Ergebnisse im Bulk-Vorgang ausblenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Zeigt, wie Sie vorhandene Ergebnisse basierend auf den von Ihnen angegebenen Filtern im Bulk ausblenden.
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[],[],null,["# Bulk-mute findings\n\nDemonstrates how to bulk-mute existing findings based on filters you specify.\n\nCode sample\n-----------\n\n### Go\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tsecuritycenter \"cloud.google.com/go/securitycenter/apiv1\"\n \t\"cloud.google.com/go/securitycenter/apiv1/securitycenterpb\"\n )\n\n // bulkMute kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.\n // The parent can be either an organization, folder, or project. The findings\n // matched by the filter will be muted after the LRO is done.\n func bulkMute(w io.Writer, parent string, muteRule string) error {\n \t// parent: Use any one of the following options:\n \t// - organizations/{organization_id}\n \t// - folders/{folder_id}\n \t// - projects/{project_id}\n \t// parent := fmt.Sprintf(\"projects/%s\", \"your-google-cloud-project-id\")\n \t// muteRule: Expression that identifies findings that should be muted.\n \t// To create mute rules, see:\n \t// https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules\n \t// muteRule := \"filter-condition\"\n \tctx := context.Background()\n \tclient, err := securitycenter.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_NewClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"securitycenter.NewClient: %w\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_Close()\n\n \treq := &securitycenterpb.BulkMuteFindingsRequest{\n \t\tParent: parent,\n \t\tFilter: muteRule,\n \t}\n\n \top, err := client.BulkMuteFindings(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to bulk mute findings: %w\", err)\n \t}\n \tresponse, err := op.Wait(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to bulk mute findings: %w\", err)\n \t}\n \tfmt.Fprintf(w, \"Bulk mute findings completed successfully! %s\", response)\n \treturn nil\n }\n\n### Java\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest.html;\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse.html;\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html;\n import java.io.IOException;\n import java.util.concurrent.ExecutionException;\n\n public class BulkMuteFindings {\n\n public static void main(String[] args) {\n // TODO: Replace the variables within {}\n\n // parentPath: Use any one of the following options:\n // - organizations/{organization_id}\n // - folders/{folder_id}\n // - projects/{project_id}\n String parentPath = String.format(\"projects/%s\", \"your-google-cloud-project-id\");\n\n // muteRule: Expression that identifies findings that should be muted.\n // eg: \"resource.project_display_name=\\\"PROJECT_ID\\\"\"\n String muteRule = \"{filter-condition}\";\n\n bulkMute(parentPath, muteRule);\n }\n\n // Kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.\n // The parent can be either an organization, folder, or project. The findings\n // matched by the filter will be muted after the LRO is done.\n public static void bulkMute(String parentPath, String muteRule) {\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html.create()) {\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest.html bulkMuteFindingsRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest.html.newBuilder()\n .setParent(parentPath)\n // To create mute rules, see:\n // https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules\n .setFilter(muteRule)\n .build();\n\n // ExecutionException is thrown if the below call fails.\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse.html response =\n client.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html#com_google_cloud_securitycenter_v1_SecurityCenterClient_bulkMuteFindingsAsync_com_google_api_resourcenames_ResourceName_(bulkMuteFindingsRequest).get();\n System.out.println(\"Bulk mute findings completed successfully! \" + response);\n } catch (IOException | InterruptedException | ExecutionException e) {\n System.out.println(\"Bulk mute findings failed! \\n Exception: \" + e);\n }\n }\n }\n\n### Python\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def bulk_mute_findings(parent_path: str, mute_rule: str) -\u003e None:\n \"\"\"\n Kicks off a long-running operation (LRO) to bulk mute findings for a parent based on a filter.\n The parent can be either an organization, folder, or project. The findings\n matched by the filter will be muted after the LRO is done.\n Args:\n parent_path: use any one of the following options:\n - organizations/{organization}\n - folders/{folder}\n - projects/{project}\n mute_rule: Expression that identifies findings that should be updated.\n \"\"\"\n from google.cloud import securitycenter\n\n client = securitycenter.SecurityCenterClient()\n\n request = securitycenter.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.types.BulkMuteFindingsRequest.html()\n request.parent = parent_path\n # To create mute rules, see:\n # https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules\n request.filter = mute_rule\n\n response = client.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.services.security_center.SecurityCenterClient.html#google_cloud_securitycenter_v1_services_security_center_SecurityCenterClient_bulk_mute_findings(request)\n print(f\"Bulk mute findings completed successfully! : {response}\")\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=securitycenter)."]]