|
13 | 13 | */ |
14 | 14 |
|
15 | 15 | import { createHash } from 'node:crypto' |
16 | | -import { existsSync, promises as fs } from 'node:fs' |
17 | 16 | import { homedir } from 'node:os' |
18 | 17 | import path from 'node:path' |
19 | 18 |
|
20 | 19 | import { debug } from '@socketsecurity/lib/debug' |
21 | | -import { safeDelete, safeMkdir } from '@socketsecurity/lib/fs' |
22 | 20 | import { getDefaultLogger } from '@socketsecurity/lib/logger' |
23 | 21 | import { normalizePath } from '@socketsecurity/lib/paths/normalize' |
24 | 22 | import { spawn } from '@socketsecurity/lib/spawn' |
25 | 23 |
|
26 | 24 | import { UPDATE_STORE_DIR } from '../../constants/paths.mts' |
27 | | -import { getOpengrepVersion } from '../../env/opengrep-version.mts' |
28 | | -import { getPyCliVersion } from '../../env/pycli-version.mts' |
29 | 25 | import { getPythonMajorMinor } from '../../env/python-version.mts' |
30 | | -import { getTrivyVersion } from '../../env/trivy-version.mts' |
31 | | -import { getTrufflehogVersion } from '../../env/trufflehog-version.mts' |
32 | 26 | import { isSeaBinary } from '../sea/detect.mts' |
33 | 27 |
|
34 | 28 | const logger = getDefaultLogger() |
@@ -167,7 +161,9 @@ export async function extractBasicsTools( |
167 | 161 |
|
168 | 162 | const isPlatWin = process.platform === 'win32' |
169 | 163 | const tools = BASICS_TOOLS |
170 | | - const extractedPaths: Record<string, string> = {} |
| 164 | + const extractedPaths: Partial< |
| 165 | + Record<(typeof BASICS_TOOLS)[number], string> |
| 166 | + > = {} |
171 | 167 |
|
172 | 168 | try { |
173 | 169 | // Extract all tools using process.smol.mount(). |
@@ -195,9 +191,14 @@ export async function extractBasicsTools( |
195 | 191 | // Validate all extracted binaries work after extraction. |
196 | 192 | logger.group('Validating extracted basics tools...') |
197 | 193 |
|
| 194 | + const pythonRoot = extractedPaths['python'] |
| 195 | + if (!pythonRoot) { |
| 196 | + throw new Error('Failed to extract python from VFS') |
| 197 | + } |
| 198 | + |
198 | 199 | const pythonExe = isPlatWin ? 'python3.exe' : 'python3' |
199 | 200 | const pythonPath = normalizePath( |
200 | | - path.join(extractedPaths.python, 'bin', pythonExe), |
| 201 | + path.join(pythonRoot, 'bin', pythonExe), |
201 | 202 | ) |
202 | 203 |
|
203 | 204 | const validateResult = await spawn(pythonPath, ['--version'], { |
@@ -239,7 +240,7 @@ export async function extractBasicsTools( |
239 | 240 |
|
240 | 241 | logger.success('Basics tools extracted and validated') |
241 | 242 | // Return the Python directory path for backward compatibility. |
242 | | - return extractedPaths.python |
| 243 | + return pythonRoot |
243 | 244 | } catch (e) { |
244 | 245 | logger.error('VFS extraction failed') |
245 | 246 | throw e |
|
0 commit comments