pumuki-ast-hooks 5.5.3 → 5.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/scripts/hooks-system/.audit-reports/auto-recovery.log +1 -0
- package/scripts/hooks-system/.audit-reports/install-wizard.log +4 -0
- package/scripts/hooks-system/.audit_tmp/audit.log +0 -0
- package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +24 -0
- package/scripts/hooks-system/.hook-system/config.json +8 -0
- package/scripts/hooks-system/application/CompositionRoot.js +31 -19
- package/scripts/hooks-system/application/factories/AdapterFactory.js +6 -6
- package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +0 -2
- package/scripts/hooks-system/application/services/RealtimeGuardService.js +146 -2
- package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +0 -1
- package/scripts/hooks-system/application/services/guard/EvidenceManager.js +31 -7
- package/scripts/hooks-system/application/services/guard/GitTreeManager.js +43 -11
- package/scripts/hooks-system/application/services/guard/GuardNotifier.js +2 -2
- package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +0 -2
- package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +0 -3
- package/scripts/hooks-system/application/services/installation/InstallService.js +0 -1
- package/scripts/hooks-system/application/services/installation/McpConfigurator.js +9 -2
- package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +1 -1
- package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +0 -2
- package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +0 -2
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +0 -3
- package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +22 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +1 -1
- package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +0 -1
- package/scripts/hooks-system/application/services/token/TokenMetricsService.js +1 -1
- package/scripts/hooks-system/application/services/token/TokenMonitorService.js +0 -1
- package/scripts/hooks-system/application/use-cases/AnalyzeCodebaseUseCase.js +0 -2
- package/scripts/hooks-system/application/use-cases/AnalyzeStagedFilesUseCase.js +0 -2
- package/scripts/hooks-system/application/use-cases/AutoExecuteAIStartUseCase.js +0 -1
- package/scripts/hooks-system/application/use-cases/BlockCommitUseCase.js +0 -2
- package/scripts/hooks-system/application/use-cases/GenerateAuditReportUseCase.js +0 -3
- package/scripts/hooks-system/bin/cli.js +16 -0
- package/scripts/hooks-system/domain/services/AuditResultSerializer.js +0 -5
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTIntelligentAnalyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTParser.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidArchitectureDetector.js +5 -7
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidClassAnalyzer.js +0 -3
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidForbiddenLiteralsAnalyzer.js +0 -1
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidSOLIDAnalyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/archive/ios-rules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/archive/kotlin-analyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/archive/kotlin-parser.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/archive/swift-analyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendArchitectureDetector.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/common/BDDTDDWorkflowRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/common/rules/BDDRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/common/rules/ImplementationRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/common/rules/TDDRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/common/rules/WorkflowRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendArchitectureDetector.js +14 -16
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendForbiddenLiteralsAnalyzer.js +0 -5
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendSOLIDAnalyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +17 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureDetector.js +10 -12
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSCICDRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSEnterpriseAnalyzer.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSForbiddenLiteralsAnalyzer.js +0 -1
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSNetworkingAdvancedRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSPerformanceRules.js +0 -3
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSPMRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSwiftUIAdvancedRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSTestingAdvancedRules.js +0 -2
- package/scripts/hooks-system/infrastructure/ast/ios/native-bridge.js +0 -1
- package/scripts/hooks-system/infrastructure/ast/ios/parsers/SourceKittenParser.js +0 -2
- package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +1 -1
- package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +149 -57
- package/scripts/hooks-system/infrastructure/mcp/services/McpProtocolHandler.js +14 -6
- package/scripts/hooks-system/infrastructure/repositories/CursorTokenRepository.js +0 -2
- package/scripts/hooks-system/infrastructure/repositories/FileFindingsRepository.js +0 -2
- package/scripts/hooks-system/infrastructure/repositories/datasources/CursorApiDataSource.js +1 -3
- package/scripts/hooks-system/infrastructure/repositories/datasources/CursorFileDataSource.js +0 -2
- package/scripts/hooks-system/infrastructure/severity/severity-evaluator.js +0 -2
- package/scripts/hooks-system/infrastructure/telemetry/TelemetryService.js +0 -2
- package/scripts/hooks-system/infrastructure/utils/token-manager.js +0 -2
- package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +1 -1
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log +6 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
4
3
|
|
|
5
4
|
class DevDocsMonitor {
|
|
6
5
|
constructor({
|
|
@@ -12,7 +11,6 @@ class DevDocsMonitor {
|
|
|
12
11
|
notificationService = null
|
|
13
12
|
} = {}) {
|
|
14
13
|
this.repoRoot = repoRoot;
|
|
15
|
-
this.auditLogger = new AuditLogger({ repoRoot, logger });
|
|
16
14
|
this.checkIntervalMs = checkIntervalMs;
|
|
17
15
|
this.staleThresholdMs = staleThresholdMs;
|
|
18
16
|
this.autoRefreshEnabled = autoRefreshEnabled;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
2
|
-
|
|
3
1
|
class GitTreeMonitorService {
|
|
4
2
|
constructor({
|
|
5
3
|
repoRoot = process.cwd(),
|
|
@@ -13,7 +11,6 @@ class GitTreeMonitorService {
|
|
|
13
11
|
debugLogger = null
|
|
14
12
|
} = {}) {
|
|
15
13
|
this.repoRoot = repoRoot;
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot, logger });
|
|
17
14
|
this.limit = limit;
|
|
18
15
|
this.warning = warning;
|
|
19
16
|
this.reminderMs = reminderMs;
|
|
@@ -87,6 +87,28 @@ class NotificationCenterService {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
notify(notification) {
|
|
91
|
+
if (!notification) return false;
|
|
92
|
+
|
|
93
|
+
const type = notification.type || 'generic';
|
|
94
|
+
const level = notification.level || 'info';
|
|
95
|
+
const message = notification.message || notification.title || '';
|
|
96
|
+
|
|
97
|
+
if (!String(message).trim()) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.enqueue({
|
|
102
|
+
type,
|
|
103
|
+
level,
|
|
104
|
+
message: String(message),
|
|
105
|
+
metadata: notification.metadata || {
|
|
106
|
+
title: notification.title,
|
|
107
|
+
sound: notification.sound
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
90
112
|
/**
|
|
91
113
|
* Enqueues a notification to be sent
|
|
92
114
|
*/
|
|
@@ -14,7 +14,6 @@ class AutoRecoveryManager {
|
|
|
14
14
|
} = {}) {
|
|
15
15
|
this.repoRoot = repoRoot;
|
|
16
16
|
this.logger = logger || console;
|
|
17
|
-
this.auditLogger = new AuditLogger({ repoRoot, logger });
|
|
18
17
|
this.notificationCenter = notificationCenter;
|
|
19
18
|
this.timers = timers;
|
|
20
19
|
this.maxAttempts = maxAttempts;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const AuditResult = require('../../domain/entities/AuditResult');
|
|
2
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
3
2
|
|
|
4
3
|
class AnalyzeCodebaseUseCase {
|
|
5
4
|
constructor(platformAnalyzers, findingsRepository, platformDetectionService) {
|
|
6
5
|
this.platformAnalyzers = platformAnalyzers;
|
|
7
6
|
this.findingsRepository = findingsRepository;
|
|
8
7
|
this.platformDetectionService = platformDetectionService;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
async execute(targetPath, options = {}) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
const AuditResult = require('../../domain/entities/AuditResult');
|
|
3
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
4
3
|
|
|
5
4
|
class AnalyzeStagedFilesUseCase {
|
|
6
5
|
constructor(platformAnalyzers, gitOperations, platformDetectionService) {
|
|
7
6
|
this.platformAnalyzers = platformAnalyzers;
|
|
8
7
|
this.gitOperations = gitOperations;
|
|
9
8
|
this.platformDetectionService = platformDetectionService;
|
|
10
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
async execute(options = {}) {
|
|
@@ -25,7 +25,6 @@ class AutoExecuteAIStartUseCase {
|
|
|
25
25
|
this.orchestrator = orchestrator;
|
|
26
26
|
this.repoRoot = repoRoot || process.cwd();
|
|
27
27
|
this.logger = logger;
|
|
28
|
-
this.auditLogger = new AuditLogger({ repoRoot: this.repoRoot, logger });
|
|
29
28
|
this.updateEvidenceScript = resolveUpdateEvidenceScript(this.repoRoot);
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
const CommitBlockingRules = require('../../domain/rules/CommitBlockingRules');
|
|
3
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
4
3
|
|
|
5
4
|
class BlockCommitUseCase {
|
|
6
5
|
constructor(commitBlockingRules) {
|
|
7
6
|
this.commitBlockingRules = commitBlockingRules || new CommitBlockingRules();
|
|
8
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
async execute(auditResult, options = {}) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
const AuditLogger = require('../logging/AuditLogger');
|
|
3
|
-
|
|
4
2
|
class GenerateAuditReportUseCase {
|
|
5
3
|
constructor(outputFormatter, auditAnalyzer, auditScorer) {
|
|
6
4
|
this.outputFormatter = outputFormatter;
|
|
7
5
|
this.auditAnalyzer = auditAnalyzer; // Inject Analyzer
|
|
8
6
|
this.auditScorer = auditScorer; // Inject Scorer
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
async execute(auditResult, options = {}) {
|
|
@@ -121,6 +121,22 @@ const commands = {
|
|
|
121
121
|
execSync(`bash ${path.join(HOOKS_ROOT, 'presentation/cli/audit.sh')}`, { stdio: 'inherit' });
|
|
122
122
|
},
|
|
123
123
|
|
|
124
|
+
'evidence:update': () => {
|
|
125
|
+
const repoRoot = resolveRepoRoot();
|
|
126
|
+
const evidencePath = path.join(repoRoot, '.AI_EVIDENCE.json');
|
|
127
|
+
|
|
128
|
+
const payload = {
|
|
129
|
+
timestamp: new Date().toISOString(),
|
|
130
|
+
trigger: process.env.AUTO_EVIDENCE_TRIGGER,
|
|
131
|
+
reason: process.env.AUTO_EVIDENCE_REASON,
|
|
132
|
+
summary: process.env.AUTO_EVIDENCE_SUMMARY,
|
|
133
|
+
action: 'evidence:update'
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
fs.writeFileSync(evidencePath, JSON.stringify(payload, null, 2), 'utf8');
|
|
137
|
+
process.stdout.write(`${evidencePath}\n`);
|
|
138
|
+
},
|
|
139
|
+
|
|
124
140
|
ast: () => {
|
|
125
141
|
const filteredArgs = [];
|
|
126
142
|
let stagingOnlyMode = false;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const Finding = require('../entities/Finding');
|
|
2
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
3
2
|
|
|
4
3
|
class AuditResultSerializer {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
toJSON(auditResult) {
|
|
10
5
|
return {
|
|
11
6
|
timestamp: auditResult.timestamp.toISOString(),
|
package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTIntelligentAnalyzer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
const { AndroidAnalysisOrchestrator } = require('./AndroidAnalysisOrchestrator');
|
|
3
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
4
3
|
|
|
5
4
|
class AndroidASTIntelligentAnalyzer {
|
|
6
5
|
constructor(findings) {
|
|
7
6
|
this.findings = findings;
|
|
8
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
9
7
|
this.orchestrator = new AndroidAnalysisOrchestrator(findings);
|
|
10
8
|
}
|
|
11
9
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
3
2
|
|
|
4
3
|
class AndroidASTParser {
|
|
5
4
|
constructor(filePath) {
|
|
6
5
|
this.filePath = filePath;
|
|
7
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
8
6
|
this.content = '';
|
|
9
7
|
this.lines = [];
|
|
10
8
|
this.imports = [];
|
package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const { AndroidASTParser } = require('./AndroidASTParser');
|
|
2
2
|
const { AndroidClassAnalyzer } = require('./AndroidClassAnalyzer');
|
|
3
3
|
const fs = require('fs');
|
|
4
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class AndroidAnalysisOrchestrator {
|
|
7
6
|
constructor(findings) {
|
|
8
7
|
this.findings = findings;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
10
8
|
this.godClassCandidates = [];
|
|
11
9
|
this.godClassBaseline = null;
|
|
12
10
|
}
|
package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidArchitectureDetector.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const glob = require('glob');
|
|
4
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class AndroidArchitectureDetector {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
this.patterns = {
|
|
11
9
|
featureFirstClean: 0, // Feature-First + DDD + Clean Architecture
|
|
12
10
|
mvvm: 0,
|
|
@@ -232,10 +230,10 @@ class AndroidArchitectureDetector {
|
|
|
232
230
|
this.patterns.cleanArchitecture += 10;
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
const domainRepos = files.filter(f =>
|
|
233
|
+
const domainRepos = files.filter(f =>
|
|
236
234
|
f.includes('/domain/') && f.includes('Repository') && fs.readFileSync(path.join(this.projectRoot, f), 'utf-8').includes('interface ')
|
|
237
235
|
);
|
|
238
|
-
const dataRepos = files.filter(f =>
|
|
236
|
+
const dataRepos = files.filter(f =>
|
|
239
237
|
f.includes('/data/') && f.includes('Repository') && fs.readFileSync(path.join(this.projectRoot, f), 'utf-8').includes('class ')
|
|
240
238
|
);
|
|
241
239
|
|
|
@@ -255,14 +253,14 @@ class AndroidArchitectureDetector {
|
|
|
255
253
|
detectMVC(files) {
|
|
256
254
|
files.forEach(file => {
|
|
257
255
|
const content = this.readFile(file);
|
|
258
|
-
|
|
256
|
+
|
|
259
257
|
if ((file.includes('Activity.kt') || file.includes('Fragment.kt')) &&
|
|
260
|
-
|
|
258
|
+
(content.includes('RoomDatabase') || content.includes('SQLiteDatabase'))) {
|
|
261
259
|
this.patterns.mvc += 3;
|
|
262
260
|
}
|
|
263
261
|
|
|
264
262
|
if ((file.includes('Activity.kt') || file.includes('Fragment.kt')) &&
|
|
265
|
-
|
|
263
|
+
content.match(/fun\s+(calculate|process|validate|transform)/)) {
|
|
266
264
|
this.patterns.mvc += 2;
|
|
267
265
|
}
|
|
268
266
|
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
2
|
-
|
|
3
1
|
class AndroidClassAnalyzer {
|
|
4
2
|
constructor(parser, findings, godClassBaseline = null) {
|
|
5
3
|
this.parser = parser;
|
|
6
4
|
this.findings = findings;
|
|
7
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
8
5
|
this.godClassBaseline = godClassBaseline;
|
|
9
6
|
}
|
|
10
7
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { pushFinding, SyntaxKind } = require(path.join(__dirname, '../../ast-core'));
|
|
4
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* AndroidSOLIDAnalyzer
|
|
@@ -13,7 +12,6 @@ const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
|
13
12
|
class AndroidSOLIDAnalyzer {
|
|
14
13
|
constructor() {
|
|
15
14
|
this.findings = [];
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/**
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
const SwiftParser = require('./swift-parser');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
12
11
|
|
|
13
12
|
class iOSRules {
|
|
14
13
|
constructor() {
|
|
15
14
|
this.parser = null;
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
17
15
|
try {
|
|
18
16
|
this.parser = new SwiftParser();
|
|
19
17
|
} catch (error) {
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
const { execSync } = require('child_process');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
12
11
|
|
|
13
12
|
class KotlinAnalyzer {
|
|
14
13
|
constructor() {
|
|
15
14
|
this.findings = [];
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/**
|
|
@@ -10,11 +10,9 @@ const fs = require('fs');
|
|
|
10
10
|
const path = require('path');
|
|
11
11
|
const xml2js = require('xml2js');
|
|
12
12
|
const { ConfigurationError } = require('../../../domain/errors');
|
|
13
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
14
13
|
|
|
15
14
|
class KotlinParser {
|
|
16
15
|
constructor() {
|
|
17
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
18
16
|
this.detektPath = '/opt/homebrew/bin/detekt';
|
|
19
17
|
this.checkAvailability();
|
|
20
18
|
}
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
const { execSync } = require('child_process');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
12
11
|
|
|
13
12
|
class SwiftAnalyzer {
|
|
14
13
|
constructor() {
|
|
15
14
|
this.findings = [];
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/**
|
package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendArchitectureDetector.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const glob = require('glob');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
const { FeatureFirstCleanDetector } = require('./detectors/FeatureFirstCleanDetector');
|
|
7
6
|
const { CleanArchitectureDetector } = require('./detectors/CleanArchitectureDetector');
|
|
@@ -13,7 +12,6 @@ const { MVCDetector } = require('./detectors/MVCDetector');
|
|
|
13
12
|
class BackendArchitectureDetector {
|
|
14
13
|
constructor(projectRoot) {
|
|
15
14
|
this.projectRoot = projectRoot;
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
17
15
|
this.patterns = {
|
|
18
16
|
featureFirstClean: 0,
|
|
19
17
|
cleanArchitecture: 0,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const env = require('../../../../config/env');
|
|
4
|
-
const AuditLogger = require('../../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class BackendPatternDetector {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
readFile(relativePath) {
|
|
@@ -2,7 +2,6 @@ const BDDRules = require('./rules/BDDRules');
|
|
|
2
2
|
const TDDRules = require('./rules/TDDRules');
|
|
3
3
|
const ImplementationRules = require('./rules/ImplementationRules');
|
|
4
4
|
const WorkflowRules = require('./rules/WorkflowRules');
|
|
5
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* BDDTDDWorkflowRules
|
|
@@ -14,7 +13,6 @@ class BDDTDDWorkflowRules {
|
|
|
14
13
|
constructor(findings, projectRoot) {
|
|
15
14
|
this.findings = findings;
|
|
16
15
|
this.projectRoot = projectRoot;
|
|
17
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
18
16
|
|
|
19
17
|
this.bddRules = new BDDRules(projectRoot);
|
|
20
18
|
this.tddRules = new TDDRules(projectRoot);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const glob = require('glob');
|
|
3
3
|
const { pushFileFinding } = require('../../ast-core');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class BDDRules {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
analyze(findings) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const glob = require('glob');
|
|
3
3
|
const { pushFileFinding } = require('../../ast-core');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class ImplementationRules {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
analyze(findings) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const glob = require('glob');
|
|
3
3
|
const { pushFileFinding } = require('../../ast-core');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class TDDRules {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
analyze(findings) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const glob = require('glob');
|
|
3
3
|
const { pushFileFinding } = require('../../ast-core');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class WorkflowRules {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
analyze(findings) {
|
package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendArchitectureDetector.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const glob = require('glob');
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
class FrontendArchitectureDetector {
|
|
7
6
|
constructor(projectRoot) {
|
|
8
7
|
this.projectRoot = projectRoot;
|
|
9
|
-
this.auditLogger = new AuditLogger({ repoRoot: projectRoot });
|
|
10
8
|
this.patterns = {
|
|
11
9
|
featureFirstClean: 0, // Feature-First + DDD + Clean Architecture
|
|
12
10
|
componentBased: 0, // Component-Based Architecture
|
|
@@ -130,7 +128,7 @@ class FrontendArchitectureDetector {
|
|
|
130
128
|
|
|
131
129
|
detectComponentBased(files) {
|
|
132
130
|
const hasComponentsFolder = files.some(f => f.includes('/components/'));
|
|
133
|
-
|
|
131
|
+
|
|
134
132
|
if (hasComponentsFolder) {
|
|
135
133
|
this.patterns.componentBased += 10;
|
|
136
134
|
}
|
|
@@ -145,10 +143,10 @@ class FrontendArchitectureDetector {
|
|
|
145
143
|
|
|
146
144
|
files.forEach(file => {
|
|
147
145
|
if (!file.includes('/components/')) return;
|
|
148
|
-
|
|
146
|
+
|
|
149
147
|
const content = this.readFile(file);
|
|
150
148
|
const componentImports = content.match(/from\s+['"]\.\.\/components\//g) || [];
|
|
151
|
-
|
|
149
|
+
|
|
152
150
|
if (componentImports.length > 0) {
|
|
153
151
|
this.patterns.componentBased += componentImports.length;
|
|
154
152
|
}
|
|
@@ -157,7 +155,7 @@ class FrontendArchitectureDetector {
|
|
|
157
155
|
|
|
158
156
|
detectAtomicDesign(files) {
|
|
159
157
|
const atomicFolders = ['atoms', 'molecules', 'organisms', 'templates', 'pages'];
|
|
160
|
-
|
|
158
|
+
|
|
161
159
|
const foundFolders = atomicFolders.filter(folder => {
|
|
162
160
|
return files.some(f => f.includes(`/${folder}/`));
|
|
163
161
|
});
|
|
@@ -166,9 +164,9 @@ class FrontendArchitectureDetector {
|
|
|
166
164
|
this.patterns.atomicDesign += foundFolders.length * 5;
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
if (files.some(f => f.includes('/atoms/')) &&
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
if (files.some(f => f.includes('/atoms/')) &&
|
|
168
|
+
files.some(f => f.includes('/molecules/')) &&
|
|
169
|
+
files.some(f => f.includes('/organisms/'))) {
|
|
172
170
|
this.patterns.atomicDesign += 10;
|
|
173
171
|
}
|
|
174
172
|
}
|
|
@@ -181,8 +179,8 @@ class FrontendArchitectureDetector {
|
|
|
181
179
|
this.patterns.stateManagement += 5;
|
|
182
180
|
}
|
|
183
181
|
|
|
184
|
-
if (content.includes('redux') || content.includes('@reduxjs/toolkit') ||
|
|
185
|
-
|
|
182
|
+
if (content.includes('redux') || content.includes('@reduxjs/toolkit') ||
|
|
183
|
+
file.includes('slice') || file.includes('reducer')) {
|
|
186
184
|
this.patterns.stateManagement += 5;
|
|
187
185
|
}
|
|
188
186
|
|
|
@@ -199,17 +197,17 @@ class FrontendArchitectureDetector {
|
|
|
199
197
|
detectMVC(files) {
|
|
200
198
|
files.forEach(file => {
|
|
201
199
|
if (!file.includes('component') && !file.endsWith('.tsx') && !file.endsWith('.jsx')) return;
|
|
202
|
-
|
|
200
|
+
|
|
203
201
|
const content = this.readFile(file);
|
|
204
|
-
|
|
202
|
+
|
|
205
203
|
if (content.includes('fetch(') || content.includes('axios.') || content.includes('.get(')) {
|
|
206
|
-
const hasHook = files.some(f =>
|
|
204
|
+
const hasHook = files.some(f =>
|
|
207
205
|
f.includes('use') && f.endsWith('.ts') && !f.includes('component')
|
|
208
206
|
);
|
|
209
|
-
const hasService = files.some(f =>
|
|
207
|
+
const hasService = files.some(f =>
|
|
210
208
|
f.includes('service') || f.includes('api')
|
|
211
209
|
);
|
|
212
|
-
|
|
210
|
+
|
|
213
211
|
if (!hasHook && !hasService) {
|
|
214
212
|
this.patterns.mvc += 3;
|
|
215
213
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { SyntaxKind } = require('../../ast-core');
|
|
2
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
3
2
|
|
|
4
3
|
const FORBIDDEN_STRING_LITERALS = [
|
|
5
4
|
'unknown',
|
|
@@ -23,10 +22,6 @@ const FORBIDDEN_STATUS_LITERALS = [
|
|
|
23
22
|
const MAGIC_NUMBERS = [0, 1];
|
|
24
23
|
|
|
25
24
|
class FrontendForbiddenLiteralsAnalyzer {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
25
|
analyze(sf, findings, pushFinding) {
|
|
31
26
|
const stringLiterals = sf.getDescendantsOfKind(SyntaxKind.StringLiteral);
|
|
32
27
|
const numericLiterals = sf.getDescendantsOfKind(SyntaxKind.NumericLiteral);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { pushFinding, SyntaxKind } = require(path.join(__dirname, '../../ast-core'));
|
|
4
|
-
const AuditLogger = require('../../../application/services/logging/AuditLogger');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* FrontendSOLIDAnalyzer
|
|
@@ -13,7 +12,6 @@ const AuditLogger = require('../../../application/services/logging/AuditLogger')
|
|
|
13
12
|
class FrontendSOLIDAnalyzer {
|
|
14
13
|
constructor() {
|
|
15
14
|
this.findings = [];
|
|
16
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/**
|
|
@@ -4,12 +4,10 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const crypto = require('crypto');
|
|
6
6
|
const env = require(path.join(__dirname, '../../../../config/env'));
|
|
7
|
-
const AuditLogger = require('../../application/services/logging/AuditLogger');
|
|
8
7
|
|
|
9
8
|
class iOSASTIntelligentAnalyzer {
|
|
10
9
|
constructor(findings) {
|
|
11
10
|
this.findings = findings;
|
|
12
|
-
this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
|
|
13
11
|
this.sourceKittenPath = '/opt/homebrew/bin/sourcekitten';
|
|
14
12
|
this.isAvailable = this.checkSourceKitten();
|
|
15
13
|
this.hasSwiftSyntax = this.checkSwiftSyntax();
|
|
@@ -644,6 +642,23 @@ class iOSASTIntelligentAnalyzer {
|
|
|
644
642
|
}
|
|
645
643
|
|
|
646
644
|
analyzeAdditionalRules(filePath) {
|
|
645
|
+
const hasSwiftUIViewType = (this.imports || []).some(i => i && i.name === 'SwiftUI') &&
|
|
646
|
+
(this.structs || []).some(s => (s['key.inheritedtypes'] || []).some(t => t && t['key.name'] === 'View'));
|
|
647
|
+
|
|
648
|
+
if (this.fileContent.includes('pushViewController') || this.fileContent.includes('popViewController') || this.fileContent.includes('present(')) {
|
|
649
|
+
const line = this.findLineNumber('pushViewController') || this.findLineNumber('popViewController') || this.findLineNumber('present(');
|
|
650
|
+
this.pushFinding('ios.navigation.imperative_navigation', 'critical', filePath, line,
|
|
651
|
+
'Imperative navigation detected - use event-driven navigation/coordinator');
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const swiftuiNavTokens = ['NavigationLink', 'NavigationStack', 'NavigationSplitView', '.navigationDestination'];
|
|
655
|
+
const hasSwiftUINavigation = swiftuiNavTokens.some(token => this.fileContent.includes(token));
|
|
656
|
+
if (hasSwiftUINavigation && !hasSwiftUIViewType) {
|
|
657
|
+
const line = this.findLineNumber('NavigationLink') || this.findLineNumber('NavigationStack') || this.findLineNumber('.navigationDestination');
|
|
658
|
+
this.pushFinding('ios.navigation.swiftui_navigation_outside_view', 'critical', filePath, line,
|
|
659
|
+
'SwiftUI navigation API detected outside View types');
|
|
660
|
+
}
|
|
661
|
+
|
|
647
662
|
if (filePath.includes('ViewModel') && this.fileContent.includes('NavigationLink')) {
|
|
648
663
|
const hasCoordinator = this.imports.some(i => i.name.includes('Coordinator'));
|
|
649
664
|
if (!hasCoordinator) {
|