diff --git a/ql/lib/codeql/bicep/AST.qll b/ql/lib/codeql/bicep/AST.qll index 346eac6..e656b2a 100644 --- a/ql/lib/codeql/bicep/AST.qll +++ b/ql/lib/codeql/bicep/AST.qll @@ -1,5 +1,6 @@ import ast.AstNodes import ast.Literals +import ast.Calls import ast.Expr import ast.Stmts import ast.Loops diff --git a/ql/lib/codeql/bicep/ast/Calls.qll b/ql/lib/codeql/bicep/ast/Calls.qll index 320897c..6ff336e 100644 --- a/ql/lib/codeql/bicep/ast/Calls.qll +++ b/ql/lib/codeql/bicep/ast/Calls.qll @@ -1,6 +1,13 @@ private import AstNodes private import Expr private import Idents +private import Misc +private import internal.Arguments +private import internal.CallExpression +private import internal.Parameter +private import internal.Parameters +private import internal.ParameterDeclaration +private import internal.UserDefinedFunction abstract class Callable extends Expr { /** @@ -17,4 +24,114 @@ abstract class Callable extends Expr { * Checks if the call expression has a specific name. */ predicate hasName(string name) { this.getName() = name } -} \ No newline at end of file +} + +/** + * A CallExpression expression in the AST. + */ +class CallExpression extends Callable instanceof CallExpressionImpl { + override Idents getIdentifier() { + result = CallExpressionImpl.super.getIdentifier() + } + + Expr getArgument(int index) { + result = this.getDeclaredArguments().getArgument(index) + } + + Expr getArguments() { + result = this.getDeclaredArguments().getArguments() + } + + Arguments getDeclaredArguments() { + result = CallExpressionImpl.super.getArguments() + } +} + + +/** + * A Arguments unknown AST node. + */ +class Arguments extends AstNode instanceof ArgumentsImpl { + + Expr getArgument(int index) { + result = ArgumentsImpl.super.getArgument(index) + } + + Expr getArguments() { + result = ArgumentsImpl.super.getArguments() + } +} + +/** + * A Parameter unknown AST node. + */ +class Parameter extends AstNode instanceof ParameterImpl { + + Idents getName() { + result = ParameterImpl.super.getName() + } + + Type getType() { + result = ParameterImpl.super.getType() + } +} + +/** + * A Parameters unknown AST node. + */ +class Parameters extends AstNode instanceof ParametersImpl { + Parameter getParameter(int index) { + result = ParametersImpl.super.getParameter(index) + } +} + + +/** + * A ParameterDeclaration unknown AST node. + */ +class ParameterDeclaration extends AstNode instanceof ParameterDeclarationImpl { + Identifier getName() { + result = ParameterDeclarationImpl.super.getName() + } + + Type getType() { + result = ParameterDeclarationImpl.super.getType() + } + + Expr getDefaultValue() { + result = ParameterDeclarationImpl.super.getDefaultValue() + } +} + +/** + * A UserDefinedFunction unknown AST node. + */ +class UserDefinedFunction extends AstNode instanceof UserDefinedFunctionImpl { + Identifier getIdentifier() { + result = UserDefinedFunctionImpl.super.getName() + } + + string getName() { + result = this.getIdentifier().getName() + } + + Type getReturnType() { + result = UserDefinedFunctionImpl.super.getReturnType() + } + + Parameters getDeclaredParameters() { + result = UserDefinedFunctionImpl.super.getParameters() + } + + Parameter getParameters() { + result = this.getDeclaredParameters().getParameter(_) + } + + Parameter getParameter(int index) { + result = this.getDeclaredParameters().getParameter(index) + } + + Expr getBody() { + result = UserDefinedFunctionImpl.super.getBody() + } +} diff --git a/ql/lib/codeql/bicep/ast/Expr.qll b/ql/lib/codeql/bicep/ast/Expr.qll index d3a6567..d76d8d5 100644 --- a/ql/lib/codeql/bicep/ast/Expr.qll +++ b/ql/lib/codeql/bicep/ast/Expr.qll @@ -1,10 +1,13 @@ +/** + * Bicep AST expressions. + */ + private import AstNodes private import internal.AstNodes private import internal.TreeSitter private import internal.Expr private import internal.AssignmentExpression private import internal.BinaryExpression -private import internal.CallExpression private import internal.Expression private import internal.Interpolation private import internal.LambdaExpression @@ -16,7 +19,6 @@ private import internal.ResourceExpression private import internal.SubscriptExpression private import internal.TernaryExpression private import internal.UnaryExpression - private import Idents private import Resources @@ -35,11 +37,6 @@ final class AssignmentExpression extends Expr instanceof AssignmentExpressionImp */ final class BinaryExpression extends Expr instanceof BinaryExpressionImpl { } -/** - * A CallExpression expression in the AST. - */ -final class CallExpression extends Expr instanceof CallExpressionImpl { } - /** * A Expression expression in the AST. */ @@ -59,16 +56,22 @@ final class LambdaExpression extends Expr instanceof LambdaExpressionImpl { } * A MemberExpression expression in the AST. */ class MemberExpression extends Expr instanceof MemberExpressionImpl { - - /** - * The namespace of the member expression. - */ - Idents getNamespace() { result = MemberExpressionImpl.super.getObject() } - - /** - * The member of the member expression. - */ - Idents getName() { result = MemberExpressionImpl.super.getProperty() } + /** + * The namespace of the member expression. + */ + Idents getNamespace() { result = MemberExpressionImpl.super.getObject() } + + /** + * The member of the member expression. + */ + Idents getName() { result = MemberExpressionImpl.super.getProperty() } + + /** + * Gets the full name of the member expression, which includes the namespace and the member name. + */ + string getFullName() { + result = this.getNamespace().getName() + "." + this.getName().getName() + } } /** diff --git a/ql/lib/codeql/bicep/ast/Misc.qll b/ql/lib/codeql/bicep/ast/Misc.qll index a2235ae..5b8dfb6 100644 --- a/ql/lib/codeql/bicep/ast/Misc.qll +++ b/ql/lib/codeql/bicep/ast/Misc.qll @@ -1,5 +1,5 @@ private import AstNodes -private import internal.Arguments + private import internal.Array private import internal.ArrayType private import internal.Boolean @@ -12,7 +12,6 @@ private import internal.EscapeSequence private import internal.ForLoopParameters private import internal.Identifier private import internal.ImportFunctionality -private import internal.Infrastructure private import internal.LoopEnumerator private import internal.LoopVariable private import internal.MetadataDeclaration @@ -20,10 +19,7 @@ private import internal.ModuleDeclaration private import internal.NegatedType private import internal.ObjectProperty private import internal.OutputDeclaration -private import internal.Parameter -private import internal.ParameterDeclaration private import internal.ParameterizedType -private import internal.Parameters private import internal.ParenthesizedType private import internal.PrimitiveType private import internal.PropertyIdentifier @@ -33,14 +29,8 @@ private import internal.Type private import internal.TypeArguments private import internal.TypeDeclaration private import internal.UnionType -private import internal.UserDefinedFunction private import internal.VariableDeclaration -/** - * A Arguments unknown AST node. - */ -class Arguments extends AstNode instanceof ArgumentsImpl { } - /** * A ArrayType unknown AST node. */ @@ -87,11 +77,6 @@ class ForLoopParameters extends AstNode instanceof ForLoopParametersImpl { } */ class ImportFunctionality extends AstNode instanceof ImportFunctionalityImpl { } -/** - * A Infrastructure unknown AST node. - */ -class Infrastructure extends AstNode instanceof InfrastructureImpl { } - /** * A LoopEnumerator unknown AST node. */ @@ -122,25 +107,11 @@ class NegatedType extends AstNode instanceof NegatedTypeImpl { } */ class OutputDeclaration extends AstNode instanceof OutputDeclarationImpl { } -/** - * A Parameter unknown AST node. - */ -class Parameter extends AstNode instanceof ParameterImpl { } - -/** - * A ParameterDeclaration unknown AST node. - */ -class ParameterDeclaration extends AstNode instanceof ParameterDeclarationImpl { } - /** * A ParameterizedType unknown AST node. */ class ParameterizedType extends AstNode instanceof ParameterizedTypeImpl { } -/** - * A Parameters unknown AST node. - */ -class Parameters extends AstNode instanceof ParametersImpl { } /** * A ParenthesizedType unknown AST node. @@ -165,7 +136,14 @@ class TestBlock extends AstNode instanceof TestBlockImpl { } /** * A Type unknown AST node. */ -class Type extends AstNode instanceof TypeImpl { } +class Type extends AstNode instanceof TypeImpl { + /** + * Returns the type of this AST node. + */ + string getType() { + result = TypeImpl.super.getType() + } +} /** * A TypeArguments unknown AST node. @@ -182,10 +160,6 @@ class TypeDeclaration extends AstNode instanceof TypeDeclarationImpl { } */ class UnionType extends AstNode instanceof UnionTypeImpl { } -/** - * A UserDefinedFunction unknown AST node. - */ -class UserDefinedFunction extends AstNode instanceof UserDefinedFunctionImpl { } /** * A VariableDeclaration unknown AST node. diff --git a/ql/lib/codeql/bicep/ast/Stmts.qll b/ql/lib/codeql/bicep/ast/Stmts.qll index 20fe815..68be165 100644 --- a/ql/lib/codeql/bicep/ast/Stmts.qll +++ b/ql/lib/codeql/bicep/ast/Stmts.qll @@ -1,6 +1,7 @@ /** * Statement nodes in the AST. */ + private import AstNodes private import internal.AstNodes private import internal.TreeSitter @@ -10,6 +11,7 @@ private import internal.ForStatement private import internal.IfStatement private import internal.ImportStatement private import internal.ImportWithStatement +private import internal.Infrastructure private import internal.Statement private import internal.UsingStatement // CFG @@ -22,37 +24,49 @@ private import codeql.bicep.controlflow.internal.ControlFlowGraphImpl as CfgImpl class Stmts extends AstNode instanceof StmtsImpl { /** Gets a control-flow node for this statement, if any. */ CfgImpl::AstCfgNode getAControlFlowNode() { result.getAstNode() = this } - + /** Gets a control-flow entry node for this statement, if any */ AstNode getAControlFlowEntryNode() { result = CfgImpl::getAControlFlowEntryNode(this) } } - - /** * A AssertStatement statement */ final class AssertStatementStmt extends Stmts instanceof AssertStatementImpl { } + /** * A ForStatement statement */ final class ForStatementStmt extends Stmts instanceof ForStatementImpl { } + /** * A IfStatement statement */ final class IfStatementStmt extends Stmts instanceof IfStatementImpl { } + /** * A ImportStatement statement */ final class ImportStatementStmt extends Stmts instanceof ImportStatementImpl { } + +/** + * A Infrastructure unknown AST node. + */ +class Infrastructure extends AstNode instanceof InfrastructureImpl { + /** Gets the first statement in the infrastructure. */ + Stmts getStatement(int index) { result = InfrastructureImpl.super.getStatement(index) } +} + /** * A ImportWithStatement statement */ final class ImportWithStatementStmt extends Stmts instanceof ImportWithStatementImpl { } + /** * A Statement statement */ final class StatementStmt extends Stmts instanceof StatementImpl { } + /** * A UsingStatement statement */ diff --git a/ql/lib/codeql/bicep/ast/internal/Arguments.qll b/ql/lib/codeql/bicep/ast/internal/Arguments.qll index a1c39ff..0e28877 100644 --- a/ql/lib/codeql/bicep/ast/internal/Arguments.qll +++ b/ql/lib/codeql/bicep/ast/internal/Arguments.qll @@ -6,6 +6,7 @@ private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Expr /** * A Arguments AST Node. @@ -19,6 +20,11 @@ class ArgumentsImpl extends TArguments, AstNode { override string toString() { result = ast.toString() } + ExprImpl getArgument(int index ) { + toTreeSitter(result) = ast.getChild(index) + } - + ExprImpl getArguments() { + toTreeSitter(result) = ast.getChild(_) + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/AstNodes.qll b/ql/lib/codeql/bicep/ast/internal/AstNodes.qll index e8c5d0a..464d2c3 100644 --- a/ql/lib/codeql/bicep/ast/internal/AstNodes.qll +++ b/ql/lib/codeql/bicep/ast/internal/AstNodes.qll @@ -87,8 +87,8 @@ class TIdents = TIdentifier or TPropertyIdentifier; * A statement in a Bicep program */ class TStmts = - TAssertStatement or TForStatement or TIfStatement or TImportStatement or TImportWithStatement or - TStatement or TUsingStatement; + TInfrastructure or TAssertStatement or TForStatement or TIfStatement or TImportStatement or + TImportWithStatement or TStatement or TUsingStatement; /** * A expersion value in a Bicep program diff --git a/ql/lib/codeql/bicep/ast/internal/CallExpression.qll b/ql/lib/codeql/bicep/ast/internal/CallExpression.qll index f99096c..c1f6175 100644 --- a/ql/lib/codeql/bicep/ast/internal/CallExpression.qll +++ b/ql/lib/codeql/bicep/ast/internal/CallExpression.qll @@ -7,7 +7,10 @@ private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes private import Expr - +private import Expression +private import Idents +private import Arguments +private import NullableReturnType /** * A CallExpression AST Node. @@ -21,6 +24,15 @@ class CallExpressionImpl extends TCallExpression, ExprImpl { override string toString() { result = ast.toString() } + IdentsImpl getIdentifier() { + toTreeSitter(result) = ast.getFunction() + } + ArgumentsImpl getArguments() { + toTreeSitter(result) = ast.getArguments() + } + NullableReturnTypeImpl getReturnType() { + toTreeSitter(result) = ast.getChild() + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/Infrastructure.qll b/ql/lib/codeql/bicep/ast/internal/Infrastructure.qll index d9177aa..12f4373 100644 --- a/ql/lib/codeql/bicep/ast/internal/Infrastructure.qll +++ b/ql/lib/codeql/bicep/ast/internal/Infrastructure.qll @@ -6,6 +6,8 @@ private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Stmts + /** * A Infrastructure AST Node. @@ -19,6 +21,7 @@ class InfrastructureImpl extends TInfrastructure, AstNode { override string toString() { result = ast.toString() } - - + StmtsImpl getStatement(int index) { + toTreeSitter(result) = ast.getChild(index) + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/Parameter.qll b/ql/lib/codeql/bicep/ast/internal/Parameter.qll index 5754a8a..7acfedc 100644 --- a/ql/lib/codeql/bicep/ast/internal/Parameter.qll +++ b/ql/lib/codeql/bicep/ast/internal/Parameter.qll @@ -6,6 +6,9 @@ private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Idents +private import Expr +private import Type /** * A Parameter AST Node. @@ -19,6 +22,11 @@ class ParameterImpl extends TParameter, AstNode { override string toString() { result = ast.toString() } + IdentsImpl getName() { + toTreeSitter(result) = ast.getChild(0) + } - + TypeImpl getType() { + toTreeSitter(result) = ast.getChild(1) + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/ParameterDeclaration.qll b/ql/lib/codeql/bicep/ast/internal/ParameterDeclaration.qll index d6d0525..a9f2226 100644 --- a/ql/lib/codeql/bicep/ast/internal/ParameterDeclaration.qll +++ b/ql/lib/codeql/bicep/ast/internal/ParameterDeclaration.qll @@ -3,9 +3,13 @@ * * WARNING: this file is generated, do not edit manually */ + private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Identifier +private import Type +private import Expr /** * A ParameterDeclaration AST Node. @@ -19,6 +23,9 @@ class ParameterDeclarationImpl extends TParameterDeclaration, AstNode { override string toString() { result = ast.toString() } + IdentifierImpl getName() { toTreeSitter(result) = ast.getChild(0) } + TypeImpl getType() { toTreeSitter(result) = ast.getChild(1) } -} \ No newline at end of file + ExprImpl getDefaultValue() { toTreeSitter(result) = ast.getChild(2) } +} diff --git a/ql/lib/codeql/bicep/ast/internal/Parameters.qll b/ql/lib/codeql/bicep/ast/internal/Parameters.qll index a870612..7f26bac 100644 --- a/ql/lib/codeql/bicep/ast/internal/Parameters.qll +++ b/ql/lib/codeql/bicep/ast/internal/Parameters.qll @@ -6,6 +6,7 @@ private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Parameter /** * A Parameters AST Node. @@ -19,6 +20,8 @@ class ParametersImpl extends TParameters, AstNode { override string toString() { result = ast.toString() } - + ParameterImpl getParameter(int index) { + toTreeSitter(result) = ast.getChild(index) + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/Type.qll b/ql/lib/codeql/bicep/ast/internal/Type.qll index d1906f8..95de8a0 100644 --- a/ql/lib/codeql/bicep/ast/internal/Type.qll +++ b/ql/lib/codeql/bicep/ast/internal/Type.qll @@ -19,6 +19,7 @@ class TypeImpl extends TType, AstNode { override string toString() { result = ast.toString() } - - + string getType() { + result = ast.getChild().toString() + } } \ No newline at end of file diff --git a/ql/lib/codeql/bicep/ast/internal/UserDefinedFunction.qll b/ql/lib/codeql/bicep/ast/internal/UserDefinedFunction.qll index 0f3d029..0705255 100644 --- a/ql/lib/codeql/bicep/ast/internal/UserDefinedFunction.qll +++ b/ql/lib/codeql/bicep/ast/internal/UserDefinedFunction.qll @@ -3,9 +3,15 @@ * * WARNING: this file is generated, do not edit manually */ + private import AstNodes private import TreeSitter private import codeql.bicep.ast.AstNodes +private import Identifier +private import Stmts +private import Type +private import Parameter +private import Parameters /** * A UserDefinedFunction AST Node. @@ -19,6 +25,11 @@ class UserDefinedFunctionImpl extends TUserDefinedFunction, AstNode { override string toString() { result = ast.toString() } + IdentifierImpl getName() { toTreeSitter(result) = ast.getName() } + + ParametersImpl getParameters() { toTreeSitter(result) = ast.getChild(0) } + TypeImpl getReturnType() { toTreeSitter(result) = ast.getReturns() } -} \ No newline at end of file + StmtsImpl getBody() { toTreeSitter(result) = ast.getChild(1) } +} diff --git a/ql/test/library-tests/ast/AST.expected b/ql/test/library-tests/ast/AST.expected index 3b75afd..775a7d7 100644 --- a/ql/test/library-tests/ast/AST.expected +++ b/ql/test/library-tests/ast/AST.expected @@ -1,3 +1,409 @@ +| data.bicep:1:1:1:10 | Comment | +| data.bicep:1:1:62:4 | Infrastructure | +| data.bicep:2:1:6:1 | VariableDeclaration | +| data.bicep:2:1:6:1 | VariableDeclaration | +| data.bicep:2:1:6:1 | VariableDeclaration | +| data.bicep:2:5:2:18 | multiLineArray | +| data.bicep:2:5:2:18 | multiLineArray | +| data.bicep:2:5:2:18 | multiLineArray | +| data.bicep:2:22:6:1 | Array | +| data.bicep:2:22:6:1 | Array | +| data.bicep:2:22:6:1 | Array | +| data.bicep:3:3:3:7 | String | +| data.bicep:3:3:3:7 | String | +| data.bicep:3:3:3:7 | String | +| data.bicep:3:4:3:6 | abc | +| data.bicep:4:3:4:7 | String | +| data.bicep:4:3:4:7 | String | +| data.bicep:4:3:4:7 | String | +| data.bicep:4:4:4:6 | def | +| data.bicep:5:3:5:7 | String | +| data.bicep:5:3:5:7 | String | +| data.bicep:5:3:5:7 | String | +| data.bicep:5:4:5:6 | ghi | +| data.bicep:8:1:8:43 | VariableDeclaration | +| data.bicep:8:1:8:43 | VariableDeclaration | +| data.bicep:8:1:8:43 | VariableDeclaration | +| data.bicep:8:5:8:19 | singleLineArray | +| data.bicep:8:5:8:19 | singleLineArray | +| data.bicep:8:5:8:19 | singleLineArray | +| data.bicep:8:23:8:43 | Array | +| data.bicep:8:23:8:43 | Array | +| data.bicep:8:23:8:43 | Array | +| data.bicep:8:24:8:28 | String | +| data.bicep:8:24:8:28 | String | +| data.bicep:8:24:8:28 | String | +| data.bicep:8:25:8:27 | abc | +| data.bicep:8:31:8:35 | String | +| data.bicep:8:31:8:35 | String | +| data.bicep:8:31:8:35 | String | +| data.bicep:8:32:8:34 | def | +| data.bicep:8:38:8:42 | String | +| data.bicep:8:38:8:42 | String | +| data.bicep:8:38:8:42 | String | +| data.bicep:8:39:8:41 | ghi | +| data.bicep:10:1:11:10 | VariableDeclaration | +| data.bicep:10:1:11:10 | VariableDeclaration | +| data.bicep:10:1:11:10 | VariableDeclaration | +| data.bicep:10:5:10:14 | mixedArray | +| data.bicep:10:5:10:14 | mixedArray | +| data.bicep:10:5:10:14 | mixedArray | +| data.bicep:10:18:11:10 | Array | +| data.bicep:10:18:11:10 | Array | +| data.bicep:10:18:11:10 | Array | +| data.bicep:10:19:10:23 | String | +| data.bicep:10:19:10:23 | String | +| data.bicep:10:19:10:23 | String | +| data.bicep:10:20:10:22 | abc | +| data.bicep:10:26:10:30 | String | +| data.bicep:10:26:10:30 | String | +| data.bicep:10:26:10:30 | String | +| data.bicep:10:27:10:29 | def | +| data.bicep:11:5:11:9 | String | +| data.bicep:11:5:11:9 | String | +| data.bicep:11:5:11:9 | String | +| data.bicep:11:6:11:8 | ghi | +| data.bicep:13:1:13:28 | VariableDeclaration | +| data.bicep:13:1:13:28 | VariableDeclaration | +| data.bicep:13:1:13:28 | VariableDeclaration | +| data.bicep:13:5:13:16 | exampleArray | +| data.bicep:13:5:13:16 | exampleArray | +| data.bicep:13:5:13:16 | exampleArray | +| data.bicep:13:20:13:28 | Array | +| data.bicep:13:20:13:28 | Array | +| data.bicep:13:20:13:28 | Array | +| data.bicep:13:21:13:21 | 1 | +| data.bicep:13:21:13:21 | 1 | +| data.bicep:13:21:13:21 | 1 | +| data.bicep:13:24:13:24 | 2 | +| data.bicep:13:24:13:24 | 2 | +| data.bicep:13:24:13:24 | 2 | +| data.bicep:13:27:13:27 | 3 | +| data.bicep:13:27:13:27 | 3 | +| data.bicep:13:27:13:27 | 3 | +| data.bicep:14:1:14:41 | OutputDeclaration | +| data.bicep:14:1:14:41 | OutputDeclaration | +| data.bicep:14:1:14:41 | OutputDeclaration | +| data.bicep:14:8:14:19 | firstElement | +| data.bicep:14:8:14:19 | firstElement | +| data.bicep:14:8:14:19 | firstElement | +| data.bicep:14:21:14:23 | Type | +| data.bicep:14:21:14:23 | int | +| data.bicep:14:27:14:38 | exampleArray | +| data.bicep:14:27:14:38 | exampleArray | +| data.bicep:14:27:14:38 | exampleArray | +| data.bicep:14:27:14:41 | SubscriptExpression | +| data.bicep:14:27:14:41 | SubscriptExpression | +| data.bicep:14:27:14:41 | SubscriptExpression | +| data.bicep:14:40:14:40 | 0 | +| data.bicep:14:40:14:40 | 0 | +| data.bicep:14:40:14:40 | 0 | +| data.bicep:14:43:14:46 | Comment | +| data.bicep:15:1:15:41 | OutputDeclaration | +| data.bicep:15:1:15:41 | OutputDeclaration | +| data.bicep:15:1:15:41 | OutputDeclaration | +| data.bicep:15:8:15:19 | thirdElement | +| data.bicep:15:8:15:19 | thirdElement | +| data.bicep:15:8:15:19 | thirdElement | +| data.bicep:15:21:15:23 | Type | +| data.bicep:15:21:15:23 | int | +| data.bicep:15:27:15:38 | exampleArray | +| data.bicep:15:27:15:38 | exampleArray | +| data.bicep:15:27:15:38 | exampleArray | +| data.bicep:15:27:15:41 | SubscriptExpression | +| data.bicep:15:27:15:41 | SubscriptExpression | +| data.bicep:15:27:15:41 | SubscriptExpression | +| data.bicep:15:40:15:40 | 2 | +| data.bicep:15:40:15:40 | 2 | +| data.bicep:15:40:15:40 | 2 | +| data.bicep:15:43:15:46 | Comment | +| data.bicep:17:1:17:13 | VariableDeclaration | +| data.bicep:17:1:17:13 | VariableDeclaration | +| data.bicep:17:1:17:13 | VariableDeclaration | +| data.bicep:17:5:17:9 | index | +| data.bicep:17:5:17:9 | index | +| data.bicep:17:5:17:9 | index | +| data.bicep:17:13:17:13 | 1 | +| data.bicep:17:13:17:13 | 1 | +| data.bicep:17:13:17:13 | 1 | +| data.bicep:18:1:18:46 | OutputDeclaration | +| data.bicep:18:1:18:46 | OutputDeclaration | +| data.bicep:18:1:18:46 | OutputDeclaration | +| data.bicep:18:8:18:20 | secondElement | +| data.bicep:18:8:18:20 | secondElement | +| data.bicep:18:8:18:20 | secondElement | +| data.bicep:18:22:18:24 | Type | +| data.bicep:18:22:18:24 | int | +| data.bicep:18:28:18:39 | exampleArray | +| data.bicep:18:28:18:39 | exampleArray | +| data.bicep:18:28:18:39 | exampleArray | +| data.bicep:18:28:18:46 | SubscriptExpression | +| data.bicep:18:28:18:46 | SubscriptExpression | +| data.bicep:18:28:18:46 | SubscriptExpression | +| data.bicep:18:41:18:45 | index | +| data.bicep:18:41:18:45 | index | +| data.bicep:18:41:18:45 | index | +| data.bicep:18:48:18:51 | Comment | +| data.bicep:20:1:20:11 | Comment | +| data.bicep:21:1:21:29 | ParameterDeclaration | +| data.bicep:21:1:21:29 | ParameterDeclaration | +| data.bicep:21:1:21:29 | ParameterDeclaration | +| data.bicep:21:7:21:17 | exampleBool | +| data.bicep:21:7:21:17 | exampleBool | +| data.bicep:21:7:21:17 | exampleBool | +| data.bicep:21:19:21:22 | Type | +| data.bicep:21:19:21:22 | bool | +| data.bicep:21:26:21:29 | true | +| data.bicep:21:26:21:29 | true | +| data.bicep:21:26:21:29 | true | +| data.bicep:23:1:23:11 | Comment | +| data.bicep:24:1:24:24 | ParameterDeclaration | +| data.bicep:24:1:24:24 | ParameterDeclaration | +| data.bicep:24:1:24:24 | ParameterDeclaration | +| data.bicep:24:7:24:16 | exampleInt | +| data.bicep:24:7:24:16 | exampleInt | +| data.bicep:24:7:24:16 | exampleInt | +| data.bicep:24:18:24:20 | Type | +| data.bicep:24:18:24:20 | int | +| data.bicep:24:24:24:24 | 1 | +| data.bicep:24:24:24:24 | 1 | +| data.bicep:24:24:24:24 | 1 | +| data.bicep:26:1:26:10 | Comment | +| data.bicep:27:1:27:92 | ParameterDeclaration | +| data.bicep:27:1:27:92 | ParameterDeclaration | +| data.bicep:27:1:27:92 | ParameterDeclaration | +| data.bicep:27:7:27:22 | singleLineObject | +| data.bicep:27:7:27:22 | singleLineObject | +| data.bicep:27:7:27:22 | singleLineObject | +| data.bicep:27:24:27:29 | Type | +| data.bicep:27:24:27:29 | object | +| data.bicep:27:33:27:92 | Object | +| data.bicep:27:33:27:92 | Object | +| data.bicep:27:33:27:92 | Object | +| data.bicep:27:34:27:37 | name | +| data.bicep:27:34:27:37 | name | +| data.bicep:27:34:27:37 | name | +| data.bicep:27:34:27:50 | ObjectProperty | +| data.bicep:27:40:27:50 | String | +| data.bicep:27:40:27:50 | String | +| data.bicep:27:40:27:50 | String | +| data.bicep:27:41:27:49 | test name | +| data.bicep:27:53:27:54 | id | +| data.bicep:27:53:27:54 | id | +| data.bicep:27:53:27:54 | id | +| data.bicep:27:53:27:65 | ObjectProperty | +| data.bicep:27:57:27:65 | String | +| data.bicep:27:57:27:65 | String | +| data.bicep:27:57:27:65 | String | +| data.bicep:27:58:27:64 | 123-abc | +| data.bicep:27:68:27:76 | isCurrent | +| data.bicep:27:68:27:76 | isCurrent | +| data.bicep:27:68:27:76 | isCurrent | +| data.bicep:27:68:27:82 | ObjectProperty | +| data.bicep:27:79:27:82 | true | +| data.bicep:27:79:27:82 | true | +| data.bicep:27:79:27:82 | true | +| data.bicep:27:85:27:88 | tier | +| data.bicep:27:85:27:88 | tier | +| data.bicep:27:85:27:88 | tier | +| data.bicep:27:85:27:91 | ObjectProperty | +| data.bicep:27:91:27:91 | 1 | +| data.bicep:27:91:27:91 | 1 | +| data.bicep:27:91:27:91 | 1 | +| data.bicep:29:1:34:1 | ParameterDeclaration | +| data.bicep:29:1:34:1 | ParameterDeclaration | +| data.bicep:29:1:34:1 | ParameterDeclaration | +| data.bicep:29:7:29:21 | multiLineObject | +| data.bicep:29:7:29:21 | multiLineObject | +| data.bicep:29:7:29:21 | multiLineObject | +| data.bicep:29:23:29:28 | Type | +| data.bicep:29:23:29:28 | object | +| data.bicep:29:32:34:1 | Object | +| data.bicep:29:32:34:1 | Object | +| data.bicep:29:32:34:1 | Object | +| data.bicep:30:3:30:6 | name | +| data.bicep:30:3:30:6 | name | +| data.bicep:30:3:30:6 | name | +| data.bicep:30:3:30:19 | ObjectProperty | +| data.bicep:30:9:30:19 | String | +| data.bicep:30:9:30:19 | String | +| data.bicep:30:9:30:19 | String | +| data.bicep:30:10:30:18 | test name | +| data.bicep:31:3:31:4 | id | +| data.bicep:31:3:31:4 | id | +| data.bicep:31:3:31:4 | id | +| data.bicep:31:3:31:15 | ObjectProperty | +| data.bicep:31:7:31:15 | String | +| data.bicep:31:7:31:15 | String | +| data.bicep:31:7:31:15 | String | +| data.bicep:31:8:31:14 | 123-abc | +| data.bicep:32:3:32:11 | isCurrent | +| data.bicep:32:3:32:11 | isCurrent | +| data.bicep:32:3:32:11 | isCurrent | +| data.bicep:32:3:32:17 | ObjectProperty | +| data.bicep:32:14:32:17 | true | +| data.bicep:32:14:32:17 | true | +| data.bicep:32:14:32:17 | true | +| data.bicep:33:3:33:6 | tier | +| data.bicep:33:3:33:6 | tier | +| data.bicep:33:3:33:6 | tier | +| data.bicep:33:3:33:9 | ObjectProperty | +| data.bicep:33:9:33:9 | 1 | +| data.bicep:33:9:33:9 | 1 | +| data.bicep:33:9:33:9 | 1 | +| data.bicep:36:1:37:12 | ParameterDeclaration | +| data.bicep:36:1:37:12 | ParameterDeclaration | +| data.bicep:36:1:37:12 | ParameterDeclaration | +| data.bicep:36:7:36:17 | mixedObject | +| data.bicep:36:7:36:17 | mixedObject | +| data.bicep:36:7:36:17 | mixedObject | +| data.bicep:36:19:36:24 | Type | +| data.bicep:36:19:36:24 | object | +| data.bicep:36:28:37:12 | Object | +| data.bicep:36:28:37:12 | Object | +| data.bicep:36:28:37:12 | Object | +| data.bicep:36:29:36:32 | name | +| data.bicep:36:29:36:32 | name | +| data.bicep:36:29:36:32 | name | +| data.bicep:36:29:36:45 | ObjectProperty | +| data.bicep:36:35:36:45 | String | +| data.bicep:36:35:36:45 | String | +| data.bicep:36:35:36:45 | String | +| data.bicep:36:36:36:44 | test name | +| data.bicep:36:48:36:49 | id | +| data.bicep:36:48:36:49 | id | +| data.bicep:36:48:36:49 | id | +| data.bicep:36:48:36:60 | ObjectProperty | +| data.bicep:36:52:36:60 | String | +| data.bicep:36:52:36:60 | String | +| data.bicep:36:52:36:60 | String | +| data.bicep:36:53:36:59 | 123-abc | +| data.bicep:36:63:36:71 | isCurrent | +| data.bicep:36:63:36:71 | isCurrent | +| data.bicep:36:63:36:71 | isCurrent | +| data.bicep:36:63:36:77 | ObjectProperty | +| data.bicep:36:74:36:77 | true | +| data.bicep:36:74:36:77 | true | +| data.bicep:36:74:36:77 | true | +| data.bicep:37:5:37:8 | tier | +| data.bicep:37:5:37:8 | tier | +| data.bicep:37:5:37:8 | tier | +| data.bicep:37:5:37:11 | ObjectProperty | +| data.bicep:37:11:37:11 | 1 | +| data.bicep:37:11:37:11 | 1 | +| data.bicep:37:11:37:11 | 1 | +| data.bicep:39:1:39:10 | Comment | +| data.bicep:40:1:40:28 | Comment | +| data.bicep:41:1:41:25 | VariableDeclaration | +| data.bicep:41:1:41:25 | VariableDeclaration | +| data.bicep:41:1:41:25 | VariableDeclaration | +| data.bicep:41:5:41:9 | myVar | +| data.bicep:41:5:41:9 | myVar | +| data.bicep:41:5:41:9 | myVar | +| data.bicep:41:13:41:25 | String | +| data.bicep:41:13:41:25 | String | +| data.bicep:41:13:41:25 | String | +| data.bicep:41:14:41:17 | what | +| data.bicep:41:18:41:19 | \\' | +| data.bicep:41:20:41:24 | s up? | +| data.bicep:42:1:42:52 | TypeDeclaration | +| data.bicep:42:1:42:52 | TypeDeclaration | +| data.bicep:42:1:42:52 | TypeDeclaration | +| data.bicep:42:6:42:14 | direction | +| data.bicep:42:6:42:14 | direction | +| data.bicep:42:6:42:14 | direction | +| data.bicep:42:18:42:24 | String | +| data.bicep:42:18:42:24 | String | +| data.bicep:42:18:42:24 | String | +| data.bicep:42:18:42:52 | UnionType | +| data.bicep:42:19:42:23 | north | +| data.bicep:42:28:42:34 | String | +| data.bicep:42:28:42:34 | String | +| data.bicep:42:28:42:34 | String | +| data.bicep:42:29:42:33 | south | +| data.bicep:42:38:42:43 | String | +| data.bicep:42:38:42:43 | String | +| data.bicep:42:38:42:43 | String | +| data.bicep:42:38:42:52 | BinaryExpression | +| data.bicep:42:38:42:52 | BinaryExpression | +| data.bicep:42:39:42:42 | east | +| data.bicep:42:47:42:52 | String | +| data.bicep:42:47:42:52 | String | +| data.bicep:42:47:42:52 | String | +| data.bicep:42:48:42:51 | west | +| data.bicep:43:1:43:62 | VariableDeclaration | +| data.bicep:43:1:43:62 | VariableDeclaration | +| data.bicep:43:1:43:62 | VariableDeclaration | +| data.bicep:43:5:43:15 | storageName | +| data.bicep:43:5:43:15 | storageName | +| data.bicep:43:5:43:15 | storageName | +| data.bicep:43:19:43:62 | String | +| data.bicep:43:19:43:62 | String | +| data.bicep:43:19:43:62 | String | +| data.bicep:43:20:43:26 | storage | +| data.bicep:43:27:43:61 | Interpolation | +| data.bicep:43:29:43:40 | uniqueString | +| data.bicep:43:29:43:40 | uniqueString | +| data.bicep:43:29:43:40 | uniqueString | +| data.bicep:43:29:43:60 | CallExpression | +| data.bicep:43:29:43:60 | CallExpression | +| data.bicep:43:29:43:60 | CallExpression | +| data.bicep:43:41:43:60 | Arguments | +| data.bicep:43:42:43:54 | resourceGroup | +| data.bicep:43:42:43:54 | resourceGroup | +| data.bicep:43:42:43:54 | resourceGroup | +| data.bicep:43:42:43:56 | CallExpression | +| data.bicep:43:42:43:56 | CallExpression | +| data.bicep:43:42:43:56 | CallExpression | +| data.bicep:43:42:43:59 | MemberExpression | +| data.bicep:43:42:43:59 | MemberExpression | +| data.bicep:43:42:43:59 | MemberExpression | +| data.bicep:43:55:43:56 | Arguments | +| data.bicep:43:58:43:59 | id | +| data.bicep:45:1:45:24 | Comment | +| data.bicep:46:1:46:24 | VariableDeclaration | +| data.bicep:46:1:46:24 | VariableDeclaration | +| data.bicep:46:1:46:24 | VariableDeclaration | +| data.bicep:46:5:46:9 | myVar | +| data.bicep:46:5:46:9 | myVar | +| data.bicep:46:5:46:9 | myVar | +| data.bicep:46:13:46:24 | String | +| data.bicep:46:13:46:24 | String | +| data.bicep:46:13:46:24 | String | +| data.bicep:46:16:46:21 | hello! | +| data.bicep:48:1:48:61 | Comment | +| data.bicep:49:1:50:9 | VariableDeclaration | +| data.bicep:49:1:50:9 | VariableDeclaration | +| data.bicep:49:1:50:9 | VariableDeclaration | +| data.bicep:49:5:49:10 | myVar2 | +| data.bicep:49:5:49:10 | myVar2 | +| data.bicep:49:5:49:10 | myVar2 | +| data.bicep:49:14:50:9 | String | +| data.bicep:49:14:50:9 | String | +| data.bicep:49:14:50:9 | String | +| data.bicep:49:17:50:6 | \nhello! | +| data.bicep:52:1:52:64 | Comment | +| data.bicep:53:1:55:3 | VariableDeclaration | +| data.bicep:53:1:55:3 | VariableDeclaration | +| data.bicep:53:1:55:3 | VariableDeclaration | +| data.bicep:53:5:53:10 | myVar3 | +| data.bicep:53:5:53:10 | myVar3 | +| data.bicep:53:5:53:10 | myVar3 | +| data.bicep:53:14:55:3 | String | +| data.bicep:53:14:55:3 | String | +| data.bicep:53:14:55:3 | String | +| data.bicep:53:17:54:7 | \nhello!\n | +| data.bicep:57:1:57:50 | Comment | +| data.bicep:58:1:62:3 | VariableDeclaration | +| data.bicep:58:1:62:3 | VariableDeclaration | +| data.bicep:58:1:62:3 | VariableDeclaration | +| data.bicep:58:5:58:10 | myVar4 | +| data.bicep:58:5:58:10 | myVar4 | +| data.bicep:58:5:58:10 | myVar4 | +| data.bicep:58:14:62:3 | String | +| data.bicep:58:14:62:3 | String | +| data.bicep:58:14:62:3 | String | +| data.bicep:58:17:61:15 | \n this\n is\n indented\n | | sample.bicep:1:1:1:48 | ParameterDeclaration | | sample.bicep:1:1:1:48 | ParameterDeclaration | | sample.bicep:1:1:1:48 | ParameterDeclaration | diff --git a/ql/test/library-tests/ast/data.bicep b/ql/test/library-tests/ast/data.bicep new file mode 100644 index 0000000..6df7c43 --- /dev/null +++ b/ql/test/library-tests/ast/data.bicep @@ -0,0 +1,62 @@ +// Array's +var multiLineArray = [ + 'abc' + 'def' + 'ghi' +] + +var singleLineArray = ['abc', 'def', 'ghi'] + +var mixedArray = ['abc', 'def' + 'ghi'] + +var exampleArray = [1, 2, 3] +output firstElement int = exampleArray[0] // 1 +output thirdElement int = exampleArray[2] // 3 + +var index = 1 +output secondElement int = exampleArray[index] // 2 + +// Booleans +param exampleBool bool = true + +// Integers +param exampleInt int = 1 + +// Objects +param singleLineObject object = {name: 'test name', id: '123-abc', isCurrent: true, tier: 1} + +param multiLineObject object = { + name: 'test name' + id: '123-abc' + isCurrent: true + tier: 1 +} + +param mixedObject object = {name: 'test name', id: '123-abc', isCurrent: true + tier: 1} + +// Strings +// evaluates to "what's up?" +var myVar = 'what\'s up?' +type direction = 'north' | 'south' | 'east' | 'west' +var storageName = 'storage${uniqueString(resourceGroup().id)}' + +// evaluates to "hello!" +var myVar = '''hello!''' + +// evaluates to "hello!" because the first newline is skipped +var myVar2 = ''' +hello!''' + +// evaluates to "hello!\n" because the final newline is included +var myVar3 = ''' +hello! +''' + +// evaluates to " this\n is\n indented\n" +var myVar4 = ''' + this + is + indented +''' diff --git a/ql/test/library-tests/calls/Calls.expected b/ql/test/library-tests/calls/Calls.expected new file mode 100644 index 0000000..a3bbbfd --- /dev/null +++ b/ql/test/library-tests/calls/Calls.expected @@ -0,0 +1,43 @@ +callable +| calls.bicep:1:32:1:63 | CallExpression | +| calls.bicep:1:45:1:59 | CallExpression | +| calls.bicep:4:111:4:121 | CallExpression | +| calls.bicep:22:26:22:65 | CallExpression | +| calls.bicep:23:30:23:82 | CallExpression | +| calls.bicep:23:62:23:81 | CallExpression | +| calls.bicep:24:32:24:53 | CallExpression | +| calls.bicep:25:26:25:42 | CallExpression | +| calls.bicep:26:29:26:48 | CallExpression | +callArguments +| calls.bicep:1:32:1:63 | CallExpression | calls.bicep:1:45:1:62 | MemberExpression | +| calls.bicep:1:32:1:63 | CallExpression | calls.bicep:1:45:1:62 | MemberExpression | +| calls.bicep:1:32:1:63 | CallExpression | calls.bicep:1:45:1:62 | MemberExpression | +| calls.bicep:4:111:4:121 | CallExpression | calls.bicep:4:117:4:120 | path | +| calls.bicep:4:111:4:121 | CallExpression | calls.bicep:4:117:4:120 | path | +| calls.bicep:4:111:4:121 | CallExpression | calls.bicep:4:117:4:120 | path | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:35:22:38 | true | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:35:22:38 | true | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:35:22:38 | true | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:41:22:55 | String | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:41:22:55 | String | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:41:22:55 | String | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:58:22:64 | String | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:58:22:64 | String | +| calls.bicep:22:26:22:65 | CallExpression | calls.bicep:22:58:22:64 | String | +| calls.bicep:23:30:23:82 | CallExpression | calls.bicep:23:34:23:51 | Array | +| calls.bicep:23:30:23:82 | CallExpression | calls.bicep:23:34:23:51 | Array | +| calls.bicep:23:30:23:82 | CallExpression | calls.bicep:23:34:23:51 | Array | +| calls.bicep:23:30:23:82 | CallExpression | calls.bicep:23:54:23:81 | LambdaExpression | +| calls.bicep:23:30:23:82 | CallExpression | calls.bicep:23:54:23:81 | LambdaExpression | +| calls.bicep:23:62:23:81 | CallExpression | calls.bicep:23:77:23:80 | name | +| calls.bicep:23:62:23:81 | CallExpression | calls.bicep:23:77:23:80 | name | +| calls.bicep:23:62:23:81 | CallExpression | calls.bicep:23:77:23:80 | name | +| calls.bicep:24:32:24:53 | CallExpression | calls.bicep:24:47:24:52 | String | +| calls.bicep:24:32:24:53 | CallExpression | calls.bicep:24:47:24:52 | String | +| calls.bicep:24:32:24:53 | CallExpression | calls.bicep:24:47:24:52 | String | +| calls.bicep:25:26:25:42 | CallExpression | calls.bicep:25:36:25:41 | String | +| calls.bicep:25:26:25:42 | CallExpression | calls.bicep:25:36:25:41 | String | +| calls.bicep:25:26:25:42 | CallExpression | calls.bicep:25:36:25:41 | String | +| calls.bicep:26:29:26:48 | CallExpression | calls.bicep:26:42:26:47 | String | +| calls.bicep:26:29:26:48 | CallExpression | calls.bicep:26:42:26:47 | String | +| calls.bicep:26:29:26:48 | CallExpression | calls.bicep:26:42:26:47 | String | diff --git a/ql/test/library-tests/calls/Calls.ql b/ql/test/library-tests/calls/Calls.ql new file mode 100644 index 0000000..ce4a48c --- /dev/null +++ b/ql/test/library-tests/calls/Calls.ql @@ -0,0 +1,5 @@ +private import bicep + +query predicate callable(Callable callable) { any() } + +query predicate callArguments(CallExpression call, Expr argument) { call.getArguments() = argument } diff --git a/ql/test/library-tests/calls/Functions.expected b/ql/test/library-tests/calls/Functions.expected new file mode 100644 index 0000000..0f10928 --- /dev/null +++ b/ql/test/library-tests/calls/Functions.expected @@ -0,0 +1,14 @@ +functions +| calls.bicep:4:1:4:141 | UserDefinedFunction | +| calls.bicep:6:1:6:56 | UserDefinedFunction | +| calls.bicep:8:1:10:1 | UserDefinedFunction | +| calls.bicep:12:1:14:1 | UserDefinedFunction | +| calls.bicep:16:1:20:1 | UserDefinedFunction | +functionParameters +| calls.bicep:4:1:4:141 | UserDefinedFunction | calls.bicep:4:15:4:24 | Parameter | +| calls.bicep:4:1:4:141 | UserDefinedFunction | calls.bicep:4:27:4:41 | Parameter | +| calls.bicep:4:1:4:141 | UserDefinedFunction | calls.bicep:4:44:4:54 | Parameter | +| calls.bicep:6:1:6:56 | UserDefinedFunction | calls.bicep:6:21:6:31 | Parameter | +| calls.bicep:8:1:10:1 | UserDefinedFunction | calls.bicep:8:21:8:31 | Parameter | +| calls.bicep:12:1:14:1 | UserDefinedFunction | calls.bicep:12:16:12:26 | Parameter | +| calls.bicep:16:1:20:1 | UserDefinedFunction | calls.bicep:16:19:16:29 | Parameter | diff --git a/ql/test/library-tests/calls/Functions.ql b/ql/test/library-tests/calls/Functions.ql new file mode 100644 index 0000000..0de9ad7 --- /dev/null +++ b/ql/test/library-tests/calls/Functions.ql @@ -0,0 +1,7 @@ +private import bicep + +query predicate functions(UserDefinedFunction function) { any() } + +query predicate functionParameters(UserDefinedFunction function, Parameter params) { + function.getParameters() = params +} diff --git a/ql/test/library-tests/calls/Parameters.expected b/ql/test/library-tests/calls/Parameters.expected new file mode 100644 index 0000000..92a1a4f --- /dev/null +++ b/ql/test/library-tests/calls/Parameters.expected @@ -0,0 +1,16 @@ +parameters +| calls.bicep:4:15:4:24 | Parameter | +| calls.bicep:4:27:4:41 | Parameter | +| calls.bicep:4:44:4:54 | Parameter | +| calls.bicep:6:21:6:31 | Parameter | +| calls.bicep:8:21:8:31 | Parameter | +| calls.bicep:12:16:12:26 | Parameter | +| calls.bicep:16:19:16:29 | Parameter | +parameter +| calls.bicep:4:15:4:24 | Parameter | calls.bicep:4:15:4:19 | https | bool | +| calls.bicep:4:27:4:41 | Parameter | calls.bicep:4:27:4:34 | hostname | string | +| calls.bicep:4:44:4:54 | Parameter | calls.bicep:4:44:4:47 | path | string | +| calls.bicep:6:21:6:31 | Parameter | calls.bicep:6:21:6:24 | name | string | +| calls.bicep:8:21:8:31 | Parameter | calls.bicep:8:21:8:24 | name | string | +| calls.bicep:12:16:12:26 | Parameter | calls.bicep:12:16:12:19 | name | string | +| calls.bicep:16:19:16:29 | Parameter | calls.bicep:16:19:16:22 | name | string | diff --git a/ql/test/library-tests/calls/Parameters.ql b/ql/test/library-tests/calls/Parameters.ql new file mode 100644 index 0000000..ab94a78 --- /dev/null +++ b/ql/test/library-tests/calls/Parameters.ql @@ -0,0 +1,10 @@ +private import bicep + +query predicate parameters(Parameter parameter) { + any() +} + +query predicate parameter(Parameter param, Identifier name, string type) { + param.getName() = name and + param.getType().getType() = type +} diff --git a/ql/test/library-tests/calls/calls.bicep b/ql/test/library-tests/calls/calls.bicep new file mode 100644 index 0000000..24b2bde --- /dev/null +++ b/ql/test/library-tests/calls/calls.bicep @@ -0,0 +1,26 @@ +param siteName string = 'site${uniqueString(resourceGroup().id)}' +param hostingPlanName string = '${siteName}-plan' + +func buildUrl(https bool, hostname string, path string) string => '${https ? 'https' : 'http'}://${hostname}${empty(path) ? '' : '/${path}'}' + +func sayHelloString(name string) string => 'Hi ${name}!' + +func sayHelloObject(name string) object => { + hello: 'Hi ${name}!' +} + +func nameArray(name string) array => [ + name +] + +func addNameArray(name string) array => [ + 'Mary' + 'Bob' + name +] + +output azureUrl string = buildUrl(true, 'microsoft.com', 'azure') +output greetingArray array = map(['Evie', 'Casper'], name => sayHelloString(name)) +output greetingObject object = sayHelloObject('John') +output nameArray array = nameArray('John') +output addNameArray array = addNameArray('John')