目次

推奨検索でのルールの割り当て

推奨検索では、 侵入防御, 変更監視、および セキュリティログ監視 ルールは、コンピュータまたはポリシー。APIでは、次のクラスを使用して、コンピュータおよびポリシーレベルで、これらの保護モジュールごとに推奨検索の結果にアクセスできます。

  • ComputerIntrusionPreventionAssignmentsRecommendationsApi
  • ComputerIntegrityMonitoringAssignmentsRecommendationsApi
  • ComputerLogInspectionAssignmentsRecommendationsApi
  • PolicyIntrusionPreventionAssignmentsRecommendationsApi
  • PolicyIntegrityMonitoringAssignmentsRecommendationsApi
  • PolicyLogInspectionAssignmentsRecommendationsApi

これらのクラスのメソッドと関数は、最新の推奨事項と検索情報を含むオブジェクトを返します。次のJSONは、返されたオブジェクトのデータ構造を表します。

{
    "assignedRuleIDs": [],
    "recommendationScanStatus": "valid",
    "lastRecommendationScanDate": "1562702362438",
    "recommendedToAssignRuleIDs": [],
    "recommendedToUnassignRuleIDs": []
}

APIを使用して推奨設定の検索を実行するには、予約タスクを使用します。予約タスクを使用した保護の維持 ガイドを参照してください。

推奨設定の検索の詳細については、「推奨設定の検索の管理と実行」を参照してください。

推奨検索が最後に実行された日時を検索

コンピュータが最近検索されたことを確認する場合は、前回の推奨検索の日付を取得します。たとえば、推奨検索が実行されるようにスケジュールされているときにコンピュータがオフラインの場合、コンピュータは検索されません。検索が実行されたときに、環境内のコンピュータごとに検出されたスクリプトを実行できます。結果に応じて、必要に応じて推奨検索を実行できます。

次の一般的な手順を使用して、1台以上のコンピュータの前回の推奨検索の日付を取得します。

  1. ComputersApi オブジェクトを作成して、確認するコンピュータのIDを取得します。
  2. ComputerIntrusionPreventionAssignmentsRecommendationsApi オブジェクトを作成し、それを使用して 侵入防御 ルールの割り当てと推奨事項をリストします。
  3. 返された IntrusionPreventionAssignments オブジェクトから前回の検索日を取得します。

推奨検索が実行されると、 侵入防御, 変更監視および セキュリティログ監視 セキュリティモジュールの推奨設定が決定されます。したがって、 ComputerIntrusionPreventionAssignmentsRecommendationsApi, ComputerIntegrityMonitoringAssignmentsRecommendationsApiおよび ComputerLogInspectionAssignmentsRecommendationsApi のメソッドと関数は、前回の検索の日時と同じ値を返します。

たとえば、環境内のすべてのコンピュータのリストを取得します(IDのみが必要なため、 expand パラメータを none に設定して、最小情報を返します)。

expand = api.Expand(api.Expand.none)
computers_api = api.ComputersApi(api.ApiClient(configuration))
computers = computers_api.list_computers(api_version, expand=expand.list(), overrides=False)

各コンピュータについて、適用されたルールと推奨設定の検索結果を取得します。

computer_ips_assignments_recommendations_api = (
    api.ComputerIntrusionPreventionRuleAssignmentsRecommendationsApi(api.ApiClient(configuration)))
intrusion_prevention_assignments = (
    computer_ips_assignments_recommendations_api.list_intrusion_prevention_rule_ids_on_computer(
        computer.id,
        api_version,
        overrides=False)

最後に、前回の検索日を抽出します。推奨検索が実行されていない場合、プロパティは Noneです。

reco_scan_info = list()
if intrusion_prevention_assignments.last_recommendation_scan_date is not None:
    d = datetime.datetime.utcfromtimestamp(intrusion_prevention_assignments.last_recommendation_scan_date/1000)
    reco_scan_info.append(d.strftime('%Y-%m-%d %H:%M:%S'))
else:
    reco_scan_info.append("No scan on record")

「APIレファレンス/参照情報」の List 侵入防御 ルールID 操作も参照してください。

例:すべてのコンピュータの前回の推奨検索の日付を取得します。

次の例では、すべてのコンピュータのリストを取得し、前回の推奨検索の日時を確認します。この情報は、コンピュータのホスト名とともにカンマ区切り形式(CSV)形式で返され、スプレッドシートとして開くことができます。

ソースを表示

# Include minimal information in the returned Computer objects
expand = api.Expand(api.Expand.none)

# Get the list of computers and iterate over it
computers_api = api.ComputersApi(api.ApiClient(configuration))
computers = computers_api.list_computers(api_version, expand=expand.list(), overrides=False)

computer_ips_assignments_recommendations_api = (
    api.ComputerIntrusionPreventionRuleAssignmentsRecommendationsApi(api.ApiClient(configuration)))

for computer in computers.computers:
    # Get the recommendation scan information
    intrusion_prevention_assignments = (
        computer_ips_assignments_recommendations_api.list_intrusion_prevention_rule_ids_on_computer(
            computer.id,
            api_version,
            overrides=False))
    reco_scan_info = list()

    # Computer name
    reco_scan_info.append(computer.host_name)

    # Scan date
    if intrusion_prevention_assignments.last_recommendation_scan_date is not None:
        d = datetime.datetime.utcfromtimestamp(intrusion_prevention_assignments.last_recommendation_scan_date/1000)
        reco_scan_info.append(d.strftime('%Y-%m-%d %H:%M:%S'))
    else:
        reco_scan_info.append("No scan on record")

    # Scan status
    reco_scan_info.append(intrusion_prevention_assignments.recommendation_scan_status)

    # Add to the CSV string
    csv += format_for_csv(reco_scan_info)

return csv

推奨事項を適用する

APIを使用すると、整合性監視、侵入防御、およびログ検査モジュール用にコンピュータに対して行われた推奨検索結果にアクセスできます。 ComputerIntrusionPreventionAssignmentsRecommendationsApi オブジェクトを使用して、コンピュータの IntrusionPreventionAssignments オブジェクトを取得します。IntrusionPreventionAssignments オブジェクトには、そのコンピュータの推奨事項が含まれています。

  • 推奨 侵入防御 ルールの割り当てと割り当て解除
  • 検索ステータス
  • 最後の検索が実行されたとき

ルール推奨設定を取得したら、 侵入防御ルールをコンピュータのポリシー に追加する例に示すように、ルールの推奨設定をコンピュータポリシーに適用できます。

コンピュータで推奨検索が実行されていない場合、 ComputerIntrusionPreventionAssignmentsRecommendationsApinull を返し、ルールIDと前回の検索結果を表示します。

整合性監視およびログ検査モジュールにも同様のクラスが用意されています。

  • ComputerIntegrityMonitoringAssignmentsRecommendationsApi and IntegrityMonitoringAssignments
  • ComputerLogInspectionAssignmentsRecommendationsApi and LogInspectionAssignments

次の例では、コンピュータの 侵入防御 の推奨設定を取得します。

ソースを表示

ip_recommendations_api = api.ComputerIntrusionPreventionRuleAssignmentsRecommendationsApi(api.ApiClient(configuration))
ip_assignments = None

ip_assignments = ip_recommendations_api.list_intrusion_prevention_rule_ids_on_computer(computer_id, api_version, overrides=False)
return ip_assignments.recommended_to_assign_rule_ids

「APIレファレンス/参照情報」の List 侵入防御 ルールID 操作も参照してください。API呼び出しの認証の詳細については、 Workload Securityを参照してください。