pumuki-ast-hooks 6.1.10 → 6.1.13
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/README.md +12 -9
- package/docs/INSTALLATION.md +3 -2
- package/hooks/__tests__/pre-tool-use-evidence-validator.spec.js +16 -0
- package/hooks/pre-tool-use-evidence-validator.ts +57 -2
- package/package.json +19 -19
- package/scripts/hooks-system/.audit-reports/auto-recovery.log +7 -0
- package/scripts/hooks-system/.audit-reports/install-wizard.log +28 -0
- package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +208 -0
- package/scripts/hooks-system/infrastructure/ast/ios/__tests__/ios-srp-helpers.spec.js +62 -0
- package/scripts/hooks-system/infrastructure/ast/ios/ast-ios.js +25 -11
- package/scripts/hooks-system/infrastructure/ast/ios/detectors/ios-ast-intelligent-strategies.js +21 -9
- package/scripts/hooks-system/infrastructure/ast/ios/utils/ios-srp-helpers.js +162 -0
- package/scripts/hooks-system/infrastructure/ast/text/__tests__/text-scanner.spec.js +60 -0
- package/scripts/hooks-system/infrastructure/ast/text/text-scanner.js +60 -0
- package/scripts/hooks-system/infrastructure/orchestration/__tests__/intelligent-audit.spec.js +40 -0
- package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +4 -5
- package/scripts/hooks-system/infrastructure/shell/gitflow/__tests__/gitflow-enforcer.spec.js +17 -0
- package/scripts/hooks-system/infrastructure/shell/gitflow/gitflow-enforcer.sh +27 -3
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log +21 -0
|
@@ -1298,3 +1298,211 @@
|
|
|
1298
1298
|
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1299
1299
|
{"timestamp":1768488803342,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1300
1300
|
{"timestamp":1768488803342,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1301
|
+
{"timestamp":1768996398842,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1302
|
+
{"timestamp":1768996398842,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1303
|
+
{"timestamp":1768996398842,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1304
|
+
{"timestamp":1768996398842,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1305
|
+
{"timestamp":1768997532262,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1306
|
+
{"timestamp":1768997532263,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1307
|
+
{"timestamp":1768997532264,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1308
|
+
{"timestamp":1768997532264,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1309
|
+
{"timestamp":1768997532264,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1310
|
+
{"timestamp":1768997532264,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1311
|
+
{"timestamp":1768997532264,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1312
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1313
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1314
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1315
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1316
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1317
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1318
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1319
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1320
|
+
{"timestamp":1768997532265,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1321
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1322
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1323
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1324
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1325
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1326
|
+
{"timestamp":1768997532266,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1327
|
+
{"timestamp":1768997532267,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1328
|
+
{"timestamp":1768997532267,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1329
|
+
{"timestamp":1768997567514,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1330
|
+
{"timestamp":1768997567515,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1331
|
+
{"timestamp":1768997567515,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1332
|
+
{"timestamp":1768997567515,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1333
|
+
{"timestamp":1769000347952,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1334
|
+
{"timestamp":1769000347953,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1335
|
+
{"timestamp":1769000347953,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1336
|
+
{"timestamp":1769000347953,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1337
|
+
{"timestamp":1769000471526,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1338
|
+
{"timestamp":1769000471527,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1339
|
+
{"timestamp":1769000471527,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1340
|
+
{"timestamp":1769000471527,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1341
|
+
{"timestamp":1769000471527,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1342
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1343
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1344
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1345
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1346
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1347
|
+
{"timestamp":1769000471528,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1348
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1349
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1350
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1351
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1352
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1353
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1354
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1355
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1356
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1357
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1358
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1359
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1360
|
+
{"timestamp":1769000471529,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1361
|
+
{"timestamp":1769000515929,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1362
|
+
{"timestamp":1769000515929,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1363
|
+
{"timestamp":1769000515929,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1364
|
+
{"timestamp":1769000515929,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1365
|
+
{"timestamp":1769001417697,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1366
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1367
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1368
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1369
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1370
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1371
|
+
{"timestamp":1769001417698,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1372
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1373
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1374
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1375
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1376
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1377
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1378
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1379
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1380
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1381
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1382
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1383
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1384
|
+
{"timestamp":1769001417699,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1385
|
+
{"timestamp":1769001417700,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1386
|
+
{"timestamp":1769001417700,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1387
|
+
{"timestamp":1769001417700,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1388
|
+
{"timestamp":1769001417700,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1389
|
+
{"timestamp":1769001466654,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1390
|
+
{"timestamp":1769001466654,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1391
|
+
{"timestamp":1769001466654,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1392
|
+
{"timestamp":1769001466654,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1393
|
+
{"timestamp":1769002218266,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1394
|
+
{"timestamp":1769002218266,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1395
|
+
{"timestamp":1769002218266,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1396
|
+
{"timestamp":1769002218266,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1397
|
+
{"timestamp":1769002828740,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1398
|
+
{"timestamp":1769002828740,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1399
|
+
{"timestamp":1769002828740,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1400
|
+
{"timestamp":1769002828740,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1401
|
+
{"timestamp":1769004488587,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1402
|
+
{"timestamp":1769004488588,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1403
|
+
{"timestamp":1769004488588,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1404
|
+
{"timestamp":1769004488588,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1405
|
+
{"timestamp":1769004488588,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1406
|
+
{"timestamp":1769004488588,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1407
|
+
{"timestamp":1769004488589,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1408
|
+
{"timestamp":1769004488589,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1409
|
+
{"timestamp":1769004488589,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1410
|
+
{"timestamp":1769004488589,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1411
|
+
{"timestamp":1769004488589,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1412
|
+
{"timestamp":1769004488592,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1413
|
+
{"timestamp":1769004488592,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1414
|
+
{"timestamp":1769004488595,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1415
|
+
{"timestamp":1769004488595,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1416
|
+
{"timestamp":1769004488595,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1417
|
+
{"timestamp":1769004488595,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1418
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1419
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1420
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1421
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1422
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1423
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1424
|
+
{"timestamp":1769004488596,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1425
|
+
{"timestamp":1769004883578,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1426
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1427
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1428
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1429
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1430
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1431
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1432
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1433
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1434
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1435
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1436
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1437
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1438
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1439
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1440
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1441
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1442
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1443
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1444
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1445
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1446
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1447
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1448
|
+
{"timestamp":1769004883579,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1449
|
+
{"timestamp":1769004905775,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1450
|
+
{"timestamp":1769004905775,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1451
|
+
{"timestamp":1769004905775,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1452
|
+
{"timestamp":1769004905775,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1453
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1454
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1455
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1456
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1457
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1458
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1459
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1460
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1461
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1462
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1463
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1464
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1465
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1466
|
+
{"timestamp":1769005153999,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1467
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1468
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1469
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1470
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1471
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1472
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1473
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1474
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1475
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1476
|
+
{"timestamp":1769005154000,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1477
|
+
{"timestamp":1769005445389,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1478
|
+
{"timestamp":1769005445389,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1479
|
+
{"timestamp":1769005445390,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1480
|
+
{"timestamp":1769005445390,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1481
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1482
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1483
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1484
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1485
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1486
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1487
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1488
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1489
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1490
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1491
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1492
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1493
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1494
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1495
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1496
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1497
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1498
|
+
{"timestamp":1769006595796,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1499
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1500
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1501
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1502
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1503
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1504
|
+
{"timestamp":1769006595797,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1505
|
+
{"timestamp":1769006619003,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
1506
|
+
{"timestamp":1769006619004,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
|
|
1507
|
+
{"timestamp":1769006619004,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
|
|
1508
|
+
{"timestamp":1769006619004,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const { summarizeSwiftTypes, evaluateMultipleTypeGroups, resolveSrpSeverity, isThinWrapperSummary } = require('../utils/ios-srp-helpers');
|
|
2
|
+
|
|
3
|
+
describe('ios srp heuristics', () => {
|
|
4
|
+
it('flags multiple unrelated types by group', () => {
|
|
5
|
+
const content = `
|
|
6
|
+
struct User { let id: String }
|
|
7
|
+
struct Order { let id: String }
|
|
8
|
+
struct Product { let id: String }
|
|
9
|
+
`;
|
|
10
|
+
const summaries = summarizeSwiftTypes(content);
|
|
11
|
+
const result = evaluateMultipleTypeGroups(summaries);
|
|
12
|
+
expect(result.shouldFlag).toBe(true);
|
|
13
|
+
expect(result.distinctGroups).toBeGreaterThan(1);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('does not flag multiple types with shared prefix', () => {
|
|
17
|
+
const content = `
|
|
18
|
+
struct UserView { var body: some View { Text("x") } }
|
|
19
|
+
final class UserViewModel { func load() {} }
|
|
20
|
+
final class UserRouter { func route() {} }
|
|
21
|
+
`;
|
|
22
|
+
const summaries = summarizeSwiftTypes(content);
|
|
23
|
+
const result = evaluateMultipleTypeGroups(summaries);
|
|
24
|
+
expect(result.shouldFlag).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('counts methods without nested type members', () => {
|
|
28
|
+
const content = `
|
|
29
|
+
struct Wrapper {
|
|
30
|
+
struct Nested { func inner() {} }
|
|
31
|
+
func outer() {}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const summaries = summarizeSwiftTypes(content);
|
|
35
|
+
const wrapper = summaries.find((item) => item.name === 'Wrapper');
|
|
36
|
+
expect(wrapper.methodsCount).toBe(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('detects thin wrappers', () => {
|
|
40
|
+
const content = `
|
|
41
|
+
struct TokenSpyStorageState {
|
|
42
|
+
var savedTokens: [String]
|
|
43
|
+
var deletedTokensCount: Int
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
final class AccessTokenSpyStorage {
|
|
47
|
+
var state: TokenSpyStorageState
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const summaries = summarizeSwiftTypes(content);
|
|
51
|
+
const wrapper = summaries.find((item) => item.name === 'AccessTokenSpyStorage');
|
|
52
|
+
expect(isThinWrapperSummary(wrapper)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('resolves severity by layer', () => {
|
|
56
|
+
const config = { coreSeverity: 'critical', defaultSeverity: 'high', testSeverity: 'low' };
|
|
57
|
+
expect(resolveSrpSeverity('Apps/Domain/User.swift', config)).toBe('critical');
|
|
58
|
+
expect(resolveSrpSeverity('Apps/Application/UserUseCase.swift', config)).toBe('critical');
|
|
59
|
+
expect(resolveSrpSeverity('Apps/Tests/UserTests.swift', config)).toBe('low');
|
|
60
|
+
expect(resolveSrpSeverity('Apps/Presentation/UserView.swift', config)).toBe('high');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -17,6 +17,7 @@ const { iOSCICDRules } = require(path.join(__dirname, 'analyzers/iOSCICDRules'))
|
|
|
17
17
|
const { iOSForbiddenLiteralsAnalyzer } = require(path.join(__dirname, 'analyzers/iOSForbiddenLiteralsAnalyzer'));
|
|
18
18
|
const { iOSASTIntelligentAnalyzer } = require(path.join(__dirname, 'analyzers/iOSASTIntelligentAnalyzer'));
|
|
19
19
|
const { iOSModernPracticesRules } = require(path.join(__dirname, 'analyzers/iOSModernPracticesRules'));
|
|
20
|
+
const { summarizeSwiftTypes, evaluateMultipleTypeGroups, resolveSrpSeverity, isThinWrapperSummary } = require(path.join(__dirname, 'utils/ios-srp-helpers'));
|
|
20
21
|
|
|
21
22
|
function detectForbiddenTestableImport({ filePath, content }) {
|
|
22
23
|
if (!filePath || !content) return null;
|
|
@@ -1134,29 +1135,42 @@ async function runIOSIntelligence(project, findings, platform) {
|
|
|
1134
1135
|
// ==========================================
|
|
1135
1136
|
|
|
1136
1137
|
|
|
1137
|
-
const
|
|
1138
|
-
const
|
|
1139
|
-
if (
|
|
1138
|
+
const typeSummaries = summarizeSwiftTypes(content);
|
|
1139
|
+
const typeGroups = evaluateMultipleTypeGroups(typeSummaries);
|
|
1140
|
+
if (typeGroups.shouldFlag && !filePath.includes('Generated')) {
|
|
1141
|
+
const severity = resolveSrpSeverity(filePath, {
|
|
1142
|
+
coreSeverity: 'high',
|
|
1143
|
+
defaultSeverity: 'medium',
|
|
1144
|
+
testSeverity: 'low'
|
|
1145
|
+
});
|
|
1140
1146
|
pushFinding(
|
|
1141
1147
|
"ios.solid.srp_multiple_types",
|
|
1142
|
-
|
|
1148
|
+
severity,
|
|
1143
1149
|
sf,
|
|
1144
1150
|
sf,
|
|
1145
|
-
`File defines ${
|
|
1151
|
+
`File defines ${typeGroups.totalTypes} types across ${typeGroups.distinctGroups} domains - split by responsibility (SRP)`,
|
|
1146
1152
|
findings
|
|
1147
1153
|
);
|
|
1148
1154
|
}
|
|
1149
1155
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1156
|
+
const godClassSeverityConfig = {
|
|
1157
|
+
coreSeverity: 'critical',
|
|
1158
|
+
defaultSeverity: 'high',
|
|
1159
|
+
testSeverity: 'low'
|
|
1160
|
+
};
|
|
1161
|
+
const godClassThreshold = 20;
|
|
1162
|
+
for (const summary of typeSummaries) {
|
|
1163
|
+
if (isThinWrapperSummary(summary)) {
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (summary.methodsCount > godClassThreshold) {
|
|
1167
|
+
const severity = resolveSrpSeverity(filePath, godClassSeverityConfig);
|
|
1154
1168
|
pushFinding(
|
|
1155
1169
|
"ios.solid.srp_god_class",
|
|
1156
|
-
|
|
1170
|
+
severity,
|
|
1157
1171
|
sf,
|
|
1158
1172
|
sf,
|
|
1159
|
-
`Type has ${
|
|
1173
|
+
`Type '${summary.name}' has ${summary.methodsCount} methods - split responsibilities (SRP: one reason to change)`,
|
|
1160
1174
|
findings
|
|
1161
1175
|
);
|
|
1162
1176
|
}
|
package/scripts/hooks-system/infrastructure/ast/ios/detectors/ios-ast-intelligent-strategies.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const DIValidationService = require('../../../../application/DIValidationService');
|
|
3
|
+
const { resolveSrpSeverity, isThinWrapperSummary } = require('../utils/ios-srp-helpers');
|
|
3
4
|
|
|
4
5
|
const diValidationService = new DIValidationService();
|
|
5
6
|
|
|
@@ -168,16 +169,22 @@ async function analyzeClassAST(analyzer, node, filePath) {
|
|
|
168
169
|
|
|
169
170
|
if (name && !/Spec$|Test$|Mock/.test(name) && !name.includes('Coordinator')) {
|
|
170
171
|
const complexity = calculateComplexityAST(substructure);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
filePath,
|
|
174
|
-
line,
|
|
175
|
-
methodsCount: methods.length,
|
|
176
|
-
significantMethodsCount: significantMethods.length,
|
|
172
|
+
const isThinWrapper = isThinWrapperSummary({
|
|
173
|
+
methodsCount: significantMethods.length,
|
|
177
174
|
propertiesCount: properties.length,
|
|
178
|
-
bodyLength,
|
|
179
|
-
complexity,
|
|
180
175
|
});
|
|
176
|
+
if (!isThinWrapper) {
|
|
177
|
+
analyzer.godClassCandidates.push({
|
|
178
|
+
name,
|
|
179
|
+
filePath,
|
|
180
|
+
line,
|
|
181
|
+
methodsCount: methods.length,
|
|
182
|
+
significantMethodsCount: significantMethods.length,
|
|
183
|
+
propertiesCount: properties.length,
|
|
184
|
+
bodyLength,
|
|
185
|
+
complexity,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
if (name.includes('ViewController')) {
|
|
@@ -803,9 +810,14 @@ function finalizeGodClassDetection(analyzer) {
|
|
|
803
810
|
const signalCount = [sizeOutlier, complexityOutlier].filter(Boolean).length;
|
|
804
811
|
|
|
805
812
|
if (extremeOutlier || signalCount >= 2) {
|
|
813
|
+
const severity = resolveSrpSeverity(c.filePath, {
|
|
814
|
+
coreSeverity: 'critical',
|
|
815
|
+
defaultSeverity: 'high',
|
|
816
|
+
testSeverity: 'low',
|
|
817
|
+
});
|
|
806
818
|
analyzer.pushFinding(
|
|
807
819
|
'ios.solid.srp.god_class',
|
|
808
|
-
|
|
820
|
+
severity,
|
|
809
821
|
c.filePath,
|
|
810
822
|
c.line,
|
|
811
823
|
`God class '${c.name}': ${c.methodsCount} methods (z=${methodsZ.toFixed(2)}), ${c.propertiesCount} properties (z=${propsZ.toFixed(2)}), body ${c.bodyLength} (z=${bodyZ.toFixed(2)}), complexity ${c.complexity} (z=${complexityZ.toFixed(2)}) - VIOLATES SRP`
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
function resolveSrpSeverity(filePath, { coreSeverity, defaultSeverity, testSeverity }) {
|
|
2
|
+
const normalized = String(filePath || '').replace(/\\/g, '/');
|
|
3
|
+
const isTest = /Tests|Test|Spec/.test(normalized);
|
|
4
|
+
if (isTest) return testSeverity || defaultSeverity;
|
|
5
|
+
const isCore = normalized.includes('/Domain/') || normalized.includes('/Application/');
|
|
6
|
+
if (isCore) return coreSeverity || defaultSeverity;
|
|
7
|
+
return defaultSeverity;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function findMatchingBraceIndex(content, startIndex) {
|
|
11
|
+
let depth = 0;
|
|
12
|
+
let inString = false;
|
|
13
|
+
let stringChar = '';
|
|
14
|
+
let inLineComment = false;
|
|
15
|
+
let inBlockComment = false;
|
|
16
|
+
|
|
17
|
+
for (let i = startIndex; i < content.length; i += 1) {
|
|
18
|
+
const current = content[i];
|
|
19
|
+
const next = content[i + 1];
|
|
20
|
+
|
|
21
|
+
if (inLineComment) {
|
|
22
|
+
if (current === '\n') inLineComment = false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (inBlockComment) {
|
|
27
|
+
if (current === '*' && next === '/') {
|
|
28
|
+
inBlockComment = false;
|
|
29
|
+
i += 1;
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (inString) {
|
|
35
|
+
if (current === '\\') {
|
|
36
|
+
i += 1;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (current === stringChar) {
|
|
40
|
+
inString = false;
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (current === '/' && next === '/') {
|
|
46
|
+
inLineComment = true;
|
|
47
|
+
i += 1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (current === '/' && next === '*') {
|
|
52
|
+
inBlockComment = true;
|
|
53
|
+
i += 1;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (current === '"' || current === "'") {
|
|
58
|
+
inString = true;
|
|
59
|
+
stringChar = current;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (current === '{') depth += 1;
|
|
64
|
+
if (current === '}') {
|
|
65
|
+
depth -= 1;
|
|
66
|
+
if (depth === 0) return i;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return -1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function extractSwiftTypeBlocks(content) {
|
|
74
|
+
const blocks = [];
|
|
75
|
+
const pattern = /(^|\n)\s*(?:public|internal|fileprivate|private|open)?\s*(?:final\s+)?(class|struct|enum|protocol)\s+([A-Za-z_][A-Za-z0-9_]*)[^\n{]*\{/g;
|
|
76
|
+
let match = pattern.exec(content);
|
|
77
|
+
while (match) {
|
|
78
|
+
const name = match[3];
|
|
79
|
+
const braceIndex = match.index + match[0].lastIndexOf('{');
|
|
80
|
+
const endIndex = findMatchingBraceIndex(content, braceIndex);
|
|
81
|
+
if (endIndex !== -1) {
|
|
82
|
+
blocks.push({
|
|
83
|
+
name,
|
|
84
|
+
openIndex: braceIndex,
|
|
85
|
+
closeIndex: endIndex,
|
|
86
|
+
body: content.slice(braceIndex + 1, endIndex)
|
|
87
|
+
});
|
|
88
|
+
pattern.lastIndex = endIndex + 1;
|
|
89
|
+
}
|
|
90
|
+
match = pattern.exec(content);
|
|
91
|
+
}
|
|
92
|
+
return blocks;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function stripNestedTypeBlocks(content) {
|
|
96
|
+
const nestedBlocks = extractSwiftTypeBlocks(content);
|
|
97
|
+
if (nestedBlocks.length === 0) return content;
|
|
98
|
+
const sorted = nestedBlocks.slice().sort((a, b) => b.openIndex - a.openIndex);
|
|
99
|
+
let output = content;
|
|
100
|
+
for (const block of sorted) {
|
|
101
|
+
const length = block.closeIndex - block.openIndex + 1;
|
|
102
|
+
output = `${output.slice(0, block.openIndex)}${' '.repeat(length)}${output.slice(block.closeIndex + 1)}`;
|
|
103
|
+
}
|
|
104
|
+
return output;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function countFunctions(content) {
|
|
108
|
+
const matches = content.match(/\bfunc\s+[A-Za-z_][A-Za-z0-9_]*/g) || [];
|
|
109
|
+
return matches.length;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function countProperties(content) {
|
|
113
|
+
const matches = content.match(/(^|\n)\s*(?:@[A-Za-z0-9_.]+\s*)*(var|let)\s+[A-Za-z_][A-Za-z0-9_]*/g) || [];
|
|
114
|
+
return matches.length;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function splitTypeName(name) {
|
|
118
|
+
return String(name).match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|[0-9]+/g) || [name];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function getTypeGroupKey(name) {
|
|
122
|
+
const parts = splitTypeName(name);
|
|
123
|
+
return parts[0] || name;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function summarizeSwiftTypes(content) {
|
|
127
|
+
const blocks = extractSwiftTypeBlocks(String(content || ''));
|
|
128
|
+
return blocks.map((block) => {
|
|
129
|
+
const sanitizedBody = stripNestedTypeBlocks(block.body);
|
|
130
|
+
return {
|
|
131
|
+
name: block.name,
|
|
132
|
+
methodsCount: countFunctions(sanitizedBody),
|
|
133
|
+
propertiesCount: countProperties(sanitizedBody),
|
|
134
|
+
groupKey: getTypeGroupKey(block.name)
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function evaluateMultipleTypeGroups(summaries) {
|
|
140
|
+
const groups = new Set((summaries || []).map((item) => item.groupKey).filter(Boolean));
|
|
141
|
+
const totalTypes = (summaries || []).length;
|
|
142
|
+
const distinctGroups = groups.size;
|
|
143
|
+
const shouldFlag = totalTypes >= 3 && distinctGroups >= 2;
|
|
144
|
+
return {
|
|
145
|
+
totalTypes,
|
|
146
|
+
distinctGroups,
|
|
147
|
+
shouldFlag,
|
|
148
|
+
groups: Array.from(groups)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function isThinWrapperSummary(summary) {
|
|
153
|
+
if (!summary) return false;
|
|
154
|
+
return summary.methodsCount === 0 && summary.propertiesCount <= 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
module.exports = {
|
|
158
|
+
summarizeSwiftTypes,
|
|
159
|
+
evaluateMultipleTypeGroups,
|
|
160
|
+
resolveSrpSeverity,
|
|
161
|
+
isThinWrapperSummary
|
|
162
|
+
};
|