Skip to content

Commit b2578f0

Browse files
author
Stephan Brandauer
committed
Java: Automodel Fr Mode: add return value endpoint type
1 parent 8cc6466 commit b2578f0

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

java/ql/automodel/src/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ newtype JavaRelatedLocationType =
2525

2626
newtype TFrameworkModeEndpoint =
2727
TExplicitParameter(Parameter p) or
28-
TQualifier(Callable c)
28+
TQualifier(Callable c) or
29+
TReturnValue(Callable c)
2930

3031
/**
3132
* A framework mode endpoint.
@@ -48,9 +49,7 @@ abstract class FrameworkModeEndpoint extends TFrameworkModeEndpoint {
4849

4950
abstract Top asTop();
5051

51-
string getExtensibleType() {
52-
result = "sinkModel"
53-
}
52+
abstract string getExtensibleType();
5453

5554
string toString() { result = this.asTop().toString() }
5655

@@ -69,6 +68,8 @@ class ExplicitParameterEndpoint extends FrameworkModeEndpoint, TExplicitParamete
6968
override Callable getEnclosingCallable() { result = param.getCallable() }
7069

7170
override Top asTop() { result = param }
71+
72+
override string getExtensibleType() { result = "sinkModel" }
7273
}
7374

7475
class QualifierEndpoint extends FrameworkModeEndpoint, TQualifier {
@@ -85,6 +86,30 @@ class QualifierEndpoint extends FrameworkModeEndpoint, TQualifier {
8586
override Callable getEnclosingCallable() { result = callable }
8687

8788
override Top asTop() { result = callable }
89+
90+
override string getExtensibleType() { result = "sinkModel" }
91+
}
92+
93+
class ReturnValue extends FrameworkModeEndpoint, TReturnValue {
94+
Callable callable;
95+
96+
ReturnValue() { this = TReturnValue(callable) and callable.fromSource() }
97+
98+
override int getIndex() {
99+
// FIXME bogus value
100+
result = -1
101+
}
102+
103+
override string getParamName() {
104+
// FIXME bogus value
105+
result = "return value"
106+
}
107+
108+
override Callable getEnclosingCallable() { result = callable }
109+
110+
override Top asTop() { result = callable }
111+
112+
override string getExtensibleType() { result = "sourceModel" }
88113
}
89114

90115
/**

java/ql/automodel/test/AutomodelFrameworkModeExtraction/com/github/codeql/test/PublicClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
public class PublicClass {
44
public void stuff(String arg) { // `arg` is a candidate, `this` is a candidate
55
System.out.println(arg);
6-
}
6+
} // method stuff is a candidate source
77

88
public static void staticStuff(String arg) { // `arg` is a candidate, `this` is not a candidate (static method)
99
System.out.println(arg);
10-
}
10+
} // method staticStuff is a candidate source
1111

1212
// `arg` and `this` are not a candidate because the method is not public:
1313
protected void nonPublicStuff(String arg) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.codeql.test;
22

33
public interface PublicInterface {
4-
public void stuff(String arg); // `arg` is a candidate, `this` is a candidate
4+
public void stuff(String arg); // `arg` is a candidate, `this` is a candidate, method stuff is a candidate source
55

66
public static void staticStuff(String arg) { // `arg` is a candidate, `this` is not a candidate (static method)
77
System.out.println(arg);
8-
}
8+
} // method staticStuff is a candidate source
99
}

java/ql/automodel/test/AutomodelFrameworkModeExtraction/java/nio/file/Files.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public static void copy(
1919
*/
2020
) throws IOException {
2121
// ...
22-
}
22+
} // method copy is a candidate source
2323

2424
public static InputStream newInputStream(
2525
Path openPath ,// positive example (known sink), candidate (ai-modeled, and useful as a candidate in regression testing)
2626
OpenOption... options
2727
) throws IOException {
2828
return new FileInputStream(openPath.toFile());
29-
}
29+
} // method newInputStream is a candidate source
3030
}

0 commit comments

Comments
 (0)