Skip to content

Commit 5645cb7

Browse files
stephentoubCopilot
andcommitted
Address CodeQL findings in dotnet E2E harness
Use Path.Join instead of Path.Combine (never silently drops rooted arguments) and replace the foreach scan with a LINQ Select + FirstOrDefault when locating the platform package's index.js. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4c6cd17 commit 5645cb7

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

dotnet/test/Harness/E2ETestContext.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,14 @@ private static string GetCliPath(string repoRoot)
143143
// As of CLI 1.0.64-1 the @github/copilot package is a thin loader; the
144144
// runnable index.js ships in the installed platform package
145145
// (e.g. @github/copilot-linux-x64). Exactly one is installed.
146-
var githubModules = Path.Combine(repoRoot, "nodejs", "node_modules", "@github");
146+
var githubModules = Path.Join(repoRoot, "nodejs", "node_modules", "@github");
147147
if (Directory.Exists(githubModules))
148148
{
149-
foreach (var dir in Directory.EnumerateDirectories(githubModules, "copilot-*"))
150-
{
151-
var candidate = Path.Combine(dir, "index.js");
152-
if (File.Exists(candidate))
153-
return candidate;
154-
}
149+
var candidate = Directory.EnumerateDirectories(githubModules, "copilot-*")
150+
.Select(dir => Path.Join(dir, "index.js"))
151+
.FirstOrDefault(File.Exists);
152+
if (candidate != null)
153+
return candidate;
155154
}
156155

157156
throw new InvalidOperationException(

0 commit comments

Comments
 (0)