Skip to content

Commit

Permalink
Rename script to add_kuberentes_rule.py
Browse files Browse the repository at this point in the history
The script now supports creation of Platform and Node rules.
  • Loading branch information
yuumasato committed Oct 30, 2023
1 parent 02874fc commit 09d23a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ release_tools/*.log
release_tools/release_notes.txt
release_tools/artifacts

# Ignore the test profile that utils/add_platform_rule.py creates
# Ignore the test profile that utils/add_kubernetes_rule.py creates
ocp4/profiles/test.profile

# Ignore the build profiling files
Expand Down
13 changes: 8 additions & 5 deletions docs/manual/developer/06_contributing_with_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,19 +640,22 @@ fixes with the following commands:
This utility requires an up-to-date JSON tree created by
`rule_dir_json.py`.

#### `utils/add_platform_rule.py`
#### `utils/add_kubernetes_rule.py`

This utility can be used to bootstrap and test Kubernetes/OpenShift
application checks. See the help output for more detailed usage examples
of each of the supported subcommands:

- `utils/add_platform_rule.py create --rule=<rule_name> <options>` -
creates files for a new rule.
- `utils/add_kubernetes_rule.py create platform --rule=<rule_name> <options>` -
creates files for a new platform rule.

- `utils/add_platform_rule.py test --rule=<rule_name> <options>` -
- `utils/add_kubernetes_rule.py create node --rule=<rule_name> <options>` -
creates files for a new node rule.

- `utils/add_kubernetes_rule.py test --rule=<rule_name> <options>` -
tests a rule against local files using an oscap container.

- `utils/add_platform_rule.py cluster-test --rule=<rule_name> <options>`
- `utils/add_kubernetes_rule.py cluster-test --rule=<rule_name> <options>`
- tests a rule against a running OCP4 cluster using
compliance-operator.

Expand Down
8 changes: 4 additions & 4 deletions utils/add_platform_rule.py → utils/add_kubernetes_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def jinja_string_representer(dumper, data):
Example workflow:
$ utils/add_platform_rule.py create --rule=ocp_proxy_has_ca \
$ utils/add_kubernetes_rule.py create --rule=ocp_proxy_has_ca \
--type="proxies.config" --name="cluster" \
--yamlpath=".spec.trustedCA.name" --match="[a-zA-Z0-9]*"
creating check for "/apis/config.openshift.io/v1/proxies/cluster" with yamlpath ".spec.trustedCA.name" satisfying match of "[a-zA-Z0-9]*"
wrote applications/openshift/ocp_proxy_has_ca/rule.yml
$ mkdir -p /tmp/apis/config.openshift.io/v1/proxies/
$ oc get proxies.config/cluster -o yaml > /tmp/apis/config.openshift.io/v1/proxies/cluster
$ utils/add_platform_rule.py test --rule=ocp_proxy_has_ca
$ utils/add_kubernetes_rule.py test --rule=ocp_proxy_has_ca
testing rule ocp_proxy_has_ca locally
Title
None
Expand All @@ -61,7 +61,7 @@ def jinja_string_representer(dumper, data):
Result
pass
$ utils/add_platform_rule.py cluster-test --rule=ocp_proxy_has_ca
$ utils/add_kubernetes_rule.py cluster-test --rule=ocp_proxy_has_ca
testing rule ocp_proxy_has_ca in-cluster
deploying compliance-operator
pushing image build to cluster
Expand Down Expand Up @@ -427,7 +427,7 @@ def testFunc(args):

def main():
parser = argparse.ArgumentParser(
prog="add_platform_rule.py",
prog="add_kubernetes_rule.py",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent(PROG_DESC))
subparser = parser.add_subparsers(
Expand Down

0 comments on commit 09d23a6

Please sign in to comment.