Skip to content

[Javascript]: How to filter out StringLiteral source with LogicalOrExpr #701

Answered by erik-krogh
manunio asked this question in Q&A
Discussion options

You must be logged in to vote

You have a mistake in your NoneEmptyStringLiteral.
You write both this.asExpr().(StringLiteral) and this.asExpr().(LogicalOrExpr), which requires that the same dataflow-node is both a logical or and a stringliteral at the same time, which cannot happen.

I think you want something like this:

class LogicalOrWithNonEmptyString extends DataFlow::Node {
  LogicalOrWithNonEmptyString() {
    exists(LogicalOrExpr logOr | logOr = this.asExpr() |
      logOr.getAnOperand().(StringLiteral).getValue().lengt() > 1
    )
  }
}

Or maybe:

class LogicalOrWithNonEmptyString extends DataFlow::ValueNode {
  override LogicalOrExpr astNode;

  LogicalOrWithNonEmptyString() { astNode.getAnOperand().(StringLiteral

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@manunio
Comment options

@erik-krogh
Comment options

@manunio
Comment options

Answer selected by manunio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants