mirror of
https://github.com/github/codeql.git
synced 2026-02-02 16:23:02 +01:00
32 lines
903 B
Plaintext
32 lines
903 B
Plaintext
/**
|
|
* @name External libraries
|
|
* @description A list of external libraries used in the code given by their namespace.
|
|
* @kind metric
|
|
* @tags summary telemetry
|
|
* @id cs/telemetry/external-libs
|
|
*/
|
|
|
|
private import csharp
|
|
private import semmle.code.csharp.dispatch.Dispatch
|
|
private import ExternalApi
|
|
|
|
private predicate getRelevantUsages(string namespace, int usages) {
|
|
usages =
|
|
strictcount(Call c, ExternalApi api |
|
|
c.getTarget().getUnboundDeclaration() = api and
|
|
api.getNamespace() = namespace
|
|
)
|
|
}
|
|
|
|
private int getOrder(string namespace) {
|
|
namespace =
|
|
rank[result](string i, int usages | getRelevantUsages(i, usages) | i order by usages desc, i)
|
|
}
|
|
|
|
from ExternalApi api, string namespace, int usages
|
|
where
|
|
namespace = api.getNamespace() and
|
|
getRelevantUsages(namespace, usages) and
|
|
getOrder(namespace) <= resultLimit()
|
|
select namespace, usages order by usages desc
|