mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Don't inject compiler flags when dotnet is used to execute an application.
This commit is contained in:
@@ -23,6 +23,10 @@ function RegisterExtractorPack(id)
|
||||
not isDotnetPath(arg)
|
||||
end
|
||||
|
||||
local function isPathToExecutable(path)
|
||||
return path:match('%.exe$') or path:match('%.dll')
|
||||
end
|
||||
|
||||
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
|
||||
_languageId)
|
||||
if not isDotnet(compilerName) then
|
||||
@@ -56,8 +60,16 @@ function RegisterExtractorPack(id)
|
||||
NativeArgumentsToArgv(compilerArguments.nativeArgumentPointer)
|
||||
end
|
||||
for i, arg in ipairs(argv) do
|
||||
-- if dotnet is being used to execute any application except dotnet itself, we should
|
||||
-- not inject any flags.
|
||||
if not match and isPathToExecutable(arg) and not isDotnetPath(arg) then
|
||||
Log(1, 'Execute a .NET application usage detected')
|
||||
Log(1, 'Dotnet path-to-application detected: %s', arg)
|
||||
break
|
||||
end
|
||||
if isPossibleDotnetSubcommand(arg) then
|
||||
if (not match) and inSubCommandPosition then
|
||||
if not match and inSubCommandPosition then
|
||||
Log(1, 'Execute a .NET SDK command usage detected')
|
||||
Log(1, 'Dotnet subcommand detected: %s', arg)
|
||||
end
|
||||
-- only respond to strings that look like sub-command names if we have not yet
|
||||
@@ -85,7 +97,7 @@ function RegisterExtractorPack(id)
|
||||
end
|
||||
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
|
||||
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
|
||||
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
|
||||
if testMatch and isPathToExecutable(arg) then
|
||||
match = false
|
||||
break
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user