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

⭐ Use cnspec container image #40

Merged
merged 44 commits into from Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6e32568
WIP: ⭐ Use container image
czunker Oct 27, 2022
6316d5e
Fix typos
czunker Oct 27, 2022
5c5c8c6
Fix prettier
czunker Oct 27, 2022
71da374
Switch to docker hub
czunker Nov 2, 2022
ec99af2
Re-work image scan
czunker Nov 2, 2022
988528f
Next try
czunker Nov 2, 2022
204e8fa
Try scanning ubuntu image
czunker Nov 2, 2022
45df414
Add debug output
czunker Nov 2, 2022
bcd7b9b
Try with mondoo client
czunker Nov 2, 2022
3f2c6c5
Fix mondoo image name
czunker Nov 2, 2022
8629999
Switch back to mondoo-test image
czunker Nov 2, 2022
0595503
Add back additional args
czunker Nov 8, 2022
1f89cd8
Remove args
czunker Nov 9, 2022
4c7ade7
Remove debug output
czunker Nov 9, 2022
7c66e5f
Switch all actions to cnspec image
czunker Nov 9, 2022
8610dbb
Fix prettier
czunker Nov 9, 2022
fbc2f2e
Fix main and setup action
czunker Nov 9, 2022
c3278af
Fix prettier§
czunker Nov 9, 2022
a1fa80e
Remove setup action
czunker Nov 10, 2022
4002f06
Fix typos
czunker Nov 10, 2022
0ed153e
Add back args
czunker Nov 10, 2022
2c60793
Rearrange docs
czunker Nov 10, 2022
cdf1bd3
Create wrapper image for action
czunker Nov 10, 2022
4ff7c2a
Temp. move Dockerfile to action to test it
czunker Nov 10, 2022
afcfcba
Re-write to sh becasue of alpine image
czunker Nov 10, 2022
f386e7e
Simplify script
czunker Nov 10, 2022
d2f2142
More tests
czunker Nov 10, 2022
ff20046
Use v1 wrapper image
czunker Nov 10, 2022
0b40720
Make prettier happy
czunker Nov 10, 2022
96c0995
First try w/o wrapper image
czunker Nov 11, 2022
71434dc
Try pre-entrypoint
czunker Nov 11, 2022
c673edd
Try entrypoint
czunker Nov 11, 2022
627368f
Try with operator repo
czunker Nov 11, 2022
658f2e8
Try composite with if and uses
czunker Nov 11, 2022
6b23423
Try composite w/o if
czunker Nov 11, 2022
0f61817
Try with operator repo
czunker Nov 11, 2022
32c7f58
Use composite
czunker Nov 11, 2022
3057051
Switch to cnspec bundle
czunker Nov 14, 2022
8a8fe12
Fix prettier
czunker Nov 14, 2022
4c3098b
Remove args from specific actions
czunker Nov 16, 2022
f234694
Fix tests
czunker Nov 16, 2022
35f96fe
Bugfix
czunker Nov 16, 2022
f7d9a4d
Fix docs bug
czunker Nov 16, 2022
125230d
Switch to GITHUB_TOKEN
czunker Nov 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/docker-image.yaml
Expand Up @@ -35,5 +35,12 @@ jobs:
- name: Scan Docker Image
uses: ./docker-image
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
image: ${{env.APP}}:${{env.VERSION}}
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
- name: Scan Docker Image
uses: ./docker-image
with:
image: ${{env.APP}}:${{env.VERSION}}
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
30 changes: 30 additions & 0 deletions .github/workflows/general-action.yaml
@@ -0,0 +1,30 @@
name: General Mondoo action
on:
pull_request:
push:
paths:
- "action.yaml"
- ".github/test_files/**"
branches:
- "main"
tags: ["v*.*.*"]

jobs:
general-action-test:
runs-on: ubuntu-latest
name: Test general Mondoo action
steps:
- uses: actions/checkout@v3

- name: Show status
uses: ./
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
args: status
- name: Show version
uses: ./
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
args: version
3 changes: 2 additions & 1 deletion .github/workflows/k8s-manifest.yaml
Expand Up @@ -19,6 +19,7 @@ jobs:

- name: Scan k8s manifest
uses: ./k8s-manifest
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: ./.github/test_files/k8s-manifest.yaml
3 changes: 2 additions & 1 deletion .github/workflows/terraform-hcl.yaml
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v3
- name: Scan Terraform HCL
uses: ./terraform-hcl
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: ./.github/test_files/tf
4 changes: 2 additions & 2 deletions .github/workflows/terraform-plan.yaml
Expand Up @@ -40,7 +40,7 @@ jobs:
path: .github/test_files/tfplan/plan.json
- name: Scan Terraform Plan
uses: ./terraform-plan
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: ".github/test_files/tfplan/plan.json"
args: "--policy-bundle .github/test_files/tfplan/policy/policy.mql.yaml"
4 changes: 2 additions & 2 deletions .github/workflows/terraform-state.yaml
Expand Up @@ -48,7 +48,7 @@ jobs:
.github/test_files/tfstate/state.json
- name: Scan Terraform State
uses: ./terraform-state
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: ".github/test_files/tfstate/state.json"
args: "--policy-bundle .github/test_files/tfstate/policy/policy.mql.yaml"
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -9,7 +9,6 @@ A set of GitHub Action for using Mondoo to check for vulnerabilities and misconf
- [Kubernetes](k8s) - Scan Kubernetes Clusters post-deploy for continuous auditing and compliance of the cluster.
- [Kubernetes Manifest](k8s-manifest) - Scan Kubernetes manifests for misconfigurations before applying changes to the cluster.
- [Policy](policy) - Publish Mondoo policies to Mondoo Platform using GitHub Actions.
- [Setup](setup) - Install and configure Mondoo into any existing GitHub Action workflow.
- [Terraform HCL](terraform-hcl) - Scan HashiCorp Terraform HCL code for security misconfigurations.
- [Terraform Plan](terraform-plan) - Scan HashiCorp Terraform Plan for security misconfigurations.
- [Terraform State](terraform-state) - Scan HashiCorp Terraform State output for security misconfigurations.
Expand Down Expand Up @@ -53,9 +52,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: mondoohq/actions/k8s-manifest@main
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: k8s/*.yaml
path: k8s/manifest.yaml
```

Simple scan of Terraform files:
Expand All @@ -71,8 +71,9 @@ jobs:
- uses: actions/checkout@v3

- uses: mondoohq/actions/terraform-hcl@main
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
path: terraform
```

Expand Down Expand Up @@ -115,8 +116,9 @@ jobs:
secrets: GIT_AUTH_TOKEN=${{ secrets.GIT_AUTH_TOKEN }}
- name: Scan Docker Image with Mondoo
uses: mondoohq/actions/docker-image@main
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
image: ghcr.io/${{github.repository_owner}}/${{env.APP}}:latest
- name: Build and push
uses: docker/build-push-action@v3
Expand Down
26 changes: 4 additions & 22 deletions action.yaml
Expand Up @@ -6,34 +6,16 @@ branding:
inputs:
args:
description: >-
Additional arguments to pass to Mondoo Client.
Additional arguments to pass to cnspec client.
required: false
log-level:
description: >-
Sets the log level: error, warn, info, debug, trace (default "info")
default: info
required: false
output:
description: >-
Set the output format for scan results: compact, yaml, json, junit, csv, summary, full, report (default "compact")
default: compact
required: false
service-account-credentials:
description: "Base64 encoded service account credentials used to authenticate with Mondoo Platform"
required: true
runs:
using: "composite"
steps:
- name: Install Mondoo Client
run: |
echo Installing Mondoo Client...
echo ${{ inputs.service-account-credentials }} | base64 -d > mondoo.json
curl -sSL https://mondoo.com/install.sh | bash
shell: bash
- name: Run Mondoo
shell: bash
run: >
mondoo ${{ inputs.args }}
--output ${{ inputs.output }}
--log-level ${{ inputs.log-level }}
--config mondoo.json
- uses: "docker://mondoo/cnspec:7"
with:
args: ${{ inputs.args }} --log-level "${{ inputs.log-level }}"
21 changes: 13 additions & 8 deletions aws/README.md
Expand Up @@ -6,13 +6,17 @@ A GitHub Action for using Mondoo to check for misconfigurations in your AWS acco

The Mondoo AWS Action has properties which are passed to the underlying image. These are passed to the action using `with`.

| Property | Required | Default | Description |
| ----------------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args` | false | | Additional arguments to pass to Mondoo Client. |
| `log-level` | false | info | Sets the log level: error, warn, info, debug, trace (default "info") |
| `output` | false | compact | Set the output format for scan results: compact, yaml, json, junit, csv, summary, full, report (default "compact") |
| `score-threshold` | false | 0 | Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan). |
| `service-account-credentials` | true | | Base64 encoded [service account credentials](https://mondoo.com/docs/platform/service_accounts/#creating-service-accounts) used to authenticate with Mondoo Platform |
| Property | Required | Default | Description |
| ----------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `log-level` | false | info | Sets the log level: error, warn, info, debug, trace (default "info") |
| `output` | false | compact | Set the output format for scan results: compact, yaml, json, junit, csv, summary, full, report (default "compact") |
| `score-threshold` | false | 0 | Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan). |

Additionally, you need to specify the service account credentials as an environment variable.

| Environment | Required | Default | Description |
| ---------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MONDOO_CONFIG_BASE64` | true | | Base64 encoded [service account credentials](https://mondoo.com/docs/platform/service_accounts/#creating-service-accounts) used to authenticate with Mondoo Platform |

## Scan AWS account example

Expand All @@ -36,8 +40,9 @@ jobs:
role-session-name: MySessionName

- uses: mondoohq/actions/aws@main
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
output: compact
score-threshold: 0
```
34 changes: 11 additions & 23 deletions aws/action.yaml
Expand Up @@ -5,10 +5,6 @@ branding:
icon: "shield"
color: "purple"
inputs:
args:
description: >-
Additional arguments to pass to Mondoo Client.
required: false
log-level:
description: >-
Sets the log level: error, warn, info, debug, trace (default "info")
Expand All @@ -24,23 +20,15 @@ inputs:
Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan).
default: "0"
required: false
service-account-credentials:
description: "Base64 encoded service account credentials used to authenticate with Mondoo Platform"
required: true
runs:
using: "composite"
steps:
- run: |
echo Installing Mondoo Client...
echo ${{ inputs.service-account-credentials }} | base64 -d > mondoo.json
curl -sSL https://mondoo.com/install.sh | bash
shell: bash
- name: Scan AWS account
shell: bash
run: >
mondoo scan aws
--output ${{ inputs.output }}
--score-threshold ${{ inputs.score-threshold }}
--log-level ${{ inputs.log-level }}
${{ inputs.args }}
--config mondoo.json
using: "docker"
image: "docker://mondoo/cnspec:7"
args:
- scan
- aws
- --output
- ${{ inputs.output }}
- --score-threshold
- ${{ inputs.score-threshold }}
- --log-level
- ${{ inputs.log-level }}
23 changes: 14 additions & 9 deletions docker-image/README.md
Expand Up @@ -6,14 +6,18 @@ A GitHub Action for using Mondoo to check for vulnerabilities and misconfigurati

The Mondoo Docker Image Action has properties which are passed to the underlying image. These are passed to the action using `with`.

| Property | Required | Default | Description |
| ----------------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args` | false | | Additional arguments to pass to Mondoo Client. |
| `image` | true | | Docker image ID or `name:tag` to scan. |
| `log-level` | false | info | Sets the log level: error, warn, info, debug, trace (default "info") |
| `output` | false | compact | Set the output format for scan results: compact, yaml, json, junit, csv, summary, full, report (default "compact") |
| `score-threshold` | false | 0 | Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan). |
| `service-account-credentials` | true | | Base64 encoded [service account credentials](https://mondoo.com/docs/platform/service_accounts/#creating-service-accounts) used to authenticate with Mondoo Platform |
| Property | Required | Default | Description |
| ----------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `image` | true | | Docker image ID or `name:tag` to scan. |
| `log-level` | false | info | Sets the log level: error, warn, info, debug, trace (default "info") |
| `output` | false | compact | Set the output format for scan results: compact, yaml, json, junit, csv, summary, full, report (default "compact") |
| `score-threshold` | false | 0 | Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan). |

Additionally, you need to specify the service account credentials as an environment variable.

| Environment | Required | Default | Description |
| ---------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MONDOO_CONFIG_BASE64` | true | | Base64 encoded [service account credentials](https://mondoo.com/docs/platform/service_accounts/#creating-service-accounts) used to authenticate with Mondoo Platform |

You can use the Action as follows:

Expand Down Expand Up @@ -58,8 +62,9 @@ jobs:
secrets: GIT_AUTH_TOKEN=${{ secrets.GIT_AUTH_TOKEN }}
- name: Scan Docker Image
uses: mondoohq/actions/docker-image@main
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
with:
service-account-credentials: ${{ secrets.MONDOO_SERVICE_ACCOUNT }}
image: ghcr.io/${{github.repository_owner}}/${{env.APP}}:latest
- name: Build and push
uses: docker/build-push-action@v3
Expand Down
39 changes: 13 additions & 26 deletions docker-image/action.yaml
Expand Up @@ -4,9 +4,6 @@ branding:
icon: "shield"
color: "purple"
inputs:
args:
description: "Additional arguments to pass to Mondoo Client"
required: false
image:
description: Docker image ID or name:tag to scan.
required: true
Expand All @@ -25,27 +22,17 @@ inputs:
Sets the score threshold for scans. Scores that fall below the threshold will exit 1. (default "0" - job continues regardless of the score returned by a scan).
default: "0"
required: false
service-account-credentials:
description: "Base64 encoded service account credentials used to authenticate with Mondoo Platform"
required: true
runs:
using: "composite"
steps:
- name: Install Mondoo Client
shell: bash
run: |
echo Installing Mondoo Client...
echo ${{ inputs.service-account-credentials }} | base64 -d > mondoo.json
curl -sSL https://mondoo.com/install.sh | bash
- name: Mondoo status
shell: bash
run: mondoo status --config mondoo.json
- name: Run mondoo scan docker image
shell: bash
run: >
mondoo scan docker image ${{ inputs.image }}
--output ${{ inputs.output }}
--score-threshold ${{ inputs.score-threshold }}
--log-level ${{ inputs.log-level }}
${{ inputs.args }}
--config mondoo.json
using: "docker"
image: "docker://mondoo/cnspec:7"
args:
- scan
- docker
- image
- ${{ inputs.image }}
- --output
- ${{ inputs.output }}
- --score-threshold
- ${{ inputs.score-threshold }}
- --log-level
- ${{ inputs.log-level }}