Skip to content

Commit 25aefb1

Browse files
authored
Add Security Scans (#20)
* Add KICS scan for image * Only scan Dockerfile * Fix report upload * Bump KICS version
1 parent aa24deb commit 25aefb1

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

.github/workflows/validate.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ jobs:
2525
with:
2626
dockerfile: Dockerfile
2727

28+
# Scan the Dockerfile with KICS to check for security issues.
29+
- name: Docker Scan
30+
uses: Checkmarx/kics-github-action@v2.1.10
31+
with:
32+
path: Dockerfile
33+
fail_on: high,medium
34+
output_path: results
35+
output_formats: 'json,sarif'
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
# Upload the results of the KICS scan as a build artifact.
40+
- name: Upload SARIF file
41+
uses: github/codeql-action/upload-sarif@v2
42+
with:
43+
sarif_file: results/results.sarif
44+
2845
test:
2946
runs-on: ubuntu-latest
3047
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
# Environments
77
venv/
88
virtualenv/
9+
10+
# Security Artifacts
11+
results.json

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contribution Guide
2+
3+
Contributions in the form of issues and pull requests are welcome. Please read the following guidelines before contributing.
4+
5+
## Pre-commit Hooks
6+
7+
This project uses [pre-commit](https://pre-commit.com/) to run a series of checks before committing code. To install the pre-commit hooks, run the following command:
8+
9+
```bash
10+
pre-commit install
11+
```
12+
13+
Run the following command to run the pre-commit hooks on all files:
14+
15+
```bash
16+
pre-commit run --all-files
17+
```
18+
19+
## Security Testing
20+
21+
This project uses [KICS](https://docs.kics.io/latest/getting-started/) to scan for security issues in the infrastructure such as the `Dockerfile`. To run the scan, run the following command:
22+
23+
```bash
24+
docker run -t -v $(pwd):/path checkmarx/kics:latest scan -p /path/Dockerfile -o "/path/"
25+
```
26+
27+
This will generate a `results.json` file as well as print the contents to the console. Any findings above a `low` severity should be addressed before committing code as they will fail the CI pipeline.

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ WORKDIR /opt/workspace
1212
# Copy in the entrypoint file
1313
COPY entrypoint.py /opt/workspace/entrypoint.py
1414

15+
# Setup a user with the appropriate permissions
16+
RUN useradd -ms /bin/bash case &&\
17+
chown -R case:case /opt/workspace
18+
USER case
19+
1520
# Define the base path for the validation path
1621
ENV CASE_PATH="/opt/json/"
1722
ENV CASE_VERSION="case-1.4.0"

0 commit comments

Comments
 (0)