Skip to content

chore: remove dead code (unused field, var, method, import) - #102

Merged
blaspat merged 4 commits into
mainfrom
chore/remove-dead-code
Jul 21, 2026
Merged

chore: remove dead code (unused field, var, method, import)#102
blaspat merged 4 commits into
mainfrom
chore/remove-dead-code

Conversation

@blaspat

@blaspat blaspat commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Remove all dead code found by staticcheck U1000 + manual review.

Removed

  • stderr field from runResult struct (exec/shell.go) — never written or read
  • levelNames map (logger/logger.go) — never read, ParseLevel uses switch
  • (*fakeServer).setNextResp method (cmd/main_test.go) — never called
  • Dummy fmt import + var _ = fmt.Sprintf (wire/reconnect_test.go)

-22 lines, go vet clean, staticcheck clean, all tests pass.

blaspat added 4 commits July 20, 2026 13:05
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>
@blaspat
blaspat merged commit 6c1f5cd into main Jul 21, 2026
14 checks passed
@blaspat
blaspat deleted the chore/remove-dead-code branch July 21, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant