mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +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)
|
not isDotnetPath(arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function isPathToExecutable(path)
|
||||||
|
return path:match('%.exe$') or path:match('%.dll')
|
||||||
|
end
|
||||||
|
|
||||||
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
|
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
|
||||||
_languageId)
|
_languageId)
|
||||||
if not isDotnet(compilerName) then
|
if not isDotnet(compilerName) then
|
||||||
@@ -56,8 +60,16 @@ function RegisterExtractorPack(id)
|
|||||||
NativeArgumentsToArgv(compilerArguments.nativeArgumentPointer)
|
NativeArgumentsToArgv(compilerArguments.nativeArgumentPointer)
|
||||||
end
|
end
|
||||||
for i, arg in ipairs(argv) do
|
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 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)
|
Log(1, 'Dotnet subcommand detected: %s', arg)
|
||||||
end
|
end
|
||||||
-- only respond to strings that look like sub-command names if we have not yet
|
-- only respond to strings that look like sub-command names if we have not yet
|
||||||
@@ -85,7 +97,7 @@ function RegisterExtractorPack(id)
|
|||||||
end
|
end
|
||||||
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
|
-- 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 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
|
match = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user