Ruby: Add regex consistency queries

This commit is contained in:
Tom Hvitved
2022-03-08 10:10:14 +01:00
parent 6d4eecff14
commit 3bc8d0878f
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
import codeql.ruby.security.performance.RegExpTreeView
query predicate nonUniqueChild(RegExpParent parent, int i, RegExpTerm child) {
child = parent.getChild(i) and
strictcount(parent.getChild(i)) > 1
}
query predicate cyclic(RegExpParent parent) { parent = parent.getAChild+() }

View File

@@ -69,7 +69,7 @@ class RegExpParent extends TRegExpParent {
RegExpTerm getChild(int i) { none() }
RegExpTerm getAChild() { result = this.getChild(_) }
final RegExpTerm getAChild() { result = this.getChild(_) }
int getNumChild() { result = count(this.getAChild()) }