@intentius/chant-lexicon-terraform 0.100.0 → 0.102.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/codegen/package.d.ts +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/hcl/jsonencode.d.ts +106 -0
- package/dist/hcl/jsonencode.d.ts.map +1 -0
- package/dist/hcl/marker.d.ts.map +1 -1
- package/dist/integrity.json +11 -2
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-lineage.d.ts +1 -1
- package/dist/lint/audit-lineage.d.ts.map +1 -1
- package/dist/lint/post-synth/flat-attributes.d.ts +69 -0
- package/dist/lint/post-synth/flat-attributes.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/tf030.d.ts +51 -0
- package/dist/lint/post-synth/tf030.d.ts.map +1 -0
- package/dist/lint/post-synth/tf031.d.ts +55 -0
- package/dist/lint/post-synth/tf031.d.ts.map +1 -0
- package/dist/lint/post-synth/tf032.d.ts +71 -0
- package/dist/lint/post-synth/tf032.d.ts.map +1 -0
- package/dist/lint/post-synth/tf033.d.ts +50 -0
- package/dist/lint/post-synth/tf033.d.ts.map +1 -0
- package/dist/lint/post-synth/tf034.d.ts +25 -0
- package/dist/lint/post-synth/tf034.d.ts.map +1 -0
- package/dist/lint/post-synth/tf035.d.ts +33 -0
- package/dist/lint/post-synth/tf035.d.ts.map +1 -0
- package/dist/lint/post-synth/tf036.d.ts +33 -0
- package/dist/lint/post-synth/tf036.d.ts.map +1 -0
- package/dist/lint/post-synth/tf037.d.ts +31 -0
- package/dist/lint/post-synth/tf037.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/okf/index.md +8 -0
- package/dist/okf/rules/TF030.md +11 -0
- package/dist/okf/rules/TF031.md +11 -0
- package/dist/okf/rules/TF032.md +11 -0
- package/dist/okf/rules/TF033.md +11 -0
- package/dist/okf/rules/TF034.md +11 -0
- package/dist/okf/rules/TF035.md +11 -0
- package/dist/okf/rules/TF036.md +11 -0
- package/dist/okf/rules/TF037.md +11 -0
- package/dist/op/activity-contracts.d.ts +18 -18
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/rules/flat-attributes.ts +146 -0
- package/dist/rules/tf030.ts +290 -0
- package/dist/rules/tf031.ts +370 -0
- package/dist/rules/tf032.ts +226 -0
- package/dist/rules/tf033.ts +160 -0
- package/dist/rules/tf034.ts +63 -0
- package/dist/rules/tf035.ts +74 -0
- package/dist/rules/tf036.ts +119 -0
- package/dist/rules/tf037.ts +101 -0
- package/package.json +3 -3
- package/src/hcl/jsonencode.test.ts +226 -0
- package/src/hcl/jsonencode.ts +454 -0
- package/src/lint/audit-catalog.ts +148 -0
- package/src/lint/audit-lineage.ts +155 -1
- package/src/lint/post-synth/estate-2284.test.ts +68 -0
- package/src/lint/post-synth/fixtures/TF030/negative-rules.tf +45 -0
- package/src/lint/post-synth/fixtures/TF030/negative.tf +55 -0
- package/src/lint/post-synth/fixtures/TF030/not-determined-port.tf +28 -0
- package/src/lint/post-synth/fixtures/TF030/not-determined-standalone.tf +32 -0
- package/src/lint/post-synth/fixtures/TF030/not-determined-vpc-rule.tf +21 -0
- package/src/lint/post-synth/fixtures/TF030/not-determined.tf +39 -0
- package/src/lint/post-synth/fixtures/TF030/positive-ipv6.tf +44 -0
- package/src/lint/post-synth/fixtures/TF030/positive-mixed.tf +36 -0
- package/src/lint/post-synth/fixtures/TF030/positive-standalone.tf +25 -0
- package/src/lint/post-synth/fixtures/TF030/positive.tf +43 -0
- package/src/lint/post-synth/fixtures/TF031/negative.tf +89 -0
- package/src/lint/post-synth/fixtures/TF031/not-determined.tf +139 -0
- package/src/lint/post-synth/fixtures/TF031/positive-data-source.tf +57 -0
- package/src/lint/post-synth/fixtures/TF031/positive-heredoc.tf +149 -0
- package/src/lint/post-synth/fixtures/TF031/positive-jsonencode.tf +115 -0
- package/src/lint/post-synth/fixtures/TF032/negative-heredoc.tf +20 -0
- package/src/lint/post-synth/fixtures/TF032/negative-references.tf +214 -0
- package/src/lint/post-synth/fixtures/TF032/negative.tf +99 -0
- package/src/lint/post-synth/fixtures/TF032/positive-heredoc.tf +22 -0
- package/src/lint/post-synth/fixtures/TF032/positive-sidecar.tf +197 -0
- package/src/lint/post-synth/fixtures/TF032/positive.tf +54 -0
- package/src/lint/post-synth/fixtures/TF033/negative.tf +39 -0
- package/src/lint/post-synth/fixtures/TF033/not-determined-aurora.tf +25 -0
- package/src/lint/post-synth/fixtures/TF033/positive-absent.tf +93 -0
- package/src/lint/post-synth/fixtures/TF033/positive.tf +50 -0
- package/src/lint/post-synth/fixtures/TF034/negative.tf +24 -0
- package/src/lint/post-synth/fixtures/TF034/positive-absent.tf +36 -0
- package/src/lint/post-synth/fixtures/TF034/positive.tf +14 -0
- package/src/lint/post-synth/fixtures/TF035/negative-absent.tf +43 -0
- package/src/lint/post-synth/fixtures/TF035/negative.tf +54 -0
- package/src/lint/post-synth/fixtures/TF035/positive.tf +37 -0
- package/src/lint/post-synth/fixtures/TF036/negative.tf +61 -0
- package/src/lint/post-synth/fixtures/TF036/not-determined.tf +28 -0
- package/src/lint/post-synth/fixtures/TF036/positive.tf +38 -0
- package/src/lint/post-synth/fixtures/TF037/negative-exclusion.tf +63 -0
- package/src/lint/post-synth/fixtures/TF037/negative.tf +27 -0
- package/src/lint/post-synth/fixtures/TF037/not-determined.tf +27 -0
- package/src/lint/post-synth/fixtures/TF037/positive-absent.tf +15 -0
- package/src/lint/post-synth/fixtures/TF037/positive.tf +26 -0
- package/src/lint/post-synth/fixtures/estate-2284/clean/main.tf +132 -0
- package/src/lint/post-synth/fixtures/estate-2284/violating/main.tf +112 -0
- package/src/lint/post-synth/flat-attributes.ts +146 -0
- package/src/lint/post-synth/index.ts +16 -0
- package/src/lint/post-synth/tf030.test.ts +219 -0
- package/src/lint/post-synth/tf030.ts +290 -0
- package/src/lint/post-synth/tf031.test.ts +229 -0
- package/src/lint/post-synth/tf031.ts +370 -0
- package/src/lint/post-synth/tf032.test.ts +127 -0
- package/src/lint/post-synth/tf032.ts +226 -0
- package/src/lint/post-synth/tf033.test.ts +126 -0
- package/src/lint/post-synth/tf033.ts +160 -0
- package/src/lint/post-synth/tf034.test.ts +71 -0
- package/src/lint/post-synth/tf034.ts +63 -0
- package/src/lint/post-synth/tf035.test.ts +68 -0
- package/src/lint/post-synth/tf035.ts +74 -0
- package/src/lint/post-synth/tf036.test.ts +87 -0
- package/src/lint/post-synth/tf036.ts +119 -0
- package/src/lint/post-synth/tf037.test.ts +88 -0
- package/src/lint/post-synth/tf037.ts +101 -0
- package/src/op/activities/terraform.test.ts +2 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Vendored for TF031 (chant #2286), unmodified below this header.
|
|
2
|
+
# Source: https://github.com/alphagov/tech-ops/blob/122e78d1c6477825b22dd52f32e185a4a7838683/reliability-engineering/terraform/modules/concourse-monitoring/prometheus-ecs-iam.tf
|
|
3
|
+
# Repository: alphagov/tech-ops, path reliability-engineering/terraform/modules/concourse-monitoring/prometheus-ecs-iam.tf, commit 122e78d1c6477825b22dd52f32e185a4a7838683
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
#
|
|
6
|
+
# Scoped policies only: every action is named and every resource is an
|
|
7
|
+
# attribute of a managed resource, which can never be "*". TF031 reports
|
|
8
|
+
# nothing, and not "not determined" either.
|
|
9
|
+
#
|
|
10
|
+
# Copyright (c) 2018 Government Digital Service
|
|
11
|
+
#
|
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
# in the Software without restriction, including without limitation the rights
|
|
15
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
# furnished to do so, subject to the following conditions:
|
|
18
|
+
#
|
|
19
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
# copies or substantial portions of the Software.
|
|
21
|
+
#
|
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
# SOFTWARE.
|
|
29
|
+
|
|
30
|
+
data "aws_iam_policy_document" "ecs_assume_role" {
|
|
31
|
+
statement {
|
|
32
|
+
actions = ["sts:AssumeRole"]
|
|
33
|
+
principals {
|
|
34
|
+
type = "Service"
|
|
35
|
+
identifiers = ["ecs-tasks.amazonaws.com"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
resource "aws_iam_role" "prometheus_execution" {
|
|
41
|
+
name = "${var.deployment}-prometheus-execution"
|
|
42
|
+
assume_role_policy = data.aws_iam_policy_document.ecs_assume_role.json
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
data "aws_iam_policy_document" "prometheus_data_volume_access" {
|
|
46
|
+
statement {
|
|
47
|
+
principals {
|
|
48
|
+
type = "AWS"
|
|
49
|
+
identifiers = [aws_iam_role.concourse_prometheus.arn]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
actions = [
|
|
53
|
+
"elasticfilesystem:ClientMount",
|
|
54
|
+
"elasticfilesystem:ClientWrite",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
condition {
|
|
58
|
+
test = "StringEquals"
|
|
59
|
+
variable = "elasticfilesystem:AccessPointArn"
|
|
60
|
+
values = [aws_efs_access_point.prometheus.arn]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
resources = [aws_efs_file_system.prometheus.arn]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
data "aws_iam_policy_document" "prometheus_cloudwatch_access" {
|
|
68
|
+
statement {
|
|
69
|
+
actions = [
|
|
70
|
+
"logs:CreateLogStream",
|
|
71
|
+
"logs:PutLogEvents",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
resources = [
|
|
75
|
+
aws_cloudwatch_log_group.prometheus.arn,
|
|
76
|
+
"${aws_cloudwatch_log_group.prometheus.arn}:log-stream:*",
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
resource "aws_iam_policy" "prometheus_cloudwatch_access" {
|
|
82
|
+
name = "${var.deployment}-prometheus-cloudwatch-access"
|
|
83
|
+
policy = data.aws_iam_policy_document.prometheus_cloudwatch_access.json
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
resource "aws_iam_role_policy_attachment" "prometheus_cloudwatch_access" {
|
|
87
|
+
role = aws_iam_role.prometheus_execution.name
|
|
88
|
+
policy_arn = aws_iam_policy.prometheus_cloudwatch_access.arn
|
|
89
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Vendored for TF031 (chant #2286), unmodified below this header.
|
|
2
|
+
# Source: https://github.com/alphagov/tech-ops/blob/122e78d1c6477825b22dd52f32e185a4a7838683/reliability-engineering/terraform/modules/concourse-secrets-admin/iam.tf
|
|
3
|
+
# Repository: alphagov/tech-ops, path reliability-engineering/terraform/modules/concourse-secrets-admin/iam.tf, commit 122e78d1c6477825b22dd52f32e185a4a7838683
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
#
|
|
6
|
+
# Both documents build Statement with concat(...) and a for-expression, so
|
|
7
|
+
# TF031 cannot read them and reports not determined, never a warning. The
|
|
8
|
+
# Deny statement with Action "*" and Resource "*" inside the concat is a guard
|
|
9
|
+
# rail and would not fire even if it were readable.
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) 2018 Government Digital Service
|
|
12
|
+
#
|
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
# furnished to do so, subject to the following conditions:
|
|
19
|
+
#
|
|
20
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
# copies or substantial portions of the Software.
|
|
22
|
+
#
|
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
# SOFTWARE.
|
|
30
|
+
|
|
31
|
+
resource "aws_iam_role" "concourse_secrets_admin" {
|
|
32
|
+
name = "${var.deployment}-${var.concourse_team_name}-concourse-secrets-admin"
|
|
33
|
+
|
|
34
|
+
assume_role_policy = jsonencode({
|
|
35
|
+
Version = "2012-10-17"
|
|
36
|
+
Statement = concat(
|
|
37
|
+
[
|
|
38
|
+
for team_id in concat(
|
|
39
|
+
var.trusted_github_team_id == "" ? [] : [var.trusted_github_team_id],
|
|
40
|
+
var.trusted_github_team_ids
|
|
41
|
+
) : {
|
|
42
|
+
Effect = "Allow"
|
|
43
|
+
Principal = {
|
|
44
|
+
Federated = var.iam_oidc_provider_arn
|
|
45
|
+
}
|
|
46
|
+
Action = "sts:AssumeRoleWithWebIdentity"
|
|
47
|
+
Condition = {
|
|
48
|
+
StringEquals = {
|
|
49
|
+
"${var.oidc_host_path}:aud" = var.github_oauth_client_id
|
|
50
|
+
"aws:RequestTag/t${team_id}" = "t"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
Sid = "AllowPassSessionTagsAndTransitive"
|
|
58
|
+
Effect = "Allow"
|
|
59
|
+
Action = "sts:TagSession"
|
|
60
|
+
Principal = {
|
|
61
|
+
Federated = var.iam_oidc_provider_arn
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
(length(var.allowed_cidrs) == 0 ? [] : [{
|
|
66
|
+
Sid = "DisallowAssumeFromUntrustedCIDR"
|
|
67
|
+
Effect = "Deny"
|
|
68
|
+
Principal = {
|
|
69
|
+
Federated = var.iam_oidc_provider_arn
|
|
70
|
+
}
|
|
71
|
+
Action = "sts:AssumeRoleWithWebIdentity"
|
|
72
|
+
Condition = {
|
|
73
|
+
NotIpAddress = {
|
|
74
|
+
"aws:SourceIp" = var.allowed_cidrs
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
])
|
|
79
|
+
)
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
resource "aws_iam_role_policy" "concourse_secrets_admin" {
|
|
84
|
+
name = "${var.deployment}-${var.concourse_team_name}-concourse-secrets-admin-policy"
|
|
85
|
+
role = aws_iam_role.concourse_secrets_admin.id
|
|
86
|
+
|
|
87
|
+
policy = jsonencode({
|
|
88
|
+
Version = "2012-10-17"
|
|
89
|
+
Statement = concat(
|
|
90
|
+
[
|
|
91
|
+
{
|
|
92
|
+
Action = [
|
|
93
|
+
"ssm:GetParameter",
|
|
94
|
+
"ssm:GetParameterHistory",
|
|
95
|
+
"ssm:GetParameters",
|
|
96
|
+
"ssm:GetParametersByPath",
|
|
97
|
+
"ssm:DeleteParameter",
|
|
98
|
+
"ssm:PutParameter",
|
|
99
|
+
]
|
|
100
|
+
Effect = "Allow"
|
|
101
|
+
Resource = [
|
|
102
|
+
"arn:aws:ssm:eu-west-2:${data.aws_caller_identity.account.account_id}:parameter/${var.deployment}/concourse/pipelines/${var.concourse_team_name}/*"
|
|
103
|
+
]
|
|
104
|
+
}, {
|
|
105
|
+
Action = [
|
|
106
|
+
"ssm:DeleteParameter",
|
|
107
|
+
"ssm:PutParameter",
|
|
108
|
+
]
|
|
109
|
+
Effect = "Deny"
|
|
110
|
+
Resource = [
|
|
111
|
+
"arn:aws:ssm:eu-west-2:${data.aws_caller_identity.account.account_id}:parameter/${var.deployment}/concourse/pipelines/${var.concourse_team_name}/readonly_*"
|
|
112
|
+
]
|
|
113
|
+
}, {
|
|
114
|
+
Action = [
|
|
115
|
+
"kms:ListKeys",
|
|
116
|
+
"kms:ListAliases",
|
|
117
|
+
"kms:Describe*",
|
|
118
|
+
"kms:Decrypt",
|
|
119
|
+
"kms:Encrypt",
|
|
120
|
+
]
|
|
121
|
+
Effect = "Allow"
|
|
122
|
+
Resource = var.kms_key_arn
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
(length(var.allowed_cidrs) == 0 ? [] : [{
|
|
126
|
+
Sid = "DisallowAllFromUntrustedCIDR"
|
|
127
|
+
Effect = "Deny"
|
|
128
|
+
Action = "*"
|
|
129
|
+
Resource = "*"
|
|
130
|
+
Condition = {
|
|
131
|
+
NotIpAddress = {
|
|
132
|
+
"aws:SourceIp" = var.allowed_cidrs
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
])
|
|
137
|
+
)
|
|
138
|
+
})
|
|
139
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Vendored for TF031 (chant #2286), unmodified below this header.
|
|
2
|
+
# Source: https://github.com/alphagov/tech-ops/blob/122e78d1c6477825b22dd52f32e185a4a7838683/cyber-security/modules/gds_security_audit_role/inline_policies.tf
|
|
3
|
+
# Repository: alphagov/tech-ops, path cyber-security/modules/gds_security_audit_role/inline_policies.tf, commit 122e78d1c6477825b22dd52f32e185a4a7838683
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
#
|
|
6
|
+
# TF031 fires on both aws_iam_policy_document data sources (resources = ["*"]).
|
|
7
|
+
# The two aws_iam_role_policy resources name those documents' .json and are
|
|
8
|
+
# not reported again.
|
|
9
|
+
#
|
|
10
|
+
# Copyright (c) 2018 Government Digital Service
|
|
11
|
+
#
|
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
# in the Software without restriction, including without limitation the rights
|
|
15
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
# furnished to do so, subject to the following conditions:
|
|
18
|
+
#
|
|
19
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
# copies or substantial portions of the Software.
|
|
21
|
+
#
|
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
# SOFTWARE.
|
|
29
|
+
|
|
30
|
+
data "aws_iam_policy_document" "support_inline_policy_document" {
|
|
31
|
+
statement {
|
|
32
|
+
effect = "Allow"
|
|
33
|
+
actions = ["support:*"]
|
|
34
|
+
resources = ["*"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resource "aws_iam_role_policy" "support_inline_policy" {
|
|
39
|
+
name = "${var.prefix}GDSSecurityAuditInlineSupportPolicy"
|
|
40
|
+
role = aws_iam_role.gds_security_audit_role.id
|
|
41
|
+
policy = data.aws_iam_policy_document.support_inline_policy_document.json
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
data "aws_iam_policy_document" "sts_inline_policy_document" {
|
|
45
|
+
statement {
|
|
46
|
+
effect = "Allow"
|
|
47
|
+
actions = ["sts:GetCallerIdentity"]
|
|
48
|
+
resources = ["*"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
resource "aws_iam_role_policy" "sts_inline_policy" {
|
|
53
|
+
name = "${var.prefix}GDSSecurityAuditInlineSTSPolicy"
|
|
54
|
+
role = aws_iam_role.gds_security_audit_role.id
|
|
55
|
+
policy = data.aws_iam_policy_document.sts_inline_policy_document.json
|
|
56
|
+
}
|
|
57
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Vendored for TF031 (chant #2286), unmodified below this header.
|
|
2
|
+
# Source: https://github.com/terraform-community-modules/tf_aws_ecs/blob/4a41e9c5acf4b71893bcb1ab3856c7c630f283d6/iam.tf
|
|
3
|
+
# Repository: terraform-community-modules/tf_aws_ecs, path iam.tf, commit 4a41e9c5acf4b71893bcb1ab3856c7c630f283d6
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
#
|
|
6
|
+
# A heredoc with no interpolation is a literal string in the parse, so TF031
|
|
7
|
+
# reads it as JSON: aws_iam_policy.ecs_policy (Resource "*") fires, and so does
|
|
8
|
+
# data.aws_iam_policy_document.consul_task_policy. aws_iam_policy.custom_ecs_policy
|
|
9
|
+
# is "${var.custom_iam_policy}" and is reported as not determined.
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) 2016 Tim Hartmann
|
|
12
|
+
#
|
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
# furnished to do so, subject to the following conditions:
|
|
19
|
+
#
|
|
20
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
# copies or substantial portions of the Software.
|
|
22
|
+
#
|
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
# SOFTWARE.
|
|
30
|
+
|
|
31
|
+
resource "aws_iam_instance_profile" "ecs_profile" {
|
|
32
|
+
name_prefix = "${replace(format("%.102s", replace("tf-ECSProfile-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
33
|
+
role = "${aws_iam_role.ecs_role.name}"
|
|
34
|
+
path = "${var.iam_path}"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
resource "aws_iam_role" "ecs_role" {
|
|
38
|
+
name_prefix = "${replace(format("%.32s", replace("tf-ECSInRole-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
39
|
+
path = "${var.iam_path}"
|
|
40
|
+
|
|
41
|
+
assume_role_policy = <<EOF
|
|
42
|
+
{
|
|
43
|
+
"Version": "2012-10-17",
|
|
44
|
+
"Statement": [
|
|
45
|
+
{
|
|
46
|
+
"Action": "sts:AssumeRole",
|
|
47
|
+
"Principal": {
|
|
48
|
+
"Service": ["ecs.amazonaws.com", "ec2.amazonaws.com"]
|
|
49
|
+
|
|
50
|
+
},
|
|
51
|
+
"Effect": "Allow",
|
|
52
|
+
"Sid": ""
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
EOF
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# It may be useful to add the following for troubleshooting the InstanceStatus
|
|
60
|
+
# Health check if using the fitnesskeeper/consul docker image
|
|
61
|
+
# "ec2:Describe*",
|
|
62
|
+
# "autoscaling:Describe*",
|
|
63
|
+
|
|
64
|
+
resource "aws_iam_policy" "ecs_policy" {
|
|
65
|
+
name_prefix = "${replace(format("%.102s", replace("tf-ECSInPol-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
66
|
+
description = "A terraform created policy for ECS"
|
|
67
|
+
path = "${var.iam_path}"
|
|
68
|
+
count = "${length(var.custom_iam_policy) > 0 ? 0 : 1}"
|
|
69
|
+
|
|
70
|
+
policy = <<EOF
|
|
71
|
+
{
|
|
72
|
+
"Version": "2012-10-17",
|
|
73
|
+
"Statement": [
|
|
74
|
+
{
|
|
75
|
+
"Effect": "Allow",
|
|
76
|
+
"Action": [
|
|
77
|
+
"ecs:CreateCluster",
|
|
78
|
+
"ecs:DeregisterContainerInstance",
|
|
79
|
+
"ecs:DiscoverPollEndpoint",
|
|
80
|
+
"ecs:Poll",
|
|
81
|
+
"ecs:RegisterContainerInstance",
|
|
82
|
+
"ecs:StartTelemetrySession",
|
|
83
|
+
"ecs:Submit*",
|
|
84
|
+
"ecr:GetAuthorizationToken",
|
|
85
|
+
"ecr:BatchCheckLayerAvailability",
|
|
86
|
+
"ecr:GetDownloadUrlForLayer",
|
|
87
|
+
"ecr:BatchGetImage",
|
|
88
|
+
"logs:CreateLogStream",
|
|
89
|
+
"logs:PutLogEvents"
|
|
90
|
+
],
|
|
91
|
+
"Resource": "*"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
EOF
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
resource "aws_iam_policy" "custom_ecs_policy" {
|
|
99
|
+
name_prefix = "${replace(format("%.102s", replace("tf-ECSInPol-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
100
|
+
description = "A terraform created policy for ECS"
|
|
101
|
+
path = "${var.iam_path}"
|
|
102
|
+
count = "${length(var.custom_iam_policy) > 0 ? 1 : 0}"
|
|
103
|
+
|
|
104
|
+
policy = "${var.custom_iam_policy}"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
resource "aws_iam_policy_attachment" "attach_ecs" {
|
|
108
|
+
name = "ecs-attachment"
|
|
109
|
+
roles = ["${aws_iam_role.ecs_role.name}"]
|
|
110
|
+
policy_arn = "${element(concat(aws_iam_policy.ecs_policy.*.arn, aws_iam_policy.custom_ecs_policy.*.arn), 0)}"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# IAM Resources for Consul and Registrator Agents
|
|
114
|
+
|
|
115
|
+
data "aws_iam_policy_document" "consul_task_policy" {
|
|
116
|
+
statement {
|
|
117
|
+
actions = [
|
|
118
|
+
"ec2:Describe*",
|
|
119
|
+
"autoscaling:Describe*",
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
resources = ["*"]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
data "aws_iam_policy_document" "assume_role_consul_task" {
|
|
127
|
+
statement {
|
|
128
|
+
actions = ["sts:AssumeRole"]
|
|
129
|
+
|
|
130
|
+
principals {
|
|
131
|
+
type = "Service"
|
|
132
|
+
identifiers = ["ecs-tasks.amazonaws.com"]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
resource "aws_iam_role" "consul_task" {
|
|
138
|
+
count = "${var.enable_agents ? 1 : 0}"
|
|
139
|
+
name_prefix = "${replace(format("%.32s", replace("tf-agentTaskRole-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
140
|
+
path = "${var.iam_path}"
|
|
141
|
+
assume_role_policy = "${data.aws_iam_policy_document.assume_role_consul_task.json}"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
resource "aws_iam_role_policy" "consul_ecs_task" {
|
|
145
|
+
count = "${var.enable_agents ? 1 : 0}"
|
|
146
|
+
name_prefix = "${replace(format("%.102s", replace("tf-agentTaskPol-${var.name}-", "_", "-")), "/\\s/", "-")}"
|
|
147
|
+
role = "${aws_iam_role.consul_task.id}"
|
|
148
|
+
policy = "${data.aws_iam_policy_document.consul_task_policy.json}"
|
|
149
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Vendored for TF031 (chant #2286), unmodified below this header.
|
|
2
|
+
# Source: https://github.com/BishopFox/iam-vulnerable/blob/0f298666f9b7cfa01488b86912afdb211773188a/modules/free-resources/privesc-paths/privesc-AssumeRole.tf
|
|
3
|
+
# Repository: BishopFox/iam-vulnerable, path modules/free-resources/privesc-paths/privesc-AssumeRole.tf, commit 0f298666f9b7cfa01488b86912afdb211773188a
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
#
|
|
6
|
+
# TF031 fires on aws_iam_policy.privesc-AssumeRole-high-priv-policy: a literal
|
|
7
|
+
# jsonencode() policy whose one Allow statement has Action "*" and Resource "*".
|
|
8
|
+
# The three roles' assume_role_policy documents carry a reference Principal
|
|
9
|
+
# beside a literal Action, and are read as scoped, not as not determined.
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) 2021 Bishop Fox
|
|
12
|
+
#
|
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
# furnished to do so, subject to the following conditions:
|
|
19
|
+
#
|
|
20
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
# copies or substantial portions of the Software.
|
|
22
|
+
#
|
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
# SOFTWARE.
|
|
30
|
+
|
|
31
|
+
resource "aws_iam_policy" "privesc-AssumeRole-high-priv-policy" {
|
|
32
|
+
name = "privesc-AssumeRole-high-priv-policy"
|
|
33
|
+
path = "/"
|
|
34
|
+
description = "Allows privesc via targeted sts:AssumeRole"
|
|
35
|
+
|
|
36
|
+
# Terraform's "jsonencode" function converts a
|
|
37
|
+
# Terraform expression result to valid JSON syntax.
|
|
38
|
+
policy = jsonencode({
|
|
39
|
+
Version = "2012-10-17"
|
|
40
|
+
Statement = [
|
|
41
|
+
{
|
|
42
|
+
Effect = "Allow"
|
|
43
|
+
Action = "*"
|
|
44
|
+
Resource = "*"
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
resource "aws_iam_role" "privesc-AssumeRole-starting-role" {
|
|
51
|
+
name = "privesc-AssumeRole-starting-role"
|
|
52
|
+
assume_role_policy = jsonencode({
|
|
53
|
+
Version = "2012-10-17"
|
|
54
|
+
Statement = [
|
|
55
|
+
{
|
|
56
|
+
Action = "sts:AssumeRole"
|
|
57
|
+
Effect = "Allow"
|
|
58
|
+
Sid = ""
|
|
59
|
+
Principal = {
|
|
60
|
+
AWS = var.aws_assume_role_arn
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
resource "aws_iam_role" "privesc-AssumeRole-intermediate-role" {
|
|
68
|
+
name = "privesc-AssumeRole-intermediate-role"
|
|
69
|
+
assume_role_policy = jsonencode({
|
|
70
|
+
Version = "2012-10-17"
|
|
71
|
+
Statement = [
|
|
72
|
+
{
|
|
73
|
+
Action = "sts:AssumeRole"
|
|
74
|
+
Effect = "Allow"
|
|
75
|
+
Sid = ""
|
|
76
|
+
Principal = {
|
|
77
|
+
AWS = aws_iam_role.privesc-AssumeRole-starting-role.arn
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
resource "aws_iam_role" "privesc-AssumeRole-ending-role" {
|
|
86
|
+
name = "privesc-AssumeRole-ending-role"
|
|
87
|
+
assume_role_policy = jsonencode({
|
|
88
|
+
Version = "2012-10-17"
|
|
89
|
+
Statement = [
|
|
90
|
+
{
|
|
91
|
+
Action = "sts:AssumeRole"
|
|
92
|
+
Effect = "Allow"
|
|
93
|
+
Sid = ""
|
|
94
|
+
Principal = {
|
|
95
|
+
AWS = aws_iam_role.privesc-AssumeRole-intermediate-role.arn
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
resource "aws_iam_user" "privesc-AssumeRole-start-user" {
|
|
105
|
+
name = "privesc-AssumeRole-start-user"
|
|
106
|
+
path = "/"
|
|
107
|
+
}
|
|
108
|
+
resource "aws_iam_access_key" "privesc-AssumeRole-start-user" {
|
|
109
|
+
user = aws_iam_user.privesc-AssumeRole-start-user.name
|
|
110
|
+
}
|
|
111
|
+
resource "aws_iam_role_policy_attachment" "privesc-AssumeRole-high-priv-policy-role-attach-policy" {
|
|
112
|
+
role = aws_iam_role.privesc-AssumeRole-ending-role.name
|
|
113
|
+
policy_arn = aws_iam_policy.privesc-AssumeRole-high-priv-policy.arn
|
|
114
|
+
|
|
115
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Vendored for TF032 (chant #2287). Source: https://github.com/aquasecurity/trivy-checks
|
|
2
|
+
# Path: checks/cloud/aws/ecs/no_plaintext_secrets.yaml (terraform.good[0])
|
|
3
|
+
# Commit: 71c05d02845cc2c3a5dfa4fe914a68a052cc88bf
|
|
4
|
+
# Licence: MIT
|
|
5
|
+
# Copyright (c) 2024 Aqua Security. MIT licence: https://github.com/aquasecurity/trivy-checks/blob/71c05d02845cc2c3a5dfa4fe914a68a052cc88bf/LICENSE
|
|
6
|
+
# The upstream check's own passing example, lifted out of its YAML block scalar unchanged.
|
|
7
|
+
# Silent: the one environment entry is not a credential.
|
|
8
|
+
|
|
9
|
+
resource "aws_ecs_task_definition" "good_example" {
|
|
10
|
+
container_definitions = <<EOF
|
|
11
|
+
[
|
|
12
|
+
{
|
|
13
|
+
"name": "my_service",
|
|
14
|
+
"environment": [
|
|
15
|
+
{ "name": "ENVIRONMENT", "value": "development" }
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
EOF
|
|
20
|
+
}
|