Skip to content

Commit a91b71c

Browse files
author
Stephan Brandauer
committed
add parameter names to metadata, set subtypes = false for static method candidates; remove UndocumentedMethodCharacteristics, now that we use ModelApi
1 parent 3868def commit a91b71c

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

java/ql/src/Telemetry/AutomodelEndpointCharacteristics.qll

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
8383
exists(int paramIdx | e.isParameterOf(_, paramIdx) | input = "Argument[" + paramIdx + "]")
8484
}
8585

86-
predicate hasMetadata(Endpoint n, string metadata) {
86+
predicate hasMetadata(Endpoint e, string metadata) {
8787
exists(
8888
string package, string type, boolean subtypes, string name, string signature, string ext,
89-
int input, string provenance, boolean isPublic, boolean isFinal, string calleeJavaDoc
89+
int input, string provenance, boolean isPublic, boolean isFinal, boolean isStatic,
90+
string calleeJavaDoc
9091
|
91-
hasMetadata(n, package, type, name, signature, input, isFinal, isPublic, calleeJavaDoc) and
92-
(if isFinal = true then subtypes = false else subtypes = true) and
92+
hasMetadata(e, package, type, name, signature, input, isFinal, isStatic, isPublic,
93+
calleeJavaDoc) and
94+
(if isFinal = true or isStatic = true then subtypes = false else subtypes = true) and
9395
ext = "" and // see https://github.slack.com/archives/CP9127VUK/p1673979477496069
9496
provenance = "ai-generated" and
9597
metadata =
@@ -98,6 +100,7 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
98100
+ "', 'Type': '" + type //
99101
+ "', 'Subtypes': " + subtypes //
100102
+ ", 'Name': '" + name //
103+
+ ", 'ParamName': '" + e.toString() //
101104
+ "', 'Signature': '" + signature //
102105
+ "', 'Ext': '" + ext //
103106
+ "', 'Argument index': " + input //
@@ -126,12 +129,17 @@ class Endpoint = CandidatesImpl::Endpoint;
126129
*/
127130
predicate hasMetadata(
128131
Endpoint n, string package, string type, string name, string signature, int input,
129-
boolean isFinal, boolean isPublic, string calleeJavaDoc
132+
boolean isFinal, boolean isStatic, boolean isPublic, string calleeJavaDoc
130133
) {
131134
exists(Callable callee |
132135
n.asParameter() = callee.getParameter(input) and
133136
package = callee.getDeclaringType().getPackage().getName() and
134137
type = callee.getDeclaringType().getErasure().(RefType).nestedName() and
138+
(
139+
if callee.isStatic() or callee.getDeclaringType().isStatic()
140+
then isStatic = true
141+
else isStatic = false
142+
) and
135143
(
136144
if callee.isFinal() or callee.getDeclaringType().isFinal()
137145
then isFinal = true
@@ -224,22 +232,6 @@ private class TestFileCharacteristic extends CharacteristicsImpl::LikelyNotASink
224232
}
225233
}
226234

227-
/**
228-
* A negative characteristic that filters out calls to undocumented methods. The assumption is that methods that are
229-
* intended / likely to be called from outside the package are documented.
230-
*
231-
* Note that in practice we have seen some interesting sinks in methods that are external-facing but undocumented (and
232-
* appear in empty Javadoc pages), so this filter can be expected to lead to the loss of some interesting sinks.
233-
*/
234-
private class UndocumentedMethodCharacteristic extends CharacteristicsImpl::UninterestingToModelCharacteristic
235-
{
236-
UndocumentedMethodCharacteristic() { this = "undocumented method" }
237-
238-
override predicate appliesToEndpoint(Endpoint e) {
239-
not exists(e.getEnclosingCallable().(Documentable).getJavadoc())
240-
}
241-
}
242-
243235
/**
244236
* A characteristic that limits candidates to parameters of methods that are recognized as `ModelApi`, iow., APIs that
245237
* are considered worth modelling.

0 commit comments

Comments
 (0)