diff --git a/ExtAnalysis/reports.json b/ExtAnalysis/reports.json index 91319ba5..ede89cd3 100644 --- a/ExtAnalysis/reports.json +++ b/ExtAnalysis/reports.json @@ -1266,6 +1266,13 @@ "report_directory": "/EXA2026163071822", "time": "2026-06-12 07:18:23", "version": "1.0.1" + }, + { + "id": "EXA2026163073153", + "name": "Chrome MCP Server - AI Browser Control", + "report_directory": "/EXA2026163073153", + "time": "2026-06-12 07:31:54", + "version": "1.0.1" } ] } \ No newline at end of file diff --git a/embedding/base/ad_frame_inline_injection.json b/embedding/base/ad_frame_inline_injection.json index a7c4b5d7..479dd9a0 100644 --- a/embedding/base/ad_frame_inline_injection.json +++ b/embedding/base/ad_frame_inline_injection.json @@ -1,4 +1,6 @@ { + "scenario_id": "mjokpjlgmbbdhooncpdlgcgpepecigdm", + "builtin": true, "pattern_name": "ad_frame_inline_injection", "doc_ref": "scenario_docs/ad_frame_inline_injection.md", "vector_fingerprint": { @@ -6,8 +8,15 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["tabs", "declarativeNetRequest", "scripting"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "tabs", + "declarativeNetRequest", + "scripting" + ] }, "capability_profile": [ "csp_removal", @@ -22,23 +31,44 @@ ], "static_code_signals": { "injection": { - "apis": ["window.eval"], - "keywords": ["onload", "this.remove", "isGoogle", "isFrame"] + "apis": [ + "window.eval" + ], + "keywords": [ + "onload", + "this.remove", + "isGoogle", + "isFrame" + ] }, "messaging": { - "apis": ["chrome.tabs.sendMessage"], - "keywords": ["link", "frame"] + "apis": [ + "chrome.tabs.sendMessage" + ], + "keywords": [ + "link", + "frame" + ] }, "dnr": { - "apis": ["declarativeNetRequest"], - "keywords": ["X-Frame-Options", "modifyHeaders"] + "apis": [ + "declarativeNetRequest" + ], + "keywords": [ + "X-Frame-Options", + "modifyHeaders" + ] } }, "predicted_flows": [ { "trigger": "page_load", "source": "remote_html_payload", - "path": ["img_inject", "onload_eval", "frame_overlay"], + "path": [ + "img_inject", + "onload_eval", + "frame_overlay" + ], "sink": "ad_frame_displayed" } ], @@ -49,4 +79,4 @@ "search_result_overlay" ] } -} +} \ No newline at end of file diff --git a/embedding/base/ad_fraud_session_replay.json b/embedding/base/ad_fraud_session_replay.json index 5cd3dffe..c39b2136 100644 --- a/embedding/base/ad_fraud_session_replay.json +++ b/embedding/base/ad_fraud_session_replay.json @@ -1,4 +1,6 @@ { + "scenario_id": "jnhoiaicifppampaldahclihhlejkbaf", + "builtin": true, "pattern_name": "ad_fraud_session_replay", "doc_ref": "scenario_docs/ad_fraud_session_replay.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["tabs", "storage"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "tabs", + "storage" + ] }, "capability_profile": [ "bloom_filter_domain_check", @@ -21,19 +29,33 @@ ], "static_code_signals": { "network": { - "apis": ["fetch"], - "keywords": ["url", "options", "arrayBuffer"] + "apis": [ + "fetch" + ], + "keywords": [ + "url", + "options", + "arrayBuffer" + ] }, "storage": { - "apis": ["chrome.storage.local"], - "keywords": ["bff"] + "apis": [ + "chrome.storage.local" + ], + "keywords": [ + "bff" + ] } }, "predicted_flows": [ { "trigger": "domain_match", "source": "bloom_filter", - "path": ["url_send", "session_id_receive", "fetch_loop"], + "path": [ + "url_send", + "session_id_receive", + "fetch_loop" + ], "sink": "ad_click_simulation" } ], @@ -44,4 +66,4 @@ "fake_traffic" ] } -} +} \ No newline at end of file diff --git a/embedding/base/affiliate_cookie_stuffing.json b/embedding/base/affiliate_cookie_stuffing.json index 1a08dfe2..78220111 100644 --- a/embedding/base/affiliate_cookie_stuffing.json +++ b/embedding/base/affiliate_cookie_stuffing.json @@ -1,4 +1,6 @@ { + "scenario_id": "oinmkgpnllnekklbmnbficejejlbgfaf", + "builtin": true, "pattern_name": "affiliate_cookie_stuffing", "doc_ref": "scenario_docs/affiliate_cookie_stuffing.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["tabs", "storage"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "tabs", + "storage" + ] }, "capability_profile": [ "affiliate_url_fetch", @@ -20,19 +28,33 @@ ], "static_code_signals": { "tabs": { - "apis": ["chrome.tabs.create"], - "keywords": ["url", "awinaffid", "awinmid"] + "apis": [ + "chrome.tabs.create" + ], + "keywords": [ + "url", + "awinaffid", + "awinmid" + ] }, "network": { - "apis": ["fetch"], - "keywords": ["selectors", "url"] + "apis": [ + "fetch" + ], + "keywords": [ + "selectors", + "url" + ] } }, "predicted_flows": [ { "trigger": "target_domain_visit", "source": "affiliate_url_from_server", - "path": ["tabs_create", "cookie_set"], + "path": [ + "tabs_create", + "cookie_set" + ], "sink": "affiliate_commission_fraud" } ], @@ -43,4 +65,4 @@ "silent_navigation" ] } -} +} \ No newline at end of file diff --git a/embedding/base/anti_debugging_trace_removal.json b/embedding/base/anti_debugging_trace_removal.json index 16861937..f6abceaf 100644 --- a/embedding/base/anti_debugging_trace_removal.json +++ b/embedding/base/anti_debugging_trace_removal.json @@ -1,4 +1,6 @@ { + "scenario_id": "gcjoobcomaehjamoklloigpjcllemfad", + "builtin": true, "pattern_name": "anti_debugging_trace_removal", "doc_ref": "scenario_docs/anti_debugging_trace_removal.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["tabs", "storage"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "tabs", + "storage" + ] }, "capability_profile": [ "devtools_detection", @@ -20,15 +27,21 @@ ], "static_code_signals": { "tabs": { - "apis": ["chrome.tabs.query"], - "keywords": ["chrome://extensions/*"] + "apis": [ + "chrome.tabs.query" + ], + "keywords": [ + "chrome://extensions/*" + ] } }, "predicted_flows": [ { "trigger": "extensions_page_detected", "source": "tabs_query_result", - "path": ["storage_key_removal"], + "path": [ + "storage_key_removal" + ], "sink": "malicious_trace_erased" } ], @@ -39,4 +52,4 @@ "storage_cleanup" ] } -} +} \ No newline at end of file diff --git a/embedding/base/browser_automation_remote_control.json b/embedding/base/browser_automation_remote_control.json index 11ccd3ee..04b2e04a 100644 --- a/embedding/base/browser_automation_remote_control.json +++ b/embedding/base/browser_automation_remote_control.json @@ -1,4 +1,6 @@ { + "scenario_id": "jopbobkiihaohndkafaboogaokbekhao", + "builtin": true, "pattern_name": "browser_automation_remote_control", "doc_ref": "scenario_docs/browser_automation_remote_control.md", "vector_fingerprint": { @@ -6,8 +8,19 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script", "popup"], - "permissions_hint": ["debugger", "scripting", "tabs", "activeTab", "offscreen", "webRequest"] + "entrypoint_roles": [ + "background", + "content_script", + "popup" + ], + "permissions_hint": [ + "debugger", + "scripting", + "tabs", + "activeTab", + "offscreen", + "webRequest" + ] }, "capability_profile": [ "remote_browser_control", @@ -103,13 +116,20 @@ { "trigger": "remote_command_or_popup_action", "source": "background", - "path": ["command_router", "scripting.executeScript", "helper_script"], + "path": [ + "command_router", + "scripting.executeScript", + "helper_script" + ], "sink": "dom_action_or_network_request" }, { "trigger": "debugger_command", "source": "background", - "path": ["chrome.debugger", "devtools_protocol"], + "path": [ + "chrome.debugger", + "devtools_protocol" + ], "sink": "page_control_or_capture" } ], @@ -123,5 +143,4 @@ "tab_control" ] } -} - +} \ No newline at end of file diff --git a/embedding/base/browser_fingerprinting_environment_collection.json b/embedding/base/browser_fingerprinting_environment_collection.json index c4875cc2..cfc33025 100644 --- a/embedding/base/browser_fingerprinting_environment_collection.json +++ b/embedding/base/browser_fingerprinting_environment_collection.json @@ -1,4 +1,6 @@ { + "scenario_id": "bmpbjkjkiabihpahahcgcdjgdnbhbkhd", + "builtin": true, "pattern_name": "browser_fingerprinting_environment_collection", "doc_ref": "scenario_docs/browser_fingerprinting_environment_collection.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["content_script", "background"], - "permissions_hint": ["storage"] + "entrypoint_roles": [ + "content_script", + "background" + ], + "permissions_hint": [ + "storage" + ] }, "capability_profile": [ "browser_fingerprinting", @@ -25,19 +32,32 @@ "screen.height", "Date.prototype.getTimezoneOffset" ], - "patterns": ["environment_fingerprint_bundle"] + "patterns": [ + "environment_fingerprint_bundle" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "endpoint_keywords": ["fingerprint", "environment"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "endpoint_keywords": [ + "fingerprint", + "environment" + ] } }, "predicted_flows": [ { "trigger": "page_load", "source": "browser_environment", - "path": ["content_script", "serialize", "background"], + "path": [ + "content_script", + "serialize", + "background" + ], "sink": "localhost_post" } ], @@ -47,4 +67,4 @@ "external_communication" ] } -} +} \ No newline at end of file diff --git a/embedding/base/browsing_profile_exfiltration.json b/embedding/base/browsing_profile_exfiltration.json index 38b9f211..bcb79954 100644 --- a/embedding/base/browsing_profile_exfiltration.json +++ b/embedding/base/browsing_profile_exfiltration.json @@ -1,4 +1,6 @@ { + "scenario_id": "bjgcjlhihffpdcopmhamgninpcbfmooc", + "builtin": true, "pattern_name": "browsing_profile_exfiltration", "doc_ref": "scenario_docs/browsing_profile_exfiltration.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["tabs", "storage"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "tabs", + "storage" + ] }, "capability_profile": [ "tab_event_monitoring", @@ -21,23 +29,44 @@ ], "static_code_signals": { "tabs": { - "apis": ["chrome.tabs.onUpdated"], - "keywords": ["url", "referrer"] + "apis": [ + "chrome.tabs.onUpdated" + ], + "keywords": [ + "url", + "referrer" + ] }, "tracking": { - "keywords": ["distinct_id", "tab_id", "browser_version", "page_visit"] + "keywords": [ + "distinct_id", + "tab_id", + "browser_version", + "page_visit" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "keywords": ["amazonaws", "alooma", "EventTracking"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "keywords": [ + "amazonaws", + "alooma", + "EventTracking" + ] } }, "predicted_flows": [ { "trigger": "tab_updated", "source": "current_url", - "path": ["collect_metadata", "post_to_endpoint"], + "path": [ + "collect_metadata", + "post_to_endpoint" + ], "sink": "browsing_profile_server" } ], @@ -48,4 +77,4 @@ "silent_telemetry" ] } -} +} \ No newline at end of file diff --git a/embedding/base/c2_response_dom_innerhtml_injection.json b/embedding/base/c2_response_dom_innerhtml_injection.json index 6e13227d..5c4df9f8 100644 --- a/embedding/base/c2_response_dom_innerhtml_injection.json +++ b/embedding/base/c2_response_dom_innerhtml_injection.json @@ -1,4 +1,6 @@ { + "scenario_id": "fhbijcbjboaaebhapeicnpoimepidffo", + "builtin": true, "pattern_name": "c2_response_dom_innerhtml_injection", "doc_ref": "scenario_docs/c2_response_dom_innerhtml_injection.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["content_script", "background"], - "permissions_hint": ["scripting", "activeTab"] + "entrypoint_roles": [ + "content_script", + "background" + ], + "permissions_hint": [ + "scripting", + "activeTab" + ] }, "capability_profile": [ "dom_access", @@ -19,14 +27,31 @@ "innerHTML + insertAdjacentHTML" ], "static_code_signals": { - "dom": {"apis": ["innerHTML", "insertAdjacentHTML"], "keywords": ["result.rating", "result.protxt", "classList.remove"]}, - "network": {"apis": ["fetch"]} + "dom": { + "apis": [ + "innerHTML", + "insertAdjacentHTML" + ], + "keywords": [ + "result.rating", + "result.protxt", + "classList.remove" + ] + }, + "network": { + "apis": [ + "fetch" + ] + } }, "predicted_flows": [ { "trigger": "mock_response", "source": "remote_html", - "path": ["content_script", "dom_write"], + "path": [ + "content_script", + "dom_write" + ], "sink": "page_dom" } ], @@ -36,4 +61,4 @@ "remote_content_injection" ] } -} +} \ No newline at end of file diff --git a/embedding/base/console_method_silencing_override.json b/embedding/base/console_method_silencing_override.json index b2e0cc1f..3e066d41 100644 --- a/embedding/base/console_method_silencing_override.json +++ b/embedding/base/console_method_silencing_override.json @@ -1,4 +1,6 @@ { + "scenario_id": "ljfeaocilnmfchmmpipneafmbeefokid", + "builtin": true, "pattern_name": "console_method_silencing_override", "doc_ref": "scenario_docs/console_method_silencing_override.md", "vector_fingerprint": { @@ -6,8 +8,12 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["content_script"], - "permissions_hint": ["scripting"] + "entrypoint_roles": [ + "content_script" + ], + "permissions_hint": [ + "scripting" + ] }, "capability_profile": [ "anti_analysis", @@ -27,14 +33,19 @@ "console.table", "console.trace" ], - "patterns": ["console_method_reassignment"] + "patterns": [ + "console_method_reassignment" + ] } }, "predicted_flows": [ { "trigger": "script_load", "source": "injected_script", - "path": ["content_script", "console_override"], + "path": [ + "content_script", + "console_override" + ], "sink": "debug_visibility_reduction" } ], @@ -43,4 +54,4 @@ "debug_evasion" ] } -} +} \ No newline at end of file diff --git a/embedding/base/dnr_security_header_bypass.json b/embedding/base/dnr_security_header_bypass.json index 20829b07..8276d862 100644 --- a/embedding/base/dnr_security_header_bypass.json +++ b/embedding/base/dnr_security_header_bypass.json @@ -1,4 +1,6 @@ { + "scenario_id": "knfdfgomknhggpcmjcnkfihjklopnifl", + "builtin": true, "pattern_name": "dnr_security_header_bypass", "doc_ref": "scenario_docs/dnr_security_header_bypass.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["declarativeNetRequest", "declarativeNetRequestWithHostAccess"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "declarativeNetRequest", + "declarativeNetRequestWithHostAccess" + ] }, "capability_profile": [ "dnr_ruleset", @@ -20,15 +27,35 @@ ], "static_code_signals": { "dnr": { - "apis": ["declarativeNetRequest", "updateSessionRules", "updateDynamicRules", "modifyHeaders", "addRules", "removeRuleIds", "webRequest.onBeforeSendHeaders"], - "keywords": ["Content-Security-Policy", "Content-Security-Policy-Report-Only", "X-Frame-Options", "operation_remove", "urlFilter_wildcard", "main_frame", "volumeHeaderRules", "Access-Control-Allow-Origin"] + "apis": [ + "declarativeNetRequest", + "updateSessionRules", + "updateDynamicRules", + "modifyHeaders", + "addRules", + "removeRuleIds", + "webRequest.onBeforeSendHeaders" + ], + "keywords": [ + "Content-Security-Policy", + "Content-Security-Policy-Report-Only", + "X-Frame-Options", + "operation_remove", + "urlFilter_wildcard", + "main_frame", + "volumeHeaderRules", + "Access-Control-Allow-Origin" + ] } }, "predicted_flows": [ { "trigger": "request_intercept", "source": "mock_request", - "path": ["dnr_rules", "header_modify"], + "path": [ + "dnr_rules", + "header_modify" + ], "sink": "modified_headers" } ], @@ -39,4 +66,4 @@ "request_modification" ] } -} +} \ No newline at end of file diff --git a/embedding/base/dynamic_config_polling_remote_interval.json b/embedding/base/dynamic_config_polling_remote_interval.json index 297bdf8f..b9b27ada 100644 --- a/embedding/base/dynamic_config_polling_remote_interval.json +++ b/embedding/base/dynamic_config_polling_remote_interval.json @@ -1,4 +1,6 @@ { + "scenario_id": "jhblcplcnhopplmjpcmhpimlpbajofpi", + "builtin": true, "pattern_name": "dynamic_config_polling_remote_interval", "doc_ref": "scenario_docs/dynamic_config_polling_remote_interval.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["alarms", "storage"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "alarms", + "storage" + ] }, "capability_profile": [ "remote_configuration", @@ -21,35 +28,72 @@ ], "static_code_signals": { "bootstrap": { - "apis": ["chrome.runtime.getManifest", "Date.now"], - "keywords": ["version", "install"] + "apis": [ + "chrome.runtime.getManifest", + "Date.now" + ], + "keywords": [ + "version", + "install" + ] }, "polling": { - "apis": ["chrome.alarms", "chrome.storage.sync"], - "keywords": ["configUpdateInterval"] + "apis": [ + "chrome.alarms", + "chrome.storage.sync" + ], + "keywords": [ + "configUpdateInterval" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "endpoint_keywords": ["checkin", "config"], - "keywords": ["installParams", "checklist", "dead_drop_resolver", "blog_c2_parse", "atob", "JSON.parse"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "endpoint_keywords": [ + "checkin", + "config" + ], + "keywords": [ + "installParams", + "checklist", + "dead_drop_resolver", + "blog_c2_parse", + "atob", + "JSON.parse" + ] }, "reload": { - "apis": ["chrome.runtime.reload"], - "keywords": ["config_merge", "storage.local.get", "storage.local.set"] + "apis": [ + "chrome.runtime.reload" + ], + "keywords": [ + "config_merge", + "storage.local.get", + "storage.local.set" + ] } }, "predicted_flows": [ { "trigger": "on_installed", "source": "manifest_version", - "path": ["background", "checkin_post"], + "path": [ + "background", + "checkin_post" + ], "sink": "remote_config" }, { "trigger": "config_received", "source": "config_payload", - "path": ["storage.sync", "alarms_reschedule"], + "path": [ + "storage.sync", + "alarms_reschedule" + ], "sink": "adaptive_polling" } ], @@ -60,4 +104,4 @@ "remote_command_or_config" ] } -} +} \ No newline at end of file diff --git a/embedding/base/input_change_event_collection.json b/embedding/base/input_change_event_collection.json index 1b9b7e9a..eb52a4b5 100644 --- a/embedding/base/input_change_event_collection.json +++ b/embedding/base/input_change_event_collection.json @@ -1,4 +1,6 @@ { + "scenario_id": "hcbgfcpdimjechnieabafjfhgmljneio", + "builtin": true, "pattern_name": "input_change_event_collection", "doc_ref": "scenario_docs/input_change_event_collection.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["content_script", "background"], - "permissions_hint": ["activeTab", "storage"] + "entrypoint_roles": [ + "content_script", + "background" + ], + "permissions_hint": [ + "activeTab", + "storage" + ] }, "capability_profile": [ "user_input_access", @@ -20,23 +28,42 @@ ], "static_code_signals": { "input": { - "apis": ["$('input').change", "Date().getTime"], - "patterns": ["input_change_hook", "HTMLInputElement_getter_hook", "HTMLTextAreaElement_getter_hook"] + "apis": [ + "$('input').change", + "Date().getTime" + ], + "patterns": [ + "input_change_hook", + "HTMLInputElement_getter_hook", + "HTMLTextAreaElement_getter_hook" + ] }, "messaging": { - "apis": ["chrome.runtime.sendMessage"], - "keywords": ["input_payload"] + "apis": [ + "chrome.runtime.sendMessage" + ], + "keywords": [ + "input_payload" + ] }, "context": { - "apis": ["window.location.href"], - "keywords": ["page_url_context"] + "apis": [ + "window.location.href" + ], + "keywords": [ + "page_url_context" + ] } }, "predicted_flows": [ { "trigger": "input_change", "source": "form_field_value", - "path": ["content_script", "runtime_message", "background"], + "path": [ + "content_script", + "runtime_message", + "background" + ], "sink": "localhost_post" } ], @@ -46,4 +73,4 @@ "data_exfiltration" ] } -} +} \ No newline at end of file diff --git a/embedding/base/oauth_profile_collection_exfiltration.json b/embedding/base/oauth_profile_collection_exfiltration.json index c6a742ca..3b1351d2 100644 --- a/embedding/base/oauth_profile_collection_exfiltration.json +++ b/embedding/base/oauth_profile_collection_exfiltration.json @@ -1,4 +1,6 @@ { + "scenario_id": "hbjejegfgicdaoklklakcagkjbeklbnf", + "builtin": true, "pattern_name": "oauth_profile_collection_exfiltration", "doc_ref": "scenario_docs/oauth_profile_collection_exfiltration.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["identity", "storage"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "identity", + "storage" + ] }, "capability_profile": [ "identity_access", @@ -19,16 +26,39 @@ "storage_access + external_network" ], "static_code_signals": { - "identity": {"apis": ["chrome.identity.getAuthToken"]}, - "storage": {"apis": ["chrome.storage.sync.get"]}, - "headers": {"apis": ["Authorization", "X-Custom-Auth"]}, - "network": {"apis": ["fetch"], "methods": ["POST"]} + "identity": { + "apis": [ + "chrome.identity.getAuthToken" + ] + }, + "storage": { + "apis": [ + "chrome.storage.sync.get" + ] + }, + "headers": { + "apis": [ + "Authorization", + "X-Custom-Auth" + ] + }, + "network": { + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ] + } }, "predicted_flows": [ { "trigger": "token_or_profile_collect", "source": "dummy_oauth_profile", - "path": ["background", "payload_build"], + "path": [ + "background", + "payload_build" + ], "sink": "localhost_post" } ], @@ -39,4 +69,4 @@ "data_exfiltration" ] } -} +} \ No newline at end of file diff --git a/embedding/base/page_screenshot_or_content_capture.json b/embedding/base/page_screenshot_or_content_capture.json index 8ea12b5f..6b30eec7 100644 --- a/embedding/base/page_screenshot_or_content_capture.json +++ b/embedding/base/page_screenshot_or_content_capture.json @@ -1,4 +1,6 @@ { + "scenario_id": "bffmneckgkmiafcnjdandmomnhidjcki", + "builtin": true, "pattern_name": "page_screenshot_or_content_capture", "doc_ref": "scenario_docs/page_screenshot_or_content_capture.md", "vector_fingerprint": { @@ -6,8 +8,18 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script", "popup"], - "permissions_hint": ["tabs", "activeTab", "scripting", "debugger", "offscreen"] + "entrypoint_roles": [ + "background", + "content_script", + "popup" + ], + "permissions_hint": [ + "tabs", + "activeTab", + "scripting", + "debugger", + "offscreen" + ] }, "capability_profile": [ "screen_capture", @@ -72,8 +84,13 @@ ] }, "network": { - "apis": ["fetch", "XMLHttpRequest"], - "methods": ["POST"], + "apis": [ + "fetch", + "XMLHttpRequest" + ], + "methods": [ + "POST" + ], "endpoint_keywords": [ "upload", "capture", @@ -88,13 +105,20 @@ { "trigger": "user_action_or_remote_command", "source": "active_tab", - "path": ["popup_or_background", "captureVisibleTab", "serialize_image"], + "path": [ + "popup_or_background", + "captureVisibleTab", + "serialize_image" + ], "sink": "external_network_or_storage" }, { "trigger": "runtime_message", "source": "content_script_or_popup", - "path": ["background", "tabs.captureVisibleTab"], + "path": [ + "background", + "tabs.captureVisibleTab" + ], "sink": "network_post" } ], @@ -107,5 +131,4 @@ "data_exfiltration" ] } -} - +} \ No newline at end of file diff --git a/embedding/base/popunder_ad_tab_injection.json b/embedding/base/popunder_ad_tab_injection.json index bd5b30dc..76c57084 100644 --- a/embedding/base/popunder_ad_tab_injection.json +++ b/embedding/base/popunder_ad_tab_injection.json @@ -1,4 +1,6 @@ { + "scenario_id": "cnjkjjlanphmhcgfcgednjnlkljplkef", + "builtin": true, "pattern_name": "popunder_ad_tab_injection", "doc_ref": "scenario_docs/popunder_ad_tab_injection.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["tabs", "storage"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "tabs", + "storage" + ] }, "capability_profile": [ "remote_configuration", @@ -20,20 +27,34 @@ ], "static_code_signals": { "tabs": { - "apis": ["chrome.tabs.create"], - "keywords": ["newsPage"] + "apis": [ + "chrome.tabs.create" + ], + "keywords": [ + "newsPage" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "keywords": ["newsPage", "config"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "keywords": [ + "newsPage", + "config" + ] } }, "predicted_flows": [ { "trigger": "config_received", "source": "newsPage_value", - "path": ["background", "tabs_create"], + "path": [ + "background", + "tabs_create" + ], "sink": "background_tab_ad_page" } ], @@ -44,4 +65,4 @@ "ad_injection" ] } -} +} \ No newline at end of file diff --git a/embedding/base/remote_browser_control_debugger_scripting.json b/embedding/base/remote_browser_control_debugger_scripting.json index 8f054d73..6033dd7a 100644 --- a/embedding/base/remote_browser_control_debugger_scripting.json +++ b/embedding/base/remote_browser_control_debugger_scripting.json @@ -1,4 +1,6 @@ { + "scenario_id": "cjjldjkklifmcpjjbdjdbbkdeimfgmeh", + "builtin": true, "pattern_name": "remote_browser_control_debugger_scripting", "doc_ref": "scenario_docs/remote_browser_control_debugger_scripting.md", "vector_fingerprint": { @@ -6,8 +8,18 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script", "popup"], - "permissions_hint": ["debugger", "scripting", "tabs", "activeTab", "offscreen"] + "entrypoint_roles": [ + "background", + "content_script", + "popup" + ], + "permissions_hint": [ + "debugger", + "scripting", + "tabs", + "activeTab", + "offscreen" + ] }, "capability_profile": [ "debugger_access", @@ -87,13 +99,19 @@ { "trigger": "remote_command", "source": "background_or_popup", - "path": ["runtime_message", "debugger.sendCommand"], + "path": [ + "runtime_message", + "debugger.sendCommand" + ], "sink": "page_control_or_capture" }, { "trigger": "remote_command", "source": "background_or_popup", - "path": ["scripting.executeScript", "injected_helper"], + "path": [ + "scripting.executeScript", + "injected_helper" + ], "sink": "dom_or_network_side_effect" } ], @@ -106,5 +124,4 @@ "tab_control" ] } -} - +} \ No newline at end of file diff --git a/embedding/base/remote_dom_event_content_manipulation.json b/embedding/base/remote_dom_event_content_manipulation.json index ae75518b..b3d23375 100644 --- a/embedding/base/remote_dom_event_content_manipulation.json +++ b/embedding/base/remote_dom_event_content_manipulation.json @@ -1,4 +1,6 @@ { + "scenario_id": "pdppilmdalpkimffnjbcaaefphiigioo", + "builtin": true, "pattern_name": "remote_dom_event_content_manipulation", "doc_ref": "scenario_docs/remote_dom_event_content_manipulation.md", "vector_fingerprint": { @@ -6,8 +8,15 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["tabs", "scripting", "storage"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "tabs", + "scripting", + "storage" + ] }, "capability_profile": [ "dom_mutation", @@ -21,35 +30,83 @@ ], "static_code_signals": { "events": { - "apis": ["dispatchEvent", "CustomEvent", "onreset"], - "patterns": ["remote_triggered_dom_event"] + "apis": [ + "dispatchEvent", + "CustomEvent", + "onreset" + ], + "patterns": [ + "remote_triggered_dom_event" + ] }, "tabs": { - "apis": ["tabs.onUpdated", "tabs.executeScript"], - "keywords": ["active_tab"] + "apis": [ + "tabs.onUpdated", + "tabs.executeScript" + ], + "keywords": [ + "active_tab" + ] }, "dom": { - "apis": ["document.documentElement.setAttribute", "document.documentElement.removeAttribute"], - "keywords": ["state_toggle", "content_flag", "checklist.info", "checklist.core"] + "apis": [ + "document.documentElement.setAttribute", + "document.documentElement.removeAttribute" + ], + "keywords": [ + "state_toggle", + "content_flag", + "checklist.info", + "checklist.core" + ] }, "storage": { - "apis": ["chrome.storage.local.get"], - "keywords": ["remote_payload"] + "apis": [ + "chrome.storage.local.get" + ], + "keywords": [ + "remote_payload" + ] }, "execution": { - "apis": ["window.eval", "Reflect.apply", "scripting.executeScript", "chrome.tabs.update"], - "keywords": ["window.top", "window.self", "btoa", "unescape", "encodeURIComponent", "credentials", "gsrpdt", "unsafe-eval"] + "apis": [ + "window.eval", + "Reflect.apply", + "scripting.executeScript", + "chrome.tabs.update" + ], + "keywords": [ + "window.top", + "window.self", + "btoa", + "unescape", + "encodeURIComponent", + "credentials", + "gsrpdt", + "unsafe-eval" + ] }, "navigation": { - "apis": ["chrome.windows", "chrome.tabs"], - "keywords": ["navigate", "focus", "setFocusTab"] + "apis": [ + "chrome.windows", + "chrome.tabs" + ], + "keywords": [ + "navigate", + "focus", + "setFocusTab" + ] } }, "predicted_flows": [ { "trigger": "remote_response", "source": "config_payload", - "path": ["storage.local", "content_script", "dispatchEvent"], + "path": [ + "storage.local", + "content_script", + "dispatchEvent" + ], "sink": "page_content_mutation" } ], @@ -60,4 +117,4 @@ "remote_navigation" ] } -} +} \ No newline at end of file diff --git a/embedding/base/session_reinjection_local_storage_overwrite.json b/embedding/base/session_reinjection_local_storage_overwrite.json index af362277..161a71e6 100644 --- a/embedding/base/session_reinjection_local_storage_overwrite.json +++ b/embedding/base/session_reinjection_local_storage_overwrite.json @@ -1,4 +1,6 @@ { + "scenario_id": "eljbpmbbooibhhmhaomdlbbdjolgomam", + "builtin": true, "pattern_name": "session_reinjection_local_storage_overwrite", "doc_ref": "scenario_docs/session_reinjection_local_storage_overwrite.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "permissions_hint": ["storage", "tabs"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "permissions_hint": [ + "storage", + "tabs" + ] }, "capability_profile": [ "storage_access", @@ -20,16 +28,36 @@ "localStorage_mutation + navigation_control" ], "static_code_signals": { - "messaging": {"apis": ["runtime.onMessage"]}, - "storage": {"apis": ["localStorage.clear", "localStorage.setItem"]}, - "navigation": {"apis": ["window.location"]}, - "cookie": {"apis": ["clearAllCookies"]} + "messaging": { + "apis": [ + "runtime.onMessage" + ] + }, + "storage": { + "apis": [ + "localStorage.clear", + "localStorage.setItem" + ] + }, + "navigation": { + "apis": [ + "window.location" + ] + }, + "cookie": { + "apis": [ + "clearAllCookies" + ] + } }, "predicted_flows": [ { "trigger": "inbound_message", "source": "background_command", - "path": ["content_script", "local_storage_overwrite"], + "path": [ + "content_script", + "local_storage_overwrite" + ], "sink": "mock_reload" } ], @@ -39,4 +67,4 @@ "remote_navigation" ] } -} +} \ No newline at end of file diff --git a/embedding/base/session_storage_exfiltration_document_start.json b/embedding/base/session_storage_exfiltration_document_start.json index f4c3d1ca..48f94075 100644 --- a/embedding/base/session_storage_exfiltration_document_start.json +++ b/embedding/base/session_storage_exfiltration_document_start.json @@ -1,4 +1,6 @@ { + "scenario_id": "meoilhadanfaddhibdnpflaeeccpghgl", + "builtin": true, "pattern_name": "session_storage_exfiltration_document_start", "doc_ref": "scenario_docs/session_storage_exfiltration_document_start.md", "vector_fingerprint": { @@ -6,9 +8,17 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "content_script_run_at": ["document_start"], - "permissions_hint": ["storage", "scripting"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "content_script_run_at": [ + "document_start" + ], + "permissions_hint": [ + "storage", + "scripting" + ] }, "capability_profile": [ "early_document_injection", @@ -24,18 +34,54 @@ "periodic_execution + repeated_transmission" ], "static_code_signals": { - "storage": {"apis": ["localStorage", "localforage.getItem", "JSON.stringify"]}, - "cookie": {"apis": ["chrome.cookies.getAll", "chrome.cookies.get", "chrome.cookies.onChanged"]}, - "network_intercept": {"apis": ["chrome.webRequest.onBeforeRequest.addListener"]}, - "messaging": {"apis": ["chrome.runtime.sendMessage", "runtime.onMessage"]}, - "timer": {"apis": ["setInterval"]}, - "network": {"apis": ["fetch"], "methods": ["POST"]} + "storage": { + "apis": [ + "localStorage", + "localforage.getItem", + "JSON.stringify" + ] + }, + "cookie": { + "apis": [ + "chrome.cookies.getAll", + "chrome.cookies.get", + "chrome.cookies.onChanged" + ] + }, + "network_intercept": { + "apis": [ + "chrome.webRequest.onBeforeRequest.addListener" + ] + }, + "messaging": { + "apis": [ + "chrome.runtime.sendMessage", + "runtime.onMessage" + ] + }, + "timer": { + "apis": [ + "setInterval" + ] + }, + "network": { + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ] + } }, "predicted_flows": [ { "trigger": "document_start", "source": "dummy_storage_cookie_data", - "path": ["content_script", "runtime_message", "background"], + "path": [ + "content_script", + "runtime_message", + "background" + ], "sink": "localhost_post" } ], @@ -47,4 +93,4 @@ "external_communication" ] } -} +} \ No newline at end of file diff --git a/embedding/base/session_storage_exfiltration_reference.json b/embedding/base/session_storage_exfiltration_reference.json index 12cd19f5..f7b51f1e 100644 --- a/embedding/base/session_storage_exfiltration_reference.json +++ b/embedding/base/session_storage_exfiltration_reference.json @@ -1,4 +1,6 @@ { + "scenario_id": "diaomlklmchphfolkkngjdjkbempnnkg", + "builtin": true, "pattern_name": "session_storage_exfiltration_reference", "doc_ref": "scenario_docs/session_storage_exfiltration_reference.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background", "content_script"], - "content_script_run_at": ["document_start"] + "entrypoint_roles": [ + "background", + "content_script" + ], + "content_script_run_at": [ + "document_start" + ] }, "capability_profile": [ "background_execution", @@ -28,36 +35,70 @@ ], "static_code_signals": { "storage": { - "apis": ["localStorage"], - "keywords": ["auth", "session", "user_id"] + "apis": [ + "localStorage" + ], + "keywords": [ + "auth", + "session", + "user_id" + ] }, "messaging": { - "apis": ["runtime.onMessage", "runtime.sendMessage"], - "patterns": ["content_script_to_background"], - "message_actions": ["save_session"] + "apis": [ + "runtime.onMessage", + "runtime.sendMessage" + ], + "patterns": [ + "content_script_to_background" + ], + "message_actions": [ + "save_session" + ] }, "network": { - "apis": ["fetch"], + "apis": [ + "fetch" + ], "external_origin_present": true, - "methods": ["POST"], - "endpoint_keywords": ["session"] + "methods": [ + "POST" + ], + "endpoint_keywords": [ + "session" + ] }, "cookie": { - "apis": ["chrome.cookies.getAll", "chrome.cookies.get", "chrome.cookies.onChanged"] + "apis": [ + "chrome.cookies.getAll", + "chrome.cookies.get", + "chrome.cookies.onChanged" + ] }, "network_intercept": { - "apis": ["chrome.webRequest.onBeforeRequest.addListener"] + "apis": [ + "chrome.webRequest.onBeforeRequest.addListener" + ] }, "delayed_execution": { - "apis": ["setInterval"], - "patterns": ["periodic_session_collection", "repeated_transmission"] + "apis": [ + "setInterval" + ], + "patterns": [ + "periodic_session_collection", + "repeated_transmission" + ] } }, "predicted_flows": [ { "trigger": "document_start", "source": "page_local_storage", - "path": ["content_script", "runtime_message", "background"], + "path": [ + "content_script", + "runtime_message", + "background" + ], "sink": "external_network" } ], @@ -70,4 +111,4 @@ "session_theft_pattern" ] } -} +} \ No newline at end of file diff --git a/embedding/base/startup_c2_backdoor_tabs_create.json b/embedding/base/startup_c2_backdoor_tabs_create.json index 381178a6..209c5398 100644 --- a/embedding/base/startup_c2_backdoor_tabs_create.json +++ b/embedding/base/startup_c2_backdoor_tabs_create.json @@ -1,4 +1,6 @@ { + "scenario_id": "ddplcepolkjmkminkjkdnjaiekoachlk", + "builtin": true, "pattern_name": "startup_c2_backdoor_tabs_create", "doc_ref": "scenario_docs/startup_c2_backdoor_tabs_create.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["tabs", "alarms"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "tabs", + "alarms" + ] }, "capability_profile": [ "startup_execution", @@ -20,15 +27,35 @@ "remote_command + tabs_create" ], "static_code_signals": { - "startup": {"apis": ["chrome.runtime.id", "runtime.onStartup", "runtime.onInstalled"]}, - "tabs": {"apis": ["chrome.tabs.create"]}, - "network": {"apis": ["fetch"], "methods": ["POST"]} + "startup": { + "apis": [ + "chrome.runtime.id", + "runtime.onStartup", + "runtime.onInstalled" + ] + }, + "tabs": { + "apis": [ + "chrome.tabs.create" + ] + }, + "network": { + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ] + } }, "predicted_flows": [ { "trigger": "browser_startup", "source": "runtime_context", - "path": ["background", "mock_config_fetch"], + "path": [ + "background", + "mock_config_fetch" + ], "sink": "mock_tab_create" } ], @@ -38,4 +65,4 @@ "tab_open_from_remote_response" ] } -} +} \ No newline at end of file diff --git a/embedding/base/tabs_capture_visible_tab_exfiltration.json b/embedding/base/tabs_capture_visible_tab_exfiltration.json index 95c13028..bd6070f1 100644 --- a/embedding/base/tabs_capture_visible_tab_exfiltration.json +++ b/embedding/base/tabs_capture_visible_tab_exfiltration.json @@ -1,4 +1,6 @@ { + "scenario_id": "bglejiggobbnabakldjlagkbiipfnclj", + "builtin": true, "pattern_name": "tabs_capture_visible_tab_exfiltration", "doc_ref": "scenario_docs/tabs_capture_visible_tab_exfiltration.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["tabs", "activeTab"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "tabs", + "activeTab" + ] }, "capability_profile": [ "tab_access", @@ -20,24 +27,42 @@ ], "static_code_signals": { "capture": { - "apis": ["chrome.tabs.captureVisibleTab"], - "patterns": ["tab_event_driven_capture"] + "apis": [ + "chrome.tabs.captureVisibleTab" + ], + "patterns": [ + "tab_event_driven_capture" + ] }, "timer": { - "apis": ["setTimeout"], - "patterns": ["delayed_capture_loop"] + "apis": [ + "setTimeout" + ], + "patterns": [ + "delayed_capture_loop" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "endpoint_keywords": ["capture", "image"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "endpoint_keywords": [ + "capture", + "image" + ] } }, "predicted_flows": [ { "trigger": "tab_event", "source": "visible_tab_bitmap", - "path": ["captureVisibleTab", "background"], + "path": [ + "captureVisibleTab", + "background" + ], "sink": "localhost_post" } ], @@ -46,4 +71,4 @@ "data_exfiltration" ] } -} +} \ No newline at end of file diff --git a/embedding/base/translation_proxy_user_text_exfiltration.json b/embedding/base/translation_proxy_user_text_exfiltration.json index e65a9387..8a32e942 100644 --- a/embedding/base/translation_proxy_user_text_exfiltration.json +++ b/embedding/base/translation_proxy_user_text_exfiltration.json @@ -1,4 +1,6 @@ { + "scenario_id": "eialpgiicfbbanpkmgnfikccipaakhdi", + "builtin": true, "pattern_name": "translation_proxy_user_text_exfiltration", "doc_ref": "scenario_docs/translation_proxy_user_text_exfiltration.md", "vector_fingerprint": { @@ -6,8 +8,15 @@ "manifest_version": 3, "host_access": "limited", "background_type": "service_worker", - "entrypoint_roles": ["content_script", "background"], - "permissions_hint": ["proxy", "webRequest", "storage"] + "entrypoint_roles": [ + "content_script", + "background" + ], + "permissions_hint": [ + "proxy", + "webRequest", + "storage" + ] }, "capability_profile": [ "user_input_access", @@ -19,15 +28,36 @@ "webRequest_observe + fetch_post" ], "static_code_signals": { - "network": {"apis": ["fetch"], "methods": ["POST"]}, - "request": {"apis": ["chrome.webRequest.onCompleted"]}, - "proxy": {"apis": ["chrome.proxy.settings.set"], "patterns": ["pac_script_download"]} + "network": { + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ] + }, + "request": { + "apis": [ + "chrome.webRequest.onCompleted" + ] + }, + "proxy": { + "apis": [ + "chrome.proxy.settings.set" + ], + "patterns": [ + "pac_script_download" + ] + } }, "predicted_flows": [ { "trigger": "translation_submit", "source": "dummy_user_text", - "path": ["content_script", "background_proxy"], + "path": [ + "content_script", + "background_proxy" + ], "sink": "localhost_post" } ], @@ -38,4 +68,4 @@ "external_communication" ] } -} +} \ No newline at end of file diff --git a/embedding/base/webmail_dom_content_tampering.json b/embedding/base/webmail_dom_content_tampering.json index e25753f3..9149fd8b 100644 --- a/embedding/base/webmail_dom_content_tampering.json +++ b/embedding/base/webmail_dom_content_tampering.json @@ -1,4 +1,6 @@ { + "scenario_id": "lnkdhkldnojafdcoickoggcckelpjile", + "builtin": true, "pattern_name": "webmail_dom_content_tampering", "doc_ref": "scenario_docs/webmail_dom_content_tampering.md", "vector_fingerprint": { @@ -6,8 +8,13 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["content_script"], - "permissions_hint": ["activeTab", "scripting"] + "entrypoint_roles": [ + "content_script" + ], + "permissions_hint": [ + "activeTab", + "scripting" + ] }, "capability_profile": [ "dom_mutation", @@ -20,23 +27,39 @@ ], "static_code_signals": { "dom_query": { - "apis": ["$(document).find(':contains()')", "$('div:contains()')"], - "patterns": ["targeted_text_query"] + "apis": [ + "$(document).find(':contains()')", + "$('div:contains()')" + ], + "patterns": [ + "targeted_text_query" + ] }, "dom_write": { - "apis": ["$(item).html"], - "patterns": ["content_replace_loop"] + "apis": [ + "$(item).html" + ], + "patterns": [ + "content_replace_loop" + ] }, "timer": { - "apis": ["setInterval"], - "patterns": ["repeated_dom_tampering"] + "apis": [ + "setInterval" + ], + "patterns": [ + "repeated_dom_tampering" + ] } }, "predicted_flows": [ { "trigger": "interval_tick", "source": "matched_webmail_dom_nodes", - "path": ["content_script", "jquery_html_replace"], + "path": [ + "content_script", + "jquery_html_replace" + ], "sink": "page_content_mutation" } ], @@ -46,4 +69,4 @@ "dom_injection" ] } -} +} \ No newline at end of file diff --git a/embedding/base/webmail_dom_surveillance_collection.json b/embedding/base/webmail_dom_surveillance_collection.json index d7c46ae8..2acb7503 100644 --- a/embedding/base/webmail_dom_surveillance_collection.json +++ b/embedding/base/webmail_dom_surveillance_collection.json @@ -1,4 +1,6 @@ { + "scenario_id": "fkhfjamniojodebmffljiipelclboiko", + "builtin": true, "pattern_name": "webmail_dom_surveillance_collection", "doc_ref": "scenario_docs/webmail_dom_surveillance_collection.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "targeted", "background_type": "service_worker", - "entrypoint_roles": ["content_script", "background"], - "permissions_hint": ["storage", "activeTab"] + "entrypoint_roles": [ + "content_script", + "background" + ], + "permissions_hint": [ + "storage", + "activeTab" + ] }, "capability_profile": [ "dom_access", @@ -20,24 +28,50 @@ ], "static_code_signals": { "dom": { - "apis": ["MutationObserver"], - "patterns": ["webmail_dom_polling"] + "apis": [ + "MutationObserver" + ], + "patterns": [ + "webmail_dom_polling" + ] }, "serialization": { - "apis": ["JSON.stringify"], - "keywords": ["email", "thread", "subject", "emailSubject", "senderAddress", "recipientList", "emailBodyText", "gmailThreadId"] + "apis": [ + "JSON.stringify" + ], + "keywords": [ + "email", + "thread", + "subject", + "emailSubject", + "senderAddress", + "recipientList", + "emailBodyText", + "gmailThreadId" + ] }, "network": { - "apis": ["fetch"], - "methods": ["POST"], - "endpoint_keywords": ["mail", "collect", "/collect"] + "apis": [ + "fetch" + ], + "methods": [ + "POST" + ], + "endpoint_keywords": [ + "mail", + "collect", + "/collect" + ] } }, "predicted_flows": [ { "trigger": "dom_change", "source": "webmail_content", - "path": ["content_script", "observer"], + "path": [ + "content_script", + "observer" + ], "sink": "localhost_post" } ], @@ -47,4 +81,4 @@ "data_exfiltration" ] } -} +} \ No newline at end of file diff --git a/embedding/base/websocket_c2_remote_control.json b/embedding/base/websocket_c2_remote_control.json index 4e39326c..a0e8e291 100644 --- a/embedding/base/websocket_c2_remote_control.json +++ b/embedding/base/websocket_c2_remote_control.json @@ -1,4 +1,6 @@ { + "scenario_id": "akbpdhcilicjoadogkojbgokbfbgeikm", + "builtin": true, "pattern_name": "websocket_c2_remote_control", "doc_ref": "scenario_docs/websocket_c2_remote_control.md", "vector_fingerprint": { @@ -6,8 +8,14 @@ "manifest_version": 3, "host_access": "broad", "background_type": "service_worker", - "entrypoint_roles": ["background"], - "permissions_hint": ["tabs", "storage", "declarativeNetRequest"] + "entrypoint_roles": [ + "background" + ], + "permissions_hint": [ + "tabs", + "storage", + "declarativeNetRequest" + ] }, "capability_profile": [ "websocket_connection", @@ -21,23 +29,44 @@ ], "static_code_signals": { "websocket": { - "apis": ["WebSocket", "socket.onmessage", "socket.send"], - "keywords": ["readyState", "arrayBuffer"] + "apis": [ + "WebSocket", + "socket.onmessage", + "socket.send" + ], + "keywords": [ + "readyState", + "arrayBuffer" + ] }, "network": { - "apis": ["fetch"], - "keywords": ["response.headers.entries", "response.status", "Promise.all"] + "apis": [ + "fetch" + ], + "keywords": [ + "response.headers.entries", + "response.status", + "Promise.all" + ] }, "parsing": { - "apis": ["JSON.parse"], - "keywords": ["event.data"] + "apis": [ + "JSON.parse" + ], + "keywords": [ + "event.data" + ] } }, "predicted_flows": [ { "trigger": "session_id_received", "source": "c2_server", - "path": ["websocket_connect", "fetch_relay", "response_collect"], + "path": [ + "websocket_connect", + "fetch_relay", + "response_collect" + ], "sink": "socket_send" } ], @@ -48,4 +77,4 @@ "remote_command_execution" ] } -} +} \ No newline at end of file diff --git a/embedding/embedding.json b/embedding/embedding.json index 1630249e..49b9a83f 100644 --- a/embedding/embedding.json +++ b/embedding/embedding.json @@ -1,1026 +1,1026 @@ [ - -0.035540424, - -0.0043125497, - -0.01500155, - -0.0039612064, - -0.034220085, - -0.014673776, - 0.022932058, - 0.043721996, - 0.003023589, - -6.411021e-05, - -0.023201818, - -0.0006830563, - -0.018230671, - -0.006285979, - 0.0009594604, - -0.011561239, - 0.014386106, - 0.007685114, - 0.002560639, - -0.008862037, - -0.015705701, - 0.00026157932, - 0.0091719115, - 0.020362707, - -0.039432317, - 0.027982226, - -0.019040931, - -0.0579503, - -0.029375508, - 0.03395607, - -0.017147735, - -0.012944642, - 0.014744964, - 0.009999208, - -0.03147265, - -0.0045112236, - -0.019853005, - -0.016967569, - -0.082720324, - -0.0037163256, - -0.025519546, - 0.009049471, - 0.0071469173, - -0.033614393, - 0.009219351, - -0.03533692, - -0.011300448, - -0.026129387, - -0.0217745, - -0.061660204, - -0.018289024, - -0.013864334, - -0.0027544769, - -0.015693415, - 0.04889935, - 0.03469741, - -0.030484525, - 0.0013913357, - -0.059629466, - 0.020596897, - -0.047446992, - -0.00998671, - -0.020718874, - 0.010504385, - 0.0034249753, - 0.030279705, - 0.016118893, - -0.00080817606, - -0.0034266284, - -0.03447596, - -0.014561402, - 0.013687459, - -0.029745989, - 0.001666492, - -0.058539372, - 0.052298434, - 0.014443302, - -0.03539248, - -0.011575928, - 0.02588514, - -0.023969132, - -0.01051046, - 0.0336828, - -0.005281555, - -0.0036213396, - 0.042740744, - -0.011760336, - 0.039187573, - 0.052444637, - 0.006970902, - -0.011505029, - -0.033932637, - 0.07297291, - -0.03752474, - -0.035911724, - 0.0055007595, - 0.0018801576, - -0.012344642, - 0.031608358, - 0.0019746614, - -0.015085678, - 0.00872032, - 0.008152795, - -0.0045497543, - 0.033418335, - 0.04651675, - 0.017604962, - 0.0033722841, - 0.005495094, - -0.0070620053, - -0.014465226, - 0.02688613, - 0.04316405, - 0.017829837, - -0.0095854215, - -0.048734505, - 0.010000191, - -0.023314316, - -0.019528374, - -0.006886649, - 0.03187103, - 0.0608218, - 0.037757162, - -0.03302051, - 0.03996502, - 0.015882034, - 0.033170387, - 0.03169574, - -0.012785765, - 0.0316073, - 0.009463434, - 0.032444615, - -0.0052398057, - -0.010948876, - -0.08481821, - -0.012677158, - 0.006891006, - 0.06301468, - 0.040772405, - -0.02859976, - 0.03152613, - 0.017300107, - -0.033778034, - -0.022050386, - 0.03158338, - -0.08632693, - 0.030773796, - 0.038783383, - -0.016291793, - -0.05024555, - 0.037132595, - 0.009242082, - 0.041624844, - 0.041804973, - -0.038715784, - -0.061805855, - 0.004833871, - -0.0032721742, - 0.06482766, - -0.007136096, - -0.014284595, - 0.0050829803, - -0.027384441, - 0.037771273, - 0.03524182, - -0.012263654, - 0.0031836503, - -0.026626673, - -0.050049827, - 0.00623903, - 0.023616785, - -0.047233075, - -0.001443006, - 0.025695024, - 0.0055104177, - -0.00042990252, - 0.07034322, - 0.027812658, - -0.002557722, - -0.033141855, - -0.046404485, - -0.004359686, - -0.011891668, - -0.015275272, - -0.015015588, - 0.022325234, - -0.02437152, - 0.01250391, - -0.025172856, - 0.0352632, - 0.0076452703, - -0.004160174, - 0.028269736, - 0.016204543, - -0.039722662, - -0.031363092, - 0.040678833, - -0.0028519824, - 0.02270374, - -0.023759235, - 0.0054619815, - 0.043257996, - 0.036729176, - -0.0005154979, - -0.03816618, - -0.0277644, - -0.002231237, - -0.022062553, - -0.008970236, - -0.011127811, - 0.017840413, - 0.014614948, - 0.005539553, - -0.018068725, - -0.033656325, - -0.011433405, - 0.0024294283, - -0.008508651, - 0.005496637, - -0.025733627, - 0.0037519112, - 0.0053659026, - 0.011044733, - 0.005352398, - 0.010653699, - -0.0047489684, - 0.028495595, - 0.01162837, - -0.049981326, - 0.022937832, - -0.016780095, - 0.034425065, - 0.020969976, - -0.0061849304, - 0.030523786, - -0.05032338, - 0.007898791, - 0.020700103, - 0.03975607, - -0.020061469, - 0.05628226, - -0.067241795, - 0.04109376, - -0.011501287, - -0.03970386, - -0.011927178, - 0.010235679, - 0.04292088, - -0.050034344, - -0.018472817, - -0.018886443, - 0.007804967, - -0.04097342, - -0.012324401, - 0.013782283, - 0.009639795, - 0.0040474017, - 0.024750462, - 0.00050500676, - 0.023131112, - -0.0043665594, - 0.020119144, - 0.013851291, - 0.027416615, - 0.035738133, - -0.009420496, - -0.023711251, - -0.033187956, - 0.0067144274, - 0.0015973891, - 0.0060812645, - -0.029172974, - 0.031199431, - -0.032828603, - -0.005249675, - 0.024949718, - -0.008640782, - 0.017278261, - 0.07636377, - 0.041372664, - -0.006425257, - 0.024150407, - 0.036597442, - 0.011449838, - 0.04448599, - 0.017793471, - -0.03430268, - -0.004826711, - -0.0058154953, - -0.030509433, - -0.028473528, - 0.026003193, - 0.055330906, - -0.04789963, - 0.024928136, - 0.03194985, - -0.02493602, - -0.17091215, - 0.020887524, - 0.010800067, - 0.021790186, - 0.010625859, - -0.0074593336, - -0.02130046, - -0.031277344, - -0.038347844, - 0.049448665, - -0.052322306, - -0.054100957, - -0.028071137, - -0.02382311, - 0.041731197, - 0.02741918, - -0.014175494, - 0.0056713466, - -0.029490303, - -0.012858688, - -0.038349167, - 0.02836895, - 0.022073276, - 0.006702537, - -0.018492635, - 0.011318007, - 0.026493872, - -0.019104743, - -0.0063021244, - 0.03877698, - -0.007421214, - -0.009439214, - 0.0014386963, - 0.019966314, - -0.0110261105, - 0.0033504947, - -0.008596098, - -0.012756703, - 0.00669487, - -0.028156321, - 0.007856934, - 0.07940014, - -0.011965161, - 0.031730916, - 0.025921395, - -0.027395304, - -0.0062956195, - -0.03806656, - -0.055978604, - -0.046453428, - -0.031692877, - -0.0115980655, - -0.009553197, - 0.02696136, - -0.07207385, - 0.010008941, - 0.009161723, - 0.0367366, - 0.04008746, - 0.011571431, - 0.002059561, - -0.00578889, - 0.02206174, - -0.05897136, - -0.00039718143, - -0.01478718, - 0.05825217, - -0.0069621434, - 0.010907628, - -0.032825023, - 0.029956196, - -0.03709911, - 0.03661216, - 0.022396093, - 0.005803921, - 0.025568428, - -0.029039348, - -0.025916398, - 0.003658393, - -0.10671754, - 0.012312412, - 0.015170817, - 0.026491951, - -0.0034667796, - -0.037462182, - -0.058557436, - 0.009534287, - -0.029417442, - 0.030745089, - 0.26336142, - -0.006270348, - -0.013675315, - 0.05166998, - 0.023462333, - -0.029233214, - -0.011385997, - 0.07055414, - -0.0096172765, - -0.02137509, - 0.023463685, - 0.044137347, - 0.031541117, - 0.008113454, - 0.028550882, - 0.021089844, - -0.046045523, - 0.009343249, - 0.055118855, - 0.00059009093, - 0.010504315, - -0.01588994, - 0.024900999, - -0.017277494, - -0.039863598, - -0.031794623, - -0.010783353, - -0.014681642, - 0.0018184608, - 0.06819786, - -0.021864409, - 0.034250077, - 0.02721689, - -0.021482835, - -0.06197356, - 0.019354058, - 0.052295797, - 0.009106822, - -0.034628466, - 0.01446979, - -0.03188524, - -0.011352402, - -0.026079426, - 0.0012850903, - -0.026897343, - 0.0055958885, - -0.03781363, - -0.023671817, - -0.05045699, - 0.012651729, - 0.017164286, - -0.0129017765, - 0.01511296, - -0.04046131, - 0.017772228, - -0.019173093, - -0.000704597, - -0.0057172966, - 0.009027126, - 0.027601425, - 0.007673995, - 0.0135371275, - -0.037670046, - 0.0153490305, - -0.028624374, - -0.008729324, - 0.020493362, - -0.0038286129, - 0.04061988, - 0.037060518, - 0.017289218, - 0.032855906, - 0.003413343, - 0.018052958, - 0.011419034, - 0.0042261574, - 0.059293475, - 0.03086562, - -0.038831692, - 0.0022679062, - -0.02062474, - -0.04939548, - -0.018029746, - -0.005109428, - -0.0076940744, - 0.009497699, - -0.023193847, - 0.062326573, - 0.009280389, - 0.034507535, - -0.0065380167, - 0.010557469, - -0.015685864, - 0.08523495, - -0.013950076, - 0.029688701, - 0.028984303, - -0.03033703, - -0.038351182, - -0.023411741, - -0.03358136, - -0.03808846, - -0.024971444, - 0.010980564, - 0.018003657, - 0.02680926, - -0.012699566, - 0.03312877, - -0.030300917, - 0.014444101, - -0.0440556, - 0.01345662, - 0.02811193, - -0.015999917, - -0.015307806, - 0.08160995, - 0.031998634, - -0.0005930801, - 0.06616691, - 0.018216204, - -0.04075321, - 0.033301502, - 0.002330849, - 0.057430778, - -0.024376707, - -0.055560768, - -0.023526592, - 0.03975858, - -0.015612394, - 0.043909956, - 0.02632352, - -0.026144067, - 0.0140032545, - 0.040780038, - 0.052309003, - 0.001090255, - 0.044166446, - -0.00060999923, - 0.005574291, - 0.036202528, - -0.015676463, - 0.0021018896, - -0.013796276, - 0.048270643, - 0.002394779, - 0.035297364, - -0.04311444, - -0.0015244705, - 0.016313026, - 0.03755499, - 0.017434109, - 0.07903873, - 0.047565084, - -0.0053588343, - -0.016122881, - -0.044135395, - -0.041864943, - 0.0017292724, - 0.025358679, - 0.011261144, - -0.0037508695, - -0.0063735545, - 0.015460245, - 0.028086416, - -0.023101276, - 0.0040004905, - 0.028008131, - 0.03499609, - -0.014988292, - 0.0055555506, - -0.016675757, - -0.053690527, - -0.034661565, - 0.037158605, - -0.024301022, - 0.04268904, - -0.040901557, - -0.04794083, - -0.025262427, - -0.020267302, - 0.018436572, - -0.011063047, - -0.007838248, - -0.021223838, - 0.017515123, - -0.021018023, - 0.0381946, - 0.008762564, - 0.008467957, - -0.027179888, - -0.02167856, - 0.12485428, - 0.028081162, - -0.01125163, - 0.03168154, - -0.010894951, - 0.079535276, - -0.021919629, - 0.010740841, - 0.0042296164, - 0.0056250114, - -0.008975374, - 0.003813022, - -0.011469158, - -0.018717444, - 0.002668455, - 0.009517659, - -0.006203588, - -0.032016136, - -0.020201974, - 0.028106695, - 0.028637234, - -0.02985525, - 0.03072794, - 0.01802249, - -0.044347633, - 0.036461044, - 0.058161937, - 0.02396372, - -0.035366416, - 0.02383857, - -0.012300006, - -0.023082707, - -0.021671489, - -0.020038316, - 0.0054275077, - 0.02136522, - -0.041313924, - -0.008360628, - -0.020315383, - -0.013007147, - -0.044424202, - 0.03470291, - -0.047108315, - -0.007244148, - -0.038348764, - 0.0026577192, - 0.020647103, - 0.015472981, - -0.021628307, - 0.04248728, - -0.019476421, - 0.020273324, - 0.047409028, - 0.024564689, - 0.025159044, - -0.07095747, - 0.0010422067, - 0.004710526, - 0.01561932, - -0.040175084, - -0.0041703386, - -0.010208369, - -0.06588367, - 0.0044695903, - 0.0145629505, - -0.0031650946, - -0.0076785143, - -0.061453726, - -0.033938143, - -0.03429412, - 0.056270715, - -0.0021333904, - -0.008727723, - -0.026811391, - -0.04140576, - 0.010979562, - -0.04479837, - -0.013969982, - -0.03787035, - -0.011467582, - 0.006865206, - 0.005961738, - 0.003261076, - 0.015390911, - 0.011385705, - -0.016311577, - -0.013051688, - 0.040660527, - -0.015573549, - -0.0737897, - -0.012749576, - 0.022413855, - 0.0021245198, - -0.009327382, - 9.7007105e-05, - 0.037278116, - -0.028731985, - -0.012166975, - -0.039664686, - 0.046987552, - 0.021548439, - -0.02877028, - 0.012877035, - -0.018463923, - 0.0039465986, - -0.012279091, - 0.067423075, - -0.0038708956, - -0.010557657, - 0.013671262, - -0.0025658733, - -0.01675385, - -0.00472873, - -0.04872376, - 0.025389161, - -0.03578233, - -0.039283987, - 0.037435297, - 0.019199183, - -0.024830999, - -0.02649742, - -0.023753455, - 0.023797851, - 0.04415423, - -0.0384997, - 0.023880698, - -0.052072763, - 0.031664502, - 0.030935949, - 0.017395388, - 0.018645382, - -0.014422513, - -0.0073672016, - -0.07344133, - 0.049215563, - -0.020804355, - -0.01877317, - -0.03781439, - -0.0016161609, - -0.035837907, - -0.010174443, - 0.0010238435, - -0.028608019, - 0.016583605, - 0.0126875155, - 0.03830263, - 0.00030887304, - 0.025015088, - 0.002044907, - 0.015047575, - -0.030303938, - 0.035282847, - -0.01299968, - -0.011408893, - 0.00915301, - 0.012805768, - -0.031176593, - 0.012043452, - -0.016835786, - 0.04098914, - 0.0052500665, - -0.022866137, - -0.031467788, - -0.010642347, - -0.030589694, - -0.018889263, - 0.0014628854, - 0.013622995, - 0.034228757, - -0.0006223219, - 0.038695943, - -0.016322842, - -0.034300745, - -1.6720902e-05, - -0.0239627, - -0.0009887859, - -0.0011182632, - 0.015420228, - 0.005127973, - -0.014761954, - 0.011237161, - -0.0051204776, - 0.00057824113, - -0.03830941, - 0.027179234, - -0.038137287, - -0.01832438, - 0.03806791, - -0.013126439, - -0.03950949, - -0.067992955, - -0.0130304, - 0.015828092, - -0.008844865, - -0.026819685, - -0.04564095, - 0.0030537127, - -0.006788286, - 0.0019503232, - -0.027307421, - 0.010493203, - -0.021539237, - 0.0490111, - -0.15990233, - 0.0058901664, - -0.005970224, - 0.053682275, - -0.025622882, - 0.008835088, - -0.0066961576, - 0.003967323, - 0.015457101, - -0.008711219, - 0.012753193, - -0.012935689, - -0.002539372, - -0.02026739, - -0.023719812, - 0.032911967, - -0.020585224, - 0.012818082, - -0.027591335, - 0.022709759, - -0.010934821, - -0.015531736, - 0.042712983, - -0.028273309, - 0.014499474, - 0.03412267, - -0.011089235, - 0.0028958756, - -0.008988179, - -0.009810768, - 0.031685375, - -0.015877446, - 0.02308227, - 0.022767428, - 0.021194082, - 0.04064294, - 0.019226698, - 0.017006392, - 0.035582703, - -0.0005129924, - -0.017660828, - -0.007734722, - -0.016305344, - -0.04025412, - -0.027390027, - 0.020124434, - -0.0005577389, - -0.0069233165, - -0.022851378, - 0.004152408, - -0.0147089735, - 0.021705763, - -0.074575365, - 0.019896494, - -0.0294909, - -0.0041059703, - -0.011890366, - 0.0053876336, - -0.032761063, - 0.022857182, - -0.03479724, - 0.022967612, - -0.019039867, - -0.004850073, - -0.02771543, - 0.028746694, - -0.0991846, - 0.0062310984, - 0.0004254631, - 0.011785716, - -0.05328627, - -0.02342981, - -0.03081385, - -0.0007593912, - 0.019680915, - 0.02081081, - 0.032079346, - -0.0014297471, - -0.03685705, - 0.0049695387, - 0.004202038, - -0.014070803, - -0.028371837, - 0.0452603, - 0.04361516, - -0.028785517, - -0.0016145506, - 0.006965871, - -0.040331863, - -0.03629871, - -0.03236876, - -0.049682707, - 0.015567453, - 0.036067814, - -0.017383588, - -0.0035371073, - -0.031706583, - 0.0064178607, - -0.011076643, - -0.007326536, - 0.02187429, - -0.015588352, - 0.02986512, - 0.0061094007, - -0.047057472, - 0.016244119, - 0.004937072, - -0.0060932045, - 0.015511481, - 0.007624867, - -0.0763661, - 0.0069588413, - -0.031857908, - 0.0015331802, - -0.058158915, - -0.006869035, - 0.037262958, - 0.0142894, - -0.01665105, - 0.03370669, - -0.024552466, - -0.010439891, - -0.03060368, - -0.026939226, - 0.03487912, - 0.039857253, - 0.023799974, - 0.032781877, - 0.028897995, - -0.03859275, - 0.0022505575, - -0.05603823, - 0.0010934499, - -0.0034986006, - 0.034185946, - 0.004990718, - -0.006264329, - 0.056614976, - -0.051314127, - -0.045782022, - -0.06054395, - -0.0026050524, - -0.002957487, - -0.057461318, - 0.018096708, - 0.000456347, - 0.014047018, - 0.0014871478, - 0.021589909, - -0.05283185, - -0.014597874, - 0.01369817, - -0.022258064, - 0.033732086, - 0.028172681, - 0.036525548, - -0.039641295, - 0.034462705, - -0.031230953, - 0.027919088, - 0.00058517413, - -0.011178362, - -0.027165003, - -0.042164024, - -0.00032456897, - 0.039929766, - -0.020390583, - 0.0063355905, - -0.04207823, - 0.016216937, - 0.036330543, - 0.046695136, - -0.013480326, - -0.01474487, - 0.05343723, - -0.009425867, - 0.024334114, - 0.008031328, - 0.03309201, - -0.010859557, - 0.03691487, - -0.021423036, - 0.011549686, - 0.021159112, - 0.02191671, - 0.029385071, - 0.0024781232, - 0.039675735, - 0.0396928, - 0.0006441838, - 0.0037860468, - -0.02468667, - 0.01988445, - -0.022660216, - 0.020144204, - 0.0018080708, - 0.008796312, - -0.031180993, - -0.0059071425, - 0.023305861, - -0.02361769, - 0.039409596, - -0.00033998038, - -0.017604206, - 0.0322121, - -0.02223584, - -0.031138483, - -0.033393633, - -0.028060216, - 0.008083868, - 0.035342738, - 0.0017326573, - -0.016791344, - 0.008498569, - -0.04010235, - -0.03804599, - 0.03137104, - -0.019063536, - 0.0074216053, - 0.001413857, - 0.038066283, - 0.015902381, - 0.03561189, - -0.048270743, - -0.060788784, - -0.031062746, - -0.007006566, - -0.00577212, - -0.0068467436, - -0.0016824654, - -0.062091805, - -0.03630424, - 0.003516641, - 0.0058498653, - 0.039400592, - 0.008428062, - -0.027738387, - 0.02425185, - -0.011731411, - -0.005528466, - 0.054143116, - 0.040314745, - 0.020573001, - -0.030335847 + -0.07560129, + 0.014236882, + -0.007440092, + 0.0024275763, + -0.029443186, + -0.005721509, + 0.019243246, + -0.007294964, + 0.0019634345, + 0.0018246851, + 0.016892005, + 0.013274709, + 0.003968804, + -0.031739168, + 0.0017124185, + 0.031172058, + 0.04963477, + -0.047057826, + 0.05247748, + -0.044427074, + -0.014691016, + -0.0132903755, + -0.024936842, + 0.038237046, + 0.0113076065, + -0.0010571283, + -0.0004957342, + -0.04652285, + -0.011828013, + 0.0066425283, + 0.031188175, + 0.010507427, + 0.022830993, + -0.022204539, + -0.033167973, + -0.035850998, + -0.026096227, + -0.005906839, + -0.07956235, + -0.006840062, + -0.044898514, + -0.006904792, + -0.000783384, + -0.070178576, + -0.0077245445, + -0.05322596, + -0.021753721, + -0.026063692, + -0.026408091, + -0.008636802, + -0.0045415843, + 0.015693516, + 0.007663884, + -0.015753016, + -0.0014883877, + 0.037399735, + -0.023919424, + -0.006746026, + -0.07304488, + 0.0065865316, + -0.015870227, + -0.0056871492, + -0.06299308, + -0.020678267, + -0.004853694, + 0.08063273, + 0.023744812, + 0.018706474, + -0.004020064, + -0.008394845, + -0.009968942, + 0.005284344, + -0.008535127, + -0.022001231, + -0.061291583, + 0.022312764, + 0.05734153, + 0.010326118, + 0.057070013, + 0.04811823, + -0.00947456, + -0.02863712, + 0.028067525, + -0.00054339424, + -0.019131951, + -0.0001113114, + -0.011452656, + -0.00653184, + 0.03442999, + -0.03743718, + -0.036319755, + -0.0014758765, + 0.0002036546, + -0.06814302, + -0.017779198, + 0.018828383, + -0.007170123, + 0.018318262, + 0.039566573, + 0.025442505, + -0.010928352, + -0.0331025, + -0.00306951, + -0.035813734, + 0.027435537, + 0.039976276, + 0.014914637, + -0.005765254, + -0.0027379096, + 3.7642465e-05, + 0.020387556, + 0.017430468, + 0.004577398, + 0.026791822, + 0.0065017263, + -0.06245511, + 0.012273262, + 0.017233968, + -0.014729283, + -0.0041075083, + 0.03801613, + -0.008783677, + 0.023131514, + -0.0358689, + 0.009882869, + -0.024578216, + 0.010493873, + 0.074082, + 0.049778428, + 0.04244209, + -0.00838043, + 0.0006379575, + 9.0738315e-05, + 0.00019830067, + -0.033334725, + -0.0034939186, + -0.029894847, + -0.0026967807, + 0.0424872, + -0.066646345, + 0.025782181, + 0.04662514, + 0.009603538, + 0.013646451, + -0.0062447316, + -0.07494642, + -0.005255938, + 0.043273345, + 0.010156778, + -0.016093064, + -0.0018813275, + -0.020194305, + 0.036419183, + 0.04078678, + 0.0216739, + -0.05226465, + -0.030308668, + -0.007748158, + 0.07005526, + 0.023088727, + -0.037164338, + 0.004760581, + -0.044332232, + 0.00024491388, + 0.043229975, + -0.04912251, + 0.010380492, + -0.0058749374, + -0.015385668, + -0.018356144, + 0.029526448, + -0.05684618, + -0.003370711, + -0.0013949698, + 0.021463891, + 0.016157499, + 0.08406333, + 0.02868903, + -0.02692579, + -0.064180925, + -0.026874935, + -0.017533831, + 0.012216839, + 0.03287669, + 0.003694263, + -0.004462113, + 0.0060564727, + -0.02082055, + -0.014241424, + 0.02426326, + -0.0031674758, + -0.025521915, + 0.068250224, + -0.028608756, + 0.00525376, + 0.007231948, + 0.029888222, + -0.0357275, + 0.013699147, + 0.012314013, + 0.005688414, + 0.011584962, + 0.061212815, + 0.02323606, + -0.04265303, + 0.009390028, + 0.007037014, + -0.05301007, + 0.0059219627, + 0.009075455, + -0.00088054733, + 0.019186351, + 0.030466087, + 0.0017418382, + -0.042393297, + 0.04967412, + -0.02163843, + -0.011724325, + -0.0017998947, + -0.018426206, + -0.018286776, + 0.043009337, + 0.0020465057, + -0.0023712837, + 0.031532392, + -0.005082307, + 0.030969348, + 0.022714242, + 0.007145235, + 0.00633519, + 0.03371155, + -0.016318846, + -0.002065793, + -0.00076500676, + 0.022602485, + -0.034449525, + -0.06665453, + 0.01005744, + 0.021006044, + -0.016178567, + 0.060256556, + -0.056134425, + 0.011915083, + -0.038052846, + -0.033488106, + 0.013718506, + 0.017667975, + 0.0141668, + -0.02118278, + -0.005712784, + -0.033877987, + 0.018272175, + -0.026013918, + -0.008895773, + 0.05353282, + 0.0076395837, + 0.028709441, + 0.021445135, + 0.0012456304, + 0.021778537, + 0.031737305, + 0.06861248, + 0.028362557, + 0.024905002, + -0.014256474, + -0.026488818, + -0.038807314, + -0.040386237, + 0.015434215, + -0.028678246, + -0.01580896, + 0.026530346, + 0.03909714, + -0.029657537, + 0.018182065, + 0.02074955, + -0.013964412, + -0.008238115, + 0.07037534, + 0.07244922, + -0.0028714233, + 0.0044172304, + 0.015780885, + 0.010851221, + 0.020029943, + -0.013475447, + -0.03752001, + -0.0058963117, + -0.026063463, + -0.05857786, + -0.016123982, + 0.01379927, + 0.079480365, + -0.035478346, + -0.015611646, + 0.029498354, + -0.045290068, + -0.15178469, + 0.035912134, + 0.04449409, + 0.04836143, + -0.0067517646, + -0.011269522, + 0.006338432, + 0.043403137, + -0.023823397, + -0.0055972924, + -0.05941106, + -0.058316052, + -0.013313087, + 0.004497583, + -0.00012288634, + 0.0057040993, + -0.030563654, + -0.01807327, + -0.011637197, + -0.042144947, + -0.01106994, + -0.042197466, + 0.037719112, + 0.04968912, + 0.0138677545, + -0.00044718548, + 0.020117762, + -0.03240842, + -0.024599735, + 0.020861633, + 0.017988935, + 0.02084155, + -0.0054945466, + 0.005179711, + 0.016424142, + -0.009331169, + -0.0044465223, + -0.0553768, + 0.0031574667, + -0.017787479, + 0.019080203, + 0.03230591, + -0.012341732, + 0.025004692, + 0.019298166, + -0.025041634, + 0.019594956, + -0.034517903, + -0.050875712, + -0.019735064, + 0.0223054, + -0.011615824, + -0.015423547, + -0.02739404, + -0.039332494, + -0.022458224, + 0.0048027067, + 0.03196106, + 0.01979664, + -0.0062706755, + 0.019448053, + -0.020343285, + 0.043424036, + -0.04586897, + 0.013968179, + -0.04126234, + 0.049639292, + -0.0021913303, + 0.024022536, + -0.017942743, + 0.033678636, + -0.0026815808, + 0.004740335, + 0.007837029, + 0.0025133016, + -0.014704166, + -0.019103019, + 0.00020881416, + -0.055314664, + -0.10588207, + -0.012290652, + -0.013280417, + -0.012066032, + 0.031525645, + -0.02848842, + -0.07452479, + 0.013740413, + -0.0069086426, + 0.021476183, + 0.21003543, + 0.03019431, + -0.0057703354, + 0.013058479, + 0.03021128, + -0.035792656, + 0.0024925217, + 0.063009314, + 0.01447695, + -0.042501368, + 0.016637918, + -0.004347526, + 0.0037653912, + -0.00875672, + 0.017176637, + 0.0496618, + -0.046407215, + 0.00420422, + 0.059771635, + -0.0072701965, + -0.0095596695, + 0.018209716, + -0.0031374195, + 0.00038444178, + -0.004737317, + -0.04121494, + -0.017534003, + 0.049045745, + -0.010472088, + 0.026896544, + 0.00889907, + 0.033942826, + 0.01221269, + 0.040200606, + -0.063737206, + 0.018511876, + 0.018314987, + -0.007963571, + -0.00614366, + 0.01681978, + -0.046448633, + -0.024795312, + -0.0863032, + 0.00024532728, + -0.022897705, + -0.039638914, + -0.015128308, + 0.014524852, + -0.054359157, + -0.0046227057, + -0.01674729, + -0.0045465007, + 0.01689407, + -0.002001382, + 0.026105125, + 0.008375628, + 0.0066461894, + -0.0018079818, + -0.012152685, + 0.065999456, + -0.011268143, + 0.023606345, + -0.055952635, + 0.021241141, + -0.0007930664, + 0.021621672, + -0.0352786, + -0.04737417, + 0.0678054, + 0.035463374, + -0.035795644, + 0.008570087, + -0.005071166, + 0.0049690553, + 0.009994089, + 0.008765795, + -0.012685508, + 0.044233117, + -0.0914326, + 0.0113208145, + 0.004692498, + -0.054381896, + -0.01629299, + 0.037889183, + 0.007327075, + -0.010359742, + -0.054703966, + 0.061306298, + 0.00906196, + 0.037151493, + -0.0037974943, + -0.013528092, + -0.020340146, + 0.028175673, + 0.02391432, + 0.02499042, + 0.032360457, + -0.00033409044, + -0.029748818, + -0.0039630746, + -0.033977274, + -0.016261173, + 0.01629143, + 0.02115507, + -0.0006883855, + -0.005401449, + -0.010338565, + 0.005253742, + -0.015998298, + -0.004929098, + -0.03718784, + 0.014855269, + 0.008430884, + -0.042657677, + -0.014095543, + 0.05653097, + 0.012700841, + 0.038654204, + 0.057084862, + 0.008283248, + -0.0038805045, + 0.01433863, + -0.010806832, + 0.002032093, + -0.034822192, + -0.059195485, + -0.06464534, + -0.0065331724, + -0.0046596904, + 0.06870491, + 0.0063025192, + -0.015969668, + 0.052501827, + 0.025292462, + 0.029614396, + 0.0627752, + 0.023294764, + -0.021694774, + -0.032884747, + 0.011542062, + -0.04903284, + 0.024722587, + -0.01771603, + 0.047911223, + 0.026072988, + 0.014621407, + -0.00068719295, + -0.0071027246, + -0.01017872, + 0.033466604, + -0.030330133, + 0.021938477, + 0.0053363005, + -0.031079197, + -0.0030351912, + -0.054265264, + -0.0033466273, + 0.0050160456, + -0.015334024, + -0.021185085, + 0.0073995665, + 0.020069182, + 0.005680933, + 0.011310939, + 0.0008004114, + -0.046266902, + -0.015315331, + 0.052749556, + 0.060199656, + -0.029846825, + 0.0021572318, + -0.041518375, + -0.054382395, + 0.03073223, + 0.0057319114, + -0.04695809, + -0.024999788, + -0.037105817, + -0.018266357, + -0.0006599289, + 0.021871628, + -0.037283786, + 0.002602609, + -0.0023893816, + 0.0096372105, + 0.0045353333, + 0.025970984, + -0.008221388, + 0.028000887, + -0.045520272, + -0.034343842, + 0.110890776, + 0.0050305375, + -0.024622781, + 0.016767783, + -0.0029298826, + 0.001343706, + -0.0004316718, + -0.026367055, + -0.027548142, + -0.0006882598, + -0.016411567, + 0.009276134, + -0.00019256136, + -0.024221217, + -0.014707676, + -0.017646747, + -0.021420673, + -0.029475793, + -0.0361871, + -0.00072792615, + 0.016765527, + -0.035031125, + 0.026409475, + 0.0021665234, + -0.054153748, + 0.05509699, + 0.028582018, + -0.020828646, + 0.010396727, + -0.027850196, + -0.0060524517, + 0.003786461, + -0.06543416, + -0.010009867, + -0.01877611, + -0.024833411, + -0.04231655, + 0.045347635, + 0.0138719715, + 0.0033026352, + -0.0540878, + 0.029384302, + -0.035129834, + 0.020549495, + 0.0054994277, + -0.011010943, + 0.034254543, + -0.029347366, + -0.02099775, + -0.009106889, + -0.0063675386, + 0.03801801, + 0.06408992, + 0.02334283, + 0.040168323, + -0.027336499, + 0.019649902, + 0.017668469, + 0.021207273, + -0.06041178, + 0.011385915, + 0.025502885, + -0.025169775, + 0.0094913775, + 0.006479949, + 0.0045493403, + -0.027151432, + -0.019396523, + -0.03737915, + -0.014329285, + 0.017777283, + -0.024481082, + 0.0024374824, + -0.013149655, + -0.020406704, + 0.057570096, + -0.017610427, + -0.011399566, + 0.0026504023, + 0.040467992, + 0.0016978766, + -0.0069717136, + 0.019263558, + 0.042821232, + 0.009246884, + -0.04365554, + 0.014474382, + 0.03059983, + 0.040423993, + -0.025032809, + 0.0022640307, + 0.04715433, + 0.023775559, + 0.028505879, + 0.07607637, + 0.065902784, + -0.028660439, + -0.008567381, + -0.03936581, + 0.03933869, + -0.00044328536, + -0.053043295, + 0.03473618, + -0.032432247, + 0.014144364, + 0.01988087, + 0.019367158, + -0.01019342, + -0.010655873, + 0.00029833888, + 0.047451008, + -0.03789396, + -0.0001574543, + -0.00039430344, + -0.0029776585, + -0.015314055, + -0.040001858, + 0.030178642, + 0.02023383, + 0.03010233, + -0.032422688, + -0.01178606, + 0.046470955, + 0.04255312, + -0.02269175, + 0.012761608, + -0.020653533, + 0.016107142, + -0.0036007082, + -0.03840523, + 0.030988485, + -0.01388788, + 0.02319522, + -0.017623072, + 0.025152182, + -0.03812054, + -0.00655977, + -0.01525569, + -0.017175646, + -0.04868773, + -0.031177327, + 0.015155245, + -0.030728387, + -0.008779726, + 0.059007447, + 0.031442434, + 0.0023708357, + 0.03047818, + 0.0052621663, + 0.021869387, + 0.0020043317, + 0.06811452, + 0.0046357014, + -0.0015064339, + -0.052893158, + -0.0026713628, + -0.026692647, + 0.033037186, + -0.0072431834, + -0.0072726845, + 0.009041898, + -0.01945484, + -0.052857347, + 0.018760143, + -0.02880663, + -0.029058898, + 0.014484246, + -0.019590463, + 0.0055371583, + -0.03252992, + 0.02882796, + 0.008329343, + -0.043450568, + -0.041187566, + 0.012979142, + 0.002462149, + 0.0035721348, + 0.012307954, + 0.026132103, + -0.04081587, + 0.012164442, + 0.02000687, + 0.015065705, + -0.03768662, + 0.063662924, + -0.014829279, + -0.029598072, + 0.036721073, + -0.034757104, + 0.0011000286, + -0.019721648, + -0.0036286835, + -0.016948981, + -0.007181322, + -0.0025407162, + -0.010760072, + -0.026336875, + -0.026019393, + 0.03695632, + -0.059773564, + 0.010931064, + -0.0065569007, + 0.03976879, + -0.14614794, + 0.04113479, + 0.009872478, + 0.010274022, + -0.03745393, + 0.04065846, + 0.008484158, + -0.02147694, + -0.02567083, + -0.023480374, + -0.022705857, + -0.040004287, + 0.021553352, + -0.041722436, + -0.017285679, + 0.0060647433, + 0.009248257, + -0.018403318, + 0.035536323, + 0.00047174402, + -0.0177962, + -0.055608835, + 0.062224504, + 0.019183502, + 0.026239147, + 0.011484372, + -0.034008756, + 0.003700058, + -0.010878078, + -0.05419217, + 0.03390225, + -0.04730178, + 0.01207646, + 0.079511955, + 0.022587545, + 0.03396943, + 0.0016266472, + 0.008346471, + 0.0195192, + -0.0032230632, + -0.03979985, + 0.023712713, + -0.0037318412, + -0.054302204, + -0.018734923, + 0.016491324, + -0.012142154, + 0.005800863, + -0.035413865, + 0.0087095415, + -0.015694749, + 0.04672853, + 0.018126588, + 0.035652485, + 0.008272519, + -0.043588184, + -0.06807094, + 0.013546888, + -0.012382437, + 0.028871085, + -0.0686504, + 0.03141793, + -0.014040778, + -0.03480182, + 0.0012224151, + 0.0023680008, + -0.022596918, + -0.007624073, + 0.016148768, + 0.027937397, + -0.016982922, + -0.018822605, + -0.017760672, + 0.040581577, + 0.0004837217, + -0.0024850285, + 0.04579277, + -0.008870415, + -0.061303787, + -0.030682448, + -0.03769964, + -0.010868018, + -0.026700469, + 0.0636063, + 0.02834812, + 0.026838003, + -0.018201817, + -0.0041244123, + 0.0032921627, + 0.010870265, + -0.03663979, + -0.037165314, + 0.006640471, + 0.02344125, + 0.008435948, + -0.047246058, + -0.0064403983, + 0.013840889, + -0.0005683037, + 0.023247436, + -0.01792416, + -0.021219999, + 0.038235236, + 0.011174954, + 0.025880745, + 0.028902924, + 0.04167197, + 0.017535383, + 0.044100802, + -0.009281118, + -0.01448841, + 0.0042119212, + -0.018454164, + 0.03456919, + -0.013484044, + -0.00072383916, + 0.035914775, + -0.018860323, + -0.019740876, + -0.012323961, + -0.00057545974, + 0.020075312, + -0.02078647, + -0.044447295, + 0.00010467891, + -0.008695298, + 0.059567474, + 0.022926642, + -0.0038921083, + -0.025651151, + 0.025463166, + -0.04100707, + -0.03225564, + 0.024455046, + 0.029539293, + -0.025711427, + 0.017723896, + 0.06504569, + -0.046183553, + -0.06840846, + -0.016517362, + 0.014398127, + -0.0011067652, + 0.00984128, + -0.027306262, + -0.003887419, + 0.028472483, + -0.023479898, + -0.0055367607, + -0.058271866, + 0.034817167, + 0.023974229, + 0.022390844, + 0.029452981, + 0.03238653, + 0.04752549, + -0.04630269, + -0.0068127275, + -0.01172649, + 0.045500774, + -0.001054104, + -0.05120993, + -0.0014360128, + -0.017861856, + -0.000881553, + 0.04078965, + -0.021778949, + -0.013852341, + -0.041431952, + 0.0009192221, + -0.0018714117, + 0.050898198, + -0.03622373, + -0.0064664236, + 0.039854188, + 0.0075146467, + 0.03382126, + -0.043119106, + 0.050508294, + 0.01222063, + 0.013417375, + -0.029155927, + 0.013130955, + -0.024506409, + -0.0060320976, + 0.024135388, + 0.023934443, + 0.008063069, + -0.038954426, + -0.0027139592, + -0.008446454, + -0.0068785483, + 0.053609833, + -0.023402665, + -0.001863744, + -0.005396493, + -0.006710818, + -0.0017272064, + -0.019511634, + 0.010182724, + -0.04044717, + -0.0085564805, + 0.023756072, + -0.01054971, + 0.006085659, + -0.021412296, + -0.041494433, + -0.040227562, + -0.030538945, + 0.027189177, + 0.010026787, + 0.0048623276, + -0.040290933, + -0.003636703, + -0.003424947, + -0.010439989, + 0.059526075, + 0.009029594, + 0.03172021, + 0.020387847, + -0.017294383, + -0.011901327, + 0.0160122, + -0.024241831, + -0.008229334, + -0.04810198, + 0.014097007, + 0.00643624, + -0.010895931, + -0.0046663242, + -0.014989608, + 0.021687325, + 3.650794e-05, + 0.0039710896, + 0.01050626, + -0.021171449, + 0.010798502, + 0.0065485593, + 0.0012133956, + 0.0385848, + -0.00058191357, + 0.043960012, + 0.038936593, + 0.01624683 ] \ No newline at end of file diff --git a/embedding/pgvector_store.py b/embedding/pgvector_store.py index ce10a66e..61124417 100644 --- a/embedding/pgvector_store.py +++ b/embedding/pgvector_store.py @@ -84,6 +84,15 @@ def count_vectors() -> int: return int(cur.fetchone()[0]) +def clear_vectors() -> None: + """Remove all rows from the vector table (used before a full re-seed).""" + ensure_schema() + with get_connection() as conn: + with conn.cursor() as cur: + cur.execute(f"TRUNCATE TABLE {_table_name()} RESTART IDENTITY") + conn.commit() + + def insert_vector_record(document: str | dict[str, Any], embedding: list[float]) -> None: ensure_schema(len(embedding)) document_text = json.dumps(document, ensure_ascii=False, sort_keys=True) if isinstance(document, dict) else document diff --git a/embedding/scenario_router.py b/embedding/scenario_router.py new file mode 100644 index 00000000..24b4b515 --- /dev/null +++ b/embedding/scenario_router.py @@ -0,0 +1,247 @@ +"""Scenario knowledge-base management API. + +Exposes the endpoints the ExtS3-Web-UI admin "시나리오 관리" page proxies to: + + GET /api/scenario/db-status -> vector DB health + count + GET /api/scenario/list -> all base scenarios + GET /api/scenario/detail/{id} -> one scenario (json + doc) + POST /api/scenario/upload -> add a scenario (json + md) + DELETE /api/scenario/delete/{id} -> remove a user scenario (json + md) + POST /api/scenario/reload -> wipe + re-embed all scenarios + +Each scenario is addressed by a Chrome-extension-style id: 32 chars drawn from +``a``–``p`` (one hex nibble each). + +* The 26 builtin scenarios carry a **fixed** ``scenario_id`` derived + deterministically from their ``pattern_name`` (SHA-256 → a-p). These ids never + change across reseed / reinstall and the scenarios cannot be deleted. +* User-uploaded scenarios get a **random** ``scenario_id`` that is checked for + collisions against every existing id before being assigned. + +Scenario definitions live in ``embedding/base/.json`` and their human docs in +``embedding/scenario_docs/.md``. +""" + +import hashlib +import json +import secrets +from pathlib import Path + +from fastapi import APIRouter, File, HTTPException, UploadFile + +from embedding.base_db import normalize_base_record, store_all_knowledge_base +from embedding.pgvector_store import clear_vectors, count_vectors + +router = APIRouter(prefix="/api/scenario", tags=["scenario"]) + +_EMBEDDING_DIR = Path(__file__).resolve().parent +_BASE_DIR = _EMBEDDING_DIR / "base" +_DOCS_DIR = _EMBEDDING_DIR / "scenario_docs" + +# 16-symbol alphabet (one hex nibble each), mirrors the Chrome extension id scheme. +_ID_ALPHABET = "abcdefghijklmnop" +_ID_LENGTH = 32 + + +def _derive_fixed_id(seed: str) -> str: + """Deterministic id from a seed (used for the fixed builtin scenarios).""" + digest = hashlib.sha256(seed.encode("utf-8")).hexdigest() + return "".join(_ID_ALPHABET[int(char, 16)] for char in digest[:_ID_LENGTH]) + + +def _is_valid_id(scenario_id: str) -> bool: + return ( + isinstance(scenario_id, str) + and len(scenario_id) == _ID_LENGTH + and all(char in _ID_ALPHABET for char in scenario_id) + ) + + +def _scenario_id_of(path: Path, data: dict) -> str: + """Resolve a scenario's id: stored ``scenario_id`` or derived from pattern_name.""" + stored = data.get("scenario_id") + if isinstance(stored, str) and _is_valid_id(stored): + return stored + pattern_name = data.get("pattern_name") or path.stem + return _derive_fixed_id(pattern_name) + + +def _load_scenario(path: Path) -> dict: + with path.open("r", encoding="utf-8") as f: + return json.load(f) + + +def _iter_scenarios(): + """Yield (path, data, scenario_id) for every readable base scenario.""" + if not _BASE_DIR.exists(): + return + for path in sorted(_BASE_DIR.glob("*.json")): + try: + data = _load_scenario(path) + except Exception: + continue + yield path, data, _scenario_id_of(path, data) + + +def _find_by_id(scenario_id: str): + """Return (path, data) for the scenario with this id, or None.""" + for path, data, sid in _iter_scenarios(): + if sid == scenario_id: + return path, data + return None + + +def _existing_ids() -> set: + return {sid for _, _, sid in _iter_scenarios()} + + +def _new_unique_id() -> str: + existing = _existing_ids() + for _ in range(1000): + candidate = "".join(secrets.choice(_ID_ALPHABET) for _ in range(_ID_LENGTH)) + if candidate not in existing: + return candidate + raise HTTPException(status_code=500, detail="고유 시나리오 ID 생성에 실패했습니다.") + + +def _behavior_tags(data: dict) -> list: + vf = data.get("vector_fingerprint") if isinstance(data.get("vector_fingerprint"), dict) else data + tags = vf.get("behavior_tags") if isinstance(vf, dict) else None + return tags if isinstance(tags, list) else [] + + +def _is_builtin(data: dict) -> bool: + return data.get("builtin") is True + + +def _doc_path_for(path: Path) -> Path: + """Markdown doc lives next to the JSON, keyed by the same file stem.""" + return _DOCS_DIR / f"{path.stem}.md" + + +def _read_doc(path: Path) -> str | None: + doc_path = _doc_path_for(path) + if not doc_path.exists(): + return None + try: + return doc_path.read_text(encoding="utf-8") + except Exception: + return None + + +@router.get("/db-status") +async def db_status(): + try: + return {"status": "ok", "vector_count": count_vectors()} + except Exception as exc: # connection / pgvector / schema failure + return {"status": "error", "detail": str(exc)} + + +@router.get("/list") +async def list_scenarios(): + scenarios = [] + for path, data, sid in _iter_scenarios(): + scenarios.append( + { + "id": sid, + "pattern_name": data.get("pattern_name") or path.stem, + "behavior_tags": _behavior_tags(data), + "has_doc": _doc_path_for(path).exists(), + "builtin": _is_builtin(data), + } + ) + return {"scenarios": scenarios} + + +@router.get("/detail/{scenario_id}") +async def get_scenario(scenario_id: str): + found = _find_by_id(scenario_id) + if not found: + raise HTTPException(status_code=404, detail="시나리오를 찾을 수 없습니다.") + path, data = found + return { + "id": scenario_id, + "pattern_name": data.get("pattern_name") or path.stem, + "builtin": _is_builtin(data), + "behavior_tags": _behavior_tags(data), + "doc": _read_doc(path), + "scenario": data, + } + + +@router.post("/upload") +async def upload_scenario( + json_file: UploadFile = File(...), + md_file: UploadFile = File(None), +): + raw = await json_file.read() + try: + data = json.loads(raw.decode("utf-8")) + except Exception as exc: + raise HTTPException(status_code=400, detail=f"JSON 파싱 실패: {exc}") + if not isinstance(data, dict): + raise HTTPException(status_code=400, detail="JSON 최상위는 객체여야 합니다.") + + # 구조 검증 (필수 키 누락 등은 ValueError) + try: + normalize_base_record(Path(json_file.filename or "scenario.json"), data) + except ValueError as exc: + raise HTTPException(status_code=400, detail=f"시나리오 형식 오류: {exc}") + + # 사용자 업로드는 항상 새 고유 ID를 부여한다 (기존 빌트인/사용자 ID와 충돌 없음). + scenario_id = _new_unique_id() + data["scenario_id"] = scenario_id + data["builtin"] = False + data["doc_ref"] = f"scenario_docs/{scenario_id}.md" + + _BASE_DIR.mkdir(parents=True, exist_ok=True) + target = _BASE_DIR / f"{scenario_id}.json" + target.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8") + + if md_file and md_file.filename: + _DOCS_DIR.mkdir(parents=True, exist_ok=True) + md_bytes = await md_file.read() + (_DOCS_DIR / f"{scenario_id}.md").write_bytes(md_bytes) + + return { + "id": scenario_id, + "message": f"시나리오 저장 완료 (ID: {scenario_id})", + "reload_required": True, + } + + +@router.delete("/delete/{scenario_id}") +async def delete_scenario(scenario_id: str): + found = _find_by_id(scenario_id) + if not found: + raise HTTPException(status_code=404, detail="시나리오를 찾을 수 없습니다.") + path, data = found + + if _is_builtin(data): + raise HTTPException( + status_code=400, + detail="기본 제공(빌트인) 시나리오는 삭제할 수 없습니다.", + ) + + doc_path = _doc_path_for(path) + path.unlink(missing_ok=True) + doc_path.unlink(missing_ok=True) + + return { + "id": scenario_id, + "message": f"시나리오 '{scenario_id}' 삭제 완료", + "reload_required": True, + } + + +@router.post("/reload") +async def reload_scenarios(): + try: + clear_vectors() + store_all_knowledge_base() + return { + "message": "vectorDB 재적재 완료", + "vector_count": count_vectors(), + } + except Exception as exc: + raise HTTPException(status_code=500, detail=f"재적재 실패: {exc}") diff --git a/main.py b/main.py index dfc56fc0..889dfc38 100644 --- a/main.py +++ b/main.py @@ -107,6 +107,10 @@ async def lifespan(app: FastAPI): from holding import router as holding_router app.include_router(holding_router) +# 시나리오 지식베이스 관리 (Web-UI 시나리오 관리 페이지가 프록시로 호출) +from embedding.scenario_router import router as scenario_router +app.include_router(scenario_router) + UPLOAD_DIR = "./storage" os.makedirs(UPLOAD_DIR, exist_ok=True)