mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: Add query for CSV framework coverage.
This commit is contained in:
14
java/ql/src/meta/frameworks/Coverage.ql
Normal file
14
java/ql/src/meta/frameworks/Coverage.ql
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @name Framework coverage
|
||||
* @description The number of API endpoints covered by CSV models sorted by
|
||||
* package and source-, sink-, and summary-kind.
|
||||
* @kind metric
|
||||
* @id java/meta/framework-coverage
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.dataflow.ExternalFlow
|
||||
|
||||
from string package, string kind, string part, int n
|
||||
where modelCoverage(package, kind, part, n)
|
||||
select package, kind, part, n
|
||||
@@ -204,6 +204,29 @@ private predicate summaryModel(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if CSV framework coverage of `package` is `n` api endpoints of the
|
||||
* kind `(kind, part)`.
|
||||
*/
|
||||
predicate modelCoverage(string package, string kind, string part, int n) {
|
||||
part = "source" and
|
||||
n =
|
||||
strictcount(string type, boolean subtypes, string name, string signature, string ext,
|
||||
string output | sourceModel(package, type, subtypes, name, signature, ext, output, kind))
|
||||
or
|
||||
part = "sink" and
|
||||
n =
|
||||
strictcount(string type, boolean subtypes, string name, string signature, string ext,
|
||||
string input | sinkModel(package, type, subtypes, name, signature, ext, input, kind))
|
||||
or
|
||||
part = "summary" and
|
||||
n =
|
||||
strictcount(string type, boolean subtypes, string name, string signature, string ext,
|
||||
string input, string output |
|
||||
summaryModel(package, type, subtypes, name, signature, ext, input, output, kind)
|
||||
)
|
||||
}
|
||||
|
||||
/** Provides a query predicate to check the CSV data for validation errors. */
|
||||
module CsvValidation {
|
||||
/** Holds if some row in a CSV-based flow model appears to contain typos. */
|
||||
|
||||
Reference in New Issue
Block a user