mirror of
https://github.com/github/codeql.git
synced 2026-05-25 00:27:09 +02:00
Merge pull request #88 from microsoft/more-specific-dbscheme-column-types
PS: Small dbscheme updates
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Making column types more specific
|
||||
compatibility: full
|
||||
@@ -6,6 +6,7 @@ groups:
|
||||
dbscheme: semmlecode.powershell.dbscheme
|
||||
extractor: powershell
|
||||
library: true
|
||||
upgrades: upgrades
|
||||
dependencies:
|
||||
codeql/controlflow: ${workspace}
|
||||
warnOnImplicitThis: true
|
||||
@@ -3,7 +3,7 @@ import powershell
|
||||
class Ast extends @ast {
|
||||
string toString() { none() }
|
||||
|
||||
Ast getParent() { parent(this, result) } // TODO: Flip parent and child in relation in the extractor
|
||||
Ast getParent() { parent(this, result) }
|
||||
|
||||
Location getLocation() { none() }
|
||||
}
|
||||
|
||||
@@ -5,13 +5,15 @@ class CatchClause extends @catch_clause, Ast {
|
||||
|
||||
override string toString() { result = "catch {...}" }
|
||||
|
||||
StmtBlock getBody() { catch_clause(this, result, _) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
StmtBlock getBody() { catch_clause(this, result, _) }
|
||||
|
||||
TypeConstraint getCatchType(int i) { catch_clause_catch_type(this, i, result) } // TODO: Change @ast to @type_constraint in dbscheme
|
||||
TypeConstraint getCatchType(int i) { catch_clause_catch_type(this, i, result) }
|
||||
|
||||
int getNumberOfCatchTypes() { result = count(this.getACatchType()) }
|
||||
|
||||
TypeConstraint getACatchType() { result = this.getCatchType(_) }
|
||||
|
||||
predicate isCatchAll() { catch_clause(this, _, true) } // TODO: Should be equivalent to not exists(this.getACatchType())
|
||||
predicate isCatchAll() { not exists(this.getACatchType()) }
|
||||
|
||||
TryStmt getTryStmt() { result.getACatchClause() = this }
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ class Configuration extends @configuration_definition, Stmt {
|
||||
|
||||
override string toString() { result = "Configuration" }
|
||||
|
||||
Expr getName() { configuration_definition(this, _, _, result) } // TODO: Change @ast to @expression in dbscheme
|
||||
Expr getName() { configuration_definition(this, _, _, result) }
|
||||
|
||||
ScriptBlockExpr getBody() { configuration_definition(this, result, _, _) } // TODO: Change @ast to @script_block in dbscheme
|
||||
ScriptBlockExpr getBody() { configuration_definition(this, result, _, _) }
|
||||
|
||||
predicate isMeta() { configuration_definition(this, _, 1, _) }
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ class DataStmt extends @data_statement, Stmt {
|
||||
|
||||
Expr getACmdAllowed() { result = this.getCmdAllowed(_) }
|
||||
|
||||
StmtBlock getBody() { data_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
StmtBlock getBody() { data_statement(this, result) }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class DoUntilStmt extends @do_until_statement, LoopStmt {
|
||||
|
||||
override string toString() { result = "DoUntil" }
|
||||
|
||||
PipelineBase getCondition() { do_until_statement_condition(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getCondition() { do_until_statement_condition(this, result) }
|
||||
|
||||
final override StmtBlock getBody() { do_until_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
final override StmtBlock getBody() { do_until_statement(this, result) }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class DoWhileStmt extends @do_while_statement, LoopStmt {
|
||||
|
||||
override string toString() { result = "DoWhile" }
|
||||
|
||||
PipelineBase getCondition() { do_while_statement_condition(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getCondition() { do_while_statement_condition(this, result) }
|
||||
|
||||
final override StmtBlock getBody() { do_while_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
final override StmtBlock getBody() { do_while_statement(this, result) }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class ExitStmt extends @exit_statement, Stmt {
|
||||
override string toString() { if this.hasPipeline() then result = "exit ..." else result = "exit" }
|
||||
|
||||
/** ..., if any. */
|
||||
PipelineBase getPipeline() { exit_statement_pipeline(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getPipeline() { exit_statement_pipeline(this, result) }
|
||||
|
||||
predicate hasPipeline() { exists(this.getPipeline()) }
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ class ForEachStmt extends @foreach_statement, LoopStmt {
|
||||
|
||||
override string toString() { result = "forach(... in ...)" }
|
||||
|
||||
final override StmtBlock getBody() { foreach_statement(this, _, _, result, _) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
final override StmtBlock getBody() { foreach_statement(this, _, _, result, _) }
|
||||
|
||||
VarAccess getVariable() { foreach_statement(this, result, _, _, _) } // TODO: Change @ast to @variable_expression in dbscheme
|
||||
VarAccess getVariable() { foreach_statement(this, result, _, _, _) }
|
||||
|
||||
PipelineBase getIterableExpr() { foreach_statement(this, _, result, _, _) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getIterableExpr() { foreach_statement(this, _, result, _, _) }
|
||||
|
||||
predicate isParallel() { foreach_statement(this, _, _, _, 1) }
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ class ForStmt extends @for_statement, LoopStmt {
|
||||
|
||||
override string toString() { result = "for(...;...;...)" }
|
||||
|
||||
PipelineBase getInitializer() { for_statement_initializer(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getInitializer() { for_statement_initializer(this, result) }
|
||||
|
||||
PipelineBase getCondition() { for_statement_condition(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getCondition() { for_statement_condition(this, result) }
|
||||
|
||||
PipelineBase getIterator() { for_statement_iterator(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getIterator() { for_statement_iterator(this, result) }
|
||||
|
||||
final override StmtBlock getBody() { for_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
final override StmtBlock getBody() { for_statement(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import powershell
|
||||
|
||||
/** A `break` or `continue` statement. */
|
||||
class GotoStmt extends @labelled_statement, Stmt { // TODO: Rename @labelled_statement to @goto_statement
|
||||
class GotoStmt extends @labelled_statement, Stmt {
|
||||
|
||||
/** ..., if any. */
|
||||
Expr getLabel() { statement_label(this, result) } // TODO: Replace @ast with @expression
|
||||
Expr getLabel() { statement_label(this, result) }
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ class IfStmt extends @if_statement, Stmt {
|
||||
if this.hasElse() then result = "if (...) {...} else {...}" else result = "if (...) {...}"
|
||||
}
|
||||
|
||||
PipelineBase getCondition(int i) { if_statement_clause(this, i, result, _) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getCondition(int i) { if_statement_clause(this, i, result, _) }
|
||||
|
||||
PipelineBase getACondition() { result = this.getCondition(_) }
|
||||
|
||||
StmtBlock getThen(int i) { if_statement_clause(this, i, _, result) } // TODO: Change @ast to @statement_block in dbscheme
|
||||
StmtBlock getThen(int i) { if_statement_clause(this, i, _, result) }
|
||||
|
||||
/** ..., if any. */
|
||||
StmtBlock getElse() { if_statement_else(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
StmtBlock getElse() { if_statement_else(this, result) }
|
||||
|
||||
predicate hasElse() { exists(this.getElse()) }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class ReturnStmt extends @return_statement, Stmt {
|
||||
if this.hasPipeline() then result = "return ..." else result = "return"
|
||||
}
|
||||
|
||||
PipelineBase getPipeline() { return_statement_pipeline(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getPipeline() { return_statement_pipeline(this, result) }
|
||||
|
||||
predicate hasPipeline() { exists(this.getPipeline()) }
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ class TryStmt extends @try_statement, Stmt {
|
||||
/** ..., if any. */
|
||||
StmtBlock getFinally() { try_statement_finally(this, result) }
|
||||
|
||||
StmtBlock getBody() { try_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
StmtBlock getBody() { try_statement(this, result) }
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class WhileStmt extends @while_statement, LoopStmt {
|
||||
|
||||
override string toString() { result = "while(...) {...}" }
|
||||
|
||||
PipelineBase getCondition() { while_statement_condition(this, result) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
PipelineBase getCondition() { while_statement_condition(this, result) }
|
||||
|
||||
final override StmtBlock getBody() { while_statement(this, result) } // TODO: Change @ast to @stmt_block in dbscheme
|
||||
final override StmtBlock getBody() { while_statement(this, result) }
|
||||
}
|
||||
|
||||
@@ -64,15 +64,15 @@ extractor_messages(
|
||||
);
|
||||
|
||||
parent(
|
||||
int parent: @ast ref,
|
||||
int child: @ast ref
|
||||
int child: @ast ref,
|
||||
int parent: @ast ref
|
||||
);
|
||||
|
||||
/* AST Nodes */
|
||||
// This is all the kinds of nodes that can inherit from Ast
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.ast?view=powershellsdk-7.3.0
|
||||
@ast = @not_implemented | @attribute_base | @catch_clause | @command_element |
|
||||
@member | @named_block | @param_block | @parameter | @redirection | @script_block | @statement | @statement_block;
|
||||
@member | @named_block | @param_block | @parameter | @redirection | @script_block | @statement | @statement_block | @named_attribute_argument;
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.attributebaseast?view=powershellsdk-7.2.0
|
||||
@attribute_base = @attribute | @type_constraint;
|
||||
|
||||
@@ -409,13 +409,13 @@ if_statement(
|
||||
if_statement_clause(
|
||||
int id: @if_statement ref,
|
||||
int index: int ref,
|
||||
int item1: @ast ref,
|
||||
int item2: @ast ref
|
||||
int item1: @pipeline_base ref,
|
||||
int item2: @statement_block ref
|
||||
)
|
||||
|
||||
if_statement_else(
|
||||
int id: @if_statement ref,
|
||||
int elseItem: @ast ref
|
||||
int elseItem: @statement_block ref
|
||||
)
|
||||
|
||||
if_statement_location(
|
||||
@@ -467,7 +467,7 @@ statement_block_trap(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.subexpressionast?view=powershellsdk-7.3.0
|
||||
sub_expression(
|
||||
unique int id: @sub_expression,
|
||||
int subExpression: @ast ref
|
||||
int subExpression: @statement_block ref
|
||||
)
|
||||
|
||||
sub_expression_location(
|
||||
@@ -627,7 +627,7 @@ exit_statement(
|
||||
|
||||
exit_statement_pipeline(
|
||||
int id: @exit_statement ref,
|
||||
int expression: @ast ref
|
||||
int expression: @pipeline_base ref
|
||||
)
|
||||
|
||||
exit_statement_location(
|
||||
@@ -814,7 +814,7 @@ continue_statement_location(
|
||||
|
||||
statement_label(
|
||||
int id: @labelled_statement ref,
|
||||
int label: @ast ref
|
||||
int label: @expression ref
|
||||
)
|
||||
|
||||
// ReturnStatementAst
|
||||
@@ -825,7 +825,7 @@ return_statement(
|
||||
|
||||
return_statement_pipeline(
|
||||
int id: @return_statement ref,
|
||||
int pipeline: @ast ref
|
||||
int pipeline: @pipeline_base ref
|
||||
)
|
||||
|
||||
return_statement_location(
|
||||
@@ -837,12 +837,12 @@ return_statement_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.dowhilestatementast?view=powershellsdk-7.3.0
|
||||
do_while_statement(
|
||||
unique int id: @do_while_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
do_while_statement_condition(
|
||||
int id: @do_while_statement ref,
|
||||
int condition: @ast ref
|
||||
int condition: @pipeline_base ref
|
||||
)
|
||||
|
||||
do_while_statement_location(
|
||||
@@ -854,12 +854,12 @@ do_while_statement_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.dountilstatementast?view=powershellsdk-7.3.0
|
||||
do_until_statement(
|
||||
unique int id: @do_until_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
do_until_statement_condition(
|
||||
int id: @do_until_statement ref,
|
||||
int condition: @ast ref
|
||||
int condition: @pipeline_base ref
|
||||
)
|
||||
|
||||
do_until_statement_location(
|
||||
@@ -871,12 +871,12 @@ do_until_statement_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.whilestatementast?view=powershellsdk-7.3.0
|
||||
while_statement(
|
||||
unique int id: @while_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
while_statement_condition(
|
||||
int id: @while_statement ref,
|
||||
int condition: @ast ref
|
||||
int condition: @pipeline_base ref
|
||||
)
|
||||
|
||||
while_statement_location(
|
||||
@@ -888,9 +888,9 @@ while_statement_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.foreachstatementast?view=powershellsdk-7.3.0
|
||||
foreach_statement(
|
||||
unique int id: @foreach_statement,
|
||||
int variable: @ast ref,
|
||||
int condition: @ast ref,
|
||||
int body: @ast ref,
|
||||
int variable: @variable_expression ref,
|
||||
int condition: @pipeline_base ref,
|
||||
int body: @statement_block ref,
|
||||
int flags: int ref
|
||||
)
|
||||
|
||||
@@ -903,7 +903,7 @@ foreach_statement_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.forstatementast?view=powershellsdk-7.3.0
|
||||
for_statement(
|
||||
unique int id: @for_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
for_statement_location(
|
||||
@@ -913,17 +913,17 @@ for_statement_location(
|
||||
|
||||
for_statement_condition(
|
||||
int id: @for_statement ref,
|
||||
int condition: @ast ref
|
||||
int condition: @pipeline_base ref
|
||||
)
|
||||
|
||||
for_statement_initializer(
|
||||
int id: @for_statement ref,
|
||||
int initializer: @ast ref
|
||||
int initializer: @pipeline_base ref
|
||||
)
|
||||
|
||||
for_statement_iterator(
|
||||
int id: @for_statement ref,
|
||||
int iterator: @ast ref
|
||||
int iterator: @pipeline_base ref
|
||||
)
|
||||
|
||||
// ExpandableStringExpressionAst
|
||||
@@ -988,14 +988,14 @@ unary_expression_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.catchclauseast?view=powershellsdk-7.3.0
|
||||
catch_clause(
|
||||
unique int id: @catch_clause,
|
||||
int body: @ast ref,
|
||||
int body: @statement_block ref,
|
||||
boolean isCatchAll: boolean ref
|
||||
)
|
||||
|
||||
catch_clause_catch_type(
|
||||
int id: @catch_clause ref,
|
||||
int index: int ref,
|
||||
int catch_type: @ast ref
|
||||
int catch_type: @type_constraint ref
|
||||
)
|
||||
|
||||
catch_clause_location(
|
||||
@@ -1024,7 +1024,7 @@ throw_statement_pipeline(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.trystatementast?view=powershellsdk-7.3.0
|
||||
try_statement(
|
||||
unique int id: @try_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
try_statement_catch_clause(
|
||||
@@ -1099,9 +1099,9 @@ token_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.configurationdefinitionast?view=powershellsdk-7.3.0
|
||||
configuration_definition(
|
||||
unique int id: @configuration_definition,
|
||||
int body: @ast ref,
|
||||
int body: @script_block_expression ref,
|
||||
int configurationType: int ref,
|
||||
int name: @ast ref
|
||||
int name: @expression ref
|
||||
)
|
||||
|
||||
configuration_definition_location(
|
||||
@@ -1113,7 +1113,7 @@ configuration_definition_location(
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.datastatementast?view=powershellsdk-7.3.0
|
||||
data_statement(
|
||||
unique int id: @data_statement,
|
||||
int body: @ast ref
|
||||
int body: @statement_block ref
|
||||
)
|
||||
|
||||
data_statement_variable(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Making column types more specific
|
||||
compatibility: full
|
||||
Reference in New Issue
Block a user