Skip to content
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
4 changes: 0 additions & 4 deletions cycode/cli/commands/report/report_command.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import click

from cycode.cli.commands.report.sbom.sbom_command import sbom_command
from cycode.cli.utils.get_api_client import get_report_cycode_client
from cycode.cli.utils.progress_bar import SBOM_REPORT_PROGRESS_BAR_SECTIONS, get_progress_bar


Expand All @@ -16,8 +15,5 @@ def report_command(
context: click.Context,
) -> int:
"""Generate report."""

context.obj['client'] = get_report_cycode_client(hide_response_log=False) # TODO disable log
context.obj['progress_bar'] = get_progress_bar(hidden=False, sections=SBOM_REPORT_PROGRESS_BAR_SECTIONS)

return 1
3 changes: 2 additions & 1 deletion cycode/cli/commands/report/sbom/sbom_path_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from cycode.cli.files_collector.path_documents import get_relevant_document
from cycode.cli.files_collector.sca.sca_code_scanner import perform_pre_scan_documents_actions
from cycode.cli.files_collector.zip_documents import zip_documents
from cycode.cli.utils.get_api_client import get_report_cycode_client
from cycode.cli.utils.progress_bar import SbomReportProgressBarSection


@click.command(short_help='Generate SBOM report for provided path in the command.')
@click.argument('path', nargs=1, type=click.Path(exists=True, resolve_path=True), required=True)
@click.pass_context
def sbom_path_command(context: click.Context, path: str) -> None:
client = context.obj['client']
client = get_report_cycode_client()
report_parameters = context.obj['report_parameters']
output_format = report_parameters.output_format
output_file = context.obj['output_file']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cycode.cli.commands.report.sbom.common import create_sbom_report, send_report_feedback
from cycode.cli.commands.report.sbom.handle_errors import handle_report_exception
from cycode.cli.utils.get_api_client import get_report_cycode_client
from cycode.cli.utils.progress_bar import SbomReportProgressBarSection


Expand All @@ -15,7 +16,7 @@ def sbom_repository_url_command(context: click.Context, uri: str) -> None:
progress_bar.start()
progress_bar.set_section_length(SbomReportProgressBarSection.PREPARE_LOCAL_FILES)

client = context.obj['client']
client = get_report_cycode_client()
report_parameters = context.obj['report_parameters']
output_file = context.obj['output_file']
output_format = report_parameters.output_format
Expand Down
4 changes: 2 additions & 2 deletions cycode/cyclient/client_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def create_scan_client(client_id: str, client_secret: str, hide_response_log: bo
return ScanClient(client, scan_config, hide_response_log)


def create_report_client(client_id: str, client_secret: str, hide_response_log: bool) -> ReportClient:
def create_report_client(client_id: str, client_secret: str, _: bool) -> ReportClient:
client = CycodeDevBasedClient(DEV_CYCODE_API_URL) if dev_mode else CycodeTokenBasedClient(client_id, client_secret)
return ReportClient(client, hide_response_log)
return ReportClient(client)
8 changes: 4 additions & 4 deletions cycode/cyclient/report_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ class ReportClient:

DOWNLOAD_REPORT_PATH: str = 'files/api/v1/file/sbom/{file_name}' # not in the report service

def __init__(self, client: CycodeClientBase, hide_response_log: bool = True) -> None:
def __init__(self, client: CycodeClientBase) -> None:
self.client = client
self._hide_response_log = hide_response_log

def request_sbom_report_execution(
self, params: ReportParameters, zip_file: InMemoryZip = None, repository_url: Optional[str] = None
Expand All @@ -55,7 +54,6 @@ def request_sbom_report_execution(
request_args = {
'url_path': url_path,
'data': request_data,
'hide_response_content_log': self._hide_response_log,
}

if zip_file:
Expand Down Expand Up @@ -84,7 +82,9 @@ def get_report_execution(self, report_execution_id: int) -> models.ReportExecuti

def get_file_content(self, file_name: str) -> str:
response = self.client.get(
url_path=self.DOWNLOAD_REPORT_PATH.format(file_name=file_name), params={'include_hidden': True}
url_path=self.DOWNLOAD_REPORT_PATH.format(file_name=file_name),
params={'include_hidden': True},
hide_response_content_log=True,
)
return response.text

Expand Down