Skip to content

Commit 36c6c72

Browse files
committed
Java: Move instance counting logic into utility library
1 parent 97610d2 commit 36c6c72

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

java/ql/src/Telemetry/AutomodelAlertSinkUtil.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class SinkModel extends TSinkModel {
6161
/** Gets the provenance for this sink model. */
6262
string getProvenance() { result = provenance }
6363

64+
/** Gets the number of instances of this sink model. */
65+
int getInstanceCount() { result = count(PotentialSinkModelExpr p | p.getSinkModel() = this) }
66+
6467
/** Gets a string representation of this sink model. */
6568
string toString() {
6669
result =

java/ql/src/Telemetry/AutomodelCountGeneratedSinks.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ private import AutomodelAlertSinkUtil
1111

1212
from int instanceCount, SinkModel s
1313
where
14-
instanceCount = strictcount(PotentialSinkModelExpr p | p.getSinkModel() = s) and
14+
instanceCount = s.getInstanceCount() and
15+
instanceCount > 0 and
1516
s.getProvenance() = "ai-generated"
1617
select instanceCount, s.getPackage() as package, s.getType() as type, s.getSubtypes() as subtypes,
1718
s.getName() as name, s.getSignature() as signature, s.getInput() as input, s.getExt() as ext,

0 commit comments

Comments
 (0)