Community寫作與編輯github.com

microsoft/azure-kusto-irql

撰寫 IRQL(事件回應查詢語言)查詢,用於 Kusto 網路安全調查。將自然語言狩獵問題轉換為可組合的 IRQL 管線,使用 Get_*、Extract_* 和 Enrich_* 函數。

azure-kusto-irql 是什麼?

IRQL(Incident Response Query Language)是建立在 Kusto 查詢語言(KQL)之上的函數式方言,專為網路安全事件回應調查而設計。此技能讓分析師和 LLM 能夠透過組合選擇器(Get_*)、提取器(Extract_*)和擴充器(Enrich_*)函數,以意圖導向的方式表達狩獵查詢,無需記憶底層的 Kusto 資料表結構、叢集位置或關聯鍵。IRQL 提供統一的資料綱要,將不同安全資料表投影到一致的欄位名稱,確保查詢在不同叢集和資料庫間的可攜性。此技能支援多種 Kusto 平台,並能將自然語言查詢轉換為可組合的 IRQL 管線。它涵蓋事件驗證、電子郵件、流程執行、網路流量等多種安全資料類型,並包含外部威脅情報擴充功能,如 VirusTotal 和 CISA KEV。著名的使用者如 KC7 的 ValdyTimes 和 JoJosHospital 資料庫已預先部署相關函數,可供練習使用。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/microsoft/agent-skills/tree/main/.github/plugins/azure-kusto-graph-skills/skills/azure-kusto-irql

Installed? Explore more 寫作與編輯 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

IRQL -- 事件回應查詢語言(Incident Response Query Language)

從選擇器、提取器和擴充器這三種建構區塊組合 IRQL 函數管線。IRQL 將原始的 KQL 安全資料表包裝在意圖明確、可組合的函數中,讓分析師(和 LLM)無需記住資料表結構、叢集位置或關聯鍵即可表達狩獵意圖。

啟動觸發條件

當使用者有下列情況時使用此技能:

  • 明確提及 IRQL、Get_*、Extract_* 或 Enrich_* 函數
  • 說「使用 IRQL」或「撰寫 IRQL 查詢」
  • 要求使用已知的 IRQL 選擇器來組合狩獵管線

如果使用者只是提出一般安全查詢(例如「尋找失敗的登入」)而未明確要求 IRQL,不要啟動此技能。請將這些請求導向 azure-kusto。

注意:這不是自然語言到 IRQL 的轉換工具。 此技能負責組合 IRQL 函數管線,並且可能處理能直接對應到已知選擇器和簡單過濾條件的基本自然語言請求。如需一般的自然語言到 KQL 或 IRQL 轉換,請使用專門的查詢生成技能(另外提供)。

IRQL 函數預檢

在生成管線之前,請確認目標資料庫上存在 IRQL 函數:

.show functions
| where Name startswith "Get_" or Name startswith "Extract_" or Name startswith "Enrich_"
| project Name

如果找不到任何 IRQL 函數,請告知使用者在目標資料庫上尚未部署 IRQL,並建議改用 azure-kusto 進行原始 KQL 查詢。IRQL 函數是必要前提——此技能不會部署基礎的 IRQL 選擇器。

IRQL 是什麼

IRQL 是建構在 KQL 之上的函數式方言。它提供:

  1. 統一的資料綱要 —— 將不同的安全資料表投影到一致的欄位名稱,無論底層資料來源為何
  2. 可組合性 —— 透過 | invoke 鏈結小型函數,從簡單步驟建構複雜的狩獵查詢
  3. 可攜性 —— 相同的 IRQL 管線可在不同叢集/資料庫中運作;只需重新指向 Get_* 原始函數

IRQL 不是一種獨立的語言。它是您可以呼叫的 KQL 函數。任何有效的 KQL 都可以與 IRQL 函數並用。

部署 IRQL

IRQL 函數是儲存的 KQL 函數(.create-or-alter function)。在使用此技能生成管線之前,它們必須已部署到目標資料庫中。

公開範例叢集(函數已預先部署):

  • 叢集:https://kc7001.eastus.kusto.windows.net
  • 資料庫:ValdyTimes、JoJosHospital

若要將 IRQL 移植到新的叢集/資料庫,請先建立 Get_* 選擇器,將您的來源資料表投影到統一的綱要(請見下方欄位名稱),然後部署提取器和擴充器。只要輸入綱要相符,提取器和擴充器即可直接使用,無需修改。

函數目錄

1. 選擇器 -- Get_*

傳回經過投影、綱要統一的來源資料表檢視。預設使用最小形式;需要額外欄位時使用 _All 形式。

函數欄位
Get_Event_AuthenticationEnvTime, Hostname, ClientIp, Username, Result
Get_Event_Authentication_All+ Description, UserAgent, PasswordHash
Get_EmailEnvTime, EmailSender, EmailRecipient, Subject, Url
Get_Email_All+ ReplyTo, Verdict
Get_EmployeesName, ClientIp, Email, Username, Hostname, Role
Get_Employees_All+ HireDate, UserAgent, Domain
Get_Event_FileCreationEnvTime, Hostname, Filename, Path
Get_Event_FileCreation_All+ Username, Sha256, ProcessName
Get_Event_NetworkInboundEnvTime, ClientIp, Url
Get_Event_NetworkInbound_All+ Method, UserAgent, StatusCode
Get_Event_NetworkOutboundEnvTime, ClientIp, Url
Get_Event_NetworkOutbound_All+ Method, UserAgent
Get_Dns_AllEnvTime, Domain, ClientIp
Get_Event_ProcessEnvTime, ProcessCommandLine, ProcessName, Hostname, Username
Get_Event_Process_All+ ParentProcessName, ParentProcessHash, ProcessHash
Get_SecurityAlerts_AllEnvTime, AlertType, Severity, Description, Indicators
Get_Network_Connection_AllEnvTime, SourceIp, SourcePort, DestinationIp, DestinationPort, Protocol, Bytes

2. 提取器 -- Extract_*

從現有欄位衍生出一個新的欄位。在選擇器之後呼叫。

函數輸入欄位新增欄位
Extract_Email_Sender_Domain(T)EmailSenderDomain
Extract_Employee_Firstname(T)NameFirstname
Extract_Event_Network_Domain(T)UrlDomainName

3. 擴充器 -- Enrich_*

左連接輔助函數,從關聯資料表附加上下文資訊。

函數鍵欄位擴充內容
Enrich_Event_Authentication_Username(T)Username使用者的驗證事件
Enrich_Ip_Employee(T)ClientIp從 IP 取得員工身分
Enrich_Username_Employee(T)Username從使用者名稱取得員工身分
Enrich_Ip_Domain(T)ClientIp解析到 IP 的 DNS 網域
Enrich_Ip_Event_NetworkOutbound(T)ClientIp來自 IP 的對外網路流量
Enrich_Ip_Network_Connection(T)ClientIp來自 IP 的網路流

4. 外部擴充

函數來源需求
Enrich_Sha256_VirusTotal(T)VirusTotal 檔案報告API 金鑰 + 回呼原則
Get_CISA_KEV() / Enrich_CISA_KEV(T)CISA KEV 目錄回呼原則

組合規則

選擇器 -> 提取 -> 過濾 -> 擴充 -> 彙總/投影
  1. 以選擇器開始:Get_Event_Authentication、Get_Email 等
  2. 提取衍生欄位:| invoke Extract_Email_Sender_Domain()
  3. 過濾以聚焦訊號:| where Result == "Failed Login"
  4. 擴充上下文資訊:| invoke Enrich_Username_Employee()
  5. 彙總 / 投影最終答案

始終使用管線符號 (|) 連接步驟。提取器和擴充器使用 | invoke FunctionName()。

查詢生成指南

  • 除非需要額外欄位,否則使用最小選擇器,否則使用 _All
  • 在擴充器之前鏈結提取器(提取器新增的欄位可能是擴充器的鍵)
  • 盡早放置 where 過濾條件
  • 使用 summarize 進行彙總,使用 project 進行最終欄位選取
  • 以 order by + take 結尾以限制輸出量

範例

如需更多提示和實作範例,請參閱 references/EXAMPLES.md。

暴力破解偵測

Get_Event_Authentication
| where Result == "Failed Login"
| summarize FailedCount = count() by Username
| where FailedCount > 19
| invoke Enrich_Username_Employee()
| project Username, Name, Role, Email, FailedCount
| order by FailedCount desc

依收件者資歷進行釣魚郵件分類

Get_Email
| invoke Extract_Email_Sender_Domain()
| project EnvTime, EmailSender, Domain, Username = EmailRecipient, Subject, Url
| invoke Enrich_Username_Employee()
| extend Seniority = case(
    Role has_any ("CEO", "Chief", "Director", "VP", "President"), 3,
    Role has_any ("Manager", "Lead", "Senior"), 2,
    1)
| summarize
    TotalEmails = count(),
    SeniorityScore = sum(Seniority),
    Recipients = make_set(Name, 50),
    DistinctRecipients = dcount(Username)
  by Domain
| where DistinctRecipients >= 2
| order by SeniorityScore desc
| take 20

從入侵指標進行入侵後橫向移動

let victims =
    Get_Event_FileCreation_All
    | where Filename has "<INDICATOR>"
    | distinct Hostname;
Get_Event_Process
| where Hostname in (victims)
| where ProcessCommandLine has_any ("rundll32", "regsvr32", "powershell", "systeminfo")
| project EnvTime, Hostname, Username, ProcessName, ProcessCommandLine
| order by EnvTime asc

可疑對外流量搭配身分擴充

Get_Event_NetworkOutbound
| invoke Extract_Event_Network_Domain()
| where DomainName has_any ("<SUSPICIOUS_DOMAIN_1>", "<SUSPICIOUS_DOMAIN_2>")
| invoke Enrich_Ip_Employee()
| project EnvTime, Name, Role, DomainName, Url, ClientIp
| order by EnvTime desc

外部 IP 驗證異常

Get_Event_Authentication_All
| where not(ClientIp startswith "10.") and not(ClientIp startswith "192.168.")
| summarize
    Attempts = count(),
    Failures = countif(Result == "Failed Login"),
    Users = make_set(Username)
  by ClientIp
| order by Failures desc
| take 20

使用的 MCP 工具

工具用途
kusto_query對 Kusto 資料庫執行 IRQL 管線
kusto_table_schema_get探索可用的資料表和欄位
kusto_cluster_list列出可用的 ADX 叢集
kusto_database_list列出叢集中的資料庫

在 Kusto Explorer 中開啟查詢(僅限 Windows)

可選的便利功能。 預設工作流程是直接在聊天中輸出 KQL,讓使用者自行複製到 Kusto Explorer 或 VS Code Kusto 擴充功能。自動啟動為選擇加入功能。

始終在聊天回應中輸出完整的 KQL 查詢,並清楚標示步驟 1(連線)和步驟 2(查詢):

// 步驟 1:連線到您的叢集(如果已連線則跳過)
// 範例:取消註解以連線到 KC7 訓練叢集
// #connect cluster('kc7001.eastus.kusto.windows.net').database('ValdyTimes')
// 或者替換為您自己的叢集:
// #connect cluster('<YOUR_CLUSTER>').database('<YOUR_DATABASE>')

// 步驟 2:執行以下查詢
<KQL_QUERY>

如果使用者要求儲存或在 Kusto Explorer 中開啟,請遵循 references/KUSTO_EXPLORER_LAUNCH.md 中的程序。關鍵規則:

  • 在寫入檔案或啟動可執行檔之前,使用 ask_user 進行確認
  • 在聊天中顯示檔案內容,讓使用者可以在開啟前審閱
  • 永遠不要使用 Shell 內插或這裡字串——透過 Set-Content/Add-Content 寫入檔案
  • 永遠不要將查詢編碼到瀏覽器 URL 中
  • 在 macOS/Linux 上,儲存 .kql 檔案並建議使用 VS Code Kusto 擴充功能或 ADX Web Explorer
  • 如需從 IRQL 資料進行圖形視覺化,請參閱 azure-kusto-graph 和 azure-kusto-irql-graph

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

microsoft/azure-ai-agents-persistent-dotnet

Azure AI Agents Persistent SDK for .NET. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Use for agent CRUD, conversation threads, streaming responses, function calling, file search, and code interpreter. Triggers: "PersistentAgentsClient", "persistent agents", "agent threads", "agent runs", "streaming agents", "function calling agents .NET".

microsoft/azure-ai-document-intelligence-dotnet

Azure AI Document Intelligence SDK for .NET. Extract text, tables, and structured data from documents using prebuilt and custom models. Use for invoice processing, receipt extraction, ID document analysis, and custom document models. Triggers: "Document Intelligence", "DocumentIntelligenceClient", "form recognizer", "invoice extraction", "receipt OCR", "document analysis .NET".

microsoft/azure-ai-openai-dotnet

Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants. Triggers: "Azure OpenAI", "AzureOpenAIClient", "ChatClient", "chat completions .NET", "GPT-4", "embeddings", "DALL-E", "Whisper", "OpenAI .NET".

microsoft/azure-ai-projects-dotnet

Azure AI Projects SDK for .NET. High-level client for Azure AI Foundry projects including agents, connections, datasets, deployments, evaluations, and indexes. Use for AI Foundry project management, versioned agents, and orchestration. Triggers: "AI Projects", "AIProjectClient", "Foundry project", "versioned agents", "evaluations", "datasets", "connections", "deployments .NET".

microsoft/azure-ai-voicelive-dotnet

Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication. Use for voice assistants, conversational AI, real-time speech-to-speech, and voice-enabled chatbots. Triggers: "voice live", "real-time voice", "VoiceLiveClient", "VoiceLiveSession", "voice assistant .NET", "bidirectional audio", "speech-to-speech".

microsoft/azure-eventgrid-dotnet

Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven", "pub/sub".

microsoft/azure-eventhub-dotnet

Azure Event Hubs SDK for .NET. Use for high-throughput event streaming: sending events (EventHubProducerClient, EventHubBufferedProducerClient), receiving events (EventProcessorClient with checkpointing), partition management, and real-time data ingestion. Triggers: "Event Hubs", "event streaming", "EventHubProducerClient", "EventProcessorClient", "send events", "receive events", "checkpointing", "partition".

microsoft/azure-identity-dotnet

Azure Identity library for .NET. Authentication library for Azure SDK clients using Microsoft Entra ID. Use for DefaultAzureCredential, managed identity, service principals, and developer credentials. Triggers: "Azure Identity", "DefaultAzureCredential", "ManagedIdentityCredential", "ClientSecretCredential", "authentication .NET", "Azure auth", "credential chain".

microsoft/azure-kusto-graph

Build and query Kusto graphs from natural language. Covers transient graphs (make-graph), persistent graph models/snapshots, pattern matching (graph-match), shortest paths, connected components, and graph-to-table export. Generates the edges-first thinking: define edges, define node lookups, union, make-graph. WHEN: make-graph, graph-match, graph-shortest-paths, graph-to-table, graph-mark-components, persistent graph, graph model, graph snapshot, build a graph from data, find paths between nodes, pattern matching in graph, connected components, transient graph, Kusto graph, KQL graph.

microsoft/azure-kusto-irql-graph

Apply IRQL graph functions to KQL or IRQL query results for Kusto Explorer visualization. Generates Lift_To_Graph mappings and composes Graph_Render_View, Graph_Fold_By_Property, Extract_Node_*, Enrich_Node_*, and Enrich_Graph_* calls. Accepts a supplied query or limited basic natural-language source request; it is not a general natural-language-to-KQL/IRQL skill. WHEN: Lift_To_Graph, Graph_Render_View, Graph_Fold_By_Property, IRQL graph enrichment, graph mapping for existing query results, icon-decorated graph, fold graph nodes. Use azure-kusto-graph for native make-graph analysis, graph-match, shortest paths, components, or persistent graphs.

microsoft/azure-local

Plan, deploy, operate, and troubleshoot Azure Local (formerly Azure Stack HCI): sizing and prerequisites, Arc registration, lifecycle updates, workloads (Azure Local VMs, AKS on Azure Local, images, disks, logical networks), SDN and network security, and failure triage — starting read-only and confirming before risky changes. WHEN: Azure Local, Azure Stack HCI, Arc resource bridge, custom location, Azure Local VM, Arc VM, AKS on Azure Local, AKS hybrid, SDN, Lifecycle Manager, Azure Local update, disconnected site.

microsoft/azure-local-multi-rack

Plan, deploy, operate, and troubleshoot multi-rack (rack scale) deployments of Azure Local — preintegrated racks scaling to hundreds of machines, built on Network Fabric Controller, Cluster Manager, SAN storage, and managed network fabric. Use for the Microsoft.NetworkCloud and Microsoft.ManagedNetworkFabric control plane. NOT for standard 1-16 node Azure Local, and NOT for rack-aware clusters (two racks as availability zones, up to 8 nodes, synchronous replication) — those are standard scale. WHEN: multi-rack, rack scale Azure Local, aggregation rack, compute rack, Network Fabric Controller, NFC, Cluster Manager, network fabric, isolation domain, az networkcloud, az networkfabric, multi-rack logical network, multi-rack Arc VM.

相關技能