mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
Add critical security feature to detect 350+ types of hardcoded secrets
using industry-standard Secretlint library.
Features:
- Detect AWS keys, GitHub tokens, NPM tokens, SSH keys, API keys, etc.
- All secrets marked as CRITICAL severity
- Context-aware remediation suggestions per secret type
- New SecretDetector using @secretlint/node
- New SecretViolation value object (100% test coverage)
- CLI output with "🔐 Secrets" section
- Async pipeline support for secret detection
Tests:
- Added 47 new tests (566 total, 100% pass rate)
- Coverage: 93.3% statements, 83.74% branches
- SecretViolation: 23 tests, 100% coverage
- SecretDetector: 24 tests
Dependencies:
- @secretlint/node: 11.2.5
- @secretlint/core: 11.2.5
- @secretlint/types: 11.2.5
- @secretlint/secretlint-rule-preset-recommend: 11.2.5
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { SecretViolation } from "../value-objects/SecretViolation"
|
|
|
|
/**
|
|
* Interface for detecting hardcoded secrets in source code
|
|
*
|
|
* Detects sensitive data like API keys, tokens, passwords, and credentials
|
|
* that should never be hardcoded in source code. Uses industry-standard
|
|
* Secretlint library for pattern matching.
|
|
*
|
|
* All detected secrets are marked as CRITICAL severity violations.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* const detector: ISecretDetector = new SecretDetector()
|
|
* const violations = await detector.detectAll(
|
|
* 'const AWS_KEY = "AKIA1234567890ABCDEF"',
|
|
* 'src/config/aws.ts'
|
|
* )
|
|
*
|
|
* violations.forEach(v => {
|
|
* console.log(v.getMessage()) // "Hardcoded AWS Access Key detected"
|
|
* })
|
|
* ```
|
|
*/
|
|
export interface ISecretDetector {
|
|
/**
|
|
* Detect all types of hardcoded secrets in the provided code
|
|
*
|
|
* @param code - Source code to analyze
|
|
* @param filePath - Path to the file being analyzed
|
|
* @returns Array of secret violations found
|
|
*/
|
|
detectAll(code: string, filePath: string): Promise<SecretViolation[]>
|
|
}
|