Skip to content

Commit

Permalink
Data flow: Dummy SourceBase/SinkBase implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Dec 17, 2024
1 parent 2f23bac commit efbbea1
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ private import semmle.code.cpp.dataflow.ExternalFlow
private import semmle.code.cpp.ir.IR

module Input implements InputSig<Location, DataFlowImplSpecific::CppDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = Function;

class SourceBase = Void;

class SinkBase = Void;

ArgumentPosition callbackSelfParameterPosition() { result = TDirectPosition(-1) }

ReturnKind getStandardReturnValueKind() { result.(NormalReturnKind).getIndirectionIndex() = 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ private import semmle.code.csharp.Unification
private import semmle.code.csharp.dataflow.internal.ExternalFlow

module Input implements InputSig<Location, DataFlowImplSpecific::CsharpDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = UnboundCallable;

class SourceBase = Void;

class SinkBase = Void;

predicate neutralElement(SummarizedCallableBase c, string kind, string provenance, boolean isExact) {
interpretNeutral(c, kind, provenance) and
// isExact is not needed for C#.
Expand Down
12 changes: 6 additions & 6 deletions go/ql/lib/semmle/go/dataflow/ExternalFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import internal.ExternalFlowExtensions as FlowExtensions
private import FlowSummary as FlowSummary
private import internal.DataFlowPrivate
private import internal.FlowSummaryImpl
private import internal.FlowSummaryImpl::Public
private import internal.FlowSummaryImpl::Public as Public
private import internal.FlowSummaryImpl::Private
private import internal.FlowSummaryImpl::Private::External
private import codeql.mad.ModelValidation as SharedModelVal
Expand Down Expand Up @@ -583,13 +583,13 @@ predicate sourceNode(DataFlow::Node node, string kind) { sourceNode(node, kind,
predicate sinkNode(DataFlow::Node node, string kind) { sinkNode(node, kind, _) }

// adapter class for converting Mad summaries to `SummarizedCallable`s
private class SummarizedCallableAdapter extends SummarizedCallable {
private class SummarizedCallableAdapter extends Public::SummarizedCallable {
SummarizedCallableAdapter() { summaryElement(this, _, _, _, _, _) }

private predicate relevantSummaryElementManual(
string input, string output, string kind, string model
) {
exists(Provenance provenance |
exists(Public::Provenance provenance |
summaryElement(this, input, output, kind, provenance, model) and
provenance.isManual()
)
Expand All @@ -598,11 +598,11 @@ private class SummarizedCallableAdapter extends SummarizedCallable {
private predicate relevantSummaryElementGenerated(
string input, string output, string kind, string model
) {
exists(Provenance provenance |
exists(Public::Provenance provenance |
summaryElement(this, input, output, kind, provenance, model) and
provenance.isGenerated()
) and
not exists(Provenance provenance |
not exists(Public::Provenance provenance |
neutralElement(this, "summary", provenance) and
provenance.isManual()
)
Expand All @@ -621,7 +621,7 @@ private class SummarizedCallableAdapter extends SummarizedCallable {
)
}

override predicate hasProvenance(Provenance provenance) {
override predicate hasProvenance(Public::Provenance provenance) {
summaryElement(this, _, _, _, provenance, _)
}
}
6 changes: 6 additions & 0 deletions go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ private string positionToString(int pos) {
}

module Input implements InputSig<Location, DataFlowImplSpecific::GoDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = Callable;

class SourceBase = Void;

class SinkBase = Void;

predicate neutralElement(
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ private string positionToString(int pos) {
}

module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = FlowSummary::SummarizedCallableBase;

class SourceBase = Void;

class SinkBase = Void;

predicate neutralElement(
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ private import DataFlowImplSpecific::Private
private import DataFlowImplSpecific::Public

module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = string;

class SourceBase = Void;

class SinkBase = Void;

ArgumentPosition callbackSelfParameterPosition() { result.isLambdaSelf() }

ReturnKind getStandardReturnValueKind() { any() }
Expand Down
6 changes: 6 additions & 0 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ private import DataFlowImplSpecific::Private
private import DataFlowImplSpecific::Public

module Input implements InputSig<Location, DataFlowImplSpecific::RubyDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = string;

class SourceBase = Void;

class SinkBase = Void;

ArgumentPosition callbackSelfParameterPosition() { result.isLambdaSelf() }

ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ private import DataFlowImplCommon
private import codeql.swift.dataflow.ExternalFlow

module Input implements InputSig<Location, DataFlowImplSpecific::SwiftDataFlow> {
private import codeql.util.Void

class SummarizedCallableBase = Function;

class SourceBase = Void;

class SinkBase = Void;

ArgumentPosition callbackSelfParameterPosition() { result instanceof ThisArgumentPosition }

ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }
Expand Down

0 comments on commit efbbea1

Please sign in to comment.