@teevee98/synapse-hub 4.2.0 → 4.2.2

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.
Files changed (109) hide show
  1. package/.agents/skills/01-web-automation/auth-session-and-cookie-manager/SKILL.md +46 -2
  2. package/.agents/skills/01-web-automation/bats-testing-patterns/SKILL.md +49 -4
  3. package/.agents/skills/01-web-automation/clean-pom-crafter/SKILL.md +56 -66
  4. package/.agents/skills/01-web-automation/e2e-testing-patterns/SKILL.md +48 -3
  5. package/.agents/skills/01-web-automation/katalon-cli-runner/SKILL.md +56 -11
  6. package/.agents/skills/01-web-automation/lam-script-generator/SKILL.md +49 -7
  7. package/.agents/skills/01-web-automation/mobile-appium-som/SKILL.md +54 -11
  8. package/.agents/skills/01-web-automation/playwright-live-interaction/SKILL.md +48 -90
  9. package/.agents/skills/01-web-automation/playwright-webapp-testing/SKILL.md +53 -10
  10. package/.agents/skills/01-web-automation/web-agent-gym-benchmarking/SKILL.md +44 -3
  11. package/.agents/skills/02-test-design/architecture-decision-records/SKILL.md +49 -8
  12. package/.agents/skills/02-test-design/gherkin-to-suite/SKILL.md +49 -8
  13. package/.agents/skills/02-test-design/rbt-manual-testing/SKILL.md +49 -7
  14. package/.agents/skills/02-test-design/review-spec/SKILL.md +46 -5
  15. package/.agents/skills/02-test-design/tot-exploratory-testing/SKILL.md +44 -3
  16. package/.agents/skills/03-api-and-contracts/api-network-mocking-interception/SKILL.md +50 -4
  17. package/.agents/skills/03-api-and-contracts/api-spec-to-e2e-matrix/SKILL.md +47 -6
  18. package/.agents/skills/03-api-and-contracts/consumer-driven-contract-testing/SKILL.md +79 -34
  19. package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/SKILL.md +47 -4
  20. package/.agents/skills/04-performance-and-load/lean-impact-scoreboard/SKILL.md +46 -5
  21. package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/SKILL.md +44 -2
  22. package/.agents/skills/05-security-and-compliance/security-dast-sentinel/SKILL.md +57 -13
  23. package/.agents/skills/05-security-and-compliance/skillspector-security-guard/SKILL.md +45 -4
  24. package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +48 -3
  25. package/.agents/skills/06-healing-and-resilience/agentless-qa-repair/SKILL.md +45 -4
  26. package/.agents/skills/06-healing-and-resilience/antigravity-test-sentinel/SKILL.md +47 -5
  27. package/.agents/skills/06-healing-and-resilience/failure-autopsy-and-healing/SKILL.md +48 -7
  28. package/.agents/skills/06-healing-and-resilience/flaky-test-sentinel-and-quarantine/SKILL.md +54 -23
  29. package/.agents/skills/06-healing-and-resilience/self-healing-locator/SKILL.md +46 -5
  30. package/.agents/skills/06-healing-and-resilience/systematic-debugging/SKILL.md +50 -9
  31. package/.agents/skills/06-healing-and-resilience/test-driven-development/SKILL.md +52 -11
  32. package/.agents/skills/06-healing-and-resilience/verification-before-completion/SKILL.md +52 -11
  33. package/.agents/skills/06-healing-and-resilience/visual-regression-sentinel/SKILL.md +47 -4
  34. package/.agents/skills/07-data-and-state/db-state-verifier-and-seeder/SKILL.md +50 -4
  35. package/.agents/skills/07-data-and-state/file-and-report-validator/SKILL.md +47 -3
  36. package/.agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md +52 -4
  37. package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/SKILL.md +51 -10
  38. package/.agents/skills/08-code-quality/graphify-impact-analyzer/SKILL.md +78 -34
  39. package/.agents/skills/08-code-quality/graphify-impact-analyzer/examples/dependency_blast_radius.json +3 -4
  40. package/.agents/skills/08-code-quality/lean-code-ladder/SKILL.md +49 -9
  41. package/.agents/skills/08-code-quality/repo-quality-audit/SKILL.md +45 -5
  42. package/.agents/skills/08-code-quality/senior-code-review/SKILL.md +48 -6
  43. package/.agents/skills/08-code-quality/surgical-coding-principles/SKILL.md +49 -9
  44. package/.agents/skills/08-code-quality/technical-debt-harvester/SKILL.md +47 -4
  45. package/.agents/skills/09-ci-and-devops/github-actions-templates/SKILL.md +48 -16
  46. package/.agents/skills/09-ci-and-devops/github-actions-templates/examples/matrix_test_pipeline.yml +2 -1
  47. package/.agents/skills/10-agent-orchestration/actor-qa-swarm/SKILL.md +44 -3
  48. package/.agents/skills/10-agent-orchestration/agent-orchestration-multi-agent-optimize/SKILL.md +47 -6
  49. package/.agents/skills/10-agent-orchestration/event-stream-qa-orchestrator/SKILL.md +44 -3
  50. package/.agents/skills/10-agent-orchestration/persistent-planning-files/SKILL.md +52 -12
  51. package/.agents/skills/10-agent-orchestration/qa-memory-os/SKILL.md +45 -4
  52. package/.agents/skills/11-ai-and-prompting/meta-prompt-crafter/SKILL.md +51 -9
  53. package/.agents/skills/11-ai-and-prompting/mipro-prompt-compiler/SKILL.md +44 -3
  54. package/.agents/skills/11-ai-and-prompting/qa-aci-interface/SKILL.md +44 -3
  55. package/.agents/skills/11-ai-and-prompting/token-and-context-optimizer/SKILL.md +49 -8
  56. package/.cursor/rules/synapse-qa.mdc +20 -7
  57. package/.cursorrules +19 -5
  58. package/.windsurfrules +18 -3
  59. package/AGENTS.md +51 -65
  60. package/CLAUDE.md +38 -24
  61. package/README.en.md +2 -2
  62. package/README.md +2 -2
  63. package/agentskills.json +1 -1
  64. package/docs/ARCHITECTURE.en.md +1 -1
  65. package/docs/ARCHITECTURE.md +1 -1
  66. package/docs/CLIENT_SUPPORT_MATRIX.md +44 -0
  67. package/docs/SIDE_EFFECTING_TOOLS_INVENTORY.md +233 -0
  68. package/package.json +1 -1
  69. package/plugin.json +1 -1
  70. package/skills_manifest.json +1 -1
  71. package/synapse.config.json +1 -1
  72. package/templates/ai_bridges/CLAUDE.md +29 -26
  73. package/templates/ai_bridges/copilot-instructions.md +14 -5
  74. package/templates/ai_bridges/cursor_synapse_qa.mdc +16 -7
  75. package/templates/ai_bridges/windsurfrules +14 -3
  76. package/tools/TOOLS_RUNBOOK.md +1 -1
  77. package/tools/__init__.py +1 -1
  78. package/tools/api_fuzzer.py +295 -41
  79. package/tools/benchmark_swarm_context.py +11 -4
  80. package/tools/browser_helpers.js +2 -2
  81. package/tools/bump_version.py +2 -2
  82. package/tools/cli.py +4 -4
  83. package/tools/core/bm25_retriever.py +1 -1
  84. package/tools/core/i18n.py +1 -1
  85. package/tools/core/provider_usage_adapter.py +66 -0
  86. package/tools/core/token_estimator.py +39 -1
  87. package/tools/count_tokens.py +2 -2
  88. package/tools/dashboard_generator.py +8 -8
  89. package/tools/db_sandbox.py +182 -43
  90. package/tools/distill_log.py +1 -1
  91. package/tools/distill_skill.py +17 -2
  92. package/tools/git_pre_commit_guard.py +190 -1
  93. package/tools/hub_publisher.py +2 -12
  94. package/tools/mcp_docx_server.py +1 -1
  95. package/tools/mcp_excel_server.py +1 -1
  96. package/tools/mcp_server.py +33 -5
  97. package/tools/micro_mutator.py +30 -1
  98. package/tools/pentest_scope_guard.py +288 -15
  99. package/tools/project_state.py +29 -5
  100. package/tools/reversible_sandbox.py +58 -13
  101. package/tools/rules_router.py +80 -27
  102. package/tools/skill_canonical_digest.py +60 -2
  103. package/tools/sync_agent_rules.py +187 -61
  104. package/tools/task_memory_manager.py +16 -1
  105. package/tools/ui_server.py +3 -1
  106. package/tools/update_sentinel.py +3 -3
  107. package/tools/validate_skills_schema.py +349 -56
  108. package/tools/verify_all.py +98 -4
  109. package/tools/welcome_page.py +1 -1
@@ -23,17 +23,27 @@ import sys
23
23
  import json
24
24
  import time
25
25
  import ssl
26
+ import tempfile
26
27
  import urllib.request
27
28
  import urllib.error
28
29
  import urllib.parse
29
30
  import argparse
31
+ import fnmatch
32
+ import uuid
33
+ import secrets
30
34
  from typing import Dict, Any, List, Optional
31
35
 
32
36
  from pentest_scope_guard import (
33
37
  PentestScopeGuard,
34
38
  PentestRateLimiter,
35
39
  PentestScopeError,
40
+ PathContainmentError,
41
+ ConsentGrant,
42
+ create_consent_grant,
43
+ is_consent_grant,
44
+ resolve_contained_path,
36
45
  mask_secrets,
46
+ _GLOBAL_CONSUMED_NONCES,
37
47
  )
38
48
 
39
49
  # Enforce UTF-8 stdout encoding for Windows/macOS/Linux compatibility
@@ -46,6 +56,7 @@ if hasattr(sys.stdout, 'reconfigure'):
46
56
 
47
57
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
48
58
  HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
59
+ QA_HUB_ROOT = HUB_ROOT
49
60
  REPORTS_DIR = os.path.join(HUB_ROOT, "reports")
50
61
 
51
62
  if SCRIPT_DIR not in sys.path:
@@ -119,6 +130,7 @@ class ApiFuzzer:
119
130
  allow_internal: bool = False,
120
131
  allow_loopback: bool = True,
121
132
  consent: Any = False,
133
+ dry_run: bool = False,
122
134
  ):
123
135
  self.base_url = base_url.rstrip("/")
124
136
  self.spec_path = spec_path_or_url
@@ -129,6 +141,7 @@ class ApiFuzzer:
129
141
  self.verify_ssl = not self.insecure
130
142
  self.max_requests = max(1, int(max_requests))
131
143
  self.consent = consent
144
+ self.dry_run = bool(dry_run)
132
145
 
133
146
  # Wire unified scope guard and rate limiter (narrow loopback opt-in for local test harnesses)
134
147
  self.scope_guard = scope_guard or PentestScopeGuard(
@@ -151,11 +164,13 @@ class ApiFuzzer:
151
164
  )
152
165
 
153
166
  # Validate target base_url before proceeding (Fail-closed)
154
- ok, reason = self.scope_guard.validate_target(self.base_url, actor="ApiFuzzer.__init__")
155
- if not ok:
156
- raise PermissionError(
157
- f"[SAFETY FIREWALL - REJECTED] Target base URL '{self.base_url}' is not permitted by pentest scope guard: {reason}"
158
- )
167
+ # When dry_run=True, skip live DNS lookups and network validation
168
+ if not self.dry_run:
169
+ ok, reason = self.scope_guard.validate_target(self.base_url, actor="ApiFuzzer.__init__")
170
+ if not ok:
171
+ raise PermissionError(
172
+ f"[SAFETY FIREWALL - REJECTED] Target base URL '{self.base_url}' is not permitted by pentest scope guard: {reason}"
173
+ )
159
174
 
160
175
  @staticmethod
161
176
  def _is_safe_non_prod_host(host: str) -> bool:
@@ -197,6 +212,18 @@ class ApiFuzzer:
197
212
  }
198
213
 
199
214
  if self.spec_path.startswith(("http://", "https://")):
215
+ if self.dry_run:
216
+ # Offline mock spec when dry_run=True: zero network and DNS requests
217
+ return {
218
+ "paths": {
219
+ "/api/v1/dry_run_endpoint": {
220
+ "get": {
221
+ "summary": "Dry run offline endpoint",
222
+ "responses": {"200": {"description": "OK"}}
223
+ }
224
+ }
225
+ }
226
+ }
200
227
  # Validate spec URL with scope guard before network dispatch
201
228
  ok, reason = self.scope_guard.validate_target(self.spec_path, actor="ApiFuzzer.load_spec")
202
229
  if not ok:
@@ -209,9 +236,23 @@ class ApiFuzzer:
209
236
  except PentestScopeError as pse:
210
237
  raise PermissionError(f"[PENTEST SCOPE GUARD] Redirect blocked during load_spec: {pse}")
211
238
  else:
212
- if not os.path.exists(self.spec_path):
239
+ # Validate that local spec path does not traverse outside workspace or temporary directories
240
+ allowed_roots = [os.path.abspath(os.getcwd()), QA_HUB_ROOT, tempfile.gettempdir()]
241
+
242
+ contained_path = None
243
+ for root in allowed_roots:
244
+ try:
245
+ contained_path = resolve_contained_path(root, self.spec_path)
246
+ break
247
+ except PathContainmentError:
248
+ continue
249
+
250
+ if contained_path is None:
251
+ raise PathContainmentError(f"OpenAPI spec path '{self.spec_path}' escapes designated containment roots.")
252
+
253
+ if not os.path.exists(contained_path):
213
254
  raise FileNotFoundError(f"OpenAPI spec not found: {self.spec_path}")
214
- with open(self.spec_path, "r", encoding="utf-8") as f:
255
+ with open(contained_path, "r", encoding="utf-8") as f:
215
256
  return json.load(f)
216
257
 
217
258
  def extract_fuzz_targets(self, spec: Dict[str, Any]) -> List[Dict[str, Any]]:
@@ -388,7 +429,7 @@ class ApiFuzzer:
388
429
  if method in ("POST", "PUT", "PATCH") and mutation.get("body") is not None:
389
430
  body_data = json.dumps(mutation["body"]).encode("utf-8")
390
431
 
391
- if dry_run:
432
+ if dry_run or self.dry_run:
392
433
  # Deterministic offline mock for CI & local checks
393
434
  return {
394
435
  "name": mutation["name"],
@@ -403,9 +444,11 @@ class ApiFuzzer:
403
444
  "response_preview": '{"status": "handled_by_dry_run"}'
404
445
  }
405
446
 
406
- # Consent verification: active live testing requires explicit consent before network dispatch
447
+ # Consent verification: active live testing requires explicit granular consent before network dispatch
407
448
  effective_consent = self.consent if consent is None else consent
408
- if not self.scope_guard.verify_consent(effective_consent):
449
+
450
+ # 1. Reject missing or generic boolean consent
451
+ if effective_consent is None or isinstance(effective_consent, bool) or not effective_consent:
409
452
  return {
410
453
  "name": mutation.get("name", "unnamed"),
411
454
  "type": mutation.get("type", "UNKNOWN"),
@@ -415,13 +458,25 @@ class ApiFuzzer:
415
458
  "duration_ms": 0.0,
416
459
  "verdict": "FAIL",
417
460
  "severity": "CRITICAL",
418
- "alarms": ["CONSENT_REQUIRED: Active API request rejected. Explicit consent required (--confirm-pentest-scope, consent=True, or scoped consent dict)."],
461
+ "alarms": ["CONSENT_REQUIRED: Active API request rejected. Granular ConsentGrant required (binding action='http:fuzz', canonical target, caller_session, nonce, expiry)."],
419
462
  "response_preview": "Active request blocked: missing consent."
420
463
  }
421
464
 
422
- # Scoped consent check: verify target, method, path if specified in consent dict
423
- if isinstance(effective_consent, dict):
424
- c_target = effective_consent.get("target") or effective_consent.get("base_url")
465
+ # 2. Extract attributes from ConsentGrant or scoped dict
466
+ if is_consent_grant(effective_consent):
467
+ c_target = effective_consent.target
468
+ c_method = effective_consent.method
469
+ c_path = effective_consent.path_pattern
470
+ c_expiry = effective_consent.expiry
471
+ c_nonce = effective_consent.nonce
472
+ elif isinstance(effective_consent, dict):
473
+ c_target = effective_consent.get("target") or effective_consent.get("target_sandbox") or effective_consent.get("base_url")
474
+ c_method = effective_consent.get("method")
475
+ c_path = effective_consent.get("path") or effective_consent.get("path_pattern")
476
+ c_expiry = effective_consent.get("expiry")
477
+ c_nonce = effective_consent.get("nonce")
478
+ c_session = effective_consent.get("caller_session") or effective_consent.get("session") or effective_consent.get("session_id")
479
+ # Check target, method, and path mismatch before rejecting incomplete dict fields
425
480
  if c_target and not (url.startswith(c_target.rstrip("/")) or self.base_url == c_target.rstrip("/")):
426
481
  return {
427
482
  "name": mutation.get("name", "unnamed"),
@@ -435,7 +490,7 @@ class ApiFuzzer:
435
490
  "alarms": [f"CONSENT_MISMATCH: Scoped consent target '{c_target}' does not authorize target URL '{mask_secrets(url)}'."],
436
491
  "response_preview": "Active request blocked: consent target mismatch."
437
492
  }
438
- c_method = effective_consent.get("method")
493
+
439
494
  if c_method and c_method.upper() != method.upper():
440
495
  return {
441
496
  "name": mutation.get("name", "unnamed"),
@@ -449,8 +504,24 @@ class ApiFuzzer:
449
504
  "alarms": [f"CONSENT_MISMATCH: Scoped consent method '{c_method}' does not authorize mutation method '{method}'."],
450
505
  "response_preview": "Active request blocked: consent method mismatch."
451
506
  }
452
- c_path = effective_consent.get("path")
453
- if c_path and c_path != mutation.get("path"):
507
+
508
+ if c_path:
509
+ m_path = mutation.get("path", "")
510
+ if c_path != m_path and not fnmatch.fnmatch(m_path, c_path):
511
+ return {
512
+ "name": mutation.get("name", "unnamed"),
513
+ "type": mutation.get("type", "UNKNOWN"),
514
+ "url": mask_secrets(url),
515
+ "method": method,
516
+ "status_code": -5,
517
+ "duration_ms": 0.0,
518
+ "verdict": "FAIL",
519
+ "severity": "CRITICAL",
520
+ "alarms": [f"CONSENT_MISMATCH: Scoped consent path '{c_path}' does not authorize mutation path '{m_path}'."],
521
+ "response_preview": "Active request blocked: consent path mismatch."
522
+ }
523
+
524
+ if not c_target or not c_nonce or c_expiry is None or not c_session:
454
525
  return {
455
526
  "name": mutation.get("name", "unnamed"),
456
527
  "type": mutation.get("type", "UNKNOWN"),
@@ -460,10 +531,135 @@ class ApiFuzzer:
460
531
  "duration_ms": 0.0,
461
532
  "verdict": "FAIL",
462
533
  "severity": "CRITICAL",
463
- "alarms": [f"CONSENT_MISMATCH: Scoped consent path '{c_path}' does not authorize mutation path '{mutation.get('path')}'."],
534
+ "alarms": ["CONSENT_REQUIRED: Granular grant dictionary missing mandatory fields (action, target, caller_session, nonce, expiry)."],
535
+ "response_preview": "Active request blocked: missing mandatory consent fields."
536
+ }
537
+ else:
538
+ return {
539
+ "name": mutation.get("name", "unnamed"),
540
+ "type": mutation.get("type", "UNKNOWN"),
541
+ "url": mask_secrets(url),
542
+ "method": method,
543
+ "status_code": -5,
544
+ "duration_ms": 0.0,
545
+ "verdict": "FAIL",
546
+ "severity": "CRITICAL",
547
+ "alarms": ["CONSENT_REQUIRED: Invalid consent type. Expected ConsentGrant or scoped grant dict."],
548
+ "response_preview": "Active request blocked: missing consent."
549
+ }
550
+
551
+ # 3. Check expiration
552
+ if c_expiry is not None:
553
+ try:
554
+ if time.time() > float(c_expiry):
555
+ return {
556
+ "name": mutation.get("name", "unnamed"),
557
+ "type": mutation.get("type", "UNKNOWN"),
558
+ "url": mask_secrets(url),
559
+ "method": method,
560
+ "status_code": -5,
561
+ "duration_ms": 0.0,
562
+ "verdict": "FAIL",
563
+ "severity": "CRITICAL",
564
+ "alarms": ["CONSENT_EXPIRED: Consent grant has expired."],
565
+ "response_preview": "Active request blocked: consent expired."
566
+ }
567
+ except (ValueError, TypeError) as exp_err:
568
+ return {
569
+ "name": mutation.get("name", "unnamed"),
570
+ "type": mutation.get("type", "UNKNOWN"),
571
+ "url": mask_secrets(url),
572
+ "method": method,
573
+ "status_code": -5,
574
+ "duration_ms": 0.0,
575
+ "verdict": "FAIL",
576
+ "severity": "CRITICAL",
577
+ "alarms": [f"CONSENT_INVALID_EXPIRY: {exp_err}"],
578
+ "response_preview": "Active request blocked: consent expiry invalid."
579
+ }
580
+
581
+ # 4. Check nonce replay
582
+ if c_nonce:
583
+ if hasattr(self.scope_guard, "consumed_nonces") and c_nonce in self.scope_guard.consumed_nonces:
584
+ return {
585
+ "name": mutation.get("name", "unnamed"),
586
+ "type": mutation.get("type", "UNKNOWN"),
587
+ "url": mask_secrets(url),
588
+ "method": method,
589
+ "status_code": -5,
590
+ "duration_ms": 0.0,
591
+ "verdict": "FAIL",
592
+ "severity": "CRITICAL",
593
+ "alarms": ["CONSENT_REPLAYED: Replay attack detected. Consent nonce has already been consumed."],
594
+ "response_preview": "Active request blocked: consent replayed."
595
+ }
596
+
597
+ # 5. Check target mismatch
598
+ if c_target and not (url.startswith(c_target.rstrip("/")) or self.base_url == c_target.rstrip("/")):
599
+ return {
600
+ "name": mutation.get("name", "unnamed"),
601
+ "type": mutation.get("type", "UNKNOWN"),
602
+ "url": mask_secrets(url),
603
+ "method": method,
604
+ "status_code": -5,
605
+ "duration_ms": 0.0,
606
+ "verdict": "FAIL",
607
+ "severity": "CRITICAL",
608
+ "alarms": [f"CONSENT_MISMATCH: Scoped consent target '{c_target}' does not authorize target URL '{mask_secrets(url)}'."],
609
+ "response_preview": "Active request blocked: consent target mismatch."
610
+ }
611
+
612
+ # 6. Check method mismatch
613
+ if c_method and c_method.upper() != method.upper():
614
+ return {
615
+ "name": mutation.get("name", "unnamed"),
616
+ "type": mutation.get("type", "UNKNOWN"),
617
+ "url": mask_secrets(url),
618
+ "method": method,
619
+ "status_code": -5,
620
+ "duration_ms": 0.0,
621
+ "verdict": "FAIL",
622
+ "severity": "CRITICAL",
623
+ "alarms": [f"CONSENT_MISMATCH: Scoped consent method '{c_method}' does not authorize mutation method '{method}'."],
624
+ "response_preview": "Active request blocked: consent method mismatch."
625
+ }
626
+
627
+ # 7. Check path mismatch
628
+ if c_path:
629
+ m_path = mutation.get("path", "")
630
+ if c_path != m_path and not fnmatch.fnmatch(m_path, c_path):
631
+ return {
632
+ "name": mutation.get("name", "unnamed"),
633
+ "type": mutation.get("type", "UNKNOWN"),
634
+ "url": mask_secrets(url),
635
+ "method": method,
636
+ "status_code": -5,
637
+ "duration_ms": 0.0,
638
+ "verdict": "FAIL",
639
+ "severity": "CRITICAL",
640
+ "alarms": [f"CONSENT_MISMATCH: Scoped consent path '{c_path}' does not authorize mutation path '{m_path}'."],
464
641
  "response_preview": "Active request blocked: consent path mismatch."
465
642
  }
466
643
 
644
+ # 8. Verify with PentestScopeGuard
645
+ if not self.scope_guard.verify_consent(effective_consent, expected_action="http:fuzz", expected_target=self.base_url):
646
+ return {
647
+ "name": mutation.get("name", "unnamed"),
648
+ "type": mutation.get("type", "UNKNOWN"),
649
+ "url": mask_secrets(url),
650
+ "method": method,
651
+ "status_code": -5,
652
+ "duration_ms": 0.0,
653
+ "verdict": "FAIL",
654
+ "severity": "CRITICAL",
655
+ "alarms": ["CONSENT_REQUIRED: Consent verification failed against pentest scope guard."],
656
+ "response_preview": "Active request blocked: missing consent."
657
+ }
658
+
659
+ # Mark nonce consumed
660
+ if c_nonce and hasattr(self.scope_guard, "consumed_nonces"):
661
+ self.scope_guard.consumed_nonces.add(c_nonce)
662
+
467
663
  # Check target URL with PentestScopeGuard before network dispatch (Consent NEVER bypasses host scope guard)
468
664
  ok, scope_reason = self.scope_guard.validate_target(url, actor="ApiFuzzer.execute_request")
469
665
  if not ok:
@@ -571,15 +767,43 @@ class ApiFuzzer:
571
767
 
572
768
  def run_fuzz_suite(self, dry_run: bool = False, consent: Any = False) -> Dict[str, Any]:
573
769
  """Runs the complete fuzzing suite against all extracted targets."""
770
+ effective_dry_run = dry_run or self.dry_run
771
+ parent_nonce = None
574
772
  # Consent validation: active live testing requires explicit consent
575
- if not dry_run:
576
- has_consent = self.scope_guard.verify_consent(consent)
773
+ if not effective_dry_run:
774
+ effective_consent = self.consent if consent is False else consent
775
+ has_consent = self.scope_guard.verify_consent(
776
+ effective_consent,
777
+ expected_action="http:fuzz",
778
+ expected_target=self.base_url,
779
+ mark_consumed=False # Do not burn session nonce during pre-flight check!
780
+ )
577
781
  if not has_consent:
578
782
  raise PermissionError(
579
- "Active API fuzzing requires explicit consent. Set PENTEST_CONSENT_ACKNOWLEDGED=1, "
580
- "pass --confirm-pentest-scope, or set dry_run=True to preview safely."
783
+ "Active API fuzzing requires explicit consent. Provide a valid granular ConsentGrant "
784
+ "(or pass --confirm-pentest-scope on CLI), or set dry_run=True to preview safely."
581
785
  )
582
786
 
787
+ # Extract parent session grant attributes for deriving child request grants
788
+ if is_consent_grant(effective_consent):
789
+ parent_action = effective_consent.action
790
+ parent_target = effective_consent.target
791
+ parent_session = effective_consent.caller_session
792
+ parent_nonce = effective_consent.nonce
793
+ parent_expiry = effective_consent.expiry
794
+ elif isinstance(effective_consent, dict):
795
+ parent_action = effective_consent.get("action") or effective_consent.get("operation") or "http:fuzz"
796
+ parent_target = effective_consent.get("target") or effective_consent.get("target_sandbox") or effective_consent.get("base_url") or self.base_url
797
+ parent_session = effective_consent.get("caller_session") or effective_consent.get("session") or f"cli_{os.getpid()}"
798
+ parent_nonce = effective_consent.get("nonce")
799
+ parent_expiry = effective_consent.get("expiry") or (time.time() + 300.0)
800
+ else:
801
+ parent_action = "http:fuzz"
802
+ parent_target = self.base_url
803
+ parent_session = f"cli_{os.getpid()}"
804
+ parent_nonce = secrets.token_hex(16)
805
+ parent_expiry = time.time() + 300.0
806
+
583
807
  spec = self.load_spec()
584
808
  targets = self.extract_fuzz_targets(spec)
585
809
 
@@ -605,24 +829,43 @@ class ApiFuzzer:
605
829
  print(f" Total Mutations : {len(all_mutations)} (capped from {total_generated})" if volume_capped else f" Total Mutations : {len(all_mutations)}")
606
830
  print(f" SLA Threshold : {self.sla_ms} ms")
607
831
  print(f" Rate Limit Max : {self.rate_limiter.max_req_per_sec} req/s")
608
- print(f" Mode : {'DRY-RUN (Air-Gapped / Deterministic)' if dry_run else 'LIVE STAGING ATTACK'}\n")
609
-
610
- for idx, m in enumerate(all_mutations, start=1):
611
- if not dry_run:
612
- self.rate_limiter.acquire()
613
-
614
- res = self.execute_request(m, dry_run=dry_run, consent=consent if not dry_run else None)
615
- results.append(res)
616
-
617
- if not dry_run and res["status_code"] > 0:
618
- self.rate_limiter.record_response(res["status_code"])
832
+ print(f" Mode : {'DRY-RUN (Air-Gapped / Deterministic)' if effective_dry_run else 'LIVE STAGING ATTACK'}\n")
619
833
 
620
- status_str = f"{GREEN}PASS{RESET}" if res["verdict"] == "PASS" else f"{RED}ALARM{RESET}"
621
- sys.stdout.write(f" [{idx:03d}/{len(all_mutations):03d}] {status_str} | HTTP {res['status_code']} ({res['duration_ms']}ms) | {m['name']}\n")
622
- if res["alarms"]:
623
- total_failures += 1
624
- for alarm in res["alarms"]:
625
- print(f" 👉 {RED}{BOLD}[DEFECT]{RESET} {alarm}")
834
+ try:
835
+ for idx, m in enumerate(all_mutations, start=1):
836
+ if not effective_dry_run:
837
+ self.rate_limiter.acquire()
838
+ sub_nonce = f"{parent_nonce}:sub_{idx}_{uuid.uuid4().hex[:8]}" if parent_nonce else secrets.token_hex(16)
839
+ child_grant = ConsentGrant(
840
+ action=parent_action,
841
+ target=parent_target,
842
+ caller_session=parent_session,
843
+ nonce=sub_nonce,
844
+ expiry=float(parent_expiry),
845
+ method=m.get("method"),
846
+ path_pattern=m.get("path")
847
+ )
848
+ res = self.execute_request(m, dry_run=False, consent=child_grant)
849
+ else:
850
+ res = self.execute_request(m, dry_run=True, consent=None)
851
+
852
+ results.append(res)
853
+
854
+ if not effective_dry_run and res["status_code"] > 0:
855
+ self.rate_limiter.record_response(res["status_code"])
856
+
857
+ status_str = f"{GREEN}PASS{RESET}" if res["verdict"] == "PASS" else f"{RED}ALARM{RESET}"
858
+ sys.stdout.write(f" [{idx:03d}/{len(all_mutations):03d}] {status_str} | HTTP {res['status_code']} ({res['duration_ms']}ms) | {m['name']}\n")
859
+ if res["alarms"]:
860
+ total_failures += 1
861
+ for alarm in res["alarms"]:
862
+ print(f" 👉 {RED}{BOLD}[DEFECT]{RESET} {alarm}")
863
+ finally:
864
+ if not effective_dry_run and parent_nonce:
865
+ clean_p_nonce = str(parent_nonce).strip()
866
+ if hasattr(self.scope_guard, "consumed_nonces"):
867
+ self.scope_guard.consumed_nonces.add(clean_p_nonce)
868
+ _GLOBAL_CONSUMED_NONCES.add(clean_p_nonce)
626
869
 
627
870
  scorecard = {
628
871
  "base_url": mask_secrets(self.base_url),
@@ -795,13 +1038,24 @@ def main():
795
1038
  if args.token:
796
1039
  headers["Authorization"] = f"Bearer {args.token}"
797
1040
 
1041
+ grant = None
1042
+ if args.confirm_pentest_scope:
1043
+ grant = create_consent_grant(
1044
+ action="http:fuzz",
1045
+ target=args.base_url,
1046
+ caller_session=f"cli_{os.getpid()}",
1047
+ ttl_seconds=300
1048
+ )
1049
+
798
1050
  fuzzer = ApiFuzzer(
799
1051
  base_url=args.base_url,
800
1052
  spec_path_or_url=args.spec,
801
1053
  headers=headers,
802
1054
  sla_ms=args.sla_ms,
803
1055
  insecure=args.insecure,
804
- max_requests=args.max_requests
1056
+ max_requests=args.max_requests,
1057
+ dry_run=args.dry_run,
1058
+ consent=grant
805
1059
  )
806
1060
 
807
1061
  if args.mode == "passive":
@@ -812,7 +1066,7 @@ def main():
812
1066
  blocking = int(severity_dict.get("HIGH", 0)) + int(severity_dict.get("CRITICAL", 0))
813
1067
  return 1 if blocking > 0 else 0
814
1068
 
815
- scorecard = fuzzer.run_fuzz_suite(dry_run=args.dry_run, consent=args.confirm_pentest_scope)
1069
+ scorecard = fuzzer.run_fuzz_suite(dry_run=args.dry_run, consent=grant)
816
1070
  if args.json:
817
1071
  print(json.dumps(scorecard, indent=2))
818
1072
 
@@ -548,15 +548,22 @@ def main() -> int:
548
548
  parser.add_argument("--dataset-dir", default=None,
549
549
  help="Path to external standardized benchmark dataset directory (containing scenarios.json)")
550
550
  parser.add_argument("--json", action="store_true", help="Output results in JSON format")
551
- parser.add_argument("--save-report", action="store_true", default=True, help="Persist markdown report to benchmarks/CONTEXT_TOKEN_BENCHMARK.md")
551
+ parser.add_argument("--save-report", action="store_true", default=False, help="Persist markdown report to benchmarks/CONTEXT_TOKEN_BENCHMARK.md (default: False)")
552
+ parser.add_argument("--no-write", action="store_true", default=False, help="Completely suppress writing reports or benchmarks to disk")
553
+ parser.add_argument("--output-dir", default=None, help="Directory to write reports instead of default benchmarks/ and reports/")
552
554
  args = parser.parse_args()
553
555
 
554
556
  bench = run_benchmark(dataset_dir=args.dataset_dir)
555
557
 
556
558
  # Save to disk
557
- if args.save_report:
558
- bench_dir = os.path.join(REPO_ROOT, "benchmarks")
559
- reports_dir = os.path.join(REPO_ROOT, "reports")
559
+ should_save = (args.save_report or args.output_dir is not None) and not args.no_write
560
+ if should_save:
561
+ if args.output_dir:
562
+ bench_dir = os.path.abspath(args.output_dir)
563
+ reports_dir = os.path.abspath(args.output_dir)
564
+ else:
565
+ bench_dir = os.path.join(REPO_ROOT, "benchmarks")
566
+ reports_dir = os.path.join(REPO_ROOT, "reports")
560
567
  os.makedirs(bench_dir, exist_ok=True)
561
568
  os.makedirs(reports_dir, exist_ok=True)
562
569
 
@@ -13,7 +13,7 @@
13
13
  (function () {
14
14
  'use strict';
15
15
 
16
- if (window.__qa && window.__qa.__version === '4.2.0') {
16
+ if (window.__qa && window.__qa.__version === '4.2.2') {
17
17
  return window.__qa;
18
18
  }
19
19
 
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  const qa = {
50
- __version: '4.2.0',
50
+ __version: '4.2.2',
51
51
 
52
52
  /**
53
53
  * 1. Smart Action Batching
@@ -206,13 +206,13 @@ def run_tests() -> bool:
206
206
  print("\n🔍 Running 10 DoD Quality Gates verification...")
207
207
  verify_script = os.path.join(REPO_ROOT, "tools", "verify_all.py")
208
208
  try:
209
- res_verify = subprocess.run([sys.executable, verify_script], cwd=REPO_ROOT, timeout=240.0)
209
+ res_verify = subprocess.run([sys.executable, verify_script], cwd=REPO_ROOT, timeout=360.0)
210
210
  if res_verify.returncode != 0:
211
211
  print("❌ Quality Gates failed! Aborting release.")
212
212
  return False
213
213
  print("✅ 10 Quality Gates DoD PASSED.")
214
214
  except subprocess.TimeoutExpired:
215
- print("❌ Quality Gates timed out after 240s! Aborting release.")
215
+ print("❌ Quality Gates timed out after 360s! Aborting release.")
216
216
  return False
217
217
  return True
218
218
 
package/tools/cli.py CHANGED
@@ -133,7 +133,7 @@ def _resolve_manifest_path(repo_root: Optional[str] = None) -> Optional[str]:
133
133
  def cmd_version(args):
134
134
  """Displays the current hub version, skill catalog count, and license information."""
135
135
  manifest_path = _resolve_manifest_path()
136
- version = "4.2.0"
136
+ version = "4.2.2"
137
137
  manifest_skills = 53
138
138
  if manifest_path and os.path.exists(manifest_path):
139
139
  try:
@@ -220,7 +220,7 @@ def cmd_heal(args):
220
220
 
221
221
 
222
222
  def cmd_distill(args):
223
- """Distills and filters high-volume CI/CD test execution logs by ~95%."""
223
+ """Distills and filters high-volume CI/CD test execution logs to actionable failure signals."""
224
224
  from distill_log import main as distill_main
225
225
  sys.argv = _forward_subcommand_args(args)
226
226
  sys.exit(distill_main())
@@ -775,14 +775,14 @@ def cmd_trend(args):
775
775
 
776
776
  def _hub_version():
777
777
  manifest_path = _resolve_manifest_path()
778
- version = "4.2.0"
778
+ version = "4.2.2"
779
779
  if manifest_path and os.path.exists(manifest_path):
780
780
  try:
781
781
  import json
782
782
  with open(manifest_path, "r", encoding="utf-8") as f:
783
783
  version = json.load(f).get("version", version)
784
784
  except (OSError, json.JSONDecodeError):
785
- version = "4.2.0"
785
+ version = "4.2.2"
786
786
  return version
787
787
 
788
788
 
@@ -7,7 +7,7 @@
7
7
  tools/core/bm25_retriever.py — Zero-Dependency Pure Python BM25 Knowledge Retriever
8
8
  Inspired by nextlevelbuilder/ui-ux-pro-max-skill core.py algorithm.
9
9
  Enables instant sub-millisecond retrieval of guidelines, rules, and QA patterns
10
- with zero external dependencies and guaranteed < 300 character truncation (95% token savings).
10
+ with zero external dependencies and guaranteed < 300 character truncation (targeted context reduction).
11
11
  100% UTF-8 No BOM.
12
12
  """
13
13
 
@@ -178,7 +178,7 @@ MESSAGES: Dict[str, Dict[str, str]] = {
178
178
  "cmd_review_spec": "Đánh giá chất lượng tài liệu đặc tả & user story theo mô hình Elephant-Goldfish",
179
179
  "cmd_drift_check": "Giám sát độ lệch giữa đặc tả và mã kiểm thử thực tế (Deficit & Scope Drift)",
180
180
  "cmd_trace_data_flow": "Theo dõi vòng đời dữ liệu test để phát hiện rò rỉ DB và thiếu sót teardown",
181
- "cmd_distill": "Cô đọng và tinh lọc log dài dòng giảm 95% độ nhiễu",
181
+ "cmd_distill": "Cô đọng và tinh lọc log dài dòng giảm nhiễu",
182
182
  "cmd_gherkin": "Biên dịch file Gherkin .feature thành ma trận kiểm thử, Universal IR và báo cáo thiếu phủ (0-token)",
183
183
  "cmd_omni_scan": "Quét toàn bộ dự án và thống kê danh mục kiểm thử đa ngôn ngữ (0-token)",
184
184
  "cmd_report_bug": "Tự động tạo phiếu báo lỗi Jira/Markdown chuyên nghiệp kèm phân tích nguyên nhân gốc",