Skip to content

Commit 62b4907

Browse files
authored
CM-25653 - Improve text messages (#149)
1 parent f8149a5 commit 62b4907

File tree

6 files changed

+61
-59
lines changed

6 files changed

+61
-59
lines changed

cycode/cli/auth/auth_command.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313

1414
@click.group(
15-
invoke_without_command=True, short_help='Authenticates your machine to associate CLI with your cycode account'
15+
invoke_without_command=True, short_help='Authenticate your machine to associate the CLI with your Cycode account.'
1616
)
1717
@click.pass_context
1818
def authenticate(context: click.Context) -> None:
19+
"""Authenticates your machine."""
1920
if context.invoked_subcommand is not None:
2021
# if it is a subcommand, do nothing
2122
return
@@ -32,14 +33,16 @@ def authenticate(context: click.Context) -> None:
3233
_handle_exception(context, e)
3334

3435

35-
@authenticate.command(name='check')
36+
@authenticate.command(
37+
name='check', short_help='Checks that your machine is associating the CLI with your Cycode account.'
38+
)
3639
@click.pass_context
3740
def authorization_check(context: click.Context) -> None:
38-
"""Check your machine associating CLI with your cycode account"""
41+
"""Validates that your Cycode account has permission to work with the CLI."""
3942
printer = ConsolePrinter(context)
4043

41-
passed_auth_check_res = CliResult(success=True, message='You are authorized')
42-
failed_auth_check_res = CliResult(success=False, message='You are not authorized')
44+
passed_auth_check_res = CliResult(success=True, message='Cycode authentication verified')
45+
failed_auth_check_res = CliResult(success=False, message='Cycode authentication failed')
4346

4447
client_id, client_secret = CredentialsManager().get_credentials()
4548
if not client_id or not client_secret:

cycode/cli/code_scanner.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
start_scan_time = time.time()
5252

5353

54-
@click.command(short_help='Scan git repository including its history')
54+
@click.command(short_help='Scan the git repository including its history.')
5555
@click.argument('path', nargs=1, type=click.STRING, required=True)
5656
@click.option(
5757
'--branch',
@@ -72,6 +72,7 @@ def scan_repository(context: click.Context, path: str, branch: str) -> None:
7272
raise click.ClickException('Monitor flag is currently supported for SCA scan type only')
7373

7474
progress_bar = context.obj['progress_bar']
75+
progress_bar.start()
7576

7677
file_entries = list(get_git_repository_tree_file_entries(path, branch))
7778
progress_bar.set_section_length(ProgressBarSection.PREPARE_LOCAL_FILES, len(file_entries))
@@ -96,7 +97,7 @@ def scan_repository(context: click.Context, path: str, branch: str) -> None:
9697
_handle_exception(context, e)
9798

9899

99-
@click.command(short_help='Scan all the commits history in this git repository')
100+
@click.command(short_help='Scan all the commits history in this git repository.')
100101
@click.argument('path', nargs=1, type=click.STRING, required=True)
101102
@click.option(
102103
'--commit_range',
@@ -119,7 +120,9 @@ def scan_commit_range(
119120
context: click.Context, path: str, commit_range: str, max_commits_count: Optional[int] = None
120121
) -> None:
121122
scan_type = context.obj['scan_type']
123+
122124
progress_bar = context.obj['progress_bar']
125+
progress_bar.start()
123126

124127
if scan_type not in consts.COMMIT_RANGE_SCAN_SUPPORTED_SCAN_TYPES:
125128
raise click.ClickException(f'Commit range scanning for {str.upper(scan_type)} is not supported')
@@ -185,13 +188,14 @@ def scan_ci(context: click.Context) -> None:
185188
scan_commit_range(context, path=os.getcwd(), commit_range=get_commit_range())
186189

187190

188-
@click.command(short_help='Scan the files in the path supplied in the command')
191+
@click.command(short_help='Scan the files in the path provided in the command.')
189192
@click.argument('path', nargs=1, type=click.STRING, required=True)
190193
@click.pass_context
191194
def scan_path(context: click.Context, path: str) -> None:
192-
logger.debug('Starting path scan process, %s', {'path': path})
193-
194195
progress_bar = context.obj['progress_bar']
196+
progress_bar.start()
197+
198+
logger.debug('Starting path scan process, %s', {'path': path})
195199

196200
all_files_to_scan = get_relevant_files_in_path(path=path, exclude_patterns=['**/.git/**', '**/.cycode/**'])
197201

@@ -218,12 +222,14 @@ def scan_path(context: click.Context, path: str) -> None:
218222
scan_disk_files(context, path, relevant_files_to_scan)
219223

220224

221-
@click.command(short_help='Use this command to scan the content that was not committed yet')
225+
@click.command(short_help='Use this command to scan any content that was not committed yet.')
222226
@click.argument('ignored_args', nargs=-1, type=click.UNPROCESSED)
223227
@click.pass_context
224228
def pre_commit_scan(context: click.Context, ignored_args: List[str]) -> None:
225229
scan_type = context.obj['scan_type']
230+
226231
progress_bar = context.obj['progress_bar']
232+
progress_bar.start()
227233

228234
if scan_type == consts.SCA_SCAN_TYPE:
229235
scan_sca_pre_commit(context)
@@ -242,7 +248,7 @@ def pre_commit_scan(context: click.Context, ignored_args: List[str]) -> None:
242248
scan_documents(context, documents_to_scan, is_git_diff=True)
243249

244250

245-
@click.command(short_help='Use this command to scan commits on the server side before pushing them to the repository')
251+
@click.command(short_help='Use this command to scan commits on the server side before pushing them to the repository.')
246252
@click.argument('ignored_args', nargs=-1, type=click.UNPROCESSED)
247253
@click.pass_context
248254
def pre_receive_scan(context: click.Context, ignored_args: List[str]) -> None:
@@ -1160,7 +1166,7 @@ def _handle_exception(context: click.Context, e: Exception, *, return_exception:
11601166
soft_fail=False,
11611167
code='invalid_git_error',
11621168
message='The path you supplied does not correlate to a git repository. '
1163-
'Should you still wish to scan this path, use: `cycode scan path <path>`',
1169+
'If you still wish to scan this path, use: `cycode scan path <path>`',
11641170
),
11651171
}
11661172

cycode/cli/consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
PROGRAM_NAME = 'cycode'
2+
CLI_CONTEXT_SETTINGS = {
3+
'terminal_width': 10**9,
4+
'max_content_width': 10**9,
5+
}
26

37
PRE_COMMIT_COMMAND_SCAN_TYPE = 'pre_commit'
48
PRE_RECEIVE_COMMAND_SCAN_TYPE = 'pre_receive'

cycode/cli/main.py

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from cycode.cli import code_scanner
1010
from cycode.cli.auth.auth_command import authenticate
1111
from cycode.cli.config import config
12-
from cycode.cli.consts import ISSUE_DETECTED_STATUS_CODE, NO_ISSUES_STATUS_CODE, PROGRAM_NAME
12+
from cycode.cli.consts import CLI_CONTEXT_SETTINGS, ISSUE_DETECTED_STATUS_CODE, NO_ISSUES_STATUS_CODE, PROGRAM_NAME
1313
from cycode.cli.models import Severity
1414
from cycode.cli.user_settings.configuration_manager import ConfigurationManager
1515
from cycode.cli.user_settings.credentials_manager import CredentialsManager
@@ -25,8 +25,6 @@
2525
if TYPE_CHECKING:
2626
from cycode.cyclient.scan_client import ScanClient
2727

28-
CONTEXT = {}
29-
3028

3129
@click.group(
3230
commands={
@@ -36,75 +34,68 @@
3634
'pre_commit': code_scanner.pre_commit_scan,
3735
'pre_receive': code_scanner.pre_receive_scan,
3836
},
39-
short_help='Scan content for secrets/IaC/sca/SAST violations. '
40-
'You need to specify which scan type: ci/commit_history/path/repository/etc',
37+
short_help='Scan the content for Secrets/IaC/SCA/SAST violations. '
38+
'You`ll need to specify which scan type to perform: ci/commit_history/path/repository/etc.',
4139
)
4240
@click.option(
4341
'--scan-type',
4442
'-t',
4543
default='secret',
46-
help="""
47-
\b
48-
Specify the scan you wish to execute (secret/iac/sca),
49-
the default is secret
50-
""",
44+
help='Specify the type of scan you wish to execute (the default is Secrets)',
5145
type=click.Choice(config['scans']['supported_scans']),
5246
)
5347
@click.option(
5448
'--secret',
5549
default=None,
56-
help='Specify a Cycode client secret for this specific scan execution',
50+
help='Specify a Cycode client secret for this specific scan execution.',
5751
type=str,
5852
required=False,
5953
)
6054
@click.option(
6155
'--client-id',
6256
default=None,
63-
help='Specify a Cycode client ID for this specific scan execution',
57+
help='Specify a Cycode client ID for this specific scan execution.',
6458
type=str,
6559
required=False,
6660
)
6761
@click.option(
68-
'--show-secret', is_flag=True, default=False, help='Show secrets in plain text', type=bool, required=False
62+
'--show-secret', is_flag=True, default=False, help='Show Secrets in plain text.', type=bool, required=False
6963
)
7064
@click.option(
7165
'--soft-fail',
7266
is_flag=True,
7367
default=False,
74-
help='Run scan without failing, always return a non-error status code',
68+
help='Run the scan without failing; always return a non-error status code.',
7569
type=bool,
7670
required=False,
7771
)
7872
@click.option(
7973
'--severity-threshold',
8074
default=None,
81-
help='Show only violations at the specified level or higher (supported for SCA scan type only).',
75+
help='Show violations only for the specified level or higher (supported for SCA scan types only).',
8276
type=click.Choice([e.name for e in Severity]),
8377
required=False,
8478
)
8579
@click.option(
8680
'--sca-scan',
8781
default=None,
88-
help='Specify the sca scan you wish to execute (package-vulnerabilities/license-compliance), the default is both',
82+
help='Specify the type of SCA scan you wish to execute (the default is both).',
8983
multiple=True,
9084
type=click.Choice(config['scans']['supported_sca_scans']),
9185
)
9286
@click.option(
9387
'--monitor',
9488
is_flag=True,
9589
default=False,
96-
help="When specified, the scan results will be recorded in the knowledge graph. "
97-
"Please note that when working in 'monitor' mode, the knowledge graph "
98-
"will not be updated as a result of SCM events (Push, Repo creation).(supported for SCA scan type only).",
90+
help='Used for SCA scan types only; when specified, the scan results are recorded in the Discovery module.',
9991
type=bool,
10092
required=False,
10193
)
10294
@click.option(
10395
'--report',
10496
is_flag=True,
10597
default=False,
106-
help='When specified, a violations report will be generated. '
107-
'A URL link to the report will be printed as an output to the command execution',
98+
help='When specified, generates a violations report. A link to the report will be displayed in the console output.',
10899
type=bool,
109100
required=False,
110101
)
@@ -121,6 +112,7 @@ def code_scan(
121112
monitor: bool,
122113
report: bool,
123114
) -> int:
115+
"""Scans for Secrets, IaC, SCA or SAST violations."""
124116
if show_secret:
125117
context.obj['show_secret'] = show_secret
126118
else:
@@ -139,9 +131,6 @@ def code_scan(
139131

140132
_sca_scan_to_context(context, sca_scan)
141133

142-
context.obj['progress_bar'] = get_progress_bar(hidden=context.obj['no_progress_meter'])
143-
context.obj['progress_bar'].start()
144-
145134
return 1
146135

147136

@@ -162,7 +151,7 @@ def finalize(context: click.Context, *_, **__) -> None:
162151
sys.exit(exit_code)
163152

164153

165-
@click.command(short_help='Show the version and exit')
154+
@click.command(short_help='Show the CLI version and exit.')
166155
@click.pass_context
167156
def version(context: click.Context) -> None:
168157
output = context.obj['output']
@@ -186,32 +175,32 @@ def version(context: click.Context) -> None:
186175
'auth': authenticate,
187176
'version': version,
188177
},
189-
context_settings=CONTEXT,
178+
context_settings=CLI_CONTEXT_SETTINGS,
190179
)
191180
@click.option(
192181
'--verbose',
193182
'-v',
194183
is_flag=True,
195184
default=False,
196-
help='Show detailed logs',
185+
help='Show detailed logs.',
197186
)
198187
@click.option(
199188
'--no-progress-meter',
200189
is_flag=True,
201190
default=False,
202-
help='Do not show the progress meter',
191+
help='Do not show the progress meter.',
203192
)
204193
@click.option(
205194
'--output',
206195
'-o',
207196
default='text',
208-
help='Specify the output (text/json/table), the default is text',
197+
help='Specify the output type (the default is text).',
209198
type=click.Choice(['text', 'json', 'table']),
210199
)
211200
@click.option(
212201
'--user-agent',
213202
default=None,
214-
help='Characteristic JSON object that lets servers identify the application',
203+
help='Characteristic JSON object that lets servers identify the application.',
215204
type=str,
216205
)
217206
@click.pass_context
@@ -232,7 +221,7 @@ def main_cli(
232221
if output == 'json':
233222
no_progress_meter = True
234223

235-
context.obj['no_progress_meter'] = no_progress_meter
224+
context.obj['progress_bar'] = get_progress_bar(hidden=no_progress_meter)
236225

237226
if user_agent:
238227
user_agent_option = UserAgentOptionScheme().loads(user_agent)

cycode/cli/printers/tables/sca_table_printer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
5858
@staticmethod
5959
def _get_title(policy_id: str) -> str:
6060
if policy_id == PACKAGE_VULNERABILITY_POLICY_ID:
61-
return 'Dependencies Vulnerabilities'
61+
return 'Dependency Vulnerabilities'
6262
if policy_id == LICENSE_COMPLIANCE_POLICY_ID:
6363
return 'License Compliance'
6464

cycode/cli/user_settings/user_settings_commands.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323

2424
@click.command(
25-
short_help='Initial command to authenticate your CLI client with Cycode using client ID and client secret'
25+
short_help='Initial command to authenticate your CLI client with Cycode using a client ID and client secret.'
2626
)
2727
def set_credentials() -> None:
28+
"""Authenticates your CLI client with Cycode manually by using a client ID and client secret."""
2829
click.echo(f'Update credentials in file ({credentials_manager.get_filename()})')
2930
current_client_id, current_client_secret = credentials_manager.get_credentials_from_file()
3031
client_id = _get_client_id_input(current_client_id)
@@ -37,40 +38,39 @@ def set_credentials() -> None:
3738
click.echo(_get_credentials_update_result_message())
3839

3940

40-
@click.command()
41+
@click.command(short_help='Ignores a specific value, path or rule ID.')
4142
@click.option(
42-
'--by-value', type=click.STRING, required=False, help='Ignore a specific value while scanning for secrets'
43+
'--by-value', type=click.STRING, required=False, help='Ignore a specific value while scanning for Secrets.'
4344
)
4445
@click.option(
4546
'--by-sha',
4647
type=click.STRING,
4748
required=False,
48-
help='Ignore a specific SHA512 representation of a string while scanning for secrets',
49+
help='Ignore a specific SHA512 representation of a string while scanning for Secrets.',
4950
)
5051
@click.option(
51-
'--by-path', type=click.STRING, required=False, help='Avoid scanning a specific path. Need to specify scan type '
52+
'--by-path',
53+
type=click.STRING,
54+
required=False,
55+
help='Avoid scanning a specific path. You`ll need to specify the scan type.',
5256
)
5357
@click.option(
5458
'--by-rule',
5559
type=click.STRING,
5660
required=False,
57-
help='Ignore scanning a specific secret rule ID/IaC rule ID. Need to specify scan type.',
61+
help='Ignore scanning a specific secret rule ID or IaC rule ID. You`ll to specify the scan type.',
5862
)
5963
@click.option(
6064
'--by-package',
6165
type=click.STRING,
6266
required=False,
63-
help='Ignore scanning a specific package version while running SCA scan. expected pattern - name@version',
67+
help='Ignore scanning a specific package version while running an SCA scan. Expected pattern: name@version.',
6468
)
6569
@click.option(
6670
'--scan-type',
6771
'-t',
6872
default='secret',
69-
help="""
70-
\b
71-
Specify the scan you wish to execute (secrets/iac),
72-
the default is secrets
73-
""",
73+
help='Specify the type of scan you wish to execute (the default is Secrets).',
7474
type=click.Choice(config['scans']['supported_scans']),
7575
required=False,
7676
)
@@ -81,12 +81,12 @@ def set_credentials() -> None:
8181
is_flag=True,
8282
default=False,
8383
required=False,
84-
help='Add an ignore rule and update it in the global .cycode config file',
84+
help='Add an ignore rule to the global CLI config.',
8585
)
8686
def add_exclusions(
8787
by_value: str, by_sha: str, by_path: str, by_rule: str, by_package: str, scan_type: str, is_global: bool
8888
) -> None:
89-
"""Ignore a specific value, path or rule ID"""
89+
"""Ignores a specific value, path or rule ID."""
9090
if not by_value and not by_sha and not by_path and not by_rule and not by_package:
9191
raise click.ClickException('ignore by type is missing')
9292

0 commit comments

Comments
 (0)