Skip to content

Commit 992d74a

Browse files
committed
More subtle validation in extractTier1ReachabilityScanId
1 parent f8f4c92 commit 992d74a

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/utils/coana.mts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import type {
1111
SpawnOptions,
1212
} from '@socketsecurity/registry/lib/spawn'
1313

14+
export function extractTier1ReachabilityScanId(
15+
socketFactsFile: string,
16+
): string | undefined {
17+
const json = readJsonSync(socketFactsFile, { throws: false })
18+
const tier1ReachabilityScanId = String(json?.['tier1ReachabilityScanId'] ?? '').trim()
19+
return tier1ReachabilityScanId.length > 0
20+
? tier1ReachabilityScanId
21+
: undefined
22+
}
23+
1424
export async function spawnCoana(
1525
args: string[] | readonly string[],
1626
options?: SpawnOptions | undefined,
@@ -60,14 +70,3 @@ export async function spawnCoana(
6070
return { ok: false, data: e, message }
6171
}
6272
}
63-
64-
export function extractTier1ReachabilityScanId(
65-
socketFactsFile: string,
66-
): string | undefined {
67-
const json = readJsonSync(socketFactsFile, { throws: false })
68-
const tier1ReachabilityScanId = json?.['tier1ReachabilityScanId']
69-
return typeof tier1ReachabilityScanId === 'string' &&
70-
tier1ReachabilityScanId.length > 0
71-
? tier1ReachabilityScanId
72-
: undefined
73-
}

0 commit comments

Comments
 (0)