-
Couldn't load subscription status.
- Fork 46
feat: rename enterprise-* images to example-* while maintaining backward compatibility #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,58 +103,103 @@ trivy_tmp_dir="$(mktemp -d -p "$PROJECT_ROOT")" | |
|
|
||
| trap 'rm -rf "$tmp_dir" "$trivy_tmp_dir"' EXIT | ||
|
|
||
| # Scan both example and enterprise images | ||
| for image in "${IMAGES[@]}"; do | ||
| image_ref="codercom/enterprise-${image}:${TAG}" | ||
| image_name="${image}-${TAG}" | ||
| output="${tmp_dir}/${image}-${TAG}.sarif" | ||
|
|
||
| if ! docker image inspect "$image_ref" >/dev/null 2>&1; then | ||
| echo "Image '$image_ref' does not exist locally; skipping" >&2 | ||
| continue | ||
| fi | ||
|
|
||
| old_tmpdir="${TMPDIR:-}" | ||
| export TMPDIR="$trivy_tmp_dir" | ||
|
|
||
| # The timeout is set to 15 minutes because in Java images it can take a while | ||
| # to scan JAR files for vulnerabilities. | ||
| run_trace $DRY_RUN trivy image \ | ||
| --severity CRITICAL,HIGH \ | ||
| --format sarif \ | ||
| --output "$output" \ | ||
| --timeout 15m0s \ | ||
| "$image_ref" 2>&1 | indent | ||
|
|
||
| if [ "$old_tmpdir" = "" ]; then | ||
| unset TMPDIR | ||
| # Process example images (primary) | ||
|
||
| example_image_ref="codercom/example-${image}:${TAG}" | ||
| example_image_name="example-${image}-${TAG}" | ||
| example_output="${tmp_dir}/example-${image}-${TAG}.sarif" | ||
|
|
||
| if docker image inspect "$example_image_ref" >/dev/null 2>&1; then | ||
| old_tmpdir="${TMPDIR:-}" | ||
| export TMPDIR="$trivy_tmp_dir" | ||
|
|
||
| # The timeout is set to 15 minutes because in Java images it can take a while | ||
| # to scan JAR files for vulnerabilities. | ||
| run_trace $DRY_RUN trivy image \ | ||
| --severity CRITICAL,HIGH \ | ||
| --format sarif \ | ||
| --output "$example_output" \ | ||
| --timeout 15m0s \ | ||
| "$example_image_ref" 2>&1 | indent | ||
|
|
||
| if [ "$old_tmpdir" = "" ]; then | ||
| unset TMPDIR | ||
| else | ||
| export TMPDIR="$old_tmpdir" | ||
| fi | ||
|
|
||
| if [ $DRY_RUN = false ] && [ -f "$example_output" ]; then | ||
| # Do substitutions to add extra details to every message. Without these | ||
| # substitutions, most messages won't have any information about which image | ||
| # the vulnerability was found in. | ||
| jq \ | ||
| ".runs[].tool.driver.name |= \"Trivy ${example_image_name}\"" \ | ||
| "$example_output" >"$example_output.tmp" | ||
| mv "$example_output.tmp" "$example_output" | ||
| jq \ | ||
| ".runs[].results[].locations[].physicalLocation.artifactLocation.uri |= \"${example_image_name}/\" + ." \ | ||
| "$example_output" >"$example_output.tmp" | ||
| mv "$example_output.tmp" "$example_output" | ||
| jq \ | ||
| ".runs[].results[].locations[].message.text |= \"${example_image_name}: \" + ." \ | ||
| "$example_output" >"$example_output.tmp" | ||
| mv "$example_output.tmp" "$example_output" | ||
| elif [ $DRY_RUN = false ]; then | ||
| echo "No SARIF output found for image '$example_image_ref' at '$example_output'" >&2 | ||
| exit 1 | ||
| fi | ||
| else | ||
| export TMPDIR="$old_tmpdir" | ||
| echo "Image '$example_image_ref' does not exist locally; skipping" >&2 | ||
| fi | ||
|
|
||
| if [ $DRY_RUN = true ]; then | ||
| continue | ||
| fi | ||
|
|
||
| if [ ! -f "$output" ]; then | ||
| echo "No SARIF output found for image '$image_ref' at '$output'" >&2 | ||
| exit 1 | ||
| # Process enterprise images (alias) | ||
| enterprise_image_ref="codercom/enterprise-${image}:${TAG}" | ||
| enterprise_image_name="enterprise-${image}-${TAG}" | ||
| enterprise_output="${tmp_dir}/enterprise-${image}-${TAG}.sarif" | ||
|
|
||
| if docker image inspect "$enterprise_image_ref" >/dev/null 2>&1; then | ||
| old_tmpdir="${TMPDIR:-}" | ||
| export TMPDIR="$trivy_tmp_dir" | ||
|
|
||
| # The timeout is set to 15 minutes because in Java images it can take a while | ||
| # to scan JAR files for vulnerabilities. | ||
| run_trace $DRY_RUN trivy image \ | ||
| --severity CRITICAL,HIGH \ | ||
| --format sarif \ | ||
| --output "$enterprise_output" \ | ||
| --timeout 15m0s \ | ||
| "$enterprise_image_ref" 2>&1 | indent | ||
|
|
||
| if [ "$old_tmpdir" = "" ]; then | ||
| unset TMPDIR | ||
| else | ||
| export TMPDIR="$old_tmpdir" | ||
| fi | ||
|
|
||
| if [ $DRY_RUN = false ] && [ -f "$enterprise_output" ]; then | ||
| # Do substitutions to add extra details to every message. Without these | ||
| # substitutions, most messages won't have any information about which image | ||
| # the vulnerability was found in. | ||
| jq \ | ||
| ".runs[].tool.driver.name |= \"Trivy ${enterprise_image_name}\"" \ | ||
| "$enterprise_output" >"$enterprise_output.tmp" | ||
| mv "$enterprise_output.tmp" "$enterprise_output" | ||
| jq \ | ||
| ".runs[].results[].locations[].physicalLocation.artifactLocation.uri |= \"${enterprise_image_name}/\" + ." \ | ||
| "$enterprise_output" >"$enterprise_output.tmp" | ||
| mv "$enterprise_output.tmp" "$enterprise_output" | ||
| jq \ | ||
| ".runs[].results[].locations[].message.text |= \"${enterprise_image_name}: \" + ." \ | ||
| "$enterprise_output" >"$enterprise_output.tmp" | ||
| mv "$enterprise_output.tmp" "$enterprise_output" | ||
| elif [ $DRY_RUN = false ]; then | ||
| echo "No SARIF output found for image '$enterprise_image_ref' at '$enterprise_output'" >&2 | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Image '$enterprise_image_ref' does not exist locally; skipping" >&2 | ||
| fi | ||
|
|
||
| # Do substitutions to add extra details to every message. Without these | ||
| # substitutions, most messages won't have any information about which image | ||
| # the vulnerability was found in. | ||
| jq \ | ||
| ".runs[].tool.driver.name |= \"Trivy ${image_name}\"" \ | ||
| "$output" >"$output.tmp" | ||
| mv "$output.tmp" "$output" | ||
| jq \ | ||
| ".runs[].results[].locations[].physicalLocation.artifactLocation.uri |= \"${image_name}/\" + ." \ | ||
| "$output" >"$output.tmp" | ||
| mv "$output.tmp" "$output" | ||
| jq \ | ||
| ".runs[].results[].locations[].message.text |= \"${image_name}: \" + ." \ | ||
| "$output" >"$output.tmp" | ||
| mv "$output.tmp" "$output" | ||
| done | ||
|
|
||
| # Merge all SARIF files into one. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between example and enterprise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same it is just that we expect people to use these images even if not enterprise users