Repository navigation
feat: nodkey broker config-diff lists config changes by meaning - #180
Merged
Merged
Conversation
It reads two configs with the parser of the start, compares them by meaning, and marks each change that widens access or weakens a control, and each change it does not know as narrowing. --short fits one Telegram message and never drops a widening line silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #174.
What
nodkey broker config-diff [--short] [--max-chars N] OLD NEWlists the changes from one broker config to another by what they mean.broker.tomlandknown_hosts(asnodkey broker check --files). For a file,known_hostsis read from the directory of the file. Both are read with the parser of the start and ofnodkey broker check:config.ReadBrokerFiles(from feat: nodkey broker check checks a config without a start #178). No copy of the config code.config.Diff(internal/config/diff.go) compares the two parsed configs. Comments, order and spaces are no change; lists of clients and hosts are sets.known_hosts) and name. A line that widens access or weakens a control starts with⚠.unknown,compared,zeroCompared), and its change is marked "a change that config-diff does not know".TestDiffComparesEveryFieldfails when a field is in neither list.--short(at most--max-chars, 3500 by default) puts the⚠lines first and cuts the rest with "and N more". When the⚠lines do not all fit, it gives one line with their count, and says to read the full list.strconv.Quote) and each line is cleaned withclaim.Line.Tests
TestDiffMarksWidening: one subtest for each kind of widening change in the issue (37 cases): new client; a secret or a key for another client; a new secret; a never rule; always to window; a longer window; wider hours and no hours; a higher and no max_per_day; notify off; more hosts and any host; preapprove; standing; a new[standing]; a longer[standing]and[preapprove]limit; another approver, notice chat, bot token file; a longer timeout; a new pin; another store program, token and password file; a secret in another store or item; another key file;listen,tls_key,audit_log,known_hostspath; a new host; a new host key; update check off.TestDiffNtfy: the channel switch and each[ntfy]setting.TestDiffUnknownIsMarked,TestDiffComparesEveryField: the catch-all.TestDiffSameMeaning: comments, spaces, the order of sections, clients and known_hosts lines give no change.TestDiffNarrowing: narrowing changes are plain lines.TestConfigDiff(exit codes 0, 1, 2; directories and files; as a user that is not root, without credentials),TestConfigDiffUsage,TestConfigDiffShort(the short form keeps every⚠line or says they do not fit, and never passes--max-chars).Security review
The
security-revieweragent found 1 medium and 3 low points. All are fixed: a config file now reads theknown_hostsnext to it (not the live one at the path in the config, which would hide a new host key; test with two files);notify,max_per_dayandhoursare compared only between twoneverrules (a move toneverlists them on its marked line); the error hints give the realnodkey broker checkcommand; the short form counts UTF-16 code units, as Telegram does. Its last small style point is fixed too. No open finding.Progress
config.Diffand its tests🤖 Generated with Claude Code