SSF Toolkit User Guide: analyze credentials Command¶
Overview¶
This guide explains how to use the ssf_tools analyze credentials sub-command to detect embedded credentials in files for PCI SSF 2.3 compliance. You will learn how to scan for secrets, customize detection options, and review results in Excel. The tool integrates detect-secrets, which is automatically installed with kp-ssf-tools.
Prerequisites¶
- Python 3.13 or later
- SSF Toolkit installed
- Access to files or directories to analyze
Quick Start¶
To scan a file for embedded credentials, run:
To view all available options:
Usage¶
The analyze credentials command scans files and directories for hard-coded secrets such as passwords, API keys, and tokens. Results are exported to Excel, with per-file worksheets and a summary sheet for easy review.
Common Commands¶
ssf_tools analyze credentials <target>: Scan a file or directory for credentialsssf_tools analyze credentials src/ --file-extensions .py --no-recursive: Scan only Python files in a directory, non-recursively
Workflow¶
- Run the Analysis
- Execute the command with your desired options:
- The tool displays progress and summary information in the terminal.
-
Results are saved to an Excel file named
analyze-credentials-<timestamp>.xlsxin your working directory. -
Open the Excel Results
- Locate the generated Excel file.
-
Open it in Microsoft Excel or a compatible spreadsheet application.
-
Review the Findings
- Each worksheet corresponds to a scanned file; the summary sheet aggregates results.
- Columns include file name, line number, secret type, context lines, and match details.
-
Use Excel's filtering and sorting features to focus on high-risk findings.
-
Interpret and Act
- Investigate matches flagged as credentials or secrets.
- Use context lines to understand the surrounding code or data.
- Share or archive the Excel file for compliance documentation or further analysis.
Tips¶
- Use file extension filters to focus on relevant file types.
- Increase context lines for more code around each match.
- For large projects, consider disabling binary scanning to improve performance.
- See additional tuning considerations below.
Configuration¶
You can customize the credential detection using the following options:
| Option | Description |
|---|---|
--recursive/--no-recursive |
Search directories recursively for files to analyze (default=recursive |
--file-extensions |
File extensions to include (e.g., .py, .js, .txt). If not specified, all text files are analyzed |
--context-lines |
Number of context lines to show around matches (default=3) |
--scan-binary/--no-scan-binary |
Whether to scan binary files for embedded credentials |
--max-binary-size |
Maximum size in MB for binary files to scan (default=10) |
--help / -h |
Show help message and exit |
Tuning¶
- Use
--file-extensionsto limit scanning to specific file types and reduce noise. - Adjust
--context-linesto see more or less surrounding code for each match. - Disable binary scanning with
--no-scan-binaryfor faster results in source code repositories. - Increase
--max-binary-sizeif you expect large binaries to contain secrets.
Example: Customizing Analysis¶
ssf_tools analyze credentials src/ --file-extensions .py --context-lines 5 --no-scan-binary --no-recursive
This command scans only Python files in the src/ directory, shows five lines of context around each match, skips binary files, and disables recursion.
Example: Scanning All Files Recursively¶
This command scans all supported files in the project/ directory and subdirectories for embedded credentials.
Advanced Features¶
- Exports results to Excel with per-file worksheets and a summary sheet
- Integrates
detect-secretsfor robust secret detection - Supports verbose output for detailed progress
Troubleshooting¶
- If no files are found, check your target path and file extension filters
- For Excel export issues, review file size and worksheet limits
- Use verbose mode for more detailed output
FAQ¶
- Q: How do I scan only JavaScript files?
A: Use
--file-extensions .js. - Q: Can I see more code around each match?
A: Yes, increase
--context-lines. - Q: What is
detect-secrets? A: It is an open-source tool for finding secrets in code, included with SSF Toolkit.
Additional Resources¶
Use this guide to get started with credential detection. Adjust options as needed for your workflow and refer to other guides for advanced topics.