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.
Files changed (149) hide show
  1. package/dist/audit/emitter.d.ts +97 -0
  2. package/dist/audit/emitter.d.ts.map +1 -0
  3. package/dist/audit/emitter.js +197 -0
  4. package/dist/audit/events.d.ts +304 -0
  5. package/dist/audit/events.d.ts.map +1 -0
  6. package/dist/audit/events.js +267 -0
  7. package/dist/audit/index.d.ts +11 -0
  8. package/dist/audit/index.d.ts.map +1 -0
  9. package/dist/audit/index.js +51 -0
  10. package/dist/audit/storage.d.ts +93 -0
  11. package/dist/audit/storage.d.ts.map +1 -0
  12. package/dist/audit/storage.js +337 -0
  13. package/dist/automation/__tests__/compliance-scheduler.test.d.ts +2 -0
  14. package/dist/automation/__tests__/compliance-scheduler.test.d.ts.map +1 -0
  15. package/dist/automation/__tests__/compliance-scheduler.test.js +140 -0
  16. package/dist/automation/audit-logger.d.ts +129 -0
  17. package/dist/automation/audit-logger.d.ts.map +1 -0
  18. package/dist/automation/audit-logger.js +473 -0
  19. package/dist/automation/compliance-scheduler-fixed.d.ts +1 -0
  20. package/dist/automation/compliance-scheduler-fixed.d.ts.map +1 -0
  21. package/dist/automation/compliance-scheduler-fixed.js +1 -0
  22. package/dist/automation/compliance-scheduler.d.ts +83 -0
  23. package/dist/automation/compliance-scheduler.d.ts.map +1 -0
  24. package/dist/automation/compliance-scheduler.js +414 -0
  25. package/dist/automation/dashboard.d.ts +194 -0
  26. package/dist/automation/dashboard.d.ts.map +1 -0
  27. package/dist/automation/dashboard.js +768 -0
  28. package/dist/automation/email-service.d.ts +69 -0
  29. package/dist/automation/email-service.d.ts.map +1 -0
  30. package/dist/automation/email-service.js +218 -0
  31. package/dist/automation/evidence-collector.d.ts +140 -0
  32. package/dist/automation/evidence-collector.d.ts.map +1 -0
  33. package/dist/automation/evidence-collector.js +682 -0
  34. package/dist/automation/index.d.ts +8 -0
  35. package/dist/automation/index.d.ts.map +1 -0
  36. package/dist/automation/index.js +24 -0
  37. package/dist/automation/pdf-exporter.d.ts +90 -0
  38. package/dist/automation/pdf-exporter.d.ts.map +1 -0
  39. package/dist/automation/pdf-exporter.js +381 -0
  40. package/dist/automation/reporting-engine.d.ts +116 -0
  41. package/dist/automation/reporting-engine.d.ts.map +1 -0
  42. package/dist/automation/reporting-engine.js +329 -0
  43. package/dist/container/index.d.ts +4 -0
  44. package/dist/container/index.d.ts.map +1 -0
  45. package/dist/container/index.js +19 -0
  46. package/dist/container/kubernetes.d.ts +94 -0
  47. package/dist/container/kubernetes.d.ts.map +1 -0
  48. package/dist/container/kubernetes.js +268 -0
  49. package/dist/container/rules.d.ts +27 -0
  50. package/dist/container/rules.d.ts.map +1 -0
  51. package/dist/container/rules.js +216 -0
  52. package/dist/container/scanner.d.ts +50 -0
  53. package/dist/container/scanner.d.ts.map +1 -0
  54. package/dist/container/scanner.js +143 -0
  55. package/dist/frameworks/engine.d.ts +108 -0
  56. package/dist/frameworks/engine.d.ts.map +1 -0
  57. package/dist/frameworks/engine.js +206 -0
  58. package/dist/frameworks/gdpr.d.ts +6 -0
  59. package/dist/frameworks/gdpr.d.ts.map +1 -0
  60. package/dist/frameworks/gdpr.js +198 -0
  61. package/dist/frameworks/hipaa.d.ts +6 -0
  62. package/dist/frameworks/hipaa.d.ts.map +1 -0
  63. package/dist/frameworks/hipaa.js +183 -0
  64. package/dist/frameworks/index.d.ts +8 -0
  65. package/dist/frameworks/index.d.ts.map +1 -0
  66. package/dist/frameworks/index.js +30 -0
  67. package/dist/frameworks/iso27001.d.ts +63 -0
  68. package/dist/frameworks/iso27001.d.ts.map +1 -0
  69. package/dist/frameworks/iso27001.js +331 -0
  70. package/dist/frameworks/nist.d.ts +62 -0
  71. package/dist/frameworks/nist.d.ts.map +1 -0
  72. package/dist/frameworks/nist.js +424 -0
  73. package/dist/frameworks/pci.d.ts +6 -0
  74. package/dist/frameworks/pci.d.ts.map +1 -0
  75. package/dist/frameworks/pci.js +201 -0
  76. package/dist/frameworks/soc2.d.ts +7 -0
  77. package/dist/frameworks/soc2.d.ts.map +1 -0
  78. package/dist/frameworks/soc2.js +248 -0
  79. package/dist/iac/drift-detector.d.ts +64 -0
  80. package/dist/iac/drift-detector.d.ts.map +1 -0
  81. package/dist/iac/drift-detector.js +134 -0
  82. package/dist/iac/index.d.ts +4 -0
  83. package/dist/iac/index.d.ts.map +1 -0
  84. package/dist/iac/index.js +19 -0
  85. package/dist/iac/rules.d.ts +17 -0
  86. package/dist/iac/rules.d.ts.map +1 -0
  87. package/dist/iac/rules.js +385 -0
  88. package/dist/iac/scanner.d.ts +104 -0
  89. package/dist/iac/scanner.d.ts.map +1 -0
  90. package/dist/iac/scanner.js +343 -0
  91. package/dist/index.d.ts +7 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +28 -0
  94. package/dist/pii/data-flow.d.ts +58 -0
  95. package/dist/pii/data-flow.d.ts.map +1 -0
  96. package/dist/pii/data-flow.js +154 -0
  97. package/dist/pii/detector.d.ts +60 -0
  98. package/dist/pii/detector.d.ts.map +1 -0
  99. package/dist/pii/detector.js +267 -0
  100. package/dist/pii/index.d.ts +4 -0
  101. package/dist/pii/index.d.ts.map +1 -0
  102. package/dist/pii/index.js +19 -0
  103. package/dist/pii/patterns.d.ts +36 -0
  104. package/dist/pii/patterns.d.ts.map +1 -0
  105. package/dist/pii/patterns.js +108 -0
  106. package/dist/policy/index.d.ts +5 -0
  107. package/dist/policy/index.d.ts.map +1 -0
  108. package/dist/policy/index.js +20 -0
  109. package/dist/policy/opa-engine.d.ts +121 -0
  110. package/dist/policy/opa-engine.d.ts.map +1 -0
  111. package/dist/policy/opa-engine.js +423 -0
  112. package/package.json +31 -0
  113. package/src/audit/emitter.ts +383 -0
  114. package/src/audit/events.ts +351 -0
  115. package/src/audit/index.ts +35 -0
  116. package/src/audit/storage.ts +394 -0
  117. package/src/automation/__tests__/compliance-scheduler.test.ts +183 -0
  118. package/src/automation/audit-logger.ts +629 -0
  119. package/src/automation/compliance-scheduler-fixed.ts +0 -0
  120. package/src/automation/compliance-scheduler.ts +516 -0
  121. package/src/automation/dashboard.ts +947 -0
  122. package/src/automation/email-service.ts +230 -0
  123. package/src/automation/evidence-collector.ts +866 -0
  124. package/src/automation/index.ts +8 -0
  125. package/src/automation/pdf-exporter.ts +434 -0
  126. package/src/automation/reporting-engine.ts +462 -0
  127. package/src/container/index.ts +3 -0
  128. package/src/container/kubernetes.ts +379 -0
  129. package/src/container/rules.ts +244 -0
  130. package/src/container/scanner.ts +202 -0
  131. package/src/frameworks/engine.ts +298 -0
  132. package/src/frameworks/gdpr.ts +204 -0
  133. package/src/frameworks/hipaa.ts +209 -0
  134. package/src/frameworks/index.ts +23 -0
  135. package/src/frameworks/iso27001.ts +398 -0
  136. package/src/frameworks/nist.ts +518 -0
  137. package/src/frameworks/pci.ts +226 -0
  138. package/src/frameworks/soc2.ts +281 -0
  139. package/src/iac/drift-detector.ts +197 -0
  140. package/src/iac/index.ts +3 -0
  141. package/src/iac/rules.ts +420 -0
  142. package/src/iac/scanner.ts +445 -0
  143. package/src/index.ts +17 -0
  144. package/src/pii/data-flow.ts +216 -0
  145. package/src/pii/detector.ts +327 -0
  146. package/src/pii/index.ts +3 -0
  147. package/src/pii/patterns.ts +128 -0
  148. package/src/policy/index.ts +5 -0
  149. package/src/policy/opa-engine.ts +504 -0
@@ -0,0 +1,3 @@
1
+ export * from './scanner';
2
+ export * from './rules';
3
+ export * from './drift-detector';
@@ -0,0 +1,420 @@
1
+ export interface IaCRule {
2
+ id: string;
3
+ provider: 'terraform' | 'cloudformation' | 'kubernetes';
4
+ resourceType: string;
5
+ severity: 'critical' | 'high' | 'medium' | 'low';
6
+ category: string;
7
+ title: string;
8
+ description: string;
9
+ check: (resource: any) => boolean;
10
+ recommendation: string;
11
+ }
12
+
13
+ // AWS/Terraform Rules
14
+ export const TERRAFORM_RULES: IaCRule[] = [
15
+ // S3 Security
16
+ {
17
+ id: 'TF-S3-001',
18
+ provider: 'terraform',
19
+ resourceType: 'aws_s3_bucket',
20
+ severity: 'critical',
21
+ category: 'data-protection',
22
+ title: 'S3 Bucket Public ACL',
23
+ description: 'S3 bucket has public ACL enabled',
24
+ check: (resource) => resource.acl === 'public-read' || resource.acl === 'public-read-write',
25
+ recommendation: 'Set ACL to private and use bucket policies for access control'
26
+ },
27
+ {
28
+ id: 'TF-S3-002',
29
+ provider: 'terraform',
30
+ resourceType: 'aws_s3_bucket',
31
+ severity: 'high',
32
+ category: 'data-protection',
33
+ title: 'S3 Bucket Encryption Disabled',
34
+ description: 'S3 bucket does not have server-side encryption enabled',
35
+ check: (resource) => !resource.server_side_encryption_configuration,
36
+ recommendation: 'Enable server-side encryption with AWS KMS'
37
+ },
38
+ {
39
+ id: 'TF-S3-003',
40
+ provider: 'terraform',
41
+ resourceType: 'aws_s3_bucket',
42
+ severity: 'medium',
43
+ category: 'data-protection',
44
+ title: 'S3 Bucket Versioning Disabled',
45
+ description: 'S3 bucket versioning is not enabled',
46
+ check: (resource) => !resource.versioning || !resource.versioning[0]?.enabled,
47
+ recommendation: 'Enable versioning for data recovery and audit trail'
48
+ },
49
+ {
50
+ id: 'TF-S3-004',
51
+ provider: 'terraform',
52
+ resourceType: 'aws_s3_bucket',
53
+ severity: 'medium',
54
+ category: 'logging',
55
+ title: 'S3 Bucket Logging Disabled',
56
+ description: 'S3 bucket access logging is not configured',
57
+ check: (resource) => !resource.logging,
58
+ recommendation: 'Enable access logging to track requests'
59
+ },
60
+
61
+ // Security Group Rules
62
+ {
63
+ id: 'TF-SG-001',
64
+ provider: 'terraform',
65
+ resourceType: 'aws_security_group',
66
+ severity: 'critical',
67
+ category: 'network-security',
68
+ title: 'Security Group Allows SSH from Internet',
69
+ description: 'Security group allows SSH (port 22) from 0.0.0.0/0',
70
+ check: (resource) => {
71
+ const ingress = resource.ingress || [];
72
+ return ingress.some((rule: any) =>
73
+ rule.from_port === 22 &&
74
+ rule.to_port === 22 &&
75
+ (rule.cidr_blocks?.includes('0.0.0.0/0') || rule.ipv6_cidr_blocks?.includes('::/0'))
76
+ );
77
+ },
78
+ recommendation: 'Restrict SSH access to specific IP addresses or use VPN/bastion host'
79
+ },
80
+ {
81
+ id: 'TF-SG-002',
82
+ provider: 'terraform',
83
+ resourceType: 'aws_security_group',
84
+ severity: 'critical',
85
+ category: 'network-security',
86
+ title: 'Security Group Allows RDP from Internet',
87
+ description: 'Security group allows RDP (port 3389) from 0.0.0.0/0',
88
+ check: (resource) => {
89
+ const ingress = resource.ingress || [];
90
+ return ingress.some((rule: any) =>
91
+ rule.from_port === 3389 &&
92
+ rule.to_port === 3389 &&
93
+ (rule.cidr_blocks?.includes('0.0.0.0/0') || rule.ipv6_cidr_blocks?.includes('::/0'))
94
+ );
95
+ },
96
+ recommendation: 'Restrict RDP access to specific IP addresses or use VPN/bastion host'
97
+ },
98
+ {
99
+ id: 'TF-SG-003',
100
+ provider: 'terraform',
101
+ resourceType: 'aws_security_group',
102
+ severity: 'high',
103
+ category: 'network-security',
104
+ title: 'Security Group Allows All Ports from Internet',
105
+ description: 'Security group allows all ports from 0.0.0.0/0',
106
+ check: (resource) => {
107
+ const ingress = resource.ingress || [];
108
+ return ingress.some((rule: any) =>
109
+ rule.from_port === 0 &&
110
+ rule.to_port === 65535 &&
111
+ (rule.cidr_blocks?.includes('0.0.0.0/0') || rule.ipv6_cidr_blocks?.includes('::/0'))
112
+ );
113
+ },
114
+ recommendation: 'Restrict ingress rules to specific ports and sources'
115
+ },
116
+
117
+ // RDS Security
118
+ {
119
+ id: 'TF-RDS-001',
120
+ provider: 'terraform',
121
+ resourceType: 'aws_db_instance',
122
+ severity: 'critical',
123
+ category: 'data-protection',
124
+ title: 'RDS Instance Publicly Accessible',
125
+ description: 'RDS instance is publicly accessible',
126
+ check: (resource) => resource.publicly_accessible === true,
127
+ recommendation: 'Disable public accessibility and use VPN or private subnet'
128
+ },
129
+ {
130
+ id: 'TF-RDS-002',
131
+ provider: 'terraform',
132
+ resourceType: 'aws_db_instance',
133
+ severity: 'high',
134
+ category: 'data-protection',
135
+ title: 'RDS Instance Encryption Disabled',
136
+ description: 'RDS instance does not have encryption at rest enabled',
137
+ check: (resource) => resource.storage_encrypted !== true,
138
+ recommendation: 'Enable storage encryption with AWS KMS'
139
+ },
140
+ {
141
+ id: 'TF-RDS-003',
142
+ provider: 'terraform',
143
+ resourceType: 'aws_db_instance',
144
+ severity: 'medium',
145
+ category: 'data-protection',
146
+ title: 'RDS Automated Backups Disabled',
147
+ description: 'RDS instance does not have automated backups configured',
148
+ check: (resource) => !resource.backup_retention_period || resource.backup_retention_period === 0,
149
+ recommendation: 'Configure automated backups with appropriate retention period'
150
+ },
151
+
152
+ // IAM Security
153
+ {
154
+ id: 'TF-IAM-001',
155
+ provider: 'terraform',
156
+ resourceType: 'aws_iam_policy',
157
+ severity: 'critical',
158
+ category: 'access-control',
159
+ title: 'IAM Policy with Admin Privileges',
160
+ description: 'IAM policy grants full administrative privileges (*:*)',
161
+ check: (resource) => {
162
+ const policy = typeof resource.policy === 'string' ? JSON.parse(resource.policy) : resource.policy;
163
+ return policy.Statement?.some((stmt: any) =>
164
+ stmt.Effect === 'Allow' &&
165
+ (stmt.Action === '*' || stmt.Action?.includes('*')) &&
166
+ (stmt.Resource === '*' || stmt.Resource?.includes('*'))
167
+ );
168
+ },
169
+ recommendation: 'Follow principle of least privilege and grant specific permissions'
170
+ },
171
+
172
+ // CloudTrail
173
+ {
174
+ id: 'TF-CT-001',
175
+ provider: 'terraform',
176
+ resourceType: 'aws_cloudtrail',
177
+ severity: 'high',
178
+ category: 'logging',
179
+ title: 'CloudTrail Log File Validation Disabled',
180
+ description: 'CloudTrail does not have log file validation enabled',
181
+ check: (resource) => resource.enable_log_file_validation !== true,
182
+ recommendation: 'Enable log file validation to detect tampering'
183
+ },
184
+
185
+ // KMS
186
+ {
187
+ id: 'TF-KMS-001',
188
+ provider: 'terraform',
189
+ resourceType: 'aws_kms_key',
190
+ severity: 'medium',
191
+ category: 'data-protection',
192
+ title: 'KMS Key Rotation Disabled',
193
+ description: 'KMS key does not have automatic rotation enabled',
194
+ check: (resource) => resource.enable_key_rotation !== true,
195
+ recommendation: 'Enable automatic key rotation for better security'
196
+ },
197
+
198
+ // EBS
199
+ {
200
+ id: 'TF-EBS-001',
201
+ provider: 'terraform',
202
+ resourceType: 'aws_ebs_volume',
203
+ severity: 'high',
204
+ category: 'data-protection',
205
+ title: 'EBS Volume Encryption Disabled',
206
+ description: 'EBS volume is not encrypted',
207
+ check: (resource) => resource.encrypted !== true,
208
+ recommendation: 'Enable EBS volume encryption'
209
+ }
210
+ ];
211
+
212
+ // GCP Rules
213
+ export const GCP_RULES: IaCRule[] = [
214
+ {
215
+ id: 'GCP-STORAGE-001',
216
+ provider: 'terraform',
217
+ resourceType: 'google_storage_bucket',
218
+ severity: 'critical',
219
+ category: 'data-protection',
220
+ title: 'GCS Bucket Public Access',
221
+ description: 'Storage bucket allows public access',
222
+ check: (resource) => {
223
+ return resource.iam_binding?.some((binding: any) =>
224
+ binding.members?.includes('allUsers') || binding.members?.includes('allAuthenticatedUsers')
225
+ );
226
+ },
227
+ recommendation: 'Remove public access and use IAM for access control'
228
+ },
229
+ {
230
+ id: 'GCP-COMPUTE-001',
231
+ provider: 'terraform',
232
+ resourceType: 'google_compute_firewall',
233
+ severity: 'critical',
234
+ category: 'network-security',
235
+ title: 'GCP Firewall Allows All Traffic',
236
+ description: 'Firewall rule allows all traffic from internet',
237
+ check: (resource) => {
238
+ return resource.source_ranges?.includes('0.0.0.0/0') &&
239
+ resource.allow?.some((rule: any) => rule.protocol === 'all' || rule.ports?.includes('0-65535'));
240
+ },
241
+ recommendation: 'Restrict firewall rules to specific protocols and ports'
242
+ },
243
+ {
244
+ id: 'GCP-SQL-001',
245
+ provider: 'terraform',
246
+ resourceType: 'google_sql_database_instance',
247
+ severity: 'critical',
248
+ category: 'data-protection',
249
+ title: 'Cloud SQL Public IP',
250
+ description: 'Cloud SQL instance has public IP address',
251
+ check: (resource) => {
252
+ return resource.settings?.[0]?.ip_configuration?.[0]?.ipv4_enabled === true;
253
+ },
254
+ recommendation: 'Use private IP and Cloud SQL Proxy for connections'
255
+ }
256
+ ];
257
+
258
+ // Azure Rules
259
+ export const AZURE_RULES: IaCRule[] = [
260
+ {
261
+ id: 'AZURE-STORAGE-001',
262
+ provider: 'terraform',
263
+ resourceType: 'azurerm_storage_account',
264
+ severity: 'critical',
265
+ category: 'data-protection',
266
+ title: 'Storage Account Public Access',
267
+ description: 'Storage account allows public blob access',
268
+ check: (resource) => resource.allow_blob_public_access === true,
269
+ recommendation: 'Disable public blob access'
270
+ },
271
+ {
272
+ id: 'AZURE-NSG-001',
273
+ provider: 'terraform',
274
+ resourceType: 'azurerm_network_security_rule',
275
+ severity: 'critical',
276
+ category: 'network-security',
277
+ title: 'NSG Allows SSH from Internet',
278
+ description: 'Network security rule allows SSH from internet',
279
+ check: (resource) => {
280
+ return resource.source_address_prefix === '*' &&
281
+ resource.destination_port_range === '22' &&
282
+ resource.access === 'Allow';
283
+ },
284
+ recommendation: 'Restrict source address to specific IPs'
285
+ },
286
+ {
287
+ id: 'AZURE-SQL-001',
288
+ provider: 'terraform',
289
+ resourceType: 'azurerm_mssql_server',
290
+ severity: 'high',
291
+ category: 'network-security',
292
+ title: 'SQL Server Firewall Allows All IPs',
293
+ description: 'SQL Server firewall rule allows all IP addresses',
294
+ check: (resource) => {
295
+ return resource.firewall_rule?.some((rule: any) =>
296
+ rule.start_ip_address === '0.0.0.0' && rule.end_ip_address === '255.255.255.255'
297
+ );
298
+ },
299
+ recommendation: 'Configure specific IP ranges for firewall rules'
300
+ }
301
+ ];
302
+
303
+ // Kubernetes Rules
304
+ export const KUBERNETES_RULES: IaCRule[] = [
305
+ {
306
+ id: 'K8S-POD-001',
307
+ provider: 'kubernetes',
308
+ resourceType: 'Pod',
309
+ severity: 'critical',
310
+ category: 'pod-security',
311
+ title: 'Privileged Container',
312
+ description: 'Container is running in privileged mode',
313
+ check: (resource) => {
314
+ const containers = resource.spec?.containers || [];
315
+ return containers.some((c: any) => c.securityContext?.privileged === true);
316
+ },
317
+ recommendation: 'Avoid privileged containers unless absolutely necessary'
318
+ },
319
+ {
320
+ id: 'K8S-POD-002',
321
+ provider: 'kubernetes',
322
+ resourceType: 'Pod',
323
+ severity: 'high',
324
+ category: 'pod-security',
325
+ title: 'Host Network Access',
326
+ description: 'Pod has access to host network',
327
+ check: (resource) => resource.spec?.hostNetwork === true,
328
+ recommendation: 'Disable hostNetwork unless required'
329
+ },
330
+ {
331
+ id: 'K8S-POD-003',
332
+ provider: 'kubernetes',
333
+ resourceType: 'Pod',
334
+ severity: 'high',
335
+ category: 'pod-security',
336
+ title: 'Host PID Access',
337
+ description: 'Pod has access to host PID namespace',
338
+ check: (resource) => resource.spec?.hostPID === true,
339
+ recommendation: 'Disable hostPID unless required'
340
+ },
341
+ {
342
+ id: 'K8S-POD-004',
343
+ provider: 'kubernetes',
344
+ resourceType: 'Pod',
345
+ severity: 'medium',
346
+ category: 'pod-security',
347
+ title: 'Running as Root',
348
+ description: 'Container is running as root user',
349
+ check: (resource) => {
350
+ const containers = resource.spec?.containers || [];
351
+ return containers.some((c: any) =>
352
+ !c.securityContext?.runAsNonRoot && c.securityContext?.runAsUser === 0
353
+ );
354
+ },
355
+ recommendation: 'Run containers as non-root user'
356
+ },
357
+ {
358
+ id: 'K8S-POD-005',
359
+ provider: 'kubernetes',
360
+ resourceType: 'Pod',
361
+ severity: 'medium',
362
+ category: 'pod-security',
363
+ title: 'Dangerous Capabilities',
364
+ description: 'Container has dangerous Linux capabilities',
365
+ check: (resource) => {
366
+ const containers = resource.spec?.containers || [];
367
+ const dangerousCaps = ['SYS_ADMIN', 'NET_ADMIN', 'SYS_MODULE', 'CAP_SYS_ADMIN'];
368
+ return containers.some((c: any) =>
369
+ c.securityContext?.capabilities?.add?.some((cap: string) => dangerousCaps.includes(cap))
370
+ );
371
+ },
372
+ recommendation: 'Remove unnecessary capabilities'
373
+ },
374
+ {
375
+ id: 'K8S-POD-006',
376
+ provider: 'kubernetes',
377
+ resourceType: 'Pod',
378
+ severity: 'low',
379
+ category: 'resource-management',
380
+ title: 'Missing Resource Limits',
381
+ description: 'Container does not have resource limits set',
382
+ check: (resource) => {
383
+ const containers = resource.spec?.containers || [];
384
+ return containers.some((c: any) => !c.resources?.limits);
385
+ },
386
+ recommendation: 'Set CPU and memory limits for containers'
387
+ },
388
+ {
389
+ id: 'K8S-POD-007',
390
+ provider: 'kubernetes',
391
+ resourceType: 'Pod',
392
+ severity: 'medium',
393
+ category: 'pod-security',
394
+ title: 'Read-Only Root Filesystem Not Set',
395
+ description: 'Container root filesystem is not read-only',
396
+ check: (resource) => {
397
+ const containers = resource.spec?.containers || [];
398
+ return containers.some((c: any) => c.securityContext?.readOnlyRootFilesystem !== true);
399
+ },
400
+ recommendation: 'Set readOnlyRootFilesystem to true'
401
+ },
402
+ {
403
+ id: 'K8S-SA-001',
404
+ provider: 'kubernetes',
405
+ resourceType: 'Pod',
406
+ severity: 'medium',
407
+ category: 'pod-security',
408
+ title: 'Service Account Token Auto-Mount',
409
+ description: 'Service account token is auto-mounted',
410
+ check: (resource) => resource.spec?.automountServiceAccountToken !== false,
411
+ recommendation: 'Set automountServiceAccountToken to false unless needed'
412
+ }
413
+ ];
414
+
415
+ export const ALL_RULES = [
416
+ ...TERRAFORM_RULES,
417
+ ...GCP_RULES,
418
+ ...AZURE_RULES,
419
+ ...KUBERNETES_RULES
420
+ ];