Skip to content

Commit 7110cb5

Browse files
committed
Use path.basename to compare DOT_SOCKET_DOT_FACTS_JSON
1 parent c8df899 commit 7110cb5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/commands/scan/handle-create-new-scan.mts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path'
2+
13
import terminalLink from 'terminal-link'
24

35
import { debugDir } from '@socketsecurity/registry/lib/debug'
@@ -151,14 +153,19 @@ export async function handleCreateNewScan({
151153

152154
logger.success('Reachability analysis completed successfully')
153155

156+
const reachabilityReport = reachResult.data?.reachabilityReport
157+
154158
scanPaths = [
155159
...packagePaths.filter(
156160
// Ensure the .socket.facts.json isn't duplicated in case it happened
157161
// to be in the scan folder before the analysis was run.
158-
p => !p.endsWith(constants.DOT_SOCKET_DOT_FACTS_JSON),
162+
p =>
163+
path.basename(p).toLowerCase() !==
164+
constants.DOT_SOCKET_DOT_FACTS_JSON,
159165
),
160-
reachResult.data?.reachabilityReport,
166+
...(reachabilityReport ? [reachabilityReport] : []),
161167
]
168+
162169
tier1ReachabilityScanId = reachResult.data?.tier1ReachabilityScanId
163170
}
164171

src/commands/scan/perform-reachability-analysis.mts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path'
2+
13
import terminalLink from 'terminal-link'
24

35
import constants from '../../constants.mts'
@@ -86,10 +88,11 @@ export async function performReachabilityAnalysis(
8688

8789
const wasSpinning = !!spinner?.isSpinning
8890

89-
// Exclude any .socket.facts.json files that happen to be
90-
// in the scan folder before the analysis was run.
91+
// Exclude any .socket.facts.json files that happen to be in the scan
92+
// folder before the analysis was run.
9193
const filepathsToUpload = packagePaths.filter(
92-
p => !p.endsWith(constants.DOT_SOCKET_DOT_FACTS_JSON),
94+
p =>
95+
path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON,
9396
)
9497

9598
spinner?.start('Uploading manifests for reachability analysis...')
@@ -151,7 +154,7 @@ export async function performReachabilityAnalysis(
151154
...(tarHash
152155
? ['--run-without-docker', '--manifests-tar-hash', tarHash]
153156
: []),
154-
// Empty reachEcosystems implies scan all ecosystems.
157+
// Empty reachEcosystems implies scanning all ecosystems.
155158
...(reachabilityOptions.reachEcosystems.length
156159
? ['--purl-types', ...reachabilityOptions.reachEcosystems]
157160
: []),

0 commit comments

Comments
 (0)