@stacksjs/ts-cloud-core 0.1.1
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/LICENSE.md +21 -0
- package/README.md +321 -0
- package/package.json +31 -0
- package/src/advanced-features.test.ts +465 -0
- package/src/aws/cloudformation.ts +421 -0
- package/src/aws/cloudfront.ts +158 -0
- package/src/aws/credentials.test.ts +132 -0
- package/src/aws/credentials.ts +545 -0
- package/src/aws/index.ts +87 -0
- package/src/aws/s3.test.ts +188 -0
- package/src/aws/s3.ts +1088 -0
- package/src/aws/signature.test.ts +670 -0
- package/src/aws/signature.ts +1155 -0
- package/src/backup/disaster-recovery.test.ts +726 -0
- package/src/backup/disaster-recovery.ts +500 -0
- package/src/backup/index.ts +34 -0
- package/src/backup/manager.test.ts +498 -0
- package/src/backup/manager.ts +432 -0
- package/src/cicd/circleci.ts +430 -0
- package/src/cicd/github-actions.ts +424 -0
- package/src/cicd/gitlab-ci.ts +255 -0
- package/src/cicd/index.ts +8 -0
- package/src/cli/history.ts +396 -0
- package/src/cli/index.ts +10 -0
- package/src/cli/progress.ts +458 -0
- package/src/cli/repl.ts +454 -0
- package/src/cli/suggestions.ts +327 -0
- package/src/cli/table.test.ts +319 -0
- package/src/cli/table.ts +332 -0
- package/src/cloudformation/builder.test.ts +327 -0
- package/src/cloudformation/builder.ts +378 -0
- package/src/cloudformation/builders/api-gateway.ts +449 -0
- package/src/cloudformation/builders/cache.ts +334 -0
- package/src/cloudformation/builders/cdn.ts +278 -0
- package/src/cloudformation/builders/compute.ts +485 -0
- package/src/cloudformation/builders/database.ts +392 -0
- package/src/cloudformation/builders/functions.ts +343 -0
- package/src/cloudformation/builders/messaging.ts +140 -0
- package/src/cloudformation/builders/monitoring.ts +300 -0
- package/src/cloudformation/builders/network.ts +264 -0
- package/src/cloudformation/builders/queue.ts +147 -0
- package/src/cloudformation/builders/security.ts +399 -0
- package/src/cloudformation/builders/storage.ts +285 -0
- package/src/cloudformation/index.ts +30 -0
- package/src/cloudformation/types.ts +173 -0
- package/src/compliance/aws-config.ts +543 -0
- package/src/compliance/cloudtrail.ts +376 -0
- package/src/compliance/compliance.test.ts +423 -0
- package/src/compliance/guardduty.ts +446 -0
- package/src/compliance/index.ts +66 -0
- package/src/compliance/security-hub.ts +456 -0
- package/src/containers/build-optimization.ts +416 -0
- package/src/containers/containers.test.ts +508 -0
- package/src/containers/image-scanning.ts +360 -0
- package/src/containers/index.ts +9 -0
- package/src/containers/registry.ts +293 -0
- package/src/containers/service-mesh.ts +520 -0
- package/src/database/database.test.ts +762 -0
- package/src/database/index.ts +9 -0
- package/src/database/migrations.ts +444 -0
- package/src/database/performance.ts +528 -0
- package/src/database/replicas.ts +534 -0
- package/src/database/users.ts +494 -0
- package/src/dependency-graph.ts +143 -0
- package/src/deployment/ab-testing.ts +582 -0
- package/src/deployment/blue-green.ts +452 -0
- package/src/deployment/canary.ts +500 -0
- package/src/deployment/deployment.test.ts +526 -0
- package/src/deployment/index.ts +61 -0
- package/src/deployment/progressive.ts +62 -0
- package/src/dns/dns.test.ts +641 -0
- package/src/dns/dnssec.ts +315 -0
- package/src/dns/index.ts +8 -0
- package/src/dns/resolver.ts +496 -0
- package/src/dns/routing.ts +593 -0
- package/src/email/advanced/analytics.ts +445 -0
- package/src/email/advanced/index.ts +11 -0
- package/src/email/advanced/rules.ts +465 -0
- package/src/email/advanced/scheduling.ts +352 -0
- package/src/email/advanced/search.ts +412 -0
- package/src/email/advanced/shared-mailboxes.ts +404 -0
- package/src/email/advanced/templates.ts +455 -0
- package/src/email/advanced/threading.ts +281 -0
- package/src/email/analytics.ts +467 -0
- package/src/email/bounce-handling.ts +425 -0
- package/src/email/email.test.ts +431 -0
- package/src/email/handlers/__tests__/inbound.test.ts +38 -0
- package/src/email/handlers/__tests__/outbound.test.ts +37 -0
- package/src/email/handlers/converter.ts +227 -0
- package/src/email/handlers/feedback.ts +228 -0
- package/src/email/handlers/inbound.ts +169 -0
- package/src/email/handlers/outbound.ts +178 -0
- package/src/email/index.ts +15 -0
- package/src/email/reputation.ts +303 -0
- package/src/email/templates.ts +352 -0
- package/src/errors/index.test.ts +434 -0
- package/src/errors/index.ts +416 -0
- package/src/health-checks/index.ts +40 -0
- package/src/index.ts +360 -0
- package/src/intrinsic-functions.ts +118 -0
- package/src/lambda/concurrency.ts +330 -0
- package/src/lambda/destinations.ts +345 -0
- package/src/lambda/dlq.ts +425 -0
- package/src/lambda/index.ts +11 -0
- package/src/lambda/lambda.test.ts +840 -0
- package/src/lambda/layers.ts +263 -0
- package/src/lambda/versions.ts +376 -0
- package/src/lambda/vpc.ts +399 -0
- package/src/local/config.ts +114 -0
- package/src/local/index.ts +6 -0
- package/src/local/mock-aws.ts +351 -0
- package/src/modules/ai.ts +340 -0
- package/src/modules/api.ts +478 -0
- package/src/modules/auth.ts +805 -0
- package/src/modules/cache.ts +417 -0
- package/src/modules/cdn.ts +1062 -0
- package/src/modules/communication.ts +1094 -0
- package/src/modules/compute.ts +3348 -0
- package/src/modules/database.ts +554 -0
- package/src/modules/deployment.ts +1079 -0
- package/src/modules/dns.ts +337 -0
- package/src/modules/email.ts +1538 -0
- package/src/modules/filesystem.ts +515 -0
- package/src/modules/index.ts +32 -0
- package/src/modules/messaging.ts +486 -0
- package/src/modules/monitoring.ts +2086 -0
- package/src/modules/network.ts +664 -0
- package/src/modules/parameter-store.ts +325 -0
- package/src/modules/permissions.ts +1081 -0
- package/src/modules/phone.ts +494 -0
- package/src/modules/queue.ts +1260 -0
- package/src/modules/redirects.ts +464 -0
- package/src/modules/registry.ts +699 -0
- package/src/modules/search.ts +401 -0
- package/src/modules/secrets.ts +416 -0
- package/src/modules/security.ts +731 -0
- package/src/modules/sms.ts +389 -0
- package/src/modules/storage.ts +1120 -0
- package/src/modules/workflow.ts +680 -0
- package/src/multi-account/config.ts +521 -0
- package/src/multi-account/index.ts +7 -0
- package/src/multi-account/manager.ts +427 -0
- package/src/multi-region/cross-region.ts +410 -0
- package/src/multi-region/index.ts +8 -0
- package/src/multi-region/manager.ts +483 -0
- package/src/multi-region/regions.ts +435 -0
- package/src/network-security/index.ts +48 -0
- package/src/observability/index.ts +9 -0
- package/src/observability/logs.ts +522 -0
- package/src/observability/metrics.ts +460 -0
- package/src/observability/observability.test.ts +782 -0
- package/src/observability/synthetics.ts +568 -0
- package/src/observability/xray.ts +358 -0
- package/src/phone/advanced/analytics.ts +349 -0
- package/src/phone/advanced/callbacks.ts +428 -0
- package/src/phone/advanced/index.ts +8 -0
- package/src/phone/advanced/ivr-builder.ts +504 -0
- package/src/phone/advanced/recording.ts +310 -0
- package/src/phone/handlers/__tests__/incoming-call.test.ts +40 -0
- package/src/phone/handlers/incoming-call.ts +117 -0
- package/src/phone/handlers/missed-call.ts +116 -0
- package/src/phone/handlers/voicemail.ts +179 -0
- package/src/phone/index.ts +9 -0
- package/src/presets/api-backend.ts +134 -0
- package/src/presets/data-pipeline.ts +204 -0
- package/src/presets/extend.test.ts +295 -0
- package/src/presets/extend.ts +297 -0
- package/src/presets/fullstack-app.ts +144 -0
- package/src/presets/index.ts +27 -0
- package/src/presets/jamstack.ts +135 -0
- package/src/presets/microservices.ts +167 -0
- package/src/presets/ml-api.ts +208 -0
- package/src/presets/nodejs-server.ts +104 -0
- package/src/presets/nodejs-serverless.ts +114 -0
- package/src/presets/realtime-app.ts +184 -0
- package/src/presets/static-site.ts +64 -0
- package/src/presets/traditional-web-app.ts +339 -0
- package/src/presets/wordpress.ts +138 -0
- package/src/preview/github.test.ts +249 -0
- package/src/preview/github.ts +297 -0
- package/src/preview/index.ts +37 -0
- package/src/preview/manager.test.ts +440 -0
- package/src/preview/manager.ts +326 -0
- package/src/preview/notifications.test.ts +582 -0
- package/src/preview/notifications.ts +341 -0
- package/src/queue/batch-processing.ts +402 -0
- package/src/queue/dlq-monitoring.ts +402 -0
- package/src/queue/fifo.ts +342 -0
- package/src/queue/index.ts +9 -0
- package/src/queue/management.ts +428 -0
- package/src/queue/queue.test.ts +429 -0
- package/src/resource-mgmt/index.ts +39 -0
- package/src/resource-naming.ts +62 -0
- package/src/s3/index.ts +523 -0
- package/src/schema/cloud-config.schema.json +554 -0
- package/src/schema/index.ts +68 -0
- package/src/security/certificate-manager.ts +492 -0
- package/src/security/index.ts +9 -0
- package/src/security/scanning.ts +545 -0
- package/src/security/secrets-manager.ts +476 -0
- package/src/security/secrets-rotation.ts +456 -0
- package/src/security/security.test.ts +738 -0
- package/src/sms/advanced/ab-testing.ts +389 -0
- package/src/sms/advanced/analytics.ts +336 -0
- package/src/sms/advanced/campaigns.ts +523 -0
- package/src/sms/advanced/chatbot.ts +224 -0
- package/src/sms/advanced/index.ts +10 -0
- package/src/sms/advanced/link-tracking.ts +248 -0
- package/src/sms/advanced/mms.ts +308 -0
- package/src/sms/handlers/__tests__/send.test.ts +40 -0
- package/src/sms/handlers/delivery-status.ts +133 -0
- package/src/sms/handlers/receive.ts +162 -0
- package/src/sms/handlers/send.ts +174 -0
- package/src/sms/index.ts +9 -0
- package/src/stack-diff.ts +389 -0
- package/src/static-site/index.ts +85 -0
- package/src/template-builder.ts +110 -0
- package/src/template-validator.ts +574 -0
- package/src/utils/cache.ts +291 -0
- package/src/utils/diff.ts +269 -0
- package/src/utils/hash.ts +227 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/parallel.ts +294 -0
- package/src/validators/credentials.test.ts +274 -0
- package/src/validators/credentials.ts +233 -0
- package/src/validators/quotas.test.ts +434 -0
- package/src/validators/quotas.ts +217 -0
- package/test/ai.test.ts +327 -0
- package/test/api.test.ts +511 -0
- package/test/auth.test.ts +632 -0
- package/test/cache.test.ts +406 -0
- package/test/cdn.test.ts +247 -0
- package/test/compute.test.ts +861 -0
- package/test/database.test.ts +523 -0
- package/test/deployment.test.ts +499 -0
- package/test/dns.test.ts +270 -0
- package/test/email.test.ts +439 -0
- package/test/filesystem.test.ts +382 -0
- package/test/integration.test.ts +350 -0
- package/test/messaging.test.ts +514 -0
- package/test/monitoring.test.ts +634 -0
- package/test/network.test.ts +425 -0
- package/test/permissions.test.ts +488 -0
- package/test/queue.test.ts +484 -0
- package/test/registry.test.ts +306 -0
- package/test/security.test.ts +462 -0
- package/test/storage.test.ts +463 -0
- package/test/template-validator.test.ts +559 -0
- package/test/workflow.test.ts +592 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS GuardDuty
|
|
3
|
+
* Intelligent threat detection and continuous monitoring
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface GuardDutyDetector {
|
|
7
|
+
id: string
|
|
8
|
+
enable: boolean
|
|
9
|
+
findingPublishingFrequency?: 'FIFTEEN_MINUTES' | 'ONE_HOUR' | 'SIX_HOURS'
|
|
10
|
+
dataSources?: DataSourceConfigurations
|
|
11
|
+
features?: DetectorFeature[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DataSourceConfigurations {
|
|
15
|
+
s3Logs?: {
|
|
16
|
+
enable: boolean
|
|
17
|
+
}
|
|
18
|
+
kubernetes?: {
|
|
19
|
+
auditLogs: {
|
|
20
|
+
enable: boolean
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
malwareProtection?: {
|
|
24
|
+
scanEc2InstanceWithFindings: {
|
|
25
|
+
ebsVolumes: {
|
|
26
|
+
enable: boolean
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DetectorFeature {
|
|
33
|
+
name: 'S3_DATA_EVENTS' | 'EKS_AUDIT_LOGS' | 'EBS_MALWARE_PROTECTION' | 'RDS_LOGIN_EVENTS' | 'LAMBDA_NETWORK_LOGS'
|
|
34
|
+
status: 'ENABLED' | 'DISABLED'
|
|
35
|
+
additionalConfiguration?: {
|
|
36
|
+
name: string
|
|
37
|
+
status: 'ENABLED' | 'DISABLED'
|
|
38
|
+
}[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ThreatIntelSet {
|
|
42
|
+
id: string
|
|
43
|
+
detectorId: string
|
|
44
|
+
name: string
|
|
45
|
+
format: 'TXT' | 'STIX' | 'OTX_CSV' | 'ALIEN_VAULT' | 'PROOF_POINT' | 'FIRE_EYE'
|
|
46
|
+
location: string // S3 URI
|
|
47
|
+
activate: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IPSet {
|
|
51
|
+
id: string
|
|
52
|
+
detectorId: string
|
|
53
|
+
name: string
|
|
54
|
+
format: 'TXT' | 'STIX' | 'OTX_CSV' | 'ALIEN_VAULT' | 'PROOF_POINT' | 'FIRE_EYE'
|
|
55
|
+
location: string // S3 URI
|
|
56
|
+
activate: boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FindingFilter {
|
|
60
|
+
id: string
|
|
61
|
+
detectorId: string
|
|
62
|
+
name: string
|
|
63
|
+
description?: string
|
|
64
|
+
action: 'NOOP' | 'ARCHIVE'
|
|
65
|
+
rank: number
|
|
66
|
+
findingCriteria: FindingCriteria
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface FindingCriteria {
|
|
70
|
+
criterion: Record<string, {
|
|
71
|
+
eq?: string[]
|
|
72
|
+
neq?: string[]
|
|
73
|
+
gt?: number
|
|
74
|
+
gte?: number
|
|
75
|
+
lt?: number
|
|
76
|
+
lte?: number
|
|
77
|
+
}>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* GuardDuty manager
|
|
82
|
+
*/
|
|
83
|
+
export class GuardDutyManager {
|
|
84
|
+
private detectors: Map<string, GuardDutyDetector> = new Map()
|
|
85
|
+
private threatIntelSets: Map<string, ThreatIntelSet> = new Map()
|
|
86
|
+
private ipSets: Map<string, IPSet> = new Map()
|
|
87
|
+
private filters: Map<string, FindingFilter> = new Map()
|
|
88
|
+
private detectorCounter = 0
|
|
89
|
+
private threatIntelCounter = 0
|
|
90
|
+
private ipSetCounter = 0
|
|
91
|
+
private filterCounter = 0
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create GuardDuty detector
|
|
95
|
+
*/
|
|
96
|
+
createDetector(detector: Omit<GuardDutyDetector, 'id'>): GuardDutyDetector {
|
|
97
|
+
const id = `detector-${Date.now()}-${this.detectorCounter++}`
|
|
98
|
+
|
|
99
|
+
const guardDutyDetector: GuardDutyDetector = {
|
|
100
|
+
id,
|
|
101
|
+
...detector,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.detectors.set(id, guardDutyDetector)
|
|
105
|
+
|
|
106
|
+
return guardDutyDetector
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Create comprehensive detector with all features
|
|
111
|
+
*/
|
|
112
|
+
createComprehensiveDetector(): GuardDutyDetector {
|
|
113
|
+
return this.createDetector({
|
|
114
|
+
enable: true,
|
|
115
|
+
findingPublishingFrequency: 'FIFTEEN_MINUTES',
|
|
116
|
+
dataSources: {
|
|
117
|
+
s3Logs: {
|
|
118
|
+
enable: true,
|
|
119
|
+
},
|
|
120
|
+
kubernetes: {
|
|
121
|
+
auditLogs: {
|
|
122
|
+
enable: true,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
malwareProtection: {
|
|
126
|
+
scanEc2InstanceWithFindings: {
|
|
127
|
+
ebsVolumes: {
|
|
128
|
+
enable: true,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
features: [
|
|
134
|
+
{ name: 'S3_DATA_EVENTS', status: 'ENABLED' },
|
|
135
|
+
{ name: 'EKS_AUDIT_LOGS', status: 'ENABLED' },
|
|
136
|
+
{ name: 'EBS_MALWARE_PROTECTION', status: 'ENABLED' },
|
|
137
|
+
{ name: 'RDS_LOGIN_EVENTS', status: 'ENABLED' },
|
|
138
|
+
{ name: 'LAMBDA_NETWORK_LOGS', status: 'ENABLED' },
|
|
139
|
+
],
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create basic detector
|
|
145
|
+
*/
|
|
146
|
+
createBasicDetector(): GuardDutyDetector {
|
|
147
|
+
return this.createDetector({
|
|
148
|
+
enable: true,
|
|
149
|
+
findingPublishingFrequency: 'SIX_HOURS',
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Create threat intel set
|
|
155
|
+
*/
|
|
156
|
+
createThreatIntelSet(set: Omit<ThreatIntelSet, 'id'>): ThreatIntelSet {
|
|
157
|
+
const id = `threat-intel-${Date.now()}-${this.threatIntelCounter++}`
|
|
158
|
+
|
|
159
|
+
const threatIntelSet: ThreatIntelSet = {
|
|
160
|
+
id,
|
|
161
|
+
...set,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.threatIntelSets.set(id, threatIntelSet)
|
|
165
|
+
|
|
166
|
+
return threatIntelSet
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Create IP set
|
|
171
|
+
*/
|
|
172
|
+
createIPSet(set: Omit<IPSet, 'id'>): IPSet {
|
|
173
|
+
const id = `ip-set-${Date.now()}-${this.ipSetCounter++}`
|
|
174
|
+
|
|
175
|
+
const ipSet: IPSet = {
|
|
176
|
+
id,
|
|
177
|
+
...set,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.ipSets.set(id, ipSet)
|
|
181
|
+
|
|
182
|
+
return ipSet
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Create finding filter
|
|
187
|
+
*/
|
|
188
|
+
createFindingFilter(filter: Omit<FindingFilter, 'id'>): FindingFilter {
|
|
189
|
+
const id = `filter-${Date.now()}-${this.filterCounter++}`
|
|
190
|
+
|
|
191
|
+
const findingFilter: FindingFilter = {
|
|
192
|
+
id,
|
|
193
|
+
...filter,
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.filters.set(id, findingFilter)
|
|
197
|
+
|
|
198
|
+
return findingFilter
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Create auto-archive filter for low severity findings
|
|
203
|
+
*/
|
|
204
|
+
createLowSeverityArchiveFilter(detectorId: string): FindingFilter {
|
|
205
|
+
return this.createFindingFilter({
|
|
206
|
+
detectorId,
|
|
207
|
+
name: 'archive-low-severity',
|
|
208
|
+
description: 'Automatically archive low severity findings',
|
|
209
|
+
action: 'ARCHIVE',
|
|
210
|
+
rank: 1,
|
|
211
|
+
findingCriteria: {
|
|
212
|
+
criterion: {
|
|
213
|
+
severity: {
|
|
214
|
+
lt: 4,
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Create filter for specific finding types
|
|
223
|
+
*/
|
|
224
|
+
createFindingTypeFilter(
|
|
225
|
+
detectorId: string,
|
|
226
|
+
findingTypes: string[],
|
|
227
|
+
action: 'NOOP' | 'ARCHIVE',
|
|
228
|
+
): FindingFilter {
|
|
229
|
+
return this.createFindingFilter({
|
|
230
|
+
detectorId,
|
|
231
|
+
name: `filter-finding-types-${action.toLowerCase()}`,
|
|
232
|
+
description: `${action === 'ARCHIVE' ? 'Archive' : 'Keep'} specific finding types`,
|
|
233
|
+
action,
|
|
234
|
+
rank: 2,
|
|
235
|
+
findingCriteria: {
|
|
236
|
+
criterion: {
|
|
237
|
+
type: {
|
|
238
|
+
eq: findingTypes,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Create filter for trusted IP addresses
|
|
247
|
+
*/
|
|
248
|
+
createTrustedIPFilter(detectorId: string, ipAddresses: string[]): FindingFilter {
|
|
249
|
+
return this.createFindingFilter({
|
|
250
|
+
detectorId,
|
|
251
|
+
name: 'trusted-ip-addresses',
|
|
252
|
+
description: 'Archive findings from trusted IP addresses',
|
|
253
|
+
action: 'ARCHIVE',
|
|
254
|
+
rank: 3,
|
|
255
|
+
findingCriteria: {
|
|
256
|
+
criterion: {
|
|
257
|
+
'resource.instanceDetails.networkInterfaces.privateIpAddress': {
|
|
258
|
+
eq: ipAddresses,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Get detector
|
|
267
|
+
*/
|
|
268
|
+
getDetector(id: string): GuardDutyDetector | undefined {
|
|
269
|
+
return this.detectors.get(id)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* List detectors
|
|
274
|
+
*/
|
|
275
|
+
listDetectors(): GuardDutyDetector[] {
|
|
276
|
+
return Array.from(this.detectors.values())
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Get threat intel set
|
|
281
|
+
*/
|
|
282
|
+
getThreatIntelSet(id: string): ThreatIntelSet | undefined {
|
|
283
|
+
return this.threatIntelSets.get(id)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* List threat intel sets
|
|
288
|
+
*/
|
|
289
|
+
listThreatIntelSets(): ThreatIntelSet[] {
|
|
290
|
+
return Array.from(this.threatIntelSets.values())
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Get IP set
|
|
295
|
+
*/
|
|
296
|
+
getIPSet(id: string): IPSet | undefined {
|
|
297
|
+
return this.ipSets.get(id)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* List IP sets
|
|
302
|
+
*/
|
|
303
|
+
listIPSets(): IPSet[] {
|
|
304
|
+
return Array.from(this.ipSets.values())
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Get finding filter
|
|
309
|
+
*/
|
|
310
|
+
getFindingFilter(id: string): FindingFilter | undefined {
|
|
311
|
+
return this.filters.get(id)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* List finding filters
|
|
316
|
+
*/
|
|
317
|
+
listFindingFilters(): FindingFilter[] {
|
|
318
|
+
return Array.from(this.filters.values())
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Generate CloudFormation for detector
|
|
323
|
+
*/
|
|
324
|
+
generateDetectorCF(detector: GuardDutyDetector): any {
|
|
325
|
+
const cf: any = {
|
|
326
|
+
Type: 'AWS::GuardDuty::Detector',
|
|
327
|
+
Properties: {
|
|
328
|
+
Enable: detector.enable,
|
|
329
|
+
},
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (detector.findingPublishingFrequency) {
|
|
333
|
+
cf.Properties.FindingPublishingFrequency = detector.findingPublishingFrequency
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (detector.dataSources) {
|
|
337
|
+
cf.Properties.DataSources = {}
|
|
338
|
+
|
|
339
|
+
if (detector.dataSources.s3Logs) {
|
|
340
|
+
cf.Properties.DataSources.S3Logs = {
|
|
341
|
+
Enable: detector.dataSources.s3Logs.enable,
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (detector.dataSources.kubernetes) {
|
|
346
|
+
cf.Properties.DataSources.Kubernetes = {
|
|
347
|
+
AuditLogs: {
|
|
348
|
+
Enable: detector.dataSources.kubernetes.auditLogs.enable,
|
|
349
|
+
},
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (detector.dataSources.malwareProtection) {
|
|
354
|
+
cf.Properties.DataSources.MalwareProtection = {
|
|
355
|
+
ScanEc2InstanceWithFindings: {
|
|
356
|
+
EbsVolumes: {
|
|
357
|
+
Enable: detector.dataSources.malwareProtection.scanEc2InstanceWithFindings.ebsVolumes.enable,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (detector.features) {
|
|
365
|
+
cf.Properties.Features = detector.features.map(feature => ({
|
|
366
|
+
Name: feature.name,
|
|
367
|
+
Status: feature.status,
|
|
368
|
+
...(feature.additionalConfiguration && {
|
|
369
|
+
AdditionalConfiguration: feature.additionalConfiguration,
|
|
370
|
+
}),
|
|
371
|
+
}))
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return cf
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Generate CloudFormation for threat intel set
|
|
379
|
+
*/
|
|
380
|
+
generateThreatIntelSetCF(set: ThreatIntelSet): any {
|
|
381
|
+
return {
|
|
382
|
+
Type: 'AWS::GuardDuty::ThreatIntelSet',
|
|
383
|
+
Properties: {
|
|
384
|
+
DetectorId: set.detectorId,
|
|
385
|
+
Name: set.name,
|
|
386
|
+
Format: set.format,
|
|
387
|
+
Location: set.location,
|
|
388
|
+
Activate: set.activate,
|
|
389
|
+
},
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Generate CloudFormation for IP set
|
|
395
|
+
*/
|
|
396
|
+
generateIPSetCF(set: IPSet): any {
|
|
397
|
+
return {
|
|
398
|
+
Type: 'AWS::GuardDuty::IPSet',
|
|
399
|
+
Properties: {
|
|
400
|
+
DetectorId: set.detectorId,
|
|
401
|
+
Name: set.name,
|
|
402
|
+
Format: set.format,
|
|
403
|
+
Location: set.location,
|
|
404
|
+
Activate: set.activate,
|
|
405
|
+
},
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Generate CloudFormation for finding filter
|
|
411
|
+
*/
|
|
412
|
+
generateFilterCF(filter: FindingFilter): any {
|
|
413
|
+
return {
|
|
414
|
+
Type: 'AWS::GuardDuty::Filter',
|
|
415
|
+
Properties: {
|
|
416
|
+
DetectorId: filter.detectorId,
|
|
417
|
+
Name: filter.name,
|
|
418
|
+
Description: filter.description,
|
|
419
|
+
Action: filter.action,
|
|
420
|
+
Rank: filter.rank,
|
|
421
|
+
FindingCriteria: {
|
|
422
|
+
Criterion: filter.findingCriteria.criterion,
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Clear all data
|
|
430
|
+
*/
|
|
431
|
+
clear(): void {
|
|
432
|
+
this.detectors.clear()
|
|
433
|
+
this.threatIntelSets.clear()
|
|
434
|
+
this.ipSets.clear()
|
|
435
|
+
this.filters.clear()
|
|
436
|
+
this.detectorCounter = 0
|
|
437
|
+
this.threatIntelCounter = 0
|
|
438
|
+
this.ipSetCounter = 0
|
|
439
|
+
this.filterCounter = 0
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Global GuardDuty manager instance
|
|
445
|
+
*/
|
|
446
|
+
export const guardDutyManager: GuardDutyManager = new GuardDutyManager()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compliance & Governance
|
|
3
|
+
* AWS Config, CloudTrail, GuardDuty, and Security Hub integrations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// AWS Config
|
|
7
|
+
export {
|
|
8
|
+
AWSConfigManager,
|
|
9
|
+
awsConfigManager,
|
|
10
|
+
} from './aws-config'
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
ConfigRule,
|
|
14
|
+
ConfigScope,
|
|
15
|
+
ConfigRecorder,
|
|
16
|
+
RecordingGroup,
|
|
17
|
+
DeliveryChannel,
|
|
18
|
+
} from './aws-config'
|
|
19
|
+
|
|
20
|
+
// CloudTrail
|
|
21
|
+
export {
|
|
22
|
+
CloudTrailManager,
|
|
23
|
+
cloudTrailManager,
|
|
24
|
+
} from './cloudtrail'
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
CloudTrailConfig,
|
|
28
|
+
EventSelector,
|
|
29
|
+
DataResource,
|
|
30
|
+
InsightSelector,
|
|
31
|
+
AdvancedEventSelector,
|
|
32
|
+
FieldSelector,
|
|
33
|
+
} from './cloudtrail'
|
|
34
|
+
|
|
35
|
+
// GuardDuty
|
|
36
|
+
export {
|
|
37
|
+
GuardDutyManager,
|
|
38
|
+
guardDutyManager,
|
|
39
|
+
} from './guardduty'
|
|
40
|
+
|
|
41
|
+
export type {
|
|
42
|
+
GuardDutyDetector,
|
|
43
|
+
DataSourceConfigurations,
|
|
44
|
+
DetectorFeature,
|
|
45
|
+
ThreatIntelSet,
|
|
46
|
+
IPSet,
|
|
47
|
+
FindingFilter,
|
|
48
|
+
FindingCriteria,
|
|
49
|
+
} from './guardduty'
|
|
50
|
+
|
|
51
|
+
// Security Hub
|
|
52
|
+
export {
|
|
53
|
+
SecurityHubManager,
|
|
54
|
+
securityHubManager,
|
|
55
|
+
} from './security-hub'
|
|
56
|
+
|
|
57
|
+
export type {
|
|
58
|
+
SecurityHubConfig,
|
|
59
|
+
SecurityStandard,
|
|
60
|
+
AutomationRule,
|
|
61
|
+
AutomationAction,
|
|
62
|
+
AutomationCriteria,
|
|
63
|
+
StringFilter,
|
|
64
|
+
NumberFilter,
|
|
65
|
+
MapFilter,
|
|
66
|
+
} from './security-hub'
|