Skip to content

Commit 810fda3

Browse files
committed
Encoding URI parts in PURL, removed unneeded code
1 parent 2339190 commit 810fda3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/malwareAdvisories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ export class MalwareAdvisorySync {
181181
request: agent ? { agent } : undefined
182182
});
183183

184-
this.cachePath = path.join(this.opts.cacheDir, CACHE_FILENAME);
184+
this.cachePath = this.opts.cacheDir ? path.join(this.opts.cacheDir, CACHE_FILENAME) : undefined;
185185
this.cache = this.loadCache();
186186
}
187187

188188
private loadCache(): MalwareAdvisoryCacheFile {
189189
if (!this.cachePath) {
190-
console.warn("No cache path defined; cannot load malware advisory cache.");
190+
console.debug("No cache path defined; cannot load malware advisory cache.");
191191
return { schemaVersion: 1, lastSync: new Date(0).toISOString(), advisories: [] };
192192
}
193193
try {

src/malwareMatcher.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,12 @@ export function matchMalware(advisories: MalwareAdvisoryNode[], sboms: Repositor
173173
const branchName = diff.head;
174174
for (const change of diff.changes) {
175175
if (change.changeType !== 'added' && change.changeType !== 'updated') continue;
176-
let p: string | undefined = (change as { purl?: string }).purl;
177-
if (!p && change.packageURL && change.packageURL.startsWith('pkg:')) p = change.packageURL;
176+
let p = change.packageURL;
178177
if (!p && change.ecosystem && change.name && change.version) {
179178
if (ecosystemsWithNamespace.has(change.ecosystem) && change.namespace) {
180-
p = `pkg:${change.ecosystem}/${change.namespace}/${change.name}${change.version ? '@' + change.version : ''}`;
179+
p = `pkg:${change.ecosystem}/${encodeURIComponent(change.namespace)}/${encodeURIComponent(change.name)}${change.version ? '@' + change.version : ''}`;
181180
} else {
182-
p = `pkg:${change.ecosystem}/${change.name}${change.version ? '@' + change.version : ''}`;
181+
p = `pkg:${change.ecosystem}/${encodeURIComponent(change.name)}${change.version ? '@' + change.version : ''}`;
183182
}
184183
}
185184
if (!p) continue;

0 commit comments

Comments
 (0)