project-shield 1.1.5 → 2.0.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -4
  3. package/dist/auditor/checks/environment.d.ts +7 -0
  4. package/dist/auditor/checks/environment.d.ts.map +1 -0
  5. package/dist/auditor/checks/environment.js +463 -0
  6. package/dist/auditor/checks/environment.js.map +1 -0
  7. package/dist/auditor/checks/hooks.d.ts +13 -0
  8. package/dist/auditor/checks/hooks.d.ts.map +1 -0
  9. package/dist/auditor/checks/hooks.js +234 -0
  10. package/dist/auditor/checks/hooks.js.map +1 -0
  11. package/dist/auditor/engine.d.ts +7 -0
  12. package/dist/auditor/engine.d.ts.map +1 -0
  13. package/dist/auditor/engine.js +183 -0
  14. package/dist/auditor/engine.js.map +1 -0
  15. package/dist/auditor/providers/claude-code.d.ts +17 -0
  16. package/dist/auditor/providers/claude-code.d.ts.map +1 -0
  17. package/dist/auditor/providers/claude-code.js +176 -0
  18. package/dist/auditor/providers/claude-code.js.map +1 -0
  19. package/dist/auditor/providers/types.d.ts +36 -0
  20. package/dist/auditor/providers/types.d.ts.map +1 -0
  21. package/dist/auditor/providers/types.js +4 -0
  22. package/dist/auditor/providers/types.js.map +1 -0
  23. package/dist/index.js +99 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/license/gate.d.ts +3 -0
  26. package/dist/license/gate.d.ts.map +1 -1
  27. package/dist/license/gate.js +9 -0
  28. package/dist/license/gate.js.map +1 -1
  29. package/dist/license/index.d.ts +1 -1
  30. package/dist/license/index.d.ts.map +1 -1
  31. package/dist/license/index.js +3 -1
  32. package/dist/license/index.js.map +1 -1
  33. package/dist/license/storage.d.ts.map +1 -1
  34. package/dist/license/storage.js +5 -0
  35. package/dist/license/storage.js.map +1 -1
  36. package/dist/license/types.d.ts +5 -0
  37. package/dist/license/types.d.ts.map +1 -1
  38. package/dist/license/usage.d.ts +12 -0
  39. package/dist/license/usage.d.ts.map +1 -1
  40. package/dist/license/usage.js +47 -2
  41. package/dist/license/usage.js.map +1 -1
  42. package/dist/output/audit-evidence.d.ts +10 -0
  43. package/dist/output/audit-evidence.d.ts.map +1 -0
  44. package/dist/output/audit-evidence.js +82 -0
  45. package/dist/output/audit-evidence.js.map +1 -0
  46. package/dist/output/audit-fixit.d.ts +34 -0
  47. package/dist/output/audit-fixit.d.ts.map +1 -0
  48. package/dist/output/audit-fixit.js +267 -0
  49. package/dist/output/audit-fixit.js.map +1 -0
  50. package/dist/output/audit-terminal.d.ts +15 -0
  51. package/dist/output/audit-terminal.d.ts.map +1 -0
  52. package/dist/output/audit-terminal.js +200 -0
  53. package/dist/output/audit-terminal.js.map +1 -0
  54. package/dist/retention/expiry.d.ts +13 -0
  55. package/dist/retention/expiry.d.ts.map +1 -0
  56. package/dist/retention/expiry.js +37 -0
  57. package/dist/retention/expiry.js.map +1 -0
  58. package/dist/retention/hash-detect.d.ts +12 -0
  59. package/dist/retention/hash-detect.d.ts.map +1 -0
  60. package/dist/retention/hash-detect.js +29 -0
  61. package/dist/retention/hash-detect.js.map +1 -0
  62. package/dist/retention/storage.d.ts +17 -0
  63. package/dist/retention/storage.d.ts.map +1 -0
  64. package/dist/retention/storage.js +79 -0
  65. package/dist/retention/storage.js.map +1 -0
  66. package/dist/types/audit.d.ts +77 -0
  67. package/dist/types/audit.d.ts.map +1 -0
  68. package/dist/types/audit.js +4 -0
  69. package/dist/types/audit.js.map +1 -0
  70. package/package.json +17 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShovelMaker91
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.
package/README.md CHANGED
@@ -2,11 +2,23 @@
2
2
 
3
3
  **Security scanner for AI coders and MCP users.**
4
4
 
5
- Detects leaked API keys, PII, insecure MCP configs, and prompt injection in one command.
5
+ Detects leaked API keys, PII, insecure MCP configs, and prompt injection. Audits your Claude Code environment for misconfigurations and malicious hooks.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/project-shield)](https://www.npmjs.com/package/project-shield)
8
8
  [![license](https://img.shields.io/npm/l/project-shield)](LICENSE)
9
9
 
10
+ ### Key Features
11
+
12
+ - **9 detection engines** in one CLI — secrets, PII, MCP config, prompt injection, environment audit, hooks analysis, scoring, fix-it, evidence
13
+ - **Multi-layer detection** — 3-layer secrets (regex + entropy + context), 2-layer PII (regex + checksum), 2-layer injection (keyword + structural)
14
+ - **Environment Audit** — Claude Code settings, CLAUDE.md injection, hooks malicious command detection (16 checks)
15
+ - **Retention System** — 7-day audit expiry warning, settings hash change detection
16
+ - **Security grade scoring** (A-F) with automatic badge lock on critical findings
17
+ - **Fix-it guides** — actionable remediation with code examples, not just warnings
18
+ - **Evidence Pack** — compliance-ready PDF + JSON reports with integrity seals (SHA-256 + UUID)
19
+ - **MCP-native** — purpose-built for AI agent configs (Claude, Cursor, Windsurf)
20
+ - **Lightweight** — 4 dependencies, runs offline, CI/CD ready
21
+
10
22
  ```bash
11
23
  npx project-shield scan ./my-project
12
24
  ```
@@ -14,7 +26,7 @@ npx project-shield scan ./my-project
14
26
  ```
15
27
  Tier: Free (0/5 scans)
16
28
 
17
- Project Shield v1.0.0
29
+ Project Shield v2.0.0
18
30
  Ruleset: v1.0.0 (SHA-256: f408a4fd...)
19
31
  Scanning: 47 files (3 excluded)
20
32
 
@@ -46,6 +58,43 @@ Scanning: 47 files (3 excluded)
46
58
  Badge generation LOCKED — Fix all critical findings first.
47
59
  ```
48
60
 
61
+ ### Audit Demo
62
+
63
+ ```bash
64
+ npx project-shield audit
65
+ ```
66
+
67
+ ```
68
+ Project Shield v2.0.0 — Environment Audit
69
+ Target: Claude Code
70
+
71
+ ╔══════════════════════════════════════════════════╗
72
+ ║ F008: Environment Security ║
73
+ ╠══════════════════════════════════════════════════╣
74
+ ║ 🔴 CRITICAL Unrestricted MCP servers ║
75
+ ║ allowedTools: ["*"] permits all tools ║
76
+ ║ 🔴 CRITICAL CLAUDE.md prompt injection ║
77
+ ║ Hidden instruction detected in CLAUDE.md ║
78
+ ║ ⚠ WARNING Permissions too broad ║
79
+ ║ AllowedDirectories includes root path ║
80
+ ║ ✅ PASS API key not exposed in settings ║
81
+ ║ ✅ PASS No disabled security features ║
82
+ ╠══════════════════════════════════════════════════╣
83
+ ║ F009: Hooks Analysis ║
84
+ ╠══════════════════════════════════════════════════╣
85
+ ║ 🔴 CRITICAL Malicious command in PreToolUse ║
86
+ ║ curl | sh detected in hook command ║
87
+ ║ ✅ PASS No data exfiltration patterns ║
88
+ ║ ✅ PASS No file system destruction ║
89
+ ╠══════════════════════════════════════════════════╣
90
+ ║ Score: 35/100 (D) | 3 Critical · 1 Warning ║
91
+ ║ ⚠ 3 additional issues — upgrade to Pro ║
92
+ ╚══════════════════════════════════════════════════╝
93
+
94
+ Retention: Last audit 8 days ago (expired)
95
+ Settings hash: changed since last audit
96
+ ```
97
+
49
98
  ---
50
99
 
51
100
  ## Why Project Shield?
@@ -123,6 +172,22 @@ project-shield scan ./my-project --badge shield-badge.svg
123
172
  project-shield scan ./my-project --ignore .shieldignore
124
173
  ```
125
174
 
175
+ ### Audit (v2.0)
176
+
177
+ ```bash
178
+ # Basic environment audit
179
+ project-shield audit
180
+
181
+ # Auto-fix safe issues
182
+ project-shield audit --fix
183
+
184
+ # JSON output
185
+ project-shield audit --format json
186
+
187
+ # Audit evidence pack (Pro)
188
+ project-shield audit --evidence ./audit-report
189
+ ```
190
+
126
191
  ### All options
127
192
 
128
193
  ```
@@ -133,6 +198,11 @@ project-shield scan <path>
133
198
  -b, --badge <path> Output path for SVG badge
134
199
  --fix Show fix-it remediation guides
135
200
  --evidence <path> Output path for evidence pack (JSON + PDF)
201
+
202
+ project-shield audit
203
+ -f, --format <format> Output format: terminal | json (default: terminal)
204
+ --fix Auto-fix safe issues
205
+ --evidence <path> Output path for audit evidence pack (Pro)
136
206
  ```
137
207
 
138
208
  ---
@@ -142,6 +212,10 @@ project-shield scan <path>
142
212
  | Feature | Free | Pro |
143
213
  |---------|------|-----|
144
214
  | Scans per month | 5 | 50 |
215
+ | Audits per month | 3 | 20 |
216
+ | Audit checks (F008) | 3 critical only | All 9 checks |
217
+ | Hooks analysis (F009) | — | Full 7 checks |
218
+ | Audit evidence | — | JSON Evidence Pack |
145
219
  | Secrets / MCP / Injection details | Full | Full |
146
220
  | PII details | Count only | File:line details |
147
221
  | Fix-it guides | Top 3, summary | All, with code + references |
@@ -233,6 +307,40 @@ project-shield deactivate
233
307
 
234
308
  Deductions: critical -25, warning -10, possible -5, info -2.
235
309
 
310
+ ### F008: Environment Security (9 checks)
311
+
312
+ | ID | Check | Severity | Tier | Description |
313
+ |----|-------|----------|------|-------------|
314
+ | F008-01 | MCP Server Allowlist | Critical | Free | Unrestricted MCP servers (`allowedTools: ["*"]`) |
315
+ | F008-02 | CLAUDE.md Injection | Critical | Free | Hidden instructions or prompt injection in CLAUDE.md |
316
+ | F008-03 | API Key Exposure | Critical | Free | API keys hardcoded in settings files |
317
+ | F008-04 | Permission Scope | Warning | Pro | Overly broad directory/file permissions |
318
+ | F008-05 | Disabled Security | Warning | Pro | Security features explicitly disabled |
319
+ | F008-06 | Telemetry Settings | Info | Pro | Telemetry misconfiguration |
320
+ | F008-07 | Extension Trust | Warning | Pro | Untrusted extensions enabled |
321
+ | F008-08 | Network Exposure | Warning | Pro | Insecure network configurations |
322
+ | F008-09 | Update Policy | Info | Pro | Auto-update disabled or misconfigured |
323
+
324
+ ### F009: Hooks Analysis (7 checks)
325
+
326
+ | ID | Check | Severity | Description |
327
+ |----|-------|----------|-------------|
328
+ | F009-01 | Malicious Commands | Critical | `curl\|sh`, `wget\|bash`, reverse shells in hooks |
329
+ | F009-02 | Data Exfiltration | Critical | Sending data to external endpoints |
330
+ | F009-03 | File Destruction | Critical | `rm -rf`, file system wipes |
331
+ | F009-04 | Privilege Escalation | Critical | `sudo`, `chmod 777`, permission changes |
332
+ | F009-05 | Environment Tampering | Warning | Modifying PATH, env variables |
333
+ | F009-06 | Obfuscated Commands | Warning | Base64-encoded or obfuscated payloads |
334
+ | F009-07 | Unauthorized Network | Warning | Unexpected outbound connections |
335
+
336
+ ### Retention
337
+
338
+ Audit results expire after **7 days** to ensure ongoing security monitoring.
339
+
340
+ - **Expiry warning**: "Your last audit expired N days ago. Re-run `project-shield audit`."
341
+ - **Hash change detection**: If `.claude/settings.json` changes, Shield detects the hash mismatch and recommends re-audit.
342
+ - **State storage**: `.claude/.shield/audit-state.json`
343
+
236
344
  ---
237
345
 
238
346
  ## Inline Suppression
@@ -303,6 +411,7 @@ The `--evidence` flag generates a compliance-ready report (Pro only):
303
411
  src/
304
412
  index.ts CLI entry (commander)
305
413
  types/index.ts All TypeScript interfaces
414
+ types/audit.ts Audit type definitions
306
415
  scanner/
307
416
  engine.ts Scan orchestrator (glob, binary skip, ignore)
308
417
  secrets.ts 3-layer secret detection
@@ -310,6 +419,14 @@ src/
310
419
  mcp.ts 5-point MCP config check
311
420
  injection.ts 2-layer injection detection
312
421
  ignore.ts shield-ignore + .shieldignore
422
+ auditor/
423
+ engine.ts Audit orchestrator (providers, checks, scoring)
424
+ providers/
425
+ types.ts AuditProvider interface
426
+ claude-code.ts Claude Code environment provider
427
+ checks/
428
+ environment.ts F008: 9 environment security checks
429
+ hooks.ts F009: 7 hooks malicious command checks
313
430
  scoring/
314
431
  score.ts 0-100 scoring + A-F grading
315
432
  lock.ts Badge lock logic
@@ -322,12 +439,19 @@ src/
322
439
  badge.ts SVG badge generator (shields.io style)
323
440
  fixit.ts 10-type fix-it guide system
324
441
  evidence.ts Evidence pack (JSON + PDF)
442
+ audit-terminal.ts Audit PRD box format terminal output
443
+ audit-evidence.ts Audit evidence pack JSON
444
+ audit-fixit.ts Audit fix-it guides (16 checks)
445
+ retention/
446
+ storage.ts Audit state storage (.claude/.shield/audit-state.json)
447
+ expiry.ts 7-day audit expiry detection
448
+ hash-detect.ts Settings hash change detection
325
449
  license/
326
450
  types.ts License type definitions
327
451
  storage.ts Local file I/O (~/.project-shield/)
328
452
  http.ts HTTPS request wrapper
329
453
  validator.ts Key validation + 7-day cache + 3-day grace
330
- usage.ts Scan usage tracking (monthly)
454
+ usage.ts Scan + audit usage tracking (monthly)
331
455
  gate.ts Feature gating (Free/Pro)
332
456
  commands.ts activate / deactivate / status
333
457
  rules/
@@ -360,7 +484,19 @@ MIT
360
484
 
361
485
  **AI 코더/MCP 사용자를 위한 보안 스캐너 CLI.**
362
486
 
363
- API 키 유출, 개인정보, MCP 설정 보안 취약점, 프롬프트 인젝션을 번에 탐지합니다.
487
+ API 키 유출, 개인정보, MCP 설정 보안 취약점, 프롬프트 인젝션을 탐지합니다. Claude Code 환경 설정 오류와 악성 훅도 감사합니다.
488
+
489
+ ### 주요 특징
490
+
491
+ - **9개 탐지 엔진** 올인원 — 시크릿, PII, MCP 설정, 프롬프트 인젝션, 환경 감사, 훅 분석, 스코어링, Fix-it, Evidence
492
+ - **다중 레이어 탐지** — 시크릿 3중 (정규식 + 엔트로피 + 컨텍스트), PII 2중 (정규식 + 체크섬), 인젝션 2중 (키워드 + 구조)
493
+ - **환경 감사** — Claude Code 설정, CLAUDE.md 인젝션, 훅 악성 명령 탐지 (16개 검사)
494
+ - **리텐션 시스템** — 7일 감사 만료 경고, 설정 해시 변경 감지
495
+ - **보안 등급 스코어** (A-F) — Critical 발견 시 자동 뱃지 잠금
496
+ - **Fix-it 가이드** — 경고만 하지 않고, 코드 예제와 함께 수정 방법 제시
497
+ - **Evidence Pack** — 컴플라이언스용 PDF + JSON 리포트, 무결성 봉인 (SHA-256 + UUID)
498
+ - **MCP 네이티브** — AI 에이전트 설정 전용 (Claude, Cursor, Windsurf)
499
+ - **경량** — 의존성 4개, 오프라인 실행 가능, CI/CD 즉시 연동
364
500
 
365
501
  ```bash
366
502
  npx project-shield scan ./my-project
@@ -424,6 +560,22 @@ project-shield scan ./my-project --evidence ./report
424
560
  project-shield scan ./my-project --badge shield-badge.svg
425
561
  ```
426
562
 
563
+ ### 환경 감사 (v2.0)
564
+
565
+ ```bash
566
+ # 기본 환경 감사
567
+ project-shield audit
568
+
569
+ # 안전한 이슈 자동 수정
570
+ project-shield audit --fix
571
+
572
+ # JSON 출력
573
+ project-shield audit --format json
574
+
575
+ # 감사 Evidence Pack (Pro)
576
+ project-shield audit --evidence ./audit-report
577
+ ```
578
+
427
579
  ---
428
580
 
429
581
  ## Free vs Pro
@@ -431,6 +583,10 @@ project-shield scan ./my-project --badge shield-badge.svg
431
583
  | 기능 | Free | Pro |
432
584
  |------|------|-----|
433
585
  | 월간 스캔 | 5회 | 50회 |
586
+ | 월간 감사 | 3회 | 20회 |
587
+ | 환경 검사 (F008) | Critical 3개만 | 전체 9개 |
588
+ | 훅 분석 (F009) | — | 전체 7개 |
589
+ | 감사 Evidence | — | JSON Evidence Pack |
434
590
  | 시크릿 / MCP / 인젝션 상세 | 전체 표시 | 전체 표시 |
435
591
  | PII 상세 | 건수만 표시 | 파일:라인 상세 |
436
592
  | Fix-it 가이드 | 상위 3개, 요약만 | 전체, 코드 + 참조 포함 |
@@ -489,6 +645,40 @@ Base64/URL 인코딩된 우회 시도 감지 시 **자동 critical**
489
645
 
490
646
  JSON + PDF. 점수, 등급, 발견, 수정 가이드, 무결성 해시, 면책조항 포함.
491
647
 
648
+ ### F008: 환경 보안 검사 (9개)
649
+
650
+ | ID | 검사 | 심각도 | 티어 | 설명 |
651
+ |----|------|--------|------|------|
652
+ | F008-01 | MCP 서버 허용 목록 | Critical | Free | 무제한 MCP 서버 (`allowedTools: ["*"]`) |
653
+ | F008-02 | CLAUDE.md 인젝션 | Critical | Free | CLAUDE.md에 숨겨진 명령어/프롬프트 인젝션 |
654
+ | F008-03 | API 키 노출 | Critical | Free | 설정 파일에 하드코딩된 API 키 |
655
+ | F008-04 | 권한 범위 | Warning | Pro | 과도하게 넓은 디렉토리/파일 권한 |
656
+ | F008-05 | 보안 기능 비활성화 | Warning | Pro | 보안 기능이 명시적으로 꺼져 있음 |
657
+ | F008-06 | 텔레메트리 설정 | Info | Pro | 텔레메트리 설정 오류 |
658
+ | F008-07 | 확장 프로그램 신뢰 | Warning | Pro | 신뢰할 수 없는 확장 프로그램 활성화 |
659
+ | F008-08 | 네트워크 노출 | Warning | Pro | 안전하지 않은 네트워크 설정 |
660
+ | F008-09 | 업데이트 정책 | Info | Pro | 자동 업데이트 비활성화/설정 오류 |
661
+
662
+ ### F009: 훅 분석 (7개)
663
+
664
+ | ID | 검사 | 심각도 | 설명 |
665
+ |----|------|--------|------|
666
+ | F009-01 | 악성 명령 | Critical | `curl\|sh`, `wget\|bash`, 리버스 셸 |
667
+ | F009-02 | 데이터 유출 | Critical | 외부 엔드포인트로 데이터 전송 |
668
+ | F009-03 | 파일 파괴 | Critical | `rm -rf`, 파일 시스템 삭제 |
669
+ | F009-04 | 권한 상승 | Critical | `sudo`, `chmod 777`, 권한 변경 |
670
+ | F009-05 | 환경 변수 변조 | Warning | PATH, 환경 변수 수정 |
671
+ | F009-06 | 난독화 명령 | Warning | Base64 인코딩 등 난독화된 페이로드 |
672
+ | F009-07 | 비인가 네트워크 | Warning | 예상치 못한 외부 연결 |
673
+
674
+ ### 리텐션
675
+
676
+ 감사 결과는 **7일 후 만료**되어 지속적 보안 모니터링을 보장합니다.
677
+
678
+ - **만료 경고**: "마지막 감사가 N일 전에 만료되었습니다. `project-shield audit`를 다시 실행하세요."
679
+ - **해시 변경 감지**: `.claude/settings.json`이 변경되면 해시 불일치를 감지하고 재감사를 권장합니다.
680
+ - **상태 저장**: `.claude/.shield/audit-state.json`
681
+
492
682
  ---
493
683
 
494
684
  ## 라인 무시 (shield-ignore)
@@ -0,0 +1,7 @@
1
+ import type { AuditFinding } from '../../types/audit.js';
2
+ import type { ToolSettings, EnvFileInfo, InstructionFileInfo } from '../providers/types.js';
3
+ /**
4
+ * Run all F008 environment checks and return findings.
5
+ */
6
+ export declare function checkEnvironment(settings: ToolSettings[], envFiles: EnvFileInfo[], instructionFiles: InstructionFileInfo[], projectDir: string): AuditFinding[];
7
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/auditor/checks/environment.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA6C5F;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EAAE,EACxB,QAAQ,EAAE,WAAW,EAAE,EACvB,gBAAgB,EAAE,mBAAmB,EAAE,EACvC,UAAU,EAAE,MAAM,GACjB,YAAY,EAAE,CAchB"}