Skip to content

Commit bce8237

Browse files
committed
Formatted, default delay adjustments
1 parent 36a9e58 commit bce8237

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ async function main() {
1515
.option("org", { type: "string", describe: "Single organization login" })
1616
.option("base-url", { type: "string", describe: "GitHub Enterprise Server base URL, e.g. https://github.mycompany.com/api/v3" })
1717
.option("concurrency", { type: "number", default: 5 })
18-
.option("sbom-delay", { type: "number", default: 5000, describe: "Delay (ms) between SBOM fetch requests" })
19-
.option("light-delay", { type: "number", default: 500, describe: "Delay (ms) between lightweight metadata requests (org/repo listing, commit head checks)" })
18+
.option("sbom-delay", { type: "number", default: 3000, describe: "Delay (ms) between SBOM fetch requests" })
19+
.option("light-delay", { type: "number", default: 100, describe: "Delay (ms) between lightweight metadata requests (org/repo listing, commit head checks)" })
2020
.option("sbom-cache", { type: "string", describe: "Directory to read/write cached SBOM JSON files" })
2121
.option("purl", { type: "array", describe: "One or more PURL strings to search (supports suffix * wildcard after slash)" })
2222
.option("sync-sboms", { type: "boolean", default: false, describe: "Fetch SBOMs from GitHub (write to --sbom-cache if provided) instead of offline-only" })
@@ -107,10 +107,10 @@ async function main() {
107107

108108
if (argv["sync-malware"]) {
109109

110-
if (!quiet) console.log(chalk.cyan("Syncing malware advisories from GitHub Advisory Database..."));
110+
if (!quiet) console.log(chalk.cyan("Syncing malware advisories from GitHub Advisory Database..."));
111111

112112
const { added, updated, total } = await mas.sync();
113-
if (!quiet) console.log(chalk.green(`Malware advisories sync complete. Added: ${added}, Updated: ${updated}, Total cached: ${total}`));
113+
if (!quiet) console.log(chalk.green(`Malware advisories sync complete. Added: ${added}, Updated: ${updated}, Total cached: ${total}`));
114114
}
115115

116116
let malwareMatches: import("./malwareMatcher.js").MalwareMatch[] | undefined;

src/sbomCollector.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export class SbomCollector {
6060
onSecondaryRateLimitHit: () => {
6161
// Increase SBOM delay (delayMsBetweenRepos) by 10% each time to reduce pressure.
6262
const oldDelay = this.opts.delayMsBetweenRepos;
63-
const newDelay = Math.ceil(oldDelay * 1.1 + 1);
64-
this.opts.delayMsBetweenRepos = newDelay as unknown as typeof this.opts.delayMsBetweenRepos;
65-
if (!this.opts.quiet) {
66-
console.warn(chalk.yellow(`Adaptive backoff: increased SBOM delay from ${oldDelay}ms to ${newDelay}ms after secondary rate limit.`));
67-
}
63+
const newDelay = Math.ceil(oldDelay * 1.1 + 1);
64+
this.opts.delayMsBetweenRepos = newDelay as unknown as typeof this.opts.delayMsBetweenRepos;
65+
if (!this.opts.quiet) {
66+
console.warn(chalk.yellow(`Adaptive backoff: increased SBOM delay from ${oldDelay}ms to ${newDelay}ms after secondary rate limit.`));
67+
}
6868
}
6969
});
7070
}
@@ -90,7 +90,7 @@ export class SbomCollector {
9090
// find just the path for a single org, if given
9191
const loadPath = this.opts.org ? `${this.opts.loadFromDir}/${this.opts.org}` : this.opts.loadFromDir;
9292

93-
if (!this.opts.quiet) console.log(chalk.blue(`Loading SBOMs from cache at ${loadPath}`));
93+
if (!this.opts.quiet) console.log(chalk.blue(`Loading SBOMs from cache at ${loadPath}`));
9494

9595
try {
9696
this.sboms = readAll(loadPath);
@@ -131,7 +131,7 @@ export class SbomCollector {
131131
const orgRepoMap: Record<string, { name: string; pushed_at?: string; updated_at?: string; default_branch?: string }[]> = {};
132132
let totalRepos = 0;
133133
for (const org of orgs) {
134-
if (!this.opts.quiet) console.log(chalk.blue(`Listing repositories for org ${org}`));
134+
if (!this.opts.quiet) console.log(chalk.blue(`Listing repositories for org ${org}`));
135135
if (this.opts.lightDelayMs) await new Promise(r => setTimeout(r, this.opts.lightDelayMs));
136136
const repos = await this.listOrgRepos(org);
137137
orgRepoMap[org] = repos;
@@ -170,8 +170,8 @@ export class SbomCollector {
170170
const fullName = `${org}/${repo.name}`;
171171
const baseline = this.baselineMap.get(fullName.toLowerCase());
172172
let skipped = false;
173-
let pendingCommitMeta: { sha?: string; date?: string } | undefined;
174-
if (baseline && baseline.repoPushedAt && repo.pushed_at) {
173+
let pendingCommitMeta: { sha?: string; date?: string } | undefined;
174+
if (baseline && baseline.repoPushedAt && repo.pushed_at) {
175175
try {
176176
if (new Date(repo.pushed_at) <= new Date(baseline.repoPushedAt)) {
177177
// repo pushed_at unchanged -> skip

0 commit comments

Comments
 (0)