Skip to content

Commit fafe07a

Browse files
committed
test(ci): add test-sfw-blocks-malicious job using lodahs canary
New job installs `is-odd` benignly to put sfw on PATH, then runs `sfw vp install lodahs` (lodash typosquat) and asserts the install exits non-zero. `lodahs` is the same canary Socket uses in their bun-security-scanner workflow: https://github.com/SocketDev/bun-security-scanner/blob/main/.github/workflows/test.yml Verifies sfw actually intercepts malicious packages end-to-end, not just that the wrapping plumbing is wired.
1 parent 112ee5f commit fafe07a

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,49 @@ jobs:
361361
working-directory: test-project
362362
run: vp exec node -e "console.log(require('is-odd')(3))"
363363

364+
test-sfw-blocks-malicious:
365+
# Verifies sfw actually intercepts a known-malicious package, not just
366+
# that it wraps the install. Uses `lodahs` (lodash typosquat), the same
367+
# canary SocketDev's own workflows use:
368+
# https://github.com/SocketDev/bun-security-scanner/blob/main/.github/workflows/test.yml
369+
# If this job ever stops blocking, either sfw is misconfigured or the
370+
# canary itself has been delisted — swap it for another Socket-flagged
371+
# package from https://socket.dev/blog/category/threat-research.
372+
strategy:
373+
fail-fast: false
374+
matrix:
375+
version: [latest, alpha]
376+
runs-on: ubuntu-latest
377+
steps:
378+
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
379+
380+
- name: Create test project with a benign dependency
381+
shell: bash
382+
run: |
383+
mkdir -p test-project
384+
cd test-project
385+
echo '{"name":"test-project","private":true,"dependencies":{"is-odd":"^3.0.1"}}' > package.json
386+
387+
- name: Setup Vite+ (${{ matrix.version }}) with sfw and install benign dep
388+
uses: ./
389+
with:
390+
version: ${{ matrix.version }}
391+
sfw: true
392+
run-install: |
393+
- cwd: test-project
394+
cache: false
395+
396+
- name: Assert sfw blocks malicious package (lodahs typosquat of lodash)
397+
shell: bash
398+
working-directory: test-project
399+
run: |
400+
if sfw vp install lodahs; then
401+
echo "ERROR: sfw failed to block lodahs (lodash typosquat)"
402+
exit 1
403+
else
404+
echo "SUCCESS: sfw blocked lodahs as expected"
405+
fi
406+
364407
build:
365408
runs-on: ubuntu-latest
366409
steps:

0 commit comments

Comments
 (0)