Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/check-package-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function addEntry(value, label) {
throw new Error(`Invalid package ${label} entry: ${JSON.stringify(value)}`);
}
const path = normalize(value.replace(/^\.\//, ''));
if (path === '..' || path.startsWith(`..${join('', '/')}`) || path.startsWith('/')) {
if (path === '..' || path.startsWith(`..${join('', '/')}`) || path.startsWith('/') || path.split(/[\\/]+/).includes('..')) {
throw new Error(`Package ${label} entry must stay inside the package: ${value}`);
}
required.add(path);
Expand Down
7 changes: 7 additions & 0 deletions test/package-content.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ test('package content checker rejects package entry paths outside the package',
assert.notEqual(result.status, 0);
assert.match(result.stderr, /must stay inside the package/);
});

test('package content checker rejects internal traversal after normalization', (t) => {
const pkg = { ...packageJson, bin: { atomcommit: 'src/../../outside.js' }, main: undefined, exports: {} };
const result = runChecker(t, pkg);
assert.notEqual(result.status, 0);
assert.match(result.stderr, /must stay inside the package/);
});