guardskills 0.1.0-alpha.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 guardskills contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ # PRODUCTION_READINESS
2
+
3
+ This checklist tracks readiness for a production-grade `guardskills` release.
4
+
5
+ ## Readiness Scale
6
+
7
+ - `Done`: implemented and verified in this repository
8
+ - `In Progress`: partially implemented
9
+ - `Pending`: not yet implemented
10
+
11
+ ## P0 Critical (Must-have before production)
12
+
13
+ 1. Deterministic CI gating (`--ci`)
14
+ Status: `Done`
15
+
16
+ 2. Hard safety limits for resolver (timeouts, max file size/count)
17
+ Status: `Done`
18
+
19
+ 3. Stable, documented exit codes
20
+ Status: `Done`
21
+
22
+ 4. Scanner rule coverage for core malware classes
23
+ Status: `In Progress`
24
+
25
+ 5. False-positive controls with fixture regression tests
26
+ Status: `Done`
27
+
28
+ 6. End-to-end integration tests for install handoff paths
29
+ Status: `Done` (command-level integration tests in `tests/add-handoff.test.ts`)
30
+
31
+ 7. Security review of scanner bypass/evasion paths
32
+ Status: `Pending`
33
+
34
+ ## P1 High (Required for broad adoption)
35
+
36
+ 1. Versioned policy/config file (`guardskills.config.json`)
37
+ Status: `Done` (supports defaults, resolver limits, and source/override policy)
38
+
39
+ 2. Rule versioning + changelog + compatibility guarantees
40
+ Status: `Pending`
41
+
42
+ 3. Structured error taxonomy (network/auth/not-found/rate-limit)
43
+ Status: `Done`
44
+
45
+ 4. Robust retry/backoff for transient GitHub API failures
46
+ Status: `Done`
47
+
48
+ 5. Performance and memory profiling on large repositories
49
+ Status: `Pending`
50
+
51
+ 6. Signed release artifacts and provenance (supply chain hardening)
52
+ Status: `Done` (GitHub release workflow publishes with npm provenance)
53
+
54
+ ## P2 Medium (Operational maturity)
55
+
56
+ 1. Telemetry/metrics (opt-in) for false positive and miss rates
57
+ Status: `Pending`
58
+
59
+ 2. Policy presets by risk posture (balanced/strict/paranoid)
60
+ Status: `Pending`
61
+
62
+ 3. Rule documentation auto-generation from source metadata
63
+ Status: `Pending`
64
+
65
+ 4. Security benchmark corpus with periodic calibration
66
+ Status: `In Progress`
67
+
68
+ ## Implemented in this sprint
69
+
70
+ - `--ci` mode: scan + gate only, no install handoff
71
+ - Resolver controls:
72
+ - `--github-timeout-ms`
73
+ - `--github-retries`
74
+ - `--github-retry-base-ms`
75
+ - `--max-file-bytes`
76
+ - `--max-aux-files`
77
+ - `--max-total-files`
78
+ - Expanded scanner rules and markdown executable-content filtering
79
+ - Fixture tests for safe/warning/malicious/prose-only cases
80
+ - Command integration tests for installer handoff and gate behavior
81
+ - Structured resolver errors with retry/backoff strategy
82
+ - CI + release workflows and SECURITY policy
83
+ - Rulebook in `RULES.md`
84
+
85
+ ## Next 3 priorities
86
+
87
+ 1. Add repository integration tests with HTTP fixtures for resolver retries and error classes.
88
+ 2. Add scanner benchmark corpus and threshold calibration automation.
89
+ 3. Add policy versioning/migration semantics for long-term compatibility.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # guardskills
2
+
3
+ `guardskills` is a security wrapper around `skills` installation.
4
+
5
+ Instead of:
6
+
7
+ ```bash
8
+ npx skills add https://github.com/vercel-labs/skills --skill find-skills
9
+ ```
10
+
11
+ use:
12
+
13
+ ```bash
14
+ npx guardskills add https://github.com/vercel-labs/skills --skill find-skills
15
+ ```
16
+
17
+ ## What It Does
18
+
19
+ 1. Resolves a skill from GitHub.
20
+ 2. Scans resolved files for malicious patterns.
21
+ 3. Computes a risk decision (`SAFE`, `WARNING`, `UNSAFE`, `CRITICAL`, `UNVERIFIABLE`).
22
+ 4. Proceeds to `npx skills add ...` only if gate policy allows.
23
+
24
+ ## Current Readiness
25
+
26
+ - Current stage: **beta-quality**.
27
+ - Good for internal use and early adopters.
28
+ - Not final production-grade yet; see `PRODUCTION_READINESS.md`.
29
+
30
+ ## Implemented Features
31
+
32
+ - `guardskills add <repo> --skill <name>`
33
+ - GitHub resolver (`owner/repo` and `https://github.com/...`)
34
+ - Deterministic static scanner with rule matrix in `RULES.md`
35
+ - Score-based decision engine with hard-block guardrails
36
+ - Gate controls:
37
+ - `--yes` (accept warning)
38
+ - `--force` (accept unsafe)
39
+ - `--allow-unverifiable`
40
+ - Modes:
41
+ - `--dry-run` (scan + decision only)
42
+ - `--ci` (deterministic gate mode, no install handoff)
43
+ - Config file support:
44
+ - auto-load `guardskills.config.json` from current directory
45
+ - or specify explicit path with `--config <path>`
46
+ - Resolver safety controls:
47
+ - `--github-timeout-ms`
48
+ - `--github-retries`
49
+ - `--github-retry-base-ms`
50
+ - `--max-file-bytes`
51
+ - `--max-aux-files`
52
+ - `--max-total-files`
53
+ - Installer handoff to `npx skills add ...` when allowed
54
+ - Structured resolver error taxonomy + retry/backoff
55
+ - Tests:
56
+ - fixture scanner tests (`safe`, `warning`, `malicious`, `prose-only`)
57
+ - gate behavior tests
58
+ - command install-handoff integration tests
59
+ - Release hardening baseline:
60
+ - `.github/workflows/ci.yml`
61
+ - `.github/workflows/release.yml` (npm provenance publish)
62
+ - `SECURITY.md`
63
+
64
+ ## False-Positive Controls
65
+
66
+ - Markdown is scanned as executable content only:
67
+ - fenced code blocks
68
+ - command-like inline snippets
69
+ - command-style lines
70
+ - Prose-only markdown is ignored for high-risk matching.
71
+
72
+ ## Quick Start
73
+
74
+ Install dependencies and validate:
75
+
76
+ ```bash
77
+ npm install
78
+ npm run ci
79
+ npm run audit:prod
80
+ ```
81
+
82
+ Local dry-run:
83
+
84
+ ```bash
85
+ guardskills add https://github.com/vercel-labs/skills --skill find-skills --dry-run
86
+ ```
87
+
88
+ Deterministic CI gate:
89
+
90
+ ```bash
91
+ guardskills add https://github.com/vercel-labs/skills --skill find-skills --ci --json
92
+ ```
93
+
94
+ With resolver reliability controls:
95
+
96
+ ```bash
97
+ guardskills add owner/repo --skill name \
98
+ --github-timeout-ms 15000 \
99
+ --github-retries 2 \
100
+ --github-retry-base-ms 300 \
101
+ --max-file-bytes 250000 \
102
+ --max-aux-files 40 \
103
+ --max-total-files 120
104
+ ```
105
+
106
+ ## Configuration File
107
+
108
+ `guardskills` supports repository-local policy and default settings via `guardskills.config.json`.
109
+
110
+ - Default lookup: `./guardskills.config.json`
111
+ - Explicit path: `--config <path>`
112
+ - CLI flags always override config values.
113
+
114
+ Starter template:
115
+
116
+ ```json
117
+ {
118
+ "defaults": {
119
+ "strict": false,
120
+ "ci": false,
121
+ "json": false,
122
+ "yes": false,
123
+ "dryRun": false,
124
+ "force": false,
125
+ "allowUnverifiable": false
126
+ },
127
+ "resolver": {
128
+ "githubTimeoutMs": 15000,
129
+ "githubRetries": 2,
130
+ "githubRetryBaseMs": 300,
131
+ "maxFileBytes": 250000,
132
+ "maxAuxFiles": 40,
133
+ "maxTotalFiles": 120
134
+ },
135
+ "policy": {
136
+ "allowForce": true,
137
+ "allowUnverifiableOverride": true,
138
+ "allowedOwners": [],
139
+ "blockedOwners": [],
140
+ "allowedRepos": [],
141
+ "blockedRepos": []
142
+ }
143
+ }
144
+ ```
145
+
146
+ Template files are included as:
147
+
148
+ - `guardskills.config.json` (baseline default)
149
+ - `guardskills.config.example.json` (copy/reference template)
150
+
151
+ ## Exit Codes
152
+
153
+ - `0`: allowed/success
154
+ - `10`: warning not confirmed
155
+ - `20`: blocked (`UNSAFE`, `CRITICAL`, or `UNVERIFIABLE` without override)
156
+ - `30`: runtime/internal error
157
+
158
+ ## Scoring Logic (v3)
159
+
160
+ Two-layer model:
161
+
162
+ 1. Hard-block guardrails
163
+ 2. Weighted risk score (`0-100`)
164
+
165
+ Formula:
166
+
167
+ ```text
168
+ risk_score = clamp(
169
+ sum(base_points * confidence_multiplier)
170
+ + chain_bonuses
171
+ - trust_credits,
172
+ 0, 100
173
+ )
174
+ ```
175
+
176
+ Severity base points:
177
+
178
+ - `CRITICAL = 50`
179
+ - `HIGH = 25`
180
+ - `MEDIUM = 12`
181
+ - `LOW = 5`
182
+ - `INFO = 0`
183
+
184
+ Confidence multipliers:
185
+
186
+ - `high = 1.0`
187
+ - `medium = 0.7`
188
+ - `low = 0.4`
189
+
190
+ Standard thresholds:
191
+
192
+ - `0-29 SAFE`
193
+ - `30-59 WARNING`
194
+ - `60-79 UNSAFE`
195
+ - `80-100 CRITICAL`
196
+
197
+ Strict thresholds (`--strict`):
198
+
199
+ - `0-19 SAFE`
200
+ - `20-39 WARNING`
201
+ - `40-59 UNSAFE`
202
+ - `60-100 CRITICAL`
203
+
204
+ `UNVERIFIABLE` is non-scored and blocked by default unless `--allow-unverifiable`.
205
+
206
+ ## References
207
+
208
+ - `RULES.md` (scanner matrix, chain bonuses, tuning workflow)
209
+ - `PROJECT_PLAN.md` (project roadmap)
210
+ - `PRODUCTION_READINESS.md` (production checklist/status)
211
+ - `SECURITY.md` (vulnerability reporting policy)
package/RULES.md ADDED
@@ -0,0 +1,105 @@
1
+ # RULES
2
+
3
+ This document is the tuning reference for scanner behavior and scoring.
4
+
5
+ ## Scoring Map
6
+
7
+ - Severity points:
8
+ - `CRITICAL = 50`
9
+ - `HIGH = 25`
10
+ - `MEDIUM = 12`
11
+ - `LOW = 5`
12
+ - `INFO = 0`
13
+ - Confidence multipliers:
14
+ - `high = 1.0`
15
+ - `medium = 0.7`
16
+ - `low = 0.4`
17
+ - Risk formula:
18
+ - `risk = clamp(sum(base_points * confidence) + chain_bonus - trust_credits, 0, 100)`
19
+ - Trust credits:
20
+ - allowed only when no `HIGH`/`CRITICAL`
21
+ - capped at `20`
22
+
23
+ ## Decision Levels
24
+
25
+ - Standard mode:
26
+ - `0-29 SAFE`
27
+ - `30-59 WARNING`
28
+ - `60-79 UNSAFE`
29
+ - `80-100 CRITICAL`
30
+ - Strict mode:
31
+ - `0-19 SAFE`
32
+ - `20-39 WARNING`
33
+ - `40-59 UNSAFE`
34
+ - `60-100 CRITICAL`
35
+ - `UNVERIFIABLE` is separate (not scored), default block unless `--allow-unverifiable`.
36
+
37
+ ## Hard-Block Policy
38
+
39
+ A finding triggers hard block only when all are true:
40
+
41
+ - severity is `CRITICAL`
42
+ - confidence is `high`
43
+ - type is one of:
44
+ - `CREDENTIAL_EXFIL`
45
+ - `DESTRUCTIVE_OP`
46
+ - `REMOTE_CODE_EXEC`
47
+ - `PRIV_ESCALATION`
48
+
49
+ ## Scanner Rule Matrix
50
+
51
+ | Rule ID | Type | Severity | Confidence | Primary intent | False-positive notes |
52
+ |---|---|---:|---:|---|---|
53
+ | `R001_CREDENTIAL_EXFIL` | `CREDENTIAL_EXFIL` | `CRITICAL` | `high` | Detect credential read followed by outbound transfer | Requires read + network sequence, not standalone mention |
54
+ | `R002_RCE_PIPE` | `REMOTE_CODE_EXEC` | `CRITICAL` | `high` | Detect `download | interpreter` patterns | Anchored to shell-style pipeline |
55
+ | `R003_DESTRUCTIVE_FS` | `DESTRUCTIVE_OP` | `CRITICAL` | `high` | Detect destructive wipe/delete commands | Looks for dangerous targets (`/`, home, root-like paths) |
56
+ | `R004_PRIV_ESC` | `PRIV_ESCALATION` | `CRITICAL` | `high` | Detect risky `sudo` command execution | Focuses on high-risk command verbs |
57
+ | `R005_SECRET_READ` | `SECRET_READ` | `HIGH` | `medium` | Detect secret/token source access | Alone does not hard-block |
58
+ | `R006_NETWORK_POST` | `NETWORK_POST` | `MEDIUM` | `medium` | Detect outbound requests with explicit payload/body | Requires payload/body indicators |
59
+ | `R007_DECODE_EXEC` | `DECODE_EXEC` | `HIGH` | `medium` | Detect decode/deobfuscation with execution sink | Requires both decode and sink |
60
+ | `R008_ENV_ACCESS` | `ENV_ACCESS` | `LOW` | `low` | Detect env reads | Low weight by design |
61
+ | `R009_FILE_STAGE` | `FILE_STAGE` | `LOW` | `low` | Detect temp/staging writes | Low weight by design |
62
+ | `R010_DYNAMIC_EXEC` | `REMOTE_CODE_EXEC` | `HIGH` | `medium` | Detect dynamic execution primitives | Not hard-block unless promoted to critical/high-confidence |
63
+ | `R011_IEX_DOWNLOAD` | `REMOTE_CODE_EXEC` | `CRITICAL` | `high` | Detect PowerShell download-and-execute | Strong signature for malicious behavior |
64
+ | `R012_DOWNLOAD_THEN_EXEC` | `REMOTE_CODE_EXEC` | `HIGH` | `medium` | Detect downloaded artifact executed without verification | Medium confidence because some installers are legitimate |
65
+ | `R013_ENCODED_EXFIL` | `NETWORK_POST` | `HIGH` | `medium` | Detect encoded data sent externally | Requires encoded transform + network |
66
+ | `R014_ARCHIVE_FETCH_EXEC` | `REMOTE_CODE_EXEC` | `HIGH` | `medium` | Detect archive download/extract then execute flow | Can match legitimate bootstrap scripts; not hard-block by itself |
67
+ | `R015_CHMOD_THEN_EXEC` | `REMOTE_CODE_EXEC` | `HIGH` | `medium` | Detect chmod +x followed by execution | Requires local execution sequence, still may appear in installers |
68
+ | `R016_SPLIT_TOKEN_RCE` | `REMOTE_CODE_EXEC` | `CRITICAL` | `high` | Detect obfuscated split-token download-exec signatures | Targets evasion via token splitting/non-word separators |
69
+
70
+ ## Attack Chain Matrix
71
+
72
+ | Chain ID | Required finding types | Bonus | Intent |
73
+ |---|---|---:|---|
74
+ | `CHAIN_SECRET_EXFIL` | `SECRET_READ` + `NETWORK_POST` | `+25` | Credential/data exfil flow |
75
+ | `CHAIN_DECODE_EXEC` | `DECODE_EXEC` + `REMOTE_CODE_EXEC` | `+30` | Obfuscated payload execution |
76
+ | `CHAIN_ENV_STAGE_EXFIL` | `ENV_ACCESS` + `FILE_STAGE` + `NETWORK_POST` | `+20` | Staged environment exfiltration |
77
+
78
+ ## False-Positive Controls
79
+
80
+ - Markdown is scanned as executable content only:
81
+ - fenced code blocks
82
+ - inline code snippets that look command-like
83
+ - command-style lines (`$`, `PS>`, `>`, list-item command lines)
84
+ - Prose-only markdown text is ignored for high-risk matching.
85
+
86
+ ## Test Fixtures
87
+
88
+ Current fixture suite in `tests/scanner-scoring.test.ts`:
89
+
90
+ - `tests/fixtures/safe`: expected `SAFE`
91
+ - `tests/fixtures/prose-only`: expected `SAFE` (FP guard)
92
+ - `tests/fixtures/warning`: expected `WARNING` with secret+network chain
93
+ - `tests/fixtures/malicious`: expected `CRITICAL` hard block
94
+
95
+ ## Tuning Workflow
96
+
97
+ 1. Add/update a rule in `src/scanner/scan.ts`.
98
+ 2. Add fixture content that should trigger (and one that should not).
99
+ 3. Assert expected level and chain behavior in `tests/scanner-scoring.test.ts`.
100
+ 4. Run:
101
+ - `npm run typecheck`
102
+ - `npm test`
103
+ - `npm run build`
104
+ - `npm run audit:prod`
105
+ 5. If false positives increase, narrow pattern context or lower confidence/severity.
package/SECURITY.md ADDED
@@ -0,0 +1,34 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security fixes are applied to the latest pre-release and latest stable tag.
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ - Do not open public issues for suspected vulnerabilities.
10
+ - Report privately to: `security@guardskills.sh` (placeholder; replace with your real address before public launch).
11
+ - Include:
12
+ - affected version
13
+ - reproduction steps
14
+ - expected vs actual behavior
15
+ - potential impact
16
+
17
+ ## Response Targets
18
+
19
+ - Initial acknowledgment: within 72 hours
20
+ - Triage decision: within 7 days
21
+ - Fix and disclosure timeline: risk-based; critical issues prioritized
22
+
23
+ ## Scope
24
+
25
+ In scope:
26
+
27
+ - scanner bypasses that cause false negatives for malicious skills
28
+ - install-gate bypasses
29
+ - supply-chain integrity and release artifacts
30
+
31
+ Out of scope:
32
+
33
+ - vulnerabilities in third-party skill repositories themselves
34
+ - social engineering reports without technical exploit details
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("../dist/cli.cjs");