security-automation について
セキュリティ運用を自動化するスキルで、自動修復、SOAR プレイブック、コンプライアンスチェックを扱います。セキュリティパイプラインや再現可能な対応プロセスを構築するチーム向けです。
主な機能
- 01セキュリティパイプラインの自動化
- 02自動修復スクリプト
- 03SOAR プレイブックの例
- 04カスタムコンプライアンスチェック
- 05ステージングテストと手動承認
活用シーン
- 01CI ワークフローでのセキュリティ検査の自動化
- 02S3 バケットの公開アクセスの修復
- 03不審なログインアラートの情報補強と対応
- 04独自のインフラコンプライアンスルールの追加
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ bagelhole/ devops-security-agent-skills --skill security-automationインストール後、Claude Code で/security-automationを入力して読み込まれたか確認します。
詳細
セキュリティ自動化
セキュリティ運用を自動化し、規模と効率性を高めます。
セキュリティパイプライン
# .github/workflows/security.yml
name: Security Pipeline
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Secret Scanning
uses: trufflesecurity/trufflehog@main
- name: SAST
uses: returntocorp/semgrep-action@v1
- name: Dependency Scan
run: npm audit --audit-level=high
- name: Container Scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
- name: Compliance Check
run: |
checkov -d . --framework terraform
自動修復
# Auto-remediation script
def remediate_public_s3(bucket_name):
"""Remove public access from S3 bucket."""
s3 = boto3.client('s3')
s3.put_public_access_block(
Bucket=bucket_name,
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)
SOAR 連携
playbook:
name: Suspicious Login Response
trigger: alert.type == "suspicious_login"
actions:
- enrich_ip:
source: threat_intel
- if_condition: ip.is_malicious
then:
- block_ip:
firewall: cloudflare
- disable_user:
duration: 1h
- notify:
channel: security
- create_ticket:
priority: high
コードとしてのコンプライアンス
# Checkov custom check
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
class S3Encryption(BaseResourceCheck):
def __init__(self):
name = "Ensure S3 bucket has encryption enabled"
id = "CUSTOM_S3_1"
supported_resources = ['aws_s3_bucket']
super().__init__(name=name, id=id, ...)
def scan_resource_conf(self, conf):
if 'server_side_encryption_configuration' in conf:
return CheckResult.PASSED
return CheckResult.FAILED
ベストプラクティス
- 影響の大きい自動化から始める
- まずステージング環境でテストする
- 手動レビューの承認ポイントを設ける
- 自動化の有効性を監視する
- ルールを定期的に更新する
関連スキル
- github-actions - CI/CD 自動化
- policy-as-code - ポリシー適用
コメント
Markdown 対応