Securelog scan allows you to define custom detectors using a YAML configuration file, making it easy to scan for organization-specific secrets or APIs not yet covered by the built-in detectors.
sls scan --dir . --config "sls.config.yml"
Create a sls.config.yml
file with the following structure:
detectors:
detector_name:
regex: string | object
keywords: string[]
detectorType: string
group?: string[] # Optional
exclude:
paths: string[]
extensions: string[]
detectors:
paystack:
regex: "\\bsk\\_[a-z]{1,}\\_[A-Za-z0-9]{40}\\b"
keywords: ["paystack"]
detectorType: "Paystack"
detectors:
mailgun:
regex:
"Original Token": "\\b([a-zA-Z-0-9]{72})\\b"
"Key-Mailgun Token": "\\b(key-[a-z0-9]{32})\\b"
"Hex Mailgun Token": "\\b([a-f0-9]{32}-[a-f0-9]{8}-[a-f0-9]{8})\\b"
keywords: ["mailgun"]
detectorType: "Mailgun"
regex
: String or object containing regex patterns- Single pattern: Use a string value
- Multiple patterns: Use an object with named patterns
keywords
: Array of trigger words for the detectordetectorType
: Unique identifier for the detectorgroup
: Optional array for grouping related patterns
paths
: Directories to skip during scanningextensions
: File types to ignore
- Always use double escaped backslashes (
\\b
not\b
) - Use word boundaries (
\\b
) to prevent partial matches - Be specific with character classes and lengths
- Consider all possible format variations
detectors:
custom_api:
regex: "\\bapi_[a-zA-Z0-9]{32}\\b"
keywords: ["custom_api"]
detectorType: "CustomAPI"
detectors:
internal_service:
regex:
"Production": "\\bprod_[a-zA-Z0-9]{40}\\b"
"Staging": "\\bstg_[a-zA-Z0-9]{40}\\b"
keywords: ["internal"]
detectorType: "InternalService"
group: ["internal_keys"]
detectors:
paystack:
regex: "\\bsk\\_[a-z]{1,}\\_[A-Za-z0-9]{40}\\b"
keywords: ["paystack"]
detectorType: "Paystack"
mailgun:
regex:
"Original Token": "\\b([a-zA-Z-0-9]{72})\\b"
"Key-Mailgun Token": "\\b(key-[a-z0-9]{32})\\b"
keywords: ["mailgun"]
detectorType: "Mailgun"
exclude:
paths:
- "node_modules"
- "dist"
extensions:
- ".png"
- ".jpg"
- ".log"
-
Pattern Design
- Use word boundaries (
\\b
) to prevent false positives - Be specific with character lengths
- Include environment indicators when applicable
- Group related patterns together
- Use word boundaries (
-
Keywords
- Include common variations of service names
- Consider abbreviated forms
- Include relevant environment terms
-
Exclusions
- Exclude build directories
- Skip binary and media files
- Ignore log files to prevent noise
-
Maintenance
- Document pattern explanations
- Group related services
- Update patterns when token formats change
-
False Positives
- Make patterns more specific
- Use word boundaries
- Include service-specific prefixes
-
Missing Matches
- Check for format variations
- Include all possible prefixes
- Consider case sensitivity
-
Performance
- Exclude unnecessary directories
- Be specific with file extensions
- Use efficient regex patterns