Skip to content

Commit 8334618

Browse files
authored
Merge branch 'main' into jhelie/add-xss-through-dom
2 parents 227d6ff + bda4b52 commit 8334618

File tree

117 files changed

+908
-871
lines changed

Some content is hidden

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

117 files changed

+908
-871
lines changed

config/identical-files.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll"
9595
],
9696
"Model as Data Generation Java/C# - CaptureModels": [
97-
"java/ql/src/utils/model-generator/internal/CaptureModels.qll",
98-
"csharp/ql/src/utils/model-generator/internal/CaptureModels.qll"
97+
"java/ql/src/utils/modelgenerator/internal/CaptureModels.qll",
98+
"csharp/ql/src/utils/modelgenerator/internal/CaptureModels.qll"
9999
],
100100
"Sign Java/C#": [
101101
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/Sign.qll",

cpp/ql/test/library-tests/dataflow/taint-tests/bsd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct sockaddr {
99
char* sa_data;
1010
};
1111

12-
int accept(int, const sockaddr*, int*);
12+
int accept(int, sockaddr*, int*);
1313

1414
void sink(sockaddr);
1515

@@ -20,5 +20,5 @@ void test_accept() {
2020
int a = accept(s, &addr, &size);
2121

2222
sink(a); // $ ast=17:11 ir SPURIOUS: ast=18:12
23-
sink(addr); // $ ast,ir
23+
sink(addr); // $ ast=17:11 ir SPURIOUS: ast=18:12
2424
}

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,14 @@
142142
| bsd.cpp:19:14:19:29 | sizeof(sockaddr) | bsd.cpp:20:29:20:32 | size | |
143143
| bsd.cpp:20:11:20:16 | call to accept | bsd.cpp:22:8:22:8 | a | |
144144
| bsd.cpp:20:18:20:18 | s | bsd.cpp:20:11:20:16 | call to accept | TAINT |
145+
| bsd.cpp:20:18:20:18 | s | bsd.cpp:20:21:20:25 | ref arg & ... | TAINT |
145146
| bsd.cpp:20:21:20:25 | & ... | bsd.cpp:20:11:20:16 | call to accept | TAINT |
147+
| bsd.cpp:20:21:20:25 | & ... | bsd.cpp:20:21:20:25 | ref arg & ... | TAINT |
148+
| bsd.cpp:20:21:20:25 | ref arg & ... | bsd.cpp:20:22:20:25 | addr [inner post update] | |
149+
| bsd.cpp:20:21:20:25 | ref arg & ... | bsd.cpp:23:8:23:11 | addr | |
146150
| bsd.cpp:20:22:20:25 | addr | bsd.cpp:20:11:20:16 | call to accept | TAINT |
147151
| bsd.cpp:20:22:20:25 | addr | bsd.cpp:20:21:20:25 | & ... | |
152+
| bsd.cpp:20:22:20:25 | addr | bsd.cpp:20:21:20:25 | ref arg & ... | TAINT |
148153
| bsd.cpp:20:28:20:32 | ref arg & ... | bsd.cpp:20:29:20:32 | size [inner post update] | |
149154
| bsd.cpp:20:29:20:32 | size | bsd.cpp:20:28:20:32 | & ... | |
150155
| constructor_delegation.cpp:8:2:8:8 | this | constructor_delegation.cpp:8:20:8:24 | constructor init of field x [pre-this] | |

csharp/ql/src/utils/model-generator/CaptureDiscardedSummaryModels.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66

77
import semmle.code.csharp.dataflow.ExternalFlow
8-
import internal.CaptureModels
9-
import internal.CaptureSummaryFlow
8+
import utils.modelgenerator.internal.CaptureModels
9+
import utils.modelgenerator.internal.CaptureSummaryFlow
1010

1111
from DataFlowTargetApi api, string flow
1212
where flow = captureFlow(api) and hasSummary(api, false)

csharp/ql/src/utils/model-generator/CaptureNegativeSummaryModels.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import semmle.code.csharp.dataflow.ExternalFlow
10-
import internal.CaptureModels
11-
import internal.CaptureSummaryFlow
10+
import utils.modelgenerator.internal.CaptureModels
11+
import utils.modelgenerator.internal.CaptureSummaryFlow
1212

1313
from DataFlowTargetApi api, string noflow
1414
where

csharp/ql/src/utils/model-generator/CaptureSinkModels.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
9+
import utils.modelgenerator.internal.CaptureModels
1010

1111
class Activate extends ActiveConfiguration {
1212
override predicate activateToSinkConfig() { any() }

csharp/ql/src/utils/model-generator/CaptureSourceModels.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
9+
import utils.modelgenerator.internal.CaptureModels
1010

1111
class Activate extends ActiveConfiguration {
1212
override predicate activateFromSourceConfig() { any() }

csharp/ql/src/utils/model-generator/CaptureSummaryModels.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import semmle.code.csharp.dataflow.ExternalFlow
10-
import internal.CaptureModels
11-
import internal.CaptureSummaryFlow
10+
import utils.modelgenerator.internal.CaptureModels
11+
import utils.modelgenerator.internal.CaptureSummaryFlow
1212

1313
from DataFlowTargetApi api, string flow
1414
where flow = captureFlow(api) and not hasSummary(api, false)

csharp/ql/src/utils/model-generator/CaptureTypeBasedSummaryModels.ql

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

99
import semmle.code.csharp.dataflow.ExternalFlow
10-
import internal.CaptureTypeBasedSummaryModels
10+
import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels
1111

1212
from TypeBasedFlowTargetApi api, string flow
1313
where flow = captureFlow(api)

csharp/ql/src/utils/model-generator/internal/CaptureTypeBasedSummaryModels.qll renamed to csharp/ql/src/utils/modelgenerator/internal/CaptureTypeBasedSummaryModels.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private string getSyntheticField(TypeParameter tp) {
6464
*/
6565
private string implicit(DotNet::Callable callable, TypeParameter tp) {
6666
classTypeParameter(callable, tp) and
67+
not callable.(Modifiable).isStatic() and
6768
exists(string access |
6869
if genericCollectionType(callable.getDeclaringType(), tp)
6970
then access = ".Element"
@@ -188,7 +189,7 @@ class TypeBasedFlowTargetApi extends Specific::TargetApiSpecific {
188189
* Gets the string representation of all type based summaries for `this`
189190
* inspired by the Theorems for Free approach.
190191
*
191-
* Examples could be (see C# psuedo code below)
192+
* Examples could be (see C# pseudo code below)
192193
* (1) `Get` returns a value of type `T`. We assume that the returned
193194
* value was fetched from a (synthetic) field.
194195
* (2) `Set` consumes a value of type `T`. We assume that the value is stored in

java/ql/lib/semmle/code/java/Collections.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import java
77

88
/**
9-
* The type `t` is a parameterization of `g`, where the `i`-th type parameter of
10-
* `g` is instantiated to `a`?
9+
* Holds if the type `t` is a parameterization of `g`, where the `i`-th type parameter of
10+
* `g` is instantiated to `arg`.
1111
*
1212
* For example, `List<Integer>` parameterizes `List<T>`, instantiating its `0`-th
1313
* type parameter to `Integer`, while the raw type `List` also parameterizes

java/ql/lib/semmle/code/java/Generics.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class TypeVariable extends BoundedType, Modifiable, @typevariable {
195195
result = this.getASuppliedType().(TypeVariable).getAnUltimatelySuppliedType()
196196
}
197197

198+
/** Gets the index of `this` type variable. */
199+
int getIndex() { typeVars(this, _, result, _, _) }
200+
198201
override string getAPrimaryQlClass() { result = "TypeVariable" }
199202
}
200203

java/ql/src/utils/model-generator/CaptureNegativeSummaryModels.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
10-
import internal.CaptureSummaryFlow
9+
import utils.modelgenerator.internal.CaptureModels
10+
import utils.modelgenerator.internal.CaptureSummaryFlow
1111

1212
from DataFlowTargetApi api, string noflow
1313
where noflow = captureNoFlow(api)

java/ql/src/utils/model-generator/CaptureSinkModels.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
9+
import utils.modelgenerator.internal.CaptureModels
1010

1111
class Activate extends ActiveConfiguration {
1212
override predicate activateToSinkConfig() { any() }

java/ql/src/utils/model-generator/CaptureSourceModels.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
9+
import utils.modelgenerator.internal.CaptureModels
1010

1111
class Activate extends ActiveConfiguration {
1212
override predicate activateFromSourceConfig() { any() }

java/ql/src/utils/model-generator/CaptureSummaryModels.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @tags model-generator
77
*/
88

9-
import internal.CaptureModels
10-
import internal.CaptureSummaryFlow
9+
import utils.modelgenerator.internal.CaptureModels
10+
import utils.modelgenerator.internal.CaptureSummaryFlow
1111

1212
from DataFlowTargetApi api, string flow
1313
where flow = captureFlow(api)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @name Capture typed based summary models.
3+
* @description Finds applicable summary models to be used by other queries.
4+
* @kind diagnostic
5+
* @id java/utils/model-generator/summary-models-typed-based
6+
* @tags model-generator
7+
*/
8+
9+
import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels
10+
11+
from TypeBasedFlowTargetApi api, string flow
12+
where flow = captureFlow(api)
13+
select flow order by flow

java/ql/src/utils/model-generator/internal/CaptureModelsSpecific.qll renamed to java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ private predicate isRelevantForModels(J::Callable api) {
6767
*/
6868
predicate isRelevantForDataFlowModels = isRelevantForModels/1;
6969

70+
predicate isRelevantForTypeBasedFlowModels = isRelevantForModels/1;
71+
7072
/**
7173
* A class of Callables that are relevant for generating summary, source and sinks models for.
7274
*
@@ -141,7 +143,7 @@ string asPartialNegativeModel(TargetApiSpecific api) {
141143
)
142144
}
143145

144-
private predicate isPrimitiveTypeUsedForBulkData(J::Type t) {
146+
predicate isPrimitiveTypeUsedForBulkData(J::Type t) {
145147
t.hasName(["byte", "char", "Byte", "Character"])
146148
}
147149

0 commit comments

Comments
 (0)