guardrail-compliance 1.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.
- package/dist/audit/emitter.d.ts +97 -0
- package/dist/audit/emitter.d.ts.map +1 -0
- package/dist/audit/emitter.js +197 -0
- package/dist/audit/events.d.ts +304 -0
- package/dist/audit/events.d.ts.map +1 -0
- package/dist/audit/events.js +267 -0
- package/dist/audit/index.d.ts +11 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +51 -0
- package/dist/audit/storage.d.ts +93 -0
- package/dist/audit/storage.d.ts.map +1 -0
- package/dist/audit/storage.js +337 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts +2 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts.map +1 -0
- package/dist/automation/__tests__/compliance-scheduler.test.js +140 -0
- package/dist/automation/audit-logger.d.ts +129 -0
- package/dist/automation/audit-logger.d.ts.map +1 -0
- package/dist/automation/audit-logger.js +473 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts +1 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler-fixed.js +1 -0
- package/dist/automation/compliance-scheduler.d.ts +83 -0
- package/dist/automation/compliance-scheduler.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler.js +414 -0
- package/dist/automation/dashboard.d.ts +194 -0
- package/dist/automation/dashboard.d.ts.map +1 -0
- package/dist/automation/dashboard.js +768 -0
- package/dist/automation/email-service.d.ts +69 -0
- package/dist/automation/email-service.d.ts.map +1 -0
- package/dist/automation/email-service.js +218 -0
- package/dist/automation/evidence-collector.d.ts +140 -0
- package/dist/automation/evidence-collector.d.ts.map +1 -0
- package/dist/automation/evidence-collector.js +682 -0
- package/dist/automation/index.d.ts +8 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +24 -0
- package/dist/automation/pdf-exporter.d.ts +90 -0
- package/dist/automation/pdf-exporter.d.ts.map +1 -0
- package/dist/automation/pdf-exporter.js +381 -0
- package/dist/automation/reporting-engine.d.ts +116 -0
- package/dist/automation/reporting-engine.d.ts.map +1 -0
- package/dist/automation/reporting-engine.js +329 -0
- package/dist/container/index.d.ts +4 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +19 -0
- package/dist/container/kubernetes.d.ts +94 -0
- package/dist/container/kubernetes.d.ts.map +1 -0
- package/dist/container/kubernetes.js +268 -0
- package/dist/container/rules.d.ts +27 -0
- package/dist/container/rules.d.ts.map +1 -0
- package/dist/container/rules.js +216 -0
- package/dist/container/scanner.d.ts +50 -0
- package/dist/container/scanner.d.ts.map +1 -0
- package/dist/container/scanner.js +143 -0
- package/dist/frameworks/engine.d.ts +108 -0
- package/dist/frameworks/engine.d.ts.map +1 -0
- package/dist/frameworks/engine.js +206 -0
- package/dist/frameworks/gdpr.d.ts +6 -0
- package/dist/frameworks/gdpr.d.ts.map +1 -0
- package/dist/frameworks/gdpr.js +198 -0
- package/dist/frameworks/hipaa.d.ts +6 -0
- package/dist/frameworks/hipaa.d.ts.map +1 -0
- package/dist/frameworks/hipaa.js +183 -0
- package/dist/frameworks/index.d.ts +8 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +30 -0
- package/dist/frameworks/iso27001.d.ts +63 -0
- package/dist/frameworks/iso27001.d.ts.map +1 -0
- package/dist/frameworks/iso27001.js +331 -0
- package/dist/frameworks/nist.d.ts +62 -0
- package/dist/frameworks/nist.d.ts.map +1 -0
- package/dist/frameworks/nist.js +424 -0
- package/dist/frameworks/pci.d.ts +6 -0
- package/dist/frameworks/pci.d.ts.map +1 -0
- package/dist/frameworks/pci.js +201 -0
- package/dist/frameworks/soc2.d.ts +7 -0
- package/dist/frameworks/soc2.d.ts.map +1 -0
- package/dist/frameworks/soc2.js +248 -0
- package/dist/iac/drift-detector.d.ts +64 -0
- package/dist/iac/drift-detector.d.ts.map +1 -0
- package/dist/iac/drift-detector.js +134 -0
- package/dist/iac/index.d.ts +4 -0
- package/dist/iac/index.d.ts.map +1 -0
- package/dist/iac/index.js +19 -0
- package/dist/iac/rules.d.ts +17 -0
- package/dist/iac/rules.d.ts.map +1 -0
- package/dist/iac/rules.js +385 -0
- package/dist/iac/scanner.d.ts +104 -0
- package/dist/iac/scanner.d.ts.map +1 -0
- package/dist/iac/scanner.js +343 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/pii/data-flow.d.ts +58 -0
- package/dist/pii/data-flow.d.ts.map +1 -0
- package/dist/pii/data-flow.js +154 -0
- package/dist/pii/detector.d.ts +60 -0
- package/dist/pii/detector.d.ts.map +1 -0
- package/dist/pii/detector.js +267 -0
- package/dist/pii/index.d.ts +4 -0
- package/dist/pii/index.d.ts.map +1 -0
- package/dist/pii/index.js +19 -0
- package/dist/pii/patterns.d.ts +36 -0
- package/dist/pii/patterns.d.ts.map +1 -0
- package/dist/pii/patterns.js +108 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +20 -0
- package/dist/policy/opa-engine.d.ts +121 -0
- package/dist/policy/opa-engine.d.ts.map +1 -0
- package/dist/policy/opa-engine.js +423 -0
- package/package.json +31 -0
- package/src/audit/emitter.ts +383 -0
- package/src/audit/events.ts +351 -0
- package/src/audit/index.ts +35 -0
- package/src/audit/storage.ts +394 -0
- package/src/automation/__tests__/compliance-scheduler.test.ts +183 -0
- package/src/automation/audit-logger.ts +629 -0
- package/src/automation/compliance-scheduler-fixed.ts +0 -0
- package/src/automation/compliance-scheduler.ts +516 -0
- package/src/automation/dashboard.ts +947 -0
- package/src/automation/email-service.ts +230 -0
- package/src/automation/evidence-collector.ts +866 -0
- package/src/automation/index.ts +8 -0
- package/src/automation/pdf-exporter.ts +434 -0
- package/src/automation/reporting-engine.ts +462 -0
- package/src/container/index.ts +3 -0
- package/src/container/kubernetes.ts +379 -0
- package/src/container/rules.ts +244 -0
- package/src/container/scanner.ts +202 -0
- package/src/frameworks/engine.ts +298 -0
- package/src/frameworks/gdpr.ts +204 -0
- package/src/frameworks/hipaa.ts +209 -0
- package/src/frameworks/index.ts +23 -0
- package/src/frameworks/iso27001.ts +398 -0
- package/src/frameworks/nist.ts +518 -0
- package/src/frameworks/pci.ts +226 -0
- package/src/frameworks/soc2.ts +281 -0
- package/src/iac/drift-detector.ts +197 -0
- package/src/iac/index.ts +3 -0
- package/src/iac/rules.ts +420 -0
- package/src/iac/scanner.ts +445 -0
- package/src/index.ts +17 -0
- package/src/pii/data-flow.ts +216 -0
- package/src/pii/detector.ts +327 -0
- package/src/pii/index.ts +3 -0
- package/src/pii/patterns.ts +128 -0
- package/src/policy/index.ts +5 -0
- package/src/policy/opa-engine.ts +504 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HIPAA_FRAMEWORK = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* HIPAA (Health Insurance Portability and Accountability Act) Compliance Framework
|
|
8
|
+
*/
|
|
9
|
+
exports.HIPAA_FRAMEWORK = {
|
|
10
|
+
id: 'hipaa',
|
|
11
|
+
name: 'HIPAA Security Rule',
|
|
12
|
+
version: '2013',
|
|
13
|
+
description: 'Health Insurance Portability and Accountability Act',
|
|
14
|
+
controls: [
|
|
15
|
+
{
|
|
16
|
+
id: 'HIPAA-AC',
|
|
17
|
+
title: 'Access Controls',
|
|
18
|
+
description: 'Implement technical policies and procedures for electronic information systems',
|
|
19
|
+
category: 'access-control',
|
|
20
|
+
requirements: [
|
|
21
|
+
'Unique user identification',
|
|
22
|
+
'Emergency access procedure',
|
|
23
|
+
'Automatic logoff',
|
|
24
|
+
'Encryption and decryption'
|
|
25
|
+
],
|
|
26
|
+
automatedChecks: [
|
|
27
|
+
{
|
|
28
|
+
id: 'HIPAA-AC-001',
|
|
29
|
+
description: 'Verify user authentication',
|
|
30
|
+
check: async (projectPath) => {
|
|
31
|
+
const packageJsonPath = (0, path_1.join)(projectPath, 'package.json');
|
|
32
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
33
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
34
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
35
|
+
const authLibs = ['passport', 'jsonwebtoken', 'jose', 'auth0', 'okta'];
|
|
36
|
+
const hasAuth = Object.keys(deps).some(dep => authLibs.some(lib => dep.toLowerCase().includes(lib)));
|
|
37
|
+
if (hasAuth) {
|
|
38
|
+
return {
|
|
39
|
+
passed: true,
|
|
40
|
+
details: 'Authentication library found',
|
|
41
|
+
evidence: { libraries: Object.keys(deps).filter(d => authLibs.some(l => d.toLowerCase().includes(l))) }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
passed: false,
|
|
47
|
+
details: 'No authentication library found'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'HIPAA-AC-002',
|
|
53
|
+
description: 'Check for session management',
|
|
54
|
+
check: async (projectPath) => {
|
|
55
|
+
const packageJsonPath = (0, path_1.join)(projectPath, 'package.json');
|
|
56
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
57
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
58
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
59
|
+
const sessionLibs = ['express-session', 'cookie-session', 'session'];
|
|
60
|
+
const hasSession = Object.keys(deps).some(dep => sessionLibs.some(lib => dep.toLowerCase().includes(lib)));
|
|
61
|
+
if (hasSession) {
|
|
62
|
+
return {
|
|
63
|
+
passed: true,
|
|
64
|
+
details: 'Session management library found'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
passed: false,
|
|
70
|
+
details: 'No session management library found'
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'HIPAA-AUDIT',
|
|
78
|
+
title: 'Audit Controls',
|
|
79
|
+
description: 'Implement hardware, software, and/or procedural mechanisms that record and examine activity',
|
|
80
|
+
category: 'logging',
|
|
81
|
+
requirements: [
|
|
82
|
+
'Record and examine system activity',
|
|
83
|
+
'Log access to ePHI',
|
|
84
|
+
'Maintain audit logs'
|
|
85
|
+
],
|
|
86
|
+
automatedChecks: [
|
|
87
|
+
{
|
|
88
|
+
id: 'HIPAA-AUDIT-001',
|
|
89
|
+
description: 'Verify audit logging',
|
|
90
|
+
check: async (projectPath) => {
|
|
91
|
+
const packageJsonPath = (0, path_1.join)(projectPath, 'package.json');
|
|
92
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
93
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
94
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
95
|
+
const loggingLibs = ['winston', 'pino', 'bunyan', 'morgan'];
|
|
96
|
+
const hasLogging = Object.keys(deps).some(dep => loggingLibs.some(lib => dep.toLowerCase().includes(lib)));
|
|
97
|
+
if (hasLogging) {
|
|
98
|
+
return {
|
|
99
|
+
passed: true,
|
|
100
|
+
details: 'Audit logging library found'
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
passed: false,
|
|
106
|
+
details: 'No audit logging library found'
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 'HIPAA-INTEGRITY',
|
|
114
|
+
title: 'Integrity Controls',
|
|
115
|
+
description: 'Implement policies and procedures to protect ePHI from improper alteration or destruction',
|
|
116
|
+
category: 'data-protection',
|
|
117
|
+
requirements: [
|
|
118
|
+
'Mechanism to authenticate ePHI',
|
|
119
|
+
'Protect against unauthorized modification'
|
|
120
|
+
],
|
|
121
|
+
automatedChecks: [
|
|
122
|
+
{
|
|
123
|
+
id: 'HIPAA-INTEGRITY-001',
|
|
124
|
+
description: 'Check for data validation',
|
|
125
|
+
check: async (projectPath) => {
|
|
126
|
+
const packageJsonPath = (0, path_1.join)(projectPath, 'package.json');
|
|
127
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
128
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
129
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
130
|
+
const validationLibs = ['zod', 'joi', 'yup', 'validator', 'ajv'];
|
|
131
|
+
const hasValidation = Object.keys(deps).some(dep => validationLibs.some(lib => dep.toLowerCase().includes(lib)));
|
|
132
|
+
if (hasValidation) {
|
|
133
|
+
return {
|
|
134
|
+
passed: true,
|
|
135
|
+
details: 'Data validation library found'
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
passed: false,
|
|
141
|
+
details: 'No data validation library found'
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: 'HIPAA-TRANSMISSION',
|
|
149
|
+
title: 'Transmission Security',
|
|
150
|
+
description: 'Implement technical security measures to guard against unauthorized access to ePHI',
|
|
151
|
+
category: 'security',
|
|
152
|
+
requirements: [
|
|
153
|
+
'Integrity controls',
|
|
154
|
+
'Encryption during transmission'
|
|
155
|
+
],
|
|
156
|
+
automatedChecks: [
|
|
157
|
+
{
|
|
158
|
+
id: 'HIPAA-TRANSMISSION-001',
|
|
159
|
+
description: 'Verify encryption in transit',
|
|
160
|
+
check: async (projectPath) => {
|
|
161
|
+
const packageJsonPath = (0, path_1.join)(projectPath, 'package.json');
|
|
162
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
163
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
164
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
165
|
+
const tlsLibs = ['https', 'tls', 'helmet'];
|
|
166
|
+
const hasTLS = Object.keys(deps).some(dep => tlsLibs.some(lib => dep.toLowerCase().includes(lib)));
|
|
167
|
+
if (hasTLS) {
|
|
168
|
+
return {
|
|
169
|
+
passed: true,
|
|
170
|
+
details: 'TLS/HTTPS library found'
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
passed: false,
|
|
176
|
+
details: 'No TLS/HTTPS library found'
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './engine';
|
|
2
|
+
export * from './soc2';
|
|
3
|
+
export * from './gdpr';
|
|
4
|
+
export * from './hipaa';
|
|
5
|
+
export * from './pci';
|
|
6
|
+
export { ISO27001Checker, iso27001Checker, ISO27001_CONTROLS, type ISO27001Control, type ISO27001Check, type ISO27001Category, type ISO27001Report, } from './iso27001';
|
|
7
|
+
export { NISTChecker, nistChecker, NIST_CONTROLS, type NISTControl, type NISTCheck, type NISTFunction, type NISTReport, } from './nist';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frameworks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.NIST_CONTROLS = exports.nistChecker = exports.NISTChecker = exports.ISO27001_CONTROLS = exports.iso27001Checker = exports.ISO27001Checker = void 0;
|
|
18
|
+
__exportStar(require("./engine"), exports);
|
|
19
|
+
__exportStar(require("./soc2"), exports);
|
|
20
|
+
__exportStar(require("./gdpr"), exports);
|
|
21
|
+
__exportStar(require("./hipaa"), exports);
|
|
22
|
+
__exportStar(require("./pci"), exports);
|
|
23
|
+
var iso27001_1 = require("./iso27001");
|
|
24
|
+
Object.defineProperty(exports, "ISO27001Checker", { enumerable: true, get: function () { return iso27001_1.ISO27001Checker; } });
|
|
25
|
+
Object.defineProperty(exports, "iso27001Checker", { enumerable: true, get: function () { return iso27001_1.iso27001Checker; } });
|
|
26
|
+
Object.defineProperty(exports, "ISO27001_CONTROLS", { enumerable: true, get: function () { return iso27001_1.ISO27001_CONTROLS; } });
|
|
27
|
+
var nist_1 = require("./nist");
|
|
28
|
+
Object.defineProperty(exports, "NISTChecker", { enumerable: true, get: function () { return nist_1.NISTChecker; } });
|
|
29
|
+
Object.defineProperty(exports, "nistChecker", { enumerable: true, get: function () { return nist_1.nistChecker; } });
|
|
30
|
+
Object.defineProperty(exports, "NIST_CONTROLS", { enumerable: true, get: function () { return nist_1.NIST_CONTROLS; } });
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO 27001 Compliance Framework
|
|
3
|
+
*
|
|
4
|
+
* Information Security Management System (ISMS) controls
|
|
5
|
+
* Based on ISO/IEC 27001:2022
|
|
6
|
+
*/
|
|
7
|
+
export interface ISO27001Control {
|
|
8
|
+
id: string;
|
|
9
|
+
clause: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
category: ISO27001Category;
|
|
13
|
+
checks: ISO27001Check[];
|
|
14
|
+
}
|
|
15
|
+
export interface ISO27001Check {
|
|
16
|
+
id: string;
|
|
17
|
+
description: string;
|
|
18
|
+
automated: boolean;
|
|
19
|
+
checkFunction?: (context: ComplianceContext) => Promise<CheckResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface CheckResult {
|
|
22
|
+
passed: boolean;
|
|
23
|
+
findings: string[];
|
|
24
|
+
evidence: string[];
|
|
25
|
+
recommendations: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface ComplianceContext {
|
|
28
|
+
projectPath: string;
|
|
29
|
+
codebase: any;
|
|
30
|
+
config: any;
|
|
31
|
+
}
|
|
32
|
+
export type ISO27001Category = 'organizational' | 'people' | 'physical' | 'technological';
|
|
33
|
+
export declare const ISO27001_CONTROLS: ISO27001Control[];
|
|
34
|
+
/**
|
|
35
|
+
* ISO 27001 Compliance Checker
|
|
36
|
+
*/
|
|
37
|
+
export declare class ISO27001Checker {
|
|
38
|
+
/**
|
|
39
|
+
* Run all ISO 27001 compliance checks
|
|
40
|
+
*/
|
|
41
|
+
checkCompliance(context: ComplianceContext): Promise<ISO27001Report>;
|
|
42
|
+
/**
|
|
43
|
+
* Generate prioritized recommendations
|
|
44
|
+
*/
|
|
45
|
+
private generateRecommendations;
|
|
46
|
+
}
|
|
47
|
+
export interface ControlResult {
|
|
48
|
+
control: ISO27001Control;
|
|
49
|
+
passed: boolean;
|
|
50
|
+
checkResults: CheckResult[];
|
|
51
|
+
}
|
|
52
|
+
export interface ISO27001Report {
|
|
53
|
+
framework: string;
|
|
54
|
+
timestamp: string;
|
|
55
|
+
score: number;
|
|
56
|
+
passedControls: number;
|
|
57
|
+
failedControls: number;
|
|
58
|
+
totalControls: number;
|
|
59
|
+
results: ControlResult[];
|
|
60
|
+
recommendations: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare const iso27001Checker: ISO27001Checker;
|
|
63
|
+
//# sourceMappingURL=iso27001.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso27001.d.ts","sourceRoot":"","sources":["../../src/frameworks/iso27001.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,QAAQ,GACR,UAAU,GACV,eAAe,CAAC;AAEpB,eAAO,MAAM,iBAAiB,EAAE,eAAe,EA8P9C,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAwD1E;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAahC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,eAAe,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAGD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ISO 27001 Compliance Framework
|
|
4
|
+
*
|
|
5
|
+
* Information Security Management System (ISMS) controls
|
|
6
|
+
* Based on ISO/IEC 27001:2022
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.iso27001Checker = exports.ISO27001Checker = exports.ISO27001_CONTROLS = void 0;
|
|
10
|
+
exports.ISO27001_CONTROLS = [
|
|
11
|
+
// A.5 - Organizational Controls
|
|
12
|
+
{
|
|
13
|
+
id: 'A.5.1',
|
|
14
|
+
clause: 'A.5.1',
|
|
15
|
+
title: 'Policies for information security',
|
|
16
|
+
description: 'Information security policy and topic-specific policies shall be defined, approved by management, published, communicated to and acknowledged by relevant personnel and relevant interested parties, and reviewed at planned intervals and if significant changes occur.',
|
|
17
|
+
category: 'organizational',
|
|
18
|
+
checks: [
|
|
19
|
+
{
|
|
20
|
+
id: 'A.5.1.1',
|
|
21
|
+
description: 'Security policy documentation exists',
|
|
22
|
+
automated: true,
|
|
23
|
+
checkFunction: async (ctx) => {
|
|
24
|
+
const policyFiles = ['SECURITY.md', 'security-policy.md', 'docs/security.md'];
|
|
25
|
+
const found = policyFiles.some(f => ctx.codebase?.files?.includes(f));
|
|
26
|
+
return {
|
|
27
|
+
passed: found,
|
|
28
|
+
findings: found ? [] : ['No security policy document found'],
|
|
29
|
+
evidence: found ? ['Security policy document exists'] : [],
|
|
30
|
+
recommendations: found ? [] : ['Create a SECURITY.md file documenting security policies'],
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'A.5.7',
|
|
38
|
+
clause: 'A.5.7',
|
|
39
|
+
title: 'Threat intelligence',
|
|
40
|
+
description: 'Information relating to information security threats shall be collected and analysed to produce threat intelligence.',
|
|
41
|
+
category: 'organizational',
|
|
42
|
+
checks: [
|
|
43
|
+
{
|
|
44
|
+
id: 'A.5.7.1',
|
|
45
|
+
description: 'Vulnerability scanning is configured',
|
|
46
|
+
automated: true,
|
|
47
|
+
checkFunction: async (ctx) => {
|
|
48
|
+
const hasVulnScanning = ctx.config?.security?.vulnerabilityScanning !== false;
|
|
49
|
+
return {
|
|
50
|
+
passed: hasVulnScanning,
|
|
51
|
+
findings: hasVulnScanning ? [] : ['Vulnerability scanning not configured'],
|
|
52
|
+
evidence: hasVulnScanning ? ['Vulnerability scanning enabled'] : [],
|
|
53
|
+
recommendations: hasVulnScanning ? [] : ['Enable automated vulnerability scanning'],
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'A.5.15',
|
|
61
|
+
clause: 'A.5.15',
|
|
62
|
+
title: 'Access control',
|
|
63
|
+
description: 'Rules to control physical and logical access to information and other associated assets shall be established and implemented based on business and information security requirements.',
|
|
64
|
+
category: 'organizational',
|
|
65
|
+
checks: [
|
|
66
|
+
{
|
|
67
|
+
id: 'A.5.15.1',
|
|
68
|
+
description: 'Authentication is implemented',
|
|
69
|
+
automated: true,
|
|
70
|
+
checkFunction: async (ctx) => {
|
|
71
|
+
const authPatterns = ['authenticate', 'login', 'jwt', 'session', 'oauth'];
|
|
72
|
+
const hasAuth = authPatterns.some(p => ctx.codebase?.content?.toLowerCase().includes(p));
|
|
73
|
+
return {
|
|
74
|
+
passed: hasAuth,
|
|
75
|
+
findings: hasAuth ? [] : ['No authentication implementation detected'],
|
|
76
|
+
evidence: hasAuth ? ['Authentication patterns found in codebase'] : [],
|
|
77
|
+
recommendations: hasAuth ? [] : ['Implement user authentication'],
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
// A.8 - Technological Controls
|
|
84
|
+
{
|
|
85
|
+
id: 'A.8.3',
|
|
86
|
+
clause: 'A.8.3',
|
|
87
|
+
title: 'Information access restriction',
|
|
88
|
+
description: 'Access to information and other associated assets shall be restricted in accordance with the established topic-specific policy on access control.',
|
|
89
|
+
category: 'technological',
|
|
90
|
+
checks: [
|
|
91
|
+
{
|
|
92
|
+
id: 'A.8.3.1',
|
|
93
|
+
description: 'Role-based access control implemented',
|
|
94
|
+
automated: true,
|
|
95
|
+
checkFunction: async (ctx) => {
|
|
96
|
+
const rbacPatterns = ['role', 'permission', 'authorize', 'acl', 'rbac'];
|
|
97
|
+
const hasRBAC = rbacPatterns.some(p => ctx.codebase?.content?.toLowerCase().includes(p));
|
|
98
|
+
return {
|
|
99
|
+
passed: hasRBAC,
|
|
100
|
+
findings: hasRBAC ? [] : ['No RBAC implementation detected'],
|
|
101
|
+
evidence: hasRBAC ? ['RBAC patterns found'] : [],
|
|
102
|
+
recommendations: hasRBAC ? [] : ['Implement role-based access control'],
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'A.8.4',
|
|
110
|
+
clause: 'A.8.4',
|
|
111
|
+
title: 'Access to source code',
|
|
112
|
+
description: 'Read and write access to source code, development tools and software libraries shall be appropriately managed.',
|
|
113
|
+
category: 'technological',
|
|
114
|
+
checks: [
|
|
115
|
+
{
|
|
116
|
+
id: 'A.8.4.1',
|
|
117
|
+
description: 'Branch protection is configured',
|
|
118
|
+
automated: true,
|
|
119
|
+
checkFunction: async (ctx) => {
|
|
120
|
+
const hasBranchProtection = ctx.config?.git?.branchProtection !== false;
|
|
121
|
+
return {
|
|
122
|
+
passed: hasBranchProtection,
|
|
123
|
+
findings: hasBranchProtection ? [] : ['Branch protection not configured'],
|
|
124
|
+
evidence: hasBranchProtection ? ['Branch protection enabled'] : [],
|
|
125
|
+
recommendations: hasBranchProtection ? [] : ['Enable branch protection on main branches'],
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'A.8.9',
|
|
133
|
+
clause: 'A.8.9',
|
|
134
|
+
title: 'Configuration management',
|
|
135
|
+
description: 'Configurations, including security configurations, of hardware, software, services and networks shall be established, documented, implemented, monitored and reviewed.',
|
|
136
|
+
category: 'technological',
|
|
137
|
+
checks: [
|
|
138
|
+
{
|
|
139
|
+
id: 'A.8.9.1',
|
|
140
|
+
description: 'Environment configuration is documented',
|
|
141
|
+
automated: true,
|
|
142
|
+
checkFunction: async (ctx) => {
|
|
143
|
+
const configFiles = ['.env.example', 'config/README.md', 'docs/configuration.md'];
|
|
144
|
+
const hasConfig = configFiles.some(f => ctx.codebase?.files?.includes(f));
|
|
145
|
+
return {
|
|
146
|
+
passed: hasConfig,
|
|
147
|
+
findings: hasConfig ? [] : ['Configuration documentation missing'],
|
|
148
|
+
evidence: hasConfig ? ['Configuration documentation exists'] : [],
|
|
149
|
+
recommendations: hasConfig ? [] : ['Create .env.example and configuration documentation'],
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: 'A.8.12',
|
|
157
|
+
clause: 'A.8.12',
|
|
158
|
+
title: 'Data leakage prevention',
|
|
159
|
+
description: 'Data leakage prevention measures shall be applied to systems, networks and any other devices that process, store or transmit sensitive information.',
|
|
160
|
+
category: 'technological',
|
|
161
|
+
checks: [
|
|
162
|
+
{
|
|
163
|
+
id: 'A.8.12.1',
|
|
164
|
+
description: 'No hardcoded secrets in codebase',
|
|
165
|
+
automated: true,
|
|
166
|
+
checkFunction: async (ctx) => {
|
|
167
|
+
const secretPatterns = [
|
|
168
|
+
/api[_-]?key\s*=\s*['"][^'"]+['"]/i,
|
|
169
|
+
/password\s*=\s*['"][^'"]+['"]/i,
|
|
170
|
+
/secret\s*=\s*['"][^'"]+['"]/i,
|
|
171
|
+
];
|
|
172
|
+
const hasSecrets = secretPatterns.some(p => p.test(ctx.codebase?.content || ''));
|
|
173
|
+
return {
|
|
174
|
+
passed: !hasSecrets,
|
|
175
|
+
findings: hasSecrets ? ['Potential hardcoded secrets detected'] : [],
|
|
176
|
+
evidence: !hasSecrets ? ['No hardcoded secrets found'] : [],
|
|
177
|
+
recommendations: hasSecrets ? ['Remove hardcoded secrets and use environment variables'] : [],
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: 'A.8.24',
|
|
185
|
+
clause: 'A.8.24',
|
|
186
|
+
title: 'Use of cryptography',
|
|
187
|
+
description: 'Rules for the effective use of cryptography, including cryptographic key management, shall be defined and implemented.',
|
|
188
|
+
category: 'technological',
|
|
189
|
+
checks: [
|
|
190
|
+
{
|
|
191
|
+
id: 'A.8.24.1',
|
|
192
|
+
description: 'Secure cryptographic algorithms used',
|
|
193
|
+
automated: true,
|
|
194
|
+
checkFunction: async (ctx) => {
|
|
195
|
+
const weakAlgorithms = ['md5', 'sha1', 'des', 'rc4'];
|
|
196
|
+
const usesWeak = weakAlgorithms.some(a => ctx.codebase?.content?.toLowerCase().includes(a));
|
|
197
|
+
return {
|
|
198
|
+
passed: !usesWeak,
|
|
199
|
+
findings: usesWeak ? ['Weak cryptographic algorithms detected'] : [],
|
|
200
|
+
evidence: !usesWeak ? ['No weak algorithms found'] : [],
|
|
201
|
+
recommendations: usesWeak ? ['Replace MD5/SHA1 with SHA-256 or stronger'] : [],
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: 'A.8.25',
|
|
209
|
+
clause: 'A.8.25',
|
|
210
|
+
title: 'Secure development life cycle',
|
|
211
|
+
description: 'Rules for the secure development of software and systems shall be established and applied.',
|
|
212
|
+
category: 'technological',
|
|
213
|
+
checks: [
|
|
214
|
+
{
|
|
215
|
+
id: 'A.8.25.1',
|
|
216
|
+
description: 'Security testing is automated',
|
|
217
|
+
automated: true,
|
|
218
|
+
checkFunction: async (ctx) => {
|
|
219
|
+
const ciFiles = ['.github/workflows', '.gitlab-ci.yml', 'Jenkinsfile'];
|
|
220
|
+
const hasCI = ciFiles.some(f => ctx.codebase?.files?.includes(f));
|
|
221
|
+
return {
|
|
222
|
+
passed: hasCI,
|
|
223
|
+
findings: hasCI ? [] : ['No CI/CD security testing detected'],
|
|
224
|
+
evidence: hasCI ? ['CI/CD configuration found'] : [],
|
|
225
|
+
recommendations: hasCI ? [] : ['Set up automated security testing in CI/CD'],
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 'A.8.28',
|
|
233
|
+
clause: 'A.8.28',
|
|
234
|
+
title: 'Secure coding',
|
|
235
|
+
description: 'Secure coding principles shall be applied to software development.',
|
|
236
|
+
category: 'technological',
|
|
237
|
+
checks: [
|
|
238
|
+
{
|
|
239
|
+
id: 'A.8.28.1',
|
|
240
|
+
description: 'Input validation is implemented',
|
|
241
|
+
automated: true,
|
|
242
|
+
checkFunction: async (ctx) => {
|
|
243
|
+
const validationPatterns = ['validate', 'sanitize', 'escape', 'zod', 'yup', 'joi'];
|
|
244
|
+
const hasValidation = validationPatterns.some(p => ctx.codebase?.content?.toLowerCase().includes(p));
|
|
245
|
+
return {
|
|
246
|
+
passed: hasValidation,
|
|
247
|
+
findings: hasValidation ? [] : ['No input validation detected'],
|
|
248
|
+
evidence: hasValidation ? ['Input validation patterns found'] : [],
|
|
249
|
+
recommendations: hasValidation ? [] : ['Implement input validation using Zod, Yup, or similar'],
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
/**
|
|
257
|
+
* ISO 27001 Compliance Checker
|
|
258
|
+
*/
|
|
259
|
+
class ISO27001Checker {
|
|
260
|
+
/**
|
|
261
|
+
* Run all ISO 27001 compliance checks
|
|
262
|
+
*/
|
|
263
|
+
async checkCompliance(context) {
|
|
264
|
+
const results = [];
|
|
265
|
+
let passedControls = 0;
|
|
266
|
+
let failedControls = 0;
|
|
267
|
+
for (const control of exports.ISO27001_CONTROLS) {
|
|
268
|
+
const controlResults = [];
|
|
269
|
+
let controlPassed = true;
|
|
270
|
+
for (const check of control.checks) {
|
|
271
|
+
if (check.automated && check.checkFunction) {
|
|
272
|
+
try {
|
|
273
|
+
const result = await check.checkFunction(context);
|
|
274
|
+
controlResults.push(result);
|
|
275
|
+
if (!result.passed) {
|
|
276
|
+
controlPassed = false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
controlResults.push({
|
|
281
|
+
passed: false,
|
|
282
|
+
findings: [`Check failed: ${error}`],
|
|
283
|
+
evidence: [],
|
|
284
|
+
recommendations: ['Review and fix the check implementation'],
|
|
285
|
+
});
|
|
286
|
+
controlPassed = false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (controlPassed) {
|
|
291
|
+
passedControls++;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
failedControls++;
|
|
295
|
+
}
|
|
296
|
+
results.push({
|
|
297
|
+
control,
|
|
298
|
+
passed: controlPassed,
|
|
299
|
+
checkResults: controlResults,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const score = Math.round((passedControls / (passedControls + failedControls)) * 100);
|
|
303
|
+
return {
|
|
304
|
+
framework: 'ISO 27001:2022',
|
|
305
|
+
timestamp: new Date().toISOString(),
|
|
306
|
+
score,
|
|
307
|
+
passedControls,
|
|
308
|
+
failedControls,
|
|
309
|
+
totalControls: passedControls + failedControls,
|
|
310
|
+
results,
|
|
311
|
+
recommendations: this.generateRecommendations(results),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generate prioritized recommendations
|
|
316
|
+
*/
|
|
317
|
+
generateRecommendations(results) {
|
|
318
|
+
const recommendations = [];
|
|
319
|
+
for (const result of results) {
|
|
320
|
+
if (!result.passed) {
|
|
321
|
+
for (const checkResult of result.checkResults) {
|
|
322
|
+
recommendations.push(...checkResult.recommendations);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return [...new Set(recommendations)];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.ISO27001Checker = ISO27001Checker;
|
|
330
|
+
// Export singleton
|
|
331
|
+
exports.iso27001Checker = new ISO27001Checker();
|