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

Implementation of the rest of the gpg signing support #2728

Closed
wants to merge 5 commits into from

Conversation

necauqua
Copy link
Contributor

@necauqua necauqua commented Dec 21, 2023

So I've been using this stack locally for a while and I'm very happy with it, but I couldn't find it in me (at least for a little while at the moment) to actually finish it, and the only thing that has to be done here is just more tests 🤷

And well also I just noticed the changelog checkbox, changelog too
And also SSH impl, I was focused on GPG, but an SSH impl should be trivial at this point (cc @chriskrycho)

I'm just pushing this just so that it's not only on my machine, and maybe for someone to take it and make the final push to have it in main (maybe me after a few months) - every commit is independent and can be cherry-picked (hm, except I think in the templater one I touch some stuff in the signer, could conflict a little, eh)

Also the GPG impl commit has those weird tests that need a gpg binary in path which I'm 95% certain will fail on windows/mac, and maybe on linux too 🙃

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
necauqua Anton Bulakh
Now it is actually possible to set GPG as the main backend and have jj
"preserving" signatures on rewrites. Just no way to make signatures yet

Verified

This commit was signed with the committer’s verified signature.
necauqua Anton Bulakh
Cannot make it accept multiple revisions easily, that'd have to be done
with a rebaser
@necauqua necauqua changed the title sign: Implement and test GPG signing backend Implementation of the rest of the gpg signing support Dec 21, 2023

Verified

This commit was signed with the committer’s verified signature.
necauqua Anton Bulakh
Add it to default templates as well, it only shows anything when
there's a signature.

Verified

This commit was signed with the committer’s verified signature.
necauqua Anton Bulakh
@necauqua
Copy link
Contributor Author

huh codespell actually caught something, cool

@necauqua
Copy link
Contributor Author

necauqua commented Dec 21, 2023

Huuuuuh, gpg is not only present on the windows worker, but even works (in a sense that jj successfully calls the command, so a build off this PR should work on windows) - only thing breaking seems to be how I import the test keys - idk how to fix, and I've no windows machine

And it did work on mac too

Verified

This commit was signed with the committer’s verified signature.
necauqua Anton Bulakh
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

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

(just random comments for the first two. I haven't reviewed the other patches.)


impl SigningBackend for GpgBackend {
fn name(&self) -> &str {
"GPG"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe better to stick to lowercase "gpg"? I expect config key would be lowercase (with dash or underscore.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Resolved in #3007

// in the output from --status-fd=1
// Assume signature is invalid if none of the above was found
output
.split(|&b| b == b'\n')
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps, this text parsing part can be split to function, and added test for that.

signature_file.path().as_os_str(), /* the only reason we have those .as_refs
* transmuting to &OsStr everywhere.. */
"-".as_ref(),
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe run() could be split to two functions? If the first half returned a Command object, we don't have to build a slice of a certain type.

.prefix("jj-test-")
.tempdir()
.unwrap()
.into_path();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you know, but this temporary directory isn't removed at exit.

Copy link
Contributor

Choose a reason for hiding this comment

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

The tempfile crate implements the Drop trait which cleans up the file. This should be fine!

Copy link
Contributor

Choose a reason for hiding this comment

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

It's static object, so Drop won't be called afaik.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, makes sense

force: bool,
/// Drop the signature, explicitly "un-signing" the commit.
#[arg(long, short = 'D', conflicts_with = "force")]
drop: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might be better to make sign --drop a separate command. jj tends to have create/delete/set/get/list verbs as subcommands.

@0xdeafbeef 0xdeafbeef linked an issue Feb 6, 2024 that may be closed by this pull request
@julienvincent
Copy link
Contributor

I started work on adding an ssh backend - initial wip implementation based on the GpgBackend can be found here: julienvincent@eb623e6

This commit was created and signed by that commit! I love that haha.

@julienvincent
Copy link
Contributor

julienvincent commented Feb 9, 2024

A comment I have after using this - I don't think commands like jj log and jj show should show or verify the signature by default.

  1. Even if someone has signing enabled they might not have the necessary public keys configured for verification on their local machine.

  2. It has a not-insignificant performance impact when viewing the log - especially on larger repos.

Git only performs signature validation when the --show-signature flag is passed - I think jj should expose the same or similar behaviour.

I'll make this change on my branch unless someone objects.

@necauqua
Copy link
Contributor Author

necauqua commented Feb 9, 2024

might not have the necessary public keys configured for verification on their local machine

Well then it'll show ?s, which is "unknown", all part of the plan - it specifically does show you that you need to import some keys if you enabled signing

performance impact

I thought about it, but it didn't seem that bad, and it's only there if you enable signing, again

I think jj should expose the same or similar

We could remove it from the default template and add docs that show how to get it back if someone wants them (also check out builtin_log_detailed)
I had no issues, but I've never used repos that would have thousands of signatures either - and I really like the green checkmarks it gives me :)

Also okay performance issue makes sense for log, but what's wrong with show? It's just a single commit then

@necauqua
Copy link
Contributor Author

Superseded by #3007 and it's followups

@necauqua necauqua closed this Feb 19, 2024
@necauqua necauqua deleted the necauqua/signing branch February 19, 2024 22:45
This was referenced Feb 25, 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.

support for signed commits
3 participants