推奨設定の検索 は、侵入防御、変更監視、および セキュリティログ監視 のルールを特定し、コンピュータまたはポリシーに割り当てるか削除する必要があります。アプリケーションプログラミングインターフェース (API) は、次のクラスを介してコンピュータおよびポリシーレベルでこれらの保護モジュールの推奨スキャン結果にアクセスできます。
ComputerIntrusionPreventionAssignmentsRecommendationsApi
ComputerIntegrityMonitoringAssignmentsRecommendationsApi
ComputerLogInspectionAssignmentsRecommendationsApi
PolicyIntrusionPreventionAssignmentsRecommendationsApi
PolicyIntegrityMonitoringAssignmentsRecommendationsApi
PolicyLogInspectionAssignmentsRecommendationsApi
これらのクラスのメソッドと関数は、最新の推奨事項と検索情報を含むオブジェクトを返します。次のJSONは、返されたオブジェクトのデータ構造を表します。
{ "assignedRuleIDs": [], "recommendationScanStatus": "valid", "lastRecommendationScanDate": "1562702362438", "recommendedToAssignRuleIDs": [], "recommendedToUnassignRuleIDs": [] }
PolicyIntrusionPreventionAssignmentsRecommendationsApi
PolicyIntegrityMonitoringAssignmentsRecommendationsApi
PolicyLogInspectionAssignmentsRecommendationsApi
推奨設定スキャンが実行されると、侵入防御、変更監視、およびセキュリティログ監視のセキュリティモジュールに対する推奨設定が決定されます。したがって、
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を使用して推奨検索を実行するには、スケジュールされたタスクを使用します。また、APIレファレンスのIPSルールIDの一覧操作を参照してください。
推奨スキャンが最後に実行された日時を確認する
最後の推奨スキャンの日付を取得して、コンピュータが最近スキャンされたかどうかを確認してください。例えば、推奨スキャンが実行されるときにオフラインの場合、コンピュータがスキャンされないことがあります。環境内の各コンピュータに対して最後にスキャンが実行された時期を確認するスクリプトを実行できます。結果に応じて、すぐに推奨スキャンを実行することができます。
次の一般的な手順を使用して、1台以上のコンピュータの前回の推奨検索の日付を取得します。
手順
ComputersApi
オブジェクトを作成して、確認するコンピュータのIDを取得します。ComputerIntrusionPreventionAssignmentsRecommendationsApi
オブジェクトを作成し、それを使用して侵入防御ルールの割り当てと推奨設定を一覧表示します。- 返された
IntrusionPreventionAssignments
オブジェクトから最後のスキャンの日付を取得します。
例:すべてのコンピュータの前回の推奨検索の日付を取得します。
次の例では、すべてのコンピュータのリストを取得し、前回の推奨検索の日時を確認します。この情報は、コンピュータのホスト名とともにカンマ区切り形式(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
オブジェクトは、そのコンピュータの推奨設定を含み、アクセスを提供します。- 推奨 侵入防御 ルールの割り当てと割り当て解除
- 検索ステータス
- 最後の検索が実行されたとき
ルールの推奨設定を取得した後、コンピュータのポリシーにIPSルールを追加する例に示されているように、それらをコンピュータポリシーに適用できます。
推奨スキャンがコンピュータで実行されていない場合、
ComputerIntrusionPreventionAssignmentsRecommendationsApi
はルールIDと最後のスキャン発生に対してnull
を返します。変更監視とセキュリティログ監視には同様のクラスが提供されています。
- 変更監視
ComputerIntegrityMonitoringAssignmentsRecommendationsApi
IntegrityMonitoringAssignments
- セキュリティログ監視
ComputerLogInspectionAssignmentsRecommendationsApi
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レファレンスのIPSルールIDの一覧操作を参照してください。API呼び出しの認証に関する情報については、Workload Securityで認証するを参照してください。