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

fix(scan): add compliance info inside finding #5649

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions docs/developer-guide/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ from prowler.providers.common.models import Audit_Metadata
from prowler.providers.common.provider import Provider
from prowler.providers.<new_provider_name>.models import (
# All providers models needed
ProvierSessionModel,
ProvierIdentityModel,
ProvierOutputOptionsModel
ProviderSessionModel,
ProviderIdentityModel,
ProviderOutputOptionsModel
)

class NewProvider(Provider):
Expand All @@ -201,7 +201,7 @@ class NewProvider(Provider):
_session: <ProvierSessionModel>
_identity: <ProvierIdentityModel>
_audit_config: dict
_output_options: ProvierOutputOptionsModel
_output_options: ProviderOutputOptionsModel
_mutelist: dict
audit_metadata: Audit_Metadata

Expand Down
20 changes: 17 additions & 3 deletions prowler/lib/scan/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ScanInvalidSeverityError,
ScanInvalidStatusError,
)
from prowler.providers.common.models import Audit_Metadata
from prowler.providers.common.models import Audit_Metadata, ProviderOutputOptions
from prowler.providers.common.provider import Provider


Expand Down Expand Up @@ -222,7 +222,7 @@ def findings(self) -> list:

def scan(
self,
custom_checks_metadata: dict = {},
custom_checks_metadata: dict = None,
) -> Generator[tuple[float, list[Finding]], None, None]:
"""
Executes the scan by iterating over the checks to execute and executing each check.
Expand All @@ -239,6 +239,20 @@ def scan(
Exception: If any other error occurs during the execution of a check.
"""
try:
# Load bulk compliance frameworks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this two times: one here and another one during the __init__ maybe you can store it in the class. What do you think?

bulk_compliance_frameworks = Compliance.get_bulk(self.provider.type)

# Get bulk checks metadata for the provider
bulk_checks_metadata = CheckMetadata.get_bulk(self.provider.type)
# Complete checks metadata with the compliance framework specification
bulk_checks_metadata = update_checks_metadata_with_compliance(
bulk_compliance_frameworks, bulk_checks_metadata
)

output_options = ProviderOutputOptions(
bulk_checks_metadata=bulk_checks_metadata,
)

checks_to_execute = self.checks_to_execute
# Initialize the Audit Metadata
# TODO: this should be done in the provider class
Expand Down Expand Up @@ -306,7 +320,7 @@ def scan(

findings = [
Finding.generate_output(
self._provider, finding, output_options=None
self._provider, finding, output_options=output_options
)
for finding in check_findings
]
Expand Down
Loading