Skip to content

fix(rules): match gpg2 and --export-secret-key in gpg-keyring-access - #1044

Open
rudycelekli wants to merge 1 commit into
Asymptote-Labs:mainfrom
rudycelekli:fix/gpg-export-secret-key-spellings
Open

rudycelekli wants to merge 1 commit into
Asymptote-Labs:mainfrom
rudycelekli:fix/gpg-export-secret-key-spellings

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

What was wrong

gpg-keyring-access misses two common ways of exporting a private key:

  • The singular option. The pattern only accepts --export-secret-keys and --export-secret-subkeys. gpg also accepts the singular --export-secret-key, as an unambiguous prefix, and many guides use it. So gpg --armor --export-secret-key ABCDEF12 > key.asc went unflagged.
  • The gpg2 binary. The command anchor is gpg\b, which does not match gpg2, the binary name on distros that ship GnuPG 2 alongside 1.x. So gpg2 --export-secret-keys --armor > all.asc went unflagged.

The fix

The anchor is now gpg2?\b in the three command clauses, and the export clause accepts --export-secret-(keys?|subkeys?). A public --export still does not match. I updated the description and bumped the rule version to 2.

Tests

I added two match fixtures and a no_match for gpg --armor --export. Before the fix:

gpg-keyring-access/gpg_export_secret_key_singular: expected match, got no_match
gpg-keyring-access/gpg2_export_secret_keys: expected match, got no_match

What I ran

cd pkg/asymptoteobserve && go test -count=1 ./...   # all ok (go1.27.2)

This branch has not been deployed

No deployments
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