Skip to content

Commit 6121faf

Browse files
author
Stephan Brandauer
committed
Java: Automodel: fr mode: connect new endpoints with MaD models
1 parent 7f084c9 commit 6121faf

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

java/ql/automodel/src/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,20 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
199199
}
200200

201201
predicate isSource(Endpoint e, string kind, string provenance) {
202-
none() // TODO: implement
202+
exists(string package, string type, string name, string signature, string ext, string output |
203+
sourceSpec(e, package, type, name, signature, ext, output) and
204+
ExternalFlow::sourceModel(package, type, _, name, [signature, ""], ext, output, kind,
205+
provenance)
206+
)
203207
}
204208

205209
predicate isNeutral(Endpoint e) {
206210
exists(string package, string type, string name, string signature |
207-
sinkSpec(e, package, type, name, signature, _, _) and
211+
(
212+
sinkSpec(e, package, type, name, signature, _, _)
213+
or
214+
sourceSpec(e, package, type, name, signature, _, _)
215+
) and
208216
ExternalFlow::neutralModel(package, type, name, [signature, ""], "sink", _)
209217
)
210218
}
@@ -218,6 +226,16 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
218226
input = e.getMaDInput()
219227
}
220228

229+
additional predicate sourceSpec(
230+
Endpoint e, string package, string type, string name, string signature, string ext,
231+
string output
232+
) {
233+
e.getEnclosingCallable().hasQualifiedName(package, type, name) and
234+
signature = ExternalFlow::paramsString(e.getEnclosingCallable()) and
235+
ext = "" and
236+
output = e.getMaDOutput()
237+
}
238+
221239
/**
222240
* Gets the related location for the given endpoint.
223241
*
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
| java/io/File.java:4:9:4:17 | compareTo | known non-sink\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/io/File.java:4:9:4:17 | compareTo | MethodDoc | java/io/File.java:4:9:4:17 | compareTo | ClassDoc | file://java.io:1:1:1:1 | java.io | package | file://File:1:1:1:1 | File | type | file://true:1:1:1:1 | true | subtypes | file://compareTo:1:1:1:1 | compareTo | name | file://(File):1:1:1:1 | (File) | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://:1:1:1:1 | | output | file://this:1:1:1:1 | this | parameterName | file://sinkModel:1:1:1:1 | sinkModel | extensibleType |
1+
| java/io/File.java:4:16:4:24 | compareTo | known non-sink\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/io/File.java:4:16:4:24 | compareTo | MethodDoc | java/io/File.java:4:16:4:24 | compareTo | ClassDoc | file://java.io:1:1:1:1 | java.io | package | file://File:1:1:1:1 | File | type | file://true:1:1:1:1 | true | subtypes | file://compareTo:1:1:1:1 | compareTo | name | file://(File):1:1:1:1 | (File) | signature | file://:1:1:1:1 | | input | file://ReturnValue:1:1:1:1 | ReturnValue | output | file://:1:1:1:1 | | parameterName | file://sourceModel:1:1:1:1 | sourceModel | extensibleType |
2+
| java/io/File.java:4:16:4:24 | compareTo | known non-sink\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/io/File.java:4:16:4:24 | compareTo | MethodDoc | java/io/File.java:4:16:4:24 | compareTo | ClassDoc | file://java.io:1:1:1:1 | java.io | package | file://File:1:1:1:1 | File | type | file://true:1:1:1:1 | true | subtypes | file://compareTo:1:1:1:1 | compareTo | name | file://(File):1:1:1:1 | (File) | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://:1:1:1:1 | | output | file://this:1:1:1:1 | this | parameterName | file://sinkModel:1:1:1:1 | sinkModel | extensibleType |
3+
| java/io/File.java:5:9:5:21 | pathname | known non-sink\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/io/File.java:5:9:5:21 | pathname | MethodDoc | java/io/File.java:5:9:5:21 | pathname | ClassDoc | file://java.io:1:1:1:1 | java.io | package | file://File:1:1:1:1 | File | type | file://true:1:1:1:1 | true | subtypes | file://compareTo:1:1:1:1 | compareTo | name | file://(File):1:1:1:1 | (File) | signature | file://:1:1:1:1 | | input | file://Parameter[0]:1:1:1:1 | Parameter[0] | output | file://pathname:1:1:1:1 | pathname | parameterName | file://sourceModel:1:1:1:1 | sourceModel | extensibleType |
24
| java/io/File.java:5:9:5:21 | pathname | known non-sink\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/io/File.java:5:9:5:21 | pathname | MethodDoc | java/io/File.java:5:9:5:21 | pathname | ClassDoc | file://java.io:1:1:1:1 | java.io | package | file://File:1:1:1:1 | File | type | file://true:1:1:1:1 | true | subtypes | file://compareTo:1:1:1:1 | compareTo | name | file://(File):1:1:1:1 | (File) | signature | file://Argument[0]:1:1:1:1 | Argument[0] | input | file://:1:1:1:1 | | output | file://pathname:1:1:1:1 | pathname | parameterName | file://sinkModel:1:1:1:1 | sinkModel | extensibleType |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package java.io;
22

33
public class File {
4-
int compareTo( // `this` is a negative example - this is modeled as a neutral model
4+
public int compareTo( // `this` is a negative example - this is modeled as a neutral model
55
File pathname // negative example - this is modeled as a neutral model
66
) {
77
return 0;
8-
}
8+
} // also a negative example for ReturnValue source
99
}

0 commit comments

Comments
 (0)