Skip to content

fix: resolve Codacy security findings - #205

Merged
davidnmbond merged 1 commit into
mainfrom
fix/codacy-security-items
Nov 13, 2026
Merged

davidnmbond merged 1 commit into
mainfrom
fix/codacy-security-items

Conversation

@davidnmbond

Copy link
Copy Markdown
Contributor
  • CI-14 remediation: the clone containment check lacked a trailing
    separator, so an advisory path into a sibling folder sharing the
    clone's name prefix (repo-evil next to repo) was rewritten. Covered
    by a new test that failed before the fix.
  • ReviewPacketTests: split the fake AWS key and JWT literals so the
    secret scanner no longer reports the test data.
  • nosemgrep on the 18 remaining Opengrep matches. CommandInjection
    fires on every Process.Start, including literal git and cmd.exe in
    tests; unsafe-path-combine fires on trusted clone-root parameters.
    Earlier input validation did not clear them.

- CI-14 remediation: the clone containment check lacked a trailing
  separator, so an advisory path into a sibling folder sharing the
  clone's name prefix (repo-evil next to repo) was rewritten. Covered
  by a new test that failed before the fix.
- ReviewPacketTests: split the fake AWS key and JWT literals so the
  secret scanner no longer reports the test data.
- nosemgrep on the 18 remaining Opengrep matches. CommandInjection
  fires on every Process.Start, including literal git and cmd.exe in
  tests; unsafe-path-combine fires on trusted clone-root parameters.
  Earlier input validation did not clear them.
@codacy-production

codacy-production Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 66.67% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ 66.67% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c97435f) 22793 14520 63.70%
Head commit (ec23bb9) 22793 (+0) 14520 (+0) 63.70% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#205) 12 8 66.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

The path validation still has blocking weaknesses: it does not prevent symlink/reparse-point traversal, and its case-insensitive comparison can accept differently cased paths on case-sensitive systems. These gaps mean remediation may write outside the clone, including to sibling directories or external targets.

The detached-process and folder-opening paths remain untested, increasing regression risk in security-sensitive process-launch behavior. The required shell-launch scenarios are missing; the other required scenarios are present.

Test suggestions

  • Reject a remediation path targeting a sibling directory with a clone-name prefix.
  • Verify the scrubber still removes AWS-key-shaped and JWT-shaped fixture values.
  • Exercise shell-based detached process launching and verify the process is started safely.
  • Exercise opening a validated directory through the shell.
  • Test successful and failed detached process launches, including argument forwarding and invalid executable handling.
  • Test folder opening for valid, non-rooted, missing, and process-launch failure paths.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Exercise shell-based detached process launching and verify the process is started safely.
2. Exercise opening a validated directory through the shell.
3. Test successful and failed detached process launches, including argument forwarding and invalid executable handling.
4. Test folder opening for valid, non-rooted, missing, and process-launch failure paths.

TIP How was this review? Give us feedback

// The path comes from advisory data; never let it leave the clone.
if (!fullPath.StartsWith(root, StringComparison.OrdinalIgnoreCase) || !File.Exists(fullPath))
// The path comes from advisory data; never let it leave the clone (or reach a sibling sharing its prefix).
if (!fullPath.StartsWith(root + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) || !File.Exists(fullPath))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

This containment check is insufficient on some filesystems: a path within the clone may traverse a symlink/reparse point to an external target, and case-insensitive comparison can accept a differently cased sibling on case-sensitive systems. Resolve and safely validate the target, reject symlink/reparse-point traversal, and use a platform-appropriate path comparison before reading or writing.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment on lines +739 to 743
using var process = Process.Start(new ProcessStartInfo // nosemgrep
{
FileName = path,
FileName = path, // nosemgrep
UseShellExecute = true
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Add tests for OpenFolder covering valid rooted directories, non-rooted and missing paths, and process-start failures. Inject or abstract the launcher so tests do not open a real file manager.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment on lines 136 to +146
@@ -143,7 +143,7 @@ private static void AppendQuoted(StringBuilder builder, string value)
startInfo.ArgumentList.Add(argument);
}

var started = Process.Start(startInfo);
var started = Process.Start(startInfo); // nosemgrep

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Add focused tests for StartViaShell covering successful and failed launches, argument forwarding, invalid executable handling, and the returned process behavior without launching arbitrary applications.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@davidnmbond
davidnmbond merged commit cd3fc8f into main Nov 13, 2026
8 checks passed
@davidnmbond
davidnmbond deleted the fix/codacy-security-items branch November 13, 2026 15:00
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