Ergebnis ausblenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Demonstriert, wie ein einzelnes Ergebnis manuell ausgeblendet wird
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,["# Mute a finding\n\nDemonstrates how to manually mute an individual finding\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 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 // setMute mutes an individual finding, can also unmute or reset the mute state of a finding.\n // If a finding is already muted, muting it again has no effect.\n // Various mute states are: UNDEFINED/MUTE/UNMUTE.\n func setMute(w io.Writer, findingPath string) error {\n \t// findingPath: The relative resource name of the finding. See:\n \t// https://cloud.google.com/apis/design/resource_names#relative_resource_name\n \t// Use any one of the following formats:\n \t// - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}\n \t// - folders/{folder_id}/sources/{source_id}/finding/{finding_id}\n \t// - projects/{project_id}/sources/{source_id}/finding/{finding_id}\n \t// findingPath := fmt.Sprintf(\"projects/%s/sources/%s/finding/%s\", \"your-google-cloud-project-id\", \"source\", \"finding-id\")\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.SetMuteRequest{\n \t\tName: findingPath,\n \t\tMute: securitycenterpb.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1/securitycenterpb.html#cloud_google_com_go_securitycenter_apiv1_securitycenterpb_Finding_MUTE_UNSPECIFIED_Finding_MUTED_Finding_UNMUTED_Finding_UNDEFINED}\n\n \tfinding, err := client.SetMute(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to set the specified mute value: %w\", err)\n \t}\n \tfmt.Fprintf(w, \"Mute value for the finding: %s is %s\", finding.Name, finding.Mute)\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.Finding.html;\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.html.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.Mute.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 com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SetMuteRequest.html;\n import java.io.IOException;\n\n public class SetMuteFinding {\n\n public static void main(String[] args) throws IOException {\n // TODO: Replace the variables within {}\n\n // findingPath: The relative resource name of the finding. See:\n // https://cloud.google.com/apis/design/resource_names#relative_resource_name\n // Use any one of the following formats:\n // - organizations/{organization_id}/sources/{source_id}/finding/{finding_id}\n // - folders/{folder_id}/sources/{source_id}/finding/{finding_id}\n // - projects/{project_id}/sources/{source_id}/finding/{finding_id}\n String findingPath = \"{path-to-the-finding}\";\n setMute(findingPath);\n }\n\n // Mute an individual finding.\n // If a finding is already muted, muting it again has no effect.\n // Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.\n public static https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.html setMute(String findingPath) throws IOException {\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.SetMuteRequest.html setMuteRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SetMuteRequest.html.newBuilder().setName(findingPath).setMute(https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.Mute.html.MUTED).build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.html finding = client.setMute(setMuteRequest);\n System.out.println(\n \"Mute value for the finding \" + finding.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.html#com_google_cloud_securitycenter_v1_Finding_getName__() + \" is: \" + finding.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.Finding.html#com_google_cloud_securitycenter_v1_Finding_getMute__());\n return finding;\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 set_mute_finding(finding_path: str) -\u003e None:\n \"\"\"\n Mute an individual finding.\n If a finding is already muted, muting it again has no effect.\n Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE.\n Args:\n finding_path: The relative resource name of the finding. See:\n https://cloud.google.com/apis/design/resource_names#relative_resource_name\n Use any one of the following formats:\n - organizations/{organization_id}/sources/{source_id}/finding/{finding_id},\n - folders/{folder_id}/sources/{source_id}/finding/{finding_id},\n - projects/{project_id}/sources/{source_id}/finding/{finding_id}.\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.SetMuteRequest.html()\n request.name = finding_path\n request.mute = securitycenter.Finding.Mute.MUTED\n\n finding = 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_set_mute(request)\n print(f\"Mute value for the finding: {finding.mute.name}\")\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)."]]