Scanner Configuration
Configuration File
The Secret Scanner is configured using a JSON file named bytehide.secrets.json in your project root. This file controls all aspects of the scanner's behavior.
{
"token": "<your-project-token>",
"appName": "My Python Project",
"environment": "production",
"sync": true,
"report": "security/scan-results.json",
"reportFormat": "json",
"anonymize": false,
"fix": false
}{
"token": "<your-project-token>",
"appName": "My Python Project",
"environment": "production",
"sync": true,
"report": "security/scan-results.json",
"reportFormat": "json",
"anonymize": false,
"fix": false
}Required Settings
Security Best Practice
It's recommended to use environment variables for sensitive settings rather than storing them in your configuration file. This helps prevent accidental secret exposure.
| Setting | Description |
|---|---|
token | Your ByteHide project token. For better security, use the BYTEHIDE_SECRETS_TOKEN environment variable instead. |
environment | The environment context (e.g., "development", "staging", "production"). Can be set with BYTEHIDE_SECRETS_ENVIRONMENT (defaults to "production" if missing). |
Optional Settings
| Setting | Default | Description |
|---|---|---|
appName | "MyApp" | A custom name for this scanner configuration. |
sync | true | Export detected secrets to ByteHide Secrets Manager. |
report | "" | Path to export a local report file (empty for no report). |
reportFormat | "json" | Format for local reports ("json" or "yaml"). |
anonymize | false | Mask actual secret values in logs and reports. |
fix | false | Automatically replace detected secrets with secure calls. |
CLI Commands
Configure the scanner behavior using command-line arguments that override the JSON configuration:
Initialization
bytehide-secrets initbytehide-secrets initThis interactive wizard helps you set up your scanner configuration.
Manual Scanning
bytehide-secrets scan [PATH] [OPTIONS]bytehide-secrets scan [PATH] [OPTIONS]| Option | Description |
|---|---|
--token | ByteHide project token |
--app-name | Application name for identification |
--environment | Environment name |
--sync / --no-sync | Export to ByteHide Secrets Manager |
--report | Path for local report file |
--report-format | Report format (json/yaml) |
--anonymize / --no-anonymize | Mask secret values |
--fix / --no-fix | Replace secrets with secure calls |
Example:
bytehide-secrets scan ./src --report ./reports/secrets.json --fixbytehide-secrets scan ./src --report ./reports/secrets.json --fixPython API Usage
You can also use the scanner programmatically in your Python code:
from bytehide_secrets_scanner import SecretsScanner
# Initialize scanner
scanner = SecretsScanner()
# Run a scan
exit_code = scanner.scan(
path="./src",
token="your-bytehide-token",
app_name="MyApp",
environment="production",
fix=True,
report="./scan-results.json",
report_format="json"
)
if exit_code == 0:
print("No secrets found!")
else:
print("Secrets detected. Check the report.")from bytehide_secrets_scanner import SecretsScanner
# Initialize scanner
scanner = SecretsScanner()
# Run a scan
exit_code = scanner.scan(
path="./src",
token="your-bytehide-token",
app_name="MyApp",
environment="production",
fix=True,
report="./scan-results.json",
report_format="json"
)
if exit_code == 0:
print("No secrets found!")
else:
print("Secrets detected. Check the report.")Detection Capabilities
The ByteHide Secrets Scanner includes advanced detection methods:
- Pattern Matching: Identifies known secret formats from over 6,000 detection rules
- Entropy Analysis: Detects high-entropy strings that may be secrets
- Contextual Analysis: Understands variable names and surrounding code
- Provider-Specific Plugins: Specialized detectors for AWS, Azure, GitHub, Stripe, and many more
Environment Variables
You can configure key settings using environment variables:
BYTEHIDE_SECRETS_TOKEN=your-project-token
BYTEHIDE_SECRETS_ENVIRONMENT=productionBYTEHIDE_SECRETS_TOKEN=your-project-token
BYTEHIDE_SECRETS_ENVIRONMENT=productionConfiguration Precedence
Settings are applied in the following order (later overrides earlier):
- Default values
bytehide.secrets.jsonfile- Environment variables
- Command-line arguments