Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ iniconfig = "*"

[packages]
bc-jsonpath-ng = "==1.6.1"
pycep-parser = "==0.5.1"
pycep-parser = "==0.7.0"
tabulate = ">=0.9.0,<0.10.0"
colorama = ">=0.4.3,<0.5.0"
termcolor=">=1.1.0,<2.4.0"
Expand Down Expand Up @@ -87,4 +87,4 @@ urllib3 = ">=1.26.20"
bc-python-hcl2 = "==0.4.3"

[requires]
python_version = "3.9"
python_version = "3.10"
3,733 changes: 1,864 additions & 1,869 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self) -> None:
"bc-python-hcl2==0.4.3",
"bc-detect-secrets==1.5.45",
"bc-jsonpath-ng==1.6.1",
"pycep-parser==0.5.1",
"pycep-parser==0.7.0",
"tabulate>=0.9.0,<0.10.0",
"colorama>=0.4.3,<0.5.0",
"termcolor>=1.1.0,<2.4.0",
Expand Down Expand Up @@ -114,7 +114,7 @@ def run(self) -> None:
license="Apache License 2.0",
name="checkov",
version=version,
python_requires=">=3.9",
python_requires=">=3.10",
description="Infrastructure as code static analysis",
author="bridgecrew",
author_email="meet@bridgecrew.io",
Expand Down
13 changes: 13 additions & 0 deletions tests/bicep/examples/multiline_function.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource cognitiveServicesOpenAIUserForUser 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
scope: azureOpenAI
name: guid(
azureOpenAI.id,
principalId,
resourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd')
)
properties: {
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd')
principalId: principalId
principalType: principalType
}
}
37 changes: 26 additions & 11 deletions tests/bicep/test_graph_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ def test_build_graph_from_source_directory():
playground_file = EXAMPLES_DIR / "playground.bicep"
graph_file = EXAMPLES_DIR / "graph.bicep"
loop_file = EXAMPLES_DIR / "loop.bicep"
multiline_function_file = EXAMPLES_DIR / "multiline_function.bicep"
graph_manager = BicepGraphManager(db_connector=NetworkxConnector())

# when
local_graph, definitions = graph_manager.build_graph_from_source_directory(source_dir=str(EXAMPLES_DIR))

# then
assert set(definitions.keys()) == {existing_file, playground_file, graph_file, loop_file} # should not include 'malformed.bicep' file
assert set(definitions.keys()) == {existing_file, playground_file, graph_file, loop_file, multiline_function_file} # should not include 'malformed.bicep' file

assert len(local_graph.vertices) == 48
assert len(local_graph.edges) == 47
assert len(local_graph.vertices) == 50
assert len(local_graph.edges) == 53

storage_account_idx = local_graph.vertices_by_name["diagsAccount"] # vertices_by_name exists for BicepGraphManager
storage_account = local_graph.vertices[storage_account_idx]
Expand All @@ -39,10 +40,17 @@ def test_build_graph_from_source_directory():
"config": {
"name": "diags${uniqueString(resourceGroup().id)}",
"location": {
"function": {
"type": "resource_group",
"parameters": {"resource_group_name": None, "subscription_id": None},
"property_name": "location",
"operator": {
"type": "property_accessor",
"operands": {
"operand_1": {
"function": {
"type": "resource_group",
"parameters": {"resource_group_name": None, "subscription_id": None},
}
},
"operand_2": "location",
},
}
},
"sku": {"name": "Standard_LRS"},
Expand Down Expand Up @@ -80,10 +88,17 @@ def test_build_graph_from_definitions():
"config": {
"name": "diags${uniqueString(resourceGroup().id)}",
"location": {
"function": {
"type": "resource_group",
"parameters": {"resource_group_name": None, "subscription_id": None},
"property_name": "location",
"operator": {
"type": "property_accessor",
"operands": {
"operand_1": {
"function": {
"type": "resource_group",
"parameters": {"resource_group_name": None, "subscription_id": None},
}
},
"operand_2": "location",
},
}
},
"sku": {"name": "Standard_LRS"},
Expand Down
11 changes: 11 additions & 0 deletions tests/bicep/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ def test_parse_malformed_file():
# then
assert template is None
assert file_lines is None

def test_parse_multiline_function():
# given
test_file = EXAMPLES_DIR / "multiline_function.bicep"

# when
template, file_lines = Parser().parse(test_file)

# then
assert template is not None
assert file_lines is not None
Loading