-
Notifications
You must be signed in to change notification settings - Fork 29
Add multi-arch Plerkle plugin image #104
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,81 @@ | ||||||||||||||||
| name: Publish Plerkle plugin image | ||||||||||||||||
|
|
||||||||||||||||
| on: | ||||||||||||||||
| push: | ||||||||||||||||
| tags: | ||||||||||||||||
| - "v*" | ||||||||||||||||
| workflow_dispatch: | ||||||||||||||||
| inputs: | ||||||||||||||||
| tag: | ||||||||||||||||
| description: "Release tag to publish, for example v3.0.1" | ||||||||||||||||
| required: true | ||||||||||||||||
| type: string | ||||||||||||||||
|
|
||||||||||||||||
| env: | ||||||||||||||||
| PLERKLE_PLUGIN_IMAGE_NAME: plerkle-plugin | ||||||||||||||||
| RUST_VERSION: 1.89.0 | ||||||||||||||||
| SOLANA_VERSION_STABLE: v3.1.13 | ||||||||||||||||
|
|
||||||||||||||||
| permissions: | ||||||||||||||||
| contents: read | ||||||||||||||||
| packages: write | ||||||||||||||||
|
|
||||||||||||||||
| jobs: | ||||||||||||||||
| publish: | ||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
| steps: | ||||||||||||||||
| - name: Resolve tag | ||||||||||||||||
| id: resolve | ||||||||||||||||
| run: | | ||||||||||||||||
| set -euo pipefail | ||||||||||||||||
| if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then | ||||||||||||||||
| tag="${{ inputs.tag }}" | ||||||||||||||||
| else | ||||||||||||||||
| tag="${GITHUB_REF#refs/tags/}" | ||||||||||||||||
| fi | ||||||||||||||||
| agave_version="${SOLANA_VERSION_STABLE#v}" | ||||||||||||||||
| echo "ci_tag=${tag}" >> "$GITHUB_OUTPUT" | ||||||||||||||||
| echo "CI_TAG=${tag}" >> "$GITHUB_ENV" | ||||||||||||||||
| echo "PLERKLE_PLUGIN_TAG=${tag}-rust${RUST_VERSION}-agave${agave_version}" >> "$GITHUB_ENV" | ||||||||||||||||
| echo "PLERKLE_PLUGIN_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER}/${PLERKLE_PLUGIN_IMAGE_NAME}" >> "$GITHUB_ENV" | ||||||||||||||||
|
Comment on lines
+29
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code injection vulnerability via unescaped template expansion. Line 32 directly interpolates Example malicious input: 🔒 Recommended fix using intermediate environment variable - name: Resolve tag
id: resolve
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
- tag="${{ inputs.tag }}"
+ tag="${INPUT_TAG}"
else
tag="${GITHUB_REF#refs/tags/}"
fi
agave_version="${SOLANA_VERSION_STABLE#v}"
echo "ci_tag=${tag}" >> "$GITHUB_OUTPUT"
echo "CI_TAG=${tag}" >> "$GITHUB_ENV"
echo "PLERKLE_PLUGIN_TAG=${tag}-rust${RUST_VERSION}-agave${agave_version}" >> "$GITHUB_ENV"
echo "PLERKLE_PLUGIN_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER}/${PLERKLE_PLUGIN_IMAGE_NAME}" >> "$GITHUB_ENV"This approach passes the input through an environment variable, preventing shell interpretation of special characters. 🧰 Tools🪛 zizmor (1.25.2)[error] 32-32: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||
| with: | ||||||||||||||||
| ref: ${{ steps.resolve.outputs.ci_tag }} | ||||||||||||||||
|
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win Security hardening: Disable credential persistence and pin action to commit SHA. Two security improvements:
🔒 Recommended hardening- - uses: actions/checkout@v4
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ steps.resolve.outputs.ci_tag }}
+ persist-credentials: falseNote: You'll need to repeat SHA pinning for all actions in this workflow (setup-qemu-action@v3, setup-buildx-action@v3, login-action@v3, build-push-action@v6). 📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.25.2)[warning] 42-44: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [error] 42-42: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| - uses: docker/setup-qemu-action@v3 | ||||||||||||||||
|
|
||||||||||||||||
| - uses: docker/setup-buildx-action@v3 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Log in to GHCR | ||||||||||||||||
| uses: docker/login-action@v3 | ||||||||||||||||
| with: | ||||||||||||||||
| registry: ghcr.io | ||||||||||||||||
| username: ${{ github.actor }} | ||||||||||||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||
|
|
||||||||||||||||
| - name: Build and push Plerkle plugin image | ||||||||||||||||
| uses: docker/build-push-action@v6 | ||||||||||||||||
| with: | ||||||||||||||||
| context: . | ||||||||||||||||
| file: PlerklePlugin.Dockerfile | ||||||||||||||||
| platforms: linux/amd64,linux/arm64 | ||||||||||||||||
| push: true | ||||||||||||||||
| build-args: | | ||||||||||||||||
| RUST_VERSION=${{ env.RUST_VERSION }} | ||||||||||||||||
| labels: | | ||||||||||||||||
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||||||||||||||||
| org.opencontainers.image.revision=${{ github.sha }} | ||||||||||||||||
| org.opencontainers.image.version=${{ env.PLERKLE_PLUGIN_TAG }} | ||||||||||||||||
| tags: | | ||||||||||||||||
| ${{ env.PLERKLE_PLUGIN_IMAGE }}:${{ env.PLERKLE_PLUGIN_TAG }} | ||||||||||||||||
|
|
||||||||||||||||
| - name: Verify multi-arch image | ||||||||||||||||
| run: | | ||||||||||||||||
| set -euo pipefail | ||||||||||||||||
| image="${PLERKLE_PLUGIN_IMAGE}:${PLERKLE_PLUGIN_TAG}" | ||||||||||||||||
| docker buildx imagetools inspect "$image" | tee /tmp/plerkle-plugin-image.txt | ||||||||||||||||
| grep -q 'linux/amd64' /tmp/plerkle-plugin-image.txt | ||||||||||||||||
| grep -q 'linux/arm64' /tmp/plerkle-plugin-image.txt | ||||||||||||||||
| docker run --rm --platform linux/amd64 --entrypoint test "$image" -f /plugin/plugin.so | ||||||||||||||||
| docker run --rm --platform linux/arm64 --entrypoint test "$image" -f /plugin/plugin.so | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ARG RUST_VERSION=1.89.0 | ||
|
|
||
| FROM --platform=$TARGETPLATFORM rust:${RUST_VERSION}-bullseye AS builder | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| cmake \ | ||
| libelf-dev \ | ||
| libsasl2-dev \ | ||
| libssl-dev \ | ||
| libudev-dev \ | ||
| libzstd-dev \ | ||
| pkg-config \ | ||
| protobuf-compiler \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /rust | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY plerkle ./plerkle | ||
| COPY plerkle_messenger ./plerkle_messenger | ||
| COPY plerkle_serialization ./plerkle_serialization | ||
|
|
||
| RUN cargo build --release --locked -p plerkle | ||
|
|
||
| FROM --platform=$TARGETPLATFORM debian:bullseye-slim | ||
|
|
||
| LABEL org.opencontainers.image.title="Plerkle Geyser Plugin" | ||
| LABEL org.opencontainers.image.description="Plerkle Geyser plugin artifact for DAS e2e validator images" | ||
| LABEL org.opencontainers.image.source="https://github.com/metaplex-foundation/digital-asset-validator-plugin" | ||
|
|
||
| COPY --from=builder /rust/target/release/libplerkle.so /plugin/plugin.so | ||
|
Comment on lines
+27
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial | 💤 Low value Consider adding a non-root USER for security hardening. The container runs as root. While this is acceptable for an artifact-only container, adding a non-root user would follow security best practices and satisfy static analysis tools. 🔒 Optional hardening to add non-root user FROM --platform=$TARGETPLATFORM debian:bullseye-slim
LABEL org.opencontainers.image.title="Plerkle Geyser Plugin"
LABEL org.opencontainers.image.description="Plerkle Geyser plugin artifact for DAS e2e validator images"
LABEL org.opencontainers.image.source="https://github.com/metaplex-foundation/digital-asset-validator-plugin"
+RUN groupadd -r plerkle && useradd -r -g plerkle plerkle \
+ && mkdir -p /plugin && chown plerkle:plerkle /plugin
+
+USER plerkle
+
COPY --from=builder /rust/target/release/libplerkle.so /plugin/plugin.so🧰 Tools🪛 Checkov (3.2.529)[low] 1-33: Ensure that HEALTHCHECK instructions have been added to container images (CKV_DOCKER_2) [low] 1-33: Ensure that a user for the container has been created (CKV_DOCKER_3) 🤖 Prompt for AI Agents |
||
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.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Consider adding concurrency controls to prevent parallel builds.
Without concurrency limits, multiple simultaneous triggers (e.g., manual dispatch while a tag push is running) could result in parallel builds of the same image, wasting resources and potentially causing race conditions in GHCR.
♻️ Recommended concurrency configuration
name: Publish Plerkle plugin image on: push: tags: - "v*" workflow_dispatch: inputs: tag: description: "Release tag to publish, for example v3.0.1" required: true type: string +concurrency: + group: publish-plerkle-plugin-${{ github.event.inputs.tag || github.ref }} + cancel-in-progress: false + env:🧰 Tools
🪛 zizmor (1.25.2)
[warning] 3-12: insufficient job-level concurrency limits (concurrency-limits): workflow is missing concurrency setting
(concurrency-limits)
🤖 Prompt for AI Agents