Address Codacy critical security findings#74
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
This PR focuses on critical security hardening, including loopback-only constraints for HTTP traffic, shell injection prevention, and cryptographic randomness. While the PR addresses 39 existing issues, Codacy reports that the PR is currently not up to standards due to 17 new issues, including high-severity linting violations.
A primary concern is the lack of unit tests for the newly introduced security-critical validation logic (e.g., hostname checks, allowlists). Additionally, the absence of a coverage report makes it impossible to verify if these paths are exercised. Several implementation gaps were identified, such as incorrect IPv6 URL construction and potential information leaks through filesystem metadata access.
About this PR
- The PR lacks new unit tests to verify critical security validation logic introduced, such as rejecting non-loopback hosts or invalid command flags. Furthermore, the empty coverage report prevents verification that these new security paths are covered by existing tests.
1 comment outside of the diff
plugins/opencode/scripts/opencode-companion.mjs
line 143🔴 HIGH RISK
InitializereviewGateMaxPerSessionOverridewith a default value to avoid it evaluating toundefined. Since the project's linting rules discourage bothnullandundefined, consider using a numeric sentinel (like0or-1).
Test suggestions
- Missing: Verify that non-loopback hosts are rejected by normalizeLoopbackHost and assertLoopbackUrl in opencode-server.mjs.
- Missing: Verify that safe-command.mjs rejects unknown flags and invalid values for --agent and --model (e.g., path traversal attempts).
- Missing: Ensure withPlatformShell correctly configures the shell and windowsHide options across Windows and POSIX platforms.
- Missing: Confirm that generateJobId and makeWorktreeId produce unique, random identifiers using crypto.randomBytes.
- Missing: Automated test coverage for new security-critical code paths.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Missing: Verify that non-loopback hosts are rejected by normalizeLoopbackHost and assertLoopbackUrl in opencode-server.mjs.
2. Missing: Verify that safe-command.mjs rejects unknown flags and invalid values for --agent and --model (e.g., path traversal attempts).
3. Missing: Ensure withPlatformShell correctly configures the shell and windowsHide options across Windows and POSIX platforms.
4. Missing: Confirm that generateJobId and makeWorktreeId produce unique, random identifiers using crypto.randomBytes.
5. Missing: Automated test coverage for new security-critical code paths.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d69f51586a
ℹ️ 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".
d1a4bad to
515cc27
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 515cc27aa8
ℹ️ 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".
9fadcba to
48b8562
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48b8562f9a
ℹ️ 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".
ee326ee to
93698fa
Compare
93698fa to
3e970ed
Compare
|



Summary
Closes #72.
opencodebefore spawning server/version commandscrypto.randomBytesopencoderesolutionVerification
npm testpassed locally: 222 tests, 0 failuresnode --checkpassed for the touched process module and test filegit diff --checkpassed0new issues on head3e970ed0new issues and21fixed issues on head3e970ed