Repository navigation
feat: nodkey broker check checks a config without a start - #178
Merged
Merged
Conversation
nodkey broker check --config FILE [--files DIR] [--credentials DIR] parses the config with the parser of the start and a reload, and checks the files it names with CheckFilesAs. It starts nothing, opens no port, uses no network, needs no root, and reads no credential. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
This was referenced Nov 11, 2026
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 #173.
What
nodkey broker check [--config FILE] [--files DIR] [--credentials DIR]checks a broker config without a start.config.loadBrokernow takes a files directory, andconfig.ReadBrokerFilesis its entry.nodkey doctor brokeruses the same parser (ReadBroker) and the same file checks (CheckFilesAs).CheckFilesAs, for the user that runs it. The list of private files is now one function,(*Broker).PrivateFiles, used byCheckFilesAsand by the check. The checks of the start do not change.${CREDENTIALS_DIRECTORY}/file is skipped, and the output says so. With--credentials DIR, it only looks forNAMEorNAME.credin DIR. It opens none of them.--files DIR,known_hostsis read from DIR by its base name, not from its path. The files of the broker host (TLS key, token and key files, store programs, audit log) are then not checked. Without--config, the config isDIR/broker.toml.claim.Line, so text in a config from a pull request cannot add lines to a CI log.What it cannot find: problems that only the content of a credential shows, such as a key that does not parse. The start and a reload still check these. DESIGN.md says so.
Tests
TestBrokerCheckRefusesWhatTheStartRefuses: for 5 bad configs (bad pin, unknown host, store program that others can change, known_hosts that others can change, audit log that is another file of the broker), the realnodkey brokerstart in a child process exits 1, and the check exits 1 with the same reason. A good config passes.TestBrokerCheckFiles: with--files, theknown_hostsat the config's path is removed and the check passes; then a good file at the path and a bad one in DIR: the check refuses.TestBrokerCheckNeedsNoCredentials: runs as a user that is not root, with the listen address held by the test. Skips each credential without--credentials; findsNAMEandNAME.credfiles with mode 0 (not read); refuses a missing one, a directory, a directory it cannot enter (with its own error), and a path with...TestBrokerCheckCleansConfigText,TestBrokerCheckUsage.Security review
The
security-revieweragent found 1 medium and 4 low points, then 2 more low points. All are fixed. One note is left for a follow-up issue: the start accepts${CREDENTIALS_DIRECTORY}/../x(the check refuses it). This is a change of the start, outside this issue.Progress
--files,--credentials🤖 Generated with Claude Code