mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Ruby: Add regex consistency queries
This commit is contained in:
8
ruby/ql/consistency-queries/RegExpConsistency.ql
Normal file
8
ruby/ql/consistency-queries/RegExpConsistency.ql
Normal 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+() }
|
||||
@@ -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()) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user