Skip to content

Commit 0707636

Browse files
authored
CM-45588 - Improve --help (#302)
1 parent 0405c6b commit 0707636

File tree

94 files changed

+819
-633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+819
-633
lines changed

.github/workflows/build_executable.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ jobs:
166166
shell: cmd
167167
env:
168168
SM_HOST: ${{ secrets.SM_HOST }}
169+
SM_KEYPAIR_ALIAS: ${{ secrets.SM_KEYPAIR_ALIAS }}
169170
SM_API_KEY: ${{ secrets.SM_API_KEY }}
170171
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
171172
SM_CODE_SIGNING_CERT_SHA1_HASH: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
@@ -174,7 +175,7 @@ jobs:
174175
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
175176
msiexec /i smtools-windows-x64.msi /quiet /qn
176177
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
177-
smksp_cert_sync.exe
178+
smctl windows certsync --keypair-alias=%SM_KEYPAIR_ALIAS%
178179
179180
:: sign executable
180181
signtool.exe sign /sha1 %SM_CODE_SIGNING_CERT_SHA1_HASH% /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 ".\dist\cycode-cli.exe"

.pre-commit-hooks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
language: python
44
language_version: python3
55
entry: cycode
6-
args: [ '--no-progress-meter', 'scan', '--scan-type', 'secret', 'pre_commit' ]
6+
args: [ '--no-progress-meter', 'scan', '--scan-type', 'secret', 'pre-commit' ]
77
- id: cycode-sca
88
name: Cycode SCA pre-commit defender
99
language: python
1010
language_version: python3
1111
entry: cycode
12-
args: [ '--no-progress-meter', 'scan', '--scan-type', 'sca', 'pre_commit' ]
12+
args: [ '--no-progress-meter', 'scan', '--scan-type', 'sca', 'pre-commit' ]

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ But it’s fine to use a higher version without using new features from these ve
1111
The project is under Poetry project management.
1212
To deal with it, you should install it on your system:
1313

14-
Install Poetry (feel free to use Brew, etc):
14+
Install Poetry (feel free to use Brew, etc.):
1515

1616
```shell
1717
curl -sSL https://install.python-poetry.org | python - -y
@@ -70,6 +70,8 @@ poetry run ruff format .
7070

7171
Many rules support auto-fixing. You can run it with the `--fix` flag.
7272

73+
Plugin for JB IDEs with auto formatting on save is available [here](https://plugins.jetbrains.com/plugin/20574-ruff).
74+
7375
### Branching and versioning
7476

7577
We use the `main` branch as the main one.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ The following are the options and commands available with the Cycode CLI applica
281281
| [auth](#using-the-auth-command) | Authenticate your machine to associate the CLI with your Cycode account. |
282282
| [configure](#using-the-configure-command) | Initial command to configure your CLI client authentication. |
283283
| [ignore](#ignoring-scan-results) | Ignores a specific value, path or rule ID. |
284-
| [scan](#running-a-scan) | Scan the content for Secrets/IaC/SCA/SAST violations. You`ll need to specify which scan type to perform: commit_history/path/repository/etc. |
284+
| [scan](#running-a-scan) | Scan the content for Secrets/IaC/SCA/SAST violations. You`ll need to specify which scan type to perform: commit-history/path/repository/etc. |
285285
| [report](#report-command) | Generate report. You`ll need to specify which report type to perform. |
286286
| status | Show the CLI status and exit. |
287287

@@ -294,7 +294,7 @@ The Cycode CLI application offers several types of scans so that you can choose
294294
| Option | Description |
295295
|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
296296
| `-t, --scan-type [secret\|iac\|sca\|sast]` | Specify the scan you wish to execute (`secret`/`iac`/`sca`/`sast`), the default is `secret`. |
297-
| `--secret TEXT` | Specify a Cycode client secret for this specific scan execution. |
297+
| `--client-secret TEXT` | Specify a Cycode client secret for this specific scan execution. |
298298
| `--client-id TEXT` | Specify a Cycode client ID for this specific scan execution. |
299299
| `--show-secret BOOLEAN` | Show secrets in plain text. See [Show/Hide Secrets](#showhide-secrets) section for more details. |
300300
| `--soft-fail BOOLEAN` | Run scan without failing, always return a non-error status code. See [Soft Fail](#soft-fail) section for more details. |
@@ -308,9 +308,9 @@ The Cycode CLI application offers several types of scans so that you can choose
308308

309309
| Command | Description |
310310
|----------------------------------------|-----------------------------------------------------------------|
311-
| [commit_history](#commit-history-scan) | Scan all the commits history in this git repository |
311+
| [commit-history](#commit-history-scan) | Scan all the commits history in this git repository |
312312
| [path](#path-scan) | Scan the files in the path supplied in the command |
313-
| [pre_commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
313+
| [pre-commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
314314
| [repository](#repository-scan) | Scan git repository including its history |
315315

316316
### Options
@@ -466,25 +466,25 @@ A commit history scan is limited to a local repository’s previous commits, foc
466466
467467
To execute a commit history scan, execute the following:
468468
469-
`cycode scan commit_history {{path}}`
469+
`cycode scan commit-history {{path}}`
470470
471471
For example, consider a scenario in which you want to scan the commit history for a repository stored in `~/home/git/codebase`. You could then execute the following:
472472
473-
`cycode scan commit_history ~/home/git/codebase`
473+
`cycode scan commit-history ~/home/git/codebase`
474474
475475
The following options are available for use with this command:
476476
477477
| Option | Description |
478478
|---------------------------|----------------------------------------------------------------------------------------------------------|
479-
| `-r, --commit_range TEXT` | Scan a commit range in this git repository, by default cycode scans all commit history (example: HEAD~1) |
479+
| `-r, --commit-range TEXT` | Scan a commit range in this git repository, by default cycode scans all commit history (example: HEAD~1) |
480480
481481
#### Commit Range Option
482482
483-
The commit history scan, by default, examines the repository’s entire commit history, all the way back to the initial commit. You can instead limit the scan to a specific commit range by adding the argument `--commit_range` (`-r`) followed by the name you specify.
483+
The commit history scan, by default, examines the repository’s entire commit history, all the way back to the initial commit. You can instead limit the scan to a specific commit range by adding the argument `--commit-range` (`-r`) followed by the name you specify.
484484
485485
Consider the previous example. If you wanted to scan only specific commits in your repository, you could execute the following:
486486
487-
`cycode scan commit_history -r {{from-commit-id}}...{{to-commit-id}} ~/home/git/codebase`
487+
`cycode scan commit-history -r {{from-commit-id}}...{{to-commit-id}} ~/home/git/codebase`
488488
489489
### Pre-Commit Scan
490490
@@ -823,7 +823,7 @@ The following commands are available for use with this command:
823823
| Command | Description |
824824
|------------------|-----------------------------------------------------------------|
825825
| `path` | Generate SBOM report for provided path in the command |
826-
| `repository_url` | Generate SBOM report for provided repository URI in the command |
826+
| `repository-url` | Generate SBOM report for provided repository URI in the command |
827827
828828
### Repository
829829

cycode/cli/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@
2525
rich_utils.RICH_HELP = "Try [cyan]'{command_path} {help_option}'[/] for help."
2626

2727

28+
_cycode_cli_docs = 'https://github.com/cycodehq/cycode-cli/blob/main/README.md'
29+
_cycode_cli_epilog = f"""[bold]Documentation[/]
30+
31+
32+
33+
For more details and advanced usage, visit: [link={_cycode_cli_docs}]{_cycode_cli_docs}[/link]
34+
"""
35+
2836
app = typer.Typer(
2937
pretty_exceptions_show_locals=False,
3038
pretty_exceptions_short=True,
3139
context_settings=CLI_CONTEXT_SETTINGS,
40+
epilog=_cycode_cli_epilog,
3241
rich_markup_mode='rich',
3342
no_args_is_help=True,
3443
add_completion=False, # we add it manually to control the rich help panel
@@ -125,6 +134,7 @@ def app_callback(
125134
),
126135
] = False,
127136
) -> None:
137+
"""[bold cyan]Cycode CLI - Command Line Interface for Cycode.[/]"""
128138
init_sentry()
129139
add_breadcrumb('cycode')
130140

cycode/cli/apps/ai_remediation/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22

33
from cycode.cli.apps.ai_remediation.ai_remediation_command import ai_remediation_command
44

5-
app = typer.Typer(no_args_is_help=True)
6-
app.command(name='ai-remediation', short_help='Get AI remediation (INTERNAL).', hidden=True)(ai_remediation_command)
5+
app = typer.Typer()
6+
7+
_ai_remediation_epilog = """
8+
Note: AI remediation suggestions are generated automatically and should be reviewed before applying.
9+
"""
10+
11+
app.command(
12+
name='ai-remediation',
13+
short_help='Get AI remediation (INTERNAL).',
14+
epilog=_ai_remediation_epilog,
15+
hidden=True,
16+
no_args_is_help=True,
17+
)(ai_remediation_command)
718

819
# backward compatibility
920
app.command(hidden=True, name='ai_remediation')(ai_remediation_command)

cycode/cli/apps/ai_remediation/ai_remediation_command.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ def ai_remediation_command(
1616
bool, typer.Option('--fix', help='Apply fixes to resolve violations. Note: fix could be not available.')
1717
] = False,
1818
) -> None:
19-
"""Get AI remediation (INTERNAL)."""
19+
""":robot: [bold cyan]Get AI-powered remediation for security issues.[/]
20+
21+
This command provides AI-generated remediation guidance for detected security issues.
22+
23+
Example usage:
24+
* `cycode ai-remediation <detection_id>`: View remediation guidance
25+
* `cycode ai-remediation <detection_id> --fix`: Apply suggested fixes
26+
"""
2027
client = get_scan_cycode_client()
2128

2229
try:

cycode/cli/apps/auth/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import typer
22

33
from cycode.cli.apps.auth.auth_command import auth_command
4-
from cycode.cli.apps.auth.check_command import check_command
5-
6-
app = typer.Typer(
7-
name='auth',
8-
help='Authenticate your machine to associate the CLI with your Cycode account.',
9-
no_args_is_help=True,
10-
)
11-
app.callback(invoke_without_command=True)(auth_command)
12-
app.command(name='check')(check_command)
4+
5+
_auth_command_docs = 'https://github.com/cycodehq/cycode-cli/blob/main/README.md#using-the-auth-command'
6+
_auth_command_epilog = f"""[bold]Documentation[/]
7+
8+
9+
10+
For more details and advanced usage, visit: [link={_auth_command_docs}]{_auth_command_docs}[/link]
11+
"""
12+
13+
app = typer.Typer(no_args_is_help=False)
14+
app.command(name='auth', epilog=_auth_command_epilog, short_help='Authenticate your machine with Cycode.')(auth_command)

cycode/cli/apps/auth/auth_command.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88

99

1010
def auth_command(ctx: typer.Context) -> None:
11-
"""Authenticates your machine."""
11+
""":key: [bold cyan]Authenticate your machine with Cycode.[/]
12+
13+
This command handles authentication with Cycode's security platform.
14+
15+
Example usage:
16+
* `cycode auth`: Start interactive authentication
17+
* `cycode auth --help`: View authentication options
18+
"""
1219
add_breadcrumb('auth')
1320
printer = ctx.obj.get('console_printer')
1421

15-
if ctx.invoked_subcommand is not None:
16-
# if it is a subcommand, do nothing
17-
return
18-
1922
try:
2023
logger.debug('Starting authentication process')
2124

cycode/cli/apps/auth/auth_common.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
from typing import Optional
2-
3-
import typer
1+
from typing import TYPE_CHECKING, Optional
42

53
from cycode.cli.apps.auth.models import AuthInfo
64
from cycode.cli.exceptions.custom_exceptions import HttpUnauthorizedError, RequestHttpError
75
from cycode.cli.user_settings.credentials_manager import CredentialsManager
86
from cycode.cli.utils.jwt_utils import get_user_and_tenant_ids_from_access_token
97
from cycode.cyclient.cycode_token_based_client import CycodeTokenBasedClient
108

9+
if TYPE_CHECKING:
10+
from typer import Context
11+
1112

12-
def get_authorization_info(ctx: Optional[typer.Context] = None) -> Optional[AuthInfo]:
13+
def get_authorization_info(ctx: 'Context') -> Optional[AuthInfo]:
1314
printer = ctx.obj.get('console_printer')
1415

1516
client_id, client_secret = CredentialsManager().get_credentials()

cycode/cli/apps/auth/auth_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
import webbrowser
3-
from typing import TYPE_CHECKING, Tuple
3+
from typing import TYPE_CHECKING
44

55
from cycode.cli.exceptions.custom_exceptions import AuthProcessError
66
from cycode.cli.user_settings.configuration_manager import ConfigurationManager
@@ -78,7 +78,7 @@ def get_api_token_polling(self, session_id: str, code_verifier: str) -> 'ApiToke
7878
def save_api_token(self, api_token: 'ApiToken') -> None:
7979
self.credentials_manager.update_credentials(api_token.client_id, api_token.secret)
8080

81-
def _generate_pkce_code_pair(self) -> Tuple[str, str]:
81+
def _generate_pkce_code_pair(self) -> tuple[str, str]:
8282
code_verifier = generate_random_string(self.CODE_VERIFIER_LENGTH)
8383
code_challenge = hash_string_to_sha256(code_verifier)
8484
return code_challenge, code_verifier

cycode/cli/apps/auth/check_command.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

cycode/cli/apps/configure/__init__.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
from cycode.cli.apps.configure.configure_command import configure_command
44

5+
_configure_command_docs = 'https://github.com/cycodehq/cycode-cli/blob/main/README.md#using-the-configure-command'
6+
_configure_command_epilog = f"""[bold]Documentation[/]
7+
8+
9+
10+
For more details and advanced usage, visit: [link={_configure_command_docs}]{_configure_command_docs}[/link]
11+
"""
12+
13+
514
app = typer.Typer(no_args_is_help=True)
6-
app.command(name='configure', short_help='Initial command to configure your CLI client authentication.')(
7-
configure_command
8-
)
15+
app.command(
16+
name='configure',
17+
epilog=_configure_command_epilog,
18+
short_help='Initial command to configure your CLI client authentication.',
19+
)(configure_command)

cycode/cli/apps/configure/configure_command.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ def _should_update_value(
2323

2424

2525
def configure_command() -> None:
26-
"""Configure your CLI client authentication manually."""
26+
""":gear: [bold cyan]Configure Cycode CLI settings.[/]
27+
28+
This command allows you to configure various aspects of the Cycode CLI.
29+
30+
Configuration options:
31+
* API URL: The base URL for Cycode's API (for on-premise or EU installations)
32+
* APP URL: The base URL for Cycode's web application (for on-premise or EU installations)
33+
* Client ID: Your Cycode client ID for authentication
34+
* Client Secret: Your Cycode client secret for authentication
35+
36+
Example usage:
37+
* `cycode configure`: Start interactive configuration
38+
* `cycode configure --help`: View configuration options
39+
"""
2740
add_breadcrumb('configure')
2841

2942
global_config_manager = CONFIGURATION_MANAGER.global_config_file_manager

cycode/cli/apps/ignore/ignore_command.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ def ignore_command( # noqa: C901
8383
bool, typer.Option('--global', '-g', help='Add an ignore rule to the global CLI config.')
8484
] = False,
8585
) -> None:
86-
"""Ignores a specific value, path or rule ID."""
86+
""":no_entry: [bold cyan]Ignore specific findings or paths in scans.[/]
87+
88+
This command allows you to exclude specific items from Cycode scans, including:
89+
* Paths: Exclude specific files or directories
90+
* Rules: Ignore specific security rules
91+
* Values: Exclude specific sensitive values
92+
* Packages: Ignore specific package versions
93+
* CVEs: Exclude specific vulnerabilities
94+
95+
Example usage:
96+
* `cycode ignore --by-path .env`: Ignore the tests directory
97+
* `cycode ignore --by-rule GUID`: Ignore rule with the specified GUID
98+
* `cycode ignore --by-package lodash@4.17.21`: Ignore lodash version 4.17.21
99+
"""
87100
add_breadcrumb('ignore')
88101

89102
all_by_values = [by_value, by_sha, by_path, by_rule, by_package, by_cve]
@@ -145,4 +158,4 @@ def ignore_command( # noqa: C901
145158
'exclusion_value': exclusion_value,
146159
},
147160
)
148-
configuration_manager.add_exclusion(configuration_scope, scan_type, exclusion_type, exclusion_value)
161+
configuration_manager.add_exclusion(configuration_scope, str(scan_type), exclusion_type, exclusion_value)

cycode/cli/apps/report/report_command.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66

77
def report_command(ctx: typer.Context) -> int:
8-
"""Generate report."""
8+
""":bar_chart: [bold cyan]Generate security reports.[/]
9+
10+
Example usage:
11+
* `cycode report sbom`: Generate SBOM report
12+
"""
913
add_breadcrumb('report')
1014
ctx.obj['progress_bar'] = get_progress_bar(hidden=False, sections=SBOM_REPORT_PROGRESS_BAR_SECTIONS)
1115
return 1

0 commit comments

Comments
 (0)