File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,14 +91,24 @@ trivy --version
9191# of how trivy is invoked (login shell, non-interactive sh -c, etc.).
9292mkdir -p " ${TRIVY_HOME} "
9393mv /usr/local/bin/trivy /usr/local/bin/trivy-real
94- cat > /usr/local/bin/trivy << WRAPPER
94+ cat > /usr/local/bin/trivy << ' WRAPPER '
9595#!/bin/sh
96- export TRIVY_HOME="\$ {TRIVY_HOME:-${TRIVY_HOME} }"
97- exec /usr/local/bin/trivy-real "\$ @"
96+ TRIVY_HOME="${TRIVY_HOME:-/usr/local/share/trivy}"
97+ export TRIVY_HOME
98+ # Ensure the current user's .trivy points to the shared TRIVY_HOME
99+ # so plugins installed at build time are available to all users.
100+ if [ ! -e "$HOME/.trivy" ]; then
101+ ln -sf "$TRIVY_HOME" "$HOME/.trivy" 2>/dev/null || true
102+ fi
103+ exec /usr/local/bin/trivy-real "$@"
98104WRAPPER
99105chmod +x /usr/local/bin/trivy
100106export TRIVY_HOME
101107
108+ # Symlink root's .trivy to TRIVY_HOME so that plugin installs during
109+ # the build are written to the shared location.
110+ ln -sf " ${TRIVY_HOME} " /root/.trivy
111+
102112# Install plugins if specified
103113if [ -n " ${TRIVY_PLUGINS} " ]; then
104114 echo " Installing Trivy plugins..."
You can’t perform that action at this time.
0 commit comments