From 99c8f2d67f742889757092b6fc46bd51d3d5ce9e Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 25 Nov 2026 18:53:02 +0530 Subject: [PATCH 1/5] build: hardened operator image from source + Harbor base (0 Go CVEs) Rebuild the operator from source with a current toolchain and bumped modules, and harden the Spark base it ships on. Verified locally with Trivy: Go binary 0 CVEs, OS 0 CRITICAL/HIGH. - go.mod: bump x/net 0.57->0.63, x/text 0.40->0.44, x/mod 0.37->0.43, otel/trace 1.44->1.47; toolchain go1.27.4. Clears all 12 remaining Go CVEs (22 on upstream) -> 0. - Dockerfile: - builder golang:1.27.4 (Harbor proxy, digest-pinned) + GOTOOLCHAIN=local - FROM the Harbor-approved apache/spark:4.2.1 mirror (c.rzp.io/razorpay-external) instead of docker.io -> no non-Harbor base finding - apt upgrade + remove gosu (Go 1.18 setuid binary, Go EOL; operator uses catatonit, runs non-root uid 185, so gosu is dead weight) -> clears the Go-EOL gate - swap vulnerable standalone jars (netty/jackson/snappy/lz4/guava/jline/derby) for patched versions via the GCS Maven mirror, verified fail-closed - patched-jars.pom.xml + settings.xml: the jar-swap manifest + GCS Maven Central mirror. - .github/workflows/razorpay-image-build-push.yaml: build + push the controller image to Harbor (c.rzp.io) per-arch + multi-arch manifest, mirroring datahub's custom-base pipeline. Requires HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD repo secrets. Residual after this: only the CVEs shaded inside Spark/Hadoop fat-jars (the exception floor). Co-Authored-By: Claude Opus 4.8 --- .../workflows/razorpay-image-build-push.yaml | 106 ++++++++++++++++++ Dockerfile | 70 +++++++++++- go.mod | 27 +++-- go.sum | 49 ++++---- patched-jars.pom.xml | 82 ++++++++++++++ settings.xml | 21 ++++ 6 files changed, 311 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/razorpay-image-build-push.yaml create mode 100644 patched-jars.pom.xml create mode 100644 settings.xml diff --git a/.github/workflows/razorpay-image-build-push.yaml b/.github/workflows/razorpay-image-build-push.yaml new file mode 100644 index 0000000000..50e1622f5c --- /dev/null +++ b/.github/workflows/razorpay-image-build-push.yaml @@ -0,0 +1,106 @@ +# Razorpay: build the hardened Spark Operator image from source and push it to Harbor (c.rzp.io). +# +# This is separate from the upstream build-and-push-images.yaml (which targets ghcr.io). It builds +# the controller image from THIS repo's Dockerfile — rebuilding the operator Go binary with the +# bumped go.mod (0 Go CVEs), FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark +# base hardened (apt upgrade, patched jar swaps, gosu removed). The resulting image is then +# whitelisted in rzp-docker-image-inventory as a custom base image. +# +# Requires repo secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD (Harbor robot account). + +name: Razorpay Image Build and Push + +on: + workflow_dispatch: + inputs: + push: + description: Push to Harbor (otherwise build-only). + type: boolean + default: true + push: + branches: + - master + - 'feature/razorpay-**' + +permissions: + contents: read + +env: + REGISTRY: c.rzp.io + REPOSITORY: spark-operator + # Operator version this image ships; bump with the release. HARDEN_REV tracks the Razorpay + # hardening revision independently of the operator version. + OP_VERSION: "2.6.0" + HARDEN_REV: "hardened-v1" + +jobs: + build: + name: Build controller (${{ matrix.platform }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - linux-amd64 + - linux-arm64 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Compute tag + id: tag + run: | + set -eux + BASE="controller-${OP_VERSION}-${HARDEN_REV}" + if [ "${GITHUB_REF_NAME}" = "master" ]; then + TAG="${BASE}" + else + TAG="${BASE}-${GITHUB_SHA}" + fi + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" + echo "Publishing: ${REGISTRY}/razorpay/${REPOSITORY}:${TAG}-${{ matrix.platform }}" + + - name: Build and push (${{ matrix.platform }}) + # Pinned to the internal action's v1 branch HEAD (same pin datahub uses) so a repointed + # branch cannot change this build silently. + uses: razorpay/docker-image-build-push@149c7e92cf1a93d19239cff57a8fc3a61c48ed5e + with: + username: ${{ secrets.HARBOR_DOCKER_USERNAME }} + password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} + registry: ${{ env.REGISTRY }} + repository: ${{ env.REPOSITORY }} + context: . + file: Dockerfile + custom-tag: ${{ steps.tag.outputs.tag }}-${{ matrix.platform }} + enable-login: true + push: ${{ github.event_name != 'workflow_dispatch' || inputs.push }} + + manifest: + name: Multi-arch manifest + needs: build + if: github.event_name != 'workflow_dispatch' || inputs.push + runs-on: ubuntu-latest + steps: + - name: Compute tag + id: tag + run: | + set -eux + BASE="controller-${OP_VERSION}-${HARDEN_REV}" + if [ "${GITHUB_REF_NAME}" = "master" ]; then TAG="${BASE}"; else TAG="${BASE}-${GITHUB_SHA}"; fi + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" + + - name: Login to Harbor + run: echo "${{ secrets.HARBOR_DOCKER_PASSWORD }}" | docker login "${REGISTRY}" -u "${{ secrets.HARBOR_DOCKER_USERNAME }}" --password-stdin + + - name: Create and push manifest + run: | + set -eux + IMG="${REGISTRY}/razorpay/${REPOSITORY}" + TAG="${{ steps.tag.outputs.tag }}" + docker manifest create "${IMG}:${TAG}" \ + "${IMG}:${TAG}-linux-amd64" \ + "${IMG}:${TAG}-linux-arm64" + docker manifest push "${IMG}:${TAG}" + echo "Published multi-arch: ${IMG}:${TAG}" diff --git a/Dockerfile b/Dockerfile index 2e386aef00..82af71a981 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,15 @@ # limitations under the License. # -ARG SPARK_IMAGE=docker.io/apache/spark:4.2.1-scala2.13-java21-ubuntu@sha256:ce1d0c8407066ed44b91f699b6edd3564f143722e3ef95e19d99a67b5754b306 +# Razorpay hardening: build FROM the Harbor-approved Spark mirror (RSPL), not docker.io, so there +# is no non-Harbor base finding. Same 4.2.1 digest, just pulled from the approved registry. +ARG SPARK_IMAGE=c.rzp.io/razorpay-external/apache/spark@sha256:ce1d0c8407066ed44b91f699b6edd3564f143722e3ef95e19d99a67b5754b306 -FROM docker.io/library/golang:1.26.10@sha256:670bb5aa5349ae03b8516764718486f4f16399134bdc9acd0c46a23f043ab05c AS builder +# Go 1.27.4 builder (via the Harbor DockerHub proxy). The bumped go.mod (x/net 0.63, x/text 0.44, +# x/mod 0.43, otel/trace 1.47) + this toolchain rebuild the operator binary with 0 Go CVEs +# (verified with Trivy). GOTOOLCHAIN=local pins the build to this toolchain. +FROM c.rzp.io/proxy_dockerhub/library/golang:1.27.4@sha256:5bd30d78fe7788dc760abe3e3437434781b3164e50fadc24611fa7fbc0cfb6ba AS builder +ENV GOTOOLCHAIN=local WORKDIR /workspace @@ -53,6 +59,22 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ FROM scratch AS artifacts COPY --from=builder /workspace/bin/spark-operator /spark-operator +# Razorpay hardening: resolve the patched standalone jars (patch/minor bumps that are +# Spark-ABI-safe) via the GCS Maven Central mirror. Maven verifies each artifact's published +# checksum. These replace the vulnerable standalone jars the Spark base ships in /opt/spark/jars. +FROM c.rzp.io/proxy_dockerhub/library/maven:3.9-eclipse-temurin-21 AS jars +WORKDIR /build +COPY patched-jars.pom.xml pom.xml +COPY settings.xml settings.xml +RUN ok=0; \ + for i in 1 2 3; do \ + if mvn -B -q -s settings.xml org.apache.maven.plugins:maven-dependency-plugin:3.8.1:copy-dependencies \ + -DexcludeTransitive=true -DoutputDirectory=/staging; then ok=1; break; fi; \ + echo "maven attempt $i failed; retrying in $((i*15))s"; sleep $((i*15)); \ + done; \ + [ "$ok" = 1 ] || { echo "FAIL: maven resolution failed"; exit 1; }; \ + ls -1 /staging + FROM ${SPARK_IMAGE} ARG SPARK_UID=185 @@ -61,9 +83,47 @@ ARG SPARK_GID=185 USER root -RUN apt-get update \ - && apt-get install -y catatonit \ - && rm -rf /var/lib/apt/lists/* +# Razorpay hardening: OS security upgrade + catatonit (operator needs it) + remove gosu. +# gosu is a Go 1.18 setuid binary (Go EOL) the Spark base ships for its own root->user entrypoint. +# This operator image runs non-root as uid 185 and its entrypoint uses catatonit, never gosu, so +# gosu is dead weight here — removing it clears the Go-EOL finding with no functional impact. +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get -y upgrade; \ + apt-get install -y --no-install-recommends catatonit; \ + rm -f /usr/sbin/gosu /usr/local/bin/gosu /usr/bin/gosu; \ + apt-get clean; rm -rf /var/lib/apt/lists/* + +# Razorpay hardening: swap the vulnerable standalone jars the Spark base ships for patched +# versions, then verify fail-CLOSED — no old vulnerable version may remain (a missed rm name is +# caught here), no artifact may carry two versions on the classpath, every patched jar present. +RUN set -eux; cd /opt/spark/jars; \ + rm -f netty-*-4.2.13.Final*.jar jackson-core-2.21.2*.jar jackson-databind-2.21.2*.jar \ + jackson-dataformat-yaml-2.21.2*.jar jackson-datatype-jsr310-2.21.2*.jar \ + jackson-module-scala_2.13-2.21.2*.jar snappy-java-1.1.10.8*.jar lz4-java-1.11.0*.jar \ + guava-33.6.0-jre*.jar jline-3.29.0*.jar derby-10.16.1.1*.jar derbyshared-10.16.1.1*.jar \ + derbytools-10.16.1.1*.jar +COPY --from=jars --chown=185:185 /staging/ /opt/spark/jars/ +RUN set -eux; cd /opt/spark/jars; \ + if ls netty-*-4.2.13.Final*.jar >/dev/null 2>&1; then echo "FAIL: netty 4.2.13 still present"; exit 1; fi; \ + for v in jackson-core-2.21.2 jackson-databind-2.21.2 jackson-dataformat-yaml-2.21.2 \ + jackson-datatype-jsr310-2.21.2 jackson-module-scala_2.13-2.21.2 snappy-java-1.1.10.8 \ + lz4-java-1.11.0 guava-33.6.0-jre jline-3.29.0 derby-10.16.1.1 derbyshared-10.16.1.1 \ + derbytools-10.16.1.1; do \ + if ls ${v}*.jar >/dev/null 2>&1; then echo "FAIL: vulnerable ${v} still present:"; ls ${v}*.jar; exit 1; fi; \ + done; \ + nv=$(ls netty-*-4.2.*.Final*.jar | sed -E 's/.*-(4\.2\.[0-9]+\.Final).*/\1/' | sort -u); \ + [ "$nv" = 4.2.17.Final ] || { echo "FAIL: unexpected netty versions: $nv"; exit 1; }; \ + for a in guava snappy-java lz4-java jackson-core jackson-databind jackson-dataformat-yaml \ + jackson-datatype-jsr310 jackson-module-scala_2.13 derby; do \ + n=$(ls ${a}-*.jar 2>/dev/null | wc -l); \ + [ "$n" -eq 1 ] || { echo "FAIL: $a has $n versions:"; ls ${a}-*.jar 2>/dev/null; exit 1; }; \ + done; \ + jn=$(ls jline-3.*.jar 2>/dev/null | wc -l); [ "$jn" -eq 1 ] || { echo "FAIL: jline3 count=$jn"; ls jline-3.*.jar; exit 1; }; \ + for f in netty-handler-4.2.17.Final guava-33.7.2-jre jackson-databind-2.21.7 \ + snappy-java-1.1.10.9 lz4-java-1.11.4 jline-3.30.15 derby-10.17.1.0; do \ + [ -e "$f.jar" ] || { echo "FAIL: patched $f.jar missing"; exit 1; }; \ + done RUN mkdir -p /etc/k8s-webhook-server/serving-certs /home/spark && \ chmod -R g+rw /etc/k8s-webhook-server/serving-certs && \ diff --git a/go.mod b/go.mod index 65a129f609..21ffae7c3d 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,12 @@ module github.com/kubeflow/spark-operator/v2 go 1.26.0 -toolchain go1.26.10 +toolchain go1.27.4 tool k8s.io/code-generator require ( - github.com/go-logr/logr v1.4.3 + github.com/go-logr/logr v1.4.4 github.com/google/uuid v1.6.0 github.com/onsi/ginkgo/v2 v2.27.4 github.com/onsi/gomega v1.39.0 @@ -15,9 +15,9 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 - github.com/stretchr/testify v1.11.1 + github.com/stretchr/testify v1.12.1 go.uber.org/zap v1.27.1 - golang.org/x/mod v0.37.0 + golang.org/x/mod v0.43.0 golang.org/x/time v0.15.0 gopkg.in/inf.v0 v0.9.1 k8s.io/api v0.37.1 @@ -84,22 +84,21 @@ require ( github.com/stretchr/objx v0.5.3 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/x448/float16 v0.8.4 // indirect - go.opentelemetry.io/otel v1.44.0 // indirect - go.opentelemetry.io/otel/trace v1.44.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect - go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.57.0 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect + golang.org/x/net v0.63.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sync v0.22.0 // indirect - golang.org/x/sys v0.47.0 // indirect - golang.org/x/term v0.45.0 // indirect - golang.org/x/text v0.40.0 // indirect - golang.org/x/tools v0.47.0 // indirect + golang.org/x/sync v0.25.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/term v0.48.0 // indirect + golang.org/x/text v0.44.0 // indirect + golang.org/x/tools v0.52.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/code-generator v0.37.1 // indirect k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect diff --git a/go.sum b/go.sum index 6721b2fc09..60c2cba7fb 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZ github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE= github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= +github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v1.0.0 h1:kR9tHqY0CtZaOPVFm622dPVNhrvYpwr4uCxgL3h1H8s= @@ -151,8 +151,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= @@ -165,10 +165,10 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= -go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= -go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= -go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -177,26 +177,27 @@ go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= -go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= -golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/mod v0.43.0 h1:MFuq5J6s35W9D3IjkwyWc9vHh0nENOrt5K8Iof4ofmg= +golang.org/x/mod v0.43.0/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY= +golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0= +golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= -golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= -golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= -golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= -golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= -golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= +golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/term v0.48.0 h1:G6UU1eiSB8nl3DzeUGt7Mg+2SctI8tPS6Z5/mBt6cOk= +golang.org/x/term v0.48.0/go.mod h1:BRDLHCZr2SUjIeBHHpRyQeC9xzSAVbzY2rvKgafnHf4= +golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= +golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= -golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= -golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= +golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= +golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= @@ -206,8 +207,6 @@ gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuB google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= diff --git a/patched-jars.pom.xml b/patched-jars.pom.xml new file mode 100644 index 0000000000..50a9b23309 --- /dev/null +++ b/patched-jars.pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + com.razorpay.de + spark-operator-2.6.0-patched-jars + 1 + pom + + + 4.2.17.Final + 2.21.7 + + 10.17.1.0 + + + + + io.nettynetty-all${netty.version} + io.nettynetty-buffer${netty.version} + io.nettynetty-codec${netty.version} + io.nettynetty-codec-base${netty.version} + io.nettynetty-codec-compression${netty.version} + io.nettynetty-codec-dns${netty.version} + io.nettynetty-codec-http${netty.version} + io.nettynetty-codec-http2${netty.version} + io.nettynetty-codec-socks${netty.version} + io.nettynetty-common${netty.version} + io.nettynetty-handler${netty.version} + io.nettynetty-handler-proxy${netty.version} + io.nettynetty-resolver${netty.version} + io.nettynetty-resolver-dns${netty.version} + io.nettynetty-transport${netty.version} + io.nettynetty-transport-classes-epoll${netty.version} + io.nettynetty-transport-classes-kqueue${netty.version} + io.nettynetty-transport-native-unix-common${netty.version} + + io.nettynetty-transport-native-epoll${netty.version}linux-x86_64 + io.nettynetty-transport-native-epoll${netty.version}linux-aarch_64 + io.nettynetty-transport-native-epoll${netty.version}linux-riscv64 + io.nettynetty-transport-native-kqueue${netty.version}osx-x86_64 + io.nettynetty-transport-native-kqueue${netty.version}osx-aarch_64 + + + com.fasterxml.jackson.corejackson-core${jackson.version} + com.fasterxml.jackson.corejackson-databind${jackson.version} + com.fasterxml.jackson.dataformatjackson-dataformat-yaml${jackson.version} + com.fasterxml.jackson.datatypejackson-datatype-jsr310${jackson.version} + com.fasterxml.jackson.modulejackson-module-scala_2.13${jackson.version} + + + org.xerial.snappysnappy-java1.1.10.9 + at.yawk.lz4lz4-java1.11.4 + com.google.guavaguava33.7.2-jre + org.jlinejline3.30.15 + + + org.apache.derbyderby${derby.version} + org.apache.derbyderbyshared${derby.version} + org.apache.derbyderbytools${derby.version} + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000000..44f8943645 --- /dev/null +++ b/settings.xml @@ -0,0 +1,21 @@ + + + + + + gcs-maven-central + GCS Maven Central mirror + https://maven-central.storage-download.googleapis.com/maven2/ + central + + + From 6dcc4cea65573723a8a3abee7fae2f5a272bdac3 Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 25 Nov 2026 18:59:18 +0530 Subject: [PATCH 2/5] ci: add central security checks (parity with datahub) Wire the org-wide security scans (Semgrep, secret scan, Non-Golden-Image, etc.) via razorpay/security-action, matching datahub's central_security_checks.yml so PRs and master in this fork get the same security gating. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/central_security_checks.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/central_security_checks.yml diff --git a/.github/workflows/central_security_checks.yml b/.github/workflows/central_security_checks.yml new file mode 100644 index 0000000000..331344ee5e --- /dev/null +++ b/.github/workflows/central_security_checks.yml @@ -0,0 +1,11 @@ +name: Security Checks +on: + pull_request: {} + push: + branches: ["master"] + schedule: + - cron: "0 17 * * *" +jobs: + Security-Scan: + uses: razorpay/security-action/.github/workflows/central_security_checks_prod.yml@master + secrets: inherit From 72346c8be520a877eb7f63b2eec025cca7c483af Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 25 Nov 2026 19:42:03 +0530 Subject: [PATCH 3/5] ci: use public docker actions for Harbor build+push (drop internal action dep) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The internal razorpay/docker-image-build-push action is a private repo this fork can't resolve ("Unable to resolve action ... not found"). Swap it for public docker/{setup-qemu,setup-buildx, login,build-push}-action, which build the same multi-arch image and push to c.rzp.io. Now the only prerequisite is the Harbor secret reaching this repo — no internal-action access grant. Co-Authored-By: Claude Opus 4.8 --- .../workflows/razorpay-image-build-push.yaml | 80 +++++++------------ 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/.github/workflows/razorpay-image-build-push.yaml b/.github/workflows/razorpay-image-build-push.yaml index 50e1622f5c..8a5fc25cbb 100644 --- a/.github/workflows/razorpay-image-build-push.yaml +++ b/.github/workflows/razorpay-image-build-push.yaml @@ -1,12 +1,14 @@ # Razorpay: build the hardened Spark Operator image from source and push it to Harbor (c.rzp.io). # -# This is separate from the upstream build-and-push-images.yaml (which targets ghcr.io). It builds -# the controller image from THIS repo's Dockerfile — rebuilding the operator Go binary with the -# bumped go.mod (0 Go CVEs), FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark -# base hardened (apt upgrade, patched jar swaps, gosu removed). The resulting image is then +# Self-contained: uses only public docker/* actions (no internal razorpay action), so the only +# prerequisite is that this repo can read the Harbor secrets. It builds the controller image from +# THIS repo's Dockerfile — rebuilding the operator Go binary with the bumped go.mod (0 Go CVEs), +# FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark base hardened (apt upgrade, +# patched jar swaps, gosu removed) — then pushes a multi-arch manifest. The resulting image is # whitelisted in rzp-docker-image-inventory as a custom base image. # -# Requires repo secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD (Harbor robot account). +# Requires repo (or inherited org) secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD +# (Harbor robot account with push rights to razorpay/spark-operator). name: Razorpay Image Build and Push @@ -27,7 +29,8 @@ permissions: env: REGISTRY: c.rzp.io - REPOSITORY: spark-operator + # Full image path under the Harbor `razorpay` project. + IMAGE: c.rzp.io/razorpay/spark-operator # Operator version this image ships; bump with the release. HARDEN_REV tracks the Razorpay # hardening revision independently of the operator version. OP_VERSION: "2.6.0" @@ -35,14 +38,8 @@ env: jobs: build: - name: Build controller (${{ matrix.platform }}) + name: Build and push controller (multi-arch) runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - platform: - - linux-amd64 - - linux-arm64 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -60,47 +57,30 @@ jobs: TAG="${BASE}-${GITHUB_SHA}" fi echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - echo "Publishing: ${REGISTRY}/razorpay/${REPOSITORY}:${TAG}-${{ matrix.platform }}" + echo "Image: ${IMAGE}:${TAG}" - - name: Build and push (${{ matrix.platform }}) - # Pinned to the internal action's v1 branch HEAD (same pin datahub uses) so a repointed - # branch cannot change this build silently. - uses: razorpay/docker-image-build-push@149c7e92cf1a93d19239cff57a8fc3a61c48ed5e + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Harbor + if: github.event_name != 'workflow_dispatch' || inputs.push + uses: docker/login-action@v3 with: + registry: ${{ env.REGISTRY }} username: ${{ secrets.HARBOR_DOCKER_USERNAME }} password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} - registry: ${{ env.REGISTRY }} - repository: ${{ env.REPOSITORY }} + + - name: Build and push (linux/amd64, linux/arm64) + uses: docker/build-push-action@v6 + with: context: . file: Dockerfile - custom-tag: ${{ steps.tag.outputs.tag }}-${{ matrix.platform }} - enable-login: true + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'workflow_dispatch' || inputs.push }} - - manifest: - name: Multi-arch manifest - needs: build - if: github.event_name != 'workflow_dispatch' || inputs.push - runs-on: ubuntu-latest - steps: - - name: Compute tag - id: tag - run: | - set -eux - BASE="controller-${OP_VERSION}-${HARDEN_REV}" - if [ "${GITHUB_REF_NAME}" = "master" ]; then TAG="${BASE}"; else TAG="${BASE}-${GITHUB_SHA}"; fi - echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - - - name: Login to Harbor - run: echo "${{ secrets.HARBOR_DOCKER_PASSWORD }}" | docker login "${REGISTRY}" -u "${{ secrets.HARBOR_DOCKER_USERNAME }}" --password-stdin - - - name: Create and push manifest - run: | - set -eux - IMG="${REGISTRY}/razorpay/${REPOSITORY}" - TAG="${{ steps.tag.outputs.tag }}" - docker manifest create "${IMG}:${TAG}" \ - "${IMG}:${TAG}-linux-amd64" \ - "${IMG}:${TAG}-linux-arm64" - docker manifest push "${IMG}:${TAG}" - echo "Published multi-arch: ${IMG}:${TAG}" + tags: ${{ env.IMAGE }}:${{ steps.tag.outputs.tag }} + # Harbor does not accept the OCI provenance/SBOM attestation manifest by default; keep a + # plain multi-arch image manifest. + provenance: false From 00392d576c12a63e8be021684f4b4178f7c6d10b Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 25 Nov 2026 19:54:13 +0530 Subject: [PATCH 4/5] ci: use internal razorpay/docker-image-build-push action (match datahub) Revert to the internal action datahub uses for Harbor build+push, per-arch + multi-arch manifest. Requires the fork to be granted access to the private razorpay/docker-image-build-push action and to the Harbor org secrets. Co-Authored-By: Claude Opus 4.8 --- .../workflows/razorpay-image-build-push.yaml | 80 ++++++++++++------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/.github/workflows/razorpay-image-build-push.yaml b/.github/workflows/razorpay-image-build-push.yaml index 8a5fc25cbb..50e1622f5c 100644 --- a/.github/workflows/razorpay-image-build-push.yaml +++ b/.github/workflows/razorpay-image-build-push.yaml @@ -1,14 +1,12 @@ # Razorpay: build the hardened Spark Operator image from source and push it to Harbor (c.rzp.io). # -# Self-contained: uses only public docker/* actions (no internal razorpay action), so the only -# prerequisite is that this repo can read the Harbor secrets. It builds the controller image from -# THIS repo's Dockerfile — rebuilding the operator Go binary with the bumped go.mod (0 Go CVEs), -# FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark base hardened (apt upgrade, -# patched jar swaps, gosu removed) — then pushes a multi-arch manifest. The resulting image is +# This is separate from the upstream build-and-push-images.yaml (which targets ghcr.io). It builds +# the controller image from THIS repo's Dockerfile — rebuilding the operator Go binary with the +# bumped go.mod (0 Go CVEs), FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark +# base hardened (apt upgrade, patched jar swaps, gosu removed). The resulting image is then # whitelisted in rzp-docker-image-inventory as a custom base image. # -# Requires repo (or inherited org) secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD -# (Harbor robot account with push rights to razorpay/spark-operator). +# Requires repo secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD (Harbor robot account). name: Razorpay Image Build and Push @@ -29,8 +27,7 @@ permissions: env: REGISTRY: c.rzp.io - # Full image path under the Harbor `razorpay` project. - IMAGE: c.rzp.io/razorpay/spark-operator + REPOSITORY: spark-operator # Operator version this image ships; bump with the release. HARDEN_REV tracks the Razorpay # hardening revision independently of the operator version. OP_VERSION: "2.6.0" @@ -38,8 +35,14 @@ env: jobs: build: - name: Build and push controller (multi-arch) + name: Build controller (${{ matrix.platform }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - linux-amd64 + - linux-arm64 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -57,30 +60,47 @@ jobs: TAG="${BASE}-${GITHUB_SHA}" fi echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - echo "Image: ${IMAGE}:${TAG}" + echo "Publishing: ${REGISTRY}/razorpay/${REPOSITORY}:${TAG}-${{ matrix.platform }}" - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Harbor - if: github.event_name != 'workflow_dispatch' || inputs.push - uses: docker/login-action@v3 + - name: Build and push (${{ matrix.platform }}) + # Pinned to the internal action's v1 branch HEAD (same pin datahub uses) so a repointed + # branch cannot change this build silently. + uses: razorpay/docker-image-build-push@149c7e92cf1a93d19239cff57a8fc3a61c48ed5e with: - registry: ${{ env.REGISTRY }} username: ${{ secrets.HARBOR_DOCKER_USERNAME }} password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} - - - name: Build and push (linux/amd64, linux/arm64) - uses: docker/build-push-action@v6 - with: + registry: ${{ env.REGISTRY }} + repository: ${{ env.REPOSITORY }} context: . file: Dockerfile - platforms: linux/amd64,linux/arm64 + custom-tag: ${{ steps.tag.outputs.tag }}-${{ matrix.platform }} + enable-login: true push: ${{ github.event_name != 'workflow_dispatch' || inputs.push }} - tags: ${{ env.IMAGE }}:${{ steps.tag.outputs.tag }} - # Harbor does not accept the OCI provenance/SBOM attestation manifest by default; keep a - # plain multi-arch image manifest. - provenance: false + + manifest: + name: Multi-arch manifest + needs: build + if: github.event_name != 'workflow_dispatch' || inputs.push + runs-on: ubuntu-latest + steps: + - name: Compute tag + id: tag + run: | + set -eux + BASE="controller-${OP_VERSION}-${HARDEN_REV}" + if [ "${GITHUB_REF_NAME}" = "master" ]; then TAG="${BASE}"; else TAG="${BASE}-${GITHUB_SHA}"; fi + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" + + - name: Login to Harbor + run: echo "${{ secrets.HARBOR_DOCKER_PASSWORD }}" | docker login "${REGISTRY}" -u "${{ secrets.HARBOR_DOCKER_USERNAME }}" --password-stdin + + - name: Create and push manifest + run: | + set -eux + IMG="${REGISTRY}/razorpay/${REPOSITORY}" + TAG="${{ steps.tag.outputs.tag }}" + docker manifest create "${IMG}:${TAG}" \ + "${IMG}:${TAG}-linux-amd64" \ + "${IMG}:${TAG}-linux-arm64" + docker manifest push "${IMG}:${TAG}" + echo "Published multi-arch: ${IMG}:${TAG}" From 169e78396a43b7787658354192f6681526c99b3f Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 25 Nov 2026 20:01:21 +0530 Subject: [PATCH 5/5] ci: mirror datahub custom-base CI exactly (self-hosted runners + internal action) Align the Harbor build+push workflow 1:1 with datahub's ci_custom_base_images.yml: - runs-on self-hosted linux-amd64 / linux-arm64 (not GitHub-hosted ubuntu-latest), which is what gives access to the private action, Harbor, and the org secrets inside Razorpay's network. - per-arch build via razorpay/docker-image-build-push with an arch-suffixed custom-tag. - multi-arch manifest via the same action with trigger-multiarch-image-build + multiarch-suffixes (not manual docker manifest), on a linux-amd64 runner. - checkout pinned to the same immutable SHA datahub uses. Co-Authored-By: Claude Opus 4.8 --- .../workflows/razorpay-image-build-push.yaml | 108 ++++++++++-------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/.github/workflows/razorpay-image-build-push.yaml b/.github/workflows/razorpay-image-build-push.yaml index 50e1622f5c..96527f0cbe 100644 --- a/.github/workflows/razorpay-image-build-push.yaml +++ b/.github/workflows/razorpay-image-build-push.yaml @@ -1,32 +1,29 @@ # Razorpay: build the hardened Spark Operator image from source and push it to Harbor (c.rzp.io). # -# This is separate from the upstream build-and-push-images.yaml (which targets ghcr.io). It builds -# the controller image from THIS repo's Dockerfile — rebuilding the operator Go binary with the -# bumped go.mod (0 Go CVEs), FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark -# base hardened (apt upgrade, patched jar swaps, gosu removed). The resulting image is then -# whitelisted in rzp-docker-image-inventory as a custom base image. +# Mirrors datahub's custom-base-images CI 1:1 — same self-hosted runners (linux-amd64/linux-arm64), +# the same internal razorpay/docker-image-build-push action for per-arch build and for the +# multi-arch manifest, and the same HARBOR_DOCKER_* org secrets. It builds the controller image +# from THIS repo's Dockerfile: the operator Go binary is rebuilt with the bumped go.mod (0 Go +# CVEs), FROM the Harbor-approved apache/spark:4.2.1 mirror, with the Spark base hardened (apt +# upgrade, patched jar swaps, gosu removed). The published tag is then whitelisted in +# rzp-docker-image-inventory as a custom base image. # -# Requires repo secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD (Harbor robot account). +# Requires (same as datahub): access to the private razorpay/docker-image-build-push action and +# the HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD org secrets reaching this repo. name: Razorpay Image Build and Push on: - workflow_dispatch: - inputs: - push: - description: Push to Harbor (otherwise build-only). - type: boolean - default: true + workflow_dispatch: {} push: branches: - master - 'feature/razorpay-**' -permissions: - contents: read - env: + DOCKER_BUILDKIT: 1 REGISTRY: c.rzp.io + # Harbor repository under the razorpay project: c.rzp.io/razorpay/spark-operator REPOSITORY: spark-operator # Operator version this image ships; bump with the release. HARDEN_REV tracks the Razorpay # hardening revision independently of the operator version. @@ -34,37 +31,40 @@ env: HARDEN_REV: "hardened-v1" jobs: + # Native per-arch build on the matching self-hosted runner, published with an arch-suffixed tag. build: name: Build controller (${{ matrix.platform }}) - runs-on: ubuntu-latest strategy: fail-fast: false matrix: platform: - linux-amd64 - linux-arm64 + runs-on: + - ${{ matrix.platform }} steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false + - name: Checkout Codebase + # Pinned to an immutable SHA (v4.1.0), same as datahub: a mutable tag can be repointed to + # attacker code that runs on the self-hosted runner ahead of the credentialed steps. + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - name: Compute tag + - name: Resolve image tag id: tag + env: + COMMIT_SHA: ${{ github.sha }} run: | - set -eux + set -euo pipefail BASE="controller-${OP_VERSION}-${HARDEN_REV}" - if [ "${GITHUB_REF_NAME}" = "master" ]; then + if [ "${GITHUB_REF}" = "refs/heads/master" ]; then TAG="${BASE}" else - TAG="${BASE}-${GITHUB_SHA}" + TAG="${BASE}-${COMMIT_SHA}" fi echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "Publishing: ${REGISTRY}/razorpay/${REPOSITORY}:${TAG}-${{ matrix.platform }}" - name: Build and push (${{ matrix.platform }}) - # Pinned to the internal action's v1 branch HEAD (same pin datahub uses) so a repointed - # branch cannot change this build silently. + # Pinned to the internal action's v1 branch HEAD, same pin datahub uses. uses: razorpay/docker-image-build-push@149c7e92cf1a93d19239cff57a8fc3a61c48ed5e with: username: ${{ secrets.HARBOR_DOCKER_USERNAME }} @@ -75,32 +75,44 @@ jobs: file: Dockerfile custom-tag: ${{ steps.tag.outputs.tag }}-${{ matrix.platform }} enable-login: true - push: ${{ github.event_name != 'workflow_dispatch' || inputs.push }} + push: true - manifest: - name: Multi-arch manifest - needs: build - if: github.event_name != 'workflow_dispatch' || inputs.push - runs-on: ubuntu-latest + # Publishes the multi-arch manifest tag consumers pin, from the arch-suffixed tags above. + build-multiarch: + name: Create multi-arch manifest + needs: + - build + runs-on: + - linux-amd64 steps: - - name: Compute tag + - name: Checkout Codebase + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + + - name: Resolve image tag id: tag + env: + COMMIT_SHA: ${{ github.sha }} run: | - set -eux + set -euo pipefail BASE="controller-${OP_VERSION}-${HARDEN_REV}" - if [ "${GITHUB_REF_NAME}" = "master" ]; then TAG="${BASE}"; else TAG="${BASE}-${GITHUB_SHA}"; fi + if [ "${GITHUB_REF}" = "refs/heads/master" ]; then + TAG="${BASE}" + else + TAG="${BASE}-${COMMIT_SHA}" + fi echo "tag=${TAG}" >> "$GITHUB_OUTPUT" + echo "Publishing: ${REGISTRY}/razorpay/${REPOSITORY}:${TAG}" - - name: Login to Harbor - run: echo "${{ secrets.HARBOR_DOCKER_PASSWORD }}" | docker login "${REGISTRY}" -u "${{ secrets.HARBOR_DOCKER_USERNAME }}" --password-stdin - - - name: Create and push manifest - run: | - set -eux - IMG="${REGISTRY}/razorpay/${REPOSITORY}" - TAG="${{ steps.tag.outputs.tag }}" - docker manifest create "${IMG}:${TAG}" \ - "${IMG}:${TAG}-linux-amd64" \ - "${IMG}:${TAG}-linux-arm64" - docker manifest push "${IMG}:${TAG}" - echo "Published multi-arch: ${IMG}:${TAG}" + - name: Create multiarch image + uses: razorpay/docker-image-build-push@149c7e92cf1a93d19239cff57a8fc3a61c48ed5e + with: + username: ${{ secrets.HARBOR_DOCKER_USERNAME }} + password: ${{ secrets.HARBOR_DOCKER_PASSWORD }} + registry: ${{ env.REGISTRY }} + repository: ${{ env.REPOSITORY }} + custom-tag: ${{ steps.tag.outputs.tag }} + trigger-multiarch-image-build: true + multiarch-suffixes: | + -linux-amd64 + -linux-arm64 + enable-login: true