-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
4,526 additions
and
3,818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import re | ||
|
||
COMMENT_REGEX = re.compile(r'(checkov:skip=|bridgecrew:skip=) *([A-Za-z_\d]+(?:,[A-Za-z_\d]+)*)?(:[^\n]*)?') | ||
COMMENT_REGEX = re.compile(r'(checkov:skip=|bridgecrew:skip=|cortex:skip=) *([A-Za-z_\d]+(?:,[A-Za-z_\d]+)*)?(:[^\n]*)?') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
|
||
def build_definitions_context(definitions: dict[str, dict[str, Any]], definitions_raw: dict[str, list[tuple[int, str]]] | ||
) -> dict[str, dict[str, Any]]: | ||
return {} | ||
|
||
|
||
def add_resource_to_definitions_context(definitions_context: dict[str, dict[str, Any]], resource_key: str, | ||
resource_attributes: dict[str, Any], definition_attribute: str, | ||
definitions_raw: dict[str, Any], file_path: str) -> None: | ||
pass |
12 changes: 0 additions & 12 deletions
12
checkov/serverless/graph_builder/graph_components/block_types.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from pathlib import Path | ||
from typing import Any, TYPE_CHECKING | ||
|
||
from checkov.serverless.utils import ServerlessElements | ||
|
||
if TYPE_CHECKING: | ||
from checkov.serverless.graph_builder.graph_components.blocks import ServerlessBlock | ||
|
||
|
||
def convert_graph_vertices_to_definitions(vertices: list[ServerlessBlock], root_folder: str | Path | None) \ | ||
-> tuple[dict[str, dict[str, Any]], dict[str, dict[str, Any]]]: | ||
serverless_definitions: dict[str, dict[str, Any]] = {} | ||
breadcrumbs: dict[str, dict[str, Any]] = {} | ||
for vertex in vertices: | ||
block_path = vertex.path | ||
element_name = vertex.name.split('.')[-1] | ||
# Plugins section is formatted as a list | ||
if vertex.block_type == ServerlessElements.PLUGINS: | ||
serverless_definitions.setdefault(block_path, {}).setdefault(vertex.block_type, []).append(element_name) | ||
|
||
# If there is a ket named 'value' in the config it means that | ||
# this vertex's config contains only a single string | ||
elif 'value' in vertex.config: | ||
# If the vertex is provider or service and it only contains a string the section should look like: | ||
# provider: <value> | ||
# service: <value> | ||
if element_name == ServerlessElements.PROVIDER or element_name == ServerlessElements.SERVICE: | ||
serverless_definitions.setdefault(block_path, {})[vertex.block_type] = vertex.config['value'] | ||
|
||
# Otherwise it's a vertex of a specific nested attribute and need to include the full path | ||
# Examples: | ||
# provider: | ||
# runtime: nodejs20.x | ||
# custom: | ||
# myCustomVar: value | ||
else: | ||
serverless_definitions.setdefault(block_path, {}).setdefault(vertex.block_type, {})[element_name] = \ | ||
vertex.config['value'] | ||
|
||
# Otherwise, the vertex config is a dict | ||
else: | ||
serverless_definitions.setdefault(block_path, {}).setdefault(vertex.block_type, {})[ | ||
element_name] = vertex.config | ||
|
||
if vertex.breadcrumbs: | ||
relative_block_path = f"/{os.path.relpath(block_path, root_folder)}" | ||
add_breadcrumbs(vertex, breadcrumbs, relative_block_path) | ||
return serverless_definitions, breadcrumbs | ||
|
||
|
||
def add_breadcrumbs(vertex: ServerlessBlock, breadcrumbs: dict[str, dict[str, Any]], relative_block_path: str) -> None: | ||
breadcrumbs.setdefault(relative_block_path, {})[vertex.name] = vertex.breadcrumbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.