@teevee98/synapse-hub 4.1.3 → 4.2.0
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/.agents/rules/git-push-protocol.md +2 -2
- package/.agents/skills/01-web-automation/auth-session-and-cookie-manager/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/bats-testing-patterns/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/clean-pom-crafter/SKILL.md +8 -3
- package/.agents/skills/01-web-automation/clean-pom-crafter/examples/standard_test_case.groovy +3 -0
- package/.agents/skills/01-web-automation/clean-pom-crafter/references/pom_patterns.groovy +3 -0
- package/.agents/skills/01-web-automation/e2e-testing-patterns/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/e2e-testing-patterns/examples/playwright_sharded_config.ts +3 -0
- package/.agents/skills/01-web-automation/katalon-cli-runner/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/lam-script-generator/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/mobile-appium-som/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/BaseScreen.java +2 -2
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/LoginScreen.java +2 -2
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/TC_MobileLogin.java +2 -2
- package/.agents/skills/01-web-automation/playwright-live-interaction/SKILL.md +7 -2
- package/.agents/skills/01-web-automation/playwright-webapp-testing/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/playwright-webapp-testing/examples/server_lifecycle_playwright.py +3 -0
- package/.agents/skills/01-web-automation/web-agent-gym-benchmarking/SKILL.md +6 -1
- package/.agents/skills/02-test-design/architecture-decision-records/SKILL.md +6 -1
- package/.agents/skills/02-test-design/gherkin-to-suite/SKILL.md +6 -1
- package/.agents/skills/02-test-design/rbt-manual-testing/SKILL.md +6 -1
- package/.agents/skills/02-test-design/review-spec/SKILL.md +4 -1
- package/.agents/skills/02-test-design/tot-exploratory-testing/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/api-network-mocking-interception/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/api-spec-to-e2e-matrix/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/consumer-driven-contract-testing/SKILL.md +7 -2
- package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/SKILL.md +7 -2
- package/.agents/skills/04-performance-and-load/lean-impact-scoreboard/SKILL.md +4 -1
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/SKILL.md +6 -1
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +3 -0
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/SKILL.md +6 -1
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/references/dast_recipes.ts +3 -0
- package/.agents/skills/05-security-and-compliance/skillspector-security-guard/SKILL.md +6 -1
- package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/agentless-qa-repair/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/antigravity-test-sentinel/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/failure-autopsy-and-healing/SKILL.md +7 -2
- package/.agents/skills/06-healing-and-resilience/flaky-test-sentinel-and-quarantine/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/self-healing-locator/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/systematic-debugging/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/test-driven-development/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/verification-before-completion/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/visual-regression-sentinel/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/db-state-verifier-and-seeder/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/file-and-report-validator/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +3 -0
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +3 -0
- package/.agents/skills/08-code-quality/graphify-impact-analyzer/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/lean-code-ladder/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/repo-quality-audit/SKILL.md +4 -1
- package/.agents/skills/08-code-quality/senior-code-review/SKILL.md +4 -1
- package/.agents/skills/08-code-quality/surgical-coding-principles/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/technical-debt-harvester/SKILL.md +4 -1
- package/.agents/skills/09-ci-and-devops/github-actions-templates/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/actor-qa-swarm/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/agent-orchestration-multi-agent-optimize/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/event-stream-qa-orchestrator/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/persistent-planning-files/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/qa-memory-os/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/meta-prompt-crafter/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/mipro-prompt-compiler/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/qa-aci-interface/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/qa-aci-interface/examples/surgical_code_window_walkthrough.md +1 -1
- package/.agents/skills/11-ai-and-prompting/token-and-context-optimizer/SKILL.md +6 -1
- package/AGENTS.md +7 -1
- package/LICENSE +5 -5
- package/NOTICE +1 -1
- package/README.en.md +4 -4
- package/README.md +4 -4
- package/agentskills.json +1 -1
- package/docs/ARCHITECTURE.en.md +2 -2
- package/docs/ARCHITECTURE.md +11 -2
- package/docs/CLI_REFERENCE.en.md +6 -4
- package/docs/CLI_REFERENCE.md +1 -1
- package/docs/CONTRIBUTING.en.md +1 -1
- package/docs/CONTRIBUTING.md +2 -2
- package/docs/PERFORMANCE_AUDIT_REPORT.md +2 -2
- package/docs/TOOL_CATALOG.md +6 -2
- package/docs/research/agent_skill_training_analysis.md +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/generate_skill_examples.py +3 -0
- package/scripts/package_dist.py +3 -0
- package/skills_manifest.json +320 -55
- package/synapse.config.json +1 -1
- package/templates/ui/index.html +2 -2
- package/tools/.infer_baseline.json +3 -796
- package/tools/TOOL_CATALOG.json +63 -3
- package/tools/__init__.py +4 -1
- package/tools/agent_canary.py +3 -0
- package/tools/analyze_project.py +3 -0
- package/tools/api_drift_sentinel.py +3 -0
- package/tools/api_fuzzer.py +182 -118
- package/tools/ast_cache.py +4 -2
- package/tools/author_integrity.py +174 -12
- package/tools/auto_heal.py +7 -2
- package/tools/autogen_qa_broker.py +14 -15
- package/tools/benchmark_swarm_context.py +119 -18
- package/tools/break_ui_generator.py +233 -0
- package/tools/browser_helpers.js +2 -2
- package/tools/bug_reporter.py +3 -0
- package/tools/build_consolidated_report.py +3 -0
- package/tools/bump_version.py +4 -1
- package/tools/cache_resolver.py +7 -3
- package/tools/check_env.py +3 -0
- package/tools/check_version_sync.py +21 -50
- package/tools/ci_healing_hook.py +3 -0
- package/tools/cli.py +116 -22
- package/tools/config_decoupler.py +3 -0
- package/tools/core/__init__.py +3 -0
- package/tools/core/bm25_retriever.py +218 -0
- package/tools/core/file_lock.py +23 -14
- package/tools/core/i18n.py +13 -11
- package/tools/core/memory_bus.py +6 -3
- package/tools/core/process_supervisor.py +28 -18
- package/tools/core/provider_usage_adapter.py +317 -0
- package/tools/core/token_estimator.py +83 -18
- package/tools/count_tokens.py +16 -7
- package/tools/coverage_reporter.py +245 -0
- package/tools/create_mock_docx.py +3 -0
- package/tools/dashboard_generator.py +17 -15
- package/tools/db_sandbox.py +150 -5
- package/tools/debt_harvester.py +2 -2
- package/tools/diagram_architect.py +3 -0
- package/tools/distill_log.py +22 -2
- package/tools/distill_skill.py +191 -0
- package/tools/e2e_flow_prober.py +3 -0
- package/tools/export_postman_collection.py +3 -0
- package/tools/flaky_detector.py +3 -0
- package/tools/fsm_enforcer.py +2 -2
- package/tools/fuzz_payloads.py +3 -0
- package/tools/generate_allure_report.py +3 -0
- package/tools/generate_api_matrix.py +3 -0
- package/tools/generate_jmx_plan.py +3 -0
- package/tools/generate_tc_from_story.py +3 -0
- package/tools/generate_test_reports.py +3 -0
- package/tools/git_pre_commit_guard.py +25 -3
- package/tools/git_worktree_manager.py +3 -0
- package/tools/heal/__init__.py +3 -0
- package/tools/heal_pr_automator.py +3 -0
- package/tools/heuristic_locator_matcher.py +3 -0
- package/tools/hub_publisher.py +3 -3
- package/tools/humanize_linter.py +3 -0
- package/tools/infer_linter.py +19 -9
- package/tools/init_config.py +6 -9
- package/tools/jtl_analyzer.py +3 -0
- package/tools/lint/__init__.py +3 -0
- package/tools/lint_ai_docs.py +3 -0
- package/tools/lookup_tc.py +3 -0
- package/tools/lookup_xpath.py +3 -0
- package/tools/matrix_sharder.py +3 -0
- package/tools/mcp/__init__.py +3 -0
- package/tools/mcp_docx_server.py +1 -1
- package/tools/mcp_excel_server.py +4 -1
- package/tools/mcp_server.py +78 -15
- package/tools/md_to_xlsx.py +3 -0
- package/tools/mechanical_ui_gate.py +3 -0
- package/tools/micro_mutator.py +93 -19
- package/tools/network_mock_shield.py +3 -0
- package/tools/newman_analyzer.py +3 -0
- package/tools/omni_emitter.py +3 -0
- package/tools/omni_parser.py +3 -0
- package/tools/omni_transpiler.py +3 -0
- package/tools/output_formatter.py +3 -0
- package/tools/package_release.py +6 -6
- package/tools/pairwise_generator.py +3 -0
- package/tools/pentest_scope_guard.py +401 -58
- package/tools/perf/__init__.py +3 -0
- package/tools/perf/benchmark_perf_runner.py +42 -0
- package/tools/pinpoint_failure.py +3 -0
- package/tools/project_state.py +3 -0
- package/tools/repo_map.py +3 -0
- package/tools/report/__init__.py +3 -0
- package/tools/rules_router.py +426 -34
- package/tools/runaway_stopper.py +3 -0
- package/tools/safety_firewall.py +3 -0
- package/tools/security_scanner.py +80 -0
- package/tools/senior_code_review.py +14 -0
- package/tools/setup_project.py +9 -4
- package/tools/skill_canonical_digest.py +244 -0
- package/tools/skill_collision_guard.py +2 -2
- package/tools/skill_profiles.py +77 -7
- package/tools/skillspector.py +2 -1
- package/tools/slide_deck_exporter.py +477 -0
- package/tools/smart_visual_masker.py +3 -0
- package/tools/sync_skills_manifest.py +166 -0
- package/tools/task_memory_manager.py +260 -0
- package/tools/telemetry_correlator.py +3 -0
- package/tools/template_excel_exporter.py +2 -2
- package/tools/test_impact.py +3 -0
- package/tools/trace_data_flow.py +3 -0
- package/tools/traffic_session_converter.py +3 -0
- package/tools/ui_server.py +2 -2
- package/tools/universal_ir.py +3 -0
- package/tools/update_sentinel.py +15 -9
- package/tools/validate_groovy_scripts.py +3 -0
- package/tools/validate_host_interop.py +485 -0
- package/tools/validate_skills_schema.py +282 -0
- package/tools/verify_all.py +600 -63
- package/tools/visual_diff_canvas.py +3 -0
- package/tools/visual_som_helper.py +3 -0
- package/tools/watch_mode.py +4 -4
- package/tools/wcag_audit.py +3 -0
- package/tools/welcome_page.py +2 -2
package/tools/mcp_server.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Enterprise Model Context Protocol (MCP) Standard Server
|
|
4
7
|
-------------------------------------------------------
|
|
@@ -11,6 +14,7 @@ import os
|
|
|
11
14
|
import sys
|
|
12
15
|
import json
|
|
13
16
|
import re
|
|
17
|
+
import tempfile
|
|
14
18
|
from pathlib import Path
|
|
15
19
|
from typing import Dict, Any, Optional, Set
|
|
16
20
|
|
|
@@ -46,7 +50,7 @@ import gherkin_suite
|
|
|
46
50
|
import api_fuzzer
|
|
47
51
|
|
|
48
52
|
SERVER_NAME = "enterprise-agent-qa"
|
|
49
|
-
SERVER_VERSION = "4.
|
|
53
|
+
SERVER_VERSION = "4.2.0"
|
|
50
54
|
|
|
51
55
|
MCP_TOOLS = [
|
|
52
56
|
{
|
|
@@ -211,7 +215,8 @@ MCP_TOOLS = [
|
|
|
211
215
|
"action": {"type": "string", "enum": ["snapshot", "restore", "audit_and_purge"], "description": "Sandbox operation to execute."},
|
|
212
216
|
"db_path": {"type": "string", "description": "Path to database file (optional for SQLite)."},
|
|
213
217
|
"snapshot_id": {"type": "string", "description": "Snapshot identifier (default: pristine_baseline)."},
|
|
214
|
-
"dry_run": {"type": "boolean", "description": "For audit_and_purge: preview
|
|
218
|
+
"dry_run": {"type": "boolean", "default": True, "description": "For restore and audit_and_purge: preview actions without modifying database (default: true)."},
|
|
219
|
+
"consent": {"type": "boolean", "default": False, "description": "Explicit consent acknowledgement for destructive state modification when dry_run=False."}
|
|
215
220
|
},
|
|
216
221
|
"required": ["action"]
|
|
217
222
|
}
|
|
@@ -259,8 +264,9 @@ MCP_TOOLS = [
|
|
|
259
264
|
"properties": {
|
|
260
265
|
"base_url": {"type": "string", "description": "Base URL of target API (non-production allowlist enforced)."},
|
|
261
266
|
"spec_path": {"type": "string", "description": "Path or URL to OpenAPI/Swagger JSON spec."},
|
|
262
|
-
"mode": {"type": "string", "enum": ["active", "passive"], "description": "active fuzzing or passive offline spec audit."},
|
|
263
|
-
"dry_run": {"type": "boolean", "description": "Deterministic offline mock (default true for safety)."}
|
|
267
|
+
"mode": {"type": "string", "enum": ["active", "passive"], "default": "passive", "description": "active fuzzing or passive offline spec audit (default: passive)."},
|
|
268
|
+
"dry_run": {"type": "boolean", "default": True, "description": "Deterministic offline mock (default true for safety)."},
|
|
269
|
+
"consent": {"type": "boolean", "default": False, "description": "Explicit consent acknowledgement for active mutations when mode=active and dry_run=False."}
|
|
264
270
|
},
|
|
265
271
|
"required": ["base_url"]
|
|
266
272
|
}
|
|
@@ -292,8 +298,12 @@ def _validate_safe_path(filepath: str, allowed_root: Optional[str] = None, allow
|
|
|
292
298
|
root_norm = os.path.normcase(str(root_path))
|
|
293
299
|
target_norm = os.path.normcase(str(target_path))
|
|
294
300
|
|
|
295
|
-
# Path must reside within the allowed root
|
|
296
|
-
|
|
301
|
+
# Path must reside within the allowed root OR within the OS temporary directory
|
|
302
|
+
temp_dir_norm = os.path.normcase(str(Path(tempfile.gettempdir()).resolve()))
|
|
303
|
+
is_temp_path = target_norm == temp_dir_norm or target_norm.startswith(temp_dir_norm + os.sep)
|
|
304
|
+
is_in_root = (target_norm == root_norm or target_norm.startswith(root_norm + os.sep))
|
|
305
|
+
|
|
306
|
+
if not is_in_root and not is_temp_path:
|
|
297
307
|
raise PermissionError(f"Access denied: path '{filepath}' resolves outside allowed project root '{root_path}'")
|
|
298
308
|
|
|
299
309
|
# Reject explicit sensitive configuration / secret files and private keys
|
|
@@ -331,8 +341,16 @@ def _validate_safe_path(filepath: str, allowed_root: Optional[str] = None, allow
|
|
|
331
341
|
except OSError:
|
|
332
342
|
sensitive_prefixes.append(Path(win_val))
|
|
333
343
|
|
|
344
|
+
temp_dir_norm = os.path.normcase(str(Path(tempfile.gettempdir()).resolve()))
|
|
345
|
+
is_temp_path = target_norm == temp_dir_norm or target_norm.startswith(temp_dir_norm + os.sep)
|
|
346
|
+
|
|
334
347
|
for sp in sensitive_prefixes:
|
|
335
348
|
sp_norm = os.path.normcase(str(sp))
|
|
349
|
+
if is_temp_path and sys.platform == "win32" and sp_norm in (
|
|
350
|
+
os.path.normcase(os.environ.get("LOCALAPPDATA", "")),
|
|
351
|
+
os.path.normcase(os.environ.get("APPDATA", "")),
|
|
352
|
+
):
|
|
353
|
+
continue
|
|
336
354
|
if target_norm == sp_norm or target_norm.startswith(sp_norm + os.sep):
|
|
337
355
|
raise PermissionError(f"Access denied: path references restricted system directory '{sp}'")
|
|
338
356
|
|
|
@@ -501,15 +519,37 @@ def _handle_manage_db_sandbox(arguments: Dict[str, Any]) -> str:
|
|
|
501
519
|
safe_db = _validate_safe_path(raw_db) if raw_db else ""
|
|
502
520
|
raw_id = arguments.get("snapshot_id", "pristine_baseline")
|
|
503
521
|
safe_id = re.sub(r'[^a-zA-Z0-9_\-]', '', raw_id) or "pristine_baseline"
|
|
522
|
+
consent = bool(arguments.get("consent", False)) or (os.environ.get("PENTEST_CONSENT_ACKNOWLEDGED", "").strip().lower() in ("1", "true", "yes"))
|
|
504
523
|
|
|
505
524
|
sandbox = db_sandbox.DBSandbox(db_path=safe_db)
|
|
506
525
|
if action == "snapshot":
|
|
507
526
|
res = sandbox.create_snapshot(safe_id)
|
|
508
527
|
elif action == "restore":
|
|
509
|
-
|
|
528
|
+
dry_run = bool(arguments.get("dry_run", True))
|
|
529
|
+
if dry_run:
|
|
530
|
+
res = {
|
|
531
|
+
"status": "dry_run_preview",
|
|
532
|
+
"action": "restore",
|
|
533
|
+
"snapshot_id": safe_id,
|
|
534
|
+
"db_path": safe_db or sandbox.db_path,
|
|
535
|
+
"dry_run": True,
|
|
536
|
+
"impact_summary": f"DRY-RUN PREVIEW: Would restore database snapshot '{safe_id}' to '{safe_db or sandbox.db_path}'. Pass dry_run=False and consent=True to execute."
|
|
537
|
+
}
|
|
538
|
+
else:
|
|
539
|
+
if not consent:
|
|
540
|
+
raise PermissionError(
|
|
541
|
+
f"Active restore operation on database '{safe_db or sandbox.db_path}' requires explicit consent. "
|
|
542
|
+
f"Pass consent=True to confirm state modification."
|
|
543
|
+
)
|
|
544
|
+
res = sandbox.restore_snapshot(safe_id, consent=consent, dry_run=dry_run)
|
|
510
545
|
elif action == "audit_and_purge":
|
|
511
|
-
dry_run = bool(arguments.get("dry_run",
|
|
512
|
-
|
|
546
|
+
dry_run = bool(arguments.get("dry_run", True))
|
|
547
|
+
if not dry_run and not consent:
|
|
548
|
+
raise PermissionError(
|
|
549
|
+
f"Active purge operation on database '{safe_db or sandbox.db_path}' requires explicit consent. "
|
|
550
|
+
f"Pass consent=True to confirm record deletion."
|
|
551
|
+
)
|
|
552
|
+
res = sandbox.audit_and_purge_pollution(dry_run=dry_run, consent=consent)
|
|
513
553
|
else:
|
|
514
554
|
raise ValueError(f"Unknown sandbox action: {action}")
|
|
515
555
|
return json.dumps(res, indent=2)
|
|
@@ -553,14 +593,36 @@ def _handle_compile_gherkin_suite(arguments: Dict[str, Any]) -> str:
|
|
|
553
593
|
|
|
554
594
|
|
|
555
595
|
def _handle_fuzz_api(arguments: Dict[str, Any]) -> str:
|
|
556
|
-
mode = arguments.get("mode", "
|
|
557
|
-
dry_run = arguments.get("dry_run", True)
|
|
596
|
+
mode = arguments.get("mode", "passive")
|
|
597
|
+
dry_run = bool(arguments.get("dry_run", True))
|
|
598
|
+
consent = bool(arguments.get("consent", False)) or (os.environ.get("PENTEST_CONSENT_ACKNOWLEDGED", "").strip().lower() in ("1", "true", "yes"))
|
|
558
599
|
spec_path = arguments.get("spec_path")
|
|
559
|
-
|
|
560
|
-
|
|
600
|
+
base_url = arguments.get("base_url", "")
|
|
601
|
+
|
|
602
|
+
from pentest_scope_guard import PentestScopeGuard
|
|
603
|
+
guard = PentestScopeGuard(allow_internal=True)
|
|
604
|
+
ok, reason = guard.validate_target(base_url, actor="mcp_server.fuzz_api")
|
|
605
|
+
if not ok:
|
|
606
|
+
raise PermissionError(f"[PENTEST SCOPE GUARD - REJECTED] Target base_url '{base_url}' blocked: {reason}")
|
|
607
|
+
|
|
608
|
+
if spec_path:
|
|
609
|
+
if spec_path.startswith(("http://", "https://")):
|
|
610
|
+
spec_ok, spec_reason = guard.validate_target(spec_path, actor="mcp_server.fuzz_api.spec_url")
|
|
611
|
+
if not spec_ok:
|
|
612
|
+
raise PermissionError(f"[PENTEST SCOPE GUARD - REJECTED] spec_path URL '{spec_path}' blocked: {spec_reason}")
|
|
613
|
+
else:
|
|
614
|
+
spec_path = _validate_safe_path(spec_path)
|
|
615
|
+
|
|
616
|
+
if mode == "active" and not dry_run:
|
|
617
|
+
if not consent:
|
|
618
|
+
raise PermissionError(
|
|
619
|
+
"Active API fuzzing (dry_run=False) requires explicit consent. Set consent=True or run with dry_run=True / mode=passive."
|
|
620
|
+
)
|
|
621
|
+
|
|
561
622
|
fuzzer = api_fuzzer.ApiFuzzer(
|
|
562
|
-
base_url=
|
|
623
|
+
base_url=base_url,
|
|
563
624
|
spec_path_or_url=spec_path,
|
|
625
|
+
scope_guard=guard,
|
|
564
626
|
)
|
|
565
627
|
if mode == "passive":
|
|
566
628
|
scorecard = fuzzer.run_passive_scan()
|
|
@@ -570,13 +632,14 @@ def _handle_fuzz_api(arguments: Dict[str, Any]) -> str:
|
|
|
570
632
|
"severity_summary": scorecard["severity_summary"],
|
|
571
633
|
"findings": scorecard["findings"],
|
|
572
634
|
}, indent=2)
|
|
573
|
-
scorecard = fuzzer.run_fuzz_suite(dry_run=dry_run)
|
|
635
|
+
scorecard = fuzzer.run_fuzz_suite(dry_run=dry_run, consent=consent)
|
|
574
636
|
return json.dumps({
|
|
575
637
|
"mode": scorecard["mode"],
|
|
576
638
|
"total_mutations": scorecard["total_mutations"],
|
|
577
639
|
"passed": scorecard["passed"],
|
|
578
640
|
"failed": scorecard["failed"],
|
|
579
641
|
"severity_summary": scorecard["severity_summary"],
|
|
642
|
+
"dry_run": scorecard["dry_run"],
|
|
580
643
|
}, indent=2)
|
|
581
644
|
|
|
582
645
|
|
package/tools/md_to_xlsx.py
CHANGED
package/tools/micro_mutator.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Assertion Sensitivity & Syntactic Micro-Mutation Sentinel (Heuristic)
|
|
4
7
|
---------------------------------------------------------------------
|
|
@@ -21,6 +24,7 @@ Implementation Note:
|
|
|
21
24
|
import os
|
|
22
25
|
import re
|
|
23
26
|
import sys
|
|
27
|
+
import glob
|
|
24
28
|
import json
|
|
25
29
|
import shlex
|
|
26
30
|
import html as html_lib
|
|
@@ -35,13 +39,13 @@ for stream in (sys.stdout, sys.stderr):
|
|
|
35
39
|
if hasattr(stream, 'fileno'):
|
|
36
40
|
try:
|
|
37
41
|
os.set_blocking(stream.fileno(), True)
|
|
38
|
-
except Exception
|
|
39
|
-
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
40
44
|
if hasattr(stream, 'reconfigure'):
|
|
41
45
|
try:
|
|
42
46
|
stream.reconfigure(encoding='utf-8')
|
|
43
|
-
except Exception
|
|
44
|
-
|
|
47
|
+
except Exception:
|
|
48
|
+
pass
|
|
45
49
|
|
|
46
50
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
47
51
|
HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
|
|
@@ -80,9 +84,23 @@ def resolve_scoped_test_cmd(scoped_template: str, target_file: str, repo_root: O
|
|
|
80
84
|
impacted = []
|
|
81
85
|
|
|
82
86
|
if not impacted:
|
|
83
|
-
# Fallback: if target is itself a test script, run on target
|
|
87
|
+
# Fallback 1: if target is itself a test script, run on target
|
|
84
88
|
if "tests/" in rel_path or "Scripts/" in rel_path or rel_path.endswith(("_test.py", ".spec.ts", ".test.ts", ".groovy")) or os.path.basename(rel_path).startswith("test_"):
|
|
85
89
|
impacted = [rel_path]
|
|
90
|
+
else:
|
|
91
|
+
# Fallback 2: convention-based test mapping for tools/<name>.py -> tests/test_<name>.py
|
|
92
|
+
base_mod = os.path.splitext(os.path.basename(rel_path))[0]
|
|
93
|
+
candidates = [
|
|
94
|
+
os.path.join("tests", f"test_{base_mod}.py"),
|
|
95
|
+
os.path.join("tests", f"{base_mod}_test.py"),
|
|
96
|
+
]
|
|
97
|
+
for cand in candidates:
|
|
98
|
+
cand_rel = cand.replace("\\", "/")
|
|
99
|
+
if os.path.isfile(os.path.join(root, cand_rel)):
|
|
100
|
+
impacted.append(cand_rel)
|
|
101
|
+
if not impacted:
|
|
102
|
+
for f in glob.glob(os.path.join(root, "tests", f"test_*{base_mod}*.py")):
|
|
103
|
+
impacted.append(os.path.relpath(f, root).replace("\\", "/"))
|
|
86
104
|
|
|
87
105
|
tests_str = " ".join(impacted) if impacted else ""
|
|
88
106
|
if "{test_files}" in scoped_template:
|
|
@@ -117,8 +135,8 @@ MUTATION_RULES = [
|
|
|
117
135
|
(r"\bor\b", "and", "Logical Inversion (or -> and)"),
|
|
118
136
|
(r"\s&&\s", " || ", "Logical AND Inversion (&& -> ||)"),
|
|
119
137
|
(r"\s\|\|\s", " && ", "Logical OR Inversion (|| -> &&)"),
|
|
120
|
-
(r"\s\bis\s", " is not ", "Identity Inversion (is -> is not)"),
|
|
121
|
-
(r"\s\bis
|
|
138
|
+
(r"\s\bis\s+(?!not\b)", " is not ", "Identity Inversion (is -> is not)"),
|
|
139
|
+
(r"\s\bis\s+not\s+", " is ", "Identity Inversion (is not -> is)"),
|
|
122
140
|
(r"\s\+\s", " - ", "Arithmetic Inversion (+ -> -)"),
|
|
123
141
|
(r"\s-\s", " + ", "Arithmetic Inversion (- -> +)"),
|
|
124
142
|
(r"\breturn\s+true\b", "return false", "Return Value Inversion (return true -> return false)"),
|
|
@@ -306,6 +324,13 @@ def generate_mutants_for_code(code: str, file_path: str = "") -> List[Dict[str,
|
|
|
306
324
|
mutated_lines[line_idx] = mutated_line
|
|
307
325
|
mutated_code = "".join(mutated_lines)
|
|
308
326
|
|
|
327
|
+
# Syntax guard for Python: ensure mutant produces valid Python syntax
|
|
328
|
+
if file_path.endswith((".py", ".pyw")):
|
|
329
|
+
try:
|
|
330
|
+
compile(mutated_code, file_path, "exec")
|
|
331
|
+
except SyntaxError:
|
|
332
|
+
continue
|
|
333
|
+
|
|
309
334
|
mutants.append({
|
|
310
335
|
"id": f"MUT-{mutant_id:04d}",
|
|
311
336
|
"file": file_path,
|
|
@@ -470,7 +495,14 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
470
495
|
else:
|
|
471
496
|
cmd_args = shlex.split(test_cmd, posix=True)
|
|
472
497
|
else:
|
|
473
|
-
cmd_args = test_cmd
|
|
498
|
+
cmd_args = list(test_cmd) if isinstance(test_cmd, (list, tuple)) else [str(test_cmd)]
|
|
499
|
+
|
|
500
|
+
# Guarantee sys.executable is used for running pytest or python
|
|
501
|
+
if cmd_args:
|
|
502
|
+
if cmd_args[0] == "pytest":
|
|
503
|
+
cmd_args = [sys.executable, "-m", "pytest"] + cmd_args[1:]
|
|
504
|
+
elif cmd_args[0] in ("python", "python3"):
|
|
505
|
+
cmd_args = [sys.executable] + cmd_args[1:]
|
|
474
506
|
use_shell = False
|
|
475
507
|
run_env = os.environ.copy()
|
|
476
508
|
run_env["PYTHONDONTWRITEBYTECODE"] = "1"
|
|
@@ -485,7 +517,7 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
485
517
|
cmd_args,
|
|
486
518
|
shell=use_shell,
|
|
487
519
|
capture_output=True,
|
|
488
|
-
timeout=
|
|
520
|
+
timeout=max(2.0, float(timeout)),
|
|
489
521
|
text=True,
|
|
490
522
|
env=run_env,
|
|
491
523
|
cwd=target_cwd
|
|
@@ -499,7 +531,7 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
499
531
|
except subprocess.TimeoutExpired:
|
|
500
532
|
for m in mutants:
|
|
501
533
|
m["status"] = "SURVIVED"
|
|
502
|
-
m["reason"] = f"Baseline execution error: timed out after {
|
|
534
|
+
m["reason"] = f"Baseline execution error: timed out after {float(timeout):.1f} seconds"
|
|
503
535
|
return mutants, 0.0
|
|
504
536
|
except Exception as e:
|
|
505
537
|
for m in mutants:
|
|
@@ -573,8 +605,11 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
573
605
|
with open(abs_path, "w", encoding="utf-8") as f:
|
|
574
606
|
f.write(code)
|
|
575
607
|
|
|
576
|
-
total_eval = valid_mutants_count
|
|
577
|
-
|
|
608
|
+
total_eval = valid_mutants_count
|
|
609
|
+
if total_eval == 0:
|
|
610
|
+
score = 0.0
|
|
611
|
+
else:
|
|
612
|
+
score = evaluate_mutation_score(killed_count, total_eval)
|
|
578
613
|
return mutants, score
|
|
579
614
|
|
|
580
615
|
|
|
@@ -701,12 +736,30 @@ def evaluate_target(
|
|
|
701
736
|
code = ""
|
|
702
737
|
|
|
703
738
|
killed_count = sum(1 for m in all_mutants if m["status"] == "KILLED")
|
|
704
|
-
|
|
739
|
+
if "DYNAMIC" in exec_mode:
|
|
740
|
+
valid_m_count = sum(1 for m in all_mutants if m["status"] in ("KILLED", "SURVIVED", "TIMED_OUT"))
|
|
741
|
+
score = evaluate_mutation_score(killed_count, valid_m_count) if valid_m_count > 0 else 0.0
|
|
742
|
+
else:
|
|
743
|
+
score = evaluate_mutation_score(killed_count, len(all_mutants))
|
|
705
744
|
|
|
706
745
|
killed = sum(1 for m in all_mutants if m["status"] == "KILLED")
|
|
707
746
|
survived = sum(1 for m in all_mutants if m["status"] == "SURVIVED")
|
|
747
|
+
timed_out = sum(1 for m in all_mutants if m["status"] == "TIMED_OUT")
|
|
748
|
+
invalid_syntax = sum(1 for m in all_mutants if m["status"] in ("INVALID_SYNTAX", "INVALID"))
|
|
749
|
+
valid_mutants = killed + survived + timed_out
|
|
708
750
|
no_mutants = (len(all_mutants) == 0)
|
|
709
|
-
|
|
751
|
+
no_valid_mutants = (valid_mutants == 0) if "DYNAMIC" in exec_mode else no_mutants
|
|
752
|
+
|
|
753
|
+
if "DYNAMIC" in exec_mode:
|
|
754
|
+
if no_valid_mutants:
|
|
755
|
+
passed = False
|
|
756
|
+
score = 0.0
|
|
757
|
+
else:
|
|
758
|
+
passed = (score >= min_score)
|
|
759
|
+
if survived > 0 and score < min_score:
|
|
760
|
+
passed = False
|
|
761
|
+
else:
|
|
762
|
+
passed = (score >= min_score) and not no_mutants
|
|
710
763
|
|
|
711
764
|
failed_files = {}
|
|
712
765
|
if not os.path.isfile(target) and min_file_score > 0.0:
|
|
@@ -718,13 +771,20 @@ def evaluate_target(
|
|
|
718
771
|
"target": target,
|
|
719
772
|
"mode": exec_mode,
|
|
720
773
|
"is_heuristic_static": (exec_mode == "STATIC"),
|
|
774
|
+
"measurement_kind": "dynamic_execution" if "DYNAMIC" in exec_mode else "static_ast_heuristic",
|
|
721
775
|
"total_mutants": len(all_mutants),
|
|
776
|
+
"valid_mutants": valid_mutants if "DYNAMIC" in exec_mode else len(all_mutants),
|
|
722
777
|
"killed": killed,
|
|
723
778
|
"survived": survived,
|
|
779
|
+
"timed_out": timed_out,
|
|
780
|
+
"invalid_syntax": invalid_syntax,
|
|
724
781
|
"mutation_score": score,
|
|
725
782
|
"static_assertion_sensitivity_score": score if exec_mode == "STATIC" else None,
|
|
783
|
+
"dynamic_mutation_score": score if "DYNAMIC" in exec_mode else None,
|
|
726
784
|
"runtime_mutation_kill_score": score if "DYNAMIC" in exec_mode else None,
|
|
785
|
+
"score_denominator": valid_mutants if "DYNAMIC" in exec_mode else len(all_mutants),
|
|
727
786
|
"no_mutants_generated": no_mutants,
|
|
787
|
+
"no_valid_mutants": no_valid_mutants,
|
|
728
788
|
"min_score": min_score,
|
|
729
789
|
"min_file_score": min_file_score,
|
|
730
790
|
"passed": passed,
|
|
@@ -786,21 +846,30 @@ def format_junit(report: Dict[str, Any]) -> str:
|
|
|
786
846
|
"""Formats mutation evaluation in standard JUnit XML format."""
|
|
787
847
|
total = max(1, report.get("total_mutants", 0))
|
|
788
848
|
survived = report.get("survived", 0)
|
|
849
|
+
timed_out = report.get("timed_out", 0)
|
|
850
|
+
invalid_syntax = report.get("invalid_syntax", 0)
|
|
789
851
|
lines = [
|
|
790
852
|
'<?xml version="1.0" encoding="utf-8"?>',
|
|
791
|
-
f'<testsuite name="synapse-micro-mutator" tests="{total}" failures="{survived}" errors="
|
|
853
|
+
f'<testsuite name="synapse-micro-mutator" tests="{total}" failures="{survived}" errors="{timed_out}" skipped="{invalid_syntax}">'
|
|
792
854
|
]
|
|
793
855
|
for m in report.get("mutants", []):
|
|
794
856
|
cname = (m.get("file") or report.get("target", "")).replace("/", ".").replace("\\", ".")
|
|
795
857
|
clean_desc = re.sub(r'[^a-zA-Z0-9_]', '_', m.get('description', 'mutant'))
|
|
796
858
|
tname = f"Mutant_L{m.get('line', 1)}_{clean_desc}"
|
|
797
859
|
lines.append(f' <testcase classname="{cname}" name="{tname}">')
|
|
798
|
-
|
|
860
|
+
status = m.get("status")
|
|
861
|
+
if status == "SURVIVED":
|
|
799
862
|
desc = html_lib.escape(m.get("description", ""))
|
|
800
863
|
orig = html_lib.escape(m.get("original_snippet", ""))
|
|
801
864
|
mut = html_lib.escape(m.get("mutated_snippet", ""))
|
|
802
865
|
reason = html_lib.escape(m.get("reason", "Downstream assertions failed to kill mutant"))
|
|
803
866
|
lines.append(f' <failure message="Mutant survived: {desc}" type="MUTANT_SURVIVED">Line {m.get("line", 1)}: {orig} -> {mut}. Reason: {reason}</failure>')
|
|
867
|
+
elif status == "TIMED_OUT":
|
|
868
|
+
reason = html_lib.escape(m.get("reason", "Test command execution timed out"))
|
|
869
|
+
lines.append(f' <error message="Mutant timed out" type="MUTANT_TIMED_OUT">{reason}</error>')
|
|
870
|
+
elif status in ("INVALID_SYNTAX", "INVALID"):
|
|
871
|
+
reason = html_lib.escape(m.get("reason", "Invalid syntax mutant discarded"))
|
|
872
|
+
lines.append(f' <skipped message="Discarded invalid mutant: {reason}"/>')
|
|
804
873
|
lines.append(' </testcase>')
|
|
805
874
|
if not report.get("mutants"):
|
|
806
875
|
lines.append(' <testcase classname="synapse.mutator" name="clean_run"/>')
|
|
@@ -868,7 +937,8 @@ def main():
|
|
|
868
937
|
with open(mutation_run_file, "w", encoding="utf-8") as mrf:
|
|
869
938
|
json.dump(report, mrf, indent=2)
|
|
870
939
|
except Exception as err:
|
|
871
|
-
|
|
940
|
+
import logging
|
|
941
|
+
logging.getLogger("micro_mutator").debug("Failed to write mutation run report: %s", err)
|
|
872
942
|
|
|
873
943
|
output_format = "json" if args.json else args.format
|
|
874
944
|
|
|
@@ -886,7 +956,8 @@ def main():
|
|
|
886
956
|
mode_desc = f"LIVE DYNAMIC RUNNER (cmd: '{args.test_cmd}')"
|
|
887
957
|
else:
|
|
888
958
|
mode_desc = "STATIC HEURISTIC (fast heuristic assertion sensitivity scan; pass --test-cmd or --scoped-test-cmd for dynamic run)"
|
|
889
|
-
score_label = "Runtime Mutation
|
|
959
|
+
score_label = "Runtime Dynamic Mutation Score" if "DYNAMIC" in report.get("mode", "") else "Static Assertion Sensitivity Score"
|
|
960
|
+
denominator_label = f"(Denominator: {report.get('valid_mutants', report['total_mutants'])} valid mutants)" if "DYNAMIC" in report.get("mode", "") else f"(Denominator: {report['total_mutants']} syntactic expressions)"
|
|
890
961
|
|
|
891
962
|
print("\n======================================================================")
|
|
892
963
|
print(f" ASSERTION SENSITIVITY & SYNTACTIC MUTATION SENTINEL [{mode_tag}] ")
|
|
@@ -896,9 +967,12 @@ def main():
|
|
|
896
967
|
print(f" Mutants Injected : {report['total_mutants']}")
|
|
897
968
|
print(f" Mutants Caught/Killed : {report['killed']}")
|
|
898
969
|
print(f" Mutants Survived : {report['survived']}")
|
|
970
|
+
if "DYNAMIC" in report.get("mode", ""):
|
|
971
|
+
print(f" Mutants Timed Out : {report.get('timed_out', 0)} (inconclusive, not counted as killed)")
|
|
972
|
+
print(f" Invalid Mutants : {report.get('invalid_syntax', 0)} (discarded from denominator)")
|
|
899
973
|
if report.get("no_mutants_generated"):
|
|
900
974
|
print(" ⚠️ Notice : Zero syntactic mutants generated. Target lacks mutable logic expressions.")
|
|
901
|
-
print(f" {score_label:<
|
|
975
|
+
print(f" {score_label:<34}: {report['mutation_score']}% {denominator_label} (Required: >={report['min_score']}%)")
|
|
902
976
|
print("======================================================================\n")
|
|
903
977
|
|
|
904
978
|
for m in report['mutants'][:6]:
|
package/tools/newman_analyzer.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
# -*- coding: utf-8 -*-
|
|
3
6
|
"""
|
|
4
7
|
tools/newman_analyzer.py — Enterprise Newman Test Results Analyzer & CI/CD Quality Gate
|
package/tools/omni_emitter.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Omni-Emitter: Universal Polyglot Code Generator & Transpiler
|
|
4
7
|
------------------------------------------------------------
|
package/tools/omni_parser.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Omni-Parser: Universal Polyglot AST & Structure Parser
|
|
4
7
|
------------------------------------------------------
|
package/tools/omni_transpiler.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Enterprise Standardized Output Formatter & Exit Code Specification
|
|
4
7
|
------------------------------------------------------------------
|
package/tools/package_release.py
CHANGED
|
@@ -239,21 +239,21 @@ def package_synapse_hub(
|
|
|
239
239
|
if re.match(r"^synapse-hub-v\d+\.\d+\.\d+.*", f, re.IGNORECASE) and f.endswith((".zip", ".tar.gz", ".sha256")):
|
|
240
240
|
try:
|
|
241
241
|
os.remove(os.path.join(out_dir, f))
|
|
242
|
-
except OSError
|
|
243
|
-
|
|
242
|
+
except OSError:
|
|
243
|
+
continue
|
|
244
244
|
elif not is_same_as_root and f.endswith((".zip", ".tar.gz", ".sha256")) and f.lower().startswith("synapse-hub"):
|
|
245
245
|
try:
|
|
246
246
|
os.remove(os.path.join(out_dir, f))
|
|
247
|
-
except OSError
|
|
248
|
-
|
|
247
|
+
except OSError:
|
|
248
|
+
continue
|
|
249
249
|
|
|
250
250
|
if not is_same_as_root:
|
|
251
251
|
for f in os.listdir(repo_root):
|
|
252
252
|
if re.match(r"^synapse-hub-v\d+\.\d+\.\d+.*", f, re.IGNORECASE) and f.endswith((".zip", ".tar.gz", ".sha256")):
|
|
253
253
|
try:
|
|
254
254
|
os.remove(os.path.join(repo_root, f))
|
|
255
|
-
except OSError
|
|
256
|
-
|
|
255
|
+
except OSError:
|
|
256
|
+
continue
|
|
257
257
|
|
|
258
258
|
files = collect_package_files(repo_root)
|
|
259
259
|
base_name = f"synapse-hub-v{version}"
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
# -*- coding: utf-8 -*-
|
|
3
6
|
"""
|
|
4
7
|
tools/pairwise_generator.py — Pairwise (2-Way) Combinatorial Test Case Generator
|