Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
category: minorAnalysis
---
* Data flow configurations can now include a predicate `neverSkip(Node node)`
in order to ensure inclusion of certain nodes in the path explanations. The
predicate defaults to the end-points of the additional flow steps provided in
the configuration, which means that such steps now always are visible by
default in path explanations.
19 changes: 19 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ signature module ConfigSig {
*/
default predicate allowImplicitRead(Node node, ContentSet c) { none() }

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
default predicate neverSkip(Node node) {
isAdditionalFlowStep(node, _) or isAdditionalFlowStep(_, node)
}

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down Expand Up @@ -141,6 +149,17 @@ signature module StateConfigSig {
*/
default predicate allowImplicitRead(Node node, ContentSet c) { none() }

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
default predicate neverSkip(Node node) {
isAdditionalFlowStep(node, _) or
isAdditionalFlowStep(_, node) or
isAdditionalFlowStep(node, _, _, _) or
isAdditionalFlowStep(_, _, node, _)
}

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ signature module FullStateConfigSig {
*/
predicate allowImplicitRead(Node node, ContentSet c);

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
predicate neverSkip(Node node);

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down Expand Up @@ -2024,7 +2030,8 @@ module Impl<FullStateConfigSig Config> {
castNode(this.asNode()) or
clearsContentCached(this.asNode(), _) or
expectsContentCached(this.asNode(), _) or
neverSkipInPathGraph(this.asNode())
neverSkipInPathGraph(this.asNode()) or
Config::neverSkip(this.asNode())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
19 changes: 19 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ signature module ConfigSig {
*/
default predicate allowImplicitRead(Node node, ContentSet c) { none() }

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
default predicate neverSkip(Node node) {
isAdditionalFlowStep(node, _) or isAdditionalFlowStep(_, node)
}

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down Expand Up @@ -141,6 +149,17 @@ signature module StateConfigSig {
*/
default predicate allowImplicitRead(Node node, ContentSet c) { none() }

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
default predicate neverSkip(Node node) {
isAdditionalFlowStep(node, _) or
isAdditionalFlowStep(_, node) or
isAdditionalFlowStep(node, _, _, _) or
isAdditionalFlowStep(_, _, node, _)
}

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ signature module FullStateConfigSig {
*/
predicate allowImplicitRead(Node node, ContentSet c);

/**
* Holds if `node` should never be skipped over in the `PathGraph` and in path
* explanations.
*/
predicate neverSkip(Node node);

/**
* Gets the virtual dispatch branching limit when calculating field flow.
* This can be overridden to a smaller value to improve performance (a
Expand Down Expand Up @@ -2024,7 +2030,8 @@ module Impl<FullStateConfigSig Config> {
castNode(this.asNode()) or
clearsContentCached(this.asNode(), _) or
expectsContentCached(this.asNode(), _) or
neverSkipInPathGraph(this.asNode())
neverSkipInPathGraph(this.asNode()) or
Config::neverSkip(this.asNode())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private module Config implements FullStateConfigSig {
any(Configuration config).allowImplicitRead(node, c)
}

predicate neverSkip(Node node) { none() }

int fieldFlowBranchLimit() { result = min(any(Configuration config).fieldFlowBranchLimit()) }

FlowFeature getAFeature() { result = any(Configuration config).getAFeature() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ module TaintedWithPath {
}

predicate isBarrierIn(DataFlow::Node node) { nodeIsBarrierIn(node) }

predicate neverSkip(Node node) { none() }
}

private module AdjustedFlow = TaintTracking::Global<AdjustedConfig>;
Expand Down
2 changes: 2 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-611/XXE.ql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module XxeConfig implements DataFlow::StateConfigSig {
// flowstate value.
node.asIndirectExpr().(XxeFlowStateTransformer).transform(flowstate) != flowstate
}

predicate neverSkip(DataFlow::Node node) { none() }
}

module XxeFlow = DataFlow::GlobalWithState<XxeConfig>;
Expand Down
Loading