Skip to content

refactor: change images README from enterprise- to example- (pt 2) #303

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions images/base/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Enterprise Base
# Example Base

[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/enterprise-base?label=codercom%2Fenterprise-base)](https://hub.docker.com/r/codercom/enterprise-base)
[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/example-base?label=codercom%2Fexample-base)](https://hub.docker.com/r/codercom/example-base)

## Description

Expand Down
4 changes: 2 additions & 2 deletions images/desktop/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Desktop

[![DockerPulls](https://img.shields.io/docker/pulls/codercom/enterprise-desktop)](https://hub.docker.com/r/codercom/enterprise-desktop)
[![DockerPulls](https://img.shields.io/docker/pulls/codercom/example-desktop)](https://hub.docker.com/r/codercom/example-desktop)

## Description

Wraps [enterprise-base](../base/README.md) with a xfce desktop environment.
Wraps [example-minimal](../minimal/README.md) with a xfce desktop environment.

> **Note:** This image does not contain a vnc-server.
> A VNC server can be added by using the [KasmVNC](https://registry.coder.com/modules/kasmvnc) module.
Expand Down
2 changes: 1 addition & 1 deletion images/desktop/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codercom/enterprise-minimal:latest
FROM codercom/example-minimal:latest

USER root

Expand Down
4 changes: 2 additions & 2 deletions images/golang/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Golang

[![DockerPulls](https://img.shields.io/docker/pulls/codercom/enterprise-golang)](https://hub.docker.com/r/codercom/enterprise-golang)
[![DockerPulls](https://img.shields.io/docker/pulls/codercom/example-golang)](https://hub.docker.com/r/codercom/example-golang)

## Description

Wraps [enterprise-base](../base/README.md) with the basics for Go development.
Wraps [example-base](../base/README.md) with the basics for Go development.

> **Note:** This image does not contain GoLand. For an example of how to install
> GoLand, see [enterprise-goland](../../deprecated/goland/README.md)
Expand Down
2 changes: 1 addition & 1 deletion images/golang/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codercom/enterprise-base:ubuntu
FROM codercom/example-base:ubuntu

# Run everything as root
USER root
Expand Down
4 changes: 2 additions & 2 deletions images/java/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Java

[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/enterprise-java?label=codercom%2Fenterprise-java)](https://hub.docker.com/r/codercom/enterprise-java)
[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/example-java?label=codercom%2Fexample-java)](https://hub.docker.com/r/codercom/example-java)

## Description

Wraps [enterprise-base](../base/README.md) with the basics for Java development.
Wraps [example-base](../base/README.md) with the basics for Java development.

> **Note:** This image does not contain IntelliJ. For an example of how to
> install IntelliJ, see [enterprise-intellij](../../deprecated/intellij/README.md)
Expand Down
2 changes: 1 addition & 1 deletion images/java/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codercom/enterprise-base:ubuntu
FROM codercom/example-base:ubuntu

# Run everything as root
USER root
Expand Down
4 changes: 3 additions & 1 deletion images/minimal/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Minimal Image
# Example Minimal

[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/example-minimal?label=codercom%2Fexample-minimal)](https://hub.docker.com/r/codercom/example-minimal)

This image only contains the bare necessities:

Expand Down
4 changes: 2 additions & 2 deletions images/node/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Node

[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/enterprise-node?label=codercom%2Fenterprise-node)](https://hub.docker.com/r/codercom/enterprise-node)
[![Docker Pulls](https://img.shields.io/docker/pulls/codercom/example-node?label=codercom%2Fexample-node)](https://hub.docker.com/r/codercom/example-node)

## Description

Wraps [enterprise-base](../base/README.md) with the basics for Node development.
Wraps [example-base](../base/README.md) with the basics for Node development.

## How To Use

Expand Down
2 changes: 1 addition & 1 deletion images/node/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codercom/enterprise-base:ubuntu
FROM codercom/example-base:ubuntu

# Run everything as root
USER root
Expand Down
109 changes: 75 additions & 34 deletions scripts/scan_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,14 @@ trivy_tmp_dir="$(mktemp -d -p "$PROJECT_ROOT")"

trap 'rm -rf "$tmp_dir" "$trivy_tmp_dir"' EXIT

PREFIXES=("example" "enterprise")

# Scan both example and enterprise images
for image in "${IMAGES[@]}"; do
for prefix in "${PREFIXES[@]}"; do
image_ref="codercom/${prefix}-${image}:${TAG}"
image_name="${prefix}-${image}-${TAG}"
output="${tmp_dir}/${prefix}-${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
# 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"

Expand All @@ -124,41 +119,87 @@ for image in "${IMAGES[@]}"; do
run_trace $DRY_RUN trivy image \
--severity CRITICAL,HIGH \
--format sarif \
--output "$output" \
--output "$example_output" \
--timeout 15m0s \
"$image_ref" 2>&1 | indent
"$example_image_ref" 2>&1 | indent

if [ "$old_tmpdir" = "" ]; then
unset TMPDIR
else
export TMPDIR="$old_tmpdir"
fi

if [ $DRY_RUN = true ]; then
continue
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
echo "Image '$example_image_ref' does not exist locally; skipping" >&2
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

# 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
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
done

# Merge all SARIF files into one.
Expand Down
Loading