Skip to content

Commit 5ee16bb

Browse files
authored
fix: [CN-436] go binaries in linux image not scanned on windows (#720)
* fix: [CN-436] some go binaries in linux image not scanned on windows
1 parent 881a5ef commit 5ee16bb

File tree

5 files changed

+674
-3
lines changed

5 files changed

+674
-3
lines changed

lib/go-parser/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ export const DEP_GRAPH_TYPE = "gomodules";
3737
function filePathMatches(filePath: string): boolean {
3838
const normalizedPath = path.normalize(filePath);
3939
const dirName = path.dirname(normalizedPath);
40-
return (
41-
!path.parse(normalizedPath).ext &&
42-
!ignoredPaths.some((ignorePath) => dirName.startsWith(ignorePath))
40+
const forwardSlashedPath = filePath.replace(/\\/g, "/");
41+
42+
// Fix backslash path extension detection false positives: path.parse().ext incorrectly detects extensions in paths with backslashes (usually on Windows)
43+
const hasExtension = !!path.posix.parse(forwardSlashedPath).ext;
44+
const isInIgnoredPath = ignoredPaths.some((ignorePath) =>
45+
dirName.startsWith(ignorePath),
4346
);
47+
48+
return !hasExtension && !isInIgnoredPath;
4449
}
4550

4651
export const getGoModulesContentAction: ExtractAction = {
5.51 MB
Binary file not shown.

0 commit comments

Comments
 (0)