欢迎来到统一的 Microsoft Sentinel 与 Microsoft 365 Defender 仓库!本仓库包含开箱即用的检测、探索查询、搜寻查询、工作簿、剧本以及更多内容,帮助您快速上手 Microsoft Sentinel,并提供安全内容以保护您的环境并搜寻威胁。这些搜寻查询还包括适用于 Microsoft 365 Defender 和 Microsoft Sentinel 中的高级搜寻场景的 Microsoft 365 Defender 搜寻查询。您还可以向 issues 提交您希望在接入 Microsoft Sentinel 时看到的任何示例或资源。本仓库欢迎贡献,请参阅本仓库的 wiki 开始操作。如有疑问或反馈,请联系 [email protected]
我们非常重视您的反馈。以下是一些帮助您提出疑问或反馈的渠道:
本项目欢迎贡献和建议。大多数贡献需要您同意一份贡献者许可协议(CLA),声明您有权并且确实授予我们使用您的贡献的权利。有关详细信息,请访问 https://cla.microsoft.com。
注意:如果您是首次向本仓库贡献,请在克隆前查阅 常规 GitHub Fork 仓库指南 或 Sentinel 仓库的具体步骤。
全新贡献或更新贡献可通过以下方式:
作为 PR 检查的一部分,我们会运行结构验证,以确保包含 YAML 结构的所有必需部分。对于检测,必须包含一个新的部分。请参阅 贡献指南 了解更多信息。如果未包含此部分或任何其他必需部分,则会出现类似于以下的验证错误。 以下示例特指 YAML 缺少 entityMappings 部分的情况:
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.95] Kqlvalidations.Tests.DetectionTemplateStructureValidationTests.Validate_DetectionTemplates_HaveValidTemplateStructure(detectionsYamlFileName: "ExcessiveBlockedTrafficGeneratedbyUser.yaml") [FAIL]
X Kqlvalidations.Tests.DetectionTemplateStructureValidationTests.Validate_DetectionTemplates_HaveValidTemplateStructure(detectionsYamlFileName: "ExcessiveBlockedTrafficGeneratedbyUser.yaml") [104ms]
Error Message:
Expected object to be <null>, but found System.ComponentModel.DataAnnotations.ValidationException with message "An old mapping for entity 'AccountCustomEntity' does not have a matching new mapping entry."
作为 PR 检查的一部分,我们会运行模板中定义的 KQL 查询的语法验证。如果此检查失败,请转到 Azure Pipeline(通过点击 PR 中 checks 选项卡上的错误链接)
在管道中,您可以查看哪个测试失败以及原因:

示例错误消息:
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:01.81] Kqlvalidations.Tests.KqlValidationTests.Validate_DetectionQueries_HaveValidKql(detectionsYamlFileName: "ExcessiveBlockedTrafficGeneratedbyUser.yaml") [FAIL]
X Kqlvalidations.Tests.KqlValidationTests.Validate_DetectionQueries_HaveValidKql(detectionsYamlFileName: "ExcessiveBlockedTrafficGeneratedbyUser.yaml") [21ms]
Error Message:
Template Id:fa0ab69c-7124-4f62-acdd-61017cf6ce89 is not valid Errors:The name 'SymantecEndpointProtection' does not refer to any known table, tabular variable or function., Code: 'KS204', Severity: 'Error', Location: '67..93',The name 'SymantecEndpointProtection' does not refer to any known table, tabular variable or function., Code: 'KS204', Severity: 'Error', Location: '289..315'
如果您使用自定义日志表(默认所有工作区中未定义的表),您应验证 您的表架构是否定义在文件夹 Azure-Sentinel\.script\tests\KqlvalidationsTests\CustomTables 中的 json 文件中
表 tablexyz.json 的示例
{
"Name": "tablexyz",
"Properties": [
{
"Name": "SomeDateTimeColumn",
"Type": "DateTime"
},
{
"Name": "SomeStringColumn",
"Type": "String"
},
{
"Name": "SomeDynamicColumn",
"Type": "Dynamic"
}
]
}
为了在提交拉取请求之前在本地机器上运行 KQL 验证:
Azure-Sentinel\\.script\tests\KqlvalidationsTests\dotnet test输出示例(在 Ubuntu 中):
Welcome to .NET Core 3.1!
----------------------
SDK Version: 3.1.403
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Test run for /mnt/c/git/Azure-Sentinel/.script/tests/KqlvalidationsTests/bin/Debug/netcoreapp3.1/Kqlvalidations.Tests.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.7.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 171
Passed: 171
Total time: 25.7973 Seconds
与 KQL 验证类似,检测的架构也会自动验证。 架构验证包括检测的频率和周期、检测的触发类型和阈值、连接器 ID 的有效性(有效连接器 ID 列表)等。 格式错误或缺少属性将导致信息性检查失败,这应指导您解决问题,但请确保查看已批准检测的格式。
为了在提交拉取请求之前在本地机器上运行检测架构验证:
Azure-Sentinel\\.script\tests\DetectionTemplateSchemaValidation\dotnet test当您提交拉取请求时,CLA 机器人会自动确定您是否需要提供 CLA,并适当装饰 PR(例如,标签、评论)。只需按照机器人提供的指示操作即可。您只需在使用我们 CLA 的所有仓库中执行一次此操作。
本项目已采用 Microsoft 开源行为准则。 有关更多信息,请参阅 行为准则常见问题解答 或联系 [email protected] 提出其他问题或意见。