Skip to content

Commit b672950

Browse files
authored
Merge branch 'main' into denisl/goreferenceupdate
2 parents 42776fb + 4d00aa3 commit b672950

File tree

1,117 files changed

+2002
-2077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,117 files changed

+2002
-2077
lines changed

powershell/misc/typemodelgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def writeModels():
155155
with open(filename, "x") as file:
156156
file.write("extensions:\n")
157157
file.write(" - addsTo:\n")
158-
file.write(" pack: microsoft-sdl/powershell-all\n")
158+
file.write(" pack: microsoft/powershell-all\n")
159159
file.write(" extensible: typeModel\n")
160160
file.write(" data:\n")
161161
for summary in s:

powershell/ql/consistency-queries/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ groups:
55
- test
66
- consistency-queries
77
dependencies:
8-
microsoft-sdl/powershell-all: ${workspace}
8+
microsoft/powershell-all: ${workspace}
99
warnOnImplicitThis: true

powershell/ql/lib/qlpack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: microsoft-sdl/powershell-all
1+
name: microsoft/powershell-all
22
version: 0.0.1
33
groups:
44
- powershell
@@ -16,4 +16,4 @@ dependencies:
1616
dataExtensions:
1717
- semmle/code/powershell/frameworks/**/model.yml
1818
- semmle/code/powershell/frameworks/**/*.model.yml
19-
warnOnImplicitThis: true
19+
warnOnImplicitThis: true

powershell/ql/lib/semmle/code/powershell/ApiGraphs.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ module API {
511511
predicate toplevelCall(string name, Node node) {
512512
exists(DataFlow::CallNode call |
513513
call.asExpr().getExpr().getEnclosingScope() instanceof TopLevelScriptBlock and
514-
call.getName() = name and
514+
call.getLowerCaseName() = name and
515515
node = MkMethodAccessNode(call)
516516
)
517517
}
@@ -522,7 +522,7 @@ module API {
522522
// from receiver to method call node
523523
pred = getForwardEndNode(getALocalSourceStrict(call.getQualifier())) and
524524
succ = MkMethodAccessNode(call) and
525-
name = call.getName()
525+
name = call.getLowerCaseName()
526526
)
527527
}
528528

@@ -549,7 +549,7 @@ module API {
549549
_)
550550
|
551551
result = MkMethodAccessNode(call) and
552-
name = call.getName().toLowerCase()
552+
name = call.getLowerCaseName()
553553
)
554554
}
555555

@@ -586,7 +586,7 @@ module API {
586586
cached
587587
predicate methodEdge(Node pred, string name, Node succ) {
588588
exists(DataFlow::CallNode call |
589-
succ = MkMethodAccessNode(call) and name = call.getName().toLowerCase()
589+
succ = MkMethodAccessNode(call) and name = call.getLowerCaseName()
590590
|
591591
pred = getForwardEndNode(getALocalSourceStrict(call.getQualifier()))
592592
)

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ class CallExpr extends Expr, TCallExpr {
55
Expr getArgument(int i) { none() }
66

77
/** Gets the name that is used to select the callee. */
8-
string getName() { none() }
8+
string getLowerCaseName() { none() }
9+
10+
/** Holds if `name` is the name of this call. The name is case insensitive. */
11+
bindingset[name]
12+
pragma[inline_late]
13+
final predicate matchesName(string name) { this.getLowerCaseName() = name.toLowerCase() }
14+
15+
/** Gets a name that case-insensitively matches the name of this call. */
16+
bindingset[result]
17+
pragma[inline_late]
18+
final string getAName() { result.toLowerCase() = this.getLowerCaseName() }
919

1020
/** Gets the i'th positional argument to this call. */
1121
Expr getPositionalArgument(int i) { none() }
@@ -32,7 +42,7 @@ class CallExpr extends Expr, TCallExpr {
3242
exists(Pipeline p, int i | this = p.getComponent(i + 1) and result = p.getComponent(i))
3343
}
3444

35-
final override string toString() { result = "Call to " + this.getName() }
45+
final override string toString() { result = "Call to " + this.getLowerCaseName() }
3646

3747
predicate isStatic() { none() }
3848
}
@@ -44,7 +54,15 @@ class Argument extends Expr {
4454

4555
int getPosition() { this = call.getPositionalArgument(result) }
4656

47-
string getName() { this = call.getNamedArgument(result) }
57+
string getLowerCaseName() { this = call.getNamedArgument(result) }
58+
59+
bindingset[name]
60+
pragma[inline_late]
61+
final predicate matchesName(string name) { this.getLowerCaseName() = name.toLowerCase() }
62+
63+
bindingset[result]
64+
pragma[inline_late]
65+
final string getAName() { result.toLowerCase() = this.getLowerCaseName() }
4866

4967
CallExpr getCall() { result = call }
5068
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ newtype ChildIndex =
3737
RealVar(string name) { name = variableNameInScope(_, _) } or
3838
ProcessBlockPipelineVarReadAccess() or
3939
ProcessBlockPipelineByPropertyNameVarReadAccess(string name) {
40-
name = any(Raw::PipelineByPropertyNameParameter p).getName()
40+
name = any(Raw::PipelineByPropertyNameParameter p).getLowerCaseName()
4141
}
4242

4343
int synthPipelineParameterChildIndex(Raw::ScriptBlock sb) {

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

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

33
class CmdCall extends CallExpr, TCmd {
4-
final override string getName() { result = getRawAst(this).(Raw::Cmd).getCommandName() }
4+
final override string getLowerCaseName() { result = getRawAst(this).(Raw::Cmd).getLowerCaseName() }
55

66
final override Expr getArgument(int i) { synthChild(getRawAst(this), cmdArgument(i), result) }
77

@@ -85,7 +85,7 @@ class DotSourcingOperator extends CmdCall {
8585
}
8686

8787
class JoinPath extends CmdCall {
88-
JoinPath() { this.getName().toLowerCase() = "join-path" }
88+
JoinPath() { this.getLowerCaseName() = "join-path" }
8989

9090
Expr getPath() {
9191
result = this.getNamedArgument("path")
@@ -103,7 +103,7 @@ class JoinPath extends CmdCall {
103103
}
104104

105105
class SplitPath extends CmdCall {
106-
SplitPath() { this.getName().toLowerCase() = "split-path" }
106+
SplitPath() { this.getLowerCaseName() = "split-path" }
107107

108108
Expr getPath() {
109109
result = this.getNamedArgument("path")
@@ -131,7 +131,7 @@ class SplitPath extends CmdCall {
131131
}
132132

133133
class GetVariable extends CmdCall {
134-
GetVariable() { this.getName().toLowerCase() = "get-variable" }
134+
GetVariable() { this.getLowerCaseName() = "get-variable" }
135135

136136
Expr getVariable() { result = this.getPositionalArgument(0) }
137137

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

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

33
class InvokeMemberExpr extends CallExpr, TInvokeMemberExpr {
4-
final override string getName() { result = getRawAst(this).(Raw::InvokeMemberExpr).getName() }
4+
final override string getLowerCaseName() {
5+
result = getRawAst(this).(Raw::InvokeMemberExpr).getLowerCaseName()
6+
}
57

68
final override Ast getChild(ChildIndex i) {
79
result = super.getChild(i)
@@ -66,7 +68,7 @@ class ConstructorCall extends InvokeMemberExpr {
6668
TypeNameExpr typename;
6769

6870
ConstructorCall() {
69-
this.isStatic() and typename = this.getQualifier() and this.getName() = "new"
71+
this.isStatic() and typename = this.getQualifier() and this.getLowerCaseName() = "new"
7072
}
7173

7274
/** Gets the name of the type being constructed by this constructor call. */
@@ -81,5 +83,5 @@ class ConstructorCall extends InvokeMemberExpr {
8183
* ```
8284
*/
8385
class ToStringCall extends InvokeMemberExpr {
84-
ToStringCall() { this.getName().toLowerCase() = "toString" }
86+
ToStringCall() { this.getLowerCaseName() = "tostring" }
8587
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ProcessBlock extends NamedBlock {
6060

6161
PipelineByPropertyNameParameter getPipelineByPropertyNameParameter(string name) {
6262
result = scriptBlock.getAParameter() and
63-
result.getPropertyName() = name
63+
result.getLowerCaseName() = name
6464
}
6565

6666
PipelineByPropertyNameParameter getAPipelineByPropertyNameParameter() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NewObjectCreation extends AbstractObjectCreation, ConstructorCall {
2828
* ```
2929
*/
3030
class DotNetObjectCreation extends AbstractObjectCreation, CmdCall {
31-
DotNetObjectCreation() { this.getName() = "New-Object" }
31+
DotNetObjectCreation() { this.getLowerCaseName() = "new-object" }
3232

3333
final override string getConstructedTypeName() {
3434
result = this.getConstructedTypeExpr().(StringConstExpr).getValueString()

0 commit comments

Comments
 (0)