mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
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
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { ICodeParser } from "../../../domain/services/ICodeParser"
|
|
import { SourceFile } from "../../../domain/entities/SourceFile"
|
|
import { DependencyGraph } from "../../../domain/entities/DependencyGraph"
|
|
|
|
export interface ParsingRequest {
|
|
sourceFiles: SourceFile[]
|
|
rootDir: string
|
|
}
|
|
|
|
export interface ParsingResult {
|
|
dependencyGraph: DependencyGraph
|
|
totalFunctions: number
|
|
}
|
|
|
|
/**
|
|
* Pipeline step responsible for AST parsing and dependency graph construction
|
|
*/
|
|
export class ParseSourceFiles {
|
|
constructor(private readonly codeParser: ICodeParser) {}
|
|
|
|
public execute(request: ParsingRequest): ParsingResult {
|
|
const dependencyGraph = new DependencyGraph()
|
|
let totalFunctions = 0
|
|
|
|
for (const sourceFile of request.sourceFiles) {
|
|
dependencyGraph.addFile(sourceFile)
|
|
|
|
if (sourceFile.path.isTypeScript()) {
|
|
const tree = this.codeParser.parseTypeScript(sourceFile.content)
|
|
const functions = this.codeParser.extractFunctions(tree)
|
|
totalFunctions += functions.length
|
|
}
|
|
|
|
for (const imp of sourceFile.imports) {
|
|
dependencyGraph.addDependency(
|
|
sourceFile.path.relative,
|
|
this.resolveImportPath(imp, sourceFile.path.relative, request.rootDir),
|
|
)
|
|
}
|
|
}
|
|
|
|
return { dependencyGraph, totalFunctions }
|
|
}
|
|
|
|
private resolveImportPath(importPath: string, _currentFile: string, _rootDir: string): string {
|
|
if (importPath.startsWith(".")) {
|
|
return importPath
|
|
}
|
|
return importPath
|
|
}
|
|
}
|