Skip to content

CLI-47 support multiple files & dir analysis with secrets#96

Open
sophio-japharidze-sonarsource wants to merge 1 commit intomasterfrom
CLI-47_secrets_multifile_analysis
Open

CLI-47 support multiple files & dir analysis with secrets#96
sophio-japharidze-sonarsource wants to merge 1 commit intomasterfrom
CLI-47_secrets_multifile_analysis

Conversation

@sophio-japharidze-sonarsource
Copy link
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 11, 2026

CLI-47

Copy link
Contributor

@jonas-wielage-sonarsource jonas-wielage-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick improvement here 💪
Please have a look at my comments to see if it's worth adding before merging

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the CLI-47_secrets_multifile_analysis branch from fad812c to f7aee28 Compare March 12, 2026 09:59
@sonarqubecloud
Copy link

SonarQube reviewer guide

Review in SonarQube

Summary: Refactor sonar analyze secrets command to accept multiple file/directory paths as positional arguments instead of a --file flag, improving CLI usability and flexibility.

Review Focus:

  • The core logic change in src/cli/commands/analyze/secrets.ts where performFileScan() becomes performPathsScan() to handle multiple paths with validation for each
  • Changes to command-tree.ts CLI argument parsing - ensure the argument binding [paths...] correctly passes arguments to the action handler
  • Validation logic updates in validateScanOptions() now checks array length instead of existence; verify error messages are clear

Start review at: src/cli/command-tree.ts. This file defines how CLI arguments are parsed and passed to the command handler, making it critical to verify the argument binding is correct before reviewing downstream logic.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
94.7% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Member

@kirill-knize-sonarsource kirill-knize-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

.option('--stdin', 'Read from standard input instead of paths')
.action((paths: string[], options: AnalyzeSecretsOptions) =>
runCommand(() =>
analyzeSecrets({ paths: Array.isArray(paths) ? paths : [], stdin: options.stdin }),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed we will need to think about coherent UX for all the analysis we will have. What happens if people call just parent command:
sonar analyze file1.txt file2.txt
What happens to analyzing commands who doesn't support multi-file analysis?

'sonar analyze secrets': [
{
command: 'sonar analyze secrets --file src/config.ts',
command: 'sonar analyze secrets src/config.ts',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no example that shows we can call with many files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants