Merge pull request #12261 from michaelnebel/csharpjava/refactorissupported

C#/Java: Re-factor the `isSupported` predicate.
This commit is contained in:
Michael Nebel
2023-02-23 10:06:11 +01:00
committed by GitHub
7 changed files with 29 additions and 29 deletions

View File

@@ -6,6 +6,7 @@ private import semmle.code.java.dataflow.ExternalFlow
private import semmle.code.java.dataflow.FlowSources
private import semmle.code.java.dataflow.FlowSummary
private import semmle.code.java.dataflow.internal.DataFlowPrivate
private import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
private import semmle.code.java.dataflow.TaintTracking
pragma[nomagic]
@@ -91,8 +92,17 @@ class ExternalApi extends Callable {
pragma[nomagic]
predicate isSink() { sinkNode(this.getAnInput(), _) }
/** 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. */
predicate isSupported() { this.hasSummary() or this.isSource() or this.isSink() }
/** Holds if this API is a known neutral. */
pragma[nomagic]
predicate isNeutral() { this = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable() }
/**
* Holds if this API is supported by existing CodeQL libraries, that is, it is either a
* recognized source, sink or neutral or it has a flow summary.
*/
predicate isSupported() {
this.hasSummary() or this.isSource() or this.isSink() or this.isNeutral()
}
}
/** DEPRECATED: Alias for ExternalApi */

View File

@@ -7,13 +7,9 @@
*/
import java
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
import ExternalApi
private predicate relevant(ExternalApi api) {
api.isSupported() or
api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
}
private predicate relevant(ExternalApi api) { api.isSupported() }
from string apiName, int usages
where Results<relevant/1>::restrict(apiName, usages)

View File

@@ -7,13 +7,9 @@
*/
import java
import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
import ExternalApi
private predicate relevant(ExternalApi api) {
not api.isSupported() and
not api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
}
private predicate relevant(ExternalApi api) { not api.isSupported() }
from string apiName, int usages
where Results<relevant/1>::restrict(apiName, usages)