Skip to content

Commit

Permalink
Add bash script to run test locally + rename the old file
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-dd committed May 5, 2023
1 parent 56b8481 commit f26aa32
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/samples/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ 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"]
COPY docker_run_test.sh /tmp/
ENTRYPOINT ["/bin/sh", "docker_run_test.sh"]
File renamed without changes.
24 changes: 24 additions & 0 deletions tests/samples/local_run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

runtest="$1"
scan_dir="$2"

if [ -z "$runtest" ] || [ -z "$scan_dir" ]; then
echo "Add argument to specify the tests you want to do (false_positive, false_negative, all)"
echo "and add a directory to scan"
exit 0
fi

if [ "$runtest" = "false_positive" ] || [ "$runtest" = "all" ]; then
echo "[+] ## Test - False Positives"
guarddog pypi scan "${scan_dir}" --output-format json | jq -c '.[]' | grep -v '"issues":0' > false_positive_result.json
echo "[+] Result exported in false_positive_result.json"
fi

if [ "$runtest" = "false_negative" ] || [ "$runtest" = "all" ]; then
echo "[+] ## Test - False Negatives"
guarddog pypi scan "${scan_dir}" --output-format json | jq -c '.[]' | grep '"issues":0' > false_negative_result.json
echo "[+] Result exported in false_negative_result.json"
fi


0 comments on commit f26aa32

Please sign in to comment.