forked from DataDog/guarddog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile to test legit and malicious packages to avoid triggeri…
…ng AV
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM python:3.10.11-bullseye | ||
|
||
# gcc and musl-dev needed for the pip install | ||
RUN apt update && apt install -y gcc musl-dev g++ libffi-dev libgit2-dev | ||
RUN pip install guarddog | ||
RUN apt install -y git jq unzip | ||
|
||
# Download ~954 malicious pypi packages | ||
COPY download_malicious_pypi_package.sh /opt/ | ||
RUN /bin/sh /opt/download_malicious_pypi_package.sh /opt/malicious_pypi_package/ | ||
ENV MALICIOUS_PYPI_PACKAGE="/opt/malicious_pypi_package/" | ||
|
||
# Download legitimate top 1000 pypi packages | ||
COPY download_legit_pypi_package.sh /opt/ | ||
RUN /bin/sh /opt/download_legit_pypi_package.sh /opt/legit_pypi_package/ | ||
ENV LEGIT_PYPI_PACKAGE="/opt/legit_pypi_package/" | ||
|
||
COPY run_test.sh /tmp/ | ||
ENTRYPOINT ["/bin/sh", "/tmp/run_test.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
runtest="$1" | ||
|
||
if [ -z "$runtest" ]; then | ||
echo "Add argument to specify the tests (false_positive, false_negative, all)" | ||
exit 0 | ||
fi | ||
|
||
if [ "$runtest" = "false_positive" ] || [ "$runtest" = "all" ]; then | ||
echo "## Test - False Positives" | ||
guarddog pypi scan "$LEGIT_PYPI_PACKAGE" --output-format json | jq -c '.[]' | grep -v '"issues":0' | ||
fi | ||
|
||
if [ "$runtest" = "false_negative" ] || [ "$runtest" = "all" ]; then | ||
echo "## Test - False Negatives" | ||
guarddog pypi scan "$MALICIOUS_PYPI_PACKAGE" --output-format json | jq -c '.[]' | grep '"issues":0' | ||
fi | ||
|
||
|