Skip to content

Conversation

@aschackmull
Copy link
Contributor

@aschackmull aschackmull commented Jun 20, 2022

Deprecates the BarrierGuard class for all languages using the shared data flow library, and replaces existing usage with the BarrierGuard parameterised module.

See initial Java implementation in #9294

Comment on lines +397 to +405
abstract deprecated class BarrierGuard extends Node {
/** Holds if this guard validates `e` upon evaluating to `branch`. */
abstract predicate checks(Expr e, boolean branch);

/** Gets a node guarded by this guard. */
final Node getAGuardedNode() {
result = BarrierGuard<barrierGuardChecks/3>::getABarrierNodeForGuard(this)
}
}

Check failure

Code scanning / CodeQL

Bidirectional imports for abstract classes

This abstract class doesn't import its subclass [SharedXssSanitizerGuard](1) but imports 4 other subclasses, such as [RedirectCheckBarrierGuard](2). This abstract class doesn't import its subclass [SanitizerGuardAsBarrierGuard](3) but imports 4 other subclasses, such as [RedirectCheckBarrierGuard](2).
*/
module BarrierGuard<guardChecksSig/3 guardChecks> {
/** Gets a node that is safely guarded by the given guard check. */
ExprNode getABarrierNode() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoff should this be ExprNode or CfgNode? It seems the only difference is that CfgNodes can also be patterns from a match statement. I simply don't know whether such patterns should be eligible for being the result of a guards check 🤔 Anyway, I was just a bit suspicious about this since we use ExprNode very little in our code, and thought it might just be a leftover from @aschackmull normally using that for Java.

/** A node corresponding to a control flow node. */
TCfgNode(ControlFlowNode node) {
isExpressionNode(node)
or
node.getNode() instanceof Pattern
} or

class ExprNode extends CfgNode {
ExprNode() { isExpressionNode(node) }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to change it as a follow-up. I just kept the status quo in this case.

@aschackmull aschackmull marked this pull request as ready for review June 21, 2022 09:19
@aschackmull aschackmull requested review from a team as code owners June 21, 2022 09:19
@aschackmull aschackmull requested review from a team as code owners June 21, 2022 09:19
MathiasVP
MathiasVP previously approved these changes Jun 21, 2022
atorralba
atorralba previously approved these changes Jun 21, 2022
Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 👍

michaelnebel
michaelnebel previously approved these changes Jun 21, 2022
Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C# Looks plausible to me!

@smowton smowton dismissed stale reviews from michaelnebel, atorralba, and MathiasVP via 8ae4c21 June 21, 2022 11:11
smowton
smowton previously approved these changes Jun 21, 2022
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly resolved some ql-for-ql doc complaints; with that Go 👍

Copy link
Contributor

@nickrolfe nickrolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ruby changes look good to me.

Are you running DCA comparisons?

@aschackmull
Copy link
Contributor Author

Are you running DCA comparisons?

I didn't plan to.

Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python: Besides the point I already raised for @yoff, this LGTM 👍


/** A validation of unknown node by comparing with a constant string value. */
class StringConstCompare extends DataFlow::BarrierGuard, CompareNode {
class StringConstCompareBarrier extends DataFlow::Node {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered for a second whether this should be called StringConstCompareSanitizer, but I think using StringConstCompareBarrier is fine 👍 (and consistent with the new name in Ruby at least)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like this is good to merge, then.

@michaelnebel michaelnebel self-requested a review June 22, 2022 08:39
Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C# Looks plausible to me!

@aschackmull aschackmull merged commit df6d68b into github:main Jun 22, 2022
@aschackmull aschackmull deleted the dataflow/deprecate-barrierguard-class branch June 22, 2022 08:44
}

/** A bridge class to access the deprecated `isBarrierGuard`. */
private class BarrierGuardGuardedNodeBridge extends Unit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat trick for accessing a deprecated predicate without getting a deprecation warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants