From 7c2f4949e2695a1f259479aaf703d9f7695f4bb5 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Thu, 24 Oct 2024 15:29:26 -0500 Subject: [PATCH] add example for opslevel_check_code_issue --- .../opslevel_check_code_issue/import.sh | 1 + .../opslevel_check_code_issue/resource.tf | 59 +++++++++++++++++++ tests/check_code_issue.tftest.hcl | 4 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 examples/resources/opslevel_check_code_issue/import.sh create mode 100644 examples/resources/opslevel_check_code_issue/resource.tf diff --git a/examples/resources/opslevel_check_code_issue/import.sh b/examples/resources/opslevel_check_code_issue/import.sh new file mode 100644 index 00000000..67bd6068 --- /dev/null +++ b/examples/resources/opslevel_check_code_issue/import.sh @@ -0,0 +1 @@ +terraform import opslevel_check_code_issue.example Z2lkOi8vb3BzbGV2ZWwvU2VydmljZS82MDI0 diff --git a/examples/resources/opslevel_check_code_issue/resource.tf b/examples/resources/opslevel_check_code_issue/resource.tf new file mode 100644 index 00000000..82637a71 --- /dev/null +++ b/examples/resources/opslevel_check_code_issue/resource.tf @@ -0,0 +1,59 @@ +data "opslevel_rubric_category" "security" { + filter { + field = "name" + value = "Security" + } +} + +data "opslevel_rubric_level" "bronze" { + filter { + field = "name" + value = "Bronze" + } +} + +data "opslevel_team" "devs" { + alias = "developers" +} + +data "opslevel_filter" "tier1" { + filter { + field = "name" + value = "Tier 1" + } +} + +resource "opslevel_check_code_issue" "example" { + name = "foo" + pass_pending = true + enabled = true + # To set a future enable date remove field 'enabled' and use 'enable_on' + # enable_on = "2022-05-23T14:14:18.782000Z" + category = data.opslevel_rubric_category.security.id + level = data.opslevel_rubric_level.bronze.id + owner = data.opslevel_team.devs.id + filter = data.opslevel_filter.tier1.id + notes = "Optional additional info on why this check is run or how to fix it" + + constraint = "any" + issue_name = "CVE-2024-0001" + issue_type = [ + "snyk:code", + "snyk:cloud", + "snyk:config", + "snyk:custom", + "snyk:license", + "snyk:package_vulnerability", + ] + max_allowed = 5 + resolution_time = { + unit = "day" + value = 3 + } + severity = [ + "snyk:critical", + "snyk:low", + "snyk:medium", + "snyk:high", + ] +} diff --git a/tests/check_code_issue.tftest.hcl b/tests/check_code_issue.tftest.hcl index 0611bd68..735fdda8 100644 --- a/tests/check_code_issue.tftest.hcl +++ b/tests/check_code_issue.tftest.hcl @@ -6,8 +6,8 @@ variables { constraint = "any" # optional fields - issue_name = "idk" - issue_type = ["snyk:code"] + issue_name = "CVE-2024-0001" + issue_type = ["snyk:code", "snyk:cloud", "snyk:config", "snyk:custom", "snyk:license", "snyk:package_vulnerability"] max_allowed = 5 resolution_time = { unit = "week"