Skip to content

Commit 770439a

Browse files
authored
feat: checkov workflow added (#49)
Co-authored-by: Deepak Verma <[email protected]>
1 parent b52180b commit 770439a

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

.github/workflows/checkov.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: checkov
2+
# Controls when the workflow will run
3+
on:
4+
# Triggers the workflow on worflow call request events.
5+
workflow_call:
6+
inputs:
7+
directory:
8+
required: true
9+
type: string
10+
continue_on_error:
11+
required: true
12+
type: string
13+
default: 'true'
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "scan"
17+
scan:
18+
permissions:
19+
contents: read # for actions/checkout to fetch code
20+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
21+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
22+
23+
# The type of runner that the job will run on
24+
runs-on: ubuntu-latest
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so follow-up steps can access it
29+
- uses: actions/checkout@v3
30+
31+
- name: Checkov GitHub Action
32+
if: ${{ inputs.continue_on_error == 'true' }}
33+
uses: bridgecrewio/checkov-action@v12
34+
with:
35+
# This will add both a CLI output to the console and create a results.sarif file
36+
output_format: cli,sarif
37+
output_file_path: console,results.sarif
38+
soft_fail: true
39+
directory: ${{ inputs.directory}}
40+
41+
- name: Checkov GitHub Action
42+
if: ${{ inputs.continue_on_error == 'false' }}
43+
uses: bridgecrewio/checkov-action@v12
44+
with:
45+
# This will add both a CLI output to the console and create a results.sarif file
46+
output_format: cli,sarif
47+
output_file_path: console,results.sarif
48+
directory: ${{ inputs.directory}}
49+
50+
51+
- name: Upload SARIF file
52+
uses: github/codeql-action/upload-sarif@v2
53+
# Results are generated only on a success or failure
54+
# this is required since GitHub by default won't run the next step
55+
# when the previous one has failed. Security checks that do not pass will 'fail'.
56+
# An alternative is to add `continue-on-error: true` to the previous step
57+
# Or 'soft_fail: true' to checkov.
58+
if: success() || failure()
59+
with:
60+
sarif_file: results.sarif

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Above example is just a simple example to call workflow from github shared workf
6060
* [Example for terraform checks with digitalocean cloud](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/terraform-checks.md#example-for-terraform-checks-with-digitalocean-cloud)
6161
6. [Terraform Lint Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/terraform-lint.md)
6262
7. [Terraform Checks Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/terraform-checks.md)
63+
7. [Checkov Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/checkov.md)
6364
6465
## Feedback
6566
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/github-shared-workflows/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).

docs/checkov.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## [Checkov Assignee Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/checkov.yml)
2+
3+
This workflow does a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations that may lead to security or compliance problems.
4+
5+
#### Usage
6+
Checkov is a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations that may lead to security or compliance problems. Checkov includes more than 750 predefined policies to check for common misconfiguration issues. Checkov also supports the creation and contribution of custom policies.
7+
8+
## Supported IaC types
9+
### Checkov scans these IaC file types:
10+
11+
- Terraform (for AWS, GCP, Azure and OCI)
12+
- CloudFormation (including AWS SAM)
13+
- Azure Resource Manager (ARM)
14+
- Serverless framework
15+
- Helm charts
16+
- Kubernetes
17+
- Docker
18+
19+
#### Example
20+
```yaml
21+
name: checkov
22+
on:
23+
# this can be trigger based on both master and main branch.
24+
push:
25+
branches: [ "main", "master" ]
26+
pull_request:
27+
branches: [ "main", "master" ]
28+
workflow_dispatch:
29+
jobs:
30+
checkov:
31+
uses: clouddrove/github-shared-workflows/.github/workflows/checkov.yml@master # shared workflow
32+
with:
33+
directory: # specify your working folder from repo
34+
continue_on_error: true #action will continue on error
35+
```

0 commit comments

Comments
 (0)