@aldegad/safedeps 2.1.0 → 2.2.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/ARCHITECTURE.md +268 -462
- package/README.ko.md +168 -0
- package/README.md +88 -44
- package/ROADMAP.md +82 -87
- package/SKILL.md +13 -7
- package/bin/safedeps +385 -52
- package/lib/gates/audit.sh +36 -0
- package/lib/gates/hooks.sh +93 -0
- package/lib/gates/repo-profile.sh +60 -0
- package/lib/gates/scan.sh +94 -0
- package/lib/ledger/ledger.sh +94 -16
- package/lib/npm/closure.sh +115 -0
- package/lib/providers/providers.sh +244 -25
- package/package.json +2 -1
- package/scripts/install/install-safedeps-hooks.mjs +62 -23
- package/scripts/release-gates.sh +252 -0
- package/scripts/safedeps-post-verify.sh +167 -10
- package/scripts/safedeps-pre-guard.sh +270 -32
- package/scripts/test/e2e.sh +180 -4
- package/scripts/test/fixture-provider.mjs +21 -0
- package/scripts/test/smoke.sh +135 -10
package/ROADMAP.md
CHANGED
|
@@ -1,131 +1,126 @@
|
|
|
1
1
|
# Safedeps Roadmap
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Timeline and priorities. The **why / how** lives in [`ARCHITECTURE.md`](./ARCHITECTURE.md); the **when / what first** lives here. *(한국어 → [ROADMAP.ko.md](./ROADMAP.ko.md))*
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Scope
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
OS-level (nginx / apt / brew / system binary) 은 **별도 도구로 분리**. SRP 측면 더 깔끔.
|
|
9
|
+
Safedeps gates **development dependency installs** (npm / pip / cargo / go / gem / maven / nuget). At release time it also runs a repo-tree secret scan, dependency audit, and git-hook install/check (the lane absorbed from the former `security-release-gates`).
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
- dev = "새 기능 → install 명령 → 매번 새 패키지 진입" (install 순간 게이트가 의미 큼).
|
|
14
|
-
- OS = "기존 패키지 security update" (cron 주기 audit + RSS 알람이 더 맞음).
|
|
15
|
-
|
|
16
|
-
→ safedeps = dev 의존성 install 단계 결.
|
|
17
|
-
→ OS-level 은 별도 (가칭 `infra-cve-monitor` — 미래 v3+).
|
|
11
|
+
Out of scope: OS / system packages, container images, runtime sandboxing, registry integrity, and reputation analysis. Those are different security layers and stay in different tools — see [`ARCHITECTURE.md`](./ARCHITECTURE.md) §1 for the boundary.
|
|
18
12
|
|
|
19
13
|
---
|
|
20
14
|
|
|
21
|
-
## v1 (
|
|
22
|
-
|
|
23
|
-
**이름**: `npm-reorg-guard`
|
|
24
|
-
**Status**: shipped as v1. GitHub repo has since been renamed to `aldegad/safedeps`.
|
|
15
|
+
## v1 — `npm-reorg-guard` (shipped)
|
|
25
16
|
|
|
26
|
-
- npm
|
|
27
|
-
- PreToolUse hook
|
|
28
|
-
- PostToolUse hook
|
|
29
|
-
- 외부 vuln DB 조회 0. self-contained.
|
|
17
|
+
- npm-only, self-contained, no external advisory database.
|
|
18
|
+
- PreToolUse hook: typosquat / `curl | bash` / non-standard registry pattern blocks.
|
|
19
|
+
- PostToolUse hook: lockfile diff + install-script analysis → reorg (rollback) on suspicion.
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
- npm 만.
|
|
33
|
-
- 알려진 CVE 검사 X (pattern matching 위주).
|
|
34
|
-
- adversarial 회피 가능.
|
|
21
|
+
Limits: npm only, no CVE lookup (pattern matching), evadable by a determined adversary. The GitHub repo has since been renamed `aldegad/safedeps`.
|
|
35
22
|
|
|
36
23
|
---
|
|
37
24
|
|
|
38
|
-
## v2 —
|
|
25
|
+
## v2 — `safedeps` (shipped, v2.1.x)
|
|
39
26
|
|
|
40
|
-
|
|
41
|
-
**Status**: `ARCHITECTURE.md` v2 작성 완료, v2.1 provider/ledger 구현 시작.
|
|
27
|
+
The internal engine keeps the v1 `reorg-guard` assets.
|
|
42
28
|
|
|
43
|
-
###
|
|
44
|
-
- ecosystem 통합: npm / yarn / pnpm / pip (poetry, uv, pipenv) / cargo / go / gem / maven / nuget.
|
|
45
|
-
- **외부 vuln DB 결합**: OSV.dev (primary) + CISA KEV (hard-risk overlay) + GHSA (cross-check). NVD / deps.dev / Snyk = enrichment.
|
|
46
|
-
- **3-phase defense**:
|
|
47
|
-
1. Advisory Gate (`safedeps check`) — install 명령 *작성 전* vuln DB 조회 → 안전 spec 결정 → `~/.safedeps/approved-specs/<hash>.json` ledger 기록.
|
|
48
|
-
2. Hook Enforcement (`safedeps-pre-guard.sh`) — ledger 일치 검증.
|
|
49
|
-
3. Post-Install Reorg (`safedeps-post-verify.sh`) — v1 engine 그대로 (rollback fallback).
|
|
50
|
-
- Approved spec **TTL** (30일) + **daily re-check** cron (새 CVE 발견 시 revoke + 알람).
|
|
51
|
-
- **No silent fallback**: provider fail = fail-closed + `--allow-unverified` explicit override (observable).
|
|
29
|
+
### What changed
|
|
52
30
|
|
|
53
|
-
|
|
31
|
+
- **Multi-ecosystem**: npm / yarn / pnpm / pip (poetry, uv, pipenv) / cargo / go / gem / maven / nuget.
|
|
32
|
+
- **External advisory databases**: OSV.dev (canonical) + CISA KEV (hard-risk overlay) + GitHub Advisory (enrichment).
|
|
33
|
+
- **Three-phase defense**:
|
|
34
|
+
1. Advisory gate (`safedeps check`) — query the advisory databases before the install command is written, decide a safe spec, and record it to the `~/.safedeps/approved-specs/` ledger.
|
|
35
|
+
2. Hook enforcement (`safedeps-pre-guard.sh`) — verify the install matches the ledger.
|
|
36
|
+
3. Post-install reorg (`safedeps-post-verify.sh`) — the v1 engine, rolling back on divergence.
|
|
37
|
+
- **Approved-spec TTL** (30 days) + **daily re-check** (revoke + alert when a new CVE appears).
|
|
38
|
+
- **No silent fallback**: a provider failure is fail-closed; any override is explicit and observable.
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|---|---|---|
|
|
57
|
-
| **v2.0-doc** ✅ | `ARCHITECTURE.md` v2 작성·push | — |
|
|
58
|
-
| **v2.0-roadmap** ✅ | 이 문서 | — |
|
|
59
|
-
| **v2.1-rename** ✅ | GitHub repo rename `aldegad/npm-reorg-guard` → `aldegad/safedeps` ✅. 로컬 repo/skill id/path `safedeps` ✅. `safedeps migrate` 로 legacy `~/.npm-reorg-guard` → `~/.safedeps` 이전 + legacy hook cleanup. | v2.0-doc |
|
|
60
|
-
| **v2.1-providers** ✅ | `lib/providers/` 신규 — OSV / KEV / GHSA adapter. 단일 query interface. 응답 cache (TTL 24h). | — |
|
|
61
|
-
| **v2.1-ledger** ✅ | `lib/ledger/` 신규 — approved spec JSON I/O (atomic write, hash 계산, TTL 검사). | v2.1-providers |
|
|
62
|
-
| **v2.1-cli** ✅ | `bin/safedeps` 신규 — `check`, `ledger`, `revoke`, `re-check`, `migrate`, `version` 서브커맨드. | v2.1-providers, v2.1-ledger |
|
|
63
|
-
| **v2.1-guard-patch** ✅ | `scripts/safedeps-pre-guard.sh` 갱신 — ledger 일치 검증 추가 + v1 pattern 유지. | v2.1-ledger |
|
|
64
|
-
| **v2.1-verify-patch** ✅ | `scripts/safedeps-post-verify.sh` 갱신 — approved spec 과 lockfile diff 비교 추가 + v1 reorg 유지. | v2.1-ledger |
|
|
65
|
-
| **v2.1-multi-ecosystem** ✅ | pip / cargo / go / gem / maven / nuget 명령 파싱 + lockfile snapshot. `safedeps-pre-guard.sh` 는 install 분류와 typosquat pattern 을 확장했고, `safedeps-post-verify.sh` 는 monitored dependency files 기준으로 rollback truth 를 공유한다. | v2.1-guard-patch |
|
|
66
|
-
| **v2.1-hook-rename** ✅ | hook 파일 namespacing (`guard.sh` → `safedeps-pre-guard.sh`, `verify.sh` → `safedeps-post-verify.sh`) + cross-engine installer (`scripts/install/install-safedeps-hooks.mjs`, ~/.claude + ~/.codex 자동 등록, idempotent, --uninstall). | v2.1-cli |
|
|
67
|
-
| **v2.1-recheck-cron** ✅ | daily re-check launchd — 전체 approved spec 재 query → 새 CVE/KEV/provider-skip 시 revoke + macOS 알림. | v2.1-providers, v2.1-ledger |
|
|
68
|
-
| **v2.1-tests** ✅ | end-to-end 테스트 — fixture provider 응답 → 명령 시뮬레이션 → ledger / hook / re-check / migration 동작 검증. | 모든 v2.1 |
|
|
69
|
-
| **v2.1-release** | npm package publish (`@aldegad/safedeps`) + GitHub release v2.1.0. | 모든 v2.1 |
|
|
40
|
+
### Milestones (all shipped)
|
|
70
41
|
|
|
71
|
-
|
|
42
|
+
| Milestone | Output |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `v2.0-doc` | `ARCHITECTURE.md` v2 written and pushed. |
|
|
45
|
+
| `v2.1-rename` | Repo / skill id / paths renamed to `safedeps`; `safedeps migrate` moves legacy `~/.npm-reorg-guard` state to `~/.safedeps` and cleans up legacy hooks. |
|
|
46
|
+
| `v2.1-providers` | `lib/providers/` — OSV / KEV / GHSA adapters behind one query interface, with a 24h response cache. |
|
|
47
|
+
| `v2.1-ledger` | `lib/ledger/` — approved-spec JSON I/O (atomic write, hash, TTL check). |
|
|
48
|
+
| `v2.1-cli` | `bin/safedeps` — `check`, `ledger`, `revoke`, `re-check`, `migrate`, `version` subcommands. |
|
|
49
|
+
| `v2.1-guard-patch` | `safedeps-pre-guard.sh` — ledger enforcement on top of the v1 pattern blocks. |
|
|
50
|
+
| `v2.1-verify-patch` | `safedeps-post-verify.sh` — lockfile-diff comparison against the approved spec on top of the v1 reorg. |
|
|
51
|
+
| `v2.1-multi-ecosystem` | pip / cargo / go / gem / maven / nuget command parsing + lockfile snapshots, shared as rollback truth across both hooks. |
|
|
52
|
+
| `v2.1-hook-rename` | Hook file namespacing + cross-engine installer (`install-safedeps-hooks.mjs`, idempotent, `--uninstall`). |
|
|
53
|
+
| `v2.1-recheck-cron` | Daily re-check LaunchAgent — re-queries every approved spec, revokes + notifies on new CVE/KEV/provider-skip. |
|
|
54
|
+
| `v2.1-tests` | End-to-end tests — fixture provider responses drive ledger / hook / re-check / migration checks. |
|
|
55
|
+
| `v2.1-release` | npm publish (`@aldegad/safedeps`) + GitHub release. |
|
|
72
56
|
|
|
73
|
-
|
|
74
|
-
- `npm test` 는 release smoke suite 를 실행한다. full fixture E2E 는 `v2.1-tests` 후속으로 남긴다.
|
|
75
|
-
- daily re-check 는 토큰을 쓰지 않는다. 알렉스가 opt-in 하면 macOS `launchd` user agent 로 `safedeps re-check --json` 을 매일 실행하는 구조가 기본이다. 네트워크는 OSV/CISA/GHSA provider query 에만 사용된다.
|
|
76
|
-
- 실제 local background job 은 `scripts/install/install-safedeps-recheck-agent.mjs` 로 atomic install 한다. wrapper 는 `~/.safedeps/recheck.log` 와 `~/.safedeps/recheck-alerts.jsonl` 를 쓰고, 새 CVE/KEV/revoke/provider-skip 이 있으면 macOS notification 을 띄운다.
|
|
57
|
+
### Release notes
|
|
77
58
|
|
|
78
|
-
|
|
59
|
+
- The npm package version in `package.json` is the single source of truth. `bin/safedeps` `SAFEDEPS_VERSION` tracks it and the smoke test reads `package.json` to compare (current: v2.2.0).
|
|
60
|
+
- `npm test` runs the release smoke suite; the full fixture E2E lives under `v2.1-tests`.
|
|
61
|
+
- The daily re-check uses no LLM tokens. It is opt-in: a macOS `launchd` user agent runs `safedeps re-check --json` daily, installed atomically by `install-safedeps-recheck-agent.mjs`. It writes `~/.safedeps/recheck.log` and `~/.safedeps/recheck-alerts.jsonl` and raises a macOS notification on a new CVE/KEV/revoke/provider-skip. Network is used only for OSV / CISA / GHSA queries.
|
|
79
62
|
|
|
80
|
-
|
|
63
|
+
## v2.2 — effect-based enforcement (npm)
|
|
81
64
|
|
|
82
|
-
|
|
65
|
+
Status: shipped as v2.2.0 (npm-first).
|
|
83
66
|
|
|
84
|
-
|
|
67
|
+
### What changed
|
|
85
68
|
|
|
86
|
-
|
|
69
|
+
- **Authority moved to effects**: PostToolUse now reads the actual `package-lock.json` closure and compares every installed `pkg@version` against approved direct specs plus their `transitive_specs`.
|
|
70
|
+
- **Full closure approval for npm**: `safedeps check npm <pkg>@<version>` resolves a script-free lockfile in a temp dir with `npm install --package-lock-only --ignore-scripts`, extracts the full closure, and queries OSV `/v1/querybatch`.
|
|
71
|
+
- **Batch + cache**: OSV batch responses are written back into the same per `pkg@version` 24h cache used by single-package provider queries.
|
|
72
|
+
- **No blind trust for transitives**: a clean direct package with an unapproved or vulnerable transitive dependency is not enough; the full closure must be clean and recorded.
|
|
73
|
+
- **PreToolUse demoted to fast UX guard**: command parsing still blocks obvious unapproved install attempts and keeps the bypass regression coverage, but PostToolUse is the primary enforcement surface.
|
|
74
|
+
- **Inert install (Claude Code)**: the PreToolUse hook rewrites an npm install to add `--ignore-scripts` via the hook `updatedInput` capability, so the install runs inert; PostToolUse runs `npm rebuild` only after the closure is verified clean, so a rejected package's lifecycle scripts never run. Codex CLI lacks `updatedInput`, so it stays on detect-and-rollback.
|
|
87
75
|
|
|
88
|
-
|
|
76
|
+
### npm-only boundary
|
|
89
77
|
|
|
90
|
-
|
|
91
|
-
- **policy file** — `.safedeps.toml` 로 \"우리 팀 정책: KEV hit 자동 block, CVSS 7+ 사용자 컨펌, 특정 패키지 allowlist\" 명시.
|
|
92
|
-
- **CI mode** — `safedeps check --ci` 로 GitHub Actions / CircleCI fail-fast.
|
|
93
|
-
- **transitive risk score** — deps.dev graph 통합. 직접 dep 만 아니라 transitive dep 의 \"위험 점수\" 시각화.
|
|
78
|
+
This phase covers npm lockfile closure only. pip / cargo / go / gem / maven / nuget keep the v2.1 command/ledger/reorg behavior until each ecosystem has an explicit closure resolver and script/no-execution policy.
|
|
94
79
|
|
|
95
|
-
|
|
80
|
+
### Verification
|
|
81
|
+
|
|
82
|
+
- closure approval records `transitive_specs`
|
|
83
|
+
- unapproved transitive package in `package-lock.json` triggers post-verify reorg
|
|
84
|
+
- approved full-closure install passes without false reorg
|
|
85
|
+
- heredoc / echo text does not trigger install detection
|
|
86
|
+
- existing smoke + fixture E2E regression suite remains green
|
|
96
87
|
|
|
97
|
-
|
|
88
|
+
### Current focus
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
- **AI agent integration** — Claude / Codex 가 vuln 발견 시 \"대체 모듈 X 권장\" 직접 제안 (LLM-as-judge).
|
|
101
|
-
- **diff visualization UI** — 두 approved spec snapshot 사이의 dep tree diff 시각화.
|
|
90
|
+
1. `v2.2.0-release`: merge `safedeps-security-hardening`, tag `v2.2.0`, GitHub release, `npm publish`.
|
|
102
91
|
|
|
103
92
|
---
|
|
104
93
|
|
|
105
|
-
##
|
|
94
|
+
## v3 (future)
|
|
106
95
|
|
|
107
|
-
|
|
108
|
-
- **컨테이너 이미지 스캔**. → Trivy / Grype.
|
|
109
|
-
- **runtime 권한 sandbox**. → lavamoat / firejail.
|
|
110
|
-
- **registry 자체의 손상 감지**. → registry 운영사 책임.
|
|
111
|
-
- **사용자 평판 분석 (behavioral)**. → socket.dev.
|
|
96
|
+
### Ledger tamper resistance
|
|
112
97
|
|
|
113
|
-
|
|
98
|
+
Defends the second-order attack where a malicious package's `postinstall` (running as the user) forges a "B approved" ledger entry so a later install of B skips the advisory check. The package cannot do this *before* it runs, so closing the install-time gate is the first line of defense; this hardens the case where a first compromise already happened.
|
|
114
99
|
|
|
115
|
-
|
|
100
|
+
Approach — **treat OSV as the authority and the ledger as a cache**, plus tamper detection. Cheap, layers onto existing infra:
|
|
101
|
+
|
|
102
|
+
1. **Re-validate at enforcement / re-check** — verify the stored evidence against OSV instead of trusting the ledger verdict. A forged entry with no real evidence (or for a package OSV reports as vulnerable) is caught and revoked. Reduces the ledger to memoization with OSV as SSoT.
|
|
103
|
+
2. **Watch `~/.safedeps/` in the post-install scan** — the post-verify hook already flags `postinstall` scripts that touch `~/.ssh` / `.env`; add `~/.safedeps/` so a package that writes the ledger trips a reorg — catching the forge in the act.
|
|
104
|
+
3. **Provenance cross-check in daily re-check** — flag ledger entries with no matching `advisory.log` record (i.e. no real `safedeps check` ever ran) as suspected forgeries.
|
|
105
|
+
|
|
106
|
+
Explicit non-approach: **cryptographic ledger signing is not pursued** — a same-uid attacker can read the signing key and re-sign forgeries, so a local HMAC/signature adds no real boundary. The defense is authority-elsewhere (OSV) + detection, not local secrets.
|
|
107
|
+
|
|
108
|
+
### Other v3 work
|
|
116
109
|
|
|
117
|
-
|
|
110
|
+
- **Plugin providers** — user-defined advisory sources (internal vuln DB, private registry).
|
|
111
|
+
- **Policy file** — `.safedeps.toml` for team policy (auto-block on KEV hit, user confirm on CVSS 7+, per-package allowlist).
|
|
112
|
+
- **CI mode** — `safedeps check --ci` for fail-fast in GitHub Actions / CircleCI.
|
|
113
|
+
- **Closure expansion beyond npm** — pip / cargo / go / gem / maven / nuget closure resolvers with explicit no-script/no-build policies.
|
|
114
|
+
- **Transitive risk score** — deps.dev graph integration; risk visualization beyond direct dependencies.
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|---|---|---|
|
|
121
|
-
| `safedeps` (이것) | dev 의존성 (npm/pip/cargo/...) install 단계 | 현재 작업 |
|
|
122
|
-
| `infra-cve-monitor` (가칭) | nginx / apt / OS package 주기적 audit + RSS 알람 | 미래 별 도구 |
|
|
123
|
-
| `container-scan-bridge` (가칭) | Trivy / Grype wrapper, 컨테이너 이미지 결 | 미래 별 도구 |
|
|
116
|
+
## v4+ (long-term)
|
|
124
117
|
|
|
125
|
-
|
|
118
|
+
- **Team-shared ledger** — multi-machine approved-spec sync.
|
|
119
|
+
- **Agent remediation** — Claude / Codex suggests a safer replacement when a vuln is found (LLM-as-judge).
|
|
120
|
+
- **Diff visualization** — dependency-tree diff between two approved-spec snapshots.
|
|
126
121
|
|
|
127
122
|
---
|
|
128
123
|
|
|
129
|
-
##
|
|
124
|
+
## History
|
|
130
125
|
|
|
131
|
-
- 2026-05-18: ROADMAP
|
|
126
|
+
- 2026-05-18: Initial ROADMAP — v1 → v2 decision plus v3 / v4 outline.
|
package/SKILL.md
CHANGED
|
@@ -12,9 +12,11 @@ hooks:
|
|
|
12
12
|
|
|
13
13
|
Safedeps protects development dependency installs with a three-phase flow:
|
|
14
14
|
|
|
15
|
-
1. **Phase 1 — Advisory gate (`safedeps check`)**: query OSV (canonical advisory truth), CISA KEV (overlay), and GitHub Advisory (enrichment) before install.
|
|
16
|
-
2. **Phase 2 —
|
|
17
|
-
3. **Phase 3 —
|
|
15
|
+
1. **Phase 1 — Advisory gate (`safedeps check`)**: query OSV (canonical advisory truth), CISA KEV (overlay), and GitHub Advisory (enrichment) before install. For npm, resolve the full dependency closure with a script-free lockfile probe and OSV `/v1/querybatch`; write the approved direct spec plus `transitive_specs` to `~/.safedeps/approved-specs/<hash>.json` with a 30-day TTL.
|
|
16
|
+
2. **Phase 2 — Fast command guard (`scripts/safedeps-pre-guard.sh`)**: the PreToolUse hook does not call providers. It checks the approved-spec ledger for package/version tokens in the about-to-run install command and snapshots dependency truth. Miss or expired → block with a structured message that names the exact `safedeps check` command to run next. On Claude Code it also rewrites an npm install to add `--ignore-scripts` (hook `updatedInput`), so the install runs inert until verified; Codex CLI lacks `updatedInput`, so it falls back to detect-and-rollback.
|
|
17
|
+
3. **Phase 3 — Effect enforcement + reorg (`scripts/safedeps-post-verify.sh`)**: PostToolUse is the primary enforcement surface for npm. It compares the actual `package-lock.json` closure against direct ledger entries and their `transitive_specs`, re-checks the closure with OSV batch, and rolls back when any package is unapproved/vulnerable or install scripts look suspicious. After a verified inert install it runs `npm rebuild` so the now-trusted lifecycle scripts execute.
|
|
18
|
+
|
|
19
|
+
> **Release-time lane**: the `security-release-gates` orchestrator is absorbed into `safedeps gates`. It runs the repo-tree gates (secret scan, dependency audit, repo git-hook/CI check, install-guard presence) from one entry point, detecting and orchestrating the repo's `security:*` npm scripts, `scripts/security/*`, and gitleaks/npm-audit fallback. Splitting the individual `scan`/`audit`/`hooks`/`git` commands out and fully migrating a target repo's `scripts/security/*` is follow-up work. Design SSoT: [`ARCHITECTURE.md`](./ARCHITECTURE.md) §1 (Two Lanes).
|
|
18
20
|
|
|
19
21
|
## CLI Reference
|
|
20
22
|
|
|
@@ -24,6 +26,7 @@ safedeps ledger [--json]
|
|
|
24
26
|
safedeps revoke <hash> | <ecosystem> <pkg>@<version> | <pkg>@<version> [--reason <r>] [--json]
|
|
25
27
|
safedeps re-check [--json]
|
|
26
28
|
safedeps migrate [--keep-legacy]
|
|
29
|
+
safedeps gates [run] [--root <repo>] [--strict] [--no-run]
|
|
27
30
|
safedeps help [command]
|
|
28
31
|
safedeps version
|
|
29
32
|
```
|
|
@@ -55,6 +58,8 @@ You are the primary user of this skill when you propose `npm install`, `pip inst
|
|
|
55
58
|
|
|
56
59
|
Use `--json` so the output is parseable. Read the `result` field.
|
|
57
60
|
|
|
61
|
+
If `safedeps` is not on your PATH, invoke it at the skill path instead — `~/.claude/skills/safedeps/bin/safedeps` (Claude Code) or `~/.codex/skills/safedeps/bin/safedeps` (Codex CLI). The hook's block messages already name a runnable path, so when blocked you never have to resolve this yourself.
|
|
62
|
+
|
|
58
63
|
2. **Decide from `result`**:
|
|
59
64
|
|
|
60
65
|
| `result` | Action |
|
|
@@ -64,7 +69,7 @@ You are the primary user of this skill when you propose `npm install`, `pip inst
|
|
|
64
69
|
| `cve_unpatched` | Do **not** install. Surface the CVE list to the human, propose an alternative package. |
|
|
65
70
|
| `kev_hard_block` | Do **not** install. Recommend an alternative module — the package is actively exploited in the wild. |
|
|
66
71
|
| `provider_unavailable` | OSV is unreachable and there is no fresh cache. Do not install. Retry later or tell the human. |
|
|
67
|
-
| `error` | Argument parsing failed. Fix and retry. |
|
|
72
|
+
| `error` | Argument parsing or version/closure resolution failed (e.g. an unpublished version). Fix the spec and retry. |
|
|
68
73
|
|
|
69
74
|
3. **Issue the install** only after the spec is approved. The hook re-checks the ledger; if the approved version differs from your install argument, the hook will block again — re-narrow and retry.
|
|
70
75
|
|
|
@@ -111,7 +116,7 @@ You are the primary user of this skill when you propose `npm install`, `pip inst
|
|
|
111
116
|
}
|
|
112
117
|
```
|
|
113
118
|
|
|
114
|
-
Both engines surface `permissionDecisionReason` back to you as the block message.
|
|
119
|
+
Both engines surface `permissionDecisionReason` back to you as the block message. The command quoted inside backticks is already runnable as-is — bare `safedeps` when the CLI is on PATH, otherwise an absolute path. Run it **verbatim** (do not rewrite a full path back down to a bare `safedeps`), parse the `--json` output, and retry the install with the approved version.
|
|
115
120
|
|
|
116
121
|
### Hard rules
|
|
117
122
|
|
|
@@ -159,7 +164,8 @@ Disable color with `--no-color` or `NO_COLOR=1`. Non-TTY pipes also strip color
|
|
|
159
164
|
- `lib/providers/providers.sh` — OSV / CISA KEV / GitHub Advisory adapters with a single query interface and 24h local cache under `~/.safedeps/cache/`.
|
|
160
165
|
- `lib/ledger/ledger.sh` — approved spec JSON ledger I/O under `~/.safedeps/approved-specs/`, deterministic spec hash, TTL checks, atomic writes.
|
|
161
166
|
- `scripts/safedeps-pre-guard.sh` — PreToolUse hook. v1 command pattern guard + ledger lookup for install commands.
|
|
162
|
-
- `scripts/safedeps-post-verify.sh` — PostToolUse hook. v1 rollback engine +
|
|
167
|
+
- `scripts/safedeps-post-verify.sh` — PostToolUse hook. v1 rollback engine + npm effect gate (lockfile closure vs ledger + OSV batch).
|
|
168
|
+
- `lib/npm/closure.sh` — npm lockfile closure extraction and script-free temp lockfile resolver.
|
|
163
169
|
- `scripts/install/install-safedeps-hooks.mjs` — cross-engine installer. Symlinks `~/.claude/skills/safedeps` and `~/.codex/skills/safedeps`, idempotently patches `~/.claude/settings.json` and `~/.codex/hooks.json`. `--uninstall` removes both.
|
|
164
170
|
|
|
165
171
|
## Provider Failure Policy
|
|
@@ -182,7 +188,7 @@ What it does:
|
|
|
182
188
|
- Symlink the repo at `~/.claude/skills/safedeps` (when `~/.claude` exists) and `~/.codex/skills/safedeps` (when `~/.codex` exists).
|
|
183
189
|
- Patch `~/.claude/settings.json` `hooks.PreToolUse[matcher=Bash]` and `hooks.PostToolUse[matcher=Bash]` with the canonical script paths.
|
|
184
190
|
- Patch `~/.codex/hooks.json` with the same matcher and paths.
|
|
185
|
-
- Optionally symlink `~/.local/bin/safedeps -> bin/safedeps` so the
|
|
191
|
+
- Optionally symlink `~/.local/bin/safedeps -> bin/safedeps` (via `--link-bin`) for a clean `safedeps` on PATH. **Not required** — the hook block messages and this skill fall back to the absolute skill-relative path, so the gate is fully self-contained without any PATH setup.
|
|
186
192
|
|
|
187
193
|
Manual registration is also supported — see [Claude Code Hooks reference](https://code.claude.com/docs/en/hooks) and [Codex CLI Hooks](https://developers.openai.com/codex/hooks). The canonical script paths are:
|
|
188
194
|
|