Skip to content

Commit bdc605d

Browse files
committed
add readme
1 parent 025d007 commit bdc605d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Example Policy Org's Policy-as-code
2+
3+
This repo contains the company policy that has been codified into [kyverno](https://kyverno.io/) and [checkov](https://www.checkov.io/) policies.
4+
5+
## Usage
6+
7+
See [app1](https://github.com/example-policy-org/app1),
8+
[app2](https://github.com/example-policy-org/app2) and
9+
[app3](https://github.com/example-policy-org/app3) for kubernetes implementations; and [infra1](https://github.com/example-policy-org/infra1),
10+
[infra2](https://github.com/example-policy-org/infra2) and
11+
[infra3](https://github.com/example-policy-org/infra3) for terraform implementations.
12+
13+
## Development
14+
15+
### Kubernetes policies
16+
17+
These are kept in [kubernetes/kyverno](./kubernetes/kyverno) and can be added to by creating a new directory, and referencing this in the [kustomization.yaml](./kubernetes/kyverno/kustomization.yaml). It is important that test cases are created and a test.yaml accompanies the policy.yaml following the [documentation of developing kyverno policy](https://kyverno.io/docs/kyverno-cli/#test).
18+
19+
If you want to inherit an external policy for example from the kyverno policy library you can add the reference in the [kustomization.yaml](./kubernetes/kyverno/kustomization.yaml). If doing this, it is important for the stability of the policy to reference an immutable reference such as a git-sha to ensure that the implementations of policy checking based on this repo are deterministic and repeatable.
20+
21+
Testing can be accomplished with:
22+
```bash
23+
$ kyverno test .
24+
```
25+
26+
### Terraform IaaC policies
27+
28+
Similar to the [Kubernetes policies](#kubernetes-policies) these are in [infra/checkov](./infra/checkov/) and can be added to by creating a new directory. [checkov](https://checkov.io) doesn't yet have a formalised testing pattern for policy. So a [BATS](https://github.com/bats-core/bats-core) testing framework has been implemented. Policy can be written either as [python](https://www.checkov.io/3.Custom%20Policies/Python%20Custom%20Policies.html) or [yaml](https://www.checkov.io/3.Custom%20Policies/YAML%20Custom%20Policies.html).
29+
30+
If you want to inherit an external policy for example one of the checks built in to checkov you can add to the checks in the [checkov config](./infra/checkov/config.yaml).
31+
32+
If doing this, it is important for the stability of the policy to reference specific checks and an immutable reference where available such as a git-sha to ensure that the implementations of policy checking based on this repo are deterministic and repeatable.
33+
34+
Testing can be accomplished with:
35+
```bash
36+
$ bats infra/checkov/test.bats
37+
```
38+
39+
40+
---
41+
42+
See the [What is Policy As [versioned] Code? blog post](https://www.appvia.io/blog/policy-as-versioned-code) and the github [organisation's .github repo](https://github.com/example-policy-org/.github) to better understand how the repositories connect together.
43+

infra/checkov/test.bats

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bats
22

3+
# Bats doesn't currently support dynamic test definitions
4+
# so I've had to test all the policies within a single @test
5+
# while test failures will show some output it would be
6+
# much nicer to have a @test per test case
7+
# https://github.com/bats-core/bats-core/issues/306
8+
39
@test "checkov" {
410
for dir in infra/checkov/*/ ; do
511
for passing in ${dir}pass*.tf ; do

0 commit comments

Comments
 (0)