diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 04755f4..bd50db9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,7 +6,7 @@ on: workflow_dispatch: env: - TRIVY_VERSION: 0.56.1 + TRIVY_VERSION: 0.57.1 BATS_LIB_PATH: '/usr/lib/' jobs: diff --git a/README.md b/README.md index 59442f8..8b8c988 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ jobs: uses: aquasecurity/setup-trivy@v0.2.0 with: cache: true - version: v0.56.1 + version: v0.57.1 - name: Run Trivy vulnerability scanner in repo mode uses: aquasecurity/trivy-action@master diff --git a/action.yaml b/action.yaml index b42ab4d..14588de 100644 --- a/action.yaml +++ b/action.yaml @@ -98,7 +98,7 @@ inputs: version: description: 'Trivy version to use' required: false - default: 'v0.56.1' + default: 'v0.57.1' cache: description: 'Used to specify whether caching is needed. Set to false, if you would like to disable caching.' required: false diff --git a/test/data/config-sarif-report/report.sarif b/test/data/config-sarif-report/report.sarif index 152d3e4..db8444c 100644 --- a/test/data/config-sarif-report/report.sarif +++ b/test/data/config-sarif-report/report.sarif @@ -10,7 +10,88 @@ "name": "Trivy", "rules": [ { - "id": "AVD-AWS-0089", + "id": "AVD-AWS-0086", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Access block should block public ACL" + }, + "fullDescription": { + "text": "S3 buckets should block public ACLs on buckets and any objects they contain. By blocking, PUTs with fail if the object has any public ACL a.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0086", + "help": { + "text": "Misconfiguration AVD-AWS-0086\nType: Terraform Security Check\nSeverity: HIGH\nCheck: S3 Access block should block public ACL\nMessage: No public access block so not blocking public acls\nLink: [AVD-AWS-0086](https://avd.aquasec.com/misconfig/avd-aws-0086)\nS3 buckets should block public ACLs on buckets and any objects they contain. By blocking, PUTs with fail if the object has any public ACL a.\n", + "markdown": "**Misconfiguration AVD-AWS-0086**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|S3 Access block should block public ACL|No public access block so not blocking public acls|[AVD-AWS-0086](https://avd.aquasec.com/misconfig/avd-aws-0086)|\n\nS3 buckets should block public ACLs on buckets and any objects they contain. By blocking, PUTs with fail if the object has any public ACL a.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "AVD-AWS-0087", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Access block should block public policy" + }, + "fullDescription": { + "text": "S3 bucket policy should have block public policy to prevent users from putting a policy that enable public access.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0087", + "help": { + "text": "Misconfiguration AVD-AWS-0087\nType: Terraform Security Check\nSeverity: HIGH\nCheck: S3 Access block should block public policy\nMessage: No public access block so not blocking public policies\nLink: [AVD-AWS-0087](https://avd.aquasec.com/misconfig/avd-aws-0087)\nS3 bucket policy should have block public policy to prevent users from putting a policy that enable public access.\n", + "markdown": "**Misconfiguration AVD-AWS-0087**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|S3 Access block should block public policy|No public access block so not blocking public policies|[AVD-AWS-0087](https://avd.aquasec.com/misconfig/avd-aws-0087)|\n\nS3 bucket policy should have block public policy to prevent users from putting a policy that enable public access.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "AVD-AWS-0088", + "name": "Misconfiguration", + "shortDescription": { + "text": "Unencrypted S3 bucket." + }, + "fullDescription": { + "text": "S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0088", + "help": { + "text": "Misconfiguration AVD-AWS-0088\nType: Terraform Security Check\nSeverity: HIGH\nCheck: Unencrypted S3 bucket.\nMessage: Bucket does not have encryption enabled\nLink: [AVD-AWS-0088](https://avd.aquasec.com/misconfig/avd-aws-0088)\nS3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.\n", + "markdown": "**Misconfiguration AVD-AWS-0088**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|Unencrypted S3 bucket.|Bucket does not have encryption enabled|[AVD-AWS-0088](https://avd.aquasec.com/misconfig/avd-aws-0088)|\n\nS3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "s3-bucket-logging", "name": "Misconfiguration", "shortDescription": { "text": "S3 Bucket Logging" @@ -21,10 +102,10 @@ "defaultConfiguration": { "level": "note" }, - "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0089", + "helpUri": "https://avd.aquasec.com/misconfig/s3-bucket-logging", "help": { - "text": "Misconfiguration AVD-AWS-0089\nType: Terraform Security Check\nSeverity: LOW\nCheck: S3 Bucket Logging\nMessage: Bucket has logging disabled\nLink: [AVD-AWS-0089](https://avd.aquasec.com/misconfig/avd-aws-0089)\nEnsures S3 bucket logging is enabled for S3 buckets", - "markdown": "**Misconfiguration AVD-AWS-0089**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|LOW|S3 Bucket Logging|Bucket has logging disabled|[AVD-AWS-0089](https://avd.aquasec.com/misconfig/avd-aws-0089)|\n\nEnsures S3 bucket logging is enabled for S3 buckets" + "text": "Misconfiguration s3-bucket-logging\nType: Terraform Security Check\nSeverity: LOW\nCheck: S3 Bucket Logging\nMessage: Bucket has logging disabled\nLink: [s3-bucket-logging](https://avd.aquasec.com/misconfig/s3-bucket-logging)\nEnsures S3 bucket logging is enabled for S3 buckets", + "markdown": "**Misconfiguration s3-bucket-logging**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|LOW|S3 Bucket Logging|Bucket has logging disabled|[s3-bucket-logging](https://avd.aquasec.com/misconfig/s3-bucket-logging)|\n\nEnsures S3 bucket logging is enabled for S3 buckets" }, "properties": { "precision": "very-high", @@ -35,17 +116,368 @@ "LOW" ] } + }, + { + "id": "AVD-AWS-0090", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Data should be versioned" + }, + "fullDescription": { + "text": "Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket.\n\nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.\n\nWith versioning you can recover more easily from both unintended user actions and application failures.\n" + }, + "defaultConfiguration": { + "level": "warning" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0090", + "help": { + "text": "Misconfiguration AVD-AWS-0090\nType: Terraform Security Check\nSeverity: MEDIUM\nCheck: S3 Data should be versioned\nMessage: Bucket does not have versioning enabled\nLink: [AVD-AWS-0090](https://avd.aquasec.com/misconfig/avd-aws-0090)\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket.\n\nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.\n\nWith versioning you can recover more easily from both unintended user actions and application failures.\n", + "markdown": "**Misconfiguration AVD-AWS-0090**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|MEDIUM|S3 Data should be versioned|Bucket does not have versioning enabled|[AVD-AWS-0090](https://avd.aquasec.com/misconfig/avd-aws-0090)|\n\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket.\n\nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.\n\nWith versioning you can recover more easily from both unintended user actions and application failures.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "5.5", + "tags": [ + "misconfiguration", + "security", + "MEDIUM" + ] + } + }, + { + "id": "AVD-AWS-0091", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Access Block should Ignore Public Acl" + }, + "fullDescription": { + "text": "S3 buckets should ignore public ACLs on buckets and any objects they contain. By ignoring rather than blocking, PUT calls with public ACLs will still be applied but the ACL will be ignored.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0091", + "help": { + "text": "Misconfiguration AVD-AWS-0091\nType: Terraform Security Check\nSeverity: HIGH\nCheck: S3 Access Block should Ignore Public Acl\nMessage: No public access block so not blocking public acls\nLink: [AVD-AWS-0091](https://avd.aquasec.com/misconfig/avd-aws-0091)\nS3 buckets should ignore public ACLs on buckets and any objects they contain. By ignoring rather than blocking, PUT calls with public ACLs will still be applied but the ACL will be ignored.\n", + "markdown": "**Misconfiguration AVD-AWS-0091**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|S3 Access Block should Ignore Public Acl|No public access block so not blocking public acls|[AVD-AWS-0091](https://avd.aquasec.com/misconfig/avd-aws-0091)|\n\nS3 buckets should ignore public ACLs on buckets and any objects they contain. By ignoring rather than blocking, PUT calls with public ACLs will still be applied but the ACL will be ignored.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "AVD-AWS-0093", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Access block should restrict public bucket to limit access" + }, + "fullDescription": { + "text": "S3 buckets should restrict public policies for the bucket. By enabling, the restrict_public_buckets, only the bucket owner and AWS Services can access if it has a public policy.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0093", + "help": { + "text": "Misconfiguration AVD-AWS-0093\nType: Terraform Security Check\nSeverity: HIGH\nCheck: S3 Access block should restrict public bucket to limit access\nMessage: No public access block so not restricting public buckets\nLink: [AVD-AWS-0093](https://avd.aquasec.com/misconfig/avd-aws-0093)\nS3 buckets should restrict public policies for the bucket. By enabling, the restrict_public_buckets, only the bucket owner and AWS Services can access if it has a public policy.\n", + "markdown": "**Misconfiguration AVD-AWS-0093**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|S3 Access block should restrict public bucket to limit access|No public access block so not restricting public buckets|[AVD-AWS-0093](https://avd.aquasec.com/misconfig/avd-aws-0093)|\n\nS3 buckets should restrict public policies for the bucket. By enabling, the restrict_public_buckets, only the bucket owner and AWS Services can access if it has a public policy.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "AVD-AWS-0094", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 buckets should each define an aws_s3_bucket_public_access_block" + }, + "fullDescription": { + "text": "The "block public access" settings in S3 override individual policies that apply to a given bucket, meaning that all public access can be controlled in one central types for that bucket. It is therefore good practice to define these settings for each bucket in order to clearly define the public access that can be allowed for it.\n" + }, + "defaultConfiguration": { + "level": "note" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0094", + "help": { + "text": "Misconfiguration AVD-AWS-0094\nType: Terraform Security Check\nSeverity: LOW\nCheck: S3 buckets should each define an aws_s3_bucket_public_access_block\nMessage: Bucket does not have a corresponding public access block.\nLink: [AVD-AWS-0094](https://avd.aquasec.com/misconfig/avd-aws-0094)\nThe \"block public access\" settings in S3 override individual policies that apply to a given bucket, meaning that all public access can be controlled in one central types for that bucket. It is therefore good practice to define these settings for each bucket in order to clearly define the public access that can be allowed for it.\n", + "markdown": "**Misconfiguration AVD-AWS-0094**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|LOW|S3 buckets should each define an aws_s3_bucket_public_access_block|Bucket does not have a corresponding public access block.|[AVD-AWS-0094](https://avd.aquasec.com/misconfig/avd-aws-0094)|\n\nThe \"block public access\" settings in S3 override individual policies that apply to a given bucket, meaning that all public access can be controlled in one central types for that bucket. It is therefore good practice to define these settings for each bucket in order to clearly define the public access that can be allowed for it.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "2.0", + "tags": [ + "misconfiguration", + "security", + "LOW" + ] + } + }, + { + "id": "AVD-AWS-0132", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 encryption should use Customer Managed Keys" + }, + "fullDescription": { + "text": "Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.\n" + }, + "defaultConfiguration": { + "level": "error" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0132", + "help": { + "text": "Misconfiguration AVD-AWS-0132\nType: Terraform Security Check\nSeverity: HIGH\nCheck: S3 encryption should use Customer Managed Keys\nMessage: Bucket does not encrypt data with a customer managed key.\nLink: [AVD-AWS-0132](https://avd.aquasec.com/misconfig/avd-aws-0132)\nEncryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.\n", + "markdown": "**Misconfiguration AVD-AWS-0132**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Terraform Security Check|HIGH|S3 encryption should use Customer Managed Keys|Bucket does not encrypt data with a customer managed key.|[AVD-AWS-0132](https://avd.aquasec.com/misconfig/avd-aws-0132)|\n\nEncryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.\n" + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } } ] } }, "results": [ { - "ruleId": "AVD-AWS-0089", + "ruleId": "AVD-AWS-0086", "ruleIndex": 0, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0086\nSeverity: HIGH\nMessage: No public access block so not blocking public acls\nLink: [AVD-AWS-0086](https://avd.aquasec.com/misconfig/avd-aws-0086)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0087", + "ruleIndex": 1, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0087\nSeverity: HIGH\nMessage: No public access block so not blocking public policies\nLink: [AVD-AWS-0087](https://avd.aquasec.com/misconfig/avd-aws-0087)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0088", + "ruleIndex": 2, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0088\nSeverity: HIGH\nMessage: Bucket does not have encryption enabled\nLink: [AVD-AWS-0088](https://avd.aquasec.com/misconfig/avd-aws-0088)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "s3-bucket-logging", + "ruleIndex": 3, "level": "note", "message": { - "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0089\nSeverity: LOW\nMessage: Bucket has logging disabled\nLink: [AVD-AWS-0089](https://avd.aquasec.com/misconfig/avd-aws-0089)" + "text": "Artifact: main.tf\nType: terraform\nVulnerability s3-bucket-logging\nSeverity: LOW\nMessage: Bucket has logging disabled\nLink: [s3-bucket-logging](https://avd.aquasec.com/misconfig/s3-bucket-logging)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0090", + "ruleIndex": 4, + "level": "warning", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0090\nSeverity: MEDIUM\nMessage: Bucket does not have versioning enabled\nLink: [AVD-AWS-0090](https://avd.aquasec.com/misconfig/avd-aws-0090)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 16, + "startColumn": 1, + "endLine": 16, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0091", + "ruleIndex": 5, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0091\nSeverity: HIGH\nMessage: No public access block so not blocking public acls\nLink: [AVD-AWS-0091](https://avd.aquasec.com/misconfig/avd-aws-0091)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0093", + "ruleIndex": 6, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0093\nSeverity: HIGH\nMessage: No public access block so not restricting public buckets\nLink: [AVD-AWS-0093](https://avd.aquasec.com/misconfig/avd-aws-0093)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0094", + "ruleIndex": 7, + "level": "note", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0094\nSeverity: LOW\nMessage: Bucket does not have a corresponding public access block.\nLink: [AVD-AWS-0094](https://avd.aquasec.com/misconfig/avd-aws-0094)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0132", + "ruleIndex": 8, + "level": "error", + "message": { + "text": "Artifact: main.tf\nType: terraform\nVulnerability AVD-AWS-0132\nSeverity: HIGH\nMessage: Bucket does not encrypt data with a customer managed key.\nLink: [AVD-AWS-0132](https://avd.aquasec.com/misconfig/avd-aws-0132)" }, "locations": [ { diff --git a/test/data/config-scan/report.json b/test/data/config-scan/report.json index 9cea638..7501a22 100644 --- a/test/data/config-scan/report.json +++ b/test/data/config-scan/report.json @@ -20,9 +20,8 @@ "Class": "config", "Type": "terraform", "MisconfSummary": { - "Successes": 2, - "Failures": 0, - "Exceptions": 0 + "Successes": 38, + "Failures": 0 } }, { @@ -31,13 +30,192 @@ "Type": "terraform", "MisconfSummary": { "Successes": 0, - "Failures": 1, - "Exceptions": 0 + "Failures": 9 }, "Misconfigurations": [ { "Type": "Terraform Security Check", - "ID": "AVD-AWS-0089", + "ID": "AVD-AWS-0086", + "AVDID": "AVD-AWS-0086", + "Title": "S3 Access block should block public ACL", + "Description": "S3 buckets should block public ACLs on buckets and any objects they contain. By blocking, PUTs with fail if the object has any public ACL a.\n", + "Message": "No public access block so not blocking public acls", + "Namespace": "builtin.aws.s3.aws0086", + "Query": "data.builtin.aws.s3.aws0086.deny", + "Resolution": "Enable blocking any PUT calls with a public ACL specified", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0086", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", + "https://avd.aquasec.com/misconfig/avd-aws-0086" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0087", + "AVDID": "AVD-AWS-0087", + "Title": "S3 Access block should block public policy", + "Description": "S3 bucket policy should have block public policy to prevent users from putting a policy that enable public access.\n", + "Message": "No public access block so not blocking public policies", + "Namespace": "builtin.aws.s3.aws0087", + "Query": "data.builtin.aws.s3.aws0087.deny", + "Resolution": "Prevent policies that allow public access being PUT", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0087", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/dev-retired/access-control-block-public-access.html", + "https://avd.aquasec.com/misconfig/avd-aws-0087" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0088", + "AVDID": "AVD-AWS-0088", + "Title": "Unencrypted S3 bucket.", + "Description": "S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.\n", + "Message": "Bucket does not have encryption enabled", + "Namespace": "builtin.aws.s3.aws0088", + "Query": "data.builtin.aws.s3.aws0088.deny", + "Resolution": "Configure bucket encryption", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0088", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html", + "https://avd.aquasec.com/misconfig/avd-aws-0088" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "s3-bucket-logging", "AVDID": "AVD-AWS-0089", "Title": "S3 Bucket Logging", "Description": "Ensures S3 bucket logging is enabled for S3 buckets", @@ -46,10 +224,368 @@ "Query": "data.builtin.aws.s3.aws0089.deny", "Resolution": "Add a logging block to the resource to enable access logging", "Severity": "LOW", - "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0089", + "PrimaryURL": "https://avd.aquasec.com/misconfig/s3-bucket-logging", "References": [ "https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html", - "https://avd.aquasec.com/misconfig/avd-aws-0089" + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html", + "https://avd.aquasec.com/misconfig/s3-bucket-logging" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0090", + "AVDID": "AVD-AWS-0090", + "Title": "S3 Data should be versioned", + "Description": "Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket.\n\nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.\n\nWith versioning you can recover more easily from both unintended user actions and application failures.\n", + "Message": "Bucket does not have versioning enabled", + "Namespace": "builtin.aws.s3.aws0090", + "Query": "data.builtin.aws.s3.aws0090.deny", + "Resolution": "Enable versioning to protect against accidental/malicious removal or modification", + "Severity": "MEDIUM", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0090", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html", + "https://avd.aquasec.com/misconfig/avd-aws-0090" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket_versioning.bucket_versioning", + "Provider": "AWS", + "Service": "s3", + "StartLine": 16, + "EndLine": 16, + "Code": { + "Lines": [ + { + "Number": 12, + "Content": "resource \"aws_s3_bucket_versioning\" \"bucket_versioning\" {", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket_versioning\"\u001b[0m \u001b[38;5;37m\"bucket_versioning\"\u001b[0m {", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 13, + "Content": " bucket = aws_s3_bucket.bucket.id", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = aws_s3_bucket.bucket.id", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 14, + "Content": "", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 15, + "Content": " versioning_configuration {", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "Highlighted": " versioning_configuration {", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 16, + "Content": " status = var.bucket_versioning_enabled", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mstatus\u001b[0m = \u001b[38;5;33mvar\u001b[0m.bucket_versioning_enabled", + "FirstCause": true, + "LastCause": true + }, + { + "Number": 17, + "Content": " }", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "Highlighted": " }", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 18, + "Content": "}", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "Highlighted": "}", + "FirstCause": false, + "LastCause": false + } + ] + }, + "Occurrences": [ + { + "Resource": "versioning_configuration", + "Filename": "main.tf", + "Location": { + "StartLine": 15, + "EndLine": 17 + } + }, + { + "Resource": "aws_s3_bucket_versioning.bucket_versioning", + "Filename": "main.tf", + "Location": { + "StartLine": 12, + "EndLine": 18 + } + } + ] + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0091", + "AVDID": "AVD-AWS-0091", + "Title": "S3 Access Block should Ignore Public Acl", + "Description": "S3 buckets should ignore public ACLs on buckets and any objects they contain. By ignoring rather than blocking, PUT calls with public ACLs will still be applied but the ACL will be ignored.\n", + "Message": "No public access block so not blocking public acls", + "Namespace": "builtin.aws.s3.aws0091", + "Query": "data.builtin.aws.s3.aws0091.deny", + "Resolution": "Enable ignoring the application of public ACLs in PUT calls", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0091", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", + "https://avd.aquasec.com/misconfig/avd-aws-0091" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0093", + "AVDID": "AVD-AWS-0093", + "Title": "S3 Access block should restrict public bucket to limit access", + "Description": "S3 buckets should restrict public policies for the bucket. By enabling, the restrict_public_buckets, only the bucket owner and AWS Services can access if it has a public policy.\n", + "Message": "No public access block so not restricting public buckets", + "Namespace": "builtin.aws.s3.aws0093", + "Query": "data.builtin.aws.s3.aws0093.deny", + "Resolution": "Limit the access to public buckets to only the owner or AWS Services (eg; CloudFront)", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0093", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/dev-retired/access-control-block-public-access.html", + "https://avd.aquasec.com/misconfig/avd-aws-0093" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0094", + "AVDID": "AVD-AWS-0094", + "Title": "S3 buckets should each define an aws_s3_bucket_public_access_block", + "Description": "The \"block public access\" settings in S3 override individual policies that apply to a given bucket, meaning that all public access can be controlled in one central types for that bucket. It is therefore good practice to define these settings for each bucket in order to clearly define the public access that can be allowed for it.\n", + "Message": "Bucket does not have a corresponding public access block.", + "Namespace": "builtin.aws.s3.aws0094", + "Query": "data.builtin.aws.s3.aws0094.deny", + "Resolution": "Define a aws_s3_bucket_public_access_block for the given bucket to control public access policies", + "Severity": "LOW", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0094", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html", + "https://avd.aquasec.com/misconfig/avd-aws-0094" + ], + "Status": "FAIL", + "Layer": {}, + "CauseMetadata": { + "Resource": "aws_s3_bucket.bucket", + "Provider": "AWS", + "Service": "s3", + "StartLine": 8, + "EndLine": 10, + "Code": { + "Lines": [ + { + "Number": 8, + "Content": "resource \"aws_s3_bucket\" \"bucket\" {", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket\"\u001b[0m \u001b[38;5;37m\"bucket\"\u001b[0m {", + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": " \u001b[38;5;245mbucket\u001b[0m = \u001b[38;5;37m\"trivy-action-bucket\"", + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "Highlighted": "\u001b[0m}", + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0132", + "AVDID": "AVD-AWS-0132", + "Title": "S3 encryption should use Customer Managed Keys", + "Description": "Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.\n", + "Message": "Bucket does not encrypt data with a customer managed key.", + "Namespace": "builtin.aws.s3.aws0132", + "Query": "data.builtin.aws.s3.aws0132.deny", + "Resolution": "Enable encryption using customer managed keys", + "Severity": "HIGH", + "PrimaryURL": "https://avd.aquasec.com/misconfig/avd-aws-0132", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html", + "https://avd.aquasec.com/misconfig/avd-aws-0132" ], "Status": "FAIL", "Layer": {}, diff --git a/test/data/with-tf-vars/report.json b/test/data/with-tf-vars/report.json index 981200e..9a187ce 100644 --- a/test/data/with-tf-vars/report.json +++ b/test/data/with-tf-vars/report.json @@ -20,9 +20,8 @@ "Class": "config", "Type": "terraform", "MisconfSummary": { - "Successes": 2, - "Failures": 0, - "Exceptions": 0 + "Successes": 19, + "Failures": 0 } }, {