Skip to content

Fix for Call to 'System.IO.Path.Combine' may silently drop its earlier arguments - #2

Merged
Alcheri merged 1 commit into
mainfrom
finding-autofix-3
Aug 11, 2026
Merged

Alcheri merged 1 commit into
mainfrom
finding-autofix-3

Conversation

@Alcheri

@Alcheri Alcheri commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Use a combination approach that cannot be reset by a rooted later segment. The best fix is to normalize the base directory first and then append the filename with Path.Join instead of Path.Combine. Path.Join concatenates path segments without the rooted-path reset behavior of Path.Combine, which directly addresses the CodeQL concern while preserving current functionality (<base>/settings.json).

In example.csharp.greeter/GreeterPlugin.cs, replace the static SettingsPath initializer (lines 8–10 in the snippet) so it uses Path.Join(...) with the same base-directory expression and "settings.json". No new imports, methods, or dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…r arguments

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Alcheri <barry.suridge@gmail.com>
@Alcheri
Alcheri marked this pull request as ready for review August 11, 2026 10:46
Copilot AI lite review requested due to automatic review settings August 11, 2026 10:46
@Alcheri
Alcheri merged commit ddc7e93 into main Aug 11, 2026
4 checks passed
@Alcheri
Alcheri deleted the finding-autofix-3 branch August 11, 2026 10:46

Copilot AI 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

This PR addresses a CodeQL warning about System.IO.Path.Combine potentially discarding earlier segments when a later segment is rooted, by switching the settings file path construction to Path.Join, which does not have the rooted-segment reset behavior.

Changes:

  • Replace Path.Combine(...) with Path.Join(...) for the SettingsPath static initializer in the C# greeter plugin.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants