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

feat(changelog): skip ssh and x509 signatures in tag messages #748

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

PigeonF
Copy link
Contributor

@PigeonF PigeonF commented Jul 6, 2024

Description

Support for tag messages was added in 3eb828e. The commit contains code for stripping GPG signatures from the tag message, but git supports SSH signatures and x509 signatures as well.

This PR adds support for stripping those signature types.

The regex is not 100% accurate (e.g. this would allow SSH MESSAGE, which is not part of the gitformat-signature description), but I prioritized readability over correctness in this case (since the code is for replacing text, not verifying the signature).

Motivation and Context

Signatures should not show up in the changelog, regardless of what kind of signature was used.

How Has This Been Tested?

I have no x509 certificates, but I created a SSH-signed tag in my fork, and then ran the resolves_existing_tag_with_name_and_message test and replaced the tag that is checked from v0.2.3 to example-ssh-signed-tag

diff --git a/git-cliff-core/src/repo.rs b/git-cliff-core/src/repo.rs
index 95843d76840ce4d5..219d7a6e979e3db3 100644
--- a/git-cliff-core/src/repo.rs
+++ b/git-cliff-core/src/repo.rs
@@ -372,8 +372,8 @@ mod test {
        #[test]
        fn resolves_existing_tag_with_name_and_message() -> Result<()> {
                let repository = get_repository()?;
-               let tag = repository.resolve_tag("v0.2.3");
-               assert_eq!(tag.name, "v0.2.3");
+               let tag = repository.resolve_tag("example-ssh-signed-tag");
+               assert_eq!(tag.name, "example-ssh-signed-tag");
                assert_eq!(
                        tag.message,
                        Some(

Screenshots / Logs (if applicable)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Arguably this could also be a bug fix.

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I did not update any documentation, since I could find no mention of the gpg signature stripping.

I am not sure how to add a test: the existing functionality is covered by reading a tag that is GPG signed, but I have no way to add a SSH signed tag to this repository :^)

Git supports SSH and x509 signatures in addition to GPG signatures.
See <https://git-scm.com/docs/gitformat-signature#_description>.

The regex is not 100% accurate (e.g. this would allow `SSH MESSAGE`,
which is not part of the gitformat-signature description), but I
prioritized readability over correctness in this case (since the code is
for replacing text, not verifying the signature).
@PigeonF PigeonF requested a review from orhun as a code owner July 6, 2024 12:00
Copy link

welcome bot commented Jul 6, 2024

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.71%. Comparing base (227a307) to head (09e7650).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #748   +/-   ##
=======================================
  Coverage   36.71%   36.71%           
=======================================
  Files          19       19           
  Lines        1501     1501           
=======================================
  Hits          551      551           
  Misses        950      950           
Flag Coverage Δ
unit-tests 36.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

Perfect, thanks for catching this!

@orhun orhun merged commit ecbabbf into orhun:main Jul 27, 2024
53 of 54 checks passed
@orhun orhun changed the title feat: Skip ssh and x509 signatures in tag messages feat(changelog): skip ssh and x509 signatures in tag messages Jul 27, 2024
Copy link

welcome bot commented Jul 27, 2024

Congrats on merging your first pull request! ⛰️

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.

3 participants