From dc7a286948abf93a1233c63bcd3e34fb604b01aa Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Thu, 8 Jun 2023 11:29:04 +0100 Subject: [PATCH] Swift: Add lines of code to SummaryStats.ql. --- swift/ql/src/queries/Summary/SummaryStats.ql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/swift/ql/src/queries/Summary/SummaryStats.ql b/swift/ql/src/queries/Summary/SummaryStats.ql index 444c4da2ca2..9174dd19aee 100644 --- a/swift/ql/src/queries/Summary/SummaryStats.ql +++ b/swift/ql/src/queries/Summary/SummaryStats.ql @@ -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()