Java: Add query for counting sink model instances

Also adds a more sensible ordering to the existing queries.
This commit is contained in:
Taus
2023-07-04 14:24:52 +02:00
parent b7e4bd290d
commit 97610d2cac
4 changed files with 21 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ class SinkModel extends TSinkModel {
}
/** An expression that may correspond to a sink model. */
private class PotentialSinkModelExpr extends Expr {
class PotentialSinkModelExpr extends Expr {
/**
* Holds if this expression has the given signature. The signature should contain enough
* information to determine a corresponding sink model, if one exists.

View File

@@ -13,4 +13,4 @@ from int alertCount, SinkModel s
where sinkModelTally(alertCount, s) and s.getProvenance() = "ai-generated"
select alertCount, 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,
s.getKind() as kind, s.getProvenance() as provenance
s.getKind() as kind, s.getProvenance() as provenance order by alertCount desc

View File

@@ -16,3 +16,4 @@ where
select queryId, alertCount, 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, s.getKind() as kind, s.getProvenance() as provenance
order by queryId, alertCount desc

View File

@@ -0,0 +1,18 @@
/**
* @name Number of instances of each sink model
* @description Counts the number of instances of `ai-generated` sink models.
* @kind table
* @id java/ml/metrics-count-instances-per-sink-model
* @tags internal automodel metrics
*/
private import java
private import AutomodelAlertSinkUtil
from int instanceCount, SinkModel s
where
instanceCount = strictcount(PotentialSinkModelExpr p | p.getSinkModel() = s) 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,
s.getKind() as kind, s.getProvenance() as provenance order by instanceCount desc