File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -107,3 +107,32 @@ class ExternalApi extends DotNet::Callable {
107
107
/** Holds if this API is supported by existing CodeQL libraries, that is, it is either a recognized source or sink or has a flow summary. */
108
108
predicate isSupported ( ) { this .hasSummary ( ) or this .isSource ( ) or this .isSink ( ) }
109
109
}
110
+
111
+ /**
112
+ * A limit for the number of results produced by a telemetry query.
113
+ */
114
+ int resultLimit ( ) { result = 1000 }
115
+
116
+ /**
117
+ * A predicate signature for relevant usage counts of an External API `api`.
118
+ */
119
+ signature predicate relevantUsagesSig ( ExternalApi api , int usages ) ;
120
+
121
+ /**
122
+ * Given a predicate to count relevant API usages, this module provides a predicate
123
+ * for restricting the number or returned results based on a certain limit.
124
+ */
125
+ module Results< relevantUsagesSig / 2 getRelevantUsages> {
126
+ private int getOrder ( ExternalApi api ) {
127
+ api =
128
+ rank [ result ] ( ExternalApi a , int usages |
129
+ getRelevantUsages ( a , usages )
130
+ |
131
+ a order by usages desc , a .getInfo ( )
132
+ )
133
+ }
134
+
135
+ predicate restrict ( ExternalApi api , int usages ) {
136
+ getRelevantUsages ( api , usages ) and getOrder ( api ) <= resultLimit ( )
137
+ }
138
+ }
You can’t perform that action at this time.
0 commit comments