Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: create OSCAL json report from compliance operator evidence #50

Closed
wants to merge 5 commits into from

Conversation

degenaro
Copy link

What

Transform Kubernetes compliance operator evidence from cluster_resource fetcher into a NIST OSCAL Assessment Results collection of Observations in JSON format.

Why

Rationale: standardized version of evidence for multi-cloud and to facilitate creation of NIST OSCAL Assessment Results.

How

Write a harvest report compliance_oscal_observations that consumes cluster_resource.json evidence and optional oscal-metadata.yaml to produce compliance_oscal_observations.json.

Test

  • Ensure check results summary filename property is set.
  • Ensure proper handling of no cluster_resource content.
  • Ensure proper report creation.
  • Ensure proper report creation with oscal metadata.
  • Test no 'resources' found.
  • Test no 'kind' found.
  • Test no 'ConfigMap' found.
  • Test no 'data' found.
  • Test no 'results' found.
  • Test no 'metadata' found.
  • Test no 'name' found.

Context

Copy link
Contributor

@alfinkel alfinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's over 1000 lines of content here. This should really be pared down to a series of smaller PRs and/or see about making your test fixtures a bit less verbose. Our general guideline is to keep PRs under 500 lines of overall content.

Your commits also need to be signed.

@degenaro degenaro force-pushed the main branch 5 times, most recently from 7e8720f to 9e29062 Compare February 17, 2021 21:24
Improved doc string, comprising report --details.

spit & polish.

spit & polish.

Support optional config parameters --start and --end

copyright

remove test fixtures

README

reduce LOCs

README original

README report

README merge

0.11.0
@degenaro
Copy link
Author

Content pretty close to 500 lines now. Commits signed.

@@ -1,3 +1,7 @@
# [0.11.0](https://github.com/ComplianceAsCode/auditree-arboretum/releases/tag/v0.11.0)

- [ADDED] Kubernetes resources report added.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [ADDED] Kubernetes resources report added.
- [ADDED] Kubernetes Compliance OSCAL Observations harvest report added.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

```

[compliance-oscal-observations]: https://github.com/ComplianceAsCode/auditree-arboretum/blob/main/arboretum/kubernetes/reports/compliance_oscal_observations.py
[fetch-cluster-resource]: https://github.ibm.com/auditree/auditree-central/blob/master/auditree_central/provider/iks/fetchers/fetch_cluster_resource.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken link

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two broken links fixed.

Comment on lines +124 to +128
* A report is generated comprising a collection of observations, one for each [XCCDF][xccdf] rule/result pair discovered in the `cluster_resource.json` files with respect to the optional date range. Each observation may be enhanced in accordance with an optional `oscal_metadata.yaml` file.
* Data files required:
* `raw/kubernetes/cluster_resource.json`, created by the kubernetes provider [ClusterResourceFetcher][fetch-cluster-resource].
* Data files optional:
* `raw/kubernetes/oscal_metadata.json`, planted by the kubernetes provider account administrator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the oscal_metadata.yaml different from the raw/kubernetes/oscal_metadata.json?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does whichever file that is going to be planted in the locker need to be treated as evidence? Planting it in the locker implies that it is auditable and will be treated as evidence with a time to live setting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are the 2 files: cluster_resource.json and oscal_metadata.json. They go hand-in-hand. The latter is metadata about the former. If the inventory (e.g. name: ssg-ocp4-ds-cis-10.221.139.105-pod) of the former former adds/deletes/modifies a name, then the latter should change accordingly.

@@ -0,0 +1,227 @@
# -*- mode:python; coding:utf-8 -*-
# Copyright (c) 2020 IBM Corp. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed copyright date.

The compliance OSCAL observations report.

A json report comprising NIST OSCAL Assessment Results Observations generated
by processing compliance operator fetcher cluster_resource evidence. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
by processing compliance operator fetcher cluster_resource evidence. The
by processing Kubernetes stand-alone cluster resources evidence. The

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed "compliance operator fetcher cluster_resource" to "Kubernetes stand-alone cluster resources" as suggested.


A json report comprising NIST OSCAL Assessment Results Observations generated
by processing compliance operator fetcher cluster_resource evidence. The
embedded XML within the cluster_resource evidence is transformed to produce the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
embedded XML within the cluster_resource evidence is transformed to produce the
XML within the cluster resource evidence is transformed to produce the JSON

Copy link
Author

@degenaro degenaro Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "embedded", removed "_", added "JSON" as suggested.

A json report comprising NIST OSCAL Assessment Results Observations generated
by processing compliance operator fetcher cluster_resource evidence. The
embedded XML within the cluster_resource evidence is transformed to produce the
report. If an optional oscal_metadata file is specified, then the report is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
report. If an optional oscal_metadata file is specified, then the report is
report. If an optional OSCAL metadata file is specified, then the report is

...again this is confusing. Is this a file or evidence gathered from the locker?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed "oscal_metadata" to "OSCAL metadata". The metadata (if present) makes up for what is lacking in the cluster_resource evidence to produce a better OSCAL. As mentioned in a comment above, the metadata should change over time as the resources contained within the cluster change.


> harvest report my-repo arboretum compliance_oscal_observations \
--config '{ \
"cluster_resource":"raw/kubernetes/cluster_resource.json", \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) Why would someone need to supply this? AFAICT this evidence should always be processed by the report.
(2) Also, this isn't the evidence file name generated by the fetcher.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow flexibility in case the fetcher generated file name changes for any reason.

format of a single mapping. The items in angle brackets are to be replaced with
desired values for augmenting the produced OSCAL.

The mapping whose <name> matches the [metadata][name] in the evidence for the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing. Above you imply that this yaml is evidence as is the cluster resources evidence. If that's the case then you should be clear which evidence you're referring to here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to specify "cluster resources evidence" as suggested.

@alfinkel
Copy link
Contributor

alfinkel commented Jun 7, 2021

Closing due to inactivity

@alfinkel alfinkel closed this Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants