Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/stackhpc-container-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:

- name: Install Trivy
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.49.0
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.69.2

- name: Install yq
run: |
Expand Down
2 changes: 1 addition & 1 deletion tools/scan-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -u

# Check that trivy is installed
if ! trivy --version; then
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.49.1'
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.69.2'
fi
Comment on lines 13 to 15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current check for trivy can be improved for robustness and better user experience.

  • If trivy is installed, trivy --version prints its output to stdout, which can be noisy.
  • If trivy is not installed, the script prints a message but continues, failing later on. This can be confusing for the user.
  • Diagnostic messages should be printed to stderr, not stdout.

The suggested change addresses these points by silencing the version check, exiting immediately if trivy is not found, and printing messages to stderr.

Suggested change
if ! trivy --version; then
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.49.1'
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.69.2'
fi
if ! trivy --version >/dev/null 2>&1; then
echo "Error: trivy not found. Please install v0.69.2:" >&2
echo 'curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.69.2' >&2
exit 1
fi


# Clear any previous outputs
Expand Down