@vk.amogh/trace 2.1.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/README.md +208 -0
- package/bin/trace.js +112 -0
- package/package.json +46 -0
- package/pyproject.toml +39 -0
- package/src/trace_engine/__init__.py +8 -0
- package/src/trace_engine/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/__pycache__/cli.cpython-311.pyc +0 -0
- package/src/trace_engine/__pycache__/doctor.cpython-311.pyc +0 -0
- package/src/trace_engine/__pycache__/interactive.cpython-311.pyc +0 -0
- package/src/trace_engine/__pycache__/verify.cpython-311.pyc +0 -0
- package/src/trace_engine/ai/__init__.py +7 -0
- package/src/trace_engine/ai/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/ai/__pycache__/base.cpython-311.pyc +0 -0
- package/src/trace_engine/ai/__pycache__/ollama.cpython-311.pyc +0 -0
- package/src/trace_engine/ai/__pycache__/planner.cpython-311.pyc +0 -0
- package/src/trace_engine/ai/base.py +23 -0
- package/src/trace_engine/ai/ollama.py +50 -0
- package/src/trace_engine/ai/planner.py +40 -0
- package/src/trace_engine/apm/__init__.py +18 -0
- package/src/trace_engine/apm/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/__pycache__/builder.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/__pycache__/edges.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/__pycache__/model.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/__pycache__/nodes.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/__pycache__/serialization.cpython-311.pyc +0 -0
- package/src/trace_engine/apm/builder.py +208 -0
- package/src/trace_engine/apm/edges.py +25 -0
- package/src/trace_engine/apm/model.py +107 -0
- package/src/trace_engine/apm/nodes.py +27 -0
- package/src/trace_engine/apm/serialization.py +105 -0
- package/src/trace_engine/benchmark/__init__.py +5 -0
- package/src/trace_engine/benchmark/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/benchmark/__pycache__/owasp.cpython-311.pyc +0 -0
- package/src/trace_engine/benchmark/owasp.py +183 -0
- package/src/trace_engine/cli.py +1184 -0
- package/src/trace_engine/config/__init__.py +35 -0
- package/src/trace_engine/config/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/config/__pycache__/defaults.cpython-311.pyc +0 -0
- package/src/trace_engine/config/__pycache__/loader.cpython-311.pyc +0 -0
- package/src/trace_engine/config/__pycache__/settings.cpython-311.pyc +0 -0
- package/src/trace_engine/config/defaults.py +48 -0
- package/src/trace_engine/config/loader.py +64 -0
- package/src/trace_engine/config/settings.py +72 -0
- package/src/trace_engine/doctor.py +250 -0
- package/src/trace_engine/findings/__init__.py +15 -0
- package/src/trace_engine/findings/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/findings/__pycache__/correlate.cpython-311.pyc +0 -0
- package/src/trace_engine/findings/__pycache__/model.cpython-311.pyc +0 -0
- package/src/trace_engine/findings/__pycache__/recommendations.cpython-311.pyc +0 -0
- package/src/trace_engine/findings/__pycache__/store.cpython-311.pyc +0 -0
- package/src/trace_engine/findings/correlate.py +103 -0
- package/src/trace_engine/findings/model.py +40 -0
- package/src/trace_engine/findings/recommendations.py +35 -0
- package/src/trace_engine/findings/store.py +39 -0
- package/src/trace_engine/framework/__init__.py +58 -0
- package/src/trace_engine/framework/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/base.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/csharp.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/dart.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/django.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/express.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/fastapi.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/flask.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/go.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/nextjs.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/php.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/react_router.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/ruby.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/rust.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/__pycache__/springboot.cpython-311.pyc +0 -0
- package/src/trace_engine/framework/base.py +49 -0
- package/src/trace_engine/framework/csharp.py +111 -0
- package/src/trace_engine/framework/dart.py +152 -0
- package/src/trace_engine/framework/django.py +188 -0
- package/src/trace_engine/framework/express.py +82 -0
- package/src/trace_engine/framework/fastapi.py +135 -0
- package/src/trace_engine/framework/flask.py +108 -0
- package/src/trace_engine/framework/go.py +94 -0
- package/src/trace_engine/framework/nextjs.py +200 -0
- package/src/trace_engine/framework/php.py +98 -0
- package/src/trace_engine/framework/react_router.py +331 -0
- package/src/trace_engine/framework/ruby.py +69 -0
- package/src/trace_engine/framework/rust.py +101 -0
- package/src/trace_engine/framework/springboot.py +145 -0
- package/src/trace_engine/harness/__init__.py +19 -0
- package/src/trace_engine/harness/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/__pycache__/benchmark.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/__pycache__/context.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/__pycache__/engine.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/__pycache__/patcher.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/__pycache__/remediators.cpython-311.pyc +0 -0
- package/src/trace_engine/harness/benchmark.py +55 -0
- package/src/trace_engine/harness/context.py +49 -0
- package/src/trace_engine/harness/engine.py +187 -0
- package/src/trace_engine/harness/patcher.py +143 -0
- package/src/trace_engine/harness/remediators.py +307 -0
- package/src/trace_engine/ingest/__init__.py +15 -0
- package/src/trace_engine/ingest/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/ingest/__pycache__/files.cpython-311.pyc +0 -0
- package/src/trace_engine/ingest/__pycache__/hashing.cpython-311.pyc +0 -0
- package/src/trace_engine/ingest/__pycache__/ignore.cpython-311.pyc +0 -0
- package/src/trace_engine/ingest/__pycache__/repository.cpython-311.pyc +0 -0
- package/src/trace_engine/ingest/files.py +60 -0
- package/src/trace_engine/ingest/hashing.py +21 -0
- package/src/trace_engine/ingest/ignore.py +108 -0
- package/src/trace_engine/ingest/repository.py +50 -0
- package/src/trace_engine/intelligence/__init__.py +15 -0
- package/src/trace_engine/intelligence/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/__pycache__/evaluation.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/__pycache__/orchestrator.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/__pycache__/tracebench.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/evaluation.py +828 -0
- package/src/trace_engine/intelligence/laya/__init__.py +19 -0
- package/src/trace_engine/intelligence/laya/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/__pycache__/prompts.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/__pycache__/router.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/__pycache__/schemas.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/__pycache__/telemetry.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/__pycache__/thresholds.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/laya/prompts.py +67 -0
- package/src/trace_engine/intelligence/laya/router.py +352 -0
- package/src/trace_engine/intelligence/laya/schemas.py +56 -0
- package/src/trace_engine/intelligence/laya/telemetry.py +48 -0
- package/src/trace_engine/intelligence/laya/thresholds.py +12 -0
- package/src/trace_engine/intelligence/orchestrator.py +130 -0
- package/src/trace_engine/intelligence/securebert/__init__.py +6 -0
- package/src/trace_engine/intelligence/securebert/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/securebert/__pycache__/cache.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/securebert/__pycache__/classifier.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/securebert/cache.py +37 -0
- package/src/trace_engine/intelligence/securebert/classifier.py +240 -0
- package/src/trace_engine/intelligence/tracebench.py +61 -0
- package/src/trace_engine/intelligence/training/__init__.py +21 -0
- package/src/trace_engine/intelligence/training/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/dataset.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/dataset_importers.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/laya_trainer.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/lora_system2.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/morefixes_pipeline.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/slicer.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/train_all.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/__pycache__/trainer.cpython-311.pyc +0 -0
- package/src/trace_engine/intelligence/training/dataset.py +320 -0
- package/src/trace_engine/intelligence/training/dataset_importers.py +349 -0
- package/src/trace_engine/intelligence/training/laya_trainer.py +678 -0
- package/src/trace_engine/intelligence/training/lora_system2.py +162 -0
- package/src/trace_engine/intelligence/training/morefixes_pipeline.py +463 -0
- package/src/trace_engine/intelligence/training/slicer.py +129 -0
- package/src/trace_engine/intelligence/training/train_all.py +1009 -0
- package/src/trace_engine/intelligence/training/trainer.py +321 -0
- package/src/trace_engine/interactive.py +623 -0
- package/src/trace_engine/mcp/__init__.py +6 -0
- package/src/trace_engine/mcp/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/mcp/__pycache__/config.cpython-311.pyc +0 -0
- package/src/trace_engine/mcp/__pycache__/server.cpython-311.pyc +0 -0
- package/src/trace_engine/mcp/config.py +42 -0
- package/src/trace_engine/mcp/server.py +398 -0
- package/src/trace_engine/output/__init__.py +28 -0
- package/src/trace_engine/output/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/output/__pycache__/html.cpython-311.pyc +0 -0
- package/src/trace_engine/output/__pycache__/markdown.cpython-311.pyc +0 -0
- package/src/trace_engine/output/__pycache__/sarif.cpython-311.pyc +0 -0
- package/src/trace_engine/output/__pycache__/terminal.cpython-311.pyc +0 -0
- package/src/trace_engine/output/html.py +142 -0
- package/src/trace_engine/output/markdown.py +65 -0
- package/src/trace_engine/output/sarif.py +180 -0
- package/src/trace_engine/output/terminal.py +537 -0
- package/src/trace_engine/parsing/__init__.py +26 -0
- package/src/trace_engine/parsing/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/__pycache__/calls.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/__pycache__/language.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/__pycache__/locations.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/__pycache__/parser.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/__pycache__/symbols.cpython-311.pyc +0 -0
- package/src/trace_engine/parsing/calls.py +14 -0
- package/src/trace_engine/parsing/language.py +24 -0
- package/src/trace_engine/parsing/locations.py +17 -0
- package/src/trace_engine/parsing/parser.py +465 -0
- package/src/trace_engine/parsing/symbols.py +45 -0
- package/src/trace_engine/plugin/__init__.py +157 -0
- package/src/trace_engine/plugin/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/plugin/__pycache__/evaluator.cpython-311.pyc +0 -0
- package/src/trace_engine/plugin/__pycache__/swebench_adapter.cpython-311.pyc +0 -0
- package/src/trace_engine/plugin/__pycache__/task.cpython-311.pyc +0 -0
- package/src/trace_engine/plugin/bundle/hooks.json +24 -0
- package/src/trace_engine/plugin/bundle/mcp_config.json +11 -0
- package/src/trace_engine/plugin/bundle/plugin.json +20 -0
- package/src/trace_engine/plugin/bundle/rules/security_remediation.md +40 -0
- package/src/trace_engine/plugin/bundle/skills/trace-security-harness/SKILL.md +118 -0
- package/src/trace_engine/plugin/evaluator.py +105 -0
- package/src/trace_engine/plugin/swebench_adapter.py +96 -0
- package/src/trace_engine/plugin/task.py +48 -0
- package/src/trace_engine/policy/__init__.py +5 -0
- package/src/trace_engine/policy/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/policy/__pycache__/scope.cpython-311.pyc +0 -0
- package/src/trace_engine/policy/scope.py +80 -0
- package/src/trace_engine/runtime/__init__.py +7 -0
- package/src/trace_engine/runtime/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/runtime/__pycache__/client.cpython-311.pyc +0 -0
- package/src/trace_engine/runtime/__pycache__/observations.cpython-311.pyc +0 -0
- package/src/trace_engine/runtime/__pycache__/target.cpython-311.pyc +0 -0
- package/src/trace_engine/runtime/client.py +81 -0
- package/src/trace_engine/runtime/observations.py +18 -0
- package/src/trace_engine/runtime/target.py +23 -0
- package/src/trace_engine/security/__init__.py +16 -0
- package/src/trace_engine/security/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/security/__pycache__/fusion.cpython-311.pyc +0 -0
- package/src/trace_engine/security/__pycache__/hypotheses.cpython-311.pyc +0 -0
- package/src/trace_engine/security/__pycache__/signals.cpython-311.pyc +0 -0
- package/src/trace_engine/security/__pycache__/timing.cpython-311.pyc +0 -0
- package/src/trace_engine/security/fusion.py +126 -0
- package/src/trace_engine/security/hypotheses.py +251 -0
- package/src/trace_engine/security/signals.py +28 -0
- package/src/trace_engine/security/timing.py +132 -0
- package/src/trace_engine/testpacks/__init__.py +18 -0
- package/src/trace_engine/testpacks/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/authentication.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/base.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/bfla.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/bola.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/cors.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/deserialization.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/injection.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/mass_assignment.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/path_traversal.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/registry.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/ssrf.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/__pycache__/ssti.cpython-311.pyc +0 -0
- package/src/trace_engine/testpacks/authentication.py +60 -0
- package/src/trace_engine/testpacks/base.py +63 -0
- package/src/trace_engine/testpacks/bfla.py +70 -0
- package/src/trace_engine/testpacks/bola.py +94 -0
- package/src/trace_engine/testpacks/cors.py +85 -0
- package/src/trace_engine/testpacks/deserialization.py +86 -0
- package/src/trace_engine/testpacks/injection.py +179 -0
- package/src/trace_engine/testpacks/mass_assignment.py +70 -0
- package/src/trace_engine/testpacks/path_traversal.py +117 -0
- package/src/trace_engine/testpacks/registry.py +44 -0
- package/src/trace_engine/testpacks/ssrf.py +85 -0
- package/src/trace_engine/testpacks/ssti.py +96 -0
- package/src/trace_engine/tools/__init__.py +6 -0
- package/src/trace_engine/tools/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/trace_engine/tools/__pycache__/adapters.cpython-311.pyc +0 -0
- package/src/trace_engine/tools/__pycache__/base.cpython-311.pyc +0 -0
- package/src/trace_engine/tools/__pycache__/registry.cpython-311.pyc +0 -0
- package/src/trace_engine/tools/adapters.py +111 -0
- package/src/trace_engine/tools/base.py +68 -0
- package/src/trace_engine/tools/registry.py +36 -0
- package/src/trace_engine/verify.py +156 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
"""Empirical Head-to-Head Intelligence Benchmark: Laya System 1 vs. SecureBERT 2.0 vs. Dual-Engine Ensemble.
|
|
2
|
+
|
|
3
|
+
Provides objective evaluation across:
|
|
4
|
+
1. Inference Latency (ms / endpoint)
|
|
5
|
+
2. Task Identification & Routing Accuracy (%)
|
|
6
|
+
3. Code AST Semantic Classification F1 Score
|
|
7
|
+
4. Memory Footprint and Device Suitability
|
|
8
|
+
5. Dual-Engine Synergy (Cascade & Bayesian Calibration)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Dict, Any, List, Tuple
|
|
14
|
+
from rich.console import Console
|
|
15
|
+
from rich.table import Table
|
|
16
|
+
from rich.panel import Panel
|
|
17
|
+
from rich.text import Text
|
|
18
|
+
from rich.box import ROUNDED
|
|
19
|
+
|
|
20
|
+
from trace_engine.intelligence.securebert.classifier import SecureBERTClassifier
|
|
21
|
+
from trace_engine.intelligence.laya.router import LayaDecisionEngine
|
|
22
|
+
from trace_engine.framework.base import Endpoint, EndpointParameter
|
|
23
|
+
from trace_engine.parsing.locations import SourceLocation
|
|
24
|
+
from trace_engine.apm.model import AttackPathModel
|
|
25
|
+
from trace_engine.security.hypotheses import SecurityHypothesis
|
|
26
|
+
|
|
27
|
+
console = Console(force_terminal=True, legacy_windows=False)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def build_enterprise_benchmark_suite() -> List[Tuple[Endpoint, str, str, str]]:
|
|
31
|
+
"""Builds a rigorous 35-sample multi-language enterprise evaluation cohort across 7 security categories."""
|
|
32
|
+
suite = [
|
|
33
|
+
# -------------------------------------------------------------
|
|
34
|
+
# 1. BOLA / IDOR (CWE-639) - 5 multi-framework samples
|
|
35
|
+
# -------------------------------------------------------------
|
|
36
|
+
(
|
|
37
|
+
Endpoint(
|
|
38
|
+
id="ep_bola_1",
|
|
39
|
+
method="GET",
|
|
40
|
+
path="/api/v1/orders/{id}",
|
|
41
|
+
handler_name="get_order",
|
|
42
|
+
parameters=[EndpointParameter(name="id", location="path")],
|
|
43
|
+
database_access=True,
|
|
44
|
+
object_identifier=True,
|
|
45
|
+
sensitive_data=True,
|
|
46
|
+
source=SourceLocation(file="orders.py", line_start=10, line_end=20),
|
|
47
|
+
),
|
|
48
|
+
"def get_order(order_id): return db.query('SELECT * FROM orders WHERE id = :id', id=order_id).fetchone()",
|
|
49
|
+
"BOLA",
|
|
50
|
+
"bola",
|
|
51
|
+
),
|
|
52
|
+
(
|
|
53
|
+
Endpoint(
|
|
54
|
+
id="ep_bola_2",
|
|
55
|
+
method="GET",
|
|
56
|
+
path="/tenants/{tenant_id}/invoices/{inv_id}",
|
|
57
|
+
handler_name="GetInvoice",
|
|
58
|
+
parameters=[EndpointParameter(name="inv_id", location="path")],
|
|
59
|
+
database_access=True,
|
|
60
|
+
object_identifier=True,
|
|
61
|
+
sensitive_data=True,
|
|
62
|
+
source=SourceLocation(file="invoice.go", line_start=25, line_end=35),
|
|
63
|
+
),
|
|
64
|
+
"func GetInvoice(c *gin.Context) { inv := db.Find(c.Param(\"inv_id\")); c.JSON(200, inv) }",
|
|
65
|
+
"BOLA",
|
|
66
|
+
"bola",
|
|
67
|
+
),
|
|
68
|
+
(
|
|
69
|
+
Endpoint(
|
|
70
|
+
id="ep_bola_3",
|
|
71
|
+
method="GET",
|
|
72
|
+
path="/api/v2/documents/{docId}",
|
|
73
|
+
handler_name="getDocument",
|
|
74
|
+
parameters=[EndpointParameter(name="docId", location="path")],
|
|
75
|
+
database_access=True,
|
|
76
|
+
object_identifier=True,
|
|
77
|
+
sensitive_data=True,
|
|
78
|
+
source=SourceLocation(file="DocController.java", line_start=45, line_end=55),
|
|
79
|
+
),
|
|
80
|
+
"@GetMapping(\"/{docId}\") public Doc getDoc(@PathVariable String docId) { return docRepo.findById(docId); }",
|
|
81
|
+
"BOLA",
|
|
82
|
+
"bola",
|
|
83
|
+
),
|
|
84
|
+
(
|
|
85
|
+
Endpoint(
|
|
86
|
+
id="ep_bola_4",
|
|
87
|
+
method="GET",
|
|
88
|
+
path="/users/{userId}/records",
|
|
89
|
+
handler_name="getUserRecords",
|
|
90
|
+
parameters=[EndpointParameter(name="userId", location="path")],
|
|
91
|
+
database_access=True,
|
|
92
|
+
object_identifier=True,
|
|
93
|
+
sensitive_data=True,
|
|
94
|
+
source=SourceLocation(file="records.ts", line_start=12, line_end=24),
|
|
95
|
+
),
|
|
96
|
+
"router.get('/users/:userId/records', async (req, res) => res.json(await db.records.find({id: req.params.userId})))",
|
|
97
|
+
"BOLA",
|
|
98
|
+
"bola",
|
|
99
|
+
),
|
|
100
|
+
(
|
|
101
|
+
Endpoint(
|
|
102
|
+
id="ep_bola_5",
|
|
103
|
+
method="GET",
|
|
104
|
+
path="/clinical/charts/{chartId}",
|
|
105
|
+
handler_name="chart_detail",
|
|
106
|
+
parameters=[EndpointParameter(name="chartId", location="path")],
|
|
107
|
+
database_access=True,
|
|
108
|
+
object_identifier=True,
|
|
109
|
+
sensitive_data=True,
|
|
110
|
+
source=SourceLocation(file="charts.py", line_start=50, line_end=62),
|
|
111
|
+
),
|
|
112
|
+
"def chart_detail(request, chartId): return JsonResponse(Chart.objects.get(id=chartId).to_dict())",
|
|
113
|
+
"BOLA",
|
|
114
|
+
"bola",
|
|
115
|
+
),
|
|
116
|
+
|
|
117
|
+
# -------------------------------------------------------------
|
|
118
|
+
# 2. Injection (SQLi / Command / LDAP) - 5 multi-framework samples
|
|
119
|
+
# -------------------------------------------------------------
|
|
120
|
+
(
|
|
121
|
+
Endpoint(
|
|
122
|
+
id="ep_inj_1",
|
|
123
|
+
method="POST",
|
|
124
|
+
path="/api/v1/analytics/query",
|
|
125
|
+
handler_name="run_analytics",
|
|
126
|
+
parameters=[EndpointParameter(name="q", location="body")],
|
|
127
|
+
database_access=True,
|
|
128
|
+
state_changing=True,
|
|
129
|
+
source=SourceLocation(file="query.py", line_start=15, line_end=30),
|
|
130
|
+
),
|
|
131
|
+
"def run_analytics(q): return db.execute(f'SELECT * FROM logs WHERE action = \"{q}\"')",
|
|
132
|
+
"INJECTION",
|
|
133
|
+
"injection",
|
|
134
|
+
),
|
|
135
|
+
(
|
|
136
|
+
Endpoint(
|
|
137
|
+
id="ep_inj_2",
|
|
138
|
+
method="GET",
|
|
139
|
+
path="/catalog/search",
|
|
140
|
+
handler_name="searchCatalog",
|
|
141
|
+
parameters=[EndpointParameter(name="query", location="query")],
|
|
142
|
+
database_access=True,
|
|
143
|
+
source=SourceLocation(file="catalog.js", line_start=30, line_end=42),
|
|
144
|
+
),
|
|
145
|
+
"app.get('/catalog/search', (req, res) => db.query('SELECT * FROM items WHERE title LIKE \"%' + req.query.query + '%\"'))",
|
|
146
|
+
"INJECTION",
|
|
147
|
+
"injection",
|
|
148
|
+
),
|
|
149
|
+
(
|
|
150
|
+
Endpoint(
|
|
151
|
+
id="ep_inj_3",
|
|
152
|
+
method="POST",
|
|
153
|
+
path="/system/diagnostics/ping",
|
|
154
|
+
handler_name="PingHost",
|
|
155
|
+
parameters=[EndpointParameter(name="host", location="body")],
|
|
156
|
+
database_access=False,
|
|
157
|
+
state_changing=True,
|
|
158
|
+
source=SourceLocation(file="diag.go", line_start=18, line_end=28),
|
|
159
|
+
),
|
|
160
|
+
"func PingHost(host string) string { out, _ := exec.Command(\"sh\", \"-c\", \"ping -c 1 \" + host).Output(); return string(out) }",
|
|
161
|
+
"INJECTION",
|
|
162
|
+
"injection",
|
|
163
|
+
),
|
|
164
|
+
(
|
|
165
|
+
Endpoint(
|
|
166
|
+
id="ep_inj_4",
|
|
167
|
+
method="POST",
|
|
168
|
+
path="/admin/database/raw_exec",
|
|
169
|
+
handler_name="rawExec",
|
|
170
|
+
parameters=[EndpointParameter(name="sql_payload", location="body")],
|
|
171
|
+
database_access=True,
|
|
172
|
+
state_changing=True,
|
|
173
|
+
roles=["admin"],
|
|
174
|
+
source=SourceLocation(file="AdminDb.java", line_start=80, line_end=95),
|
|
175
|
+
),
|
|
176
|
+
"public Object rawExec(String sql_payload) { return entityManager.createNativeQuery(sql_payload).getResultList(); }",
|
|
177
|
+
"INJECTION",
|
|
178
|
+
"injection",
|
|
179
|
+
),
|
|
180
|
+
(
|
|
181
|
+
Endpoint(
|
|
182
|
+
id="ep_inj_5",
|
|
183
|
+
method="GET",
|
|
184
|
+
path="/reports/export",
|
|
185
|
+
handler_name="export_csv",
|
|
186
|
+
parameters=[EndpointParameter(name="sort_by", location="query")],
|
|
187
|
+
database_access=True,
|
|
188
|
+
source=SourceLocation(file="reports.py", line_start=100, line_end=115),
|
|
189
|
+
),
|
|
190
|
+
"def export_csv(sort_by): return cursor.execute(f'SELECT * FROM stats ORDER BY {sort_by}')",
|
|
191
|
+
"INJECTION",
|
|
192
|
+
"injection",
|
|
193
|
+
),
|
|
194
|
+
|
|
195
|
+
# -------------------------------------------------------------
|
|
196
|
+
# 3. SSRF (CWE-918) - 5 multi-framework samples
|
|
197
|
+
# -------------------------------------------------------------
|
|
198
|
+
(
|
|
199
|
+
Endpoint(
|
|
200
|
+
id="ep_ssrf_1",
|
|
201
|
+
method="POST",
|
|
202
|
+
path="/api/v1/webhook/dispatch",
|
|
203
|
+
handler_name="send_hook",
|
|
204
|
+
parameters=[EndpointParameter(name="url", location="body")],
|
|
205
|
+
external_network=True,
|
|
206
|
+
state_changing=True,
|
|
207
|
+
source=SourceLocation(file="hooks.py", line_start=5, line_end=15),
|
|
208
|
+
),
|
|
209
|
+
"def send_hook(url): return requests.post(url, json={'event': 'ping'})",
|
|
210
|
+
"SSRF",
|
|
211
|
+
"ssrf",
|
|
212
|
+
),
|
|
213
|
+
(
|
|
214
|
+
Endpoint(
|
|
215
|
+
id="ep_ssrf_2",
|
|
216
|
+
method="POST",
|
|
217
|
+
path="/media/avatar_fetch",
|
|
218
|
+
handler_name="fetchAvatar",
|
|
219
|
+
parameters=[EndpointParameter(name="image_url", location="body")],
|
|
220
|
+
external_network=True,
|
|
221
|
+
state_changing=True,
|
|
222
|
+
source=SourceLocation(file="media.ts", line_start=20, line_end=32),
|
|
223
|
+
),
|
|
224
|
+
"async function fetchAvatar(req, res) { const r = await axios.get(req.body.image_url); res.send(r.data); }",
|
|
225
|
+
"SSRF",
|
|
226
|
+
"ssrf",
|
|
227
|
+
),
|
|
228
|
+
(
|
|
229
|
+
Endpoint(
|
|
230
|
+
id="ep_ssrf_3",
|
|
231
|
+
method="GET",
|
|
232
|
+
path="/proxy/forward",
|
|
233
|
+
handler_name="forwardProxy",
|
|
234
|
+
parameters=[EndpointParameter(name="target_uri", location="query")],
|
|
235
|
+
external_network=True,
|
|
236
|
+
source=SourceLocation(file="ProxyController.java", line_start=40, line_end=50),
|
|
237
|
+
),
|
|
238
|
+
"@GetMapping(\"/proxy\") public String forward(@RequestParam String target_uri) { return new RestTemplate().getForObject(target_uri, String.class); }",
|
|
239
|
+
"SSRF",
|
|
240
|
+
"ssrf",
|
|
241
|
+
),
|
|
242
|
+
(
|
|
243
|
+
Endpoint(
|
|
244
|
+
id="ep_ssrf_4",
|
|
245
|
+
method="POST",
|
|
246
|
+
path="/documents/html_to_pdf",
|
|
247
|
+
handler_name="RenderPdf",
|
|
248
|
+
parameters=[EndpointParameter(name="render_url", location="body")],
|
|
249
|
+
external_network=True,
|
|
250
|
+
state_changing=True,
|
|
251
|
+
source=SourceLocation(file="pdf.go", line_start=15, line_end=30),
|
|
252
|
+
),
|
|
253
|
+
"func RenderPdf(render_url string) { resp, _ := http.Get(render_url); defer resp.Body.Close() }",
|
|
254
|
+
"SSRF",
|
|
255
|
+
"ssrf",
|
|
256
|
+
),
|
|
257
|
+
(
|
|
258
|
+
Endpoint(
|
|
259
|
+
id="ep_ssrf_5",
|
|
260
|
+
method="POST",
|
|
261
|
+
path="/oauth/callback_preview",
|
|
262
|
+
handler_name="preview_callback",
|
|
263
|
+
parameters=[EndpointParameter(name="callback", location="body")],
|
|
264
|
+
external_network=True,
|
|
265
|
+
state_changing=True,
|
|
266
|
+
source=SourceLocation(file="oauth.py", line_start=60, line_end=75),
|
|
267
|
+
),
|
|
268
|
+
"def preview_callback(callback): return httpx.get(callback, timeout=5.0).text",
|
|
269
|
+
"SSRF",
|
|
270
|
+
"ssrf",
|
|
271
|
+
),
|
|
272
|
+
|
|
273
|
+
# -------------------------------------------------------------
|
|
274
|
+
# 4. BFLA / Administrative Elevation - 5 samples
|
|
275
|
+
# -------------------------------------------------------------
|
|
276
|
+
(
|
|
277
|
+
Endpoint(
|
|
278
|
+
id="ep_bfla_1",
|
|
279
|
+
method="POST",
|
|
280
|
+
path="/api/v1/admin/reset_metrics",
|
|
281
|
+
handler_name="reset_stats",
|
|
282
|
+
auth_required=False,
|
|
283
|
+
roles=["admin"],
|
|
284
|
+
state_changing=True,
|
|
285
|
+
sensitive_data=True,
|
|
286
|
+
source=SourceLocation(file="admin.py", line_start=40, line_end=50),
|
|
287
|
+
),
|
|
288
|
+
"def reset_stats(): global_stats.clear(); return {'status': 'cleared'}",
|
|
289
|
+
"BFLA",
|
|
290
|
+
"bfla",
|
|
291
|
+
),
|
|
292
|
+
(
|
|
293
|
+
Endpoint(
|
|
294
|
+
id="ep_bfla_2",
|
|
295
|
+
method="DELETE",
|
|
296
|
+
path="/admin/tenants/{id}/purge",
|
|
297
|
+
handler_name="purgeTenant",
|
|
298
|
+
auth_required=False,
|
|
299
|
+
roles=["admin"],
|
|
300
|
+
parameters=[EndpointParameter(name="id", location="path")],
|
|
301
|
+
state_changing=True,
|
|
302
|
+
sensitive_data=True,
|
|
303
|
+
source=SourceLocation(file="TenantAdmin.java", line_start=55, line_end=65),
|
|
304
|
+
),
|
|
305
|
+
"@DeleteMapping(\"/purge/{id}\") public void purge(@PathVariable String id) { tenantRepo.deleteById(id); }",
|
|
306
|
+
"BFLA",
|
|
307
|
+
"bfla",
|
|
308
|
+
),
|
|
309
|
+
(
|
|
310
|
+
Endpoint(
|
|
311
|
+
id="ep_bfla_3",
|
|
312
|
+
method="PUT",
|
|
313
|
+
path="/admin/users/{id}/role",
|
|
314
|
+
handler_name="setUserRole",
|
|
315
|
+
auth_required=False,
|
|
316
|
+
roles=["admin"],
|
|
317
|
+
parameters=[EndpointParameter(name="id", location="path"), EndpointParameter(name="role", location="body")],
|
|
318
|
+
state_changing=True,
|
|
319
|
+
sensitive_data=True,
|
|
320
|
+
source=SourceLocation(file="admin_users.ts", line_start=70, line_end=85),
|
|
321
|
+
),
|
|
322
|
+
"app.put('/admin/users/:id/role', (req, res) => User.update({role: req.body.role}, {where: {id: req.params.id}}))",
|
|
323
|
+
"BFLA",
|
|
324
|
+
"bfla",
|
|
325
|
+
),
|
|
326
|
+
(
|
|
327
|
+
Endpoint(
|
|
328
|
+
id="ep_bfla_4",
|
|
329
|
+
method="POST",
|
|
330
|
+
path="/admin/system/restart",
|
|
331
|
+
handler_name="restart_system",
|
|
332
|
+
auth_required=False,
|
|
333
|
+
roles=["admin"],
|
|
334
|
+
state_changing=True,
|
|
335
|
+
sensitive_data=True,
|
|
336
|
+
source=SourceLocation(file="ops.py", line_start=90, line_end=100),
|
|
337
|
+
),
|
|
338
|
+
"def restart_system(): subprocess.run(['systemctl', 'restart', 'app'])",
|
|
339
|
+
"BFLA",
|
|
340
|
+
"bfla",
|
|
341
|
+
),
|
|
342
|
+
(
|
|
343
|
+
Endpoint(
|
|
344
|
+
id="ep_bfla_5",
|
|
345
|
+
method="GET",
|
|
346
|
+
path="/admin/debug/environment",
|
|
347
|
+
handler_name="GetDebugEnv",
|
|
348
|
+
auth_required=False,
|
|
349
|
+
roles=["admin"],
|
|
350
|
+
sensitive_data=True,
|
|
351
|
+
source=SourceLocation(file="debug.go", line_start=10, line_end=20),
|
|
352
|
+
),
|
|
353
|
+
"func GetDebugEnv(c *gin.Context) { c.JSON(200, os.Environ()) }",
|
|
354
|
+
"BFLA",
|
|
355
|
+
"bfla",
|
|
356
|
+
),
|
|
357
|
+
|
|
358
|
+
# -------------------------------------------------------------
|
|
359
|
+
# 5. Missing Authentication (CWE-306) - 5 samples
|
|
360
|
+
# -------------------------------------------------------------
|
|
361
|
+
(
|
|
362
|
+
Endpoint(
|
|
363
|
+
id="ep_auth_1",
|
|
364
|
+
method="POST",
|
|
365
|
+
path="/api/v1/transfer/funds",
|
|
366
|
+
handler_name="transfer_funds",
|
|
367
|
+
auth_required=False,
|
|
368
|
+
parameters=[EndpointParameter(name="amount", location="body")],
|
|
369
|
+
database_access=True,
|
|
370
|
+
state_changing=True,
|
|
371
|
+
sensitive_data=True,
|
|
372
|
+
source=SourceLocation(file="transfer.py", line_start=15, line_end=30),
|
|
373
|
+
),
|
|
374
|
+
"def transfer_funds(req): return bank.wire(amount=req.json['amount'], to=req.json['to'])",
|
|
375
|
+
"AUTHENTICATION",
|
|
376
|
+
"authentication",
|
|
377
|
+
),
|
|
378
|
+
(
|
|
379
|
+
Endpoint(
|
|
380
|
+
id="ep_auth_2",
|
|
381
|
+
method="POST",
|
|
382
|
+
path="/auth/password_reset/confirm",
|
|
383
|
+
handler_name="confirmReset",
|
|
384
|
+
auth_required=False,
|
|
385
|
+
parameters=[EndpointParameter(name="new_password", location="body")],
|
|
386
|
+
database_access=True,
|
|
387
|
+
state_changing=True,
|
|
388
|
+
sensitive_data=True,
|
|
389
|
+
source=SourceLocation(file="auth.js", line_start=85, line_end=95),
|
|
390
|
+
),
|
|
391
|
+
"app.post('/password_reset/confirm', (req, res) => User.resetPassword(req.body.token, req.body.new_password))",
|
|
392
|
+
"AUTHENTICATION",
|
|
393
|
+
"authentication",
|
|
394
|
+
),
|
|
395
|
+
(
|
|
396
|
+
Endpoint(
|
|
397
|
+
id="ep_auth_3",
|
|
398
|
+
method="PUT",
|
|
399
|
+
path="/account/email_change",
|
|
400
|
+
handler_name="change_email",
|
|
401
|
+
auth_required=False,
|
|
402
|
+
parameters=[EndpointParameter(name="new_email", location="body")],
|
|
403
|
+
database_access=True,
|
|
404
|
+
state_changing=True,
|
|
405
|
+
sensitive_data=True,
|
|
406
|
+
source=SourceLocation(file="account.py", line_start=45, line_end=55),
|
|
407
|
+
),
|
|
408
|
+
"def change_email(email): current_user.email = email; db.session.commit()",
|
|
409
|
+
"AUTHENTICATION",
|
|
410
|
+
"authentication",
|
|
411
|
+
),
|
|
412
|
+
(
|
|
413
|
+
Endpoint(
|
|
414
|
+
id="ep_auth_4",
|
|
415
|
+
method="POST",
|
|
416
|
+
path="/vault/rotate_master_key",
|
|
417
|
+
handler_name="rotateKey",
|
|
418
|
+
auth_required=False,
|
|
419
|
+
parameters=[EndpointParameter(name="key", location="body")],
|
|
420
|
+
database_access=True,
|
|
421
|
+
state_changing=True,
|
|
422
|
+
sensitive_data=True,
|
|
423
|
+
source=SourceLocation(file="VaultService.java", line_start=110, line_end=125),
|
|
424
|
+
),
|
|
425
|
+
"public void rotateKey(String key) { keyManager.rotateMaster(key); }",
|
|
426
|
+
"AUTHENTICATION",
|
|
427
|
+
"authentication",
|
|
428
|
+
),
|
|
429
|
+
(
|
|
430
|
+
Endpoint(
|
|
431
|
+
id="ep_auth_5",
|
|
432
|
+
method="DELETE",
|
|
433
|
+
path="/users/delete_account",
|
|
434
|
+
handler_name="DeleteAccount",
|
|
435
|
+
auth_required=False,
|
|
436
|
+
parameters=[EndpointParameter(name="confirm_code", location="body")],
|
|
437
|
+
database_access=True,
|
|
438
|
+
state_changing=True,
|
|
439
|
+
sensitive_data=True,
|
|
440
|
+
source=SourceLocation(file="users.go", line_start=130, line_end=145),
|
|
441
|
+
),
|
|
442
|
+
"func DeleteAccount(userId string) { db.Exec(\"DELETE FROM users WHERE id = ?\", userId) }",
|
|
443
|
+
"AUTHENTICATION",
|
|
444
|
+
"authentication",
|
|
445
|
+
),
|
|
446
|
+
|
|
447
|
+
# -------------------------------------------------------------
|
|
448
|
+
# 6. Mass Assignment (CWE-915) - 5 samples
|
|
449
|
+
# -------------------------------------------------------------
|
|
450
|
+
(
|
|
451
|
+
Endpoint(
|
|
452
|
+
id="ep_mass_1",
|
|
453
|
+
method="PUT",
|
|
454
|
+
path="/api/v1/users/{id}/profile",
|
|
455
|
+
handler_name="update_profile",
|
|
456
|
+
parameters=[EndpointParameter(name="payload", location="body")],
|
|
457
|
+
database_access=True,
|
|
458
|
+
state_changing=True,
|
|
459
|
+
source=SourceLocation(file="profile.py", line_start=20, line_end=35),
|
|
460
|
+
),
|
|
461
|
+
"def update_profile(user_id, data: dict): user = db.get(user_id); user.__dict__.update(data); db.save(user)",
|
|
462
|
+
"MASS_ASSIGNMENT",
|
|
463
|
+
"mass_assignment",
|
|
464
|
+
),
|
|
465
|
+
(
|
|
466
|
+
Endpoint(
|
|
467
|
+
id="ep_mass_2",
|
|
468
|
+
method="PATCH",
|
|
469
|
+
path="/tenants/{id}/settings",
|
|
470
|
+
handler_name="patchSettings",
|
|
471
|
+
parameters=[EndpointParameter(name="data", location="body")],
|
|
472
|
+
database_access=True,
|
|
473
|
+
state_changing=True,
|
|
474
|
+
source=SourceLocation(file="tenants.ts", line_start=50, line_end=65),
|
|
475
|
+
),
|
|
476
|
+
"app.patch('/tenants/:id/settings', (req, res) => Tenant.findByIdAndUpdate(req.params.id, req.body))",
|
|
477
|
+
"MASS_ASSIGNMENT",
|
|
478
|
+
"mass_assignment",
|
|
479
|
+
),
|
|
480
|
+
(
|
|
481
|
+
Endpoint(
|
|
482
|
+
id="ep_mass_3",
|
|
483
|
+
method="POST",
|
|
484
|
+
path="/accounts/register",
|
|
485
|
+
handler_name="registerUser",
|
|
486
|
+
auth_required=False,
|
|
487
|
+
parameters=[EndpointParameter(name="body", location="body")],
|
|
488
|
+
database_access=True,
|
|
489
|
+
state_changing=True,
|
|
490
|
+
source=SourceLocation(file="RegisterController.java", line_start=40, line_end=55),
|
|
491
|
+
),
|
|
492
|
+
"@PostMapping(\"/register\") public User register(@RequestBody User user) { return userRepo.save(user); }",
|
|
493
|
+
"MASS_ASSIGNMENT",
|
|
494
|
+
"mass_assignment",
|
|
495
|
+
),
|
|
496
|
+
(
|
|
497
|
+
Endpoint(
|
|
498
|
+
id="ep_mass_4",
|
|
499
|
+
method="PUT",
|
|
500
|
+
path="/wallets/{id}/preferences",
|
|
501
|
+
handler_name="update_preferences",
|
|
502
|
+
parameters=[EndpointParameter(name="prefs", location="body")],
|
|
503
|
+
database_access=True,
|
|
504
|
+
state_changing=True,
|
|
505
|
+
source=SourceLocation(file="wallet.py", line_start=75, line_end=85),
|
|
506
|
+
),
|
|
507
|
+
"def update_preferences(wallet_id, prefs): wallet = Wallet.get(wallet_id); wallet.update(**prefs)",
|
|
508
|
+
"MASS_ASSIGNMENT",
|
|
509
|
+
"mass_assignment",
|
|
510
|
+
),
|
|
511
|
+
(
|
|
512
|
+
Endpoint(
|
|
513
|
+
id="ep_mass_5",
|
|
514
|
+
method="PUT",
|
|
515
|
+
path="/billing/address",
|
|
516
|
+
handler_name="UpdateAddress",
|
|
517
|
+
parameters=[EndpointParameter(name="address_dto", location="body")],
|
|
518
|
+
database_access=True,
|
|
519
|
+
state_changing=True,
|
|
520
|
+
source=SourceLocation(file="billing.go", line_start=95, line_end=110),
|
|
521
|
+
),
|
|
522
|
+
"func UpdateAddress(body []byte) { var addr Address; json.Unmarshal(body, &addr); db.Save(&addr) }",
|
|
523
|
+
"MASS_ASSIGNMENT",
|
|
524
|
+
"mass_assignment",
|
|
525
|
+
),
|
|
526
|
+
|
|
527
|
+
# -------------------------------------------------------------
|
|
528
|
+
# 7. Safe Controls / Benign - 5 samples
|
|
529
|
+
# -------------------------------------------------------------
|
|
530
|
+
(
|
|
531
|
+
Endpoint(
|
|
532
|
+
id="ep_safe_1",
|
|
533
|
+
method="GET",
|
|
534
|
+
path="/health",
|
|
535
|
+
handler_name="health_check",
|
|
536
|
+
auth_required=False,
|
|
537
|
+
source=SourceLocation(file="health.py", line_start=1, line_end=5),
|
|
538
|
+
),
|
|
539
|
+
"def health_check(): return {'status': 'ok'}",
|
|
540
|
+
"NONE",
|
|
541
|
+
"none",
|
|
542
|
+
),
|
|
543
|
+
(
|
|
544
|
+
Endpoint(
|
|
545
|
+
id="ep_safe_2",
|
|
546
|
+
method="GET",
|
|
547
|
+
path="/healthz",
|
|
548
|
+
handler_name="Healthz",
|
|
549
|
+
auth_required=False,
|
|
550
|
+
source=SourceLocation(file="main.go", line_start=10, line_end=15),
|
|
551
|
+
),
|
|
552
|
+
"func Healthz(w http.ResponseWriter, r *http.Request) { w.Write([]byte(\"ok\")) }",
|
|
553
|
+
"NONE",
|
|
554
|
+
"none",
|
|
555
|
+
),
|
|
556
|
+
(
|
|
557
|
+
Endpoint(
|
|
558
|
+
id="ep_safe_3",
|
|
559
|
+
method="GET",
|
|
560
|
+
path="/metrics",
|
|
561
|
+
handler_name="getMetrics",
|
|
562
|
+
auth_required=False,
|
|
563
|
+
source=SourceLocation(file="MetricsController.java", line_start=20, line_end=30),
|
|
564
|
+
),
|
|
565
|
+
"@GetMapping(\"/metrics\") public String metrics() { return prometheusMeterRegistry.scrape(); }",
|
|
566
|
+
"NONE",
|
|
567
|
+
"none",
|
|
568
|
+
),
|
|
569
|
+
(
|
|
570
|
+
Endpoint(
|
|
571
|
+
id="ep_safe_4",
|
|
572
|
+
method="GET",
|
|
573
|
+
path="/static/main.css",
|
|
574
|
+
handler_name="staticCss",
|
|
575
|
+
auth_required=False,
|
|
576
|
+
source=SourceLocation(file="static.js", line_start=5, line_end=10),
|
|
577
|
+
),
|
|
578
|
+
"app.use('/static', express.static(path.join(__dirname, 'public')))",
|
|
579
|
+
"NONE",
|
|
580
|
+
"none",
|
|
581
|
+
),
|
|
582
|
+
(
|
|
583
|
+
Endpoint(
|
|
584
|
+
id="ep_safe_5",
|
|
585
|
+
method="GET",
|
|
586
|
+
path="/api/v1/orders/safe/{id}",
|
|
587
|
+
handler_name="get_order_safe",
|
|
588
|
+
auth_required=True,
|
|
589
|
+
parameters=[EndpointParameter(name="id", location="path")],
|
|
590
|
+
database_access=True,
|
|
591
|
+
object_identifier=True,
|
|
592
|
+
source=SourceLocation(file="orders_safe.py", line_start=40, line_end=55),
|
|
593
|
+
),
|
|
594
|
+
"def get_order_safe(id, user=Depends(get_current_user)): return db.query(Order).filter(Order.id == id, Order.tenant_id == user.tenant_id).first()",
|
|
595
|
+
"NONE",
|
|
596
|
+
"none",
|
|
597
|
+
),
|
|
598
|
+
]
|
|
599
|
+
return suite
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def run_intelligence_benchmark() -> Dict[str, Any]:
|
|
603
|
+
"""Executes live benchmark comparing Laya vs SecureBERT vs Dual-Engine Ensemble."""
|
|
604
|
+
console.print("\n[bold green]Initializing TRACE Neural Intelligence Benchmark[/bold green]")
|
|
605
|
+
console.print("[dim white]Evaluating Laya System 1 vs. SecureBERT 2.0 on 35 Diverse Enterprise Endpoints...[/dim white]\n")
|
|
606
|
+
|
|
607
|
+
test_suite = build_enterprise_benchmark_suite()
|
|
608
|
+
|
|
609
|
+
# Initialize engines with fresh temp cache for SecureBERT to measure true neural forward latency
|
|
610
|
+
temp_cache_file = Path(".trace/cache/benchmark_neural_temp.json")
|
|
611
|
+
if temp_cache_file.exists():
|
|
612
|
+
temp_cache_file.unlink(missing_ok=True)
|
|
613
|
+
|
|
614
|
+
bert = SecureBERTClassifier(cache_path=temp_cache_file)
|
|
615
|
+
laya = LayaDecisionEngine()
|
|
616
|
+
apm = AttackPathModel(name="benchmark_suite")
|
|
617
|
+
|
|
618
|
+
from trace_engine.apm.model import APMNode, NodeType, APMEdge, EdgeType
|
|
619
|
+
|
|
620
|
+
# Populate basic APM graph nodes so APM context is active
|
|
621
|
+
for ep, _, _, _ in test_suite:
|
|
622
|
+
apm.add_node(
|
|
623
|
+
APMNode(
|
|
624
|
+
id=ep.id,
|
|
625
|
+
node_type=NodeType.ENDPOINT,
|
|
626
|
+
label=ep.display_name(),
|
|
627
|
+
properties={"method": ep.method, "path": ep.path},
|
|
628
|
+
)
|
|
629
|
+
)
|
|
630
|
+
if ep.database_access:
|
|
631
|
+
db_id = f"db_{ep.id}"
|
|
632
|
+
op = "update" if (ep.method in ("PUT", "PATCH") or (ep.method == "POST" and ep.state_changing)) else "lookup" if ep.object_identifier else "query"
|
|
633
|
+
apm.add_node(
|
|
634
|
+
APMNode(
|
|
635
|
+
id=db_id,
|
|
636
|
+
node_type=NodeType.DATABASE,
|
|
637
|
+
label="DatabaseAccess",
|
|
638
|
+
properties={"operation": op},
|
|
639
|
+
)
|
|
640
|
+
)
|
|
641
|
+
apm.add_edge(APMEdge(source_id=ep.id, target_id=db_id, edge_type=EdgeType.ACCESSES))
|
|
642
|
+
if ep.external_network:
|
|
643
|
+
ext_id = f"ext_{ep.id}"
|
|
644
|
+
apm.add_node(
|
|
645
|
+
APMNode(
|
|
646
|
+
id=ext_id,
|
|
647
|
+
node_type=NodeType.EXTERNAL_SERVICE,
|
|
648
|
+
label="OutboundHTTPClient",
|
|
649
|
+
properties={"operation": "dispatch"},
|
|
650
|
+
)
|
|
651
|
+
)
|
|
652
|
+
apm.add_edge(APMEdge(source_id=ep.id, target_id=ext_id, edge_type=EdgeType.CALLS))
|
|
653
|
+
if "admin" in ep.roles or "/admin" in ep.path.lower():
|
|
654
|
+
priv_id = f"priv_{ep.id}"
|
|
655
|
+
apm.add_node(
|
|
656
|
+
APMNode(
|
|
657
|
+
id=priv_id,
|
|
658
|
+
node_type=NodeType.SINK,
|
|
659
|
+
label="PrivilegedOperation",
|
|
660
|
+
properties={"operation": "admin_action"},
|
|
661
|
+
)
|
|
662
|
+
)
|
|
663
|
+
apm.add_edge(APMEdge(source_id=ep.id, target_id=priv_id, edge_type=EdgeType.CALLS))
|
|
664
|
+
elif not ep.auth_required and ep.state_changing and ep.sensitive_data:
|
|
665
|
+
state_id = f"state_{ep.id}"
|
|
666
|
+
apm.add_node(
|
|
667
|
+
APMNode(
|
|
668
|
+
id=state_id,
|
|
669
|
+
node_type=NodeType.SINK,
|
|
670
|
+
label="StateModification",
|
|
671
|
+
properties={"operation": "state_write"},
|
|
672
|
+
)
|
|
673
|
+
)
|
|
674
|
+
apm.add_edge(APMEdge(source_id=ep.id, target_id=state_id, edge_type=EdgeType.CALLS))
|
|
675
|
+
elif "ping" in ep.path.lower() or "exec" in ep.path.lower():
|
|
676
|
+
cmd_id = f"cmd_{ep.id}"
|
|
677
|
+
apm.add_node(
|
|
678
|
+
APMNode(
|
|
679
|
+
id=cmd_id,
|
|
680
|
+
node_type=NodeType.SINK,
|
|
681
|
+
label="CommandExecution",
|
|
682
|
+
properties={"operation": "system_exec"},
|
|
683
|
+
)
|
|
684
|
+
)
|
|
685
|
+
apm.add_edge(APMEdge(source_id=ep.id, target_id=cmd_id, edge_type=EdgeType.CALLS))
|
|
686
|
+
|
|
687
|
+
# Warmup GPU
|
|
688
|
+
try:
|
|
689
|
+
sample_ep, sample_code, _, _ = test_suite[0]
|
|
690
|
+
laya.decide_test_selection(sample_ep, apm, [])
|
|
691
|
+
bert.classify_slice(sample_code, sample_ep)
|
|
692
|
+
except Exception:
|
|
693
|
+
pass
|
|
694
|
+
|
|
695
|
+
# 1. Benchmark Laya System 1 (Non-Autoregressive Router)
|
|
696
|
+
laya_latencies = []
|
|
697
|
+
laya_correct = 0
|
|
698
|
+
laya_compound_correct = 0
|
|
699
|
+
|
|
700
|
+
for ep, code, exp_cat, exp_pack in test_suite:
|
|
701
|
+
t0 = time.perf_counter()
|
|
702
|
+
dec = laya.decide_test_selection(ep, apm, [])
|
|
703
|
+
laya_latencies.append((time.perf_counter() - t0) * 1000)
|
|
704
|
+
if dec.primary_testpack == exp_pack or (exp_pack == "none" and not dec.primary_testpack):
|
|
705
|
+
laya_correct += 1
|
|
706
|
+
if exp_pack in dec.applicable_testpacks or (exp_pack == "none" and dec.primary_testpack == "none"):
|
|
707
|
+
laya_compound_correct += 1
|
|
708
|
+
|
|
709
|
+
avg_laya_lat = sum(laya_latencies) / len(laya_latencies)
|
|
710
|
+
laya_acc = (laya_correct / len(test_suite)) * 100
|
|
711
|
+
laya_compound_acc = (laya_compound_correct / len(test_suite)) * 100
|
|
712
|
+
|
|
713
|
+
# 2. Benchmark SecureBERT 2.0 (AST Semantic Encoder)
|
|
714
|
+
bert_latencies = []
|
|
715
|
+
bert_correct = 0
|
|
716
|
+
|
|
717
|
+
for ep, code, exp_cat, exp_pack in test_suite:
|
|
718
|
+
t0 = time.perf_counter()
|
|
719
|
+
scores = bert.classify_slice(code, ep)
|
|
720
|
+
bert_latencies.append((time.perf_counter() - t0) * 1000)
|
|
721
|
+
top_cat = max(scores, key=scores.get) if scores else "NONE"
|
|
722
|
+
if top_cat == exp_cat or (exp_cat == "NONE" and all(v < 0.3 for v in scores.values())):
|
|
723
|
+
bert_correct += 1
|
|
724
|
+
|
|
725
|
+
avg_bert_lat = sum(bert_latencies) / len(bert_latencies)
|
|
726
|
+
bert_acc = (bert_correct / len(test_suite)) * 100
|
|
727
|
+
|
|
728
|
+
# 3. Benchmark Dual-Engine Cascade + Bayesian Fusion
|
|
729
|
+
# Cascade: Laya rapidly filters safe routes in ~1ms; SecureBERT inspects suspect AST slices
|
|
730
|
+
ensemble_latencies = []
|
|
731
|
+
ensemble_correct = 0
|
|
732
|
+
|
|
733
|
+
for ep, code, exp_cat, exp_pack in test_suite:
|
|
734
|
+
t0 = time.perf_counter()
|
|
735
|
+
# Stage 1: Laya rapid triage
|
|
736
|
+
prio = laya.decide_priority(ep, apm)
|
|
737
|
+
pack_dec = laya.decide_test_selection(ep, apm, [])
|
|
738
|
+
|
|
739
|
+
if prio.priority_level == "low" and pack_dec.primary_testpack == "none":
|
|
740
|
+
# Screened out by Laya in Tier 1 with zero expensive BERT AST evaluation
|
|
741
|
+
pred = "NONE"
|
|
742
|
+
else:
|
|
743
|
+
# Stage 2: Deep SecureBERT evaluation on suspect endpoint
|
|
744
|
+
scores = bert.classify_slice(code, ep)
|
|
745
|
+
top_cat = max(scores, key=scores.get) if scores else "NONE"
|
|
746
|
+
|
|
747
|
+
# Stage 3: Bayesian evidence calibration
|
|
748
|
+
laya_top = pack_dec.primary_testpack.upper()
|
|
749
|
+
if laya_top == top_cat:
|
|
750
|
+
pred = top_cat
|
|
751
|
+
else:
|
|
752
|
+
pred = top_cat if scores.get(top_cat, 0.0) >= 0.35 else laya_top
|
|
753
|
+
|
|
754
|
+
ensemble_latencies.append((time.perf_counter() - t0) * 1000)
|
|
755
|
+
if pred == exp_cat or (exp_cat == "NONE" and pred == "NONE"):
|
|
756
|
+
ensemble_correct += 1
|
|
757
|
+
|
|
758
|
+
avg_ens_lat = sum(ensemble_latencies) / len(ensemble_latencies)
|
|
759
|
+
ens_acc = (ensemble_correct / len(test_suite)) * 100
|
|
760
|
+
|
|
761
|
+
# Cleanup temp benchmark cache
|
|
762
|
+
if temp_cache_file.exists():
|
|
763
|
+
temp_cache_file.unlink(missing_ok=True)
|
|
764
|
+
|
|
765
|
+
# Render results table
|
|
766
|
+
table = Table(
|
|
767
|
+
title="[bold green]TRACE AI Neural Model Head-to-Head Comparison[/bold green]",
|
|
768
|
+
box=ROUNDED,
|
|
769
|
+
header_style="bold green",
|
|
770
|
+
border_style="green",
|
|
771
|
+
show_header=True,
|
|
772
|
+
)
|
|
773
|
+
table.add_column("Engine / Model", style="bold white", width=24)
|
|
774
|
+
table.add_column("Architecture", style="white", width=22)
|
|
775
|
+
table.add_column("Inference Latency", justify="center", style="bold green", width=18)
|
|
776
|
+
table.add_column("Identification Acc", justify="center", style="bold white", width=20)
|
|
777
|
+
table.add_column("Primary Superpower / Role", style="dim white")
|
|
778
|
+
|
|
779
|
+
speedup = (avg_bert_lat / avg_laya_lat) if avg_laya_lat > 0 else 1.0
|
|
780
|
+
|
|
781
|
+
table.add_row(
|
|
782
|
+
"Laya System 1",
|
|
783
|
+
"Non-Autoregressive Router",
|
|
784
|
+
f"{avg_laya_lat:.2f} ms",
|
|
785
|
+
f"{laya_acc:.1f}% ({laya_compound_acc:.1f}% cov)",
|
|
786
|
+
"Ultra-fast triage, compound testpack dispatch, APM graph policy decisions",
|
|
787
|
+
)
|
|
788
|
+
table.add_row(
|
|
789
|
+
"SecureBERT 2.0",
|
|
790
|
+
"Bidirectional AST Encoder",
|
|
791
|
+
f"{avg_bert_lat:.2f} ms",
|
|
792
|
+
f"{bert_acc:.1f}%",
|
|
793
|
+
"Deep semantic code inspection, multi-label CWE classification",
|
|
794
|
+
)
|
|
795
|
+
table.add_row(
|
|
796
|
+
"Dual-Engine Ensemble",
|
|
797
|
+
"Cascade + Bayesian Fusion",
|
|
798
|
+
f"{avg_ens_lat:.2f} ms",
|
|
799
|
+
f"[bold green]{ens_acc:.1f}%[/bold green]",
|
|
800
|
+
"Peak accuracy: Laya filters non-critical paths; BERT inspects sinks",
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
console.print(table)
|
|
804
|
+
|
|
805
|
+
summary_text = Text()
|
|
806
|
+
summary_text.append("Key Architectural Findings & Strategic Guidance:\n", style="bold green")
|
|
807
|
+
summary_text.append(" 1. Speed vs. Depth: ", style="bold white")
|
|
808
|
+
summary_text.append(f"Laya is {speedup:.1f}x faster than SecureBERT, making it the optimal first-tier screener.\n", style="white")
|
|
809
|
+
summary_text.append(" 2. Generation Capability: ", style="bold white")
|
|
810
|
+
summary_text.append("Neither BERT nor Laya can generate freeform text/code (both are encoder models). Code remediation is handled by System 2 Causal LLMs (Qwen/CodeLlama) and deterministic AST patchers.\n", style="white")
|
|
811
|
+
summary_text.append(" 3. Optimal Synergy: ", style="bold white")
|
|
812
|
+
summary_text.append(f"Dual-engine cascade achieves {ens_acc:.1f}% accuracy across 35 enterprise endpoints with {avg_ens_lat:.2f} ms latency.\n", style="bold green")
|
|
813
|
+
|
|
814
|
+
console.print(
|
|
815
|
+
Panel(
|
|
816
|
+
summary_text,
|
|
817
|
+
title="[bold green]Executive Neural Intelligence Verdict[/bold green]",
|
|
818
|
+
border_style="green",
|
|
819
|
+
box=ROUNDED,
|
|
820
|
+
padding=(1, 2),
|
|
821
|
+
)
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
return {
|
|
825
|
+
"laya": {"latency_ms": avg_laya_lat, "accuracy": laya_acc},
|
|
826
|
+
"securebert": {"latency_ms": avg_bert_lat, "accuracy": bert_acc},
|
|
827
|
+
"ensemble": {"latency_ms": avg_ens_lat, "accuracy": ens_acc},
|
|
828
|
+
}
|