Skip to content

Commit

Permalink
⭐️ new resource mondoo_integration_shodan (#141)
Browse files Browse the repository at this point in the history
* ⭐️ new resource `mondoo_integration_shodan`

You can now setup the Shodan integration with Mondoo:
```hcl
resource "mondoo_integration_shodan" "shodan_integration" {
  space_id = mondoo_space.shodan_space.id
  name     = "Shodan Integration"

  targets = ["8.8.8.8", "mondoo.com"]

  credentials = {
    token = var.shodan_token
  }
}
```

Signed-off-by: Salim Afiune Maya <[email protected]>

* 🧹 make sensitive variables sensitive

Signed-off-by: Salim Afiune Maya <[email protected]>

* 🔄 update mondoo-go dependency

Signed-off-by: Salim Afiune Maya <[email protected]>

* 🩷 add unit tests

Signed-off-by: Salim Afiune Maya <[email protected]>

---------

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune authored Oct 22, 2024
1 parent c881e16 commit d884d29
Show file tree
Hide file tree
Showing 20 changed files with 692 additions and 89 deletions.
2 changes: 2 additions & 0 deletions docs/resources/integration_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ variable "mondoo_org" {
variable "aws_access_key" {
description = "AWS access key"
type = string
sensitive = true
}
variable "aws_secret_key" {
description = "AWS secret key"
type = string
sensitive = true
}
provider "mondoo" {}
Expand Down
1 change: 1 addition & 0 deletions docs/resources/integration_github.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ variable "mondoo_org" {
variable "github_token" {
description = "The GitHub Token"
type = string
sensitive = true
}
provider "mondoo" {
Expand Down
69 changes: 69 additions & 0 deletions docs/resources/integration_shodan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_integration_shodan Resource - terraform-provider-mondoo"
subcategory: ""
description: |-
Continuously scan Internet-connected devices with Shodan.
---

# mondoo_integration_shodan (Resource)

Continuously scan Internet-connected devices with Shodan.

## Example Usage

```terraform
variable "mondoo_org" {
description = "The Mondoo Organization ID"
type = string
}
variable "shodan_token" {
description = "The Shodan Token"
type = string
sensitive = true
}
provider "mondoo" {
region = "us"
}
# Create a new space
resource "mondoo_space" "shodan_space" {
name = "My Shodan Space Name"
org_id = var.mondoo_org
}
# Setup the Shodan integration
resource "mondoo_integration_shodan" "shodan_integration" {
space_id = mondoo_space.shodan_space.id
name = "Shodan Integration"
targets = ["8.8.8.8", "mondoo.com"]
credentials = {
token = var.shodan_token
}
}
```

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

### Required

- `credentials` (Attributes) (see [below for nested schema](#nestedatt--credentials))
- `name` (String) Name of the integration.
- `space_id` (String) Mondoo Space Identifier.
- `targets` (List of String) Shodan scan targets.

### Read-Only

- `mrn` (String) Integration identifier

<a id="nestedatt--credentials"></a>
### Nested Schema for `credentials`

Required:

- `token` (String, Sensitive) Token for Shodan integration.
1 change: 1 addition & 0 deletions docs/resources/integration_slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ variable "mondoo_org" {
variable "slack_token" {
description = "The Slack Token"
type = string
sensitive = true
}
provider "mondoo" {
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/mondoo_integration_aws/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ variable "mondoo_org" {
variable "aws_access_key" {
description = "AWS access key"
type = string
sensitive = true
}

variable "aws_secret_key" {
description = "AWS secret key"
type = string
sensitive = true
}

provider "mondoo" {}
Expand Down
3 changes: 2 additions & 1 deletion examples/resources/mondoo_integration_github/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ variable "mondoo_org" {
variable "github_token" {
description = "The GitHub Token"
type = string
sensitive = true
}

provider "mondoo" {
Expand Down Expand Up @@ -35,4 +36,4 @@ resource "mondoo_integration_github" "gh_integration" {
credentials = {
token = var.github_token
}
}
}
9 changes: 9 additions & 0 deletions examples/resources/mondoo_integration_shodan/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
mondoo = {
source = "mondoohq/mondoo"
version = ">= 0.5"
}
}
}

32 changes: 32 additions & 0 deletions examples/resources/mondoo_integration_shodan/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
variable "mondoo_org" {
description = "The Mondoo Organization ID"
type = string
}

variable "shodan_token" {
description = "The Shodan Token"
type = string
sensitive = true
}

provider "mondoo" {
region = "us"
}

# Create a new space
resource "mondoo_space" "shodan_space" {
name = "My Shodan Space Name"
org_id = var.mondoo_org
}

# Setup the Shodan integration
resource "mondoo_integration_shodan" "shodan_integration" {
space_id = mondoo_space.shodan_space.id
name = "Shodan Integration"

targets = ["8.8.8.8", "mondoo.com"]

credentials = {
token = var.shodan_token
}
}
3 changes: 2 additions & 1 deletion examples/resources/mondoo_integration_slack/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ variable "mondoo_org" {
variable "slack_token" {
description = "The Slack Token"
type = string
sensitive = true
}

provider "mondoo" {
Expand All @@ -24,4 +25,4 @@ resource "mondoo_integration_slack" "slack_integration" {
name = "My Slack Integration"

slack_token = var.slack_token
}
}
45 changes: 24 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@ require (
github.com/hashicorp/terraform-plugin-go v0.24.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.10.0
github.com/stretchr/testify v1.9.0
go.mondoo.com/cnquery/v11 v11.26.0
go.mondoo.com/mondoo-go v0.0.0-20241008124445-8b5a3b0795a3
go.mondoo.com/mondoo-go v0.0.0-20241021155857-8e59c22fe68e
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
github.com/aws/aws-sdk-go-v2 v1.32.2 // indirect
github.com/aws/aws-sdk-go-v2/config v1.28.0 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.43 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.41 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect
Expand All @@ -46,29 +47,30 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 // indirect
github.com/bradleyfalzon/ghinstallation/v2 v2.5.0 // indirect
github.com/cli/go-gh v1.2.1 // indirect
github.com/cli/safeexec v1.0.1 // indirect
github.com/cli/shurcooL-graphql v0.0.4 // indirect
github.com/cli/safeexec v1.0.0 // indirect
github.com/cli/shurcooL-graphql v0.0.2 // indirect
github.com/cloudflare/circl v1.5.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.29.1 // indirect
github.com/getsentry/sentry-go v0.29.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v45 v45.2.0 // indirect
github.com/google/go-github/v60 v60.0.0 // indirect
github.com/google/go-github/v53 v53.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
Expand All @@ -92,15 +94,15 @@ require (
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/henvic/httpretty v0.1.3 // indirect
github.com/henvic/httpretty v0.0.6 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jedib0t/go-pretty v4.3.0+incompatible // indirect
github.com/jedib0t/go-pretty/v6 v6.5.9 // indirect
github.com/jedib0t/go-pretty/v6 v6.4.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
Expand All @@ -123,13 +125,14 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand All @@ -139,8 +142,8 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/thanhpk/randstr v1.0.6 // indirect
github.com/thlib/go-timezone-local v0.0.3 // indirect
github.com/thanhpk/randstr v1.0.4 // indirect
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand All @@ -149,11 +152,11 @@ require (
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
go.mondoo.com/ranger-rpc v0.6.4 // indirect
go.mongodb.org/mongo-driver v1.15.1 // indirect
go.mongodb.org/mongo-driver v1.10.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
Expand All @@ -166,7 +169,7 @@ require (
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.26.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit d884d29

Please sign in to comment.