Skip to content

roxctl exit code (image check) #21616

Description

@mtcolman

Hi, other tools (e.g., gitleaks) that I've used allow me to specify via flag the exit-code to use if there are findings, to differentiate it from exit code 1 that is normally associated with a command failure.

Is it possible to introduce this for roxctl image check (and maybe other subcommands?).

The scenario I want to handle is (where I set the exit code if there are policy violations to be 2:

roxctl image check <rest of command>
EXIT_CODE=$?
if [ $EXIT_CODE -eq 2 ]; then
  printf "There are policy violations"
  cat /workspace/roxctl-check.json
elif [ $EXIT_CODE -eq 1 ]; then
  printf "ERROR: roxctl image check failed with exit code %d\n" $EXIT_CODE
  printf -- "--- roxctl stderr ---\n"
  cat "$CHECK_STDERR"
  printf -- "--- end roxctl stderr ---\n"
  rm -f "$CHECK_STDERR"
  exit 1
fi

At the moment, any policy violations give exit code 1 and thus my code exits. This means (as I'm using this in OpenShift Pipelines) my task and therefore my pipeline is marked as failed.

The default value for the exit code for policy violations or command error can still be 1, so as not to break for existing user code, however allowing me to override policy finding exit code via flag would be very useful for automation scripts

Thanks!

(Currently using roxctl 4.11.1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions