Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Oct 24, 2023
1 parent 4ac5a87 commit 96f8dea
Show file tree
Hide file tree
Showing 40 changed files with 2,180 additions and 3,802 deletions.
3 changes: 1 addition & 2 deletions config/identical-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
"go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll",
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll",
"swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll"
],
Expand Down Expand Up @@ -534,4 +533,4 @@
"python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml",
"python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml"
]
}
}
2 changes: 1 addition & 1 deletion ruby/ql/docs/flow_summaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ have no source code, so we include a flow summary for it:
private class ChompSummary extends SimpleSummarizedCallable {
ChompSummary() { this = "chomp" }
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
input = "Argument[self]" and
output = "ReturnValue" and
preservesValue = false
Expand Down
91 changes: 48 additions & 43 deletions ruby/ql/lib/codeql/ruby/dataflow/FlowSummary.qll
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,60 @@ private import internal.FlowSummaryImpl as Impl
private import internal.DataFlowDispatch
private import internal.DataFlowImplCommon as DataFlowImplCommon
private import internal.DataFlowPrivate
private import internal.FlowSummaryImplSpecific

// import all instances below
private module Summaries {
private import codeql.ruby.Frameworks
private import codeql.ruby.frameworks.data.ModelsAsData
}

class SummaryComponent = Impl::Public::SummaryComponent;
deprecated class SummaryComponent = Impl::Private::SummaryComponent;

/** Provides predicates for constructing summary components. */
module SummaryComponent {
private import Impl::Public::SummaryComponent as SC
/**
* DEPRECATED.
*
* Provides predicates for constructing summary components.
*/
deprecated module SummaryComponent {
private import Impl::Private::SummaryComponent as SC

predicate parameter = SC::parameter/1;
deprecated predicate parameter = SC::parameter/1;

predicate argument = SC::argument/1;
deprecated predicate argument = SC::argument/1;

predicate content = SC::content/1;
deprecated predicate content = SC::content/1;

predicate withoutContent = SC::withoutContent/1;
deprecated predicate withoutContent = SC::withoutContent/1;

predicate withContent = SC::withContent/1;
deprecated predicate withContent = SC::withContent/1;

class SyntheticGlobal = SC::SyntheticGlobal;
deprecated class SyntheticGlobal = Impl::Private::SyntheticGlobal;

/** Gets a summary component that represents a receiver. */
SummaryComponent receiver() { result = argument(any(ParameterPosition pos | pos.isSelf())) }
deprecated SummaryComponent receiver() {
result = argument(any(ParameterPosition pos | pos.isSelf()))
}

/** Gets a summary component that represents a block argument. */
SummaryComponent block() { result = argument(any(ParameterPosition pos | pos.isBlock())) }
deprecated SummaryComponent block() {
result = argument(any(ParameterPosition pos | pos.isBlock()))
}

/** Gets a summary component that represents an element in a collection at an unknown index. */
SummaryComponent elementUnknown() {
deprecated SummaryComponent elementUnknown() {
result = SC::content(TSingletonContent(TUnknownElementContent()))
}

/** Gets a summary component that represents an element in a collection at a known index. */
SummaryComponent elementKnown(ConstantValue cv) {
deprecated SummaryComponent elementKnown(ConstantValue cv) {
result = SC::content(TSingletonContent(DataFlow::Content::getElementContent(cv)))
}

/**
* Gets a summary component that represents an element in a collection at a specific
* known index `cv`, or an unknown index.
*/
SummaryComponent elementKnownOrUnknown(ConstantValue cv) {
deprecated SummaryComponent elementKnownOrUnknown(ConstantValue cv) {
result = SC::content(TKnownOrUnknownElementContent(TKnownElementContent(cv)))
or
not exists(TKnownElementContent(cv)) and
Expand All @@ -71,48 +78,52 @@ module SummaryComponent {
*
* but is more efficient, because it is represented by a single value.
*/
SummaryComponent elementAny() { result = SC::content(TAnyElementContent()) }
deprecated SummaryComponent elementAny() { result = SC::content(TAnyElementContent()) }

/**
* Gets a summary component that represents an element in a collection at known
* integer index `lower` or above.
*/
SummaryComponent elementLowerBound(int lower) {
deprecated SummaryComponent elementLowerBound(int lower) {
result = SC::content(TElementLowerBoundContent(lower, false))
}

/**
* Gets a summary component that represents an element in a collection at known
* integer index `lower` or above, or possibly at an unknown index.
*/
SummaryComponent elementLowerBoundOrUnknown(int lower) {
deprecated SummaryComponent elementLowerBoundOrUnknown(int lower) {
result = SC::content(TElementLowerBoundContent(lower, true))
}

/** Gets a summary component that represents the return value of a call. */
SummaryComponent return() { result = SC::return(any(NormalReturnKind rk)) }
deprecated SummaryComponent return() { result = SC::return(any(NormalReturnKind rk)) }
}

class SummaryComponentStack = Impl::Public::SummaryComponentStack;
deprecated class SummaryComponentStack = Impl::Private::SummaryComponentStack;

/** Provides predicates for constructing stacks of summary components. */
module SummaryComponentStack {
private import Impl::Public::SummaryComponentStack as SCS
/**
* DEPRECATED.
*
* Provides predicates for constructing stacks of summary components.
*/
deprecated module SummaryComponentStack {
private import Impl::Private::SummaryComponentStack as SCS

predicate singleton = SCS::singleton/1;
deprecated predicate singleton = SCS::singleton/1;

predicate push = SCS::push/2;
deprecated predicate push = SCS::push/2;

predicate argument = SCS::argument/1;
deprecated predicate argument = SCS::argument/1;

/** Gets a singleton stack representing a receiver. */
SummaryComponentStack receiver() { result = singleton(SummaryComponent::receiver()) }
deprecated SummaryComponentStack receiver() { result = singleton(SummaryComponent::receiver()) }

/** Gets a singleton stack representing a block argument. */
SummaryComponentStack block() { result = singleton(SummaryComponent::block()) }
deprecated SummaryComponentStack block() { result = singleton(SummaryComponent::block()) }

/** Gets a singleton stack representing the return value of a call. */
SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
deprecated SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
}

/** A callable with a flow summary, identified by a unique string. */
Expand All @@ -121,18 +132,12 @@ abstract class SummarizedCallable extends LibraryCallable, Impl::Public::Summari
SummarizedCallable() { any() }

/**
* Same as
*
* ```ql
* propagatesFlow(
* SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
* )
* ```
*
* but uses an external (string) representation of the input and output stacks.
* DEPRECATED: Use `propagatesFlow` instead.
*/
pragma[nomagic]
predicate propagatesFlowExt(string input, string output, boolean preservesValue) { none() }
deprecated predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
none()
}

/**
* Gets the synthesized parameter that results from an input specification
Expand All @@ -141,7 +146,7 @@ abstract class SummarizedCallable extends LibraryCallable, Impl::Public::Summari
DataFlow::ParameterNode getParameter(string s) {
exists(ParameterPosition pos |
DataFlowImplCommon::parameterNode(result, TLibraryCallable(this), pos) and
s = getParameterPosition(pos)
s = Impl::Input::encodeParameterPosition(pos)
)
}
}
Expand All @@ -159,7 +164,7 @@ abstract class SimpleSummarizedCallable extends SummarizedCallable {
final override MethodCall getACallSimple() { result = mc }
}

class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;

/**
* Provides a set of special flow summaries to ensure that callbacks passed into
Expand Down Expand Up @@ -199,7 +204,7 @@ private module LibraryCallbackSummaries {
libraryCallHasLambdaArg(result.getAControlFlowNode(), _)
}

override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
(
input = "Argument[block]" and
output = "Argument[block].Parameter[lambda-self]"
Expand Down
Loading

0 comments on commit 96f8dea

Please sign in to comment.