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 Go Project",
"environment": "production",
"sync": true,
"report": "security/scan-results.json",
"reportFormat": "json",
"anonymize": false,
"fix": false
}{
"token": "<your-project-token>",
"appName": "My Go 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 flags 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] [FLAGS]bytehide-secrets scan [PATH] [FLAGS]| Flag | Description |
|---|---|
--token | ByteHide project token |
--app-name | Application name for identification |
--environment | Environment name |
--sync | Export to ByteHide Secrets Manager |
--report | Path for local report file |
--report-format | Report format (json/yaml) |
--anonymize | Mask secret values |
--fix | Replace secrets with secure calls |
Example:
bytehide-secrets scan ./src --report ./reports/secrets.json --fixbytehide-secrets scan ./src --report ./reports/secrets.json --fixUsing as a Library
You can also use the scanner programmatically in your Go code:
package main
import (
"fmt"
"os"
"github.com/bytehide/bytehide-secrets-scanner-wrappers/wrappers/go/pkg/scanner"
)
func main() {
s, err := scanner.NewScanner()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
opts := &scanner.ScanOptions{
Path: "./src",
Token: "your-bytehide-token",
AppName: "MyApp",
Environment: "production",
Fix: scanner.BoolPtr(true),
Report: "./scan-results.json",
ReportFormat: "json",
}
exitCode, err := s.Scan(opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
if exitCode == 0 {
fmt.Println("No secrets found!")
} else {
fmt.Println("Secrets detected. Check the report.")
}
}package main
import (
"fmt"
"os"
"github.com/bytehide/bytehide-secrets-scanner-wrappers/wrappers/go/pkg/scanner"
)
func main() {
s, err := scanner.NewScanner()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
opts := &scanner.ScanOptions{
Path: "./src",
Token: "your-bytehide-token",
AppName: "MyApp",
Environment: "production",
Fix: scanner.BoolPtr(true),
Report: "./scan-results.json",
ReportFormat: "json",
}
exitCode, err := s.Scan(opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
if exitCode == 0 {
fmt.Println("No secrets found!")
} else {
fmt.Println("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 flags