From c209be0954c2a25dc62fba82e467a999a3153acf Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Wed, 22 Nov 2023 13:32:44 +0000 Subject: [PATCH 01/11] Action now takes an input for terraform variable filess --- action.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yaml b/action.yaml index 3e37c9b..c6f457a 100644 --- a/action.yaml +++ b/action.yaml @@ -88,6 +88,9 @@ inputs: trivy-config: description: 'path to trivy.yaml config' required: false + tf-vars: + description: "path to terraform tfvars file" + required: false limit-severities-for-sarif: description: 'limit severities for SARIF format' required: false @@ -118,4 +121,6 @@ runs: - '-t ${{ inputs.trivyignores }}' - '-u ${{ inputs.github-pat }}' - '-v ${{ inputs.trivy-config }}' + - '-x ${{ inputs.tf-vars }}' - '-z ${{ inputs.limit-severities-for-sarif }}' + \ No newline at end of file From 946c0d2cd74ef082c775108ef512326603f79834 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Wed, 22 Nov 2023 13:34:06 +0000 Subject: [PATCH 02/11] added tf-vars --- entrypoint.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 22befad..8d3563d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:" o; do +while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:x:z:" o; do case "${o}" in a) export scanType=${OPTARG} @@ -68,6 +68,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:" o; do v) export trivyConfig=${OPTARG} ;; + x) + export tfVars=${OPTARG} + ;; z) export limitSeveritiesForSARIF=${OPTARG} ;; @@ -132,6 +135,10 @@ if [ $skipDirs ];then SARIF_ARGS="$SARIF_ARGS --skip-dirs $i" done fi +if [ $tfVars ] && [ "$scanType" == "config" ];then + ARGS="$ARGS --tf-vars $tfVars" +fi + if [ $trivyIgnores ];then for f in $(echo $trivyIgnores | tr "," "\n") do From 7740181b02dc138867f3bac7b8da6d74c076bd8d Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Wed, 22 Nov 2023 14:46:50 +0000 Subject: [PATCH 03/11] updated README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eba39ff..69cc0c0 100644 --- a/README.md +++ b/README.md @@ -491,6 +491,7 @@ Following inputs can be used as `step.with` keys: | `scan-ref` | String | `/github/workspace/` | Scan reference, e.g. `/github/workspace/` or `.` | | `format` | String | `table` | Output format (`table`, `json`, `sarif`, `github`) | | `template` | String | | Output template (`@/contrib/gitlab.tpl`, `@/contrib/junit.tpl`) | +| `tf-vars` | String | | path to Terraform variables file | | `output` | String | | Save results to a file | | `exit-code` | String | `0` | Exit code when specified vulnerabilities are found | | `ignore-unfixed` | Boolean | false | Ignore unpatched/unfixed vulnerabilities | From 4a6c477e331316fcaf707caf9beece38d8c6d42e Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 11:13:40 +0000 Subject: [PATCH 04/11] Updated yamlconfig test to latest version of trivy output for that container --- test/data/yamlconfig.test | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/data/yamlconfig.test b/test/data/yamlconfig.test index b34ab8a..0c00544 100644 --- a/test/data/yamlconfig.test +++ b/test/data/yamlconfig.test @@ -8,9 +8,9 @@ "Name": "3.10.9", "EOSL": true }, - "ImageID": "sha256:e7b300aee9f9bf3433d32bc9305bfdd22183beb59d933b48d77ab56ba53a197a", + "ImageID": "sha256:19a85ffa0ee14b7c64ca5104dc4e1c5021fa04bd6b4a692074691ce154f5d074", "DiffIDs": [ - "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" + "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" ], "RepoTags": [ "alpine:3.10" @@ -19,17 +19,17 @@ "alpine@sha256:451eee8bedcb2f029756dc3e9d73bab0e7943c1ac55cff3a4861c52a0fdd3e98" ], "ImageConfig": { - "architecture": "amd64", - "container": "fdb7e80e3339e8d0599282e606c907aa5881ee4c668a68136119e6dfac6ce3a4", - "created": "2021-04-14T19:20:05.338397761Z", + "architecture": "arm64", + "container": "a4d75c1d7a32e4ce20815a25661aa959ae11ee98b9f1db61e1d91b3f652c9dbe", + "created": "2021-04-14T18:43:17.827903143Z", "docker_version": "19.03.12", "history": [ { - "created": "2021-04-14T19:20:04.987219124Z", - "created_by": "/bin/sh -c #(nop) ADD file:c5377eaa926bf412dd8d4a08b0a1f2399cfd708743533b0aa03b53d14cb4bb4e in / " + "created": "2021-04-14T18:43:16Z", + "created_by": "/bin/sh -c #(nop) ADD file:85a5071af4733240679a3799298092cb671cae007156a367219b6edf6cfc6377 in / " }, { - "created": "2021-04-14T19:20:05.338397761Z", + "created": "2021-04-14T18:43:17Z", "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", "empty_layer": true } @@ -38,7 +38,7 @@ "rootfs": { "type": "layers", "diff_ids": [ - "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" + "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" ] }, "config": { @@ -48,7 +48,7 @@ "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], - "Image": "sha256:eb2080c455e94c22ae35b3aef9e078c492a00795412e026e4d6b41ef64bc7dd8" + "Image": "sha256:93dc876730ac144ef1bebf3afccf9f64b761da5bb57054b86fc391e6f2bbcbe8" } } }, @@ -66,8 +66,7 @@ "FixedVersion": "2.10.7-r0", "Status": "fixed", "Layer": { - "Digest": "sha256:396c31837116ac290458afcb928f68b6cc1c7bdd6963fc72f52f365a2a89c1b5", - "DiffID": "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" + "DiffID": "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" }, "SeveritySource": "nvd", "PrimaryURL": "https://avd.aquasec.com/nvd/cve-2021-36159", @@ -98,15 +97,15 @@ "https://access.redhat.com/security/cve/CVE-2021-36159", "https://github.com/freebsd/freebsd-src/commits/main/lib/libfetch", "https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10749", - "https://lists.apache.org/thread.html/r61db8e7dcb56dc000a5387a88f7a473bacec5ee01b9ff3f55308aacc@%3Cdev.kafka.apache.org%3E", - "https://lists.apache.org/thread.html/r61db8e7dcb56dc000a5387a88f7a473bacec5ee01b9ff3f55308aacc@%3Cusers.kafka.apache.org%3E", - "https://lists.apache.org/thread.html/rbf4ce74b0d1fa9810dec50ba3ace0caeea677af7c27a97111c06ccb7@%3Cdev.kafka.apache.org%3E", - "https://lists.apache.org/thread.html/rbf4ce74b0d1fa9810dec50ba3ace0caeea677af7c27a97111c06ccb7@%3Cusers.kafka.apache.org%3E", + "https://lists.apache.org/thread.html/r61db8e7dcb56dc000a5387a88f7a473bacec5ee01b9ff3f55308aacc%40%3Cdev.kafka.apache.org%3E", + "https://lists.apache.org/thread.html/r61db8e7dcb56dc000a5387a88f7a473bacec5ee01b9ff3f55308aacc%40%3Cusers.kafka.apache.org%3E", + "https://lists.apache.org/thread.html/rbf4ce74b0d1fa9810dec50ba3ace0caeea677af7c27a97111c06ccb7%40%3Cdev.kafka.apache.org%3E", + "https://lists.apache.org/thread.html/rbf4ce74b0d1fa9810dec50ba3ace0caeea677af7c27a97111c06ccb7%40%3Cusers.kafka.apache.org%3E", "https://nvd.nist.gov/vuln/detail/CVE-2021-36159", "https://www.cve.org/CVERecord?id=CVE-2021-36159" ], "PublishedDate": "2021-08-03T14:15:00Z", - "LastModifiedDate": "2021-10-18T12:19:00Z" + "LastModifiedDate": "2023-11-07T03:36:00Z" } ] } From 652da55d747557f4e2b4fd4d8ce9f89773224239 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 11:19:34 +0000 Subject: [PATCH 05/11] updated for correct cpu type --- test/data/yamlconfig.test | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/data/yamlconfig.test b/test/data/yamlconfig.test index 0c00544..f0208c7 100644 --- a/test/data/yamlconfig.test +++ b/test/data/yamlconfig.test @@ -8,28 +8,25 @@ "Name": "3.10.9", "EOSL": true }, - "ImageID": "sha256:19a85ffa0ee14b7c64ca5104dc4e1c5021fa04bd6b4a692074691ce154f5d074", + "ImageID": "sha256:e7b300aee9f9bf3433d32bc9305bfdd22183beb59d933b48d77ab56ba53a197a", "DiffIDs": [ - "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" + "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" ], "RepoTags": [ "alpine:3.10" ], - "RepoDigests": [ - "alpine@sha256:451eee8bedcb2f029756dc3e9d73bab0e7943c1ac55cff3a4861c52a0fdd3e98" - ], "ImageConfig": { - "architecture": "arm64", - "container": "a4d75c1d7a32e4ce20815a25661aa959ae11ee98b9f1db61e1d91b3f652c9dbe", - "created": "2021-04-14T18:43:17.827903143Z", + "architecture": "amd64", + "container": "fdb7e80e3339e8d0599282e606c907aa5881ee4c668a68136119e6dfac6ce3a4", + "created": "2021-04-14T19:20:05.338397761Z", "docker_version": "19.03.12", "history": [ { - "created": "2021-04-14T18:43:16Z", - "created_by": "/bin/sh -c #(nop) ADD file:85a5071af4733240679a3799298092cb671cae007156a367219b6edf6cfc6377 in / " + "created": "2021-04-14T19:20:04Z", + "created_by": "/bin/sh -c #(nop) ADD file:c5377eaa926bf412dd8d4a08b0a1f2399cfd708743533b0aa03b53d14cb4bb4e in / " }, { - "created": "2021-04-14T18:43:17Z", + "created": "2021-04-14T19:20:05Z", "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", "empty_layer": true } @@ -38,7 +35,7 @@ "rootfs": { "type": "layers", "diff_ids": [ - "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" + "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" ] }, "config": { @@ -48,7 +45,7 @@ "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], - "Image": "sha256:93dc876730ac144ef1bebf3afccf9f64b761da5bb57054b86fc391e6f2bbcbe8" + "Image": "sha256:eb2080c455e94c22ae35b3aef9e078c492a00795412e026e4d6b41ef64bc7dd8" } } }, @@ -66,7 +63,7 @@ "FixedVersion": "2.10.7-r0", "Status": "fixed", "Layer": { - "DiffID": "sha256:e484d53633e7e5ebaabbe277838af1f26c388cbcebfa32e29fae72dd4086d54d" + "DiffID": "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" }, "SeveritySource": "nvd", "PrimaryURL": "https://avd.aquasec.com/nvd/cve-2021-36159", From 2894ad8e2cfed904d49f383caa50b66255a27bc9 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 11:42:57 +0000 Subject: [PATCH 06/11] test trivy version change to 0.45.0 --- test/data/yamlconfig.test | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/data/yamlconfig.test b/test/data/yamlconfig.test index f0208c7..34806ac 100644 --- a/test/data/yamlconfig.test +++ b/test/data/yamlconfig.test @@ -15,6 +15,9 @@ "RepoTags": [ "alpine:3.10" ], + "RepoDigests": [ + "alpine@sha256:451eee8bedcb2f029756dc3e9d73bab0e7943c1ac55cff3a4861c52a0fdd3e98" + ], "ImageConfig": { "architecture": "amd64", "container": "fdb7e80e3339e8d0599282e606c907aa5881ee4c668a68136119e6dfac6ce3a4", @@ -22,11 +25,11 @@ "docker_version": "19.03.12", "history": [ { - "created": "2021-04-14T19:20:04Z", + "created": "2021-04-14T19:20:04.987219124Z", "created_by": "/bin/sh -c #(nop) ADD file:c5377eaa926bf412dd8d4a08b0a1f2399cfd708743533b0aa03b53d14cb4bb4e in / " }, { - "created": "2021-04-14T19:20:05Z", + "created": "2021-04-14T19:20:05.338397761Z", "created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]", "empty_layer": true } From 0d41d324334b02380e9ea42c8590f0c1eae34665 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 12:59:12 +0000 Subject: [PATCH 07/11] run scan with correct parameters --- test/data/yamlconfig.test | 1 + 1 file changed, 1 insertion(+) diff --git a/test/data/yamlconfig.test b/test/data/yamlconfig.test index 34806ac..d04683c 100644 --- a/test/data/yamlconfig.test +++ b/test/data/yamlconfig.test @@ -66,6 +66,7 @@ "FixedVersion": "2.10.7-r0", "Status": "fixed", "Layer": { + "Digest": "sha256:396c31837116ac290458afcb928f68b6cc1c7bdd6963fc72f52f365a2a89c1b5", "DiffID": "sha256:9fb3aa2f8b8023a4bebbf92aa567caf88e38e969ada9f0ac12643b2847391635" }, "SeveritySource": "nvd", From b3aba3a14a16f15f730131a7740a757582077bd8 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 16:31:56 +0000 Subject: [PATCH 08/11] Added test for terraform tfvars --- test/data/dev.tfvars | 2 ++ test/data/main.tf | 18 ++++++++++++++++ test/data/tfvars.test | 49 +++++++++++++++++++++++++++++++++++++++++++ test/test.bats | 10 ++++++++- 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 test/data/dev.tfvars create mode 100644 test/data/main.tf create mode 100644 test/data/tfvars.test diff --git a/test/data/dev.tfvars b/test/data/dev.tfvars new file mode 100644 index 0000000..6fc5f84 --- /dev/null +++ b/test/data/dev.tfvars @@ -0,0 +1,2 @@ +# test data for trivy config with terraform variables +bucket_versioning_enabled="Enabled" \ No newline at end of file diff --git a/test/data/main.tf b/test/data/main.tf new file mode 100644 index 0000000..85208bb --- /dev/null +++ b/test/data/main.tf @@ -0,0 +1,18 @@ +# test data for trivy config with terraform variables + +variable "bucket_versioning_enabled" { + type = string + default = "Disabled" +} + +resource "aws_s3_bucket" "bucket" { + bucket = "trivy-action-bucket" +} + +resource "aws_s3_bucket_versioning" "bucket_versioning" { + bucket = aws_s3_bucket.bucket.id + + versioning_configuration { + status = var.bucket_versioning_enabled + } +} \ No newline at end of file diff --git a/test/data/tfvars.test b/test/data/tfvars.test new file mode 100644 index 0000000..eed38dd --- /dev/null +++ b/test/data/tfvars.test @@ -0,0 +1,49 @@ +{ + "SchemaVersion": 2, + "ArtifactName": ".", + "ArtifactType": "filesystem", + "Metadata": { + "ImageConfig": { + "architecture": "", + "created": "0001-01-01T00:00:00Z", + "os": "", + "rootfs": { + "type": "", + "diff_ids": null + }, + "config": {} + } + }, + "Results": [ + { + "Target": "Dockerfile", + "Class": "config", + "Type": "dockerfile", + "MisconfSummary": { + "Successes": 4, + "Failures": 0, + "Exceptions": 0 + } + }, + { + "Target": "test/data", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 2, + "Failures": 0, + "Exceptions": 0 + } + }, + { + "Target": "test/data/main.tf", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 1, + "Failures": 0, + "Exceptions": 0 + } + } + ] +} diff --git a/test/test.bats b/test/test.bats index 13a69ce..7ebd15c 100644 --- a/test/test.bats +++ b/test/test.bats @@ -21,7 +21,7 @@ bats_load_library bats-file @test "trivy config sarif report" { # trivy config --format sarif --output config-sarif.test . - run ./entrypoint.sh '-a config' '-b sarif' '-h config-sarif.test' '-j .' + run ./entrypoint.sh '-a config' '-b sarif' '-h config-sarif.test' '-j .' '-q ./test/data/main.tf' run diff config-sarif.test ./test/data/config-sarif.test echo "$output" assert_files_equal config-sarif.test ./test/data/config-sarif.test @@ -81,3 +81,11 @@ bats_load_library bats-file echo "$output" assert_files_equal yamlconfig.test ./test/data/yamlconfig.test } + +@test "trivy config with terraform variables" { + # trivy config --format json --severity MEDIUM --output tfvars.test --tf-vars ./test/data/dev.tfvars ./test/data + run ./entrypoint.sh "-a config" "-j ./test/data" "-h tfvars.test" "-g MEDIUM" "-x ./test/data/dev.tfvars" "-b json" + run diff tfvars.test ./test/data/tfvars.test + echo "$output" + assert_files_equal tfvars.test ./test/data/tfvars.test +} \ No newline at end of file From 8ca9c30329c8daeb215cb264e9e8acdfea41a593 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 16:32:09 +0000 Subject: [PATCH 09/11] Updated output for other tests --- test/data/config-sarif.test | 486 ++++++++++++++++++++++++++++++ test/data/config.test | 581 ++++++++++++++++++++++++++++++++++++ test/data/fs-scheck.test | 581 ++++++++++++++++++++++++++++++++++++ 3 files changed, 1648 insertions(+) diff --git a/test/data/config-sarif.test b/test/data/config-sarif.test index 79500ae..a3ce247 100644 --- a/test/data/config-sarif.test +++ b/test/data/config-sarif.test @@ -62,6 +62,249 @@ "LOW" ] } + }, + { + "id": "AVD-AWS-0086", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Access block should block public ACL" + }, + "fullDescription": { + "text": "\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" + }, + "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)\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", + "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\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": "\nS3 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)\n\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\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." + }, + "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.", + "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." + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } + }, + { + "id": "AVD-AWS-0089", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Bucket Logging" + }, + "fullDescription": { + "text": "Ensures S3 bucket logging is enabled for S3 buckets" + }, + "defaultConfiguration": { + "level": "note" + }, + "helpUri": "https://avd.aquasec.com/misconfig/avd-aws-0089", + "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" + }, + "properties": { + "precision": "very-high", + "security-severity": "2.0", + "tags": [ + "misconfiguration", + "security", + "LOW" + ] + } + }, + { + "id": "AVD-AWS-0090", + "name": "Misconfiguration", + "shortDescription": { + "text": "S3 Data should be versioned" + }, + "fullDescription": { + "text": "\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. \nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. \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)\n\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. \nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. \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\n\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. \nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. \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": "\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" + }, + "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 ignoring public acls\nLink: [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", + "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 ignoring public acls|[AVD-AWS-0091](https://avd.aquasec.com/misconfig/avd-aws-0091)|\n\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." + }, + "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.", + "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." + }, + "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 \u0026#34;block public access\u0026#34; 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." + }, + "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.", + "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." + }, + "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." + }, + "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.", + "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." + }, + "properties": { + "precision": "very-high", + "security-severity": "8.0", + "tags": [ + "misconfiguration", + "security", + "HIGH" + ] + } } ], "version": "0.45.0" @@ -121,6 +364,249 @@ } } ] + }, + { + "ruleId": "AVD-AWS-0086", + "ruleIndex": 2, + "level": "error", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0087", + "ruleIndex": 3, + "level": "error", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0088", + "ruleIndex": 4, + "level": "error", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0089", + "ruleIndex": 5, + "level": "note", + "message": { + "text": "Artifact: test/data/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)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0090", + "ruleIndex": 6, + "level": "warning", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 16, + "startColumn": 1, + "endLine": 16, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0091", + "ruleIndex": 7, + "level": "error", + "message": { + "text": "Artifact: test/data/main.tf\nType: terraform\nVulnerability AVD-AWS-0091\nSeverity: HIGH\nMessage: No public access block so not ignoring public acls\nLink: [AVD-AWS-0091](https://avd.aquasec.com/misconfig/avd-aws-0091)" + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0093", + "ruleIndex": 8, + "level": "error", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0094", + "ruleIndex": 9, + "level": "note", + "message": { + "text": "Artifact: test/data/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": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] + }, + { + "ruleId": "AVD-AWS-0132", + "ruleIndex": 10, + "level": "error", + "message": { + "text": "Artifact: test/data/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": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "test/data/main.tf", + "uriBaseId": "ROOTPATH" + }, + "region": { + "startLine": 8, + "startColumn": 1, + "endLine": 10, + "endColumn": 1 + } + }, + "message": { + "text": "test/data/main.tf" + } + } + ] } ], "columnKind": "utf16CodeUnits", diff --git a/test/data/config.test b/test/data/config.test index bc7c357..33de38a 100644 --- a/test/data/config.test +++ b/test/data/config.test @@ -78,6 +78,587 @@ } } ] + }, + { + "Target": "test/data", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 2, + "Failures": 0, + "Exceptions": 0 + } + }, + { + "Target": "test/data/main.tf", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 1, + "Failures": 9, + "Exceptions": 0 + }, + "Misconfigurations": [ + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0086", + "AVDID": "AVD-AWS-0086", + "Title": "S3 Access block should block public ACL", + "Description": "\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", + "Message": "No public access block so not blocking public acls", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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": "\nS3 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", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not have encryption enabled", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0089", + "AVDID": "AVD-AWS-0089", + "Title": "S3 Bucket Logging", + "Description": "Ensures S3 bucket logging is enabled for S3 buckets", + "Message": "Bucket has logging disabled", + "Namespace": "builtin.aws.s3.aws0089", + "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", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html", + "https://avd.aquasec.com/misconfig/avd-aws-0089" + ], + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0090", + "AVDID": "AVD-AWS-0090", + "Title": "S3 Data should be versioned", + "Description": "\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. \nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. \nWith versioning you can recover more easily from both unintended user actions and application failures.\n", + "Message": "Bucket does not have versioning enabled", + "Query": "data..", + "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, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 13, + "Content": " bucket = aws_s3_bucket.bucket.id", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "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, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 16, + "Content": " status = var.bucket_versioning_enabled", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": true, + "LastCause": true + }, + { + "Number": 17, + "Content": " }", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 18, + "Content": "}", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + } + ] + }, + "Occurrences": [ + { + "Resource": "versioning_configuration", + "Filename": "test/data/main.tf", + "Location": { + "StartLine": 15, + "EndLine": 17 + } + }, + { + "Resource": "aws_s3_bucket_versioning.bucket_versioning", + "Filename": "test/data/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": "\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", + "Message": "No public access block so not ignoring public acls", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "No public access block so not restricting public buckets", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not have a corresponding public access block.", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not encrypt data with a customer managed key.", + "Query": "data..", + "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": {}, + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + } + ] } ] } diff --git a/test/data/fs-scheck.test b/test/data/fs-scheck.test index bc7c357..33de38a 100644 --- a/test/data/fs-scheck.test +++ b/test/data/fs-scheck.test @@ -78,6 +78,587 @@ } } ] + }, + { + "Target": "test/data", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 2, + "Failures": 0, + "Exceptions": 0 + } + }, + { + "Target": "test/data/main.tf", + "Class": "config", + "Type": "terraform", + "MisconfSummary": { + "Successes": 1, + "Failures": 9, + "Exceptions": 0 + }, + "Misconfigurations": [ + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0086", + "AVDID": "AVD-AWS-0086", + "Title": "S3 Access block should block public ACL", + "Description": "\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", + "Message": "No public access block so not blocking public acls", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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": "\nS3 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", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not have encryption enabled", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0089", + "AVDID": "AVD-AWS-0089", + "Title": "S3 Bucket Logging", + "Description": "Ensures S3 bucket logging is enabled for S3 buckets", + "Message": "Bucket has logging disabled", + "Namespace": "builtin.aws.s3.aws0089", + "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", + "References": [ + "https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html", + "https://avd.aquasec.com/misconfig/avd-aws-0089" + ], + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + }, + { + "Type": "Terraform Security Check", + "ID": "AVD-AWS-0090", + "AVDID": "AVD-AWS-0090", + "Title": "S3 Data should be versioned", + "Description": "\nVersioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. \nYou can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. \nWith versioning you can recover more easily from both unintended user actions and application failures.\n", + "Message": "Bucket does not have versioning enabled", + "Query": "data..", + "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, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 13, + "Content": " bucket = aws_s3_bucket.bucket.id", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "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, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 16, + "Content": " status = var.bucket_versioning_enabled", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": true, + "LastCause": true + }, + { + "Number": 17, + "Content": " }", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 18, + "Content": "}", + "IsCause": false, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + } + ] + }, + "Occurrences": [ + { + "Resource": "versioning_configuration", + "Filename": "test/data/main.tf", + "Location": { + "StartLine": 15, + "EndLine": 17 + } + }, + { + "Resource": "aws_s3_bucket_versioning.bucket_versioning", + "Filename": "test/data/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": "\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", + "Message": "No public access block so not ignoring public acls", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "No public access block so not restricting public buckets", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not have a corresponding public access block.", + "Query": "data..", + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "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.", + "Message": "Bucket does not encrypt data with a customer managed key.", + "Query": "data..", + "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": {}, + "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, + "FirstCause": true, + "LastCause": false + }, + { + "Number": 9, + "Content": " bucket = \"trivy-action-bucket\"", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": false + }, + { + "Number": 10, + "Content": "}", + "IsCause": true, + "Annotation": "", + "Truncated": false, + "FirstCause": false, + "LastCause": true + } + ] + } + } + } + ] } ] } From 3b26214f39bc84f558c03858bb069deb58e42a55 Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Sat, 25 Nov 2023 16:41:43 +0000 Subject: [PATCH 10/11] use test data as path and updated tf vars to be relative --- test/data/tfvars.test | 16 +++------------- test/test.bats | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/test/data/tfvars.test b/test/data/tfvars.test index eed38dd..428b11b 100644 --- a/test/data/tfvars.test +++ b/test/data/tfvars.test @@ -1,6 +1,6 @@ { "SchemaVersion": 2, - "ArtifactName": ".", + "ArtifactName": "test/data", "ArtifactType": "filesystem", "Metadata": { "ImageConfig": { @@ -16,17 +16,7 @@ }, "Results": [ { - "Target": "Dockerfile", - "Class": "config", - "Type": "dockerfile", - "MisconfSummary": { - "Successes": 4, - "Failures": 0, - "Exceptions": 0 - } - }, - { - "Target": "test/data", + "Target": ".", "Class": "config", "Type": "terraform", "MisconfSummary": { @@ -36,7 +26,7 @@ } }, { - "Target": "test/data/main.tf", + "Target": "main.tf", "Class": "config", "Type": "terraform", "MisconfSummary": { diff --git a/test/test.bats b/test/test.bats index 7ebd15c..ac4cf3b 100644 --- a/test/test.bats +++ b/test/test.bats @@ -84,7 +84,7 @@ bats_load_library bats-file @test "trivy config with terraform variables" { # trivy config --format json --severity MEDIUM --output tfvars.test --tf-vars ./test/data/dev.tfvars ./test/data - run ./entrypoint.sh "-a config" "-j ./test/data" "-h tfvars.test" "-g MEDIUM" "-x ./test/data/dev.tfvars" "-b json" + run ./entrypoint.sh "-a config" "-j ./test/data" "-h tfvars.test" "-g MEDIUM" "-x dev.tfvars" "-b json" run diff tfvars.test ./test/data/tfvars.test echo "$output" assert_files_equal tfvars.test ./test/data/tfvars.test From 6d65a54d368c6151802fe288bc1951222ec7687b Mon Sep 17 00:00:00 2001 From: Kyle Davies Date: Tue, 28 Nov 2023 13:45:55 +0000 Subject: [PATCH 11/11] removed quiet --- test/test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.bats b/test/test.bats index ac4cf3b..5301eab 100644 --- a/test/test.bats +++ b/test/test.bats @@ -21,7 +21,7 @@ bats_load_library bats-file @test "trivy config sarif report" { # trivy config --format sarif --output config-sarif.test . - run ./entrypoint.sh '-a config' '-b sarif' '-h config-sarif.test' '-j .' '-q ./test/data/main.tf' + run ./entrypoint.sh '-a config' '-b sarif' '-h config-sarif.test' '-j .' run diff config-sarif.test ./test/data/config-sarif.test echo "$output" assert_files_equal config-sarif.test ./test/data/config-sarif.test