Skip to content

Commit 7432884

Browse files
committed
Merge branch 'main' into psscriptanalyzer-port
2 parents 43954b7 + 6a5d087 commit 7432884

File tree

24 files changed

+4052
-104
lines changed

24 files changed

+4052
-104
lines changed

.github/workflows/sync-main-tags.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Sync Main Tags
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
jobs:
11+
sync-main-tags:
12+
name: Sync Main Tags
13+
runs-on: ubuntu-latest
14+
if: github.repository == 'microsoft/codeql' && github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'auto/sync-main-pr'
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
- name: Push Tags
23+
run: |
24+
git fetch upstream --tags --force
25+
git push --force origin --tags
26+
env:
27+
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

powershell/ql/lib/upgrades/c5191f89a6e3e8cea428b5c7326a06e335738533/old.dbscheme renamed to powershell/downgrades/40bf985f18b7a9affb0c97d342fa2d43c629b905/old.dbscheme

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ containerparent(
4141
unique int child: @container ref
4242
);
4343

44-
is_in_psmodule_path(
45-
int file: @file ref
46-
);
47-
4844
/* Comments */
4945
comment_entity(
5046
unique int id: @comment_entity,
@@ -68,15 +64,15 @@ extractor_messages(
6864
);
6965

7066
parent(
71-
int child: @ast ref,
72-
int parent: @ast ref
67+
int parent: @ast ref,
68+
int child: @ast ref
7369
);
7470

7571
/* AST Nodes */
7672
// This is all the kinds of nodes that can inherit from Ast
7773
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.ast?view=powershellsdk-7.3.0
7874
@ast = @not_implemented | @attribute_base | @catch_clause | @command_element |
79-
@member | @named_block | @param_block | @parameter | @redirection | @script_block | @statement | @statement_block | @named_attribute_argument;
75+
@member | @named_block | @param_block | @parameter | @redirection | @script_block | @statement | @statement_block;
8076
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.attributebaseast?view=powershellsdk-7.2.0
8177
@attribute_base = @attribute | @type_constraint;
8278

@@ -86,7 +82,7 @@ parent(
8682
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.commandbaseast?view=powershellsdk-7.3.0
8783
@command_base = @command | @command_expression;
8884
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.chainableast?view=powershellsdk-7.3.0
89-
@chainable = @command_base | @pipeline | @pipeline_chain;
85+
@chainable = @pipeline | @pipeline_chain;
9086
//https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.pipelinebaseast?view=powershellsdk-7.3.0
9187
@pipeline_base = @chainable | @error_statement | @assignment_statement;
9288
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.statementast?view=powershellsdk-7.3.0
@@ -413,13 +409,13 @@ if_statement(
413409
if_statement_clause(
414410
int id: @if_statement ref,
415411
int index: int ref,
416-
int item1: @pipeline_base ref,
417-
int item2: @statement_block ref
412+
int item1: @ast ref,
413+
int item2: @ast ref
418414
)
419415

420416
if_statement_else(
421417
int id: @if_statement ref,
422-
int elseItem: @statement_block ref
418+
int elseItem: @ast ref
423419
)
424420

425421
if_statement_location(
@@ -471,7 +467,7 @@ statement_block_trap(
471467
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.subexpressionast?view=powershellsdk-7.3.0
472468
sub_expression(
473469
unique int id: @sub_expression,
474-
int subExpression: @statement_block ref
470+
int subExpression: @ast ref
475471
)
476472

477473
sub_expression_location(
@@ -631,7 +627,7 @@ exit_statement(
631627

632628
exit_statement_pipeline(
633629
int id: @exit_statement ref,
634-
int expression: @pipeline_base ref
630+
int expression: @ast ref
635631
)
636632

637633
exit_statement_location(
@@ -818,7 +814,7 @@ continue_statement_location(
818814

819815
statement_label(
820816
int id: @labelled_statement ref,
821-
int label: @expression ref
817+
int label: @ast ref
822818
)
823819

824820
// ReturnStatementAst
@@ -829,7 +825,7 @@ return_statement(
829825

830826
return_statement_pipeline(
831827
int id: @return_statement ref,
832-
int pipeline: @pipeline_base ref
828+
int pipeline: @ast ref
833829
)
834830

835831
return_statement_location(
@@ -841,12 +837,12 @@ return_statement_location(
841837
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.dowhilestatementast?view=powershellsdk-7.3.0
842838
do_while_statement(
843839
unique int id: @do_while_statement,
844-
int body: @statement_block ref
840+
int body: @ast ref
845841
)
846842

847843
do_while_statement_condition(
848844
int id: @do_while_statement ref,
849-
int condition: @pipeline_base ref
845+
int condition: @ast ref
850846
)
851847

852848
do_while_statement_location(
@@ -858,12 +854,12 @@ do_while_statement_location(
858854
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.dountilstatementast?view=powershellsdk-7.3.0
859855
do_until_statement(
860856
unique int id: @do_until_statement,
861-
int body: @statement_block ref
857+
int body: @ast ref
862858
)
863859

864860
do_until_statement_condition(
865861
int id: @do_until_statement ref,
866-
int condition: @pipeline_base ref
862+
int condition: @ast ref
867863
)
868864

869865
do_until_statement_location(
@@ -875,12 +871,12 @@ do_until_statement_location(
875871
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.whilestatementast?view=powershellsdk-7.3.0
876872
while_statement(
877873
unique int id: @while_statement,
878-
int body: @statement_block ref
874+
int body: @ast ref
879875
)
880876

881877
while_statement_condition(
882878
int id: @while_statement ref,
883-
int condition: @pipeline_base ref
879+
int condition: @ast ref
884880
)
885881

886882
while_statement_location(
@@ -892,9 +888,9 @@ while_statement_location(
892888
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.foreachstatementast?view=powershellsdk-7.3.0
893889
foreach_statement(
894890
unique int id: @foreach_statement,
895-
int variable: @variable_expression ref,
896-
int condition: @pipeline_base ref,
897-
int body: @statement_block ref,
891+
int variable: @ast ref,
892+
int condition: @ast ref,
893+
int body: @ast ref,
898894
int flags: int ref
899895
)
900896

@@ -907,7 +903,7 @@ foreach_statement_location(
907903
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.forstatementast?view=powershellsdk-7.3.0
908904
for_statement(
909905
unique int id: @for_statement,
910-
int body: @statement_block ref
906+
int body: @ast ref
911907
)
912908

913909
for_statement_location(
@@ -917,17 +913,17 @@ for_statement_location(
917913

918914
for_statement_condition(
919915
int id: @for_statement ref,
920-
int condition: @pipeline_base ref
916+
int condition: @ast ref
921917
)
922918

923919
for_statement_initializer(
924920
int id: @for_statement ref,
925-
int initializer: @pipeline_base ref
921+
int initializer: @ast ref
926922
)
927923

928924
for_statement_iterator(
929925
int id: @for_statement ref,
930-
int iterator: @pipeline_base ref
926+
int iterator: @ast ref
931927
)
932928

933929
// ExpandableStringExpressionAst
@@ -992,14 +988,14 @@ unary_expression_location(
992988
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.catchclauseast?view=powershellsdk-7.3.0
993989
catch_clause(
994990
unique int id: @catch_clause,
995-
int body: @statement_block ref,
991+
int body: @ast ref,
996992
boolean isCatchAll: boolean ref
997993
)
998994

999995
catch_clause_catch_type(
1000996
int id: @catch_clause ref,
1001997
int index: int ref,
1002-
int catch_type: @type_constraint ref
998+
int catch_type: @ast ref
1003999
)
10041000

10051001
catch_clause_location(
@@ -1028,7 +1024,7 @@ throw_statement_pipeline(
10281024
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.trystatementast?view=powershellsdk-7.3.0
10291025
try_statement(
10301026
unique int id: @try_statement,
1031-
int body: @statement_block ref
1027+
int body: @ast ref
10321028
)
10331029

10341030
try_statement_catch_clause(
@@ -1103,9 +1099,9 @@ token_location(
11031099
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.configurationdefinitionast?view=powershellsdk-7.3.0
11041100
configuration_definition(
11051101
unique int id: @configuration_definition,
1106-
int body: @script_block_expression ref,
1102+
int body: @ast ref,
11071103
int configurationType: int ref,
1108-
int name: @expression ref
1104+
int name: @ast ref
11091105
)
11101106

11111107
configuration_definition_location(
@@ -1117,7 +1113,7 @@ configuration_definition_location(
11171113
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.datastatementast?view=powershellsdk-7.3.0
11181114
data_statement(
11191115
unique int id: @data_statement,
1120-
int body: @statement_block ref
1116+
int body: @ast ref
11211117
)
11221118

11231119
data_statement_variable(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
description: Unknown changes
2+
compatibility: partial

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
private import AstImport
2+
private import codeql.util.Boolean
23

34
private newtype TConstantValue =
45
TConstInteger(int value) {
@@ -12,15 +13,7 @@ private newtype TConstantValue =
1213
)
1314
} or
1415
TConstString(string value) { exists(Raw::StringLiteral sl | sl.getValue() = value) } or
15-
TConstBoolean(boolean value) {
16-
exists(Raw::VarAccess va |
17-
value = true and
18-
va.getUserPath() = "true"
19-
or
20-
value = false and
21-
va.getUserPath() = "false"
22-
)
23-
} or
16+
TConstBoolean(Boolean b) or
2417
TNull()
2518

2619
/** A constant value. */
@@ -61,9 +54,7 @@ class ConstInteger extends ConstantValue, TConstInteger {
6154

6255
final override string serialize() { result = this.getValue() }
6356

64-
final override ConstExpr getAnExpr() {
65-
result.getValueString() = this.getValue()
66-
}
57+
final override ConstExpr getAnExpr() { result.getValueString() = this.getValue() }
6758
}
6859

6960
/** A constant floating point value. */

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,26 @@ class MemberExpr extends Expr, TMemberExpr {
2929

3030
/** Gets the name of the member being looked up, if any. */
3131
string getMemberName() {
32-
result = getRawAst(this).(Raw::MemberExpr).getMember().(Raw::StringConstExpr).getValue().getValue()
32+
result =
33+
getRawAst(this).(Raw::MemberExpr).getMember().(Raw::StringConstExpr).getValue().getValue()
3334
}
3435

3536
predicate isNullConditional() { getRawAst(this).(Raw::MemberExpr).isNullConditional() }
3637

3738
predicate isStatic() { getRawAst(this).(Raw::MemberExpr).isStatic() }
3839

39-
final override string toString() { result = this.getMemberName() }
40+
final override string toString() {
41+
result = this.getMemberName()
42+
or
43+
not exists(this.getMemberName()) and
44+
result = "..."
45+
}
4046

4147
predicate isExplicitWrite(Ast assignment) {
4248
explicitAssignment(getRawAst(this), getRawAst(assignment))
4349
}
4450

45-
predicate isImplicitWrite() {
46-
implicitAssignment(getRawAst(this))
47-
}
51+
predicate isImplicitWrite() { implicitAssignment(getRawAst(this)) }
4852
}
4953

5054
/** A `MemberExpr` that is being written to. */

0 commit comments

Comments
 (0)