Azure/Azure-Sentinel
GitHub: Azure/Azure-Sentinel
微软官方的 Sentinel 和 365 Defender 安全内容社区仓库,提供现成的检测规则、狩猎查询和自动化剧本。
Stars: 5505 | Forks: 3538
# Microsoft Sentinel 和 Microsoft 365 Defender
欢迎使用统一的 Microsoft Sentinel 和 Microsoft 365 Defender 存储库!该存储库包含开箱即用的检测、探索查询、搜寻查询、工作簿、剧本以及更多内容,旨在帮助您快速上手 Microsoft Sentinel,并提供安全内容以保护您的环境并搜寻威胁。搜寻查询还包括适用于 Microsoft 365 Defender 和 Microsoft Sentinel 中高级搜寻场景的 Microsoft 365 Defender 搜寻查询。您也可以在加入 Microsoft Sentinel 时,将您希望在此处看到的任何样本或资源提交到 [issues](https://github.com/Azure/Azure-Sentinel/issues)。该存储库欢迎贡献,请参阅该存储库的 [wiki](https://aka.ms/threathunters) 以开始使用。如有问题和反馈,请联系 [AzureSentinel@microsoft.com](AzureSentinel@microsoft.com)
# 资源
* [Microsoft Sentinel 文档](https://go.microsoft.com/fwlink/?linkid=2073774&clcid=0x409)
* [Microsoft 365 Defender 文档](https://docs.microsoft.com/microsoft-365/security/defender/microsoft-365-defender?view=o365-worldwide)
* [安全社区网络研讨会](https://aka.ms/securitywebinars)
* [GitHub 入门](https://help.github.com/en#dotcom)
我们重视您的反馈。以下是一些有助于提出您的问题或反馈的渠道:
1. 针对 SIEM 和 SOAR 的常规产品问答 - 加入 [Microsoft Sentinel 技术社区讨论](https://techcommunity.microsoft.com/t5/microsoft-sentinel/bd-p/MicrosoftSentinel)
2. 针对 XDR 的常规产品问答 - 加入 [Microsoft 365 Defender 技术社区讨论](https://techcommunity.microsoft.com/t5/microsoft-365-defender/bd-p/MicrosoftThreatProtection)
3. 特定产品的功能请求 - 在 [Microsoft Sentinel 反馈论坛](https://feedback.azure.com/d365community/forum/37638d17-0625-ec11-b6e6-000d3a4f07b8) 上投票或发布新帖
4. 报告产品或贡献错误 - 使用 [Bug 模板](https://github.com/Azure/Azure-Sentinel/issues/new?assignees=&labels=&template=bug_report.md&title=) 提交 GitHub Issue
5. 关于社区和贡献流程的一般反馈 - 使用 [功能请求模板](https://github.com/Azure/Azure-Sentinel/issues/new?assignees=&labels=&template=feature_request.md&title=) 提交 GitHub Issue
# 贡献指南
本项目欢迎贡献和建议。大多数贡献要求您同意一份
贡献者许可协议 (CLA),声明您有权并且实际上确实授予我们
使用您的贡献的权利。详情请访问 https://cla.microsoft.com。
## 将您的新增或更新的贡献添加到 GitHub
注意:如果您是本存储库的首次贡献者,请在克隆之前参阅 [GitHub Fork 仓库通用指南](https://docs.github.com/github/getting-started-with-github/fork-a-repo) 或 [Sentinel 仓库的具体步骤](https://github.com/Azure/Azure-Sentinel/blob/master/GettingStarted.md)。
## 通用步骤
通过以下方法提交全新的贡献或更新:
* 直接在 GitHub 网站上提交以供审查
* 浏览到您要将文件上传到的文件夹
* 选择“Upload Files”(上传文件)并浏览到您的文件。
* 您将需要创建自己的分支,然后提交 Pull Request 以供审查。
* 使用 [GitHub Desktop](https://docs.github.com/en/desktop/overview/getting-started-with-github-desktop) 或 [Visual Studio](https://visualstudio.microsoft.com/vs/) 或 [VSCode](https://code.visualstudio.com/?wt.mc_id=DX_841432)
* [Fork 该仓库](https://docs.github.com/github/getting-started-with-github/fork-a-repo)
* [Clone 该仓库](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
* [创建您自己的分支](https://help.github.com/en/desktop/contributing-to-projects/creating-a-branch-for-your-work)
* 在 GitHub Desktop 中进行添加/更新
* 在推送之前,请确保将 master 合并回您的分支。
* [将您的更改推送到 GitHub](https://help.github.com/en/github/using-git/pushing-commits-to-a-remote-repository)
## Pull Request
* 推送更改后,您需要提交 [Pull Request (PR)](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
* 需要提供有关“建议更改”的详细信息,请确保包含足够详细的细节,以便审查人员能够清楚地理解更改的原因以及更改与代码的关联。
* 提交后,请检查 [Pull Request](https://github.com/Azure/Azure-Sentinel/pulls) 中的评论
* 根据建议进行更改并更新您的分支,或解释为什么不需要更改。完成后解决该评论。
### Pull Request 检测模板结构验证检查
作为 PR 检查的一部分,我们会运行结构验证,以确保包含 YAML 结构的所有必需部分。对于检测,必须包含一个新部分。有关更多信息,请参阅 [贡献指南](https://github.com/Azure/Azure-Sentinel/wiki/Contribute-to-Sentinel-GitHub-Community-of-Queries#now-onto-the-how)。如果缺少此部分或任何其他必需部分,则会出现类似于以下内容的验证错误。
该示例特指 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 , but found System.ComponentModel.DataAnnotations.ValidationException with message "An old mapping for entity 'AccountCustomEntity' does not have a matching new mapping entry."
```
### Pull Request KQL 验证检查
作为 PR 检查的一部分,我们会运行模板中定义的 KQL 查询的语法验证。如果此检查失败,请转到 Azure Pipeline(通过按 PR 中“检查”选项卡上的错误链接)

在管道中,您可以看到哪个测试失败以及原因:

错误消息示例:
```
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 验证
为了在提交 Pull Request 之前在本地机器上运行 KQL 验证:
* 您需要安装 **.Net Core 3.1 SDK** [如何下载 .Net](https://dotnet.microsoft.com/download) (支持所有平台)
* 打开 Shell 并导航到 `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 列表](https://github.com/Azure/Azure-Sentinel/blob/master/.script/tests/detectionTemplateSchemaValidation/ValidConnectorIds.json))等。
格式错误或缺少属性将导致信息丰富的检查失败,这将指导您解决问题,但请务必查看已批准检测的格式。
### 本地运行检测架构验证
为了在提交 Pull Request 之前在本地机器上运行 KQL 验证:
* 您需要安装 **.Net Core 3.1 SDK** [如何下载 .Net](https://dotnet.microsoft.com/download) (支持所有平台)
* 打开 Shell 并导航到 `Azure-Sentinel\\.script\tests\DetectionTemplateSchemaValidation\`
* 执行 `dotnet test`
当您提交拉取请求时,CLA-bot 将自动确定您是否需要提供
CLA 并相应地装饰 PR(例如,标签、评论)。只需按照
bot 提供的说明进行操作。对于我们所有使用 CLA 的仓库,您只需执行一次此操作。
本项目已采用 [Microsoft 开源行为准则](https://opensource.microsoft.com/codeofconduct/)。
有关更多信息,请参阅 [行为准则常见问题解答](https://opensource.microsoft.com/codeofconduct/faq/) 或
联系 [opencode@microsoft.com](mailto:opencode@microsoft.com) 提出任何其他问题或评论。
有关您可以贡献的内容及更多详细信息,请参阅项目 [wiki](https://aka.ms/threathunters) 上的 [“get started”](https://github.com/Azure/Azure-Sentinel/wiki#get-started) 部分。
标签:AMSI绕过, Azure 安全中心, Kusto 查询语言 (KQL), Microsoft 365 Defender, Microsoft Sentinel, 企业安全, 威胁搜寻, 威胁检测, 安全剧本, 安全工作簿, 安全编排自动化与响应 (SOAR), 安全运营中心 (SOC), 攻击调查, 网络安全, 网络资产管理, 隐私保护