Skip to content

Commit 2403ce6

Browse files
committed
PS: Add case insensitive naming to Attributes.
1 parent c8b2fda commit 2403ce6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

powershell/ql/lib/semmle/code/powershell/ast/internal/Attribute.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
private import AstImport
22

33
class Attribute extends AttributeBase, TAttribute {
4-
string getName() { result = getRawAst(this).(Raw::Attribute).getName() }
4+
string getLowerCaseName() { result = getRawAst(this).(Raw::Attribute).getName().toLowerCase() }
5+
6+
bindingset[result]
7+
string getAName() { result.toLowerCase() = this.getLowerCaseName() }
58

69
NamedAttributeArgument getNamedArgument(int i) {
710
exists(ChildIndex index, Raw::Ast r | index = attributeNamedArg(i) and r = getRawAst(this) |
@@ -41,7 +44,7 @@ class Attribute extends AttributeBase, TAttribute {
4144
result = this.toStringSpecific()
4245
or
4346
not exists(this.toStringSpecific()) and
44-
result = this.getName()
47+
result = this.getLowerCaseName()
4548
}
4649

4750
final override Ast getChild(ChildIndex i) {

powershell/ql/lib/semmle/code/powershell/controlflow/CfgNodes.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ class AttributeCfgNode extends AttributeBaseCfgNode {
180180
ExprCfgNode getPositionalArgument(int i) {
181181
attr.hasCfgChild(attr.getPositionalArgument(i), this, result)
182182
}
183+
184+
string getLowerCaseName() { result = attr.getLowerCaseName() }
185+
186+
bindingset[result]
187+
string getAName() { result = attr.getAName() }
183188
}
184189

185190
private class ScriptBlockChildMapping extends NonExprChildMapping, ScriptBlock {

0 commit comments

Comments
 (0)