Skip to content

Commit 5026c51

Browse files
committed
fix(sea): add Socket Firewall (sfw) to VFS bundling
Added missing sfw (Socket Firewall) tool to SEA binary builds: - Updated external-tools.json: Changed sfw from standalone to github-release type with SocketDev/sfw-free repository and v1.6.0 version - Added sfw to all platform mappings (8 platforms supported): - darwin-arm64, darwin-x64: Native binaries - linux-arm64, linux-x64: Native glibc binaries - linux-arm64-musl, linux-x64-musl: Native musl binaries - windows-arm64, windows-x64: x64 binaries (ARM64 uses emulation) - Enhanced downloads.mjs to handle standalone binaries that don't require extraction (sfw binaries are not compressed, unlike other tools) This fixes "File not found in VFS: /snapshot/sfw" error when running socket-cli SEA binaries with npm/npx/pnpm/yarn commands. Previous behavior: - sfw declared in EXTERNAL_TOOLS but never bundled into VFS - SEA binaries failed with VFS extraction error - Regular node cli.js worked (downloaded sfw via dlx) New behavior: - sfw downloaded from SocketDev/sfw-free releases during SEA build - sfw bundled into VFS alongside other security tools - SEA binaries can extract and use sfw from embedded VFS Sources: - https://github.com/SocketDev/sfw-free - https://docs.socket.dev/docs/socket-firewall-free
1 parent 0245f37 commit 5026c51

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

packages/cli/external-tools.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
},
4747
"sfw": {
4848
"description": "Socket Firewall (sfw)",
49-
"type": "standalone",
50-
"version": "2.0.4"
49+
"type": "github-release",
50+
"repository": "SocketDev/sfw-free",
51+
"version": "v1.6.0"
5152
},
5253
"synp": {
5354
"description": "Tool for converting between yarn.lock and package-lock.json",

packages/cli/scripts/constants/external-tools-platforms.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const PLATFORM_MAP_TOOLS = {
3737
opengrep: 'opengrep-core_osx_aarch64.tar.gz',
3838
python:
3939
'cpython-3.11.14+20260203-aarch64-apple-darwin-install_only.tar.gz',
40+
sfw: 'sfw-free-macos-arm64',
4041
trivy: 'trivy_0.69.1_macOS-ARM64.tar.gz',
4142
trufflehog: 'trufflehog_3.93.1_darwin_arm64.tar.gz',
4243
},
@@ -47,6 +48,7 @@ export const PLATFORM_MAP_TOOLS = {
4748
opengrep: 'opengrep-core_osx_x86.tar.gz',
4849
python:
4950
'cpython-3.11.14+20260203-x86_64-apple-darwin-install_only.tar.gz',
51+
sfw: 'sfw-free-macos-x86_64',
5052
trivy: 'trivy_0.69.1_macOS-64bit.tar.gz',
5153
trufflehog: 'trufflehog_3.93.1_darwin_amd64.tar.gz',
5254
},
@@ -57,6 +59,7 @@ export const PLATFORM_MAP_TOOLS = {
5759
opengrep: 'opengrep-core_linux_aarch64.tar.gz',
5860
python:
5961
'cpython-3.11.14+20260203-aarch64-unknown-linux-gnu-install_only.tar.gz',
62+
sfw: 'sfw-free-linux-arm64',
6063
trivy: 'trivy_0.69.1_Linux-ARM64.tar.gz',
6164
trufflehog: 'trufflehog_3.93.1_linux_arm64.tar.gz',
6265
},
@@ -67,6 +70,7 @@ export const PLATFORM_MAP_TOOLS = {
6770
opengrep: 'opengrep-core_linux_aarch64.tar.gz',
6871
python:
6972
'cpython-3.11.14+20260203-aarch64-unknown-linux-musl-install_only.tar.gz',
73+
sfw: 'sfw-free-musl-linux-arm64',
7074
trivy: 'trivy_0.69.1_Linux-ARM64.tar.gz',
7175
trufflehog: 'trufflehog_3.93.1_linux_arm64.tar.gz',
7276
},
@@ -77,6 +81,7 @@ export const PLATFORM_MAP_TOOLS = {
7781
opengrep: 'opengrep-core_linux_x86.tar.gz',
7882
python:
7983
'cpython-3.11.14+20260203-x86_64-unknown-linux-gnu-install_only.tar.gz',
84+
sfw: 'sfw-free-linux-x86_64',
8085
trivy: 'trivy_0.69.1_Linux-64bit.tar.gz',
8186
trufflehog: 'trufflehog_3.93.1_linux_amd64.tar.gz',
8287
},
@@ -87,17 +92,19 @@ export const PLATFORM_MAP_TOOLS = {
8792
opengrep: 'opengrep-core_linux_x86.tar.gz',
8893
python:
8994
'cpython-3.11.14+20260203-x86_64-unknown-linux-musl-install_only.tar.gz',
95+
sfw: 'sfw-free-musl-linux-x86_64',
9096
trivy: 'trivy_0.69.1_Linux-64bit.tar.gz',
9197
trufflehog: 'trufflehog_3.93.1_linux_amd64.tar.gz',
9298
},
9399

94100
// Windows ARM64 - Python and TruffleHog are native arm64.
95-
// Trivy and OpenGrep use x64 binaries (Windows 11 ARM64 emulates x64).
101+
// Trivy, OpenGrep, and sfw use x64 binaries (Windows 11 ARM64 emulates x64).
96102
'windows-arm64': {
97103
__proto__: null,
98104
opengrep: 'opengrep-core_windows_x86.zip', // x64 emulated.
99105
python:
100106
'cpython-3.11.14+20260203-aarch64-pc-windows-msvc-install_only.tar.gz', // native arm64.
107+
sfw: 'sfw-free-windows-x86_64.exe', // x64 emulated.
101108
trivy: 'trivy_0.69.1_windows-64bit.zip', // x64 emulated.
102109
trufflehog: 'trufflehog_3.93.1_windows_arm64.tar.gz', // native arm64.
103110
},
@@ -108,6 +115,7 @@ export const PLATFORM_MAP_TOOLS = {
108115
opengrep: 'opengrep-core_windows_x86.zip',
109116
python:
110117
'cpython-3.11.14+20260203-x86_64-pc-windows-msvc-install_only.tar.gz',
118+
sfw: 'sfw-free-windows-x86_64.exe',
111119
trivy: 'trivy_0.69.1_windows-64bit.zip',
112120
trufflehog: 'trufflehog_3.93.1_windows_amd64.tar.gz',
113121
},

packages/cli/scripts/sea-build-utils/downloads.mjs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,35 @@ export async function downloadExternalTools(platform, arch, isMusl = false) {
316316
retryDelay: 5000,
317317
})
318318

319-
// Extract binary.
320-
logger.log(` Extracting ${toolName}...`)
319+
// Extract binary (or handle standalone binaries).
321320
const isZip = assetName.endsWith('.zip')
321+
const isTarGz = assetName.endsWith('.tar.gz') || assetName.endsWith('.tgz')
322+
const isStandalone = !isZip && !isTarGz
323+
324+
if (isStandalone) {
325+
// Standalone binary (e.g., sfw) - already downloaded, just rename if needed.
326+
logger.log(` Preparing ${toolName}...`)
327+
if (archivePath !== binaryPath) {
328+
try {
329+
await fs.rename(archivePath, binaryPath)
330+
} catch (e) {
331+
// Fallback to copy + delete for cross-device moves.
332+
await fs.copyFile(archivePath, binaryPath)
333+
await fs.unlink(archivePath)
334+
}
335+
}
336+
337+
// Make executable on Unix.
338+
if (!isPlatWin) {
339+
await fs.chmod(binaryPath, 0o755)
340+
}
341+
342+
toolNames.push(binaryName)
343+
logger.log(` ✓ ${toolName} ready`)
344+
continue
345+
}
346+
347+
logger.log(` Extracting ${toolName}...`)
322348

323349
if (isZip) {
324350
// Use unzip command.

0 commit comments

Comments
 (0)