Skip to content

Fix bugs found in semgrep issue fixes#2069

Open
swell-agent wants to merge 6 commits intowavesplatform:fix-semgrep-issues-2from
swell-agent:issue-2068
Open

Fix bugs found in semgrep issue fixes#2069
swell-agent wants to merge 6 commits intowavesplatform:fix-semgrep-issues-2from
swell-agent:issue-2068

Conversation

@swell-agent
Copy link
Copy Markdown
Contributor

Summary

Continues work on PR #1966 by fixing bugs and issues found during code review of the semgrep fixes branch.

Closes #2068

Fixes

  • Critical: Wrong variable in error check (pkg/node/node.go:125) — errors.Is(err, net.ErrClosed) checked the wrong variable (err from Listen() which is always nil at that point). Changed to acErr from Accept().
  • Critical: Incorrect error wrapping (cmd/wmd/internal/data/symbols.go:120) — Removed %w wrapping of an unrelated base58 parse error in the "unknown ticker" error message.
  • Major: Unsigned integer underflow (cmd/chaincmp/chaincmp.go:227) — Added guard against middle == 0 underflow when computing stop = middle - 1 with uint64.
  • Major: Close error not propagated (cmd/statehash/statehash.go) — Added named return err and errors.Join to propagate state close errors instead of silently logging them.
  • Major: Timer reset pattern (pkg/networking/session.go) — Moved timer.Reset() from before select to after <-timer.C case, following the canonical Go timer pattern.
  • Major: Missing SIGTERM handling (cmd/chaincmp/chaincmp.go) — Added syscall.SIGTERM to signal.NotifyContext to restore graceful shutdown on SIGTERM (lost when sigterm.go was deleted).
  • Minor: Redundant url.Parse (pkg/client/addresses.go) — Removed unnecessary intermediate url.Parse call since joinUrl already parses the path.

Test plan

  • make completes without errors
  • All existing tests pass
  • semgrep ci returns only configuration-related warnings

🤖 Generated with Claude Code

- Fix wrong variable in error check (err -> acErr) in node.go
- Remove incorrect error wrapping in symbols.go ParseTicker
- Add unsigned underflow guard in chaincmp binary search
- Propagate state close error via named return in statehash
- Move timer.Reset after channel read in session keepaliveLoop
- Restore SIGTERM handling in chaincmp signal.NotifyContext
- Remove redundant url.Parse in addresses.go
- Reduce cognitive complexity of statehash run() by extracting
  parseFlags, setupFDLimits, openState, and compareAndSearch helpers
- Fix variable shadowing in grpc server files and appender by renaming
  inner err variables (sErr, iErr, vErr)
- Move nosemgrep comments to separate lines above code to fix line
  length violations (>120 chars)
- Fix nosemgrep comments incorrectly placed inside raw string literals
  breaking JSON parsing in test files
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