mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
refactor: migrate hardcode detector from regex to AST-based analysis
- Replace regex-based matchers with tree-sitter AST traversal - Add duplicate value tracking across files - Implement boolean literal detection - Add value type classification (email, url, ip, api_key, etc.) - Improve context awareness with AST node analysis - Reduce false positives with better constant detection Breaking changes removed: - BraceTracker.ts - ExportConstantAnalyzer.ts - MagicNumberMatcher.ts - MagicStringMatcher.ts New components added: - AstTreeTraverser for AST walking - DuplicateValueTracker for cross-file tracking - AstContextChecker for node context analysis - AstNumberAnalyzer, AstStringAnalyzer, AstBooleanAnalyzer - ValuePatternMatcher for type detection Test coverage: 87.97% statements, 96.75% functions
This commit is contained in:
@@ -11,6 +11,7 @@ import { IRepositoryPatternDetector } from "../../domain/services/RepositoryPatt
|
||||
import { IAggregateBoundaryDetector } from "../../domain/services/IAggregateBoundaryDetector"
|
||||
import { ISecretDetector } from "../../domain/services/ISecretDetector"
|
||||
import { IAnemicModelDetector } from "../../domain/services/IAnemicModelDetector"
|
||||
import { IDuplicateValueTracker } from "../../domain/services/IDuplicateValueTracker"
|
||||
import { SourceFile } from "../../domain/entities/SourceFile"
|
||||
import { DependencyGraph } from "../../domain/entities/DependencyGraph"
|
||||
import { CollectFiles } from "./pipeline/CollectFiles"
|
||||
@@ -62,8 +63,9 @@ export interface HardcodeViolation {
|
||||
type:
|
||||
| typeof HARDCODE_TYPES.MAGIC_NUMBER
|
||||
| typeof HARDCODE_TYPES.MAGIC_STRING
|
||||
| typeof HARDCODE_TYPES.MAGIC_BOOLEAN
|
||||
| typeof HARDCODE_TYPES.MAGIC_CONFIG
|
||||
value: string | number
|
||||
value: string | number | boolean
|
||||
file: string
|
||||
line: number
|
||||
column: number
|
||||
@@ -225,6 +227,7 @@ export class AnalyzeProject extends UseCase<
|
||||
aggregateBoundaryDetector: IAggregateBoundaryDetector,
|
||||
secretDetector: ISecretDetector,
|
||||
anemicModelDetector: IAnemicModelDetector,
|
||||
duplicateValueTracker: IDuplicateValueTracker,
|
||||
) {
|
||||
super()
|
||||
this.fileCollectionStep = new CollectFiles(fileScanner)
|
||||
@@ -239,6 +242,7 @@ export class AnalyzeProject extends UseCase<
|
||||
aggregateBoundaryDetector,
|
||||
secretDetector,
|
||||
anemicModelDetector,
|
||||
duplicateValueTracker,
|
||||
)
|
||||
this.resultAggregator = new AggregateResults()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user