Skip to content

Commit 0839765

Browse files
author
Prince Tripathi
committed
feat: add bun.lock scanning support
- Support text-based bun.lock format (Bun v1.2+) - Parse scoped packages correctly (@scope/package) - Add 6 new test cases for bun.lock - Update documentation with lockfile support details
1 parent 987a7a9 commit 0839765

16 files changed

Lines changed: 2724 additions & 1532 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,59 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18.x, 20.x]
15+
node-version: [18.x, 20.x, 22.x]
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424

25-
- name: Test CLI Commands
25+
- name: Verify CLI Commands
2626
run: |
27-
# Test version
27+
# Test version (must succeed)
2828
node bin/cli.mjs --version
2929
30-
# Test help
30+
# Test help (must succeed)
3131
node bin/cli.mjs --help
3232
33-
# Test status
33+
# Test status (must succeed)
3434
node bin/cli.mjs status
35-
36-
# Test scan (safe package)
37-
node bin/cli.mjs scan express --logMode=quiet || true
38-
39-
# Test list
40-
node bin/cli.mjs list --logMode=quiet || true
4135
42-
- name: Test Scan Commands
36+
- name: Test Safe Package Scan
4337
run: |
44-
# Create test package.json
45-
echo '{"name":"test","version":"1.0.0","dependencies":{"express":"^4.18.0"}}' > package.json
46-
47-
# Test scanning package.json
48-
node bin/cli.mjs scan package.json --logMode=quiet || true
49-
50-
# Test scanning lockfile (if exists)
51-
if [ -f package-lock.json ]; then
52-
node bin/cli.mjs scan package-lock.json --logMode=quiet || true
38+
# Scan safe package (should pass, exit 0)
39+
node bin/cli.mjs scan lodash@4.17.21 --skipNpmAudit=true --enableOsv=false --enableGitHub=false --logMode=quiet
40+
41+
- name: Test Compromised Package Detection
42+
run: |
43+
# Scan compromised package (should fail, exit 1)
44+
if node bin/cli.mjs scan get-them-args@1.3.3 --skipNpmAudit=true --enableOsv=false --enableGitHub=false --logMode=quiet 2>&1; then
45+
echo "ERROR: Compromised package was NOT blocked!"
46+
exit 1
47+
else
48+
echo "SUCCESS: Compromised package was correctly blocked"
5349
fi
50+
51+
- name: Test List Command
52+
run: |
53+
# List compromised packages (must succeed)
54+
node bin/cli.mjs list --logMode=quiet
55+
56+
- name: Test Repository Scan
57+
run: |
58+
# Create test package.json with safe dependencies
59+
mkdir -p test-repo
60+
echo '{"name":"test","version":"1.0.0","dependencies":{"lodash":"4.17.21"}}' > test-repo/package.json
61+
62+
# Scan test repository (should pass)
63+
node bin/cli.mjs scan test-repo --skipNpmAudit=true --enableOsv=false --enableGitHub=false --logMode=quiet
5464
55-
# Test scanning repository
56-
node bin/cli.mjs scan --logMode=quiet || true
65+
# Cleanup
66+
rm -rf test-repo
67+
68+
- name: Run Smoke Tests
69+
run: npm run test:smoke
5770

CONTRIBUTING.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Thank you for your interest in contributing! This document provides guidelines f
55
## Getting Started
66

77
1. Fork the repository
8-
2. Clone your fork: `git clone <your-fork-url>`
8+
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/sentinel.git`
99
3. Create a branch: `git checkout -b feature/your-feature-name`
1010
4. Make your changes
1111
5. Test your changes
@@ -15,7 +15,7 @@ Thank you for your interest in contributing! This document provides guidelines f
1515

1616
```bash
1717
# Clone the repository
18-
git clone <repository-url>
18+
git clone https://github.com/ds-horizon/sentinel.git
1919
cd sentinel
2020

2121
# No dependencies needed - uses only Node.js built-ins
@@ -26,15 +26,19 @@ cd sentinel
2626

2727
```bash
2828
# Run comprehensive test suite (recommended)
29-
npm test
29+
npm test # Host + local source
3030

31-
# Or run from tests folder
32-
./tests/test.sh
31+
# Docker testing (safe isolation)
32+
npm run test:docker # Docker + local source
33+
npm run test:docker:npm # Docker + npm package
3334

3435
# Quick smoke tests
3536
npm run test:smoke
3637

37-
# All tests are automated - see tests/README.md for details
38+
# Or directly from sample-test-repo/
39+
./tests/test.sh # Host + local source
40+
./tests/test.sh --docker # Docker + local source
41+
./tests/test.sh --docker --npm # Docker + npm package
3842
```
3943

4044
## Code Style

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Sentinel Package Manager is the **ONLY tool** that blocks compromised packages *
4545
|--------|----------|---------|
4646
| **npm Global** | Individual developers | `npm install -g sentinel` |
4747
| **Dev Dependency** | Team projects, CI/CD | `npm install --save-dev sentinel` |
48-
| **Git Clone** | Development, contributing | `git clone <repo> && ./bin/install.sh` |
48+
| **Git Clone** | Development, contributing | `git clone https://github.com/ds-horizon/sentinel.git && cd sentinel && ./bin/install.sh` |
4949

5050
---
5151

@@ -91,7 +91,7 @@ npx sentinel scan
9191
### Option 3: Git Clone & Install (Manual Setup)
9292
```bash
9393
# Clone and install
94-
git clone <repository-url>
94+
git clone https://github.com/ds-horizon/sentinel.git
9595
cd sentinel
9696
./bin/install.sh
9797

@@ -115,12 +115,14 @@ yarn add package-name
115115

116116
## 📋 Supported Package Managers
117117

118-
| Package Manager | Support | Auto-Validation |
119-
|----------------|---------|-----------------|
120-
| **npm** | ✅ Full | ✅ Yes |
121-
| **yarn** | ✅ Full | ✅ Yes |
122-
| **pnpm** | ✅ Full | ✅ Yes |
123-
| **bun** | ✅ Full | ✅ Yes |
118+
| Package Manager | Support | Auto-Validation | Lockfile Scanning |
119+
|----------------|---------|-----------------|-------------------|
120+
| **npm** | ✅ Full | ✅ Yes |`package-lock.json` |
121+
| **yarn** | ✅ Full | ✅ Yes |`yarn.lock` (v1 + v4) |
122+
| **pnpm** | ✅ Full | ✅ Yes |`pnpm-lock.yaml` (v5 + v6) |
123+
| **bun** | ✅ Full | ✅ Yes |`bun.lock` (v1.2+) |
124+
125+
> **Note:** Bun's binary lockfile (`bun.lockb`) is not supported. Use the text-based `bun.lock` format (default in Bun v1.2+) or run `bun install --save-text-lockfile` to migrate.
124126
125127
## ✨ Key Features
126128

0 commit comments

Comments
 (0)