Skip to content

Commit

Permalink
Merge pull request #634 from snyk/update-app-files-filter
Browse files Browse the repository at this point in the history
fix: filter usr dir from node app files
  • Loading branch information
davidgonor1408 authored Dec 25, 2024
2 parents 0ee88fb + 9183d5b commit aa046a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/inputs/node/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const getNodeAppFileContentAction: ExtractAction = {
function nodeJsTsAppFilePathMatches(filePath: string): boolean {
return (
!filePath.includes("node_modules/") &&
// "/usr/" should not include 1st party code
!filePath.startsWith("/usr/") &&
nodeJsTsAppFileSuffixes.some((suffix) => filePath.endsWith(suffix)) &&
!excludedNodeJsTsAppFileSuffixes.some((excludedSuffix) =>
filePath.endsWith(excludedSuffix),
Expand Down
13 changes: 5 additions & 8 deletions test/system/application-scans/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,13 @@ describe("node application scans", () => {
(fact) => fact.type === "applicationFiles",
)!.data;
expect(appFiles.length).toEqual(1);
expect(appFiles[0].fileHierarchy.length).toEqual(7);
expect(appFiles[0].fileHierarchy.length).toEqual(4);
expect(appFiles[0].language).toEqual("node");
expect(appFiles[0].fileHierarchy).toStrictEqual([
{ path: "usr/goof2/package.json" },
{ path: "usr/goof2/package-lock.json" },
{ path: "usr/goof/package.json" },
{ path: "opt/yarn-v1.22.4/bin/yarn.js" },
{ path: "opt/yarn-v1.22.4/lib/cli.js" },
{ path: "opt/yarn-v1.22.4/lib/v8-compile-cache.js" },
{ path: "opt/yarn-v1.22.4/package.json" },
{ path: "bin/yarn.js" },
{ path: "lib/cli.js" },
{ path: "lib/v8-compile-cache.js" },
{ path: "package.json" },
]);
});

Expand Down

0 comments on commit aa046a2

Please sign in to comment.