feat: add sfw shims and checksum validation - #10
feat: add sfw shims and checksum validation#10John-David Dalton (jdalton) wants to merge 1 commit into
Conversation
0b0cd91 to
568a112
Compare
d77997c to
6a62b75
Compare
6a62b75 to
0ee13be
Compare
|
Landed on main in bad87d6. This could not be merged as-is: #14 onboarded the repo into the Socket fleet and refactored Two latent bugs were fixed during the port: One deviation: clearing the shim directory used |
Today, getting
sfwto actually inspect your installs means remembering to writesfwin front of every package-manager command in your workflow. Miss one- run: npm installand that step quietly installs withoutsfwin the path — the job is green, the protection is not there, and nothing tells you.With this change the action creates shims for the supported package managers, so
npm install,pip install,cargo fetchand friends route throughsfwon their own. Existing workflows that keep thesfwprefix still work; workflows that forget it are now covered instead of silently unprotected. Setshims: 'false'to keep the old explicit behaviour.The second half is about trusting the binary you just downloaded. The sfw binaries are now pinned to a specific release with their SHA256 checksums embedded in the action, and every download is verified against those hashes before it is cached or run. Previously there was nothing checking that the bytes you got were the bytes that were published.
Shims — which commands are covered, and how a shim avoids calling itself
Shim scripts are created for the package managers sfw supports. The free edition covers
npm,pnpm,yarn,pip,pip3,uvandcargo; enterprise addsbundler,gem,nugetandgo. Both bash and.cmdshims are written, so Windows runners work from cmd.exe and PowerShell as well as Git Bash.Each shim strips its own directory from
PATHbefore invoking sfw, so sfw resolves the real package-manager binary instead of recursing back into the shim.The shim directory is exported as
SFW_SHIM_DIR, which lets a publish workflow temporarily turn the shims off (by renaming them to.disabled) for the steps where routing throughsfwis not wanted.Checksum validation — hardcoded hashes, no second download to trust
sfw binaries are pinned to
v1.6.1, with a SHA256 recorded per platform and per edition (free and enterprise) directly in the action source. After download, the file is hashed and compared against that hardcoded value; a mismatch throws with both hashes printed rather than caching or executing the binary.This deliberately avoids fetching a separate
.sha256file, since a checksum served from the same place as the artifact proves very little.firewall-versionstill lets you override the version, but doing so now warns that checksum validation may fail, because the embedded hashes only describe the pinned release.Windows path handling — MSYS paths confused sfw on Windows runners
Git Bash on Windows runners hands out MSYS-style paths such as
/c/Users/.... sfw and PowerShell need the native form,C:\Users\..., to resolve binaries. Paths are now normalized to the native form before use.Also in this PR — input ordering and README
action.ymland insrc/main.js, so the two lists read in the same order.The test plan — unchecked; seven scenarios to confirm before merge
npm installroutes through sfwsocket-tokenshims: 'false'still requires explicitsfwprefix.cmdshim scripts work in cmd.exe and PowerShell