Skip to content

Commit 07800ea

Browse files
authored
Merge branch 'main' into uncontrolled-allocation-size-docs
2 parents 5548304 + f7d8c21 commit 07800ea

File tree

321 files changed

+98590
-1236
lines changed

Some content is hidden

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

321 files changed

+98590
-1236
lines changed

csharp/documentation/library-coverage/coverage.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Internal.IL,,,46,,,,,,,,,,,,,,,,,,,44,2
1010
Internal.Pgo,,,9,,,,,,,,,,,,,,,,,,,8,1
1111
Internal.TypeSystem,,,315,,,,,,,,,,,,,,,,,,,299,16
1212
JsonToItemsTaskFactory,,,10,,,,,,,,,,,,,,,,,,,10,
13-
Microsoft.Android.Build,,,16,,,,,,,,,,,,,,,,,,,16,
13+
Microsoft.Android.Build,,1,16,,,,,,,,,,,,,1,,,,,,16,
1414
Microsoft.Apple.Build,,,8,,,,,,,,,,,,,,,,,,,8,
1515
Microsoft.ApplicationBlocks.Data,28,,,,,,,,,,,,28,,,,,,,,,,
1616
Microsoft.CSharp,,,13,,,,,,,,,,,,,,,,,,,13,
@@ -19,9 +19,9 @@ Microsoft.DotNet.Build.Tasks,,,6,,,,,,,,,,,,,,,,,,,6,
1919
Microsoft.EntityFrameworkCore,6,,12,,,,,,,,,,6,,,,,,,,,,12
2020
Microsoft.Extensions.Caching.Distributed,,,10,,,,,,,,,,,,,,,,,,,10,
2121
Microsoft.Extensions.Caching.Memory,,,39,,,,,,,,,,,,,,,,,,,38,1
22-
Microsoft.Extensions.Configuration,,2,90,,,,,,,,,,,,,2,,,,,,89,1
22+
Microsoft.Extensions.Configuration,,3,90,,,,,,,,,,,,,3,,,,,,89,1
2323
Microsoft.Extensions.DependencyInjection,,,134,,,,,,,,,,,,,,,,,,,133,1
24-
Microsoft.Extensions.DependencyModel,,,18,,,,,,,,,,,,,,,,,,,18,
24+
Microsoft.Extensions.DependencyModel,,1,18,,,,,,,,,,,,,1,,,,,,18,
2525
Microsoft.Extensions.Diagnostics.Metrics,,,15,,,,,,,,,,,,,,,,,,,15,
2626
Microsoft.Extensions.FileProviders,,,15,,,,,,,,,,,,,,,,,,,15,
2727
Microsoft.Extensions.FileSystemGlobbing,,,18,,,,,,,,,,,,,,,,,,,16,2
@@ -41,5 +41,5 @@ MySql.Data.MySqlClient,48,,,,,,,,,,,,48,,,,,,,,,,
4141
Newtonsoft.Json,,,91,,,,,,,,,,,,,,,,,,,73,18
4242
ServiceStack,194,,7,27,,,,,75,,,,92,,,,,,,,,7,
4343
SourceGenerators,,,5,,,,,,,,,,,,,,,,,,,5,
44-
System,60,44,10614,,7,6,5,,,4,5,,33,2,,3,15,17,3,4,,8709,1905
44+
System,54,47,10626,,6,5,5,,,4,1,,33,2,,6,15,17,3,4,,8721,1905
4545
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,10614,60,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.DotNet.Build.Tasks``, ``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,1821,148,
13-
Totals,,98,12442,402,9
11+
System,"``System.*``, ``System``",47,10626,54,5
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.DotNet.Build.Tasks``, ``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``",57,1821,148,
13+
Totals,,104,12454,396,5
1414

csharp/extractor/Semmle.Extraction.CSharp/Entities/Compilations/CompilerDiagnostic.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public CompilerDiagnostic(Context cx, Microsoft.CodeAnalysis.Diagnostic diag, Co
2121

2222
protected override void Populate(TextWriter trapFile)
2323
{
24-
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
2524
var key = diagnostic.Id;
2625
var messageCount = compilation.messageCounts.AddOrUpdate(key, 1, (_, c) => c + 1);
2726
if (messageCount > limit)

csharp/extractor/Semmle.Extraction/Entities/ExtractionMessage.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,36 @@ internal class ExtractionMessage : FreshEntity
1010
private static int messageCount = 0;
1111

1212
private readonly Message msg;
13+
private readonly bool bypassLimit;
1314

14-
public ExtractionMessage(Context cx, Message msg) : base(cx)
15+
public ExtractionMessage(Context cx, Message msg) : this(cx, msg, bypassLimit: false)
1516
{
17+
}
18+
19+
private ExtractionMessage(Context cx, Message msg, bool bypassLimit) : base(cx)
20+
{
21+
this.bypassLimit = bypassLimit;
1622
this.msg = msg;
1723
TryPopulate();
1824
}
1925

2026
protected override void Populate(TextWriter trapFile)
2127
{
22-
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
23-
Interlocked.Increment(ref messageCount);
24-
if (messageCount > limit)
28+
if (!bypassLimit)
2529
{
26-
if (messageCount == limit + 1)
30+
var val = Interlocked.Increment(ref messageCount);
31+
if (val > limit)
2732
{
28-
Context.ExtractionContext.Logger.LogWarning($"Stopped logging extractor messages after reaching {limit}");
33+
if (val == limit + 1)
34+
{
35+
Context.ExtractionContext.Logger.LogWarning($"Stopped logging extractor messages after reaching {limit}");
36+
_ = new ExtractionMessage(Context, new Message($"Stopped logging extractor messages after reaching {limit}", null, null, null, Util.Logging.Severity.Warning), bypassLimit: true);
37+
}
38+
return;
2939
}
30-
return;
3140
}
3241

33-
trapFile.extractor_messages(this, msg.Severity, "C# extractor", msg.Text, msg.EntityText ?? string.Empty,
42+
trapFile.extractor_messages(this, msg.Severity, msg.Text, msg.EntityText ?? string.Empty,
3443
msg.Location ?? Context.CreateLocation(), msg.StackTrace ?? string.Empty);
3544
}
3645
}

csharp/extractor/Semmle.Extraction/Tuples.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public static void containerparent(this System.IO.TextWriter trapFile, Folder pa
1212
trapFile.WriteTuple("containerparent", parent, child);
1313
}
1414

15-
internal static void extractor_messages(this System.IO.TextWriter trapFile, ExtractionMessage error, Semmle.Util.Logging.Severity severity, string origin, string errorMessage, string entityText, Location location, string stackTrace)
15+
internal static void extractor_messages(this System.IO.TextWriter trapFile, ExtractionMessage error, Semmle.Util.Logging.Severity severity, string errorMessage, string entityText, Location location, string stackTrace)
1616
{
17-
trapFile.WriteTuple("extractor_messages", error, (int)severity, origin, errorMessage, entityText, location, stackTrace);
17+
trapFile.WriteTuple("extractor_messages", error, (int)severity, "C# extractor", errorMessage, entityText, location, stackTrace);
1818
}
1919

2020
public static void files(this System.IO.TextWriter trapFile, File file, string fullName)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
extractorMessages
2-
| 5 |
2+
| 6 |
33
compilerDiagnostics
44
| 4 |
5+
extractorMessagesLeachedLimit
6+
| Program.cs:1:1:1:0 | Stopped logging extractor messages after reaching 5 |
57
compilationInfo
68
| Compiler diagnostic count for CS0103 | 3.0 |
79
| Compiler diagnostic count for CS8019 | 7.0 |

csharp/ql/integration-tests/all-platforms/standalone/Diag.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ query predicate extractorMessages(int c) { c = count(ExtractorMessage msg) }
55

66
query predicate compilerDiagnostics(int c) { c = count(Diagnostic diag) }
77

8+
query predicate extractorMessagesLeachedLimit(ExtractorMessage msg) {
9+
msg.getText().indexOf("Stopped logging") = 0
10+
}
11+
812
query predicate compilationInfo(string key, float value) {
913
exists(Compilation c, string infoValue |
1014
infoValue = c.getInfo(key) and key.matches("Compiler diagnostic count for%")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
* Added support for data flow through side-effects on static fields. For example, when a static field containing an array is updated.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added some new `local` source models. Most prominently `System.IO.Path.GetTempPath` and `System.Environment.GetFolderPath`. This might produce more alerts, if the `local` threat model is enabled.

csharp/ql/lib/ext/System.Configuration.model.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ extensions:
1515
- ["System.Configuration", "SettingElementCollection", False, "Clear", "()", "", "Argument[this].WithoutElement", "Argument[this]", "value", "manual"]
1616
- ["System.Configuration", "SettingsPropertyCollection", False, "Clear", "()", "", "Argument[this].WithoutElement", "Argument[this]", "value", "manual"]
1717
- ["System.Configuration", "SettingsPropertyValueCollection", False, "Clear", "()", "", "Argument[this].WithoutElement", "Argument[this]", "value", "manual"]
18+
- addsTo:
19+
pack: codeql/csharp-all
20+
extensible: neutralModel
21+
data:
22+
- ["System.Configuration", "ApplicationSettingsBase", "GetPreviousVersion", "(System.String)", "source", "manual"]

0 commit comments

Comments
 (0)