Skip to content

Commit 9845887

Browse files
author
Stephan Brandauer
committed
automodel java fix: export method name as 'name' metadata parameter; export parameter name as 'parameterName' parameter
1 parent ed79113 commit 9845887

4 files changed

+16
-12
lines changed

java/ql/src/Telemetry/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class MetadataExtractor extends string {
2727

2828
abstract predicate hasMetadata(
2929
DataFlow::ParameterNode e, string package, string type, boolean subtypes, string name,
30-
string signature, int input
30+
string signature, int input, string parameterName
3131
);
3232
}
3333

@@ -167,14 +167,15 @@ class FrameworkModeMetadataExtractor extends MetadataExtractor {
167167

168168
override predicate hasMetadata(
169169
Endpoint e, string package, string type, boolean subtypes, string name, string signature,
170-
int input
170+
int input, string parameterName
171171
) {
172172
exists(Callable callable |
173173
e.asParameter() = callable.getParameter(input) and
174174
package = callable.getDeclaringType().getPackage().getName() and
175175
type = callable.getDeclaringType().getErasure().(RefType).nestedName() and
176176
subtypes = this.considerSubtypes(callable) and
177-
name = e.toString() and
177+
name = callable.getName() and
178+
parameterName = e.toString() and
178179
signature = ExternalFlow::paramsString(callable)
179180
)
180181
}

java/ql/src/Telemetry/AutomodelFrameworkModeExtractCandidates.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private import AutomodelSharedUtil
1717

1818
from
1919
Endpoint endpoint, string message, MetadataExtractor meta, string package, string type,
20-
boolean subtypes, string name, string signature, int input
20+
boolean subtypes, string name, string signature, int input, string parameterName
2121
where
2222
not exists(CharacteristicsImpl::UninterestingToModelCharacteristic u |
2323
u.appliesToEndpoint(endpoint)
@@ -28,7 +28,7 @@ where
2828
// overlap between our detected sinks and the pre-existing modeling. We assume that, if a sink has already been
2929
// modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it.
3030
not CharacteristicsImpl::isSink(endpoint, _) and
31-
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input) and
31+
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, parameterName) and
3232
// The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be
3333
// a non-sink, and we surface only endpoints that have at least one such sink type.
3434
message =
@@ -47,4 +47,5 @@ select endpoint,
4747
subtypes.toString().(DollarAtString), "subtypes", //
4848
name.(DollarAtString), "name", //
4949
signature.(DollarAtString), "signature", //
50-
input.toString().(DollarAtString), "input" //
50+
input.toString().(DollarAtString), "input", //
51+
parameterName.(DollarAtString), "parameterName" //

java/ql/src/Telemetry/AutomodelFrameworkModeExtractNegativeExamples.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ private import AutomodelSharedUtil
1515
from
1616
Endpoint endpoint, EndpointCharacteristic characteristic, float confidence, string message,
1717
MetadataExtractor meta, string package, string type, boolean subtypes, string name,
18-
string signature, int input
18+
string signature, int input, string parameterName
1919
where
2020
characteristic.appliesToEndpoint(endpoint) and
2121
confidence >= SharedCharacteristics::highConfidence() and
2222
characteristic.hasImplications(any(NegativeSinkType negative), true, confidence) and
2323
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
2424
// certain about in the prompt.
2525
not erroneousEndpoints(endpoint, _, _, _, _, false) and
26-
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input) and
26+
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, parameterName) and
2727
// It's valid for a node to satisfy the logic for both `isSink` and `isSanitizer`, but in that case it will be
2828
// treated by the actual query as a sanitizer, since the final logic is something like
2929
// `isSink(n) and not isSanitizer(n)`. We don't want to include such nodes as negative examples in the prompt, because
@@ -44,4 +44,5 @@ select endpoint,
4444
subtypes.toString().(DollarAtString), "subtypes", //
4545
name.(DollarAtString), "name", //
4646
signature.(DollarAtString), "signature", //
47-
input.toString().(DollarAtString), "input" //
47+
input.toString().(DollarAtString), "input", //
48+
parameterName.(DollarAtString), "parameterName" //

java/ql/src/Telemetry/AutomodelFrameworkModeExtractPositiveExamples.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ private import AutomodelSharedUtil
1414

1515
from
1616
Endpoint endpoint, SinkType sinkType, MetadataExtractor meta, string package, string type,
17-
boolean subtypes, string name, string signature, int input
17+
boolean subtypes, string name, string signature, int input, string parameterName
1818
where
1919
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
2020
// certain about in the prompt.
2121
not erroneousEndpoints(endpoint, _, _, _, _, false) and
22-
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input) and
22+
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, parameterName) and
2323
// Extract positive examples of sinks belonging to the existing ATM query configurations.
2424
CharacteristicsImpl::isKnownSink(endpoint, sinkType)
2525
select endpoint,
@@ -31,4 +31,5 @@ select endpoint,
3131
subtypes.toString().(DollarAtString), "subtypes", //
3232
name.(DollarAtString), "name", //
3333
signature.(DollarAtString), "signature", //
34-
input.toString().(DollarAtString), "input" //
34+
input.toString().(DollarAtString), "input", //
35+
parameterName.(DollarAtString), "parameterName" //

0 commit comments

Comments
 (0)