diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07e24905..529be556 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,9 +12,9 @@ First of all, you should check if the provider your rule targets is supported by Next up, you'll need to check if the properties you want to target are supported, and if not, add support for them. The guide on [Adding Support for a New Service](https://github.com/aquasecurity/defsec/blob/master/CONTRIBUTING.md#adding-support-for-a-new-service) covers adding new properties. -At last, it's time to write your rule code! Rules are defined using _OPA Rego_. You can find a number of examples in the `rules/cloud/policies` directory. The [OPA documentation](https://www.openpolicyagent.org/docs/latest/policy-language/) is a great place to start learning Rego. You can also check out the [Rego Playground](https://play.openpolicyagent.org/) to experiment with Rego, and [join the OPA Slack](https://slack.openpolicyagent.org/). +At last, it's time to write your rule code! Rules are defined using _OPA Rego_. You can find a number of examples in the `checks/cloud` directory. The [OPA documentation](https://www.openpolicyagent.org/docs/latest/policy-language/) is a great place to start learning Rego. You can also check out the [Rego Playground](https://play.openpolicyagent.org/) to experiment with Rego, and [join the OPA Slack](https://slack.openpolicyagent.org/). -Create a new file in `rules/cloud/policies` with the name of your rule. You should nest it in the existing directory structure as applicable. The package name should be in the format `builtin.PROVIDER.SERVICE.ID`, e.g. `builtin.aws.rds.aws0176`. +Create a new file in `checks/cloud` with the name of your rule. You should nest it in the existing directory structure as applicable. The package name should be in the format `builtin.PROVIDER.SERVICE.ID`, e.g. `builtin.aws.rds.aws0176`. Running `make id` will provide you with the next available _ID_ for your rule. You can use this ID in your rule code to identify it. @@ -53,7 +53,7 @@ deny[res] { } ``` -In fact, this is the code for an actual rule. You can find it in `rules/cloud/policies/aws/rds/enable_iam_auth.rego`. +In fact, this is the code for an actual rule. You can find it in `checks/cloud/aws/rds/enable_iam_auth.rego`. The metadata is the top section that starts with `# METADATA`, and is fairly verbose. You can copy and paste from another rule as a starting point. This format is effectively _yaml_ within a Rego comment, and is [defined as part of Rego itself](https://www.openpolicyagent.org/docs/latest/policy-language/#metadata). @@ -88,7 +88,7 @@ The rule should return a result, which can be created using `result.new` (this f In the example above, you'll notice properties are being accessed from the `input.aws` object. The full set of schemas containing all of these properties is [available here](https://github.com/aquasecurity/defsec/tree/master/pkg/rego/schemas). You can match the schema name to the type of input you want to scan. -You should also write a test for your rule(s). There are many examples of these in the `rules/cloud/policies` directory. +You should also write a test for your rule(s). There are many examples of these in the `checks/cloud` directory. Finally, you'll want to generate documentation for your newly added rule. Please run `make docs` to generate the documentation for your new policy and submit a PR for us to take a look at. diff --git a/checks/cloud/aws/rds/disable_public_access.rego b/checks/cloud/aws/rds/disable_public_access.rego index a88d9ae4..b4fd6b81 100644 --- a/checks/cloud/aws/rds/disable_public_access.rego +++ b/checks/cloud/aws/rds/disable_public_access.rego @@ -20,9 +20,9 @@ # - service: rds # provider: aws # terraform: -# good_examples: "rules/cloud/policies/aws/rds/disable_public_access.tf.go" +# good_examples: "checks/cloud/aws/rds/disable_public_access.tf.go" # cloud_formation: -# good_examples: "rules/cloud/policies/aws/rds/disable_public_access.cf.go" +# good_examples: "checks/cloud/aws/rds/disable_public_access.cf.go" package builtin.aws.rds.aws0180 diff --git a/checks/cloud/aws/s3/enable_logging.rego b/checks/cloud/aws/s3/enable_logging.rego index a81b27b2..9cf64e9a 100644 --- a/checks/cloud/aws/s3/enable_logging.rego +++ b/checks/cloud/aws/s3/enable_logging.rego @@ -21,10 +21,10 @@ # - service: s3 # provider: aws # terraform: -# good_examples: "rules/cloud/policies/aws/s3/enable_bucket_logging.tf.go" +# good_examples: "checks/cloud/aws/s3/enable_bucket_logging.tf.go" # links: "https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket" # cloud_formation: -# good_examples: "rules/cloud/policies/aws/s3/enable_bucket_logging.cf.go" +# good_examples: "checks/cloud/aws/s3/enable_bucket_logging.cf.go" package builtin.aws.s3.aws0089 deny[res] {