Skip to content

Commit 8d93e53

Browse files
committed
Better repo handling for --repo
1 parent 3991ca0 commit 8d93e53

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async function main() {
5858
if (!args.enterprise && !args.org && !args.repo) throw new Error("Provide --enterprise, --org or --repo with --sync-sboms");
5959
if (args.enterprise && args.org) throw new Error("Specify only one of --enterprise or --org");
6060
if (args.repo && (args.enterprise || args.org)) throw new Error("Specify only one of --enterprise, --org, or --repo");
61+
if (args.repo && !(args.repo as string).includes("/")) throw new Error("--repo must be in the format owner/repo");
6162
if (syncing && !args.sbomCache) throw new Error("--sync-sboms requires --sbom-cache to write updated SBOMs to disk");
6263
} else {
6364
const malwareOnly = !!args["sync-malware"] && !args.sbomCache && !args.purl && !args["purl-file"] && !args["match-malware"] && !args.uploadSarif && !args.interactive;

src/sbomCollector.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ export class SbomCollector {
349349
renderBar();
350350
}));
351351
await Promise.all(tasks);
352-
newSboms = newSboms.filter(s => repoNames.has(s.repo) || repoNames.has(s.repo.split("/")[1]));
352+
353+
newSboms = newSboms.filter(s => {
354+
const repoToCheck = s.repo.includes("/") ? s.repo.split("/")[1] : s.repo;
355+
return repoNames.has(repoToCheck);
356+
});
353357
this.sboms.push(...newSboms);
354358
}
355359
if (this.opts.showProgressBar) process.stdout.write("\n");

0 commit comments

Comments
 (0)