Skip to content

Commit 51d2eb6

Browse files
committed
C#: Refactor queries to use Results module and thus narrowing the number of returned results.
1 parent d5eebc8 commit 51d2eb6

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

csharp/ql/src/Telemetry/SupportedExternalSinks.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
1111
private import ExternalApi
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.isSink() and
1716
usages = strictcount(DispatchCall c | c = api.getACall())
17+
}
18+
19+
from ExternalApi api, int usages
20+
where Results<getRelevantUsages/2>::restrict(api, usages)
1821
select api.getInfo() as info, usages order by usages desc

csharp/ql/src/Telemetry/SupportedExternalSources.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
1111
private import ExternalApi
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.isSource() and
1716
usages = strictcount(DispatchCall c | c = api.getACall())
17+
}
18+
19+
from ExternalApi api, int usages
20+
where Results<getRelevantUsages/2>::restrict(api, usages)
1821
select api.getInfo() as info, usages order by usages desc

csharp/ql/src/Telemetry/SupportedExternalTaint.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
1111
private import ExternalApi
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
api.hasSummary() and
1716
usages = strictcount(DispatchCall c | c = api.getACall())
17+
}
18+
19+
from ExternalApi api, int usages
20+
where Results<getRelevantUsages/2>::restrict(api, usages)
1821
select api.getInfo() as info, usages order by usages desc

csharp/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ private import csharp
1010
private import semmle.code.csharp.dispatch.Dispatch
1111
private import ExternalApi
1212

13-
from ExternalApi api, int usages
14-
where
13+
private predicate getRelevantUsages(ExternalApi api, int usages) {
1514
not api.isUninteresting() and
1615
not api.isSupported() and
1716
usages = strictcount(DispatchCall c | c = api.getACall())
17+
}
18+
19+
from ExternalApi api, int usages
20+
where Results<getRelevantUsages/2>::restrict(api, usages)
1821
select api.getInfo() as info, usages order by usages desc

0 commit comments

Comments
 (0)