Atualizar uma regra para ignorar
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Demonstra como atualizar uma regra de silenciamento
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to update a mute rule\n\nCode sample \n\nGo\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 \t\"google.golang.org/protobuf/types/known/fieldmaskpb\"\n )\n\n // updateMuteRule Updates an existing mute configuration.\n // The following can be updated in a mute config: description and filter.\n func updateMuteRule(w io.Writer, muteConfigName string) error {\n \t// Specify the name of the mute config to delete.\n \t// muteConfigName: Use any one of the following formats:\n \t// - organizations/{organization}/muteConfigs/{config_id}\n \t// - folders/{folder}/muteConfigs/{config_id}\n \t// - projects/{project}/muteConfigs/{config_id}\n \t// muteConfigName := fmt.Sprintf(\"projects/%s/muteConfigs/%s\", \"project-id\", \"mute-config\")\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 \tupdateMuteConfig := &securitycenterpb.MuteConfig{\n \t\tName: muteConfigName,\n \t\tDescription: \"Updated mute config description\",\n \t}\n\n \treq := &securitycenterpb.UpdateMuteConfigRequest{\n \t\tMuteConfig: updateMuteConfig,\n \t\t// Set the update mask to specify which properties of the mute config should be\n \t\t// updated.\n \t\t// If empty, all mutable fields will be updated.\n \t\t// Make sure that the mask fields match the properties changed in 'updateMuteConfig'.\n \t\t// For more info on constructing update mask path, see the proto or:\n \t\t// https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters\n \t\tUpdateMask: &fieldmaskpb.FieldMask{\n \t\t\tPaths: []string{\n \t\t\t\t\"description\",\n \t\t\t},\n \t\t},\n \t}\n\n \tresponse, err := client.UpdateMuteConfig(ctx, req)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"mute rule update failed! %w\", err)\n \t}\n \tfmt.Fprintf(w, \"Mute rule updated %s\", response.Name)\n \treturn nil\n }\n\nJava\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.MuteConfig.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.UpdateMuteConfigRequest.html;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html;\n import java.io.IOException;\n\n public class UpdateMuteRule {\n\n public static void main(String[] args) {\n // TODO: Replace the variables within {}\n\n // Specify the name of the mute config to delete.\n // muteConfigName: Use any one of the following formats:\n // - organizations/{organization}/muteConfigs/{config_id}\n // - folders/{folder}/muteConfigs/{config_id}\n // - projects/{project}/muteConfigs/{config_id}\n String muteConfigName = \"{any-one-of-the-above-formats}\";\n updateMuteRule(muteConfigName);\n }\n\n // Updates an existing mute configuration.\n // The following can be updated in a mute config: description and filter.\n public static void updateMuteRule(String muteConfigName) {\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 securityCenterClient = 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.MuteConfig.html updateMuteConfig =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.MuteConfig.html.newBuilder()\n .setName(muteConfigName)\n .setDescription(\"Updated mute config description\")\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest.html updateMuteConfigRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest.html.newBuilder()\n .setMuteConfig(updateMuteConfig)\n // Set the update mask to specify which properties of the mute config should be\n // updated.\n // If empty, all mutable fields will be updated.\n // Make sure that the mask fields match the properties changed in 'updateMuteConfig'.\n // For more info on constructing update mask path, see the proto or:\n // https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters\n .setUpdateMask(https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html.newBuilder().https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.Builder.html#com_google_protobuf_FieldMask_Builder_addPaths_java_lang_String_(\"description\").build())\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.MuteConfig.html response = securityCenterClient.updateMuteConfig(updateMuteConfigRequest);\n System.out.println(response);\n } catch (IOException e) {\n System.out.println(\"Mute rule update failed! \\n Exception: \" + e);\n }\n }\n }\n\nPython\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 update_mute_rule(mute_config_name: str) -\u003e None:\n \"\"\"\n Updates an existing mute configuration.\n The following can be updated in a mute config: description, and filter/ mute rule.\n Args:\n mute_config_name: Specify the name of the mute config to delete.\n Use any one of the following formats:\n - organizations/{organization}/muteConfigs/{config_id}\n - folders/{folder}/muteConfigs/{config_id}\n - projects/{project}/muteConfigs/{config_id}\n \"\"\"\n from google.cloud import securitycenter\n from google.protobuf import field_mask_pb2\n\n client = securitycenter.SecurityCenterClient()\n\n update_mute_config = securitycenter.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.types.MuteConfig.html()\n update_mute_config.name = mute_config_name\n update_mute_config.description = \"Updated mute config description\"\n\n field_mask = field_mask_pb2.FieldMask(paths=[\"description\"])\n\n request = securitycenter.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.types.UpdateMuteConfigRequest.html()\n request.mute_config = update_mute_config\n # Set the update mask to specify which properties of the Mute Config should be updated.\n # If empty, all mutable fields will be updated.\n # Make sure that the mask fields match the properties changed in 'update_mute_config'.\n # For more info on constructing update mask path, see the proto or:\n # https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters\n request.update_mask = field_mask\n\n mute_config = 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_update_mute_config(request)\n print(f\"Updated mute rule : {mute_config}\")\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=securitycenter)."]]