chore: remove dead code (unused field, var, method, import) - #102
Merged
Conversation
Bug #1 — TOCTOU symlink-swap allowlist bypass: handler_fs.go read/write operations used the raw p.Path instead of the canonical (symlink-resolved) path returned by checkAllowed. An attacker with filesystem write access could swap a symlink component between the allowlist check and the file operation, reading or writing files outside the permitted roots. Fix: pass canonical to Stat, ReadFile, WriteFile. Bug #2 — exec.cwd silently ignored: handler_exec.go passed the original cwd (or the shell's current cwd) to Shell.Run(callCtx, cwd, p.Command), but SessionAdapter.Run discarded the target parameter entirely. Commands ran in whatever directory the persistent bash session happened to be in. Fix: pass canonical (validated/resolved path) from handler to Shell.Run. SessionAdapter.Run now prepends when target is non-empty, so explicit cwd is honoured. Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
- Remove unused stderr field from runResult (exec/shell.go) - Remove unused levelNames map (logger/logger.go) - Remove unused (*fakeServer).setNextResp method (cmd/main_test.go) - Remove dead fmt import + dummy var _ = fmt.Sprintf (wire/reconnect_test.go) Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
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.
Remove all dead code found by staticcheck U1000 + manual review.
Removed
stderrfield fromrunResultstruct (exec/shell.go) — never written or readlevelNamesmap (logger/logger.go) — never read, ParseLevel uses switch(*fakeServer).setNextRespmethod (cmd/main_test.go) — never calledfmtimport +var _ = fmt.Sprintf(wire/reconnect_test.go)-22 lines, go vet clean, staticcheck clean, all tests pass.