Skip to content

Commit a1e931f

Browse files
authored
Merge branch 'main' into dependency-review
2 parents 5431556 + fc53815 commit a1e931f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/malwareMatcher.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import path from "path";
66
import zlib from "zlib";
77
import * as semver from "semver";
88

9+
// Type alias to improve readability for complex package shape
10+
type PkgLike = {
11+
purl?: string;
12+
externalRefs?: Array<{ referenceType?: string; referenceLocator?: string }>;
13+
name?: string;
14+
version?: string;
15+
versionInfo?: string;
16+
};
17+
918
const our_tool_name = "SBOM Toolkit";
1019
const our_tool_url = "https://github.com/advanced-security/github-sbom-toolkit";
1120

@@ -24,6 +33,12 @@ export interface MalwareMatch {
2433
reason: string;
2534
}
2635

36+
// Type alias for packages used in enumeratePackages
37+
export type EnumeratedPackage = SbomPackage & {
38+
externalRefs?: { referenceType?: string; referenceLocator?: string }[];
39+
versionInfo?: string;
40+
};
41+
2742
// Map GitHub ecosystem enums to purl types
2843
const ecosystemToPurlType: Record<string, string> = {
2944
ACTIONS: "githubactions",
@@ -113,11 +128,11 @@ export function matchMalware(advisories: MalwareAdvisoryNode[], sboms: Repositor
113128
const index = new Map<string, MalwareAdvisoryNode[]>();
114129
for (const adv of advisories) {
115130
// Ignore advisories that have been withdrawn
116-
if ((adv as unknown as { withdrawnAt?: string | null }).withdrawnAt) continue;
131+
if (adv.withdrawnAt) continue;
117132
// Ignore advisories older than cutoff (must be before cutoff in BOTH publishedAt & updatedAt to be excluded)
118133
if (cutoffDate) {
119-
const pub = new Date((adv as unknown as { publishedAt?: string }).publishedAt || 0);
120-
const upd = new Date((adv as unknown as { updatedAt?: string }).updatedAt || 0);
134+
const pub = new Date(adv.publishedAt || 0);
135+
const upd = new Date(adv.updatedAt || 0);
121136
if (pub < cutoffDate && upd < cutoffDate) continue;
122137
}
123138
for (const vuln of adv.vulnerabilities) {

0 commit comments

Comments
 (0)