-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathhandle-ci.mts
More file actions
77 lines (71 loc) · 2.28 KB
/
handle-ci.mts
File metadata and controls
77 lines (71 loc) · 2.28 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { debugDir, debugFn } from '@socketsecurity/registry/lib/debug'
import { logger } from '@socketsecurity/registry/lib/logger'
import { getDefaultOrgSlug } from './fetch-default-org-slug.mts'
import constants from '../../constants.mts'
import {
detectDefaultBranch,
getRepoName,
gitBranch,
} from '../../utils/git.mts'
import { serializeResultJson } from '../../utils/serialize-result-json.mts'
import { handleCreateNewScan } from '../scan/handle-create-new-scan.mts'
export async function handleCi(autoManifest: boolean): Promise<void> {
debugFn('notice', 'Starting CI scan')
debugDir('inspect', { autoManifest })
const orgSlugCResult = await getDefaultOrgSlug()
if (!orgSlugCResult.ok) {
debugFn('warn', 'Failed to get default org slug')
debugDir('inspect', { orgSlugCResult })
process.exitCode = orgSlugCResult.code ?? 1
// Always assume json mode.
logger.log(serializeResultJson(orgSlugCResult))
return
}
const orgSlug = orgSlugCResult.data
const cwd = process.cwd()
const branchName = (await gitBranch(cwd)) || (await detectDefaultBranch(cwd))
const repoName = await getRepoName(cwd)
debugFn(
'notice',
`CI scan for ${orgSlug}/${repoName} on branch ${branchName}`,
)
debugDir('inspect', { orgSlug, cwd, branchName, repoName })
await handleCreateNewScan({
autoManifest,
branchName,
commitMessage: '',
commitHash: '',
committers: '',
cwd,
defaultBranch: false,
interactive: false,
orgSlug,
outputKind: 'json',
// When 'pendingHead' is true, it requires 'branchName' set and 'tmp' false.
pendingHead: true,
pullRequest: 0,
reach: {
reachAnalysisMemoryLimit: 0,
reachAnalysisTimeout: 0,
reachConcurrency: 1,
reachDebug: false,
reachDetailedAnalysisLogFile: false,
reachDisableAnalytics: false,
reachEcosystems: [],
reachEnableAnalysisSplitting: false,
reachExcludePaths: [],
reachLazyMode: false,
reachSkipCache: false,
reachUseOnlyPregeneratedSboms: false,
reachVersion: undefined,
runReachabilityAnalysis: false,
},
repoName,
readOnly: false,
report: true,
reportLevel: constants.REPORT_LEVEL_ERROR,
targets: ['.'],
// Don't set 'tmp' when 'pendingHead' is true.
tmp: false,
})
}