推奨設定の検索は、IPS、変更監視、およびログ検査のルールを特定し、コンピュータまたはポリシーに割り当てるか削除する必要があります。APIは、コンピュータおよびポリシーレベルでこれらの保護モジュールの推奨検索結果にアクセスするための次のクラスを提供します。
ComputerIntrusionPreventionAssignmentsRecommendationsApiComputerIntegrityMonitoringAssignmentsRecommendationsApiComputerLogInspectionAssignmentsRecommendationsApiPolicyIntrusionPreventionAssignmentsRecommendationsApiPolicyIntegrityMonitoringAssignmentsRecommendationsApiPolicyLogInspectionAssignmentsRecommendationsApi
これらのクラスのメソッドと関数は、最新の推奨事項と検索情報を含むオブジェクトを返します。以下のJSONは、返されたオブジェクトのデータ構造を表しています。
{
"assignedRuleIDs": [],
"recommendationScanStatus": "valid",
"lastRecommendationScanDate": "1562702362438",
"recommendedToAssignRuleIDs": [],
"recommendedToUnassignRuleIDs": []
}
PolicyIntrusionPreventionAssignmentsRecommendationsApiPolicyIntegrityMonitoringAssignmentsRecommendationsApiPolicyLogInspectionAssignmentsRecommendationsApi
推奨検索が実行されると、IPS、変更監視、およびログ検査セキュリティモジュールの推奨事項が決定されます。そのため、
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オブジェクトを作成し、IPSルールの割り当てと推奨事項を一覧表示します。- 返された
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は、変更監視、IPS、およびログ検査のためのコンピュータの推奨検索結果へのアクセスを提供します。
ComputerIntrusionPreventionAssignmentsRecommendationsApiオブジェクトを使用して、コンピュータのIntrusionPreventionAssignmentsオブジェクトを取得します。IntrusionPreventionAssignmentsオブジェクトは、そのコンピュータの推奨事項を含み、アクセスを提供します。- 割り当ておよび割り当て解除するための推奨IPSルール
- 検索ステータス
- 最後の検索日時
ルールの推奨を取得した後、コンピュータのポリシーにIPSルールを追加する例に示されているように、それらをコンピュータポリシーに適用できます。
推奨検索がコンピュータで実行されていない場合、
ComputerIntrusionPreventionAssignmentsRecommendationsApiはルールIDと最後の検索発生に対してnullを返します。変更監視とログ検査のために同様のクラスが提供されています。
- 変更監視
ComputerIntegrityMonitoringAssignmentsRecommendationsApiIntegrityMonitoringAssignments
- セキュリティログ監視
ComputerLogInspectionAssignmentsRecommendationsApiLogInspectionAssignments
次の例は、コンピュータのIPSに対する推奨事項を取得します。
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での認証を参照してください。
