AWS Security Hubのコントロールをワンライナーで一括無効化する
AWS Security Hubのコントロールは、必要に応じて無効化すると管理がしやすいです。
しかしながら、AWSマネジメントコンソールからAWS Security Hubのコントロールを一括無効化できません。
そこで、AWS Security Hubのコントロールをワンライナーで一括無効化してみます。
コントロールを手動で無効化する
まずは手動で無効化してみます。
セキュリティ基準から任意のコントロールを選択します。
「コントロールの無効化」を押下します。
無効化する理由を記載して、「無効化」を押下します。
無効化されました。
しかしながら、AWSマネジメントコンソールからAWS Security Hubのコントロールを一括無効化できません。
そのため、複数のコントロールを無効化する際は、先ほどの手順で1つずつ無効化する必要がありますが、時間がかかりミスの原因にもなります。
コントロールをワンライナーで一括無効化する
今度は、ワンライナーで一括無効化してみます。
コマンドの入力方法はいろいろありますが、今回はAWS CloudShellを使います。
今回は、「AWS 基礎セキュリティのベストプラクティス v1.0.0」のAPIGateway関連を一括無効化してみます。
以下のコマンドを実行します。
※コマンド冒頭の
awsAccountId=<awsAccountId>; for arn in $(aws securityhub describe-standards-controls --standards-subscription-arn "arn:aws:securityhub:ap-northeast-1:$awsAccountId:subscription/aws-foundational-security-best-practices/v/1.0.0" --query "Controls[].[StandardsControlArn]" --output text); do if [[ "$arn" =~ "APIGateway" ]]; then aws securityhub update-standards-control --control-status "DISABLED" --disabled-reason "監視不要のため" --standards-control-arn "$arn"; echo "$arn is Disabled"; else :; fi; done
以下が実行結果です。
※出力結果の
$ awsAccountId=<awsAccountId>; for arn in $(aws securityhub describe-standards-controls --standards-subscription-arn "arn:aws:securityhub:ap-northeast-1:$awsAccountId:subscription/aws-foundational-security-best-practices/v/1.0.0" --query "Controls[].[StandardsControlArn]" --output text); do if [[ "$arn" =~ "APIGateway" ]]; then aws securityhub update-standards-control --control-status "DISABLED" --disabled-reason "監視不要のため" --standards-control-arn "$arn"; echo "$arn is Disabled"; else :; fi; done arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.1 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.2 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.3 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.4 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.5 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.8 is Disabled arn:aws:securityhub:ap-northeast-1:<awsAccountId>:control/aws-foundational-security-best-practices/v/1.0.0/APIGateway.9 is Disabled
APIGateway関連のコントロールをいくつか見てみると、無効化されていることが確認できます。
まとめ
AWSマネジメントコンソールからAWS Security Hubのコントロールを一括無効化できません。
CLIからAPI経由で無効化できるので、必要に応じて一括無効化できるようなコマンドを用意しておくと便利です。