Skip to content

Commit ff85e2f

Browse files
Jami CogswellJami Cogswell
authored andcommitted
C#: update ExternalApi characteristic predicate to include not isUninteresting
1 parent f48cc9f commit ff85e2f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

csharp/ql/src/Telemetry/ExternalApi.qll

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ class TestLibrary extends RefType {
2424
}
2525
}
2626

27+
/** Holds if the given callable is a constructor without parameters. */
28+
private predicate isParameterlessConstructor(DotNet::Callable c) {
29+
c instanceof Constructor and c.getNumberOfParameters() = 0
30+
}
31+
32+
/** Holds if this API is part of a common testing library or framework. */
33+
private predicate isTestLibrary(DotNet::Callable c) { c.getDeclaringType() instanceof TestLibrary }
34+
35+
/** Holds if this API is not worth supporting. */
36+
predicate isUninteresting(DotNet::Callable c) { isTestLibrary(c) or isParameterlessConstructor(c) }
37+
2738
/**
2839
* An external API from either the C# Standard Library or a 3rd party library.
2940
*/
3041
class ExternalApi extends DotNet::Callable {
3142
ExternalApi() {
3243
this.isUnboundDeclaration() and
3344
this.fromLibrary() and
34-
this.(Modifiable).isEffectivelyPublic()
45+
this.(Modifiable).isEffectivelyPublic() and
46+
not isUninteresting(this)
3547
}
3648

3749
/**
@@ -84,17 +96,6 @@ class ExternalApi extends DotNet::Callable {
8496
defaultAdditionalTaintStep(this.getAnInput(), _)
8597
}
8698

87-
/** Holds if this API is a constructor without parameters. */
88-
private predicate isParameterlessConstructor() {
89-
this instanceof Constructor and this.getNumberOfParameters() = 0
90-
}
91-
92-
/** Holds if this API is part of a common testing library or framework. */
93-
private predicate isTestLibrary() { this.getDeclaringType() instanceof TestLibrary }
94-
95-
/** Holds if this API is not worth supporting. */
96-
predicate isUninteresting() { this.isTestLibrary() or this.isParameterlessConstructor() }
97-
9899
/** Holds if this API is a known source. */
99100
predicate isSource() {
100101
this.getAnOutput() instanceof RemoteFlowSource or sourceNode(this.getAnOutput(), _)

0 commit comments

Comments
 (0)