forked from guacsec/trustify-da-javascript-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_opts.js
More file actions
37 lines (35 loc) · 1.35 KB
/
Copy pathbatch_opts.js
File metadata and controls
37 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { getCustom } from './tools.js'
/**
* Whether to skip failed manifests and continue (default), or fail on first SBOM/validation error.
* `opts.continueOnError` overrides; env `TRUSTIFY_DA_CONTINUE_ON_ERROR=false` disables continuation.
*
* @param {{ continueOnError?: boolean, TRUSTIFY_DA_CONTINUE_ON_ERROR?: string, [key: string]: unknown }} [opts={}]
* @returns {boolean} true = collect errors (default), false = fail-fast
*/
export function resolveContinueOnError(opts = {}) {
if (typeof opts.continueOnError === 'boolean') {
return opts.continueOnError
}
const v = getCustom('TRUSTIFY_DA_CONTINUE_ON_ERROR', null, opts)
if (v != null && String(v).trim() !== '') {
return String(v).toLowerCase() !== 'false'
}
return true
}
/**
* When true, `stackAnalysisBatch` returns `{ analysis, metadata }` instead of the backend response only.
* `opts.batchMetadata` overrides; env `TRUSTIFY_DA_BATCH_METADATA=true` enables.
*
* @param {{ batchMetadata?: boolean, TRUSTIFY_DA_BATCH_METADATA?: string, [key: string]: unknown }} [opts={}]
* @returns {boolean}
*/
export function resolveBatchMetadata(opts = {}) {
if (typeof opts.batchMetadata === 'boolean') {
return opts.batchMetadata
}
const v = getCustom('TRUSTIFY_DA_BATCH_METADATA', null, opts)
if (v != null && String(v).trim() !== '') {
return String(v).toLowerCase() === 'true'
}
return false
}