@softspark/ai-toolkit 1.4.1 → 1.5.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/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ Versioning follows [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ---
9
9
 
10
+ ## v1.5.0 — HIPAA Scanner: Deterministic Script, CI Integration, Self-Exclusion (2026-04-10)
11
+
12
+ ### Added
13
+ - **`scripts/hipaa_scan.py`** — deterministic Python scanner (stdlib-only) for `/hipaa-validate`. Replaces LLM-driven regex execution with a reproducible script. 8 check categories, context gate, `.hipaaignore` support, `.hipaa-config` BAA vendor list, deduplication, structured output.
14
+ - **`--output json` flag** for `/hipaa-validate` — structured JSON output for CI/CD pipeline integration. Exit code 1 on HIGH findings, 0 otherwise.
15
+ - **Self-exclusion** — scanner automatically excludes its own skill directory to prevent flagging its own regex definitions.
16
+ - **`.hipaaignore`** — project-level exclusion file (gitignore syntax) for suppressing known false positives.
17
+ - **IDE/AI config file exclusions** — `.roomodes`, `.cursorrules`, `.windsurfrules`, `llms.txt`, `llms-full.txt`, `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `COPILOT.md` automatically skipped (contain pattern examples, not source code).
18
+
19
+ ### Changed
20
+ - **`/hipaa-validate` frontmatter** — added `user-invocable: true`, `context: fork`, `agent: security-auditor`, `Bash` in `allowed-tools`.
21
+ - **`/hipaa-validate` workflow** — pivoted from "manually execute regex patterns" to "run script, interpret results, suggest specific fixes."
22
+ - **Documentation alignment** — updated hipaa-validate descriptions in README.md, ARCHITECTURE.md, skills-catalog.md, llms-full.txt to include all 8 check categories (was missing "temp file exposure" and "missing BAA references").
23
+ - Skill count: 91 → 92 in package.json description.
24
+
25
+ ---
26
+
27
+ ## v1.4.2 — --local Scoping Fix, Leading Blank Lines Fix (2026-04-09)
28
+
29
+ ### Fixed
30
+ - `--local` now runs only project-local install (no global re-install). Global install runs separately without `--local`.
31
+ - Fixed leading blank lines in generated files (copilot-instructions.md, etc.) caused by `inject_section` and `inject_with_rules`.
32
+ - Context-aware "Next steps" message (local vs global).
33
+
34
+ ### Changed
35
+ - Updated KB docs: global-install-model.md, maintenance-sop.md to reflect `--local` scoping change.
36
+
37
+ ---
38
+
10
39
  ## v1.4.1 — Documentation Fix: --local Behavior (2026-04-09)
11
40
 
12
41
  ### Fixed
package/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  [![CI](https://github.com/softspark/ai-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/softspark/ai-toolkit/actions/workflows/ci.yml)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
- [![Skills](https://img.shields.io/badge/skills-91-brightgreen)](app/skills/)
7
+ [![Skills](https://img.shields.io/badge/skills-92-brightgreen)](app/skills/)
8
8
  [![Agents](https://img.shields.io/badge/agents-44-blue)](app/agents/)
9
- [![Tests](https://img.shields.io/badge/tests-408%20passing-success)](tests/)
9
+ [![Tests](https://img.shields.io/badge/tests-439%20passing-success)](tests/)
10
10
 
11
11
  ---
12
12
 
@@ -136,7 +136,7 @@ Replaces all symlinks with real files, inlines rules into CLAUDE.md, copies cons
136
136
 
137
137
  | Component | Count | Description |
138
138
  |-----------|-------|-------------|
139
- | `skills/` (task) | 28 | Slash commands: `/commit`, `/build`, `/deploy`, `/test`, `/skill-audit`, ... |
139
+ | `skills/` (task) | 29 | Slash commands: `/commit`, `/build`, `/deploy`, `/test`, `/skill-audit`, `/hipaa-validate`, ... |
140
140
  | `skills/` (hybrid) | 31 | Slash commands with agent knowledge base |
141
141
  | `skills/` (knowledge) | 32 | Domain knowledge auto-loaded by agents |
142
142
  | `agents/` | 44 | Specialized agents across 10 categories |
@@ -227,6 +227,7 @@ ai-toolkit/
227
227
  | `/plugin-creator` | Scaffold an experimental plugin pack with manifest and optional modules | high |
228
228
  | `/skill-audit` | Scan skills/agents for security risks: dangerous patterns, secrets, permissions | medium |
229
229
  | `/cve-scan` | Scan project dependencies for known CVEs using native audit tools (npm, pip, composer, cargo, go, ruby, dart) | medium |
230
+ | `/hipaa-validate` | Scan codebase for HIPAA compliance: PHI exposure, missing audit logging, unencrypted transmission/storage, access control gaps, temp file exposure, missing BAA references | medium |
230
231
  | `/analyze` | Code quality, complexity, and pattern analysis | medium |
231
232
  | `/fix` | Auto-fix lint/type errors | low |
232
233
  | `/build` | Build with issue detection | low |
@@ -589,7 +590,7 @@ All packs have `status: experimental`. Each has a `plugin.json` manifest and `RE
589
590
 
590
591
  | Feature | ai-toolkit | everything-claude-code | wshobson/agents | ruflo |
591
592
  |---------|---------------|----------------------|-----------------|-------|
592
- | Skills | 90 | 100+ | 146 | 20+ |
593
+ | Skills | 91 | 100+ | 146 | 20+ |
593
594
  | Agents | 44 | 30+ | 112 | 20+ |
594
595
  | Machine-enforced constitution | **Yes** | No (docs only) | No | No |
595
596
  | Skill-scoped lifecycle hooks | **Yes** | No | No | No |
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-toolkit",
3
3
  "description": "Professional-grade Claude Code toolkit with persona presets, skill security auditor, expanded lifecycle hooks, experimental opt-in plugin packs, benchmark harvesting, and multi-tool support.",
4
- "version": "1.3.12",
4
+ "version": "1.5.0",
5
5
  "author": {
6
6
  "name": "SoftSpark",
7
7
  "url": "https://github.com/softspark"
@@ -102,7 +102,7 @@ Universal multi-agent system for software development. Works across all reposito
102
102
 
103
103
  ## Skills
104
104
 
105
- ### Task Skills (28)
105
+ ### Task Skills (29)
106
106
  | Skill | Slash Command | Purpose |
107
107
  |-------|---------------|---------|
108
108
  | `commit` | `/commit` | Create well-structured git commits (Conventional Commits) |
@@ -133,6 +133,7 @@ Universal multi-agent system for software development. Works across all reposito
133
133
  | `plugin-creator` | `/plugin-creator` | Create experimental opt-in plugin packs with manifests, conventions, and optional modules |
134
134
  | `prd-to-issues` | `/prd-to-issues` | Break PRD into GitHub issues with vertical slices and HITL/AFK tagging |
135
135
  | `skill-audit` | `/skill-audit` | Scan skills and agents for security risks, dangerous patterns, secrets |
136
+ | `hipaa-validate` | `/hipaa-validate` | Scan codebase for HIPAA compliance: PHI exposure, missing audit logging, unencrypted transmission/storage, access control gaps, temp file exposure, missing BAA references |
136
137
 
137
138
  ### Hybrid Skills (31)
138
139
  | Skill | Slash Command | Purpose |
@@ -0,0 +1,345 @@
1
+ ---
2
+ name: hipaa-validate
3
+ description: "Validate code against HIPAA policy: PHI exposure, missing audit logging, unencrypted transmission/storage, access control gaps, temp file exposure, and missing BAA references"
4
+ user-invocable: true
5
+ effort: medium
6
+ disable-model-invocation: true
7
+ context: fork
8
+ agent: security-auditor
9
+ argument-hint: "[path] [--mode developer|compliance] [--severity high|warn] [--keywords term1,term2] [--output json]"
10
+ allowed-tools: Read, Grep, Glob, Bash
11
+ ---
12
+
13
+ # /hipaa-validate - HIPAA Compliance Scanner
14
+
15
+ $ARGUMENTS
16
+
17
+ Scan a codebase for HIPAA compliance issues using pattern-matching heuristics. Detects PHI exposure in logs, missing audit trails, unencrypted transmission/storage, hardcoded patient data, access control gaps, and missing Business Associate Agreement references. Read-only — never modifies files.
18
+
19
+ **Regulation basis**: 45 CFR Parts 160, 162, 164 (HIPAA Administrative Simplification, as amended through March 26, 2013). Covers Security Rule (§164.302-318), Privacy Rule (§164.500-534), Breach Notification Rule (§164.400-414), and enforcement penalties (§160.400-426).
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ /hipaa-validate # Scan full project (developer mode — definitives only)
25
+ /hipaa-validate src/ # Scan specific path
26
+ /hipaa-validate --mode compliance # Full audit sweep including heuristic categories
27
+ /hipaa-validate --severity high # Filter to HIGH findings only
28
+ /hipaa-validate --keywords member,enrollee # Extend healthcare keyword list
29
+ /hipaa-validate --output json # Structured JSON output for CI integration
30
+ ```
31
+
32
+ **Modes:**
33
+ - `developer` (default): Categories 1, 3, 4, 7, 8 — definitive regex matches only, low false-positive rate, suited for daily use
34
+ - `compliance`: All 8 categories — includes heuristic checks (Cat 2, 5, 6) for audit sweep coverage, suited for pre-audit sweeps
35
+
36
+ **Severity filtering:** `--severity high` shows only HIGH findings, `--severity warn` shows HIGH + WARN. Default shows all.
37
+
38
+ ## What This Command Does
39
+
40
+ 1. **Run scanner script** — execute `scripts/hipaa_scan.py` with passed arguments
41
+ 2. **Interpret results** — analyze findings, add context, suggest specific fixes
42
+ 3. **Report** — present findings with file paths, line numbers, severity, confidence, and HIPAA rule citations
43
+
44
+ ## Steps
45
+
46
+ ### Step 1: Run the Scanner Script
47
+
48
+ Execute the Python scanner with the user's arguments:
49
+
50
+ ```bash
51
+ python3 "$(dirname "$0")/../app/skills/hipaa-validate/scripts/hipaa_scan.py" [path] [--mode developer|compliance] [--severity high|warn] [--keywords term1,term2] [--output json]
52
+ ```
53
+
54
+ The script handles all scanning logic deterministically:
55
+ - **Context gate** — identifies PHI-adjacent files via healthcare keyword matching
56
+ - **Language detection** — detects project languages from manifest files
57
+ - **8 check categories** — runs regex patterns and co-occurrence heuristics
58
+ - **Deduplication** — removes duplicate findings (same file+line+category)
59
+ - **`.hipaaignore` support** — honors exclusion patterns from project root
60
+ - **`.hipaa-config` support** — reads `covered_vendors` for BAA checks
61
+
62
+ If the script reports "No healthcare context detected", relay the message and suggest the `--keywords` flag with alternative terminology.
63
+
64
+ If `--output json` is used, the script outputs structured JSON suitable for CI pipelines. The exit code is 1 if any HIGH findings exist, 0 otherwise.
65
+
66
+ ### Step 2: Interpret and Enrich Results
67
+
68
+ For each finding from the script output:
69
+
70
+ 1. **Read the flagged file and line** to understand the actual code context
71
+ 2. **Add a specific fix suggestion** — not generic advice, but concrete code changes based on what you see
72
+ 3. **For heuristic findings** (confidence: "heuristic"), check if the concern is actually addressed elsewhere in the codebase (e.g., auth middleware at router level, audit logging in a shared module)
73
+ 4. **Mark confirmed false positives** and suggest adding them to `.hipaaignore`
74
+
75
+ ### Scanner Reference
76
+
77
+ The script implements the following scan categories. This reference is provided so you can explain findings to the user and verify edge cases.
78
+
79
+ **Modes:**
80
+ - `developer` (default): Categories 1, 3, 4, 7, 8 — definitive regex matches only, low false-positive rate
81
+ - `compliance`: All 8 categories — includes heuristic checks (Cat 2, 5, 6)
82
+
83
+ **Default keywords**: `patient`, `diagnosis`, `medication`, `clinical`, `healthcare`, `medical`, `fhir`, `hl7`, `hipaa`, `phi`, `protected.health`, `health-record`, `health-plan`, `health-insurance`
84
+
85
+ > **Note**: Bare `health` is deliberately excluded — it matches infrastructure health checks in nearly every codebase.
86
+
87
+ **Built-in exclusions**: Binary files, lock files, vendored directories (`node_modules/`, `vendor/`, `.git/`, `dist/`, `build/`, `out/`, `.next/`). Test directories (`test/`, `tests/`, `__tests__/`, `spec/`, `fixtures/`, `mocks/`) are excluded for Category 4 only.
88
+
89
+ Categories 1 and 2 scan the full project. Categories 3–8 scan only PHI-adjacent files.
90
+
91
+ ---
92
+
93
+ #### Category 1: PHI in Logs/Console Output
94
+
95
+ Scan the full project for log/print statements that reference PHI keywords.
96
+
97
+ | Pattern | Severity | Language | Description |
98
+ |---------|----------|----------|-------------|
99
+ | `console\.log\(.*patient` | HIGH | JS/TS | Patient data in console |
100
+ | `console\.\w+\(.*req\.body` | WARN | JS/TS | Raw request body may contain PHI |
101
+ | `JSON\.stringify\(.*patient` | WARN | JS/TS | Full patient object serialization |
102
+ | `print\(.*\b(patient\|ssn\|social.security)` | HIGH | Python | PHI in print statements |
103
+ | `logging\.\w+\(.*\b(patient\|ssn\|mrn\|dob)` | HIGH | Python | PHI fields in logger calls |
104
+ | `fmt\.Print.*\b(patient\|ssn\|mrn)` | HIGH | Go | PHI in fmt output |
105
+ | `log\.\w+\(.*\b(patient\|ssn\|mrn)` | HIGH | Go/Any | PHI in log calls |
106
+ | `System\.out\.print.*\b(patient\|ssn\|mrn)` | HIGH | Java | PHI in stdout |
107
+ | `logger\.\w+\(.*\b(patient\|ssn\|mrn\|dob)` | HIGH | Java/Any | PHI fields in logger |
108
+ | `puts.*\b(patient\|ssn\|mrn)` | HIGH | Ruby | PHI in puts |
109
+ | `Rails\.logger.*\b(patient\|ssn\|mrn)` | HIGH | Ruby | PHI in Rails logger |
110
+ | `Console\.Write.*\b(patient\|ssn\|mrn)` | HIGH | C# | PHI in Console output |
111
+ | `_logger\.\w+\(.*\b(patient\|ssn\|mrn\|dob)` | HIGH | C# | PHI in ILogger calls |
112
+
113
+ > **Language coverage note**: JS/TS patterns are the most comprehensive. Go, Ruby, and Java have baseline coverage for common log patterns. Contributions for additional language-specific patterns are welcome.
114
+
115
+ **Minimum Necessary violations** (§164.502(b)):
116
+
117
+ | Pattern | Severity | Language | Description |
118
+ |---------|----------|----------|-------------|
119
+ | `res\.(json\|send)\(.*patient` without field projection | WARN | JS/TS | Full patient object in API response |
120
+ | `return.*patient` in route handler without field selection | WARN | Any | May expose unnecessary PHI fields |
121
+ | `SELECT\s+\*.*FROM.*(patient\|member\|enrollee)` | WARN | SQL | SELECT * on PHI tables violates minimum necessary |
122
+ | `JSON\.stringify\(.*patient` | WARN | JS/TS | Full patient object serialization |
123
+ | `json\.dumps\(.*patient` | WARN | Python | Full patient object serialization |
124
+ | `JsonConvert\.Serialize.*patient` | WARN | C# | Full patient object serialization |
125
+
126
+ ---
127
+
128
+ #### Category 2: Missing Audit Logging
129
+
130
+ *Compliance mode only. Heuristic — flags potential gaps, not definitive findings.*
131
+
132
+ > **Developer mode**: This category is skipped. Run with `--mode compliance` to include audit gap checks.
133
+
134
+ Scan the full project for files that handle PHI data operations but lack audit-related keywords.
135
+
136
+ **PHI route file definition**: A file qualifies if it contains BOTH:
137
+ 1. A healthcare keyword from Step 0 (`patient`, `diagnosis`, `medication`, etc.)
138
+ 2. A data operation pattern: `router`, `app.get`, `app.post`, `app.put`, `app.delete`, `@RequestMapping`, `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, `Model.find`, `Model.save`, `Model.update`, `db.query`, `db.execute`, `cursor.execute`, `repository.`, `findBy`, `save(`, `delete(`
139
+
140
+ Files with a healthcare keyword but no data operation pattern are excluded.
141
+
142
+ **Audit keywords** (co-occurrence check): `audit`, `AuditEvent`, `auditLog`, `logAccess`, `logEvent`, `createAuditEntry`, `recordAccess`, `ActivityLog`, `trail`, `writeAudit`
143
+
144
+ | Pattern | Severity | Description |
145
+ |---------|----------|-------------|
146
+ | PHI route file without any audit keywords in same file | HIGH | §164.312(b) — POTENTIAL audit gap: verify audit controls exist in call chain |
147
+ | CRUD operations on patient resources without audit keywords in same file | HIGH | POTENTIAL gap: all PHI access must be logged |
148
+ | Admin operations without audit trail reference | WARN | POTENTIAL gap: administrative actions need recording |
149
+ | Bulk data operations (`export`, `download`, `bulk`, `batch`) on PHI resources without audit keywords in same file | HIGH | POTENTIAL gap: mass PHI access must be tracked |
150
+
151
+ > **Note**: This category uses co-occurrence heuristics — checking whether PHI route keywords and audit keywords appear in the same file. False positives are expected when audit logging is handled by middleware or a separate call chain. Use `.hipaaignore` to suppress confirmed false positives.
152
+
153
+ See: [reference/hipaa-rules.md](reference/hipaa-rules.md) §164.312(b) for audit control requirements.
154
+
155
+ ---
156
+
157
+ #### Category 3: Unencrypted PHI Transmission
158
+
159
+ *Context-gated: scans PHI-adjacent files only.*
160
+
161
+ | Pattern | Severity | Description |
162
+ |---------|----------|-------------|
163
+ | `http://` in API calls (not `localhost`/`127.0.0.1`) | HIGH | §164.312(e)(1) requires encryption in transit |
164
+ | Missing TLS/SSL config in database connections | HIGH | Database connections must be encrypted |
165
+ | `rejectUnauthorized:\s*false` | HIGH | TLS verification disabled |
166
+ | `ws://` (WebSocket without TLS) | WARN | Unencrypted WebSocket may carry PHI |
167
+ | Email sending without TLS config | WARN | PHI in email must use TLS |
168
+
169
+ See: [reference/hipaa-rules.md](reference/hipaa-rules.md) §164.312(e)(1) for transmission security requirements.
170
+
171
+ ---
172
+
173
+ #### Category 4: Hardcoded PHI/Test Data
174
+
175
+ *Context-gated: scans PHI-adjacent files only.*
176
+
177
+ **Built-in test directory exclusions**: Skip files in `test/`, `tests/`, `__tests__/`, `spec/`, `fixtures/`, `mocks/`, `__mocks__/`, `testdata/`, `test-data/` — test fixtures legitimately contain synthetic PHI.
178
+
179
+ | Pattern | Severity | Description |
180
+ |---------|----------|-------------|
181
+ | `\d{3}-\d{2}-\d{4}` in PHI-adjacent source files | HIGH | Hardcoded SSNs |
182
+ | MRN patterns near healthcare keywords | HIGH | Medical record numbers in code |
183
+ | `\b\d{5}(-\d{4})?\b` near `zip\|postal\|address` keywords | WARN | ZIP codes in healthcare context (§164.514(b)(2)(i)(B)) |
184
+ | Real-looking patient names in seed/fixture data | WARN | Use synthetic data generators |
185
+ | Date of birth + name co-occurrence in same file | WARN | Combined identifiers = PHI |
186
+ | Phone/email/IP regex matches in PHI-adjacent files | WARN | HIPAA identifiers in healthcare context |
187
+ | `\d{3}[\s.-]?\d{3}[\s.-]?\d{4}` near `phone` keyword | WARN | Phone numbers in healthcare context |
188
+
189
+ See: [reference/phi-identifiers.md](reference/phi-identifiers.md) for the full list of 18 HIPAA identifiers and detection patterns.
190
+
191
+ ---
192
+
193
+ #### Category 5: Access Control Gaps
194
+
195
+ *Context-gated: scans PHI-adjacent files only. Heuristic — flags potential gaps.*
196
+
197
+ **Auth keywords** (co-occurrence check): `auth`, `authenticate`, `requireAuth`, `isAuthenticated`, `protect`, `guard`, `Authorize`, `login_required`, `Permission`
198
+
199
+ | Pattern | Severity | Description |
200
+ |---------|----------|-------------|
201
+ | PHI route file without any auth keywords in same file | WARN | POTENTIAL access control gap — verify auth middleware covers these routes (§164.312(d)) |
202
+ | `Access-Control-Allow-Origin:\s*\*` or `origin:\s*(true\|\*)` in PHI-adjacent files | HIGH | Unrestricted cross-origin access to PHI endpoints |
203
+ | Routes marked `public`, `noAuth`, `anonymous` exposing PHI keywords | HIGH | PHI must require authentication |
204
+
205
+ > **Note**: Auth middleware is commonly applied at router-level or app-level. The co-occurrence heuristic checks the same file only. False positives expected when auth is configured globally. Use `.hipaaignore` to suppress.
206
+
207
+ See: [reference/hipaa-rules.md](reference/hipaa-rules.md) §164.312(a)(1) and §164.312(d) for access control and authentication requirements.
208
+
209
+ ---
210
+
211
+ #### Category 6: Missing BAA References
212
+
213
+ *Compliance mode only. Context-gated: scans PHI-adjacent files only.*
214
+
215
+ > **Developer mode**: This category is skipped. Run with `--mode compliance` to include BAA checks.
216
+
217
+ Instead of per-finding rows, emit a single **BAA Verification Checklist** in the compliance report:
218
+
219
+ 1. Grep PHI-adjacent files for HTTP client calls (`fetch(`, `axios.`, `requests.`, `http.Get`, `HttpClient`, `RestTemplate`, `urllib`). Extract external domains.
220
+ 2. Grep for cloud storage calls (`S3`, `GCS`, `BlobStorage`, `putObject`, `upload`). Note each service.
221
+ 3. Grep for cloud database connections (`mongodb+srv://`, `postgres://`, `mysql://`, `firestore`, `dynamodb`, `CosmosClient`, `MongoClient`, connection strings with cloud hostnames). Note each service.
222
+ 4. Grep for message queue / event streaming services (`SQS`, `SNS`, `RabbitMQ`, `redis://`, `kafka`, `EventBridge`, `PubSub`). Note each service.
223
+ 5. Grep for CDN references (`CloudFront`, `Cloudflare`, `Akamai`, `Fastly`, `cdn.`) serving PHI-adjacent paths. Note each service.
224
+ 6. Grep for observability / logging SDKs (`datadog`, `splunk`, `newrelic`, `sentry`, `logstash`, `elasticsearch`, `bugsnag`, `rollbar`). Note each SDK.
225
+ 7. Grep for analytics SDK calls (`analytics.`, `gtag`, `mixpanel`, `segment`, `amplitude`, `posthog`). Note each SDK.
226
+ 8. Read `.hipaa-config` at project root if it exists. Suppress vendors listed under `covered_vendors`.
227
+ 9. Emit one checklist row per unverified domain/service.
228
+
229
+ **`.hipaa-config` format** (suppress known-covered vendors):
230
+ ```json
231
+ {
232
+ "covered_vendors": ["aws", "twilio", "sendgrid", "stripe"]
233
+ }
234
+ ```
235
+
236
+ **Output format for compliance mode**:
237
+ ```
238
+ ### BAA Verification Checklist
239
+ | Service/Domain | Pattern Detected | BAA Status |
240
+ |----------------|-----------------|------------|
241
+ | AWS S3 | `putObject` in src/storage/patient-files.ts | ✓ covered (covered_vendors) |
242
+ | sendgrid.com | `axios.post` in src/notifications/email.ts | ⚠️ verify BAA exists |
243
+ | analytics.google.com | `gtag` in src/components/Dashboard.tsx | ❌ verify no PHI flows here |
244
+ ```
245
+
246
+ > **Note**: This is a documentation checklist, not a legal review. Items marked ⚠️ or ❌ require human verification, not code changes.
247
+
248
+ ---
249
+
250
+ #### Category 7: Encryption at Rest
251
+
252
+ *Context-gated: scans PHI-adjacent files only. Developer mode.*
253
+
254
+ Detects PHI storage patterns without encryption references. Per §164.312(a)(2)(iv), ePHI must be encrypted when stored.
255
+
256
+ | Pattern | Severity | Description |
257
+ |---------|----------|-------------|
258
+ | `encrypt\s*[:=]\s*false` in database config files | HIGH | §164.312(a)(2)(iv) — Encryption explicitly disabled |
259
+ | File write operations (`writeFile`, `fs.write`, `open(.*w`, `File.Create`) in PHI-adjacent code without encryption references | WARN | PHI written to disk may lack encryption at rest |
260
+ | Database connection without `ssl`, `encrypt`, or `tls` keywords in PHI-adjacent config | WARN | Database storing PHI should enforce encrypted connections |
261
+ | `localStorage.setItem` or `sessionStorage.setItem` with PHI keywords | HIGH | Browser storage is unencrypted — PHI must not be stored client-side without encryption |
262
+ | `SharedPreferences` or `UserDefaults` with PHI keywords | HIGH | Mobile local storage is unencrypted by default |
263
+
264
+ See: [reference/hipaa-rules.md](reference/hipaa-rules.md) §164.312(a)(2)(iv) for encryption requirements.
265
+
266
+ ---
267
+
268
+ #### Category 8: PHI Temp File Exposure
269
+
270
+ *Context-gated: scans PHI-adjacent files only. Developer mode.*
271
+
272
+ Detects temporary file creation in PHI-adjacent code without secure deletion. Per §164.310(d)(2)(iii), media containing PHI must be sanitized before reuse or disposal.
273
+
274
+ | Pattern | Severity | Description |
275
+ |---------|----------|-------------|
276
+ | `/tmp/` or `tempfile\.` or `os\.tmpdir\(\)` or `Path\.GetTempPath` in PHI-adjacent code | WARN | §164.310(d)(2)(iii) — Temp files with PHI must be securely deleted |
277
+ | `mktemp` or `NamedTemporaryFile` or `createTempFile` near PHI keywords | WARN | Verify temp files are cleaned up after use |
278
+ | Cache directory writes (`cache/`, `.cache`, `Cache.set`) with PHI keywords | WARN | Cached PHI must be encrypted or purged on schedule |
279
+
280
+ See: [reference/hipaa-rules.md](reference/hipaa-rules.md) §164.310(d)(2)(iii) for disposal requirements.
281
+
282
+ ### Step 3: Compile and Report
283
+
284
+ Present the scanner output to the user. Sort by severity (HIGH first), then by file path.
285
+
286
+ ## Output Format
287
+
288
+ ```markdown
289
+ ## HIPAA Validation Report
290
+
291
+ ### Summary
292
+ | Metric | Value |
293
+ |--------|-------|
294
+ | Mode | developer / compliance |
295
+ | PHI-adjacent files | N |
296
+ | Files scanned | N |
297
+ | Categories run | 1,3,4,7,8 (developer) / 1,2,3,4,5,6,7,8 (compliance) |
298
+ | Severity HIGH | N |
299
+ | Severity WARN | N |
300
+
301
+ ### Findings
302
+
303
+ #### [HIGH] src/api/patients.ts:42
304
+ Category: PHI in Logs
305
+ Confidence: definitive (regex match)
306
+ Pattern: `console.log(patient.name)`
307
+ HIPAA Rule: §164.502(b) — Minimum Necessary Standard
308
+ Fix: Replace with `safeLog()` or remove PHI from log output
309
+
310
+ #### [HIGH] src/routes/patient-api.ts:15
311
+ Category: Missing Audit Logging
312
+ Confidence: heuristic (co-occurrence check — may be false positive)
313
+ Pattern: PHI route file without audit keywords
314
+ HIPAA Rule: §164.312(b) — Audit Controls
315
+ Fix: Verify audit logging exists in call chain; add AuditEvent creation if missing
316
+
317
+ #### [WARN] src/services/patient-sync.ts:88
318
+ Category: Unencrypted PHI Transmission
319
+ Confidence: definitive (regex match)
320
+ Pattern: `http://external-api.example.com/patients`
321
+ HIPAA Rule: §164.312(e)(1) — Transmission Security
322
+ Fix: Use HTTPS for all PHI transmission
323
+ ```
324
+
325
+ **Confidence values**:
326
+ - `definitive` — Categories 1, 3, 4, 7, 8: regex matched actual code
327
+ - `heuristic` — Categories 2, 5, 6: co-occurrence/absence check, may be false positive
328
+
329
+ This distinction helps compliance officers prioritize immediate remediation (definitive) vs. investigation (heuristic).
330
+
331
+ ## Rules
332
+
333
+ - **Read-only**: Never modify any files. Report findings only.
334
+ - **HIPAA rule citation**: Every finding must reference a specific HIPAA section (§ number).
335
+ - **Skip non-source files**: Binary files, lock files (`*.lock`, `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`), vendored directories (`node_modules/`, `vendor/`, `.git/`, `dist/`, `build/`, `out/`, `.next/`).
336
+ - **Respect `.hipaaignore`**: Honor exclusion patterns in the project's `.hipaaignore` file.
337
+ - **No false confidence**: Clearly label heuristic findings as `POTENTIAL` and mark confidence as `heuristic`.
338
+ - **Context before identifiers**: Always run the healthcare keyword context gate before applying PHI identifier regex patterns (Category 4) to avoid false positives.
339
+ - **Warn on missing secrets management**: Flag PHI-adjacent config files without `.env` or secret manager references.
340
+ - **No auto-fix in v1**: Auto-fixing HIPAA issues requires project-specific knowledge of logging/audit infrastructure. Planned for v2.
341
+
342
+ ## Reference Documents
343
+
344
+ - [reference/hipaa-rules.md](reference/hipaa-rules.md) — HIPAA Security Rule, Privacy Rule, and Breach Notification Rule mapped to technical controls
345
+ - [reference/phi-identifiers.md](reference/phi-identifiers.md) — The 18 HIPAA identifiers with detection patterns and detectability status