1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Microsoft Sentinel でスクリプトを用いてテンプレートルールを一括で有効化させる

Last updated at Posted at 2022-03-25

1. はじめに

Microsoft Sentinel を構築する際に、分析ルールを用いて異常な振る舞いをインシデントとして検知することになります。
分析ルールは Azure Portal (Sentinel) の画面からだと 1 ルール単位で有効化する必要があり、手間がかかってしまいます。
本記事は、GitHub で公開されているツールを用いて、スクリプトベースで有効化する方法をご紹介致します。

2. ツールについて

今回用いたツールはこちらです。Microsoft 認定のツールではありませんが、Author の Jan さんは Most Valuable Professional として認定された方になります。

alertRuleFromGHToSentinel
紹介されたブログ記事
https://emptydc.com/2021/03/19/alertrule-from-github-to-azure-sentinel/
Author 紹介
https://mvp.microsoft.com/en-us/PublicProfile/5003550

3. 利用イメージ

Microsoft Azure のテンプレートルールは GitHub でアジャイルに開発されており、YAML 形式で随時更新されています。Sentinel の分析ルール画面からは GitHub レポジトリの情報とリンクされており、テンプレートを元にデプロイする仕組みが取られています。
今回は、テンプレートルール適用の自動化を目的として、スクリプトを用いて自環境の Sentinel に対して適用することを実践してみます。

4. GitHub 上の Sentinel 分析ルールテンプレートについて

GitHub のSentinel 分析ルールテンプレートはこちらになります。
https://github.com/Azure/Azure-Sentinel/tree/master/Detections
詳細は wiki に情報がまとまっていますので参考としてください。
https://github.com/Azure/Azure-Sentinel/wiki

Sentinel 側で表示されるログソースの単位と、GitHub 上のフォルダが一致していないものもあるので、選定するルールについては一定の理解が必要です。
例:AzureActiveDirectory は SigninLogs と AuditLogs に分割されているなど 

5. ツールを触ってみる

PowerShell なので、今回は Azure Cloud Shell を用いた手順を試してみました。

  • Cloud Shell を起動する (PowerShell モード)

    • image.png
  • スクリプトをダウンロードする

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jangeisbauer/sentinel/main/alertRuleFromGHToSentinel.ps1" -OutFile "alertRuleFromGHToSentinel.ps1"
  • スクリプトを利用して、必要となるモジュールをインストール
import-module .\alertRuleFromGHToSentinel.ps1 
  • Azure GitHub より対象となるルールを選択し、デプロイする
    • GitHub の対象ルールのRAWデータリンクを直指定すること
    • Sentinel のリソースグループ、Log Analytics のワークスペース名を指定する
 New-AzSentinelAlertRuleFromGitHub -resourceGroupName "(リソースグループ)" -workspaceName "(Log Analytics ワークスペース名)" -gitHubRawUrl "(Azure Sentinel GitHub Analytics ルールのYAMLファイルのRAWデータリンク)"

New-AzSentinelAlertRuleFromGitHub -resourceGroupName "rg-name" -workspaceName "ws-name" -gitHubRawUrl "https://github.com/Azure/Azure-Sentinel/tree/master/Detections/SecurityEvent" -isGitHubDirectoryUrl $true

New-AzSentinelAlertRuleFromGitHub -resourceGroupName "rg-name" -workspaceName "ws-name" -gitHubRawUrl "https://github.com/Azure/Azure-Sentinel/tree/master/Detections/SecurityEvent" -isGitHubDirectoryUrl $true
  • 一括で分析ルールを有効化してくれるので楽!
    image.png

7. まとめ

以上、Microsoft Sentinel のルールをスクリプトツールで有効化する方法をご紹介致しました。
Sentinel を設計導入する際に、Azure Portal からの操作だと大変でしたが、スクリプト化して一括適用出来るようになるとかなり改善されるのではないかと思います。どなたかの参考になれば幸いです。

*本稿は、個人の見解に基づいた内容であり、所属する会社の公式見解ではありません。また、いかなる保証を与えるものでもありません。正式な情報は、各製品の販売元にご確認ください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?