fix(config): reject empty selected service sections - #16
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 571cbd3103
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err != nil { | ||
| return err | ||
| } | ||
| if len(topCfg.Forward) == 0 { |
There was a problem hiding this comment.
Reject empty service objects, not just empty lists
When the selected section is written as forward: {} or forward: [{}], YAML decoding produces a list of length one containing a zero-valued config, so this check is bypassed and the later merge starts the built-in forwarder on :22. The equivalent proxy: {} case also starts the default proxy. Validate that the selected instances contain configuration fields rather than relying only on the list length.
Useful? React with 👍 / 👎.
| return err | ||
| } | ||
| if len(topCfg.Forward) == 0 { | ||
| return errors.New(i18n.T(i18n.KeyErrConfigSectionEmpty, "forward")) |
There was a problem hiding this comment.
Apply the configured language before reporting missing sections
When a valid file sets a top-level language, such as lang: fr, but omits the selected service, this newly added error is formatted before the later SetLang block processes topCfg.Lang; consequently the error uses the environment/default language rather than the configuration's requested language. The same ordering affects the proxy check.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c5af31c66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return err | ||
| } | ||
| if len(topCfg.Forward) == 0 || | ||
| (len(topCfg.Forward) == 1 && (topCfg.Forward[0] == nil || *topCfg.Forward[0] == (ForwardConfig{}))) { |
There was a problem hiding this comment.
Validate every instance in multi-instance sections
When a section contains two or more entries, this len(...) == 1 guard leaves empty entries unchecked. For example, forward: [{listen_port: 13001}, {}] reaches runForwardMulti, which fills the empty entry from defaultForwardOptions and starts an unintended :22 forwarder; an analogous proxy list starts the default proxy. Reject zero-valued or null entries at every list index rather than only when the list has one element.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fc1d266fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if len(topCfg.Forward) == 0 { | ||
| return errors.New(i18n.T(i18n.KeyErrConfigSectionEmpty, "forward")) |
There was a problem hiding this comment.
Merge the same config snapshot that was validated
When a config manager atomically replaces the file during startup, this validates the first read but the single-instance path later reads the file again at loadForwardConfig; if that second snapshot is empty or lacks forward, merging it leaves the built-in :22 forwarder active despite this fail-closed check. The same two-read race exists in runProxy between its validation and later loadTopConfig, so retain and merge the already validated topCfg snapshot instead of reopening the path.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
-configdoes not define the selectedforwardorproxysectionforward: []andproxy: []instead of starting built-in defaultsWhy
An explicitly supplied configuration should never silently start the default forwarder or proxy. The previous fallback was especially risky for the default forward listener because it could bind
:22when running with sufficient privileges.Validation