Skip to content

Commit 3bc8d08

Browse files
committed
Ruby: Add regex consistency queries
1 parent 6d4eecf commit 3bc8d08

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import codeql.ruby.security.performance.RegExpTreeView
2+
3+
query predicate nonUniqueChild(RegExpParent parent, int i, RegExpTerm child) {
4+
child = parent.getChild(i) and
5+
strictcount(parent.getChild(i)) > 1
6+
}
7+
8+
query predicate cyclic(RegExpParent parent) { parent = parent.getAChild+() }

ruby/ql/lib/codeql/ruby/security/performance/RegExpTreeView.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class RegExpParent extends TRegExpParent {
6969

7070
RegExpTerm getChild(int i) { none() }
7171

72-
RegExpTerm getAChild() { result = this.getChild(_) }
72+
final RegExpTerm getAChild() { result = this.getChild(_) }
7373

7474
int getNumChild() { result = count(this.getAChild()) }
7575

0 commit comments

Comments
 (0)