@@ -4,12 +4,16 @@ import { pluralize } from '@socketsecurity/registry/lib/words'
44
55import { fetchCreateOrgFullScan } from './fetch-create-org-full-scan.mts'
66import { fetchSupportedScanFileNames } from './fetch-supported-scan-file-names.mts'
7+ import { finalizeTier1Scan } from './finalize-tier1-scan.mts'
78import { handleScanReport } from './handle-scan-report.mts'
89import { outputCreateNewScan } from './output-create-new-scan.mts'
910import constants from '../../constants.mts'
1011import { handleApiCall } from '../../utils/api.mts'
1112import { checkCommandInput } from '../../utils/check-input.mts'
12- import { spawnCoana } from '../../utils/coana.mts'
13+ import {
14+ extractTier1ReachabilityScanId ,
15+ spawnCoana ,
16+ } from '../../utils/coana.mts'
1317import { getPackageFilesForScan } from '../../utils/path-resolve.mts'
1418import { setupSdk } from '../../utils/sdk.mts'
1519import { readOrDefaultSocketJson } from '../../utils/socketjson.mts'
@@ -112,6 +116,7 @@ export async function handleCreateNewScan({
112116 }
113117
114118 let scanPaths : string [ ] = packagePaths
119+ let tier1ReachabilityScanId : string | undefined
115120
116121 // If reachability is enabled, perform reachability analysis
117122 if ( reach ) {
@@ -131,6 +136,7 @@ export async function handleCreateNewScan({
131136 }
132137
133138 scanPaths = reachResult . data ?. scanPaths || [ ]
139+ tier1ReachabilityScanId = reachResult . data ?. tier1ReachabilityScanId
134140 }
135141
136142 const fullScanCResult = await fetchCreateOrgFullScan (
@@ -152,6 +158,15 @@ export async function handleCreateNewScan({
152158 } ,
153159 )
154160
161+ if (
162+ fullScanCResult . ok &&
163+ reach &&
164+ tier1ReachabilityScanId &&
165+ fullScanCResult . data ?. id
166+ ) {
167+ await finalizeTier1Scan ( tier1ReachabilityScanId , fullScanCResult . data ?. id )
168+ }
169+
155170 if ( fullScanCResult . ok && report ) {
156171 if ( fullScanCResult . data ?. id ) {
157172 await handleScanReport ( {
@@ -195,7 +210,9 @@ async function performReachabilityAnalysis({
195210 branchName : string
196211 outputKind : OutputKind
197212 interactive : boolean
198- } ) : Promise < CResult < { scanPaths ?: string [ ] } > > {
213+ } ) : Promise <
214+ CResult < { scanPaths ?: string [ ] ; tier1ReachabilityScanId : string | undefined } >
215+ > {
199216 logger . info ( 'Starting reachability analysis...' )
200217
201218 packagePaths = packagePaths . filter (
@@ -275,6 +292,9 @@ async function performReachabilityAnalysis({
275292 ok : true ,
276293 data : {
277294 scanPaths : [ constants . DOT_SOCKET_DOT_FACTS_JSON ] ,
295+ tier1ReachabilityScanId : extractTier1ReachabilityScanId (
296+ constants . DOT_SOCKET_DOT_FACTS_JSON ,
297+ ) ,
278298 } ,
279299 }
280300}
0 commit comments