Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeQL recommendation against Path.Combine #18865

Merged
merged 7 commits into from
Mar 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Match autoformatting, add QLDoc references
  • Loading branch information
carldybdahl-microsoft committed Mar 3, 2025
commit b3447959fa866625c4e6c95f67fcc6635e71597d
2 changes: 2 additions & 0 deletions csharp/ql/src/Bad Practices/PathCombine.qhelp
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
</recommendation>
<references>

<li>Microsoft Learn, .NET API browser, <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-9.0">Path.Combine</a>.</li>
<li>Microsoft Learn, .NET API browser, <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.path.join?view=net-9.0">Path.Join</a>.</li>

</references>
</qhelp>
2 changes: 1 addition & 1 deletion csharp/ql/src/Bad Practices/PathCombine.ql
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@ import semmle.code.csharp.frameworks.System

from MethodCall call
where call.getTarget().hasFullyQualifiedName("System.IO", "Path", "Combine")
select call, "Path.Combine may silently discard its initial arguments if the latter are absolute paths. Use Path.Join to consistently join them."
select call, "Call to System.IO.Path.Combine."
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| PathCombine.cs:7:9:7:54 | call to method Combine | Path.Combine may silently discard its initial arguments if the latter are absolute paths. Use Path.Join to consistently join them. |
| PathCombine.cs:7:9:7:54 | call to method Combine | Call to System.IO.Path.Combine. |