anchore / ci-tools

Contains scripts for running anchore engine in CI pipelines
Apache License 2.0
34 stars 33 forks source link

Reports are not copied into workspace when inline_scan is invoked with both -r and -f #24

Closed ggolawski closed 4 years ago

ggolawski commented 4 years ago

The problem When I run inline_scan with both -r and -f and if the policy evaluation fails, the reports are not copied from container to workspace. If policy evaluation is successful, the reports are copied from container into the workspace.

Details It looks like that if -f option is passed, scan exits with 1 and the following code from start_vuln_scan() is not executed:

if [[ "${r_flag}" ]]; then
  echo "Copying scan reports from ${DOCKER_NAME} to ${PWD}/anchore-reports/"
  docker cp "${DOCKER_NAME}:/anchore-engine/anchore-reports/" ./
fi

Actual Behaviour Reports are not copied from the container and anchore-reports directory in my workspace is empty.

Expected Behaviour Reports should be copied from container into anchore-reports directory in the workspace.

How do you reproduce the error?

curl -s [...]/inline_scan-v0.6.0 | bash -s -- -f -r -d Dockerfile -b anchore-policy.json IMAGE:TAG"

If the policy evaluation fails, the anchore-reports directory in my workspace is empty.

Karreg commented 4 years ago

Confirmed on my side.

Reports should be copied even in case of failure, it would make more sense to know why a scan has failed :)

Karreg commented 4 years ago

I opened a PR to fix the issue...