Skip to content

Commit 4b2e75c

Browse files
aegilopsCopilot
andauthored
Update src/malwareMatcher.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a1e931f commit 4b2e75c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/malwareMatcher.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ export function matchMalware(advisories: MalwareAdvisoryNode[], sboms: Repositor
159159
}
160160
}
161161
// Annotate with default branch for reporting (if known)
162-
return list.map(p => ({ ...p, __branch: repo.defaultBranch || undefined }));
163-
};
162+
// Some ecosystems require a namespace (e.g., Maven, NuGet)
163+
const ecosystemsWithNamespace = new Set(['maven', 'nuget', 'composer', 'golang']);
164+
if (ecosystemsWithNamespace.has(change.ecosystem) && change.namespace) {
165+
p = `pkg:${change.ecosystem}/${change.namespace}/${change.name}${change.version ? '@' + change.version : ''}`;
166+
} else {
167+
p = `pkg:${change.ecosystem}/${change.name}${change.version ? '@' + change.version : ''}`;
168+
}
164169

165170
// Enumerate packages implied by branch diffs (added/updated head-side versions)
166171
const enumerateDiffPackages = (repo: RepositorySbom): Array<{ purl: string; name?: string; ecosystem?: string; version?: string; __branch: string }> => {

0 commit comments

Comments
 (0)