scriptinel 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +136 -27
  2. package/package.json +3 -4
package/README.md CHANGED
@@ -4,10 +4,28 @@
4
4
  > Default-deny lifecycle scripts with explicit, reviewable allowlists.
5
5
 
6
6
  [![npm version](https://img.shields.io/npm/v/scriptinel)](https://www.npmjs.com/package/scriptinel)
7
+ [![npm downloads](https://img.shields.io/npm/dw/scriptinel)](https://www.npmjs.com/package/scriptinel)
7
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
9
 
9
10
  Scriptinel blocks all npm lifecycle scripts (`preinstall`, `install`, `postinstall`) unless they are explicitly approved via a policy file committed to your repository. This provides a controlled middle ground between running everything blindly (high risk) and disabling scripts entirely (breaks builds).
10
11
 
12
+ ## Table of Contents
13
+
14
+ - [Quick Start](#quick-start)
15
+ - [Why Scriptinel?](#why-scriptinel)
16
+ - [Requirements](#requirements)
17
+ - [Installation](#installation)
18
+ - [Usage](#usage)
19
+ - [Policy File](#policy-file)
20
+ - [CLI Reference](#cli-reference)
21
+ - [Operating Modes](#operating-modes)
22
+ - [Examples](#examples)
23
+ - [Comparison with Alternatives](#comparison-with-alternatives)
24
+ - [Security Considerations](#security-considerations)
25
+ - [Troubleshooting](#troubleshooting)
26
+ - [Contributing](#contributing)
27
+ - [Documentation](#documentation)
28
+
11
29
  ## Quick Start
12
30
 
13
31
  ```bash
@@ -99,18 +117,24 @@ This automatically:
99
117
 
100
118
  ### CI Integration
101
119
 
102
- Add Scriptinel to your CI pipeline to enforce policy:
120
+ Add Scriptinel to your CI pipeline to enforce policy. This is where Scriptinel provides the most value—preventing unapproved scripts from running in production builds.
103
121
 
104
122
  ```yaml
105
123
  # .github/workflows/ci.yml
106
- - name: Scriptinel
124
+ - name: Install dependencies safely
125
+ run: npm ci --ignore-scripts
126
+
127
+ - name: Run Scriptinel
107
128
  run: npx scriptinel --ci
108
129
  ```
109
130
 
110
- In CI mode:
111
- - Unapproved scripts cause the build to fail (exit code 1)
112
- - Policy violations are clearly reported
113
- - Builds pass only when all scripts are approved
131
+ **CI mode behavior:**
132
+ - Unapproved scripts cause the build to fail (exit code 1)
133
+ - Policy violations are clearly reported with actionable messages
134
+ - Builds pass only when all scripts are explicitly approved
135
+ - ✅ Policy file must be committed to version control
136
+
137
+ This ensures that **no unapproved scripts can run in your CI/CD pipeline**, providing a critical security layer.
114
138
 
115
139
  ### Audit Mode
116
140
 
@@ -125,6 +149,22 @@ Useful for:
125
149
  - Generating reports for security audits
126
150
  - Understanding script usage across dependencies
127
151
 
152
+ ## Operating Modes
153
+
154
+ Scriptinel operates in three distinct modes, each with specific behavior:
155
+
156
+ | Mode | Command | Behavior | Exit Code on Violations | Scripts Execute? |
157
+ |------|---------|----------|------------------------|------------------|
158
+ | **Default** | `npx scriptinel` | Warns on violations, continues | `0` (warns only) | Yes (approved only) |
159
+ | **CI** | `npx scriptinel --ci` | Fails on violations | `1` (fails build) | Yes (approved only) |
160
+ | **Audit** | `npx scriptinel --audit` | Reports only, no blocking | `0` (always succeeds) | No |
161
+
162
+ ### When to Use Each Mode
163
+
164
+ - **Default mode**: Local development, first-time setup, exploring dependencies
165
+ - **CI mode**: Continuous integration pipelines, automated testing, production builds
166
+ - **Audit mode**: Security reviews, compliance checks, understanding script usage
167
+
128
168
  ## Policy File
129
169
 
130
170
  Scriptinel uses `install-scripts.policy.json` in your project root:
@@ -154,10 +194,15 @@ Scriptinel uses `install-scripts.policy.json` in your project root:
154
194
 
155
195
  ### Policy Rules
156
196
 
157
- - Exact package names only (no wildcards)
158
- - Explicit script names only (`preinstall`, `install`, `postinstall`)
159
- - Policy file should be committed to version control
160
- - Policy changes require explicit approval
197
+ The policy file is the **core contract** between you and Scriptinel. It must be:
198
+
199
+ - **Exact package names only** - No wildcards, no patterns, case-sensitive matching
200
+ - **Explicit script names only** - Must specify `preinstall`, `install`, or `postinstall` exactly
201
+ - **Version-controlled** - Policy file should be committed to git for team consistency
202
+ - **Reviewable** - Policy changes appear in git diffs, enabling code review
203
+ - **Deterministic** - Same policy file always produces same behavior
204
+
205
+ > **Why no wildcards?** Security tools require predictability. Wildcards introduce ambiguity and make it harder to audit what's actually approved.
161
206
 
162
207
  ## CLI Reference
163
208
 
@@ -231,6 +276,7 @@ jobs:
231
276
  test:
232
277
  image: node:20
233
278
  script:
279
+ - npm ci --ignore-scripts
234
280
  - npx scriptinel --ci
235
281
  - npm test
236
282
  ```
@@ -244,6 +290,7 @@ jobs:
244
290
  - image: node:20
245
291
  steps:
246
292
  - checkout
293
+ - run: npm ci --ignore-scripts
247
294
  - run: npx scriptinel --ci
248
295
  - run: npm test
249
296
  ```
@@ -272,33 +319,95 @@ Check that:
272
319
 
273
320
  ## Security Considerations
274
321
 
275
- Scriptinel follows security best practices:
322
+ Scriptinel is designed with security-first principles. Here's what we **guarantee**:
323
+
324
+ ### Security Guarantees
325
+
326
+ ✅ **No shell injection risk** - Never uses `shell: true`, always uses explicit command execution
327
+ ✅ **Strict input validation** - All package names and script names are validated
328
+ ✅ **No network calls** - Zero network activity during install phase
329
+ ✅ **No dynamic execution** - No `eval()`, `Function()`, or dynamic `require()`
330
+ ✅ **No environment mutation** - Does not modify system environment variables
331
+ ✅ **Deterministic behavior** - Same input always produces same output
332
+ ✅ **Zero runtime dependencies** - Uses only Node.js built-ins (reduces attack surface)
276
333
 
277
- - Never uses `shell: true` (prevents shell injection)
278
- - Validates all package names strictly
279
- - No network calls during install phase
280
- - No dynamic code execution
281
- - No environment mutation
334
+ ### What Scriptinel Does NOT Do
335
+
336
+ Scan for known vulnerabilities (use `npm audit` or Snyk)
337
+ Monitor runtime behavior (use runtime security tools)
338
+ Analyze package contents (use static analysis tools)
339
+ ❌ Replace dependency management (works with npm/yarn/pnpm)
340
+
341
+ Scriptinel's scope is **install-time script execution control**—nothing more, nothing less.
282
342
 
283
343
  ## Contributing
284
344
 
285
- Contributions are welcome! Please read our contributing guidelines and code of conduct.
345
+ Contributions are welcome and help make Scriptinel better for everyone.
346
+
347
+ ### How to Contribute
286
348
 
287
- 1. Fork the repository
288
- 2. Create a feature branch
289
- 3. Make your changes
290
- 4. Add tests
291
- 5. Submit a pull request
349
+ 1. **Fork the repository** and clone your fork
350
+ 2. **Create a feature branch**: `git checkout -b feature/your-feature-name`
351
+ 3. **Make your changes** following our [coding rules](.cursor/rules/scriptinel_npm_plugin_coding_rules.md)
352
+ 4. **Add tests** for new functionality
353
+ 5. **Run the test suite**: `npm test`
354
+ 6. **Submit a pull request** with a clear description
355
+
356
+ ### Development Setup
357
+
358
+ ```bash
359
+ # Clone and setup
360
+ git clone https://github.com/dxmari/scriptinel.git
361
+ cd scriptinel
362
+ npm install
363
+
364
+ # Run tests
365
+ npm test
366
+
367
+ # Build
368
+ npm run build
369
+ ```
370
+
371
+ ### Code Standards
372
+
373
+ - Follow TypeScript strict mode
374
+ - Functions ≤ 25 lines, files ≤ 200 lines
375
+ - No `any` types
376
+ - Pure functions by default
377
+ - See [coding rules](.cursor/rules/scriptinel_npm_plugin_coding_rules.md) for details
378
+
379
+ ### Reporting Issues
380
+
381
+ Found a bug or have a suggestion? Please [open an issue](https://github.com/dxmari/scriptinel/issues) with:
382
+ - Clear description of the problem
383
+ - Steps to reproduce
384
+ - Expected vs actual behavior
385
+ - Environment details (Node.js version, OS, etc.)
292
386
 
293
387
  ## License
294
388
 
295
389
  MIT License - see [LICENSE](LICENSE) file for details.
296
390
 
297
- ## Related Projects
391
+ ## Comparison with Alternatives
392
+
393
+ Scriptinel focuses specifically on **install-time script execution control**, which complements but differs from other security tools:
394
+
395
+ | Tool | Primary Focus | Scriptinel Advantage |
396
+ |------|--------------|---------------------|
397
+ | **npm audit** | Vulnerability scanning (known CVEs) | Controls script execution, not just vulnerabilities |
398
+ | **Snyk** | Software Composition Analysis (SCA) | Install-time enforcement, policy-driven blocking |
399
+ | **Dependabot** | Automated dependency updates | Prevents malicious scripts from running during updates |
400
+ | **Scriptinel** | Script firewall | Default-deny with explicit approvals, CI-enforced |
401
+
402
+ ### Why Use Scriptinel?
403
+
404
+ - **Complements existing tools**: Works alongside npm audit and Snyk
405
+ - **Install-time protection**: Blocks malicious scripts before they execute
406
+ - **Policy-driven**: Reviewable, version-controlled approvals
407
+ - **CI-enforced**: Fails builds on unapproved scripts
408
+ - **Zero-config**: Works immediately with `npx scriptinel`
298
409
 
299
- - [npm-audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) - Dependency vulnerability scanning
300
- - [snyk](https://snyk.io/) - Security scanning and monitoring
301
- - [dependabot](https://dependabot.com/) - Automated dependency updates
410
+ Scriptinel is not a replacement for vulnerability scanning—use it **together** with npm audit or Snyk for comprehensive security.
302
411
 
303
412
  ## Documentation
304
413
 
@@ -316,4 +425,4 @@ MIT License - see [LICENSE](LICENSE) file for details.
316
425
 
317
426
  ---
318
427
 
319
- Made with ❤️ for secure npm installs
428
+ **Scriptinel** - Making npm install safe by default.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scriptinel",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Install script firewall for npm - default-deny lifecycle scripts with explicit, reviewable allowlists",
5
5
  "keywords": [
6
6
  "npm",
@@ -21,7 +21,7 @@
21
21
  "main": "./dist/index.js",
22
22
  "types": "./dist/index.d.ts",
23
23
  "bin": {
24
- "scriptinel": "./bin/scriptinel"
24
+ "scriptinel": "bin/scriptinel"
25
25
  },
26
26
  "files": [
27
27
  "bin",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "repository": {
48
48
  "type": "git",
49
- "url": "https://github.com/dxmari/scriptinel.git"
49
+ "url": "git+https://github.com/dxmari/scriptinel.git"
50
50
  },
51
51
  "bugs": {
52
52
  "url": "https://github.com/dxmari/scriptinel/issues"
@@ -62,4 +62,3 @@
62
62
  "vitest": "^1.6.0"
63
63
  }
64
64
  }
65
-