Skip to content
Public template

About

A Template for creating policies for use in Compliance Framework plugins

Resources

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

Template for policies for use in Compliance Framework plugins

Testing

opa test policies

Bundling

Policies are built into bundle to make distribution easier.

You can easily build the policies by running

make build

Releasing

In a repo created from this template (the release workflows skip the template repo itself):

  • Releases come from release-please PRs. Merging one publishes the bundle built from policies/.
  • Release candidates (vX.Y.Z-rcN) come from the cut-prerelease workflow.
  • If the repo already has releases, set .release-please-manifest.json to its current version (for example {".": "1.2.3"}) before the first release-please run.

Running policies locally

opa eval -I -b policies -f pretty data.compliance_framework.local_ssh <<EOF 
{
  "passwordauthentication": [
    "yes"
  ],
  "permitrootlogin": [
    "with-password"
  ],
  "pubkeyauthentication": [
    "no"
  ]
}
EOF

Writing policies.

Policies are written in the Rego language.

package ssh.deny_password_auth

import future.keywords.in

violation[{
    "title": "Host SSH is using password authentication.",
    "description": "Host SSH should not use password, as this is insecure to brute force attacks from external sources.",
    "remarks": "Migrate to using SSH Public Keys, and switch off password authentication."
}] {
	"yes" in input.passwordauthentication
}

Metadata

Plugins expect policies to contain a metadata section as comments, with a # METADATA line to indicate it. This metadata should be in a YAML format, and contain a title and description of the policy. Other configuration can be set also, like the schedule that a policy should run on, or the control that it is linked to.

Any other comments can be added as normal (before and after) with a line separator between them and the metadata.

Here is an example metadata:

# your custom comment

# METADATA
# title: <your-title>
# description: <your-description>
# custom:
#   controls:
#     - <control-id>
#   schedule: "<cron-string>"

# your custom comment

About

A Template for creating policies for use in Compliance Framework plugins

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages