Java: Move instance counting logic into utility library

This commit is contained in:
Taus
2023-07-06 16:56:15 +02:00
parent 97610d2cac
commit 36c6c7235c
2 changed files with 5 additions and 1 deletions

View File

@@ -61,6 +61,9 @@ class SinkModel extends TSinkModel {
/** Gets the provenance for this sink model. */
string getProvenance() { result = provenance }
/** Gets the number of instances of this sink model. */
int getInstanceCount() { result = count(PotentialSinkModelExpr p | p.getSinkModel() = this) }
/** Gets a string representation of this sink model. */
string toString() {
result =

View File

@@ -11,7 +11,8 @@ private import AutomodelAlertSinkUtil
from int instanceCount, SinkModel s
where
instanceCount = strictcount(PotentialSinkModelExpr p | p.getSinkModel() = s) and
instanceCount = s.getInstanceCount() and
instanceCount > 0 and
s.getProvenance() = "ai-generated"
select instanceCount, s.getPackage() as package, s.getType() as type, s.getSubtypes() as subtypes,
s.getName() as name, s.getSignature() as signature, s.getInput() as input, s.getExt() as ext,