Skip to content

Commit 7d3131c

Browse files
author
Benjamin Muskalla
committed
Move usage count into where clause
1 parent 89ce04d commit 7d3131c

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

java/ql/src/Telemetry/ExternalAPI.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private import semmle.code.java.dataflow.ExternalFlow
1010
class ExternalAPI extends Callable {
1111
ExternalAPI() { not this.fromSource() }
1212

13-
/** Holds true if this API is part of a common testing library or framework */
13+
/** Holds if this API is part of a common testing library or framework */
1414
predicate isTestLibrary() { getDeclaringType() instanceof TestLibrary }
1515

1616
/**
@@ -22,7 +22,7 @@ class ExternalAPI extends Callable {
2222
";" + api.getName() + ";" + paramsString(api)
2323
}
2424

25-
/** Holds true if this API is not yet supported by existing CodeQL libraries */
25+
/** Holds if this API is not yet supported by existing CodeQL libraries */
2626
predicate isSupported() { not supportKind(this) = "?" }
2727

2828
/**

java/ql/src/Telemetry/SupportedExternalSinks.ql

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import APIUsage
1111
import ExternalAPI
1212
import semmle.code.java.GeneratedFiles
1313

14-
from ExternalAPI api
14+
from ExternalAPI api, int usages
1515
where
1616
not api.isTestLibrary() and
17-
supportKind(api) = "sink"
18-
select api.asCsv(api) as csv,
19-
strictcount(Call c |
20-
c.getCallee() = api and
21-
not c.getFile() instanceof GeneratedFile
22-
) as Usages order by Usages desc
17+
supportKind(api) = "sink" and
18+
usages =
19+
strictcount(Call c |
20+
c.getCallee().getSourceDeclaration() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
)
23+
select api.asCsv(api) as csv, usages order by usages desc

java/ql/src/Telemetry/SupportedExternalSources.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ where
1717
supportKind(api) = "source" and
1818
usages =
1919
strictcount(Call c |
20-
c.getCallee() = api and
20+
c.getCallee().getSourceDeclaration() = api and
2121
not c.getFile() instanceof GeneratedFile
2222
)
2323
select api.asCsv(api) as csv, usages order by usages desc

java/ql/src/Telemetry/SupportedExternalTaint.ql

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import APIUsage
1111
import ExternalAPI
1212
import semmle.code.java.GeneratedFiles
1313

14-
from ExternalAPI api
14+
from ExternalAPI api, int usages
1515
where
1616
not api.isTestLibrary() and
17-
supportKind(api) = ["summary", "taint-preserving"]
18-
select api.asCsv(api) as csv,
19-
strictcount(Call c |
20-
c.getCallee() = api and
21-
not c.getFile() instanceof GeneratedFile
22-
) as Usages order by Usages desc
17+
supportKind(api) = ["summary", "taint-preserving"] and
18+
usages =
19+
strictcount(Call c |
20+
c.getCallee().getSourceDeclaration() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
)
23+
select api.asCsv(api) as csv, usages order by usages desc

java/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import APIUsage
1111
import ExternalAPI
1212
import semmle.code.java.GeneratedFiles
1313

14-
from ExternalAPI api
14+
from ExternalAPI api, int usages
1515
where
1616
not api.isTestLibrary() and
17-
not api.isSupported()
18-
select api.asCsv(api) as csv,
19-
strictcount(Call c |
20-
c.getCallee() = api and
21-
not c.getFile() instanceof GeneratedFile
22-
) as Usages order by Usages desc
17+
not api.isSupported() and
18+
usages =
19+
strictcount(Call c |
20+
c.getCallee().getSourceDeclaration() = api and
21+
not c.getFile() instanceof GeneratedFile
22+
)
23+
select api.asCsv(api) as csv, usages order by usages desc

0 commit comments

Comments
 (0)