Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arielkru committed Oct 25, 2023
1 parent c43c3dc commit ef7d3b2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions checkov/sast/checks_infra/base_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@


class Registry(BaseCheckRegistry):
def __init__(self, checks_dir: str) -> None:
def __init__(self, checks_dir: str | None = None) -> None:
super().__init__(report_type=CheckType.SAST)
self.rules: List[Dict[str, Any]] = []
self.checks_dir = checks_dir
self.logger = logging.getLogger(__name__)
self.runner_filter: Optional[RunnerFilter] = None
self.checks_dirs_path: List[str] = [checks_dir]
self.checks_dirs_path: List[str] = []

def extract_entity_details(self, entity: dict[str, Any]) -> tuple[str, str, dict[str, Any]]:
# TODO
Expand Down
6 changes: 1 addition & 5 deletions checkov/sast/engines/prisma_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def run_go_library(self, languages: Set[SastLanguages],
report_reachability: bool = False,
remove_default_policies: bool = False) -> Union[List[Report], SastPolicies]:

validate_params(languages, source_codes, policies, list_policies)
validate_params(languages, source_codes, list_policies)

if bc_integration.bc_source:
name = bc_integration.bc_source.name
Expand Down Expand Up @@ -348,17 +348,13 @@ def get_policies(self, languages: Set[SastLanguages]) -> SastPolicies:

def validate_params(languages: Set[SastLanguages],
source_codes: List[str],
policies: List[str],
list_policies: bool) -> None:
if list_policies:
return

if len(source_codes) == 0:
raise Exception('must provide source code file or dir for sast runner')

if len(policies) == 0:
raise Exception('must provide policy file or dir for sast runner')

if len(languages) == 0:
raise Exception('must provide a language for sast runner')

Expand Down
14 changes: 3 additions & 11 deletions checkov/sast/prisma_models/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Profiler(BaseModel):
duration: str # noqa: CCE003
duration: int # noqa: CCE003
memory: int # noqa: CCE003


Expand All @@ -27,22 +27,14 @@ class MatchLocation(BaseModel):
code_block: str # noqa: CCE003


class MatchMetavariable(BaseModel):
path: Optional[str] # noqa: CCE003
start: Optional[Point] # noqa: CCE003
end: Optional[Point] # noqa: CCE003
data_flow: Optional[List[Flow]] # noqa: CCE003
code_block: Optional[str] # noqa: CCE003


class DataFlow(BaseModel):
data_flow: List[Flow] # noqa: CCE003


class MatchMetadata(BaseModel):
metavariables: Dict[str, MatchMetavariable] # noqa: CCE003
metavariables: Dict[str, DataFlow] # noqa: CCE003
variables: Dict[str, Any] # noqa: CCE003
taint_mode: Optional[DataFlow] # noqa: CCE003
taint_mode: Optional[DataFlow] = None # noqa: CCE003


class Match(BaseModel):
Expand Down
4 changes: 1 addition & 3 deletions checkov/sast/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

logger = logging.getLogger(__name__)

CHECKS_DIR = (os.path.join(pathlib.Path(__file__).parent.resolve(), 'checks'))


class Runner(BaseRunner[None, None, None]):
check_type = CheckType.SAST # noqa: CCE003 # a static attribute

def __init__(self) -> None:
super().__init__(file_extensions=["." + a for a in FILE_EXT_TO_SAST_LANG.keys()])
self.registry = Registry(checks_dir=CHECKS_DIR)
self.registry = Registry()
self.engine = PrismaEngine() # noqa: disallow-untyped-calls

def should_scan_file(self, file: str) -> bool:
Expand Down

0 comments on commit ef7d3b2

Please sign in to comment.