Swift: Add lines of code to SummaryStats.ql.

This commit is contained in:
Geoffrey White
2023-06-08 11:29:04 +01:00
parent 93215ba7e1
commit dc7a286948

View File

@@ -12,6 +12,15 @@ import codeql.swift.security.SensitiveExprs
import codeql.swift.dataflow.DataFlow
import codeql.swift.dataflow.TaintTracking
int linesOfCode() {
// approximate number of lines of code in the database
result = count(File f, int line |
exists(Location loc |
not loc instanceof UnknownLocation and loc.getFile() = f and loc.getStartLine() = line
)
)
}
/**
* A taint configuration for tainted data reaching any node.
*/
@@ -37,6 +46,8 @@ float taintReach() { result = (taintedNodesCount() * 1000000.0) / count(DataFlow
predicate statistic(string what, string value) {
what = "Files" and value = count(File f).toString()
or
what = "Lines of code" and value = linesOfCode().toString()
or
what = "Expressions" and value = count(Expr e | not e.getFile() instanceof UnknownFile).toString()
or
what = "Local flow sources" and value = count(LocalFlowSource s).toString()