Skip to content

adds SSH signature validation for git commits#1141

Open
bb-Ricardo wants to merge 11 commits intofluxcd:mainfrom
bb-Ricardo:rb-feature/adds-ssh-signature-validation
Open

adds SSH signature validation for git commits#1141
bb-Ricardo wants to merge 11 commits intofluxcd:mainfrom
bb-Ricardo:rb-feature/adds-ssh-signature-validation

Conversation

@bb-Ricardo
Copy link
Copy Markdown

This PR adds support of SSH signature validation.

resolves: fluxcd/flux2#4145

  • adds new package git/signatures
  • adds validation of SSH signed commits to ssh_signature.go
  • moves GPG signature validation to gpg_signature.go
  • adds text fixtures for all SSH and GPG key types including commits and signatures
  • adds tests for all key/signature combinations
  • adds wrapper for "Verify(keyRings ...string)" function

@bb-Ricardo bb-Ricardo force-pushed the rb-feature/adds-ssh-signature-validation branch 2 times, most recently from 96523af to 1561774 Compare February 28, 2026 00:35
@stefanprodan
Copy link
Copy Markdown
Member

@bb-Ricardo please run make tidy and force push to unblock the test.

@bb-Ricardo bb-Ricardo requested a review from a team as a code owner February 28, 2026 08:48
@bb-Ricardo bb-Ricardo force-pushed the rb-feature/adds-ssh-signature-validation branch from eedb46c to 048e862 Compare February 28, 2026 09:07
@bb-Ricardo bb-Ricardo force-pushed the rb-feature/adds-ssh-signature-validation branch from e247a34 to 5e6ab4d Compare March 2, 2026 23:16
@bb-Ricardo
Copy link
Copy Markdown
Author

Hi, was just wondering if this PR is sufficient or if anything else is needed?

@stefanprodan stefanprodan added enhancement New feature or request area/git Git and SSH related issues and pull requests labels Mar 10, 2026
@stefanprodan
Copy link
Copy Markdown
Member

Hey @hiddeco and @pjbgf could you please review?

Copy link
Copy Markdown
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

Tests are failing with open signatures/... no such file or directory please run make test-git before pushing commits.

@bb-Ricardo
Copy link
Copy Markdown
Author

sorry for that, now the tests passed locally.

@bb-Ricardo bb-Ricardo force-pushed the rb-feature/adds-ssh-signature-validation branch from 83338dc to 51ceefd Compare March 10, 2026 14:30
@bb-Ricardo
Copy link
Copy Markdown
Author

@hiddeco - would you mind to have a look at this PR again? Thank you.

Copy link
Copy Markdown
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

@bb-Ricardo thanks for working on this. Overall LGTM, however I'd remove any references to DSA as per thread below.

// It returns the fingerprint of the key the signature was verified with, or an error.
// It does not verify the signature of the referencing tag (if present). Users are
// expected to explicitly verify the referencing tag's signature using `c.ReferencingTag.VerifySSH()`
func (c *Commit) VerifySSH(authorizedKeys ...string) (string, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think having a new func per type is sub-optimal as that violates OCP. From an user perspective that feels a bit awkward, as you need to iterate through commits, check each type and then make the verification. I'd rather that is abstracted away.

That being said, we can keep this as is and revisit it during the implementation upstream in go-git.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @pjbgf,

I could rework this but didn't want to break any current implementation in the source-controller. Not actually sure which other component uses this part of the pkg.

I would also like to see most of the functionality implemented in go-git and only abstract here where needed.

Maybe we can continue with the discussions over there.

@stefanprodan
Copy link
Copy Markdown
Member

stefanprodan commented Mar 19, 2026

@bb-Ricardo please use rebase not merge. Undo the last merge, and properly rebase your fork, GH has a button for this if you go to your forked repo.

- adds new package git/signatures
- adds validation of SSH signed commits to ssh_signature.go
- moves GPG signature validation to gpg_signature.go
- adds text fixtures for all SSH and GPG key types including commits and signatures
- adds tests for all key/signature combinations
- adds wrapper for "Verify(keyRings ...string)" function

Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
bb-Ricardo and others added 4 commits March 19, 2026 12:24
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
…tureType'

Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
Signed-off-by: Ricardo <ricardo@bitchbrothers.com>
Signed-off-by: Ricardo Bartels <ricardo.bartels@telekom.de>
@bb-Ricardo bb-Ricardo force-pushed the rb-feature/adds-ssh-signature-validation branch from b6f0ece to bd9abd8 Compare March 19, 2026 11:30
@bb-Ricardo
Copy link
Copy Markdown
Author

@bb-Ricardo please use rebase not merge. Undo the last merge, and properly rebase your fork, GH has a button for this if you go to your forked repo.

Yes, sorry. I used the seemingly convenient button GitHub offered in this PR. I removed all occurrences of GPG DSA keys in the tests and test fixtures.
Also rebased onto the current main.

@bb-Ricardo bb-Ricardo requested a review from pjbgf March 23, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/git Git and SSH related issues and pull requests enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants