You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,8 @@ The principal used to execute the tool requires the following permissions.
42
42
"Action": [
43
43
"access-analyzer:ValidatePolicy",
44
44
"access-analyzer:CheckNoNewAccess",
45
-
"access-analyzer:CheckAccessNotGranted"
45
+
"access-analyzer:CheckAccessNotGranted",
46
+
"access-analyzer:CheckNoPublicAccess"
46
47
],
47
48
"Resource": "*"
48
49
}
@@ -54,6 +55,7 @@ The principal used to execute the tool requires the following permissions.
54
55
| access-analyzer:ValidatePolicy| Called for each policy to validate against IAM policy best practices. |
55
56
| access-analyzer:CheckNoNewAccess| Called for each policy to validate against a reference policy to compare permissions. |
56
57
| access-analyzer:CheckAccessNotGranted| Called for each policy to validate that it does not grant access to a list of IAM actions, considered as critical permissions, provided as input. |
58
+
| access-analyzer:CheckNoPublicAccess| Called for each policy to validate that it does not grant public access to supported resource types. |
57
59
58
60
59
61
### Basic usage
@@ -103,7 +105,27 @@ Parses IAM identity-based and resource-based policies from Terraform templates.
Parses IAM identity-based and resource-based policies from Terraform templates. Then runs the policies through IAM Access Analyzer for a custom check against a list of IAM actions. Returns the findings from the custom check in JSON format. Exits with a non-zero error code if any findings categorized as blocking, based on access granted to at least one of the listed IAM actions, are found in your template. Exits with an error code of zero if all findings are non-blocking or there are no findings.
108
+
Parses IAM identity-based and resource-based policies from AWS Terraform templates. Then runs the policies through IAM Access Analyzer for a custom check against a list of IAM actions and/or resource ARNs. If both actions and resources are provided, a custom check will be run to determine whether access is granted to allow the specified actions on the specified resources. Returns the findings from the custom check in JSON format. Exits with a non-zero error code if any findings categorized as blocking, based on access granted to at least one of the listed IAM actions and/or resources, are found in your template. Exits with an error code of zero if all findings are non-blocking or there are no findings.
109
+
110
+
| Arguments | Required | Options | Description |
111
+
| --------- | ----- | ---------| ----------- |
112
+
| --help ||| show this help message and exit |
113
+
| --template-path || FILE_NAME | The path to the Terraform plan file (JSON). |
114
+
| --region | Yes | REGION | The destination region the resources will be deployed to. |
115
+
| --profile || PROFILE | The named profile to use for AWS API calls. |
116
+
| --enable-logging ||| Enables log output to stdout |
117
+
| --ignore-finding || FINDING_CODE,RESOURCE_NAME,RESOURCE_NAME.FINDING_CODE | Allow validation failures to be ignored. Specify as a comma separated list of findings to be ignored. Can be individual finding codes (e.g. "PASS_ROLE_WITH_STAR_IN_RESOURCE"), a specific resource name (e.g. "MyResource"), or a combination of both separated by a period.(e.g. "MyResource.PASS_ROLE_WITH_STAR_IN_RESOURCE"). Names of finding codes may change in IAM Access Analyzer over time. |
118
+
| --actions | At least one of actions or resources is required. | ACTION,ACTION,ACTION | List of comma-separated actions. |
119
+
| --resources | At least one of actions or resources is required. | RESOURCE,RESOURCE,RESOURCE | List of comma-separated resource ARNs, maximum 100 resource ARNs.
120
+
| --treat-findings-as-non-blocking ||| When not specified, the tool detects any findings, it will exit with a non-zero exit code. When specified, the tool exits with an exit code of 0. |
121
+
| --exclude-resource-types || aws_resource_type, aws_resource_type | List of comma-separated resource types. Resource types should be the same as terraform template resource names such as aws_iam_group_policy, aws_iam_role |
122
+
| --config |Yes | FILE_NAME1, FILE_NAME2, ... | A list of config files for running this script |
Parses resource-based policies from Terraform templates. Then runs the policies through IAM Access Analyzer for a custom check for public access to resources. Returns the findings from the custom check in JSON format. Exits with a non-zero error code if any findings categorized as blocking, based on whether public access is granted to at least one of the resources, are found in your template. Exits with an error code of zero if all findings are non-blocking or there are no findings.
107
129
108
130
| Arguments | Required | Options | Description |
109
131
| --------- | -------- | ---------| ----------- |
@@ -113,11 +135,24 @@ Parses IAM identity-based and resource-based policies from Terraform templates.
113
135
| --profile || PROFILE | The named profile to use for AWS API calls. |
114
136
| --enable-logging ||| Enables log output to stdout |
115
137
| --ignore-finding || FINDING_CODE, RESOURCE_NAME, RESOURCE_NAME.FINDING_CODE | Allow validation failures to be ignored. Specify as a comma separated list of findings to be ignored. Can be individual finding codes (e.g. "PASS_ROLE_WITH_STAR_IN_RESOURCE"), a specific resource name (e.g. "MyResource"), or a combination of both separated by a period.(e.g. "MyResource.PASS_ROLE_WITH_STAR_IN_RESOURCE"). Names of finding codes may change in IAM Access Analyzer over time. |
116
-
| --actions | Yes | ACTION,ACTION,ACTION | List of comma-separated actions. |
117
138
| --treat-findings-as-non-blocking ||| When not specified, the tool detects any findings, it will exit with a non-zero exit code. When specified, the tool exits with an exit code of 0. |
118
139
| --exclude-resource-types || aws_resource_type, aws_resource_type | List of comma-separated resource types. Resource types should be the same as terraform template resource names such as aws_iam_group_policy, aws_iam_role |
119
140
| --config |Yes | FILE_NAME1, FILE_NAME2, ... | A list of config files for running this script |
120
141
142
+
Resource-based policies that can be checked with `check-no-public-access` are limited to the resource types currently supported by IAM Policy Validator for Terraform. The following resource types are supported:
143
+
- AWS::EFS::FileSystem
144
+
- AWS::OpenSearchService::Domain
145
+
- AWS::KMS::Key
146
+
- AWS::S3::Bucket
147
+
- AWS::S3::AccessPoint
148
+
- AWS::S3::Glacier
149
+
- AWS::S3Outposts::Bucket
150
+
- AWS::SecretsManager::Secret
151
+
- AWS::SNS::Topic
152
+
- AWS::SQS::Queue
153
+
- Role trust policies (AWS::IAM::AssumeRolePolicyDocument)
154
+
155
+
121
156
### Example to check Terraform template
122
157
```
123
158
$ cd iam_check/test/
@@ -128,6 +163,7 @@ $ cd ../..
128
163
$ tf-policy-validator --config iam_check/config/default.yaml --template-path iam_check/test/tf.json --region us-east-1 --treat-finding-type-as-blocking ERROR # For TF 0.12 and prior, replace tf.json with tf.out
check_access_parser=subparsers.add_parser('check-access-not-granted', help='Parses IAM identity-based and resource-based policies from AWS Terraform templates '
135
-
'and runs them through IAM Access Analyzer to check that access to a list of actions is not granted. Returns the response '
136
-
'in JSON format.', parents=[parent_parser])
142
+
check_access_parser=subparsers.add_parser('check-access-not-granted', help='Parses IAM identity-based and resource-based policies from AWS CloudFormation '
143
+
'templates and runs them through IAM Access Analyzer to check that access to a list of actions and/or '
144
+
'resources is not granted. Returns the response in JSON format.', parents=[parent_parser])
help='If set, all findings will be treated as non-blocking',
152
169
default=True, action='store_false')
170
+
#check-no-public-access command
171
+
check_no_public_access_parser=subparsers.add_parser('check-no-public-access', help='Parses resource-based policies from AWS Terraform templates and runs them through '
172
+
'IAM Access Analyzer to check that public access to resources of supported types is not granted. Returns the response '
0 commit comments