Skip to content

Commit

Permalink
resetting the cargo audit variable and fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lander86 committed Jul 20, 2021
1 parent 2a64aa2 commit 0775658
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ script: ci/script.sh
jobs:
include:
- name: bionic_rust-1.51.0_latest
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='000,001,002,004' ENABLE_CARGO_AUDIT="$ENABLE_CARGO_AUDIT"
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='000,001,002,004'
2 changes: 1 addition & 1 deletion ci/devtools/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ -n "${RUSTFLAGS:-}" ] ||
[ -n "${CARGOARGS:-}" ] ||
[ -n "${RUST_CROSS_TARGETS:-}" ] ||
[ -n "${ENABLE_CARGO_AUDIT:-}" ] ||
[ -n "${CARGO_AUDIT_EXIT_ON_ERROR:-}" ] ||
[ -n "${RUSTUP_TOOLCHAIN:-}" ] &&
exec -c "$0"

Expand Down
4 changes: 2 additions & 2 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ DOCKER_ORG="${DOCKER_ORG:-zencash}"
IMAGE_NAME="${IMAGE_NAME:-sc-ci-base}"
IMAGE_TAG="${IMAGE_TAG:-bionic_rust-stable_latest}"
image="${DOCKER_ORG}/${IMAGE_NAME}:${IMAGE_TAG}"
ENABLE_CARGO_AUDIT="${ENABLE_CARGO_AUDIT}"
CARGO_AUDIT_EXIT_ON_ERROR="${ENABLE_CARGO_AUDIT:-true}"

# run tests in docker or natively
if [ -n "${TESTS:-}" ]; then
if [ "$have_docker" = "true" ]; then
docker run --rm -t -v "$workdir":/build --entrypoint /build/ci/docker/entrypoint.sh -e TESTS -e ENABLE_CARGO_AUDIT -e LOCAL_USER_ID="$(id -u)" \
docker run --rm -t -v "$workdir":/build --entrypoint /build/ci/docker/entrypoint.sh -e TESTS -e CARGO_AUDIT_EXIT_ON_ERROR -e LOCAL_USER_ID="$(id -u)" \
-e LOCAL_GRP_ID="$(id -g)" --env-file <(env | grep -E '^(RUSTFLAGS=|CARGOARGS=|RUST_CROSS_TARGETS=|RUSTUP_TOOLCHAIN=).+$') \
"$image" /build/ci/run_tests.sh
else
Expand Down
18 changes: 8 additions & 10 deletions ci/tests/004-cargo-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ echo "start cargo audit" && cargo audit --json > /tmp/audit.json
cat /tmp/audit.json | jq .


VULNERABILITIES=$(jq .vulnerabilities.found /tmp/audit.json)
VULNERABILITIES=$(jq '.vulnerabilities.found' /tmp/audit.json)


if [[ "$ENABLE_CARGO_AUDIT" != "enabled" ]]
then
echo "Cargo audit disabled"
elif [[ "$VULNERABILITIES" = true ]]
then
echo "Vulnerabilities have been found"
cat /tmp/audit.json | jq .vulnerabilities
exit 1
if [ "$CARGO_AUDIT_EXIT_ON_ERROR" = false ]; then
echo "Cargo audit disabled"
elif [ "$VULNERABILITIES" = true ]; then
echo "Vulnerabilities have been found"
cat /tmp/audit.json | jq '.vulnerabilities'
exit 1
else
echo "No vulnerabilities have been found"
echo "No vulnerabilities have been found"
fi

0 comments on commit 0775658

Please sign in to comment.