Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added exception management #165

Merged
merged 14 commits into from
Dec 16, 2024
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ qpbi
querypack
Qwc
scim
startswith
Tcy
testacc
TEzu
Expand Down
55 changes: 55 additions & 0 deletions docs/resources/exception.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_exception Resource - terraform-provider-mondoo"
subcategory: ""
description: |-
Set custom exceptions for a Scope.
---

# mondoo_exception (Resource)

Set custom exceptions for a Scope.

## Example Usage

```terraform
variable "space_id" {
type = string
description = "The ID of the mondoo space."
}

provider "mondoo" {
region = "eu"
space = var.space_id
}

data "mondoo_assets" "assets_data" {
space_id = var.space_id
}

locals {
ssl_asset = [for asset in data.mondoo_assets.assets_data.assets : asset if startswith(asset.name, "https")]
asset_id = one(local.ssl_asset).id
}


resource "mondoo_exception" "exception" {
scope_mrn = "//assets.api.mondoo.app/spaces/${var.space_id}/assets/${local.asset_id}"
valid_until = "2024-12-11"
justification = "testing"
action = "SNOOZE"
check_mrns = ["//policy.api.mondoo.app/queries/mondoo-tls-security-mitigate-beast"]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `action` (String) The action to perform. Default is `SNOOZE`. Other options are `ENABLE`, `DISABLE`, `OUT_OF_SCOPE`.
- `check_mrns` (List of String) List of check MRNs to set exceptions for. If set, `vulnerability_mrns` must not be set.
- `justification` (String) Description why the exception is required.
- `scope_mrn` (String) The MRN of the scope (either asset mrn or space mrn).
- `valid_until` (String) The timestamp until the exception is valid.
- `vulnerability_mrns` (List of String) List of vulnerability MRNs to set exceptions for. If set, `check_mrns` must not be set.
Comment on lines +50 to +55
Copy link
Contributor Author

@mati007thm mati007thm Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action is optional since SNOOZE is default
check_mrns conflicts with vulnerability_mrns and can therefore not be Required
justification is optional since it is simply not needed
scope_mrn is optional since it either can be declared here or the provider scope can be used
valid_until is optional since it can only be used by action SNOOZE

8 changes: 8 additions & 0 deletions examples/resources/mondoo_exception/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
mondoo = {
source = "mondoohq/mondoo"
version = ">= 0.19"
}
}
}
27 changes: 27 additions & 0 deletions examples/resources/mondoo_exception/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
variable "space_id" {
type = string
description = "The ID of the mondoo space."
}

provider "mondoo" {
region = "eu"
space = var.space_id
}

data "mondoo_assets" "assets_data" {
space_id = var.space_id
}

locals {
ssl_asset = [for asset in data.mondoo_assets.assets_data.assets : asset if startswith(asset.name, "https")]
asset_id = one(local.ssl_asset).id
}


resource "mondoo_exception" "exception" {
scope_mrn = "//assets.api.mondoo.app/spaces/${var.space_id}/assets/${local.asset_id}"
valid_until = "2024-12-11"
justification = "testing"
action = "SNOOZE"
check_mrns = ["//policy.api.mondoo.app/queries/mondoo-tls-security-mitigate-beast"]
}
Loading
Loading