Skip to content

Commit a35fb49

Browse files
authored
CM-27947 - Fix required authorization for sbom --help command (#168)
1 parent 47e2b2d commit a35fb49

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

cycode/cli/commands/report/report_command.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import click
22

33
from cycode.cli.commands.report.sbom.sbom_command import sbom_command
4-
from cycode.cli.utils.get_api_client import get_report_cycode_client
54
from cycode.cli.utils.progress_bar import SBOM_REPORT_PROGRESS_BAR_SECTIONS, get_progress_bar
65

76

@@ -16,8 +15,5 @@ def report_command(
1615
context: click.Context,
1716
) -> int:
1817
"""Generate report."""
19-
20-
context.obj['client'] = get_report_cycode_client(hide_response_log=False) # TODO disable log
2118
context.obj['progress_bar'] = get_progress_bar(hidden=False, sections=SBOM_REPORT_PROGRESS_BAR_SECTIONS)
22-
2319
return 1

cycode/cli/commands/report/sbom/sbom_path_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
from cycode.cli.files_collector.path_documents import get_relevant_document
99
from cycode.cli.files_collector.sca.sca_code_scanner import perform_pre_scan_documents_actions
1010
from cycode.cli.files_collector.zip_documents import zip_documents
11+
from cycode.cli.utils.get_api_client import get_report_cycode_client
1112
from cycode.cli.utils.progress_bar import SbomReportProgressBarSection
1213

1314

1415
@click.command(short_help='Generate SBOM report for provided path in the command.')
1516
@click.argument('path', nargs=1, type=click.Path(exists=True, resolve_path=True), required=True)
1617
@click.pass_context
1718
def sbom_path_command(context: click.Context, path: str) -> None:
18-
client = context.obj['client']
19+
client = get_report_cycode_client()
1920
report_parameters = context.obj['report_parameters']
2021
output_format = report_parameters.output_format
2122
output_file = context.obj['output_file']

cycode/cli/commands/report/sbom/sbom_repository_url_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from cycode.cli.commands.report.sbom.common import create_sbom_report, send_report_feedback
66
from cycode.cli.commands.report.sbom.handle_errors import handle_report_exception
7+
from cycode.cli.utils.get_api_client import get_report_cycode_client
78
from cycode.cli.utils.progress_bar import SbomReportProgressBarSection
89

910

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

18-
client = context.obj['client']
19+
client = get_report_cycode_client()
1920
report_parameters = context.obj['report_parameters']
2021
output_file = context.obj['output_file']
2122
output_format = report_parameters.output_format

cycode/cyclient/client_creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def create_scan_client(client_id: str, client_secret: str, hide_response_log: bo
1818
return ScanClient(client, scan_config, hide_response_log)
1919

2020

21-
def create_report_client(client_id: str, client_secret: str, hide_response_log: bool) -> ReportClient:
21+
def create_report_client(client_id: str, client_secret: str, _: bool) -> ReportClient:
2222
client = CycodeDevBasedClient(DEV_CYCODE_API_URL) if dev_mode else CycodeTokenBasedClient(client_id, client_secret)
23-
return ReportClient(client, hide_response_log)
23+
return ReportClient(client)

cycode/cyclient/report_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ class ReportClient:
3737

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

40-
def __init__(self, client: CycodeClientBase, hide_response_log: bool = True) -> None:
40+
def __init__(self, client: CycodeClientBase) -> None:
4141
self.client = client
42-
self._hide_response_log = hide_response_log
4342

4443
def request_sbom_report_execution(
4544
self, params: ReportParameters, zip_file: InMemoryZip = None, repository_url: Optional[str] = None
@@ -55,7 +54,6 @@ def request_sbom_report_execution(
5554
request_args = {
5655
'url_path': url_path,
5756
'data': request_data,
58-
'hide_response_content_log': self._hide_response_log,
5957
}
6058

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

8583
def get_file_content(self, file_name: str) -> str:
8684
response = self.client.get(
87-
url_path=self.DOWNLOAD_REPORT_PATH.format(file_name=file_name), params={'include_hidden': True}
85+
url_path=self.DOWNLOAD_REPORT_PATH.format(file_name=file_name),
86+
params={'include_hidden': True},
87+
hide_response_content_log=True,
8888
)
8989
return response.text
9090

0 commit comments

Comments
 (0)