Skip to content

Commit 0c4a3f4

Browse files
committed
Add lib files from the internal repo.
1 parent 9ba4ffd commit 0c4a3f4

Some content is hidden

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

45 files changed

+1533
-0
lines changed

powershell/ql/lib/powershell.qll

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// File Metadata
2+
import semmle.code.powershell.File
3+
import semmle.code.powershell.Location
4+
import semmle.code.powershell.SourceLocation
5+
// Base Classes
6+
import semmle.code.powershell.Ast
7+
import semmle.code.powershell.TokenKind
8+
import semmle.code.powershell.Statement
9+
import semmle.code.powershell.Expression
10+
import semmle.code.powershell.CommandBase
11+
import semmle.code.powershell.AttributeBase
12+
import semmle.code.powershell.PipelineBase
13+
import semmle.code.powershell.BaseConstantExpression
14+
import semmle.code.powershell.ConstantExpression
15+
import semmle.code.powershell.MemberExpressionBase
16+
17+
import semmle.code.powershell.Attribute
18+
import semmle.code.powershell.NamedAttributeArgument
19+
import semmle.code.powershell.VariableExpression
20+
import semmle.code.powershell.Parameter
21+
22+
import semmle.code.powershell.ModuleSpecification
23+
import semmle.code.powershell.ParamBlock
24+
import semmle.code.powershell.NamedBlock
25+
import semmle.code.powershell.ScriptBlock
26+
27+
import semmle.code.powershell.StringLiteral
28+
29+
// Inherited
30+
import semmle.code.powershell.AssignmentStatement
31+
import semmle.code.powershell.BinaryExpression
32+
import semmle.code.powershell.TernaryExpression
33+
import semmle.code.powershell.TrapStatement
34+
import semmle.code.powershell.StatementBlock
35+
import semmle.code.powershell.ArrayExpression
36+
import semmle.code.powershell.ArrayLiteral
37+
import semmle.code.powershell.CommandElement
38+
import semmle.code.powershell.Redirection
39+
import semmle.code.powershell.Command
40+
import semmle.code.powershell.CommandExpression
41+
import semmle.code.powershell.CommandParameter
42+
import semmle.code.powershell.ExpandableStringExpression
43+
import semmle.code.powershell.TypeExpression
44+
import semmle.code.powershell.VariableExpression
45+
import semmle.code.powershell.ParenExpression
46+
import semmle.code.powershell.Pipeline
47+
import semmle.code.powershell.StringConstantExpression
48+
import semmle.code.powershell.InvokeMemberExpression
49+
import semmle.code.powershell.CommentEntity

powershell/ql/lib/qlpack.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: microsoft-sdl/powershell-all
2+
version: 0.0.1
3+
groups:
4+
- powershell
5+
- microsoft-all
6+
dbscheme: semmlecode.powershell.dbscheme
7+
extractor: powershell
8+
library: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import powershell
2+
3+
class ArrayExpression extends @array_expression instanceof Expression
4+
{
5+
SourceLocation getLocation()
6+
{
7+
array_expression_location(this, result)
8+
}
9+
10+
StatementBlock getStatementBlock()
11+
{
12+
array_expression(this, result)
13+
}
14+
15+
string toString(){
16+
result = "ArrayExpression at: " + this.getLocation().toString()
17+
}
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import powershell
2+
3+
class ArrayLiteral extends @array_literal instanceof Expression
4+
{
5+
SourceLocation getLocation()
6+
{
7+
array_literal_location(this, result)
8+
}
9+
10+
Expression getElement(int index)
11+
{
12+
array_literal_element(this, index, result)
13+
}
14+
15+
Expression getAnElement()
16+
{
17+
array_literal_element(this, _, result)
18+
}
19+
20+
string toString(){
21+
result = "ArrayLiteral at: " + this.getLocation().toString()
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import powershell
2+
3+
class AssignmentStatement extends @assignment_statement instanceof Statement
4+
{
5+
SourceLocation getLocation()
6+
{
7+
assignment_statement_location(this, result)
8+
}
9+
10+
int getKind()
11+
{
12+
assignment_statement(this, result, _, _)
13+
}
14+
15+
Expression getLeftHandSide()
16+
{
17+
assignment_statement(this, _, result, _)
18+
}
19+
20+
Statement getRightHandSide()
21+
{
22+
assignment_statement(this, _, _, result)
23+
}
24+
25+
string toString(){
26+
result = "AssignmentStatement at: " + this.getLocation().toString()
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import powershell
2+
3+
class Ast extends @ast
4+
{
5+
string toString(){none()}
6+
7+
Ast getParent()
8+
{
9+
parent(result, this)
10+
}
11+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import powershell
2+
3+
class Attribute extends @attribute instanceof AttributeBase
4+
{
5+
string toString()
6+
{
7+
none()
8+
}
9+
10+
SourceLocation getLocation()
11+
{
12+
attribute_location(this, result)
13+
}
14+
15+
string getName()
16+
{
17+
attribute(this, result, _, _)
18+
}
19+
20+
int getNumNamedArguments()
21+
{
22+
attribute(this, _, result, _)
23+
}
24+
25+
int getNumPositionalArguments()
26+
{
27+
attribute(this, _, _, result)
28+
}
29+
30+
NamedAttributeArgument getNamedArgument(int i)
31+
{
32+
attribute_named_argument(this, i, result)
33+
}
34+
35+
NamedAttributeArgument getANamedArgument()
36+
{
37+
result = this.getNamedArgument(_)
38+
}
39+
40+
Expression getPositionalArgument(int i)
41+
{
42+
attribute_positional_argument(this, i, result)
43+
}
44+
45+
Expression getAPositionalArgument()
46+
{
47+
result = this.getPositionalArgument(_)
48+
}
49+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import powershell
2+
3+
class AttributeBase extends @attribute_base instanceof Ast
4+
{
5+
string toString(){none()}
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import powershell
2+
3+
class BaseConstantExpression extends @base_constant_expression instanceof Expression
4+
{
5+
string toString()
6+
{
7+
none()
8+
}
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import powershell
2+
3+
class BinaryExpression extends @binary_expression instanceof Expression
4+
{
5+
string toString() {none()}
6+
7+
SourceLocation getLocation()
8+
{
9+
binary_expression_location(this, result)
10+
}
11+
12+
int getKind()
13+
{
14+
binary_expression(this, result, _, _)
15+
}
16+
17+
Expression getLeftHandSide()
18+
{
19+
binary_expression(this, _, result, _)
20+
}
21+
22+
Expression getRightHandSide()
23+
{
24+
binary_expression(this, _, _, result)
25+
}
26+
}

0 commit comments

Comments
 (0)