Skip to content

Commit

Permalink
Implement Auditree plugin (#14)
Browse files Browse the repository at this point in the history
* implement auditree plugin

Signed-off-by: Takumi Yanagawa <[email protected]>

* format

Signed-off-by: Takumi Yanagawa <[email protected]>

* update documents, including auditree usage

Signed-off-by: Takumi Yanagawa <[email protected]>

---------

Signed-off-by: Takumi Yanagawa <[email protected]>
  • Loading branch information
yana1205 authored Jun 3, 2024
1 parent 2744462 commit 2b0081c
Show file tree
Hide file tree
Showing 18 changed files with 1,205 additions and 7 deletions.
34 changes: 32 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go/go.sum|^.secrets.baseline$",
"lines": null
},
"generated_at": "2024-04-28T07:58:38Z",
"generated_at": "2024-06-03T11:04:28Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -82,7 +82,7 @@
"hashed_secret": "845d87d073c35614bfe1fe7f7f3821ea0f175126",
"is_secret": false,
"is_verified": false,
"line_number": 279,
"line_number": 285,
"type": "Base64 High Entropy String",
"verified_result": null
}
Expand Down Expand Up @@ -142,6 +142,36 @@
"type": "Secret Keyword",
"verified_result": null
}
],
"plugins_public/tests/data/auditree/auditree.json": [
{
"hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441",
"is_secret": false,
"is_verified": false,
"line_number": 12,
"type": "Secret Keyword",
"verified_result": null
}
],
"plugins_public/tests/data/auditree/auditree.template.json": [
{
"hashed_secret": "90af18406819a28094e7a409acf03bfa214c562d",
"is_secret": false,
"is_verified": false,
"line_number": 8,
"type": "Secret Keyword",
"verified_result": null
}
],
"plugins_public/tests/data/auditree/check_results.json": [
{
"hashed_secret": "f6fd6a964bf5d8f2f88dab6b4bcd8a50745f42e9",
"is_secret": false,
"is_verified": false,
"line_number": 180,
"type": "Hex High Entropy String",
"verified_result": null
}
]
},
"version": "0.13.1+ibm.61.dss",
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ C2P supports Compliance and PVP as follows:
- Compliance framework
- Open Security Controls Assessment Language (OSCAL)
- PVP
- Kyverno
- Open Cluster Management Governance Policy Framework
- [Kyverno](https://kyverno.io/)
- [Open Cluster Management Governance Policy Framework](https://open-cluster-management.io/)
- [Auditree](https://auditree.github.io/)

C2P reduces the cost to implement the interchange between Compliance artifacts and PVP proprietary artifacts. C2P is extensible to various PVPs through plugin.

Expand Down Expand Up @@ -94,6 +95,11 @@ You may be asked passphrase of SSH key to access to the git repo.
```
![assessment-results-md.kyverno.jpg](/docs/public/images/assessment-results-md.kyverno.jpg)

## Usage of C2P Plugins
- [Kyverno](docs/public/kyverno.md)
- [Open Cluster Management Governance Policy Framework](docs/public/ocm.md)
- [Auditree](docs/public/auditree.md)

## Usage of C2P as a library

#### Generate PVP Policies from Compliance
Expand Down
2 changes: 1 addition & 1 deletion c2p/framework/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from c2p.framework.models.policy import Parameter, Policy, RuleSet
from c2p.framework.models.pvp_result import PVPResult
from c2p.framework.models.raw_result import RawResult
from c2p.framework.models.policy import Policy, Parameter, RuleSet
153 changes: 153 additions & 0 deletions docs/public/auditree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
## Plugin for Auditree

### Example usage of C2P w/ mock data
1. Generate auditree.json (C2P Compliance to Policy)
```sh
$ python ./samples_public/auditree/compliance_to_policy.py -h
usage: compliance_to_policy.py [-h] [-i INPUT] [-c COMPONENT_DEFINITION] [-o OUT]

options:
-h, --help show this help message and exit
-i INPUT, --input INPUT
Path to auditree.json template (default: plugins_public/tests/data/auditree/auditree.template.json)
-c COMPONENT_DEFINITION, --component_definition COMPONENT_DEFINITION
Path to component-definition.json (default: plugins_public/tests/data/auditree/component-
definition.json
-o OUT, --out OUT Path to generated auditree.json (default: system temporary directory)
```
e.g.
```sh
$ python ./samples_public/auditree/compliance_to_policy.py -o auditree.json
$ cat auditree.json
{
"locker": {
"default_branch": "main",
"repo_url": "https://github.com/MY_ORG/MY_EVIDENCE_REPO"
},...
```
1. Generate Assessment Result (C2P Result to Compliance)
```sh
$ python ./samples_public/auditree/result_to_compliance.py -h
usage: result_to_compliance.py [-h] [-i INPUT] [-c COMPONENT_DEFINITION]

options:
-h, --help show this help message and exit
-i INPUT, --input INPUT
Path to check_results.json (default: plugins_public/tests/data/auditree/check_results.json)
-c COMPONENT_DEFINITION, --component_definition COMPONENT_DEFINITION
Path to component-definition.json (default: plugins_public/tests/data/auditree/component-
definition.json
```
e.g.
```sh
$ python ./samples_public/auditree/result_to_compliance.py
...
"results": [
{
"uuid": "853eeb24-6970-4f73-8fcc-fc274be669ec",
"title": "Auditree Assessment Results",
"description": "OSCAL Assessment Results from Auditree",
"start": "2024-06-02T08:42:22+00:00",
"reviewed-controls": {
"control-selections": [
{
"include-controls": [
{
"control-id": "cm-2",
"statement-ids": []
},
{
"control-id": "ac-2",
"statement-ids": []
}
]
}
]
},
"observations": [
{
"uuid": "3ea6d5dd-7a69-4f18-828c-a0e578594c63",
"title": "demo_examples.checks.test_github.GitHubOrgs.test_members_is_not_empty",
"description": "demo_examples.checks.test_github.GitHubOrgs.test_members_is_not_empty",
"props": [
{
"name": "assessment-rule-id",
"value": "demo_examples.checks.test_github.GitHubOrgs.test_members_is_not_empty"
}
],
"methods": [
"AUTOMATED"
],
"subjects": [
{
"subject-uuid": "e3789a4f-f32a-4d59-b777-44df643631e6",
"type": "inventory-item",
"title": "Auditree Check: demo_examples.checks.test_github.GitHubOrgs.test_members_is_not_empty_0_nasa",
"props": [
{
"name": "resource-id",
"value": "demo_examples.checks.test_github.GitHubOrgs.test_members_is_not_empty_0_nasa"
},
{
"name": "result",
"value": "pass"
...
```
### Example usage of C2P w/ Auditree
Prerequisite:
- Install Python packages for Auditree:
- https://pypi.org/project/auditree-framework/
- https://pypi.org/project/auditree-arboretum/
1. Clone auditree-framework and go to `demo` directory (See also https://complianceascode.github.io/auditree-framework/quick-start.html)
```
git clone https://github.com/ComplianceAsCode/auditree-framework.git
cd auditree-framework/demo
```
1. Clone c2p
```
git clone https://github.com/oscal-compass/compliance-to-policy.git
```
1. Generate auditree.json (C2P Compliance to Policy)
1. Create OSCAL component-definition.json
`sed 's/nasa/oscal-compass/g' ./compliance-to-policy/plugins_public/tests/data/auditree/component-definition.json > ./component-definition.json`
1. (Optional) You can edit it in Spreadsheet [component-definition.csv](/plugins_public/tests/data/auditree/component-definition.csv) and then convert it to OSCAL JSON format through Trestle. To convert it, C2P also provides an utility (internally using Trestle)
`c2p tools csv-to-oscal-cd --title "Sample Component Definition using Auditree as PVP" --csv ./compliance-to-policy/plugins_public/tests/data/auditree/component-definition.csv --out <path to output directory>`
1. Generate auditree.json
`python ./compliance-to-policy/samples_public/auditree/compliance_to_policy.py -i ./auditree_demo.json -c ./component-definition.json -o auditree.json`
1. Run policy validation (Auditree fetchers and checks)
```
compliance --fetch --evidence local -C auditree.json -v
```
```
compliance --check demo.arboretum.accred,demo.custom.accred --evidence local -C auditree.json -v
```
You'll see the path to the local evidence locker directory in the log.
e.g.
```
$ compliance --check demo.arboretum.accred,demo.custom.accred --evidence local -C auditree.json -v
INFO: Using locker found in /var/folders/yx/1mv5rdh53xd93bphsc459ht00000gn/T/compliance...
...
```
1. Generate Assessment Result (C2P Result to Compliance)
`python ./compliance-to-policy/samples_public/auditree/result_to_compliance.py -i <PATH/TO/EVIDENCE_LOCKER/check_results.json> -c ./component-definition.json` > assessment-results.json
e.g.
```
$ python ./compliance-to-policy/samples_public/auditree/result_to_compliance.py -i /var/folders/yx/1mv5rdh53xd93bphsc459ht00000gn/T/compliance/check_results.json -c ./component-definition.json > assessment_results.json
```
1. OSCAL Assessment Results is not human readable format. You can see the merged report in markdown by a quick viewer.
```
c2p tools viewer -ar assessment_results.json -cdef ./component-definition.json
```
![assessment-results-md.auditree.jpg](/docs/public/images/assessment-results-md.auditree.jpg)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b0081c

Please sign in to comment.