-
Notifications
You must be signed in to change notification settings - Fork 751
configs: Improve security of in-repo configuration. #7761
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
Open
matts1
wants to merge
4
commits into
jj-vcs:main
Choose a base branch
from
matts1:push-slpsoluonwkm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
35ea932
test-env: Fix etcetera's data_dir method in our test environment.
matts1 2eef9ee
configs: Improve security of in-repo configuration.
matts1 aea2f95
configs: Still use configs if we don't have a signature.
matts1 cac1c1a
configs: Add a message when migrating from legacy repo configs.
matts1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,13 +552,33 @@ impl ConfigEnv { | |
// same as InvalidSignature or RepoMovedError . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove the whitespace before the period |
||
let legacy_config = path.join("config.toml"); | ||
match std::fs::read_to_string(&legacy_config).context(&legacy_config) { | ||
Ok(content) => { | ||
self.set_repo_config(&content, true)?; | ||
std::fs::remove_file(&legacy_config).context(&legacy_config)?; | ||
} | ||
Ok(content) => match read_user_config::<RepoConfig>(path) { | ||
Ok(_) => { | ||
return Err(user_error_with_hint( | ||
"Both new and legacy repo config were found. You need to delete .jj/repo/config.toml.", | ||
"You probably want to copy the contents of .jj/repo/config.toml and run `jj config edit --repo` to edit your repo config instead", | ||
)); | ||
} | ||
Err(UserConfigError::LegacyRepo) => { | ||
writeln!( | ||
ui.warning_default(), | ||
"Migrating from legacy repo config file (`$REPO_DIR/config.toml`) to \ | ||
secure configuration", | ||
)?; | ||
writeln!( | ||
ui.hint_default(), | ||
"In the future, use `jj config edit --repo` to edit your config files \ | ||
instead" | ||
)?; | ||
self.set_repo_config(&content, true)?; | ||
std::fs::remove_file(&legacy_config).context(&legacy_config)?; | ||
} | ||
Err(e) => return Err(internal_error(e)), | ||
}, | ||
Err(e) if e.source.kind() == std::io::ErrorKind::NotFound => {} | ||
Err(e) => return Err(e.into()), | ||
} | ||
|
||
self.repo_config = self.load_user_config::<RepoConfig>(ui, path)?; | ||
Ok(()) | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: squash this and the nix commit into the first one (although you may need a Nix expert to help you with the problems there before doing that).