mirror of
https://github.com/github/codeql.git
synced 2026-04-21 06:55:31 +02:00
Java: Add query for counting sink model instances
Also adds a more sensible ordering to the existing queries.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
18
java/ql/src/Telemetry/AutomodelCountGeneratedSinks.ql
Normal file
18
java/ql/src/Telemetry/AutomodelCountGeneratedSinks.ql
Normal 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
|
||||
Reference in New Issue
Block a user