Skip to content

refactor(cli): inject allocators + de-flake/extend tests (audit follow-ups)#384

Merged
BANANASJIM merged 1 commit into
mainfrom
fix/audit-cli-skipped
Jun 7, 2026
Merged

refactor(cli): inject allocators + de-flake/extend tests (audit follow-ups)#384
BANANASJIM merged 1 commit into
mainfrom
fix/audit-cli-skipped

Conversation

@BANANASJIM

Copy link
Copy Markdown
Owner

Addresses the four audit findings an earlier batch skipped (the other three — mappingLabel deletion, scan DEFAULT_CONFIG_DIR, dump alias — were already merged and verified gone in current code).

Changes

  • config/test.zig readVidPid — take an allocator param instead of hard-coding std.heap.page_allocator; thread it from run(), which already receives the allocator (api-consistency).
  • switch_mapping.zig run() — accept an allocator param instead of constructing an internal GPA; thread the existing process allocator from main.zig. The only allocation (findMapping result) is freed via defer before return, so the injected allocator's lifetime is correct (no use-after-free, no leak); behavior is identical.
  • devices.zig test — bind+listen on the caller thread before spawning the server thread, eliminating the connect/bind race; removed Thread.sleep(10ms). The listen backlog holds the pending connection until accept, so it is deterministic. Asserted property (rc == 1 on ERR response) unchanged.
  • config/test.zig — extract formatReport from run()'s read loop (public run() signature unchanged) and add falsifiable Layer-0 tests for the report hex-dump format, the remap hint, and readVidPid.

Test plan

  • ./scripts/padctl-docker test → EXIT=0.
  • Falsifiability: deliberately corrupting the formatReport expected string makes the suite fail (src.cli.config.test.test.formatReport: hex dump without mapping' failed, EXIT=1); restored to green.
  • zig fmt --check (zig 0.15.2) clean on all changed files.

refs: codebase audit

…w-ups)

- config/test.zig readVidPid: take allocator param instead of page_allocator; thread through from run() (api-consistency)
- switch_mapping.zig run(): accept allocator instead of building an internal GPA; thread the process allocator from main.zig
- devices.zig test: bind+listen on caller thread before spawning server, removing Thread.sleep(10ms) race; assertion unchanged
- config/test.zig: extract formatReport helper and add falsifiable Layer-0 tests for the report hex-dump, remap hint, and readVidPid

refs: codebase audit
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@BANANASJIM, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa08a2c6-ebf9-4ed3-8b94-ae5a44393f60

📥 Commits

Reviewing files that changed from the base of the PR and between 387ac36 and 7dc584f.

📒 Files selected for processing (4)
  • src/cli/config/test.zig
  • src/cli/devices.zig
  • src/cli/switch_mapping.zig
  • src/main.zig
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-cli-skipped

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@BANANASJIM BANANASJIM merged commit 96bd619 into main Jun 7, 2026
36 checks passed
@BANANASJIM BANANASJIM deleted the fix/audit-cli-skipped branch June 7, 2026 05:07
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