Skip to content

Commit d48938d

Browse files
authored
Merge branch 'main' into calumgrant/slow-predicates
2 parents 564d7c0 + 0419b5b commit d48938d

File tree

93 files changed

+2255
-49
lines changed

Some content is hidden

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

93 files changed

+2255
-49
lines changed

csharp/extractor/Semmle.Extraction.CSharp/SymbolExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ private static IEnumerable<SyntaxToken> GetModifiers<T>(this ISymbol symbol, Fun
7777
/// <summary>
7878
/// Gets the source-level modifiers belonging to this symbol, if any.
7979
/// </summary>
80-
public static IEnumerable<string> GetSourceLevelModifiers(this ISymbol symbol)
81-
{
82-
var methodModifiers = symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax>(md => md.Modifiers);
83-
var typeModifiers = symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax>(cd => cd.Modifiers);
84-
return methodModifiers.Concat(typeModifiers).Select(m => m.Text);
85-
}
80+
public static IEnumerable<string> GetSourceLevelModifiers(this ISymbol symbol) =>
81+
symbol.GetModifiers<Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax>(md => md.Modifiers).Select(m => m.Text);
8682

8783
/// <summary>
8884
/// Holds if the ID generated for `dependant` will contain a reference to
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The extraction of member modifiers has been generalised, which could lead to the extraction of more modifiers.

csharp/ql/src/Telemetry/ExternalApi.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import semmle.code.csharp.dataflow.FlowSummary
88
private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
99
private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
1010
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch as DataFlowDispatch
11+
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1112
private import semmle.code.csharp.dataflow.internal.TaintTrackingPrivate
1213
private import semmle.code.csharp.security.dataflow.flowsources.Remote
1314

@@ -104,8 +105,17 @@ class ExternalApi extends DotNet::Callable {
104105
pragma[nomagic]
105106
predicate isSink() { sinkNode(this.getAnInput(), _) }
106107

107-
/** Holds if this API is supported by existing CodeQL libraries, that is, it is either a recognized source or sink or has a flow summary. */
108-
predicate isSupported() { this.hasSummary() or this.isSource() or this.isSink() }
108+
/** Holds if this API is a known neutral. */
109+
pragma[nomagic]
110+
predicate isNeutral() { this instanceof FlowSummaryImpl::Public::NeutralCallable }
111+
112+
/**
113+
* Holds if this API is supported by existing CodeQL libraries, that is, it is either a
114+
* recognized source, sink or neutral or it has a flow summary.
115+
*/
116+
predicate isSupported() {
117+
this.hasSummary() or this.isSource() or this.isSink() or this.isNeutral()
118+
}
109119
}
110120

111121
/**

csharp/ql/src/Telemetry/SupportedExternalApis.ql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88

99
private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
11-
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1211
private import ExternalApi
1312

14-
private predicate relevant(ExternalApi api) {
15-
api.isSupported() or
16-
api instanceof FlowSummaryImpl::Public::NeutralCallable
17-
}
13+
private predicate relevant(ExternalApi api) { api.isSupported() }
1814

1915
from string info, int usages
2016
where Results<relevant/1>::restrict(info, usages)

csharp/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77
*/
88

99
private import csharp
10-
private import semmle.code.csharp.dispatch.Dispatch
11-
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1210
private import ExternalApi
1311

14-
private predicate relevant(ExternalApi api) {
15-
not api.isSupported() and
16-
not api instanceof FlowSummaryImpl::Public::NeutralCallable
17-
}
12+
private predicate relevant(ExternalApi api) { not api.isSupported() }
1813

1914
from string info, int usages
2015
where Results<relevant/1>::restrict(info, usages)

csharp/ql/src/meta/frameworks/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
*/
1010

1111
private import csharp
12-
private import semmle.code.csharp.dispatch.Dispatch
13-
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1412
private import Telemetry.ExternalApi
1513

1614
from Call c, ExternalApi api
1715
where
1816
c.getTarget().getUnboundDeclaration() = api and
19-
not api.isSupported() and
20-
not api instanceof FlowSummaryImpl::Public::NeutralCallable
17+
not api.isSupported()
2118
select c, "Call to unsupported external API $@.", api, api.toString()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# These are explicitly windows files and should use crlf
5+
*.bat text eol=crlf
6+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
3+
/**
4+
* Use `apply false` in the top-level build.gradle file to add a Gradle
5+
* plugin as a build dependency but not apply it to the current (root)
6+
* project. Don't use `apply false` in sub-projects. For more information,
7+
* see Applying external plugins with same version to subprojects.
8+
*/
9+
10+
id 'com.android.application' version '7.3.1' apply false
11+
id 'com.android.library' version '7.3.1' apply false
12+
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"markdownMessage": "An Android build may have failed. Ensure the Code Scanning workflow installs required dependencies, and that the [Gradle and Android SDK versions are compatible](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle). Suspicious output line: ` > Minimum supported Gradle version is 7.4. Current version is 7.3. If using the gradle wrapper, try editing the distributionUrl in <test-root-directory>/gradle/wrapper/gradle-wrapper.properties to gradle-7.4-all.zip`",
3+
"severity": "error",
4+
"source": {
5+
"extractorName": "java",
6+
"id": "java/autobuilder/android-build-failure",
7+
"name": "Android build failure"
8+
},
9+
"visibility": {
10+
"cliSummaryTable": true,
11+
"statusPage": true,
12+
"telemetry": true
13+
}
14+
}
15+
{
16+
"markdownMessage": "An Android build may have failed. Ensure the Code Scanning workflow installs required dependencies, and that the [Gradle and Android SDK versions are compatible](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle). Suspicious output line: `Caused by: java.lang.RuntimeException: Minimum supported Gradle version is 7.4. Current version is 7.3. If using the gradle wrapper, try editing the distributionUrl in <test-root-directory>/gradle/wrapper/gradle-wrapper.properties to gradle-7.4-all.zip`",
17+
"severity": "error",
18+
"source": {
19+
"extractorName": "java",
20+
"id": "java/autobuilder/android-build-failure",
21+
"name": "Android build failure"
22+
},
23+
"visibility": {
24+
"cliSummaryTable": false,
25+
"statusPage": false,
26+
"telemetry": true
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# We currently have a bug where gradle tests become flaky when executed in parallel
2+
# - sometimes, gradle fails to connect to the gradle daemon.
3+
# Therefore, force this test to run sequentially.
4+
# Additionally, Android SDK on-demand downloading can fail when multiple tests try to download the same SDK in parallel.

0 commit comments

Comments
 (0)