FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/csharp/tools/tracing-config.lua at codeql-cli-2.11.3 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
468
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
csharp
/
tools
/
tracing-config.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
218 lines (205 loc) · 8.53 KB
Breadcrumbs
codeql
/
csharp
/
tools
/
tracing-config.lua
Copy path
File metadata and controls
218 lines (205 loc) · 8.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
function
RegisterExtractorPack
(
id
)
function
Exify
(
path
)
if
OperatingSystem
==
'
windows
'
then
return
path
..
'
.exe
'
else
return
path
end
end
local
extractor
=
Exify
(
GetPlatformToolsDirectory
()
..
'
Semmle.Extraction.CSharp.Driver
'
)
function
DotnetMatcherBuild
(
compilerName
,
compilerPath
,
compilerArguments
,
_languageId
)
if
compilerName
~=
'
dotnet
'
and
compilerName
~=
'
dotnet.exe
'
then
return
nil
end
--
The dotnet CLI has the following usage instructions:
--
dotnet [sdk-options] [command] [command-options] [arguments]
--
we are interested in dotnet build, which has the following usage instructions:
--
dotnet [options] build [<PROJECT | SOLUTION>...]
--
For now, parse the command line as follows:
--
Everything that starts with `-` (or `/`) will be ignored.
--
The first non-option argument is treated as the command.
--
if that's `build`, we append `-p:UseSharedCompilation=false` to the command line,
--
otherwise we do nothing.
local
match
=
false
local
dotnetRunNeedsSeparator
=
false
;
local
dotnetRunInjectionIndex
=
nil
;
local
argv
=
compilerArguments
.
argv
if
OperatingSystem
==
'
windows
'
then
--
let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
--
or, at least, that it is close enough
argv
=
NativeArgumentsToArgv
(
compilerArguments
.
nativeArgumentPointer
)
end
for
i
,
arg
in
ipairs
(
argv
)
do
--
dotnet options start with either - or / (both are legal)
local
firstCharacter
=
string.sub
(
arg
,
1
,
1
)
if
not
(
firstCharacter
==
'
-
'
)
and
not
(
firstCharacter
==
'
/
'
)
then
if
(
not
match
)
then
Log
(
1
,
'
Dotnet subcommand detected: %s
'
,
arg
)
end
if
arg
==
'
build
'
or
arg
==
'
msbuild
'
or
arg
==
'
publish
'
or
arg
==
'
pack
'
or
arg
==
'
test
'
then
match
=
true
break
end
if
arg
==
'
run
'
then
--
for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
--
not passed in as an argument to the program that is run
match
=
true
dotnetRunNeedsSeparator
=
true
dotnetRunInjectionIndex
=
i
+
1
end
end
--
if we see a separator to `dotnet run`, inject just prior to the existing separator
if
arg
==
'
--
'
then
dotnetRunNeedsSeparator
=
false
dotnetRunInjectionIndex
=
i
break
end
--
if we see an option to `dotnet run` (e.g., `--project`), inject just prior
--
to the last option
if
firstCharacter
==
'
-
'
then
dotnetRunNeedsSeparator
=
false
dotnetRunInjectionIndex
=
i
end
end
if
match
then
local
injections
=
{
'
-p:UseSharedCompilation=false
'
}
if
dotnetRunNeedsSeparator
then
table.insert
(
injections
,
'
--
'
)
end
if
dotnetRunInjectionIndex
==
nil
then
--
Simple case; just append at the end
return
{
order
=
ORDER_REPLACE
,
invocation
=
BuildExtractorInvocation
(
id
,
compilerPath
,
compilerPath
,
compilerArguments
,
nil
,
injections
)
}
end
--
Complex case; splice injections into the middle of the command line
for
i
,
injectionArg
in
ipairs
(
injections
)
do
table.insert
(
argv
,
dotnetRunInjectionIndex
+
i
-
1
,
injectionArg
)
end
if
OperatingSystem
==
'
windows
'
then
return
{
order
=
ORDER_REPLACE
,
invocation
=
{
path
=
AbsolutifyExtractorPath
(
id
,
compilerPath
),
arguments
=
{
commandLineString
=
table.concat
(
argv
,
"
"
)
}
}
}
else
return
{
order
=
ORDER_REPLACE
,
invocation
=
{
path
=
AbsolutifyExtractorPath
(
id
,
compilerPath
),
arguments
=
{
argv
=
argv
}
}
}
end
end
return
nil
end
function
MsBuildMatcher
(
compilerName
,
compilerPath
,
compilerArguments
,
_languageId
)
if
MatchCompilerName
(
'
^
'
..
Exify
(
'
msbuild
'
)
..
'
$
'
,
compilerName
,
compilerPath
,
compilerArguments
)
or
MatchCompilerName
(
'
^
'
..
Exify
(
'
xbuild
'
)
..
'
$
'
,
compilerName
,
compilerPath
,
compilerArguments
)
then
return
{
order
=
ORDER_REPLACE
,
invocation
=
BuildExtractorInvocation
(
id
,
compilerPath
,
compilerPath
,
compilerArguments
,
nil
, {
'
/p:UseSharedCompilation=false
'
,
'
/p:MvcBuildViews=true
'
})
}
end
end
local
windowsMatchers
=
{
DotnetMatcherBuild
,
MsBuildMatcher
,
CreatePatternMatcher
({
'
^csc.*%.exe$
'
},
MatchCompilerName
,
extractor
, {
prepend
=
{
'
--compiler
'
,
'
"${compiler}"
'
},
order
=
ORDER_BEFORE
}),
CreatePatternMatcher
({
'
^fakes.*%.exe$
'
,
'
moles.*%.exe
'
},
MatchCompilerName
,
nil
, {
trace
=
false
}),
function
(
compilerName
,
compilerPath
,
compilerArguments
,
_languageId
)
--
handle cases like `dotnet.exe exec csc.dll <args>`
if
compilerName
~=
'
dotnet.exe
'
then
return
nil
end
local
seenCompilerCall
=
false
local
argv
=
NativeArgumentsToArgv
(
compilerArguments
.
nativeArgumentPointer
)
local
extractorArgs
=
{
'
--compiler
'
}
for
_
,
arg
in
ipairs
(
argv
)
do
if
arg
:
match
(
'
csc%.dll$
'
)
then
seenCompilerCall
=
true
end
if
seenCompilerCall
then
table.insert
(
extractorArgs
,
'
"
'
..
arg
..
'
"
'
)
end
end
if
seenCompilerCall
then
return
{
order
=
ORDER_BEFORE
,
invocation
=
{
path
=
AbsolutifyExtractorPath
(
id
,
extractor
),
arguments
=
{
commandLineString
=
table.concat
(
extractorArgs
,
"
"
)
}
}
}
end
return
nil
end
}
local
posixMatchers
=
{
DotnetMatcherBuild
,
CreatePatternMatcher
({
'
^mcs%.exe$
'
,
'
^csc%.exe$
'
},
MatchCompilerName
,
extractor
, {
prepend
=
{
'
--compiler
'
,
'
"${compiler}"
'
},
order
=
ORDER_BEFORE
}),
MsBuildMatcher
,
function
(
compilerName
,
compilerPath
,
compilerArguments
,
_languageId
)
--
handle cases like `dotnet exec csc.dll <args>` and `mono(-sgen64) csc.exe <args>`
if
compilerName
~=
'
dotnet
'
and
not
compilerName
:
match
(
'
^mono
'
)
then
return
nil
end
local
seenCompilerCall
=
false
local
argv
=
compilerArguments
.
argv
local
extractorArgs
=
{
'
--compiler
'
}
for
_
,
arg
in
ipairs
(
argv
)
do
if
arg
:
match
(
'
csc%.dll$
'
)
or
arg
:
match
(
'
csc%.exe$
'
)
or
arg
:
match
(
'
mcs%.exe$
'
)
then
seenCompilerCall
=
true
end
if
seenCompilerCall
then
table.insert
(
extractorArgs
,
arg
)
end
end
if
seenCompilerCall
then
return
{
order
=
ORDER_BEFORE
,
invocation
=
{
path
=
AbsolutifyExtractorPath
(
id
,
extractor
),
arguments
=
{
argv
=
extractorArgs
}
}
}
end
return
nil
end
}
if
OperatingSystem
==
'
windows
'
then
return
windowsMatchers
else
return
posixMatchers
end
end
--
Return a list of minimum supported versions of the configuration file format
--
return one entry per supported major version.
function
GetCompatibleVersions
()
return
{
'
1.0.0
'
}
end
Back
|
FazBrowse Home
|
New Git URL