Skip to content

Commit 884d730

Browse files
stephentoubCopilot
andcommitted
Use Path.Join instead of Path.Combine to avoid silent-drop warnings
CodeQL flags Path.Combine because if a later argument is rooted, it silently discards the earlier ones. Path.Join concatenates segments literally and is the safer choice for these cases. - E2ETestContext.ResolveSymlinks: use Path.Join when walking path components (the loop appends user-controlled directory names that realistically never start with a path separator on these temp dirs, but the safer API removes the risk regardless). - HooksE2ETests: use Path.Join for the protected-file lookup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 21be3d1 commit 884d730

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

dotnet/test/E2E/HooksE2ETests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ await session.SendAsync(new MessageOptions
165165
// Strengthen: verify the actual deny behavior — the protected file was NOT
166166
// modified by the runtime even though the LLM tried to edit it. The pre-tool-use
167167
// hook denial blocks tool execution before it can mutate state.
168-
var actualContent = await File.ReadAllTextAsync(Path.Combine(Ctx.WorkDir, "protected.txt"));
168+
var actualContent = await File.ReadAllTextAsync(Path.Join(Ctx.WorkDir, "protected.txt"));
169169
Assert.Equal(originalContent, actualContent);
170170
}
171171
}

dotnet/test/Harness/E2ETestContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static string ResolveSymlinks(string path)
8181
var resolved = root;
8282
foreach (var component in components)
8383
{
84-
resolved = Path.Combine(resolved, component);
84+
resolved = Path.Join(resolved, component);
8585
try
8686
{
8787
var info = new DirectoryInfo(resolved);

0 commit comments

Comments
 (0)