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
21 changes: 1 addition & 20 deletions cycode/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@
type=bool,
required=False,
)
@click.option(
'--output',
'-o',
default=None,
help="""
\b
Specify the results output (text/json/table),
the default is text
""",
type=click.Choice(['text', 'json', 'table']),
)
@click.option(
'--severity-threshold',
default=None,
Expand Down Expand Up @@ -127,7 +116,6 @@ def code_scan(
client_id: str,
show_secret: bool,
soft_fail: bool,
output: str,
severity_threshold: str,
sca_scan: List[str],
monitor: bool,
Expand All @@ -143,15 +131,8 @@ def code_scan(
else:
context.obj['soft_fail'] = config['soft_fail']

context.obj['scan_type'] = scan_type

# save backward compatability with old style command
if output is not None:
context.obj['output'] = output
if output == 'json':
context.obj['no_progress_meter'] = True

context.obj['client'] = get_cycode_client(client_id, secret, not context.obj['show_secret'])
context.obj['scan_type'] = scan_type
context.obj['severity_threshold'] = severity_threshold
context.obj['monitor'] = monitor
context.obj['report'] = report
Expand Down
18 changes: 2 additions & 16 deletions tests/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ def _is_json(plain: str) -> bool:

@responses.activate
@pytest.mark.parametrize('output', ['text', 'json'])
@pytest.mark.parametrize('option_space', ['scan', 'global'])
def test_passing_output_option(
output: str, option_space: str, scan_client: 'ScanClient', api_token_response: responses.Response
) -> None:
def test_passing_output_option(output: str, scan_client: 'ScanClient', api_token_response: responses.Response) -> None:
scan_type = 'secret'

responses.add(get_zipped_file_scan_response(get_zipped_file_scan_url(scan_type, scan_client)))
Expand All @@ -37,18 +34,7 @@ def test_passing_output_option(
# This raises connection error on the attempt to report scan.
# It doesn't perform real request

args = ['scan', '--soft-fail', 'path', str(_PATH_TO_SCAN)]

if option_space == 'global':
global_args = ['--output', output]
global_args.extend(args)

args = global_args
elif option_space == 'scan':
# test backward compatability with old style command
args.insert(2, '--output')
args.insert(3, output)

args = ['--output', output, 'scan', '--soft-fail', 'path', str(_PATH_TO_SCAN)]
result = CliRunner().invoke(main_cli, args, env=CLI_ENV_VARS)

except_json = output == 'json'
Expand Down