Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(s3): create class and refactor #4457

Merged
merged 10 commits into from
Jul 23, 2024
Merged
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
157 changes: 88 additions & 69 deletions prowler/__main__.py

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions prowler/lib/outputs/compliance/compliance_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from csv import DictWriter
from io import TextIOWrapper
from pathlib import Path
from typing import List

from prowler.lib.check.compliance_models import ComplianceBaseModel
Expand All @@ -25,17 +25,21 @@
create_file_descriptor: Method to create a file descriptor for writing data to a file.
"""

_data: list
_file_descriptor: TextIOWrapper

def __init__(
self,
findings: List[Finding],
compliance: ComplianceBaseModel,
create_file_descriptor: bool = False,
file_path: str = None,
file_extension: str = "",
) -> None:
self._data = []

if not file_extension and file_path:
self._file_extension = "".join(Path(file_path).suffixes)

Check warning on line 39 in prowler/lib/outputs/compliance/compliance_output.py

View check run for this annotation

Codecov / codecov/patch

prowler/lib/outputs/compliance/compliance_output.py#L39

Added line #L39 was not covered by tests
if file_extension:
self._file_extension = file_extension

if findings:
# Get the compliance name of the model
compliance_name = (
Expand Down
8 changes: 4 additions & 4 deletions prowler/lib/outputs/output.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from io import TextIOWrapper
from os import path
from pathlib import Path
from typing import List

from prowler.lib.logger import logger
Expand Down Expand Up @@ -40,13 +40,13 @@ def __init__(
self._data = []

if not file_extension and file_path:
_, self._file_extension = path.splitext(file_path)
self._file_extension = "".join(Path(file_path).suffixes)
if file_extension:
self._file_extension = file_extension

if findings:
self.transform(findings)
if create_file_descriptor:
if create_file_descriptor and file_path:
self.create_file_descriptor(file_path)

@property
Expand All @@ -73,7 +73,7 @@ def transform(self, findings: List[Finding]):
def batch_write_data_to_file(self) -> None:
raise NotImplementedError

def create_file_descriptor(self, file_path) -> None:
def create_file_descriptor(self, file_path: str) -> None:
"""
Creates a file descriptor for writing data to a file.

Expand Down
Loading