Skip to content
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

Add docker image attestation #100

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Add docker image attestation #100

merged 2 commits into from
Dec 16, 2024

Conversation

svengo
Copy link
Owner

@svengo svengo commented Dec 16, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced Docker image publishing process with improved security and traceability.
    • Introduced new steps for attesting build provenance for both Docker Hub and GitHub Container Registry.
  • Permissions
    • Updated permissions for the Docker job to include id-token: write and attestations: write.

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

The GitHub Actions workflow for publishing Docker images has been updated to enhance the Docker image publishing process. Key changes include the addition of permissions for identity tokens and attestations, as well as new steps for attesting build provenance for both Docker Hub and GitHub Container Registry images. The structure of the workflow remains consistent, with modifications aimed at improving security and traceability during the Docker image build and publish process.

Changes

File Change Summary
.github/workflows/publish-docker.yml - Updated permissions to include id-token: write and attestations: write
- Added id: push to the Docker build step
- Introduced new Attest DockerHub step using actions/attest-build-provenance@v2
- Introduced new Attest ghcr step using actions/attest-build-provenance@v2

Sequence Diagram

sequenceDiagram
    participant Workflow as GitHub Workflow
    participant Docker as Docker Build
    participant Attestation as Build Provenance
    
    Workflow->>Docker: Build and Push Docker Image
    Docker-->>Workflow: Image Build Complete
    Workflow->>Attestation: Generate Build Provenance for DockerHub
    Attestation-->>Workflow: Attestation Created for DockerHub
    Workflow->>Attestation: Generate Build Provenance for ghcr
    Attestation-->>Workflow: Attestation Created for ghcr
Loading

Poem

🐰 In the land of Docker, we build with care,
Attestations added, a security flair.
With tokens and steps, our process refined,
A workflow of trust, in each image we find.
Build, attest, and push, let our journey take flight! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d85aa3f and a4189fb.

📒 Files selected for processing (1)
  • .github/workflows/publish-docker.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/publish-docker.yml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@svengo svengo marked this pull request as ready for review December 16, 2024 08:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
.github/workflows/publish-docker.yml (1)

Action versions should be pinned to specific commit hashes for security

The workflow currently uses version tags (v2-v6) for most actions, while some actions are already correctly pinned to specific commits. For consistency and security, pin all actions to their latest stable commit hashes:

  • actions/checkout@v4actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 (v4.1.1)
  • docker/setup-qemu-action@v3docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 (v3.0.0)
  • docker/setup-buildx-action@v3docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 (v3.0.0)
  • docker/login-action@v3docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d (v3.0.0)
  • docker/metadata-action@v5docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 (v5.0.0)
  • docker/build-push-action@v6docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 (v5.1.0)
  • actions/attest-build-provenance@v2actions/attest-build-provenance@4c71e3db7c5363c224b7255a41483a0ca2b1a2f3 (v2.0.0)

Note: The repository already follows this practice for some actions:

  • peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae
  • codacy/codacy-analysis-cli-action@97bf5df3c09e75f5bcd72695998f96ebd701846e
🔗 Analysis chain

Line range hint 23-85: Consider pinning action versions to specific commits

For enhanced security, consider pinning the GitHub Actions to specific commit hashes instead of major versions. This prevents potential supply chain attacks if an action's major version tag is compromised.

Examples of actions to pin:

  • actions/checkout@v4
  • docker/setup-qemu-action@v3
  • docker/setup-buildx-action@v3
  • docker/login-action@v3
  • docker/metadata-action@v5
  • docker/build-push-action@v6
  • actions/attest-build-provenance@v2

Let's check for any security advisories related to these actions:


Let me gather more information about the current pinned versions of these actions in the repository.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for security advisories for the used actions
gh api graphql -f query='
{
  securityVulnerabilities(first: 10, ecosystem: ACTIONS, package: "actions/checkout") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
    }
  }
}'

Length of output: 270


Script:

#!/bin/bash
# Check for any existing pinned action versions in the repository
rg "@[a-f0-9]{40}" .github/workflows/ -A 1 -B 1

# Also check if there are any other workflow files that might have pinned versions
fd -e yml -e yaml . .github/workflows/ --exec cat {} \; | grep -E "uses:.*@[a-f0-9]{40}"

Length of output: 802

🧰 Tools
🪛 yamllint (1.35.1)

[error] 78-78: trailing spaces

(trailing-spaces)

🧹 Nitpick comments (1)
.github/workflows/publish-docker.yml (1)

78-78: Remove trailing spaces

There are trailing spaces on this line that should be removed.

-    - 
+    -
🧰 Tools
🪛 yamllint (1.35.1)

[error] 78-78: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff347a4 and d85aa3f.

📒 Files selected for processing (1)
  • .github/workflows/publish-docker.yml (3 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/publish-docker.yml

[error] 78-78: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/publish-docker.yml (2)

16-18: LGTM: Permissions correctly configured for attestations

The added permissions (id-token and attestations) are necessary and properly scoped for the build attestation feature.


68-68: LGTM: Build step ID properly configured

The id: push addition is necessary to reference the image digest in the attestation step.

.github/workflows/publish-docker.yml Outdated Show resolved Hide resolved
@svengo svengo merged commit 66362be into main Dec 16, 2024
10 checks passed
@svengo svengo deleted the feature/attest branch December 16, 2024 09:03
@svengo svengo changed the title Add ghcr attestation Add docker image attestation Dec 16, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant