Skip to content

Commit 66008a8

Browse files
committed
Added Grype and Syft Docker, fixed cdk-nag
1 parent 42e26db commit 66008a8

File tree

7 files changed

+55
-11
lines changed

7 files changed

+55
-11
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ The security helper supports the following vectors:
2222
* Git
2323
* **[git-secrets](https://github.com/awslabs/git-secrets)** - Find api keys, passwords, AWS keys in the code
2424
* Python
25-
* **[bandit](https://github.com/PyCQA/bandit)** - Find common security issues in the code.
25+
* **[bandit](https://github.com/PyCQA/bandit)** - finds common security issues in Python code.
26+
* **[Grype](https://github.com/anchore/grype)** - finds vulnerabilities scanner for Python code.
27+
* **[Syft](https://github.com/anchore/grype)** - generating a Software Bill of Materials (SBOM) for Python code.
2628
* Jupyter Notebook
27-
* **[nbconvert](https://nbconvert.readthedocs.io/en/latest/)** - converts ipynb files into Python executables. Code scan with Bandit.
29+
* **[nbconvert](https://nbconvert.readthedocs.io/en/latest/)** - converts Jupyter Notebook (ipynb) files into Python executables. Code scan with Bandit.
2830
* JavaScript; NodeJS
2931
* **[npm-audit](https://docs.npmjs.com/cli/v8/commands/npm-audit)** - checks for vulnerabilities in Javascript and NodeJS.
32+
* **[Grype](https://github.com/anchore/grype)** - finds vulnerabilities scanner for Javascript and NodeJS.
33+
* **[Syft](https://github.com/anchore/grype)** - generating a Software Bill of Materials (SBOM) for Javascript and NodeJS.
3034
* Infrastructure
3135
* Teraform; Cloudformation
3236
* **[checkov](https://github.com/bridgecrewio/checkov)**

ash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PY_EXTENSIONS=("py" "pyc" "ipynb")
2626
INFRA_EXTENSIONS=("yaml" "yml" "tf" "json" "dockerfile")
2727
CFN_EXTENSIONS=("yaml" "yml" "json")
2828
JS_EXTENSIONS=("js")
29+
GRYPE_EXTENSIONS=("js" "py")
2930

3031
# Look for specific files
3132
CDK_FILENAMES=("cdk.json")
@@ -232,6 +233,7 @@ run_security_check "Dockerfile-yaml" "${INFRA_EXTENSIONS[@]}"
232233
run_security_check "Dockerfile-js" "${JS_EXTENSIONS[@]}"
233234
search_file_content "${CFN_EXTENSIONS}" || echo "No CFN files found"
234235
run_security_check "Dockerfile-cdk" "${CFN_EXTENSIONS[@]}"
236+
run_security_check "Dockerfile-grype" "${GRYPE_EXTENSIONS[@]}"
235237

236238
# Cleanup any previous file
237239
rm -f "${OUTPUT_DIR}"/"${AGGREGATED_RESULTS_REPORT_FILENAME}"

helper_dockerfiles/Dockerfile-grype

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Get Python Image
2+
FROM public.ecr.aws/bitnami/python:latest
3+
4+
# Instal prerequisites
5+
RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin && \
6+
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
7+
8+
WORKDIR /app
9+
VOLUME /app
10+
11+
CMD bash -C /utils/grype-docker-execute.sh

helper_dockerfiles/Dockerfile-py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ FROM public.ecr.aws/bitnami/python:latest
33

44
# Instal prerequisites
55
RUN pip install --no-cache-dir --upgrade pip && \
6-
pip install --no-cache-dir bandit nbconvert jupyterlab && \
7-
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
6+
pip install --no-cache-dir bandit nbconvert jupyterlab
87

98
WORKDIR /app
109
VOLUME /app
1110

12-
CMD bash -C /utils/py-docker-execute.sh
11+
CMD bash -C /utils/py-docker-execute.sh

utils/cfn-to-cdk/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
aws-cdk-lib<3.0.0,>=2.18.0
21
constructs>=10.0.0,<11.0.0
32
jsii>=1.60.1

utils/grype-docker-execute.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
abs() { # compute the absolute value of the input parameter
4+
input=$1
5+
if [[ $input -lt 0 ]]; then
6+
input=$((-input))
7+
fi
8+
echo $input
9+
}
10+
11+
bumprc() { # return the higher absolute value of the inputs
12+
output=$1
13+
if [[ $2 -ne 0 ]]; then
14+
lrc=$(abs $2)
15+
16+
if [[ $lrc -gt $1 ]]; then
17+
output=$lrc
18+
fi
19+
fi
20+
echo $output
21+
}
22+
23+
RC=0
24+
25+
26+
grype dir:. > grype_report_result.txt 2>&1
27+
SRC=$?
28+
RC=$(bumprc $RC $SRC)
29+
30+
syft . >> grype_report_result.txt 2>&1
31+
SRC=$?
32+
RC=$(bumprc $RC $SRC)
33+
34+
exit $RC

utils/py-docker-execute.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,4 @@ BRC=$?
3030
RC=$(bumprc $RC $BRC)
3131

3232

33-
grype dir:. >> py_report_result.txt 2>&1
34-
SRC=$?
35-
RC=$(bumprc $RC $SRC)
36-
37-
3833
exit $RC

0 commit comments

Comments
 (0)