Skip to content

Commit 3991ca0

Browse files
committed
Merge branch 'dependency-review' of https://github.com/advanced-security/github-sbom-toolkit into dependency-review
2 parents ca7d8b6 + dccef0c commit 3991ca0

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/componentSubmission.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export async function submitSnapshotIfPossible(opts: SubmitOpts): Promise<boolea
8181
if (!opts.quiet) console.error(chalk.red(`Failed to determine SHA for ${opts.owner}/${opts.repo} on branch ${opts.branch}`));
8282
return false;
8383
}
84-
await run(opts.octokit, tmp, opts.owner, opts.repo, sha, opts.branch, opts.componentDetectionBinPath);
85-
return true;
84+
return await run(opts.octokit, tmp, opts.owner, opts.repo, sha, opts.branch, opts.componentDetectionBinPath);
85+
8686
} catch (e) {
8787
if (!opts.quiet) console.error(chalk.red(`Component Detection failed: ${(e as Error).message}`));
8888
return false;
@@ -150,7 +150,7 @@ async function execGit(args: string[], opts: { cwd: string, quiet?: boolean }):
150150
});
151151
}
152152

153-
export async function run(octokit: Octokit, tmpDir: string, owner: string, repo: string, sha: string, ref: string, componentDetectionBinPath?: string) {
153+
export async function run(octokit: Octokit, tmpDir: string, owner: string, repo: string, sha: string, ref: string, componentDetectionBinPath?: string): Promise<boolean> {
154154

155155
const componentDetection = new ComponentDetection(octokit, '', componentDetectionBinPath);
156156

@@ -185,20 +185,22 @@ export async function run(octokit: Octokit, tmpDir: string, owner: string, repo:
185185
snapshot.addManifest(manifest);
186186
});
187187

188-
await submitSnapshot(octokit, snapshot, { owner, repo });
188+
return await submitSnapshot(octokit, snapshot, { owner, repo });
189189
}
190190

191191
/**
192192
* submitSnapshot submits a snapshot to the Dependency Submission API - vendored in from @github/dependency-submission-toolkit, to make it work at the CLI, vs in Actions.
193193
*
194-
* @param {Snapshot} snapshot
195-
* @param {Repo} repo
194+
* @param {Octokit} octokit - The Octokit instance for GitHub API requests
195+
* @param {Snapshot} snapshot - The dependency snapshot to submit
196+
* @param {Repo} repo - The repository owner and name
197+
* @returns {Promise<boolean>} true if submission was successful, false otherwise
196198
*/
197199
export async function submitSnapshot(
198200
octokit: Octokit,
199201
snapshot: Snapshot,
200202
repo: { owner: string; repo: string }
201-
) {
203+
): Promise<boolean> {
202204
console.debug('Submitting snapshot...')
203205
console.debug(snapshot.prettyJSON())
204206

@@ -220,10 +222,12 @@ export async function submitSnapshot(
220222
`Snapshot successfully created at ${response.data.created_at.toString()}` +
221223
` with id ${response.data.id}`
222224
)
225+
return true
223226
} else {
224227
console.error(
225228
`Snapshot creation failed with result: "${result}: ${response.data.message}"`
226229
)
230+
return false
227231
}
228232
} catch (error) {
229233
if (error instanceof RequestError) {
@@ -240,6 +244,6 @@ export async function submitSnapshot(
240244
console.error(error.message)
241245
if (error.stack) console.error(error.stack)
242246
}
243-
throw new Error(`Failed to submit snapshot: ${error}`)
247+
return false
244248
}
245249
}

0 commit comments

Comments
 (0)