verification-layer 0.17.0 → 0.19.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/README.md +129 -9
- package/dist/ai/cache.d.ts +15 -0
- package/dist/ai/cache.d.ts.map +1 -0
- package/dist/ai/cache.js +75 -0
- package/dist/ai/cache.js.map +1 -0
- package/dist/ai/client.d.ts +11 -0
- package/dist/ai/client.d.ts.map +1 -0
- package/dist/ai/client.js +27 -0
- package/dist/ai/client.js.map +1 -0
- package/dist/ai/config.d.ts +29 -0
- package/dist/ai/config.d.ts.map +1 -0
- package/dist/ai/config.js +29 -0
- package/dist/ai/config.js.map +1 -0
- package/dist/ai/cost-tracker.d.ts +23 -0
- package/dist/ai/cost-tracker.d.ts.map +1 -0
- package/dist/ai/cost-tracker.js +55 -0
- package/dist/ai/cost-tracker.js.map +1 -0
- package/dist/ai/index.d.ts +16 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +13 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/rate-limiter.d.ts +16 -0
- package/dist/ai/rate-limiter.d.ts.map +1 -0
- package/dist/ai/rate-limiter.js +51 -0
- package/dist/ai/rate-limiter.js.map +1 -0
- package/dist/ai/rules/index.d.ts +11 -0
- package/dist/ai/rules/index.d.ts.map +1 -0
- package/dist/ai/rules/index.js +57 -0
- package/dist/ai/rules/index.js.map +1 -0
- package/dist/ai/rules/prompts/audit-logging.d.ts +7 -0
- package/dist/ai/rules/prompts/audit-logging.d.ts.map +1 -0
- package/dist/ai/rules/prompts/audit-logging.js +65 -0
- package/dist/ai/rules/prompts/audit-logging.js.map +1 -0
- package/dist/ai/rules/prompts/data-retention.d.ts +7 -0
- package/dist/ai/rules/prompts/data-retention.d.ts.map +1 -0
- package/dist/ai/rules/prompts/data-retention.js +60 -0
- package/dist/ai/rules/prompts/data-retention.js.map +1 -0
- package/dist/ai/rules/prompts/minimum-access.d.ts +7 -0
- package/dist/ai/rules/prompts/minimum-access.d.ts.map +1 -0
- package/dist/ai/rules/prompts/minimum-access.js +53 -0
- package/dist/ai/rules/prompts/minimum-access.js.map +1 -0
- package/dist/ai/rules/prompts/phi-encryption.d.ts +7 -0
- package/dist/ai/rules/prompts/phi-encryption.d.ts.map +1 -0
- package/dist/ai/rules/prompts/phi-encryption.js +60 -0
- package/dist/ai/rules/prompts/phi-encryption.js.map +1 -0
- package/dist/ai/rules/prompts/rbac-check.d.ts +7 -0
- package/dist/ai/rules/prompts/rbac-check.d.ts.map +1 -0
- package/dist/ai/rules/prompts/rbac-check.js +61 -0
- package/dist/ai/rules/prompts/rbac-check.js.map +1 -0
- package/dist/ai/rules/prompts/session-management.d.ts +7 -0
- package/dist/ai/rules/prompts/session-management.d.ts.map +1 -0
- package/dist/ai/rules/prompts/session-management.js +62 -0
- package/dist/ai/rules/prompts/session-management.js.map +1 -0
- package/dist/ai/rules/rule-runner.d.ts +36 -0
- package/dist/ai/rules/rule-runner.d.ts.map +1 -0
- package/dist/ai/rules/rule-runner.js +117 -0
- package/dist/ai/rules/rule-runner.js.map +1 -0
- package/dist/ai/rules/triage.d.ts +11 -0
- package/dist/ai/rules/triage.d.ts.map +1 -0
- package/dist/ai/rules/triage.js +107 -0
- package/dist/ai/rules/triage.js.map +1 -0
- package/dist/ai/rules/types.d.ts +33 -0
- package/dist/ai/rules/types.d.ts.map +1 -0
- package/dist/ai/rules/types.js +5 -0
- package/dist/ai/rules/types.js.map +1 -0
- package/dist/ai/sanitizer.d.ts +21 -0
- package/dist/ai/sanitizer.d.ts.map +1 -0
- package/dist/ai/sanitizer.js +81 -0
- package/dist/ai/sanitizer.js.map +1 -0
- package/dist/ai/scanner.d.ts +31 -0
- package/dist/ai/scanner.d.ts.map +1 -0
- package/dist/ai/scanner.js +93 -0
- package/dist/ai/scanner.js.map +1 -0
- package/dist/cli.js +97 -0
- package/dist/cli.js.map +1 -1
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +33 -0
- package/dist/scan.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-Powered HIPAA Rules
|
|
3
|
+
* Export all LLM-based detection rules
|
|
4
|
+
*/
|
|
5
|
+
import { MINIMUM_ACCESS_SYSTEM_PROMPT, MINIMUM_ACCESS_USER_PROMPT, } from './prompts/minimum-access.js';
|
|
6
|
+
import { PHI_ENCRYPTION_SYSTEM_PROMPT, PHI_ENCRYPTION_USER_PROMPT, } from './prompts/phi-encryption.js';
|
|
7
|
+
import { RBAC_CHECK_SYSTEM_PROMPT, RBAC_CHECK_USER_PROMPT, } from './prompts/rbac-check.js';
|
|
8
|
+
import { AUDIT_LOGGING_SYSTEM_PROMPT, AUDIT_LOGGING_USER_PROMPT, } from './prompts/audit-logging.js';
|
|
9
|
+
import { DATA_RETENTION_SYSTEM_PROMPT, DATA_RETENTION_USER_PROMPT, } from './prompts/data-retention.js';
|
|
10
|
+
import { SESSION_MANAGEMENT_SYSTEM_PROMPT, SESSION_MANAGEMENT_USER_PROMPT, } from './prompts/session-management.js';
|
|
11
|
+
export const AI_RULES = [
|
|
12
|
+
{
|
|
13
|
+
id: 'HIPAA-PHI-003',
|
|
14
|
+
name: 'Minimum Necessary Access',
|
|
15
|
+
category: 'phi',
|
|
16
|
+
systemPrompt: MINIMUM_ACCESS_SYSTEM_PROMPT,
|
|
17
|
+
userPromptTemplate: MINIMUM_ACCESS_USER_PROMPT,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'HIPAA-SEC-001',
|
|
21
|
+
name: 'PHI Encryption',
|
|
22
|
+
category: 'encryption',
|
|
23
|
+
systemPrompt: PHI_ENCRYPTION_SYSTEM_PROMPT,
|
|
24
|
+
userPromptTemplate: PHI_ENCRYPTION_USER_PROMPT,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'HIPAA-ACCESS-001',
|
|
28
|
+
name: 'Role-Based Access Control',
|
|
29
|
+
category: 'access',
|
|
30
|
+
systemPrompt: RBAC_CHECK_SYSTEM_PROMPT,
|
|
31
|
+
userPromptTemplate: RBAC_CHECK_USER_PROMPT,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'HIPAA-AUDIT-001',
|
|
35
|
+
name: 'Audit Logging',
|
|
36
|
+
category: 'audit',
|
|
37
|
+
systemPrompt: AUDIT_LOGGING_SYSTEM_PROMPT,
|
|
38
|
+
userPromptTemplate: AUDIT_LOGGING_USER_PROMPT,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'HIPAA-RETENTION-001',
|
|
42
|
+
name: 'Data Retention',
|
|
43
|
+
category: 'retention',
|
|
44
|
+
systemPrompt: DATA_RETENTION_SYSTEM_PROMPT,
|
|
45
|
+
userPromptTemplate: DATA_RETENTION_USER_PROMPT,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'HIPAA-AUTH-001',
|
|
49
|
+
name: 'Session Management',
|
|
50
|
+
category: 'access',
|
|
51
|
+
systemPrompt: SESSION_MANAGEMENT_SYSTEM_PROMPT,
|
|
52
|
+
userPromptTemplate: SESSION_MANAGEMENT_USER_PROMPT,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
export { RuleRunner } from './rule-runner.js';
|
|
56
|
+
export { triageFinding, triageFindings } from './triage.js';
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ai/rules/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAc;IACjC;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,4BAA4B;QAC1C,kBAAkB,EAAE,0BAA0B;KAC/C;IACD;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE,4BAA4B;QAC1C,kBAAkB,EAAE,0BAA0B;KAC/C;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,IAAI,EAAE,2BAA2B;QACjC,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,wBAAwB;QACtC,kBAAkB,EAAE,sBAAsB;KAC3C;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,OAAO;QACjB,YAAY,EAAE,2BAA2B;QACzC,kBAAkB,EAAE,yBAAyB;KAC9C;IACD;QACE,EAAE,EAAE,qBAAqB;QACzB,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE,4BAA4B;QAC1C,kBAAkB,EAAE,0BAA0B;KAC/C;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,gCAAgC;QAC9C,kBAAkB,EAAE,8BAA8B;KACnD;CACF,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-AUDIT-001: Audit Logging Rule
|
|
3
|
+
* Detects missing audit logs for PHI operations
|
|
4
|
+
*/
|
|
5
|
+
export declare const AUDIT_LOGGING_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for audit logging violations.\n\nHIPAA \u00A7164.308(a)(1)(ii)(D) and \u00A7164.312(b) require audit controls to record and examine PHI access and activity.\n\nCommon violations:\n1. PHI read/write/delete operations without audit logging\n2. Authentication events (login/logout) not logged\n3. Missing user ID, timestamp, or action in audit logs\n4. Logs stored insecurely or without retention\n5. Admin actions (role changes, permission grants) not logged\n6. PHI exports or bulk operations not logged\n\nRequired audit log fields:\n- User ID / actor\n- Timestamp\n- Action performed (read, create, update, delete, export)\n- Resource accessed (patient ID, record type)\n- Outcome (success/failure)\n- IP address (optional but recommended)\n\nLook for:\n- Database queries (SELECT, UPDATE, DELETE) on PHI tables without subsequent log statement\n- API endpoints returning patient data without auditLog() call\n- File operations (readFile, writeFile) with PHI without logging\n- Authentication functions without audit trail\n- Missing audit logging framework/middleware\n\nBe contextual:\n- Internal helper functions may not need logging if the caller logs\n- Test files don't need audit logging\n- Some frameworks have automatic audit logging middleware\n- Logging \"user viewed dashboard\" is not required, but \"user accessed patient 123 record\" is";
|
|
6
|
+
export declare const AUDIT_LOGGING_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=audit-logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-logging.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/audit-logging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,2BAA2B,83CA+BqD,CAAC;AAE9F,eAAO,MAAM,yBAAyB,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2BhF,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-AUDIT-001: Audit Logging Rule
|
|
3
|
+
* Detects missing audit logs for PHI operations
|
|
4
|
+
*/
|
|
5
|
+
export const AUDIT_LOGGING_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for audit logging violations.
|
|
6
|
+
|
|
7
|
+
HIPAA §164.308(a)(1)(ii)(D) and §164.312(b) require audit controls to record and examine PHI access and activity.
|
|
8
|
+
|
|
9
|
+
Common violations:
|
|
10
|
+
1. PHI read/write/delete operations without audit logging
|
|
11
|
+
2. Authentication events (login/logout) not logged
|
|
12
|
+
3. Missing user ID, timestamp, or action in audit logs
|
|
13
|
+
4. Logs stored insecurely or without retention
|
|
14
|
+
5. Admin actions (role changes, permission grants) not logged
|
|
15
|
+
6. PHI exports or bulk operations not logged
|
|
16
|
+
|
|
17
|
+
Required audit log fields:
|
|
18
|
+
- User ID / actor
|
|
19
|
+
- Timestamp
|
|
20
|
+
- Action performed (read, create, update, delete, export)
|
|
21
|
+
- Resource accessed (patient ID, record type)
|
|
22
|
+
- Outcome (success/failure)
|
|
23
|
+
- IP address (optional but recommended)
|
|
24
|
+
|
|
25
|
+
Look for:
|
|
26
|
+
- Database queries (SELECT, UPDATE, DELETE) on PHI tables without subsequent log statement
|
|
27
|
+
- API endpoints returning patient data without auditLog() call
|
|
28
|
+
- File operations (readFile, writeFile) with PHI without logging
|
|
29
|
+
- Authentication functions without audit trail
|
|
30
|
+
- Missing audit logging framework/middleware
|
|
31
|
+
|
|
32
|
+
Be contextual:
|
|
33
|
+
- Internal helper functions may not need logging if the caller logs
|
|
34
|
+
- Test files don't need audit logging
|
|
35
|
+
- Some frameworks have automatic audit logging middleware
|
|
36
|
+
- Logging "user viewed dashboard" is not required, but "user accessed patient 123 record" is`;
|
|
37
|
+
export const AUDIT_LOGGING_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
38
|
+
Analyze this file for missing audit logging:
|
|
39
|
+
|
|
40
|
+
File: ${filePath}
|
|
41
|
+
Code:
|
|
42
|
+
\`\`\`
|
|
43
|
+
${sanitizedCode}
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
Find instances where PHI operations occur without proper audit logging.
|
|
47
|
+
|
|
48
|
+
Respond in JSON:
|
|
49
|
+
{
|
|
50
|
+
"findings": [
|
|
51
|
+
{
|
|
52
|
+
"line": number,
|
|
53
|
+
"severity": "high" | "medium",
|
|
54
|
+
"message": "Brief description of the violation",
|
|
55
|
+
"suggestion": "How to fix (be specific - e.g., 'Add auditLog.record({ userId, action: \"PHI_READ\", resourceId: patientId })')",
|
|
56
|
+
"hipaaReference": "§164.308(a)(1)(ii)(D) - Audit Controls",
|
|
57
|
+
"confidence": 0.0-1.0
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"summary": "Overall assessment"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
If no violations found, return empty findings array.
|
|
64
|
+
`;
|
|
65
|
+
//# sourceMappingURL=audit-logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-logging.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/audit-logging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6FA+BkD,CAAC;AAE9F,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAG9E,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-RETENTION-001: Data Retention Rule
|
|
3
|
+
* Detects improper data retention and deletion
|
|
4
|
+
*/
|
|
5
|
+
export declare const DATA_RETENTION_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for data retention violations.\n\nHIPAA \u00A7164.530(j) requires retention of PHI and documentation for at least 6 years. However, when data is no longer needed, it must be securely deleted.\n\nCommon violations:\n1. Hard delete operations that don't retain audit trail\n2. Missing retention policies for PHI\n3. Immediate permanent deletion without soft delete period\n4. Backup retention policies not implemented\n5. PHI kept indefinitely without justification\n6. Deletion without secure wiping (e.g., just unlinking files)\n7. Missing automated retention enforcement\n\nLook for:\n- DELETE queries without corresponding archive/audit entry\n- File deletion (unlink, rm) of PHI without secure wipe\n- User account deletion immediately removing all PHI (should soft delete first)\n- Missing createdAt/deletedAt timestamps for retention tracking\n- No TTL or retention period configuration\n- Lack of soft delete pattern (deletedAt field)\n\nBe contextual:\n- Test data can be hard deleted\n- Non-PHI data doesn't need special retention\n- Some systems use event sourcing (all history retained by design)\n- Cloud services may handle secure deletion at infrastructure level\n- Retention requirements vary by state law (some require 7-10 years)";
|
|
6
|
+
export declare const DATA_RETENTION_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=data-retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-retention.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/data-retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,4BAA4B,mxCA0B4B,CAAC;AAEtE,eAAO,MAAM,0BAA0B,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2BjF,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-RETENTION-001: Data Retention Rule
|
|
3
|
+
* Detects improper data retention and deletion
|
|
4
|
+
*/
|
|
5
|
+
export const DATA_RETENTION_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for data retention violations.
|
|
6
|
+
|
|
7
|
+
HIPAA §164.530(j) requires retention of PHI and documentation for at least 6 years. However, when data is no longer needed, it must be securely deleted.
|
|
8
|
+
|
|
9
|
+
Common violations:
|
|
10
|
+
1. Hard delete operations that don't retain audit trail
|
|
11
|
+
2. Missing retention policies for PHI
|
|
12
|
+
3. Immediate permanent deletion without soft delete period
|
|
13
|
+
4. Backup retention policies not implemented
|
|
14
|
+
5. PHI kept indefinitely without justification
|
|
15
|
+
6. Deletion without secure wiping (e.g., just unlinking files)
|
|
16
|
+
7. Missing automated retention enforcement
|
|
17
|
+
|
|
18
|
+
Look for:
|
|
19
|
+
- DELETE queries without corresponding archive/audit entry
|
|
20
|
+
- File deletion (unlink, rm) of PHI without secure wipe
|
|
21
|
+
- User account deletion immediately removing all PHI (should soft delete first)
|
|
22
|
+
- Missing createdAt/deletedAt timestamps for retention tracking
|
|
23
|
+
- No TTL or retention period configuration
|
|
24
|
+
- Lack of soft delete pattern (deletedAt field)
|
|
25
|
+
|
|
26
|
+
Be contextual:
|
|
27
|
+
- Test data can be hard deleted
|
|
28
|
+
- Non-PHI data doesn't need special retention
|
|
29
|
+
- Some systems use event sourcing (all history retained by design)
|
|
30
|
+
- Cloud services may handle secure deletion at infrastructure level
|
|
31
|
+
- Retention requirements vary by state law (some require 7-10 years)`;
|
|
32
|
+
export const DATA_RETENTION_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
33
|
+
Analyze this file for data retention violations:
|
|
34
|
+
|
|
35
|
+
File: ${filePath}
|
|
36
|
+
Code:
|
|
37
|
+
\`\`\`
|
|
38
|
+
${sanitizedCode}
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
Find instances where PHI is deleted or retained improperly.
|
|
42
|
+
|
|
43
|
+
Respond in JSON:
|
|
44
|
+
{
|
|
45
|
+
"findings": [
|
|
46
|
+
{
|
|
47
|
+
"line": number,
|
|
48
|
+
"severity": "high" | "medium",
|
|
49
|
+
"message": "Brief description of the violation",
|
|
50
|
+
"suggestion": "How to fix (be specific - e.g., 'Use soft delete pattern with deletedAt field', 'Archive to audit table before DELETE')",
|
|
51
|
+
"hipaaReference": "§164.530(j) - Retention Requirements",
|
|
52
|
+
"confidence": 0.0-1.0
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"summary": "Overall assessment"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
If no violations found, return empty findings array.
|
|
59
|
+
`;
|
|
60
|
+
//# sourceMappingURL=data-retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-retention.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/data-retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;qEA0ByB,CAAC;AAEtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAG/E,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-PHI-003: Minimum Necessary Access Rule
|
|
3
|
+
* Detects APIs that return more PHI than necessary
|
|
4
|
+
*/
|
|
5
|
+
export declare const MINIMUM_ACCESS_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for Minimum Necessary Standard violations.\n\nHIPAA \u00A7164.502(b) requires that covered entities limit PHI to the minimum necessary to accomplish the intended purpose.\n\nCommon violations:\n1. API endpoints that return SELECT * or all patient fields when only a subset is needed\n2. Frontend components that fetch full patient records when only displaying name + appointment time\n3. Queries that join unnecessary PHI tables\n4. Endpoints returning SSN, DOB, diagnosis when not needed for the feature\n\nLook for:\n- Database queries with SELECT * on PHI tables\n- API responses including sensitive fields (ssn, diagnosis, medications) when the feature only needs basic info\n- GraphQL/REST endpoints with overly broad field selection\n- Functions that fetch entire patient objects when only a few fields are used\n\nBe contextual:\n- A \"patient detail page\" legitimately needs full patient data\n- A \"patient list\" or \"appointment calendar\" should NOT include SSN, diagnosis, etc.\n- Admin/BCBA endpoints may need more data than patient-facing endpoints";
|
|
6
|
+
export declare const MINIMUM_ACCESS_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=minimum-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimum-access.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/minimum-access.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,4BAA4B,8lCAmB+B,CAAC;AAEzE,eAAO,MAAM,0BAA0B,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2BjF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-PHI-003: Minimum Necessary Access Rule
|
|
3
|
+
* Detects APIs that return more PHI than necessary
|
|
4
|
+
*/
|
|
5
|
+
export const MINIMUM_ACCESS_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for Minimum Necessary Standard violations.
|
|
6
|
+
|
|
7
|
+
HIPAA §164.502(b) requires that covered entities limit PHI to the minimum necessary to accomplish the intended purpose.
|
|
8
|
+
|
|
9
|
+
Common violations:
|
|
10
|
+
1. API endpoints that return SELECT * or all patient fields when only a subset is needed
|
|
11
|
+
2. Frontend components that fetch full patient records when only displaying name + appointment time
|
|
12
|
+
3. Queries that join unnecessary PHI tables
|
|
13
|
+
4. Endpoints returning SSN, DOB, diagnosis when not needed for the feature
|
|
14
|
+
|
|
15
|
+
Look for:
|
|
16
|
+
- Database queries with SELECT * on PHI tables
|
|
17
|
+
- API responses including sensitive fields (ssn, diagnosis, medications) when the feature only needs basic info
|
|
18
|
+
- GraphQL/REST endpoints with overly broad field selection
|
|
19
|
+
- Functions that fetch entire patient objects when only a few fields are used
|
|
20
|
+
|
|
21
|
+
Be contextual:
|
|
22
|
+
- A "patient detail page" legitimately needs full patient data
|
|
23
|
+
- A "patient list" or "appointment calendar" should NOT include SSN, diagnosis, etc.
|
|
24
|
+
- Admin/BCBA endpoints may need more data than patient-facing endpoints`;
|
|
25
|
+
export const MINIMUM_ACCESS_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
26
|
+
Analyze this file for Minimum Necessary Access violations:
|
|
27
|
+
|
|
28
|
+
File: ${filePath}
|
|
29
|
+
Code:
|
|
30
|
+
\`\`\`
|
|
31
|
+
${sanitizedCode}
|
|
32
|
+
\`\`\`
|
|
33
|
+
|
|
34
|
+
Find instances where the code fetches or returns more PHI than necessary.
|
|
35
|
+
|
|
36
|
+
Respond in JSON:
|
|
37
|
+
{
|
|
38
|
+
"findings": [
|
|
39
|
+
{
|
|
40
|
+
"line": number,
|
|
41
|
+
"severity": "high" | "medium",
|
|
42
|
+
"message": "Brief description of the violation",
|
|
43
|
+
"suggestion": "How to fix (be specific - which fields to include/exclude)",
|
|
44
|
+
"hipaaReference": "§164.502(b) - Minimum Necessary Standard",
|
|
45
|
+
"confidence": 0.0-1.0
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"summary": "Overall assessment"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
If no violations found, return empty findings array.
|
|
52
|
+
`;
|
|
53
|
+
//# sourceMappingURL=minimum-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimum-access.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/minimum-access.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;wEAmB4B,CAAC;AAEzE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAG/E,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-SEC-001: PHI Encryption Rule
|
|
3
|
+
* Detects unencrypted PHI in transit or at rest
|
|
4
|
+
*/
|
|
5
|
+
export declare const PHI_ENCRYPTION_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for encryption violations.\n\nHIPAA \u00A7164.312(a)(2)(iv) and \u00A7164.312(e)(1) require encryption of PHI in transit and at rest.\n\nCommon violations:\n1. HTTP instead of HTTPS for PHI transmission\n2. Storing PHI in plain text files or databases without encryption\n3. Using weak encryption algorithms (MD5, DES, RC4)\n4. Missing TLS/SSL configuration for API endpoints handling PHI\n5. Unencrypted database connections (e.g., postgres:// without SSL)\n6. Local storage or cookies storing PHI without encryption\n7. File uploads with PHI not encrypted before storage\n\nLook for:\n- HTTP URLs in API calls that transmit PHI data\n- Database connection strings without SSL/TLS\n- LocalStorage/sessionStorage/cookies storing sensitive fields\n- File write operations with PHI without encryption wrapper\n- Weak crypto: crypto.createHash('md5'), DES, RC4, SHA1 for passwords\n- Missing HTTPS enforcement middleware\n\nBe contextual:\n- Test environments may use HTTP for localhost (acceptable)\n- Public data doesn't require encryption\n- Encryption at the infrastructure level (e.g., AWS RDS encryption) may not be visible in code";
|
|
6
|
+
export declare const PHI_ENCRYPTION_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=phi-encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phi-encryption.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/phi-encryption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,4BAA4B,oqCAwBsD,CAAC;AAGhG,eAAO,MAAM,0BAA0B,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2BjF,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-SEC-001: PHI Encryption Rule
|
|
3
|
+
* Detects unencrypted PHI in transit or at rest
|
|
4
|
+
*/
|
|
5
|
+
// vlayer-ignore * -- AI prompt file contains example patterns for detection
|
|
6
|
+
export const PHI_ENCRYPTION_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for encryption violations.
|
|
7
|
+
|
|
8
|
+
HIPAA §164.312(a)(2)(iv) and §164.312(e)(1) require encryption of PHI in transit and at rest.
|
|
9
|
+
|
|
10
|
+
Common violations:
|
|
11
|
+
1. HTTP instead of HTTPS for PHI transmission
|
|
12
|
+
2. Storing PHI in plain text files or databases without encryption
|
|
13
|
+
3. Using weak encryption algorithms (MD5, DES, RC4)
|
|
14
|
+
4. Missing TLS/SSL configuration for API endpoints handling PHI
|
|
15
|
+
5. Unencrypted database connections (e.g., postgres:// without SSL)
|
|
16
|
+
6. Local storage or cookies storing PHI without encryption
|
|
17
|
+
7. File uploads with PHI not encrypted before storage
|
|
18
|
+
|
|
19
|
+
Look for:
|
|
20
|
+
- HTTP URLs in API calls that transmit PHI data
|
|
21
|
+
- Database connection strings without SSL/TLS
|
|
22
|
+
- LocalStorage/sessionStorage/cookies storing sensitive fields
|
|
23
|
+
- File write operations with PHI without encryption wrapper
|
|
24
|
+
- Weak crypto: crypto.createHash('md5'), DES, RC4, SHA1 for passwords
|
|
25
|
+
- Missing HTTPS enforcement middleware
|
|
26
|
+
|
|
27
|
+
Be contextual:
|
|
28
|
+
- Test environments may use HTTP for localhost (acceptable)
|
|
29
|
+
- Public data doesn't require encryption
|
|
30
|
+
- Encryption at the infrastructure level (e.g., AWS RDS encryption) may not be visible in code`;
|
|
31
|
+
// vlayer-ignore * -- AI prompt file contains example patterns for detection
|
|
32
|
+
export const PHI_ENCRYPTION_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
33
|
+
Analyze this file for PHI encryption violations:
|
|
34
|
+
|
|
35
|
+
File: ${filePath}
|
|
36
|
+
Code:
|
|
37
|
+
\`\`\`
|
|
38
|
+
${sanitizedCode}
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
Find instances where PHI is transmitted or stored without proper encryption.
|
|
42
|
+
|
|
43
|
+
Respond in JSON:
|
|
44
|
+
{
|
|
45
|
+
"findings": [
|
|
46
|
+
{
|
|
47
|
+
"line": number,
|
|
48
|
+
"severity": "critical" | "high" | "medium",
|
|
49
|
+
"message": "Brief description of the violation",
|
|
50
|
+
"suggestion": "How to fix (be specific - e.g., 'Use HTTPS', 'Add {ssl: true} to connection')",
|
|
51
|
+
"hipaaReference": "§164.312(a)(2)(iv) or §164.312(e)(1)",
|
|
52
|
+
"confidence": 0.0-1.0
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"summary": "Overall assessment"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
If no violations found, return empty findings array.
|
|
59
|
+
`;
|
|
60
|
+
//# sourceMappingURL=phi-encryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phi-encryption.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/phi-encryption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;+FAwBmD,CAAC;AAEhG,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAG/E,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-ACCESS-001: Role-Based Access Control Rule
|
|
3
|
+
* Detects improper access control implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare const RBAC_CHECK_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for access control violations.\n\nHIPAA \u00A7164.308(a)(4) requires implementing access controls to limit PHI access to authorized personnel only.\n\nCommon violations:\n1. Missing authentication checks on PHI endpoints\n2. Hardcoded roles or permissions instead of dynamic RBAC\n3. Client-side only authorization (bypassable)\n4. Missing role validation before PHI operations\n5. Overly permissive CORS allowing any origin\n6. Admin endpoints accessible without proper role checks\n7. Direct object references without ownership validation (IDOR)\n\nLook for:\n- API routes handling PHI without auth middleware\n- Role checks like if (user.role === 'admin') with hardcoded strings\n- CORS: Access-Control-Allow-Origin: * on PHI endpoints\n- Functions that access patient data without verifying user.role or permissions\n- Missing authorization checks in GraphQL resolvers\n- JWT tokens without role claims or missing verification\n\nBe contextual:\n- Public health information (blog posts, FAQs) doesn't need auth\n- Rate limiting endpoints may not need auth\n- Authentication middleware applied at the router level may protect all routes\n- Some frameworks have built-in RBAC (check middleware usage)";
|
|
6
|
+
export declare const RBAC_CHECK_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=rbac-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rbac-check.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/rbac-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,wBAAwB,wuCAyByB,CAAC;AAG/D,eAAO,MAAM,sBAAsB,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2B7E,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-ACCESS-001: Role-Based Access Control Rule
|
|
3
|
+
* Detects improper access control implementation
|
|
4
|
+
*/
|
|
5
|
+
// vlayer-ignore * -- AI prompt file contains example patterns for detection
|
|
6
|
+
export const RBAC_CHECK_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for access control violations.
|
|
7
|
+
|
|
8
|
+
HIPAA §164.308(a)(4) requires implementing access controls to limit PHI access to authorized personnel only.
|
|
9
|
+
|
|
10
|
+
Common violations:
|
|
11
|
+
1. Missing authentication checks on PHI endpoints
|
|
12
|
+
2. Hardcoded roles or permissions instead of dynamic RBAC
|
|
13
|
+
3. Client-side only authorization (bypassable)
|
|
14
|
+
4. Missing role validation before PHI operations
|
|
15
|
+
5. Overly permissive CORS allowing any origin
|
|
16
|
+
6. Admin endpoints accessible without proper role checks
|
|
17
|
+
7. Direct object references without ownership validation (IDOR)
|
|
18
|
+
|
|
19
|
+
Look for:
|
|
20
|
+
- API routes handling PHI without auth middleware
|
|
21
|
+
- Role checks like if (user.role === 'admin') with hardcoded strings
|
|
22
|
+
- CORS: Access-Control-Allow-Origin: * on PHI endpoints
|
|
23
|
+
- Functions that access patient data without verifying user.role or permissions
|
|
24
|
+
- Missing authorization checks in GraphQL resolvers
|
|
25
|
+
- JWT tokens without role claims or missing verification
|
|
26
|
+
|
|
27
|
+
Be contextual:
|
|
28
|
+
- Public health information (blog posts, FAQs) doesn't need auth
|
|
29
|
+
- Rate limiting endpoints may not need auth
|
|
30
|
+
- Authentication middleware applied at the router level may protect all routes
|
|
31
|
+
- Some frameworks have built-in RBAC (check middleware usage)`;
|
|
32
|
+
// vlayer-ignore * -- AI prompt file contains example patterns for detection
|
|
33
|
+
export const RBAC_CHECK_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
34
|
+
Analyze this file for access control violations:
|
|
35
|
+
|
|
36
|
+
File: ${filePath}
|
|
37
|
+
Code:
|
|
38
|
+
\`\`\`
|
|
39
|
+
${sanitizedCode}
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
Find instances where PHI is accessed without proper authorization or role-based access control.
|
|
43
|
+
|
|
44
|
+
Respond in JSON:
|
|
45
|
+
{
|
|
46
|
+
"findings": [
|
|
47
|
+
{
|
|
48
|
+
"line": number,
|
|
49
|
+
"severity": "critical" | "high" | "medium",
|
|
50
|
+
"message": "Brief description of the violation",
|
|
51
|
+
"suggestion": "How to fix (be specific - e.g., 'Add requireAuth middleware', 'Check user.role against resource.ownerId')",
|
|
52
|
+
"hipaaReference": "§164.308(a)(4) - Access Controls",
|
|
53
|
+
"confidence": 0.0-1.0
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"summary": "Overall assessment"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
If no violations found, return empty findings array.
|
|
60
|
+
`;
|
|
61
|
+
//# sourceMappingURL=rbac-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rbac-check.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/rbac-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;8DAyBsB,CAAC;AAE/D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAG3E,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-AUTH-001: Session Management Rule
|
|
3
|
+
* Detects weak session management and authentication issues
|
|
4
|
+
*/
|
|
5
|
+
export declare const SESSION_MANAGEMENT_SYSTEM_PROMPT = "You are a HIPAA compliance expert analyzing code for session management violations.\n\nHIPAA \u00A7164.312(a)(2)(i) requires unique user identification and \u00A7164.312(d) requires automatic logoff.\n\nCommon violations:\n1. Missing session timeout / automatic logoff\n2. Sessions that never expire (no maxAge or TTL)\n3. Session tokens without secure/httpOnly flags\n4. Weak session ID generation (predictable tokens)\n5. Missing session invalidation on logout\n6. Concurrent sessions allowed without limit\n7. Session fixation vulnerabilities (session ID not regenerated after login)\n8. Session data stored client-side without encryption\n\nLook for:\n- Session configuration without timeout (e.g., maxAge: Infinity)\n- Cookie options missing secure: true, httpOnly: true, sameSite: 'strict'\n- JWT tokens without expiration (no exp claim)\n- Login functions that don't regenerate session ID\n- Logout functions that don't destroy session\n- LocalStorage storing session tokens (XSS vulnerable)\n- Session timeouts > 15 minutes for PHI access (HIPAA best practice)\n- Missing CSRF protection on state-changing operations\n\nBe contextual:\n- Development environments may have longer timeouts\n- Remember-me functionality needs careful implementation\n- Some frameworks handle session security by default\n- API-only services may use stateless JWT (still needs expiration)";
|
|
6
|
+
export declare const SESSION_MANAGEMENT_USER_PROMPT: (sanitizedCode: string, filePath: string) => string;
|
|
7
|
+
//# sourceMappingURL=session-management.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-management.d.ts","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/session-management.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,gCAAgC,o2CA4BsB,CAAC;AAEpE,eAAO,MAAM,8BAA8B,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,WA2BrF,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIPAA-AUTH-001: Session Management Rule
|
|
3
|
+
* Detects weak session management and authentication issues
|
|
4
|
+
*/
|
|
5
|
+
export const SESSION_MANAGEMENT_SYSTEM_PROMPT = `You are a HIPAA compliance expert analyzing code for session management violations.
|
|
6
|
+
|
|
7
|
+
HIPAA §164.312(a)(2)(i) requires unique user identification and §164.312(d) requires automatic logoff.
|
|
8
|
+
|
|
9
|
+
Common violations:
|
|
10
|
+
1. Missing session timeout / automatic logoff
|
|
11
|
+
2. Sessions that never expire (no maxAge or TTL)
|
|
12
|
+
3. Session tokens without secure/httpOnly flags
|
|
13
|
+
4. Weak session ID generation (predictable tokens)
|
|
14
|
+
5. Missing session invalidation on logout
|
|
15
|
+
6. Concurrent sessions allowed without limit
|
|
16
|
+
7. Session fixation vulnerabilities (session ID not regenerated after login)
|
|
17
|
+
8. Session data stored client-side without encryption
|
|
18
|
+
|
|
19
|
+
Look for:
|
|
20
|
+
- Session configuration without timeout (e.g., maxAge: Infinity)
|
|
21
|
+
- Cookie options missing secure: true, httpOnly: true, sameSite: 'strict'
|
|
22
|
+
- JWT tokens without expiration (no exp claim)
|
|
23
|
+
- Login functions that don't regenerate session ID
|
|
24
|
+
- Logout functions that don't destroy session
|
|
25
|
+
- LocalStorage storing session tokens (XSS vulnerable)
|
|
26
|
+
- Session timeouts > 15 minutes for PHI access (HIPAA best practice)
|
|
27
|
+
- Missing CSRF protection on state-changing operations
|
|
28
|
+
|
|
29
|
+
Be contextual:
|
|
30
|
+
- Development environments may have longer timeouts
|
|
31
|
+
- Remember-me functionality needs careful implementation
|
|
32
|
+
- Some frameworks handle session security by default
|
|
33
|
+
- API-only services may use stateless JWT (still needs expiration)`;
|
|
34
|
+
export const SESSION_MANAGEMENT_USER_PROMPT = (sanitizedCode, filePath) => `
|
|
35
|
+
Analyze this file for session management violations:
|
|
36
|
+
|
|
37
|
+
File: ${filePath}
|
|
38
|
+
Code:
|
|
39
|
+
\`\`\`
|
|
40
|
+
${sanitizedCode}
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
Find instances where session management is weak or improperly configured.
|
|
44
|
+
|
|
45
|
+
Respond in JSON:
|
|
46
|
+
{
|
|
47
|
+
"findings": [
|
|
48
|
+
{
|
|
49
|
+
"line": number,
|
|
50
|
+
"severity": "critical" | "high" | "medium",
|
|
51
|
+
"message": "Brief description of the violation",
|
|
52
|
+
"suggestion": "How to fix (be specific - e.g., 'Add maxAge: 15 * 60 * 1000 (15 min)', 'Set secure: true, httpOnly: true')",
|
|
53
|
+
"hipaaReference": "§164.312(a)(2)(i) - Unique User ID, §164.312(d) - Automatic Logoff",
|
|
54
|
+
"confidence": 0.0-1.0
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"summary": "Overall assessment"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
If no violations found, return empty findings array.
|
|
61
|
+
`;
|
|
62
|
+
//# sourceMappingURL=session-management.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-management.js","sourceRoot":"","sources":["../../../../src/ai/rules/prompts/session-management.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEA4BmB,CAAC;AAEpE,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC;;;QAGnF,QAAQ;;;EAGd,aAAa;;;;;;;;;;;;;;;;;;;;;CAqBd,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Runner - Orchestrates LLM-powered HIPAA rule execution
|
|
3
|
+
*/
|
|
4
|
+
import { CostTracker } from '../cost-tracker.js';
|
|
5
|
+
import { AICache } from '../cache.js';
|
|
6
|
+
import { RateLimiter } from '../rate-limiter.js';
|
|
7
|
+
import type { AIFinding } from './types.js';
|
|
8
|
+
export interface LLMRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
category: string;
|
|
12
|
+
systemPrompt: string;
|
|
13
|
+
userPromptTemplate: (sanitizedCode: string, filePath: string) => string;
|
|
14
|
+
}
|
|
15
|
+
export declare class RuleRunner {
|
|
16
|
+
private cache;
|
|
17
|
+
private rateLimiter;
|
|
18
|
+
private costTracker;
|
|
19
|
+
constructor(costTracker: CostTracker, cache?: AICache, rateLimiter?: RateLimiter);
|
|
20
|
+
runRule(rule: LLMRule, fileContent: string, filePath: string): Promise<AIFinding[]>;
|
|
21
|
+
private convertToAIFindings;
|
|
22
|
+
runRulesOnFile(rules: LLMRule[], fileContent: string, filePath: string): Promise<AIFinding[]>;
|
|
23
|
+
getStats(): {
|
|
24
|
+
cost: {
|
|
25
|
+
totalCalls: number;
|
|
26
|
+
totalInputTokens: number;
|
|
27
|
+
totalOutputTokens: number;
|
|
28
|
+
estimatedCost: number;
|
|
29
|
+
};
|
|
30
|
+
rateLimit: {
|
|
31
|
+
callsThisMinute: number;
|
|
32
|
+
totalCalls: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=rule-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-runner.d.ts","sourceRoot":"","sources":["../../../src/ai/rules/rule-runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,YAAY,CAAC;AAG7D,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACzE;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,WAAW,CAAc;gBAG/B,WAAW,EAAE,WAAW,EACxB,KAAK,CAAC,EAAE,OAAO,EACf,WAAW,CAAC,EAAE,WAAW;IAOrB,OAAO,CACX,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,EAAE,CAAC;IA4EvB,OAAO,CAAC,mBAAmB;IAgCrB,cAAc,CAClB,KAAK,EAAE,OAAO,EAAE,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,EAAE,CAAC;IAmBvB,QAAQ;;;;;;;;;;;;CAMT"}
|