Skip to content

Commit 5e7608d

Browse files
authored
Merge branch 'main' into dependabot/pip/pyinstaller-6.20.0
2 parents 2623c38 + 61e5289 commit 5e7608d

9 files changed

Lines changed: 52 additions & 11 deletions

File tree

.github/workflows/build_executable.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
steps:
3939
- name: Run Cimon
4040
if: matrix.os == 'ubuntu-22.04'
41-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
41+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
4242
with:
4343
client-id: ${{ secrets.CIMON_CLIENT_ID }}
4444
secret: ${{ secrets.CIMON_SECRET }}
@@ -313,7 +313,7 @@ jobs:
313313
314314
- name: Upload files to release
315315
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
316-
uses: svenstaro/upload-release-action@b98a3b12e86552593f3e4e577ca8a62aa2f3f22b # v2
316+
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
317317
with:
318318
file: dist/*
319319
tag: ${{ env.LATEST_TAG }}

.github/workflows/docker-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- name: Build and push
7777
id: docker_build
7878
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }}
79-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
79+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
8080
with:
8181
context: .
8282
platforms: linux/amd64,linux/arm64
@@ -86,7 +86,7 @@ jobs:
8686
- name: Verify build
8787
id: docker_verify_build
8888
if: ${{ github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/v') }}
89-
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
89+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
9090
with:
9191
context: .
9292
platforms: linux/amd64,linux/arm64

.github/workflows/pre_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Run Cimon
18-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
18+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
1919
with:
2020
client-id: ${{ secrets.CIMON_CLIENT_ID }}
2121
secret: ${{ secrets.CIMON_SECRET }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: Run Cimon
17-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
17+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
1818
with:
1919
client-id: ${{ secrets.CIMON_CLIENT_ID }}
2020
secret: ${{ secrets.CIMON_SECRET }}

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Run Cimon
13-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
13+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
1414
with:
1515
client-id: ${{ secrets.CIMON_CLIENT_ID }}
1616
secret: ${{ secrets.CIMON_SECRET }}

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
steps:
1313
- name: Run Cimon
14-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
14+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
1515
with:
1616
client-id: ${{ secrets.CIMON_CLIENT_ID }}
1717
secret: ${{ secrets.CIMON_SECRET }}

.github/workflows/tests_full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- name: Run Cimon
2626
if: matrix.os == 'ubuntu-latest'
27-
uses: cycodelabs/cimon-action@3ca67e875f34772093aa3bf3c185a711720bf5d9 # v0.10.1
27+
uses: cycodelabs/cimon-action@a0870cc3d9e3bf3cedd28bdb67bf3fd3281e5941 # v1.0.1
2828
with:
2929
client-id: ${{ secrets.CIMON_CLIENT_ID }}
3030
secret: ${{ secrets.CIMON_SECRET }}

cycode/cli/apps/scan/scan_command.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,32 @@
2828
_SECRET_RICH_HELP_PANEL = 'Secret options'
2929

3030

31+
def _single_value_callback(ctx: typer.Context, param: typer.CallbackParam, value: list) -> list:
32+
if len(value) > 1:
33+
values_str = ', '.join(str(v) for v in value)
34+
param_hint = '/'.join(sorted(param.opts, key=len))
35+
err = typer.BadParameter(
36+
f'Only one value can be specified per command. Got: {values_str}. Run a separate command for each value.',
37+
ctx=ctx,
38+
param_hint=param_hint,
39+
)
40+
err.exit_code = 1
41+
raise err
42+
return value
43+
44+
3145
def scan_command(
3246
ctx: typer.Context,
3347
scan_type: Annotated[
34-
ScanTypeOption,
48+
list[ScanTypeOption],
3549
typer.Option(
3650
'--scan-type',
3751
'-t',
3852
help='Specify the type of scan you wish to execute.',
3953
case_sensitive=False,
54+
callback=_single_value_callback,
4055
),
41-
] = ScanTypeOption.SECRET,
56+
] = (ScanTypeOption.SECRET,),
4257
soft_fail: Annotated[
4358
bool, typer.Option('--soft-fail', help='Run the scan without failing; always return a non-error status code.')
4459
] = False,
@@ -137,6 +152,9 @@ def scan_command(
137152
param_hint='--export-file',
138153
)
139154

155+
# _single_value_callback validated exactly one value was provided; unwrap from list
156+
scan_type = scan_type[0]
157+
140158
ctx.obj['show_secret'] = show_secret
141159
ctx.obj['soft_fail'] = soft_fail
142160
ctx.obj['stop_on_error'] = stop_on_error

tests/cli/commands/scan/test_scan_command.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import re
2+
13
import click
24
import pytest
35
import typer
6+
from typer.testing import CliRunner
47

8+
from cycode.cli.app import app
59
from cycode.cli.apps.scan.scan_command import scan_command_result_callback
610
from cycode.cli.consts import ISSUE_DETECTED_STATUS_CODE, NO_ISSUES_STATUS_CODE, SCAN_ERROR_STATUS_CODE
711

812

13+
def _strip_ansi(text: str) -> str:
14+
return re.sub(r'\x1b\[[0-9;]*[mGKHF]', '', text)
15+
16+
917
def _make_ctx(**obj_overrides: object) -> click.Context:
1018
obj = {
1119
'soft_fail': False,
@@ -25,6 +33,21 @@ def _invoke_result_callback(ctx: click.Context) -> int:
2533
return exc_info.value.exit_code
2634

2735

36+
class TestScanCommand:
37+
def test_multiple_scan_types_rejected(self) -> None:
38+
result = CliRunner().invoke(app, ['scan', '-t', 'iac', '-t', 'sast', 'path', '.'])
39+
assert result.exit_code == 1
40+
output = _strip_ansi(result.output)
41+
assert '-t/--scan-type' in output
42+
assert 'iac' in output
43+
assert 'sast' in output
44+
45+
def test_single_scan_type_accepted(self) -> None:
46+
result = CliRunner().invoke(app, ['scan', '-t', 'iac', '--help'])
47+
assert result.exit_code == 0
48+
assert 'Error' not in result.output
49+
50+
2851
class TestScanCommandResultCallback:
2952
def test_no_issues_no_errors_exits_zero(self) -> None:
3053
assert _invoke_result_callback(_make_ctx()) == NO_ISSUES_STATUS_CODE

0 commit comments

Comments
 (0)