-
Notifications
You must be signed in to change notification settings - Fork 754
config: Allow both user-managed and repo-managed configs per repo #6990
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
base: main
Are you sure you want to change the base?
Conversation
|
Please format the commits to adhere to our commit guidelines here: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#commit-guidelines and add a motivation to each commit. This is also missing tests and a changelog entry since the second commit even introduces a new command. |
|
I know, that's why it's a draft commit. Just want to make sure the concept is approved before I add finishing touches. |
e115b70 to
78f20ea
Compare
|
The idea sounds generally good to me. We might also want a similar mechanism for the zip file problem. Since the I have no idea about TUI. I personally would want to just see the diff and accept/reject. |
I'm not familiar with "the zip file problem". Could you link to the issue?
I'm not opposed to that. I chose this method because it was the same directory that the repo config was stored. I would request, however, that we submit this first and worry about that later, since this is explicitly not making the security any worse than it already is.
I do agree, as a user, that that's what I would want, but that's also relatively easy to achieve with the TUI. I think, however, that from a security perspective, a binary accept / reject choice is not great, because it might feel like you have to make a choice between new features and security. With a binary choice, if there's one particular line that you are concerned about and so you reject it, that means you have to reject every future change to the repo config. |
I don't think we have a link, but it's a familiar problem from other VCSs (familiar to VCS developers). The problem is what to do about repo-level configs in |
|
Makes sense. So I assume the solution would be to store it out of the repo, and require users to run |
|
I think Yuya's proposal was to record trusted config contents somewhere in I'm not sure if it's safe to trust configs at the key-value level or only at coarser granularity. Could there be some case where you say that you trust |
AFAICT, the attack surfaces are, in order of danger:
This is my analysis of the danger:
I think that it's possible to make one harmful thing and one alias to it, but I don't think it's possible to make two things that are independently safe but together harmful (it's technically possible with two arbitrary commands that execute files in the repo, but if they're doing that then they can already achieve this). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a bunch of actual review comments.
78f20ea to
507083f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably OK. My worries are:
-
Is this too inflexible to be useful? For example, as the user jumps from commit to commit, the repo-managed config may change, and I don't see a way to decide automatically whether they want their config to change accordingly (even if we trusted the config; see my hash idea in the other comment for how we could).
-
How easy or hard will it be for the users to miss something important in the diff interface?
Figuring this out might require real-world testing. I'd probably merge some version of this, but disable it by default and call this feature "experimental" for quite a bit after. This is to give us time to polish it, but also to see whether it's worth the complexity/security tradeoff in practice.
Most of my other comments are various ideas about how to polish this further, which only make sense once we have a consensus that we're going forward with this (It's not clear to me how close we are at the moment).
My thoughts were, when designing this:
I think that if the user cares about security, it's pretty hard to miss. It is also relatively easy to just blindly approve, though.
I wouldn't be opposed to putting this behind a flag. Since this is inherently pre config-load, do you know if this would be able to be in our config schema, or would it have to be something like an environment variable flag? |
128b569 to
9359e03
Compare
|
I've added a config setting to toggle this feature, as requested by @ilyagr. Does anyone have opinions on what the config file should be? My candidates were:
I ended up settling on the last one for a few reasons:
That being said, I'd welcome other opinions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in general, my answer is:
There is a potential solution to this, but it's definitely not within the scope of the MVP. We can create a mapping from |
What if repo configs don't allow aliases? |
9359e03 to
b9e6224
Compare
That wouldn't really solve the problem. You could achieve the same just as easily with a malicious Also, I think that would somewhat defeat the point of the repo config. In chromium, for example:
While the former might be (somewhat) unique to chromium, I think that an alias So TLDR, I think they have too much value to disable. I think one approach that could be taken though is some stricter security measures. For example:
In general, sandboxing reads is a lot more painful, and I'm not sure it's a good idea, but sandboxing writes does sound like a very good idea. |
|
I did a complete rework of it and fixed the zip file problem by storing it in the It now does the stuff that I mentioned where we would store hashes. This allows it to work very well in a multi-workspace repo, or when you're frequently changing between commits with different hashes. |
cd241ff to
1795aab
Compare
|
I'm currently running into some issues on windows, but I don't have a windows machine to test on. I've just got a windows machine from work, but I've got to go through some red tape in order to install cargo on it. I'd appreciate it if people would review it ignoring the error on windows, and I'll come back to it once the approval process is complete. |
fae7d33 to
645b5d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
645b5d4 to
53ca6b1
Compare
6a88ee1 to
42f97e3
Compare
This can be used to add shared configuration across a repository. For example, all users should have the same `jj fix` within a given repository. This commit adds a new command, `jj config review-managed`, which is a mechanism to approve configuration checked in to the repo. See https://chromium-review.googlesource.com/c/chromium/src/+/6703030 for an example
42f97e3 to
bd9622f
Compare
|
@yuja @martinvonz This should be ready for re-review |
Well, here's another idea... (This is not intended as a change request; It's rather a rough idea I had while reading this thread here.) When approving a repo-managed config:
Then, we can check for a certain revision if its config was approved by looking at the most recent signatures found in its ancestors, and if one of those is a valid certificate for the config we are fine. It's just a rough idea, but that would allow us to keep evidence of the approval close to the repo-managed config without relying on some "global state" in |
|
Hmm, true. We can use cryptographic hashing/signing with per-user secret key. That makes the zip file problem a totally separate issue from the repo-managed settings. Thoughts? I'll review this PR later in this week. I didn't have time last week, sorry. |
|
That idea gave me a few other ideas. I didn't really like the idea of storing approvals inside the
So what if instead we kept both user and repo-user config inside the We would then create the following data structure stored in the Note that the addition of this feature would mark existing user configs as insecure (as would any method that stops the zip file problem). We could work around this issue by automatically adding salts and marking repos as trusted for the first few months, then eventually stopping this practice. |
|
Does that still allow for workspaces and local clones? Does this impact CI testing of a repo with a repo config? (specifically the |
Yes, that's unaffected
No. A ci bot would not be able to approve repo Configs, so would ignore them |
Fixes #3684
This adds the following workflow to jj to support repo-level workflows:
jj config update-repo"jj config update-repoadds a TUI requesting the user to approve the diffChecklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)