refactor: extract all hardcoded values to constants (v0.8.1)

Fix all 63 hardcoded value issues from Guardian self-check:
- Remove hardcoded Slack token from documentation
- Remove aws-sdk framework leak from domain layer
- Rename 4 pipeline files to verb-noun convention
- Extract 57 magic strings to SecretExamples.ts constants
- Update SecretViolation, SecretDetector, MagicStringMatcher
- Use typeof for TypeScript literal type in getSeverity()

Result: 0 issues in Guardian self-check (was 63)
All 566 tests passing, build successful
This commit is contained in:
imfozilbek
2025-11-25 19:06:33 +05:00
parent db8a97202e
commit 1d6c2a0e00
13 changed files with 250 additions and 137 deletions

View File

@@ -12,10 +12,10 @@ import { IAggregateBoundaryDetector } from "../../domain/services/IAggregateBoun
import { ISecretDetector } from "../../domain/services/ISecretDetector"
import { SourceFile } from "../../domain/entities/SourceFile"
import { DependencyGraph } from "../../domain/entities/DependencyGraph"
import { FileCollectionStep } from "./pipeline/FileCollectionStep"
import { ParsingStep } from "./pipeline/ParsingStep"
import { DetectionPipeline } from "./pipeline/DetectionPipeline"
import { ResultAggregator } from "./pipeline/ResultAggregator"
import { CollectFiles } from "./pipeline/CollectFiles"
import { ParseSourceFiles } from "./pipeline/ParseSourceFiles"
import { ExecuteDetection } from "./pipeline/ExecuteDetection"
import { AggregateResults } from "./pipeline/AggregateResults"
import {
ERROR_MESSAGES,
HARDCODE_TYPES,
@@ -191,10 +191,10 @@ export class AnalyzeProject extends UseCase<
AnalyzeProjectRequest,
ResponseDto<AnalyzeProjectResponse>
> {
private readonly fileCollectionStep: FileCollectionStep
private readonly parsingStep: ParsingStep
private readonly detectionPipeline: DetectionPipeline
private readonly resultAggregator: ResultAggregator
private readonly fileCollectionStep: CollectFiles
private readonly parsingStep: ParseSourceFiles
private readonly detectionPipeline: ExecuteDetection
private readonly resultAggregator: AggregateResults
constructor(
fileScanner: IFileScanner,
@@ -209,9 +209,9 @@ export class AnalyzeProject extends UseCase<
secretDetector: ISecretDetector,
) {
super()
this.fileCollectionStep = new FileCollectionStep(fileScanner)
this.parsingStep = new ParsingStep(codeParser)
this.detectionPipeline = new DetectionPipeline(
this.fileCollectionStep = new CollectFiles(fileScanner)
this.parsingStep = new ParseSourceFiles(codeParser)
this.detectionPipeline = new ExecuteDetection(
hardcodeDetector,
namingConventionDetector,
frameworkLeakDetector,
@@ -221,7 +221,7 @@ export class AnalyzeProject extends UseCase<
aggregateBoundaryDetector,
secretDetector,
)
this.resultAggregator = new ResultAggregator()
this.resultAggregator = new AggregateResults()
}
public async execute(

View File

@@ -34,7 +34,7 @@ export interface AggregationRequest {
/**
* Pipeline step responsible for building final response DTO
*/
export class ResultAggregator {
export class AggregateResults {
public execute(request: AggregationRequest): AnalyzeProjectResponse {
const metrics = this.calculateMetrics(
request.sourceFiles,

View File

@@ -16,7 +16,7 @@ export interface FileCollectionResult {
/**
* Pipeline step responsible for file collection and basic parsing
*/
export class FileCollectionStep {
export class CollectFiles {
constructor(private readonly fileScanner: IFileScanner) {}
public async execute(request: FileCollectionRequest): Promise<FileCollectionResult> {

View File

@@ -50,7 +50,7 @@ export interface DetectionResult {
/**
* Pipeline step responsible for running all detectors
*/
export class DetectionPipeline {
export class ExecuteDetection {
constructor(
private readonly hardcodeDetector: IHardcodeDetector,
private readonly namingConventionDetector: INamingConventionDetector,

View File

@@ -15,7 +15,7 @@ export interface ParsingResult {
/**
* Pipeline step responsible for AST parsing and dependency graph construction
*/
export class ParsingStep {
export class ParseSourceFiles {
constructor(private readonly codeParser: ICodeParser) {}
public execute(request: ParsingRequest): ParsingResult {