Skip to content

Repository signing: add support for dual signing #8320

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

igorpecovnik
Copy link
Member

@igorpecovnik igorpecovnik commented Jun 22, 2025

Description

Supporting armbian/apa#18

How Has This Been Tested?

  • Generated repo with new key, adding this key to OS and run update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

"""

Walkthrough

The publishing workflow in the repository tool was updated to add the -skip-signing flag to the aptly publish command, disabling automatic signing during the publish step. A new signing function was introduced to manually sign repository metadata files using GPG, generating both clear-signed InRelease files and detached Release.gpg signatures for each release. The repo-manipulate command's update case was modified to invoke this new signing process after publishing. The command usage help text was updated to mention a [sign] option, and minor whitespace cleanup was performed in the serve case. Additionally, the PGP public key in config/armbian.key was fully replaced with a new Armbian Repository Signing Key.

Suggested labels

ready to merge
"""


📜 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 3739ffb and 653bc8b.

📒 Files selected for processing (1)
  • tools/repository/repo (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/repository/repo
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Shell script analysis
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch sign-repo-with-dual-keys

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @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.

@github-actions github-actions bot added 08 Milestone: Third quarter release size/small PR with less then 50 lines Needs review Seeking for review Framework Framework components labels Jun 22, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 22, 2025
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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3844ef9 and 96a3468.

📒 Files selected for processing (1)
  • tools/repository/repo (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Shell script analysis
🔇 Additional comments (2)
tools/repository/repo (2)

137-137: LGTM: Correctly disables automatic signing for dual signing approach.

The -skip-signing flag appropriately prevents aptly from automatically signing during the publish step, allowing the new manual signing process to handle dual key signing.


277-277: LGTM: Correctly integrates dual signing into the update workflow.

The signing function call is properly placed after publishing and uses consistent parameter passing.

Comment on lines 158 to 181
# signing repository
#
# $1: Input folder
# $2: Output folder
# $3: Command
# $4: GPG password
# $5: jammy,sid

signing(){
GPG_PARAMETERS=(
"--yes"
"--armor"
"-u" "3CD6F4E701E8E7F91468ABCEAC67DF56D680226A" # Igor Pecovnik (Ljubljana, Slovenia) <igor.pecovnik@gmail.com>
"-u" "8CFA83D13EB2181EEF5843E41EB30FAF236099FE" # Armbian Repository Signing Key (Repository Key) <info@armbian.com>
)
for i in "$2"/public/dists/*/Release
do
DISTRO_PATH="$(dirname "$i")"
echo $DISTRO_PATH
gpg "${GPG_PARAMETERS[@]}" --clear-sign -o "$DISTRO_PATH/InRelease" "$i"
gpg "${GPG_PARAMETERS[@]}" --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"
done
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Address security and error handling concerns in the signing function.

The signing function has several areas that need attention:

  1. Hardcoded GPG keys: While this may be intentional for this use case, consider making the keys configurable through environment variables or parameters for better security and flexibility.

  2. Missing error handling: GPG operations can fail for various reasons (missing keys, wrong passphrase, etc.). Add error checking after each GPG command.

  3. Debug output: Line 176 outputs the distro path to stdout, which may clutter the output in production.

Apply this diff to improve error handling and output:

 signing(){
 		GPG_PARAMETERS=(
 			"--yes"
 			"--armor"
 			"-u" "3CD6F4E701E8E7F91468ABCEAC67DF56D680226A" # Igor Pecovnik (Ljubljana, Slovenia) <igor.pecovnik@gmail.com>
 			"-u" "8CFA83D13EB2181EEF5843E41EB30FAF236099FE" # Armbian Repository Signing Key (Repository Key) <info@armbian.com>
 		)
 		for i in "$2"/public/dists/*/Release
 		do
+			if [[ ! -f "$i" ]]; then
+				echo "Warning: Release file not found: $i" >&2
+				continue
+			fi
 			DISTRO_PATH="$(dirname "$i")"
-			echo $DISTRO_PATH
+			echo "Signing repository: $(basename "$DISTRO_PATH")" | sudo tee -a "${DEBUGFILE}"
-			gpg "${GPG_PARAMETERS[@]}" --clear-sign -o "$DISTRO_PATH/InRelease" "$i"
-			gpg "${GPG_PARAMETERS[@]}" --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"
+			if ! gpg "${GPG_PARAMETERS[@]}" --clear-sign -o "$DISTRO_PATH/InRelease" "$i"; then
+				echo "Error: Failed to create InRelease for $DISTRO_PATH" >&2
+				return 1
+			fi
+			if ! gpg "${GPG_PARAMETERS[@]}" --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"; then
+				echo "Error: Failed to create Release.gpg for $DISTRO_PATH" >&2
+				return 1
+			fi
 		done
 }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tools/repository/repo around lines 158 to 181, the signing function has
hardcoded GPG keys, lacks error handling after GPG commands, and prints debug
output to stdout. To fix this, make the GPG keys configurable via environment
variables or function parameters instead of hardcoding them, add checks after
each gpg command to detect failures and handle errors appropriately (e.g., exit
or log errors), and remove or redirect the echo statement that outputs the
distro path to avoid cluttering production output.

@igorpecovnik igorpecovnik force-pushed the sign-repo-with-dual-keys branch from 96a3468 to 3739ffb Compare June 22, 2025 19:54
@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines Hardware Hardware related like kernel, U-Boot, ... and removed size/small PR with less then 50 lines Ready to merge Reviewed, tested and ready for merge labels Jun 22, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 22, 2025
@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Jun 22, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 Milestone: Third quarter release Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Ready to merge Reviewed, tested and ready for merge size/medium PR with more then 50 and less then 250 lines
Development

Successfully merging this pull request may close these issues.

1 participant