Skip to content

Commit a48d71b

Browse files
committed
Merge branch 'main' into redsun82/kotlin
2 parents 8205f86 + 60970ff commit a48d71b

File tree

96 files changed

+2907
-2655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2907
-2655
lines changed

csharp/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ csharp.log
1414
.vscode/launch.json
1515

1616
extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
17-
extractor-pack
1817
paket-files/

csharp/documentation/library-coverage/coverage.csv

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ Amazon.Lambda.Core,10,,,,,,,,,,,10,,,,,,,,,,,
44
Dapper,55,42,1,,,,,,,,,,55,,42,,,,,,,,1
55
ILCompiler,,,81,,,,,,,,,,,,,,,,,,,81,
66
ILLink.RoslynAnalyzer,,,63,,,,,,,,,,,,,,,,,,,63,
7-
ILLink.Shared,,,32,,,,,,,,,,,,,,,,,,,29,3
7+
ILLink.Shared,,,32,,,,,,,,,,,,,,,,,,,30,2
88
ILLink.Tasks,,,3,,,,,,,,,,,,,,,,,,,3,
9-
Internal.IL,,,69,,,,,,,,,,,,,,,,,,,67,2
9+
Internal.IL,,,46,,,,,,,,,,,,,,,,,,,44,2
1010
Internal.Pgo,,,9,,,,,,,,,,,,,,,,,,,8,1
11-
Internal.TypeSystem,,,367,,,,,,,,,,,,,,,,,,,331,36
11+
Internal.TypeSystem,,,291,,,,,,,,,,,,,,,,,,,275,16
1212
JsonToItemsTaskFactory,,,5,,,,,,,,,,,,,,,,,,,5,
1313
Microsoft.Android.Build,,,14,,,,,,,,,,,,,,,,,,,14,
1414
Microsoft.Apple.Build,,,5,,,,,,,,,,,,,,,,,,,5,
1515
Microsoft.ApplicationBlocks.Data,28,,,,,,,,,,,,28,,,,,,,,,,
16-
Microsoft.CSharp,,,24,,,,,,,,,,,,,,,,,,,24,
17-
Microsoft.Diagnostics.Tools.Pgo,,,13,,,,,,,,,,,,,,,,,,,13,
16+
Microsoft.CSharp,,,10,,,,,,,,,,,,,,,,,,,10,
17+
Microsoft.Diagnostics.Tools.Pgo,,,12,,,,,,,,,,,,,,,,,,,12,
1818
Microsoft.EntityFrameworkCore,6,,12,,,,,,,,,,6,,,,,,,,,,12
1919
Microsoft.Extensions.Caching.Distributed,,,9,,,,,,,,,,,,,,,,,,,9,
2020
Microsoft.Extensions.Caching.Memory,,,30,,,,,,,,,,,,,,,,,,,29,1
21-
Microsoft.Extensions.Configuration,,2,83,,,,,,,,,,,,,2,,,,,,81,2
22-
Microsoft.Extensions.DependencyInjection,,,120,,,,,,,,,,,,,,,,,,,120,
23-
Microsoft.Extensions.DependencyModel,,,12,,,,,,,,,,,,,,,,,,,12,
24-
Microsoft.Extensions.Diagnostics.Metrics,,,13,,,,,,,,,,,,,,,,,,,13,
21+
Microsoft.Extensions.Configuration,,2,77,,,,,,,,,,,,,2,,,,,,76,1
22+
Microsoft.Extensions.DependencyInjection,,,96,,,,,,,,,,,,,,,,,,,95,1
23+
Microsoft.Extensions.DependencyModel,,,9,,,,,,,,,,,,,,,,,,,9,
24+
Microsoft.Extensions.Diagnostics.Metrics,,,15,,,,,,,,,,,,,,,,,,,15,
2525
Microsoft.Extensions.FileProviders,,,15,,,,,,,,,,,,,,,,,,,15,
2626
Microsoft.Extensions.FileSystemGlobbing,,,16,,,,,,,,,,,,,,,,,,,14,2
27-
Microsoft.Extensions.Hosting,,,23,,,,,,,,,,,,,,,,,,,22,1
27+
Microsoft.Extensions.Hosting,,,26,,,,,,,,,,,,,,,,,,,25,1
2828
Microsoft.Extensions.Http,,,8,,,,,,,,,,,,,,,,,,,8,
29-
Microsoft.Extensions.Logging,,,60,,,,,,,,,,,,,,,,,,,59,1
29+
Microsoft.Extensions.Logging,,,53,,,,,,,,,,,,,,,,,,,52,1
3030
Microsoft.Extensions.Options,,,8,,,,,,,,,,,,,,,,,,,8,
3131
Microsoft.Extensions.Primitives,,,64,,,,,,,,,,,,,,,,,,,64,
32-
Microsoft.Interop,,,78,,,,,,,,,,,,,,,,,,,78,
32+
Microsoft.Interop,,,73,,,,,,,,,,,,,,,,,,,73,
3333
Microsoft.NET.Build.Tasks,,,1,,,,,,,,,,,,,,,,,,,1,
3434
Microsoft.NET.WebAssembly.Webcil,,,7,,,,,,,,,,,,,,,,,,,7,
35-
Microsoft.VisualBasic,,,10,,,,,,,,,,,,,,,,,,,5,5
35+
Microsoft.VisualBasic,,,6,,,,,,,,,,,,,,,,,,,1,5
3636
Microsoft.WebAssembly.Build.Tasks,,,3,,,,,,,,,,,,,,,,,,,3,
3737
Microsoft.Win32,,4,4,,,,,,,,,,,,,,,,,,4,4,
38-
Mono.Linker,,,161,,,,,,,,,,,,,,,,,,,161,
38+
Mono.Linker,,,158,,,,,,,,,,,,,,,,,,,158,
3939
MySql.Data.MySqlClient,48,,,,,,,,,,,,48,,,,,,,,,,
4040
Newtonsoft.Json,,,91,,,,,,,,,,,,,,,,,,,73,18
4141
ServiceStack,194,,7,27,,,,,75,,,,92,,,,,,,,,7,
4242
SourceGenerators,,,4,,,,,,,,,,,,,,,,,,,4,
43-
System,59,44,10429,,8,8,1,,,4,5,,33,2,,3,15,17,3,4,,8460,1969
43+
System,49,44,9873,,3,3,1,,,4,5,,33,2,,3,15,17,3,4,,7968,1905
4444
Windows.Security.Cryptography.Core,1,,,,,,,1,,,,,,,,,,,,,,,

csharp/documentation/library-coverage/coverage.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ C# framework & library support
88

99
Framework / library,Package,Flow sources,Taint & value steps,Sinks (total),`CWE-079` :sub:`Cross-site scripting`
1010
`ServiceStack <https://servicestack.net/>`_,"``ServiceStack.*``, ``ServiceStack``",,7,194,
11-
System,"``System.*``, ``System``",44,10429,59,9
12-
Others,"``Amazon.Lambda.APIGatewayEvents``, ``Amazon.Lambda.Core``, ``Dapper``, ``ILCompiler``, ``ILLink.RoslynAnalyzer``, ``ILLink.Shared``, ``ILLink.Tasks``, ``Internal.IL``, ``Internal.Pgo``, ``Internal.TypeSystem``, ``JsonToItemsTaskFactory``, ``Microsoft.Android.Build``, ``Microsoft.Apple.Build``, ``Microsoft.ApplicationBlocks.Data``, ``Microsoft.CSharp``, ``Microsoft.Diagnostics.Tools.Pgo``, ``Microsoft.EntityFrameworkCore``, ``Microsoft.Extensions.Caching.Distributed``, ``Microsoft.Extensions.Caching.Memory``, ``Microsoft.Extensions.Configuration``, ``Microsoft.Extensions.DependencyInjection``, ``Microsoft.Extensions.DependencyModel``, ``Microsoft.Extensions.Diagnostics.Metrics``, ``Microsoft.Extensions.FileProviders``, ``Microsoft.Extensions.FileSystemGlobbing``, ``Microsoft.Extensions.Hosting``, ``Microsoft.Extensions.Http``, ``Microsoft.Extensions.Logging``, ``Microsoft.Extensions.Options``, ``Microsoft.Extensions.Primitives``, ``Microsoft.Interop``, ``Microsoft.NET.Build.Tasks``, ``Microsoft.NET.WebAssembly.Webcil``, ``Microsoft.VisualBasic``, ``Microsoft.WebAssembly.Build.Tasks``, ``Microsoft.Win32``, ``Mono.Linker``, ``MySql.Data.MySqlClient``, ``Newtonsoft.Json``, ``SourceGenerators``, ``Windows.Security.Cryptography.Core``",54,1518,148,
13-
Totals,,98,11954,401,9
11+
System,"``System.*``, ``System``",44,9873,49,9
12+
Others,"``Amazon.Lambda.APIGatewayEvents``, ``Amazon.Lambda.Core``, ``Dapper``, ``ILCompiler``, ``ILLink.RoslynAnalyzer``, ``ILLink.Shared``, ``ILLink.Tasks``, ``Internal.IL``, ``Internal.Pgo``, ``Internal.TypeSystem``, ``JsonToItemsTaskFactory``, ``Microsoft.Android.Build``, ``Microsoft.Apple.Build``, ``Microsoft.ApplicationBlocks.Data``, ``Microsoft.CSharp``, ``Microsoft.Diagnostics.Tools.Pgo``, ``Microsoft.EntityFrameworkCore``, ``Microsoft.Extensions.Caching.Distributed``, ``Microsoft.Extensions.Caching.Memory``, ``Microsoft.Extensions.Configuration``, ``Microsoft.Extensions.DependencyInjection``, ``Microsoft.Extensions.DependencyModel``, ``Microsoft.Extensions.Diagnostics.Metrics``, ``Microsoft.Extensions.FileProviders``, ``Microsoft.Extensions.FileSystemGlobbing``, ``Microsoft.Extensions.Hosting``, ``Microsoft.Extensions.Http``, ``Microsoft.Extensions.Logging``, ``Microsoft.Extensions.Options``, ``Microsoft.Extensions.Primitives``, ``Microsoft.Interop``, ``Microsoft.NET.Build.Tasks``, ``Microsoft.NET.WebAssembly.Webcil``, ``Microsoft.VisualBasic``, ``Microsoft.WebAssembly.Build.Tasks``, ``Microsoft.Win32``, ``Mono.Linker``, ``MySql.Data.MySqlClient``, ``Newtonsoft.Json``, ``SourceGenerators``, ``Windows.Security.Cryptography.Core``",54,1357,148,
13+
Totals,,98,11237,391,9
1414

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetExeWrapper.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ private string ResolveNugetExe()
9797
return envVarPath;
9898
}
9999

100+
try
101+
{
102+
return DownloadNugetExe(fileProvider.SourceDir.FullName);
103+
}
104+
catch (Exception exc)
105+
{
106+
logger.LogInfo($"Download of nuget.exe failed: {exc.Message}");
107+
}
108+
100109
var nugetExesInRepo = fileProvider.NugetExes;
101110
if (nugetExesInRepo.Count > 1)
102111
{
@@ -119,7 +128,7 @@ private string ResolveNugetExe()
119128
return nugetPath;
120129
}
121130

122-
return DownloadNugetExe(fileProvider.SourceDir.FullName);
131+
throw new Exception("Could not find or download nuget.exe.");
123132
}
124133

125134
private string DownloadNugetExe(string sourceDir)
@@ -136,28 +145,20 @@ private string DownloadNugetExe(string sourceDir)
136145

137146
Directory.CreateDirectory(directory);
138147
logger.LogInfo("Attempting to download nuget.exe");
139-
try
140-
{
141-
FileUtils.DownloadFile(FileUtils.NugetExeUrl, nuget);
142-
logger.LogInfo($"Downloaded nuget.exe to {nuget}");
143-
return nuget;
144-
}
145-
catch
146-
{
147-
// Download failed.
148-
throw new FileNotFoundException("Download of nuget.exe failed.");
149-
}
148+
FileUtils.DownloadFile(FileUtils.NugetExeUrl, nuget);
149+
logger.LogInfo($"Downloaded nuget.exe to {nuget}");
150+
return nuget;
150151
}
151152

152153
private bool RunWithMono => !Win32.IsWindows() && !string.IsNullOrEmpty(Path.GetExtension(nugetExe));
153154

154155
/// <summary>
155-
/// Restore all files in a specified package.
156+
/// Restore all packages in the specified packages.config file.
156157
/// </summary>
157-
/// <param name="package">The package file.</param>
158-
private bool TryRestoreNugetPackage(string package)
158+
/// <param name="packagesConfig">The packages.config file.</param>
159+
private bool TryRestoreNugetPackage(string packagesConfig)
159160
{
160-
logger.LogInfo($"Restoring file {package}...");
161+
logger.LogInfo($"Restoring file \"{packagesConfig}\"...");
161162

162163
/* Use nuget.exe to install a package.
163164
* Note that there is a clutch of NuGet assemblies which could be used to
@@ -169,12 +170,12 @@ private bool TryRestoreNugetPackage(string package)
169170
if (RunWithMono)
170171
{
171172
exe = "mono";
172-
args = $"{nugetExe} install -OutputDirectory {packageDirectory} {package}";
173+
args = $"\"{nugetExe}\" install -OutputDirectory \"{packageDirectory}\" \"{packagesConfig}\"";
173174
}
174175
else
175176
{
176177
exe = nugetExe!;
177-
args = $"install -OutputDirectory {packageDirectory} {package}";
178+
args = $"install -OutputDirectory \"{packageDirectory}\" \"{packagesConfig}\"";
178179
}
179180

180181
var pi = new ProcessStartInfo(exe, args)
@@ -195,7 +196,7 @@ private bool TryRestoreNugetPackage(string package)
195196
}
196197
else
197198
{
198-
logger.LogInfo($"Restored file {package}");
199+
logger.LogInfo($"Restored file \"{packagesConfig}\"");
199200
return true;
200201
}
201202
}
@@ -205,7 +206,7 @@ private bool TryRestoreNugetPackage(string package)
205206
/// </summary>
206207
public int InstallPackages()
207208
{
208-
return fileProvider.PackagesConfigs.Count(package => TryRestoreNugetPackage(package));
209+
return fileProvider.PackagesConfigs.Count(TryRestoreNugetPackage);
209210
}
210211

211212
private bool HasNoPackageSource()
@@ -239,7 +240,7 @@ private void RunMonoNugetCommand(string command, out IList<string> stdout)
239240
if (RunWithMono)
240241
{
241242
exe = "mono";
242-
args = $"{nugetExe} {command}";
243+
args = $"\"{nugetExe}\" {command}";
243244
}
244245
else
245246
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| [...]/Newtonsoft.Json.6.0.4/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import csharp
2+
3+
private string getPath(Assembly a) {
4+
not a.getCompilation().getOutputAssembly() = a and
5+
exists(string s | s = a.getFile().getAbsolutePath() |
6+
result =
7+
"[...]" +
8+
s.substring(s.indexOf("test-db/working/") + "test-db/working/".length() + 16 +
9+
"/legacypackages".length(), s.length())
10+
// TODO: include all other assemblies from the test results. Initially disable because mono installations were problematic on ARM runners.
11+
)
12+
}
13+
14+
from Assembly a
15+
select getPath(a)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Program
2+
{
3+
static void Main(string[] args)
4+
{
5+
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.101"
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net461" />
4+
<package id="NUnit.ConsoleRunner" version="3.12.0" />
5+
</packages>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.

0 commit comments

Comments
 (0)