forked from aquasecurity/tfsec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
no_policy_wildcards.tf.go
85 lines (75 loc) · 1.77 KB
/
no_policy_wildcards.tf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package iam
var terraformNoPolicyWildcardsGoodExamples = []string{
`
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id
policy = data.aws_iam_policy_document.s3_policy.json
}
resource "aws_iam_role" "test_role" {
name = "test_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "s3.amazonaws.com"
}
},
]
})
}
data "aws_iam_policy_document" "s3_policy" {
statement {
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
actions = ["s3:GetObject"]
resources = [aws_s3_bucket.example.arn]
}
}
`,
}
var terraformNoPolicyWildcardsBadExamples = []string{
`
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id
policy = data.aws_iam_policy_document.s3_policy.json
}
resource "aws_iam_role" "test_role" {
name = "test_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "s3.amazonaws.com"
}
},
]
})
}
data "aws_iam_policy_document" "s3_policy" {
statement {
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
actions = ["s3:*"]
resources = ["*"]
}
}
`,
}
var terraformNoPolicyWildcardsLinks = []string{
`https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document`,
}
var terraformNoPolicyWildcardsRemediationMarkdown = ``