diff --git a/bitnami/sonarqube/26/debian-12/Dockerfile b/bitnami/sonarqube/26/debian-12/Dockerfile index f85be205643a..d7dc0f354ea8 100644 --- a/bitnami/sonarqube/26/debian-12/Dockerfile +++ b/bitnami/sonarqube/26/debian-12/Dockerfile @@ -8,7 +8,7 @@ ARG JAVA_EXTRA_SECURITY_DIR="/bitnami/java/extra-security" ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2026-05-23T11:40:49Z" \ + org.opencontainers.image.created="2026-06-01T09:55:59Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/sonarqube/README.md" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/sonarqube" \ @@ -36,12 +36,12 @@ RUN --mount=type=secret,id=downloads_url,env=SECRET_DOWNLOADS_URL \ for COMPONENT in "${COMPONENTS[@]}"; do \ if [ ! -f "${COMPONENT}.tar.gz" ]; then \ curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz" -O ; \ - curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz.sha256" -O ; \ fi ; \ - sha256sum -c "${COMPONENT}.tar.gz.sha256" ; \ + sha256sum -c "/opt/bitnami/checksums/${COMPONENT}.tar.gz.sha256" ; \ tar -zxf "${COMPONENT}.tar.gz" -C /opt/bitnami --strip-components=2 --no-same-owner ; \ - rm -rf "${COMPONENT}".tar.gz{,.sha256} ; \ - done + rm -rf "${COMPONENT}".tar.gz ; \ + done ; \ + rm -rf /opt/bitnami/checksums ; RUN apt-get update && apt-get upgrade -y && \ apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives RUN chmod g+rwX /opt/bitnami @@ -52,7 +52,7 @@ RUN /opt/bitnami/scripts/java/postunpack.sh RUN /opt/bitnami/scripts/sonarqube/postunpack.sh ENV APP_VERSION="26.4.0" \ BITNAMI_APP_NAME="sonarqube" \ - IMAGE_REVISION="5" \ + IMAGE_REVISION="6" \ JAVA_HOME="/opt/bitnami/java" \ LD_LIBRARY_PATH="/opt/bitnami/postgresql/lib:$LD_LIBRARY_PATH" \ PATH="/opt/bitnami/postgresql/bin:/opt/bitnami/java/bin:$PATH" diff --git a/bitnami/sonarqube/26/debian-12/docker-compose.yml b/bitnami/sonarqube/26/debian-12/docker-compose.yml index de032ccc5c12..cc120489afc9 100644 --- a/bitnami/sonarqube/26/debian-12/docker-compose.yml +++ b/bitnami/sonarqube/26/debian-12/docker-compose.yml @@ -22,6 +22,7 @@ services: environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes + - SONARQUBE_PASSWORD=Bitnami#1234 - SONARQUBE_DATABASE_HOST=postgresql - SONARQUBE_DATABASE_PORT_NUMBER=5432 - SONARQUBE_DATABASE_USER=bn_sonarqube diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..a2d5622b6789 --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +fa2c3125d94154a3bc67bb7899c3fe231267ed4133d3931d1ce4864f915a6d0f java-21.0.11-11-2-linux-amd64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..7b22e6802aac --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/java-21.0.11-11-2-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +9bc5e94a5934ab91f797a5cb1f1f0bdd8917ae676a21806b4394887a367eb836 java-21.0.11-11-2-linux-arm64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..b7ca2505b7c2 --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +94f47dda1a262952f801352ae6ba0c640a279384451c50d5bdfd354af008d76e postgresql-client-18.4.0-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..9017a72f7b84 --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-18.4.0-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +b54111e298a44eacf4e41b1651c196d8aecd16f6b75b89c4a85c5e7f1a31bf26 postgresql-client-18.4.0-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..a2e0ac115e25 --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +2cd7fe2fa5ebbffcfa84cdd807379107abf2c1354bf7b8333ecfb2c2f2cfb161 sonarqube-26.4.0-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..270a5009aae5 --- /dev/null +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/checksums/sonarqube-26.4.0-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +9ff29e8472d4140c0d229ebe4951fb1db431e7f6ed195266287aa42897ed9302 sonarqube-26.4.0-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh index 1c69e0e48a5d..335c1c7c9ef7 100644 --- a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh @@ -139,3 +139,40 @@ wait_for_log_entry() { return 1 fi } + +######################## +# Creates a secure temporary file containing the provided secret +# Arguments: +# $1 - secret to write to the temporary file +# Returns: +# String +######################### +credential_to_temp_file() { + local secret="$1" + local tmp_file + + # Use mktemp with a specific prefix for easier debugging if something lingers + if ! tmp_file=$(mktemp "${TMPDIR:-/tmp}/at.cred.XXXXXXXX"); then + echo "Error: Failed to create temp file" >&2 + return 1 + fi + + # Restrict permissions before writing the secret + chmod 0600 "$tmp_file" + # Write secret and ensure it's flushed to disk + printf "%s" "$secret" > "$tmp_file" + # Output the filename so the caller can capture it + echo "$tmp_file" +} + +######################## +# Cleans up temporary files created by credential_to_temp_file +# Arguments: +# None +# Returns: +# None +######################### +cleanup_credentials() { + debug "Cleaning up temporary files containing credentials" + rm -rf "${TMPDIR:-/tmp}"/at.cred.* +} diff --git a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh index 1337f6c2dd59..b16efabd3230 100644 --- a/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh +++ b/bitnami/sonarqube/26/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh @@ -131,6 +131,7 @@ relativize() { # -d|--dir-mode - mode for files. # -u|--user - user # -g|--group - group +# -n|--no-dereference - do not follow symlinks (use for runtime root chown of daemon-writable dirs) # Returns: # None ######################### @@ -140,6 +141,7 @@ configure_permissions_ownership() { local file_mode="" local user="" local group="" + local follow_symlinks="yes" # Validate arguments shift 1 @@ -161,6 +163,9 @@ configure_permissions_ownership() { shift group="${1:?missing group}" ;; + -n | --no-dereference) + follow_symlinks="no" + ;; *) echo "Invalid command line flag $1" >&2 return 1 @@ -169,22 +174,29 @@ configure_permissions_ownership() { shift done + # -L: follow symlinks and emits the target path + # This is dangerous at runtime, given a co-located lower-privileged process with write access + # to the target path can redirect the chown/chmod to arbitrary paths. Example: + # Lower-privileged process run: ln -s /etc /tmp/etc + # Then, setup.sh runs: configure_permissions_ownership --dir-mode 775 /tmp + local find_L_flag=(); [[ "$follow_symlinks" == "yes" ]] && find_L_flag=("-L") + # -h: changes symlink inode ownership without touching the target. + local chown_flags=(); [[ "$follow_symlinks" == "no" ]] && chown_flags=("-h") read -r -a filepaths <<<"$paths" for p in "${filepaths[@]}"; do if [[ -e "$p" ]]; then - find -L "$p" -printf "" if [[ -n $dir_mode ]]; then - find -L "$p" -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode" + find "${find_L_flag[@]}" "$p" -not -type l -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode" fi if [[ -n $file_mode ]]; then - find -L "$p" -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode" + find "${find_L_flag[@]}" "$p" -not -type l -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode" fi if [[ -n $user ]] && [[ -n $group ]]; then - find -L "$p" -print0 | xargs -r -0 chown "${user}:${group}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chown "${chown_flags[@]}" "${user}:${group}" elif [[ -n $user ]] && [[ -z $group ]]; then - find -L "$p" -print0 | xargs -r -0 chown "${user}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chown "${chown_flags[@]}" "${user}" elif [[ -z $user ]] && [[ -n $group ]]; then - find -L "$p" -print0 | xargs -r -0 chgrp "${group}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chgrp "${chown_flags[@]}" "${group}" fi else stderr_print "$p does not exist" diff --git a/bitnami/sonarqube/26/debian-12/rootfs/opt/bitnami/scripts/libsonarqube.sh b/bitnami/sonarqube/26/debian-12/rootfs/opt/bitnami/scripts/libsonarqube.sh index fcb7cb2cc7f2..1991445ffa4b 100644 --- a/bitnami/sonarqube/26/debian-12/rootfs/opt/bitnami/scripts/libsonarqube.sh +++ b/bitnami/sonarqube/26/debian-12/rootfs/opt/bitnami/scripts/libsonarqube.sh @@ -76,15 +76,30 @@ sonarqube_validate() { ! is_empty_value "$SONARQUBE_DATABASE_PORT_NUMBER" && check_valid_port "SONARQUBE_DATABASE_PORT_NUMBER" # Validate credentials + check_empty_value "SONARQUBE_PASSWORD" if is_boolean_yes "${ALLOW_EMPTY_PASSWORD:-}"; then warn "You set the environment variable ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD:-}. For safety reasons, do not use this flag in a production environment." else - for empty_env_var in "SONARQUBE_DATABASE_PASSWORD" "SONARQUBE_PASSWORD"; do - is_empty_value "${!empty_env_var}" && print_validation_error "The ${empty_env_var} environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow a blank password. This is only recommended for development environments." - done - if ! validate_string "$SONARQUBE_PASSWORD" -min-length 12; then - print_validation_error "SONARQUBE_PASSWORD must have at least 12 characters" - fi + is_empty_value "$SONARQUBE_DATABASE_PASSWORD" && print_validation_error "The SONARQUBE_DATABASE_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow a blank password. This is only recommended for development environments." + fi + # SonarQube enforces a local password policy for the built-in admin account. + # The password must be at least 12 characters long and contain at least one + # uppercase letter, one lowercase letter, one digit and one special character. + # Validating here avoids a cryptic HTTP 400 during the credentials bootstrap. + if ! validate_string "$SONARQUBE_PASSWORD" -min-length 12; then + print_validation_error "SONARQUBE_PASSWORD must have at least 12 characters" + fi + if [[ ! "$SONARQUBE_PASSWORD" =~ [[:upper:]] ]]; then + print_validation_error "SONARQUBE_PASSWORD must contain at least one uppercase character" + fi + if [[ ! "$SONARQUBE_PASSWORD" =~ [[:lower:]] ]]; then + print_validation_error "SONARQUBE_PASSWORD must contain at least one lowercase character" + fi + if [[ ! "$SONARQUBE_PASSWORD" =~ [[:digit:]] ]]; then + print_validation_error "SONARQUBE_PASSWORD must contain at least one digit" + fi + if [[ ! "$SONARQUBE_PASSWORD" =~ [^[:alnum:]] ]]; then + print_validation_error "SONARQUBE_PASSWORD must contain at least one special character" fi # Validate SMTP credentials @@ -152,7 +167,7 @@ sonarqube_initialize() { info "Ensuring SonarQube directories exist" ensure_dir_exists "$SONARQUBE_VOLUME_DIR" # Use daemon:root ownership for compatibility when running as a non-root user - am_i_root && configure_permissions_ownership "$SONARQUBE_VOLUME_DIR" -d "775" -f "664" -u "$SONARQUBE_DAEMON_USER" -g "root" + am_i_root && configure_permissions_ownership "$SONARQUBE_VOLUME_DIR" -d "775" -f "664" -u "$SONARQUBE_DAEMON_USER" -g "root" -n # Start SonarQube to initialize database, in order to be able to update users sonarqube_start_bg @@ -165,13 +180,17 @@ sonarqube_initialize() { local sonarqube_api_url="http://127.0.0.1:${SONARQUBE_PORT_NUMBER}/api" local -a curl_opts=( "--silent" + "--fail" "--request" "POST" "--user" "${sonarqube_default_username}:${sonarqube_default_password}" "--data-urlencode" "login=${sonarqube_default_username}" "--data-urlencode" "previousPassword=${sonarqube_default_password}" "--data-urlencode" "password=${SONARQUBE_PASSWORD}" ) - debug_execute curl "${curl_opts[@]}" "${sonarqube_api_url}/users/change_password" + if ! debug_execute curl "${curl_opts[@]}" "${sonarqube_api_url}/users/change_password"; then + error "Installation failed. Could not reach the SonarQube API to change the password" + exit 1 + fi # Update the username and email as well postgresql_remote_execute "${postgresql_execute_args[@]}" <