From ef623935a886f5046f5c63bd1b6975fd75600613 Mon Sep 17 00:00:00 2001 From: AMAZZAL Date: Mon, 1 May 2023 21:46:31 +0100 Subject: [PATCH] fix dlp dict phrases patterns issue typo & idm_profile_match_accuracy (#228) * fix dlp dict phrases patterns issue typo * Added zia_dlp_idm_profiles_lite * Updated to zscaler-sdk-go v1.4.4 * Added new zia_dlp_dictionaries attributes * fix binNumbers panic issue * Added computed and removed other readonly a attrib * Updated CHANGELOG and release-notes * remove name from flattenIDMProfileMatchAccuracySimple * check custom_phrase_match_type * Update zia_dlp_dictionaries docs --- docs/data-sources/zia_dlp_dictionaries.md | 6 +++ docs/resources/zia_dlp_dictionaries.md | 7 ++- zia/data_source_zia_dlp_dictionaries.go | 56 ++++++++++++++++++++++- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/docs/data-sources/zia_dlp_dictionaries.md b/docs/data-sources/zia_dlp_dictionaries.md index eb32a033..16851218 100644 --- a/docs/data-sources/zia_dlp_dictionaries.md +++ b/docs/data-sources/zia_dlp_dictionaries.md @@ -42,3 +42,9 @@ In addition to all arguments above, the following attributes are exported: * `action` - (String) The action applied to a DLP dictionary using patterns * `pattern` - (String) DLP dictionary pattern +* `ignore_exact_match_idm_dict` - (Boolean) Indicates whether to exclude documents that are a 100% match to already-indexed documents from triggering an Indexed Document Match (IDM) Dictionary. +* `include_bin_numbers` - (Boolean) A true value denotes that the specified Bank Identification Number (BIN) values are included in the Credit Cards dictionary. A false value denotes that the specified BIN values are excluded from the Credit Cards dictionary. Note: This field is applicable only to the predefined Credit Cards dictionary and its clones. +* `bin_numbers` - (Boolean) The list of Bank Identification Number (BIN) values that are included or excluded from the Credit Cards dictionary. BIN values can be specified only for Diners Club, Mastercard, RuPay, and Visa cards. Up to 512 BIN values can be configured in a dictionary. Note: This field is applicable only to the predefined Credit Cards dictionary and its clones. +* `dict_template_id` - (Number) ID of the predefined dictionary (original source dictionary) that is used for cloning. This field is applicable only to cloned dictionaries. Only a limited set of identification-based predefined dictionaries (e.g., Credit Cards, Social Security Numbers, National Identification Numbers, etc.) can be cloned. Up to 4 clones can be created from a predefined dictionary. +* `predefined_clone` - (Boolean) This field is set to true if the dictionary is cloned from a predefined dictionary. Otherwise, it is set to false. +* `custom` - (Boolean) This value is set to true for custom DLP dictionaries. diff --git a/docs/resources/zia_dlp_dictionaries.md b/docs/resources/zia_dlp_dictionaries.md index c388b60d..d2816b9a 100644 --- a/docs/resources/zia_dlp_dictionaries.md +++ b/docs/resources/zia_dlp_dictionaries.md @@ -43,6 +43,7 @@ The following arguments are supported: * `custom_phrase_match_type` - (Required) The DLP custom phrase match type. Supported values are: * `MATCH_ALL_CUSTOM_PHRASE_PATTERN_DICTIONARY` * `MATCH_ANY_CUSTOM_PHRASE_PATTERN_DICTIONARY` + Note: This attribute should only be set when the dictionary_type is set to ``PATTERNS_AND_PHRASES`` * `phrases` - (Required) List containing the phrases used within a custom DLP dictionary. This attribute is not applicable to predefined DLP dictionaries. Required when `dictionary_type` is `PATTERNS_AND_PHRASES` * `action` - (Required) The action applied to a DLP dictionary using patterns. The following values are supported: @@ -105,5 +106,7 @@ The following arguments are supported: - `"HEAVY"` * `proximity` - (Optional) The DLP dictionary proximity length. -* `custom` - (Optional) This value is set to true for custom DLP dictionaries. -* `proximity_length_enabled` - (Optional) This value is set to true if proximity length and high confidence phrases are enabled for the DLP dictionary. +* `ignore_exact_match_idm_dict` - (Optional) Indicates whether to exclude documents that are a 100% match to already-indexed documents from triggering an Indexed Document Match (IDM) Dictionary. +* `include_bin_numbers` - (Optional) A true value denotes that the specified Bank Identification Number (BIN) values are included in the Credit Cards dictionary. A false value denotes that the specified BIN values are excluded from the Credit Cards dictionary. Note: This field is applicable only to the predefined Credit Cards dictionary and its clones. +* `bin_numbers` - (Optional) The list of Bank Identification Number (BIN) values that are included or excluded from the Credit Cards dictionary. BIN values can be specified only for Diners Club, Mastercard, RuPay, and Visa cards. Up to 512 BIN values can be configured in a dictionary. Note: This field is applicable only to the predefined Credit Cards dictionary and its clones. +* `dict_template_id` - (Optional) ID of the predefined dictionary (original source dictionary) that is used for cloning. This field is applicable only to cloned dictionaries. Only a limited set of identification-based predefined dictionaries (e.g., Credit Cards, Social Security Numbers, National Identification Numbers, etc.) can be cloned. Up to 4 clones can be created from a predefined dictionary. diff --git a/zia/data_source_zia_dlp_dictionaries.go b/zia/data_source_zia_dlp_dictionaries.go index aa86df0b..58742f50 100644 --- a/zia/data_source_zia_dlp_dictionaries.go +++ b/zia/data_source_zia_dlp_dictionaries.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zscaler/zscaler-sdk-go/zia/services/common" "github.com/zscaler/zscaler-sdk-go/zia/services/dlpdictionaries" ) @@ -26,6 +27,10 @@ func dataSourceDLPDictionaries() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "custom": { + Type: schema.TypeBool, + Computed: true, + }, "confidence_threshold": { Type: schema.TypeString, Computed: true, @@ -129,6 +134,11 @@ func dataSourceDLPDictionaries() *schema.Resource { Computed: true, Description: "Identifier that uniquely identifies an entity", }, + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "extensions": { Type: schema.TypeMap, Computed: true, @@ -152,6 +162,37 @@ func dataSourceDLPDictionaries() *schema.Resource { Computed: true, Description: "The DLP dictionary proximity length.", }, + "ignore_exact_match_idm_dict": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether to exclude documents that are a 100% match to already-indexed documents from triggering an Indexed Document Match (IDM) Dictionary.", + }, + "include_bin_numbers": { + Type: schema.TypeBool, + Computed: true, + Description: "A true value denotes that the specified Bank Identification Number (BIN) values are included in the Credit Cards dictionary. A false value denotes that the specified BIN values are excluded from the Credit Cards dictionary.Note: This field is applicable only to the predefined Credit Cards dictionary and its clones.", + }, + "bin_numbers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeInt}, + Description: "The list of Bank Identification Number (BIN) values that are included or excluded from the Credit Cards dictionary. BIN values can be specified only for Diners Club, Mastercard, RuPay, and Visa cards. Up to 512 BIN values can be configured in a dictionary. Note: This field is applicable only to the predefined Credit Cards dictionary and its clones.", + }, + "dict_template_id": { + Type: schema.TypeInt, + Computed: true, + Description: "ID of the predefined dictionary (original source dictionary) that is used for cloning. This field is applicable only to cloned dictionaries. Only a limited set of identification-based predefined dictionaries (e.g., Credit Cards, Social Security Numbers, National Identification Numbers, etc.) can be cloned. Up to 4 clones can be created from a predefined dictionary.", + }, + "predefined_clone": { + Type: schema.TypeBool, + Computed: true, + Description: "This field is set to true if the dictionary is cloned from a predefined dictionary. Otherwise, it is set to false.", + }, + "proximity_length_enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "This value is set to true if proximity length and high confidence phrases are enabled for the DLP dictionary.", + }, }, } } @@ -183,11 +224,19 @@ func dataSourceDLPDictionariesRead(d *schema.ResourceData, m interface{}) error d.SetId(fmt.Sprintf("%d", resp.ID)) _ = d.Set("name", resp.Name) _ = d.Set("description", resp.Description) + _ = d.Set("custom", resp.Custom) _ = d.Set("confidence_threshold", resp.ConfidenceThreshold) _ = d.Set("custom_phrase_match_type", resp.CustomPhraseMatchType) _ = d.Set("name_l10n_tag", resp.NameL10nTag) _ = d.Set("threshold_type", resp.ThresholdType) _ = d.Set("dictionary_type", resp.DictionaryType) + _ = d.Set("ignore_exact_match_idm_dict", resp.IgnoreExactMatchIdmDict) + _ = d.Set("include_bin_numbers", resp.IncludeBinNumbers) + _ = d.Set("bin_numbers", resp.BinNumbers) + _ = d.Set("dict_template_id", resp.DictTemplateId) + _ = d.Set("predefined_clone", resp.PredefinedClone) + _ = d.Set("proximity_length_enabled", resp.ProximityLengthEnabled) + _ = d.Set("proximity", resp.Proximity) if err := d.Set("phrases", flattenPhrases(resp)); err != nil { return err } @@ -251,9 +300,14 @@ func flattenEDMDetails(edm *dlpdictionaries.DlpDictionary) []interface{} { func flattenIDMProfileMatchAccuracy(edm *dlpdictionaries.DlpDictionary) []interface{} { idmProfileMatchAccuracies := make([]interface{}, len(edm.IDMProfileMatchAccuracy)) for i, val := range edm.IDMProfileMatchAccuracy { + exts := []common.IDNameExtensions{} + if val.AdpIdmProfile != nil { + exts = append(exts, *val.AdpIdmProfile) + } + idmProfileMatchAccuracies[i] = map[string]interface{}{ "match_accuracy": val.MatchAccuracy, - "adp_idm_profile": val.AdpIdmProfile, + "adp_idm_profile": flattenIDNameExtensions(exts), } }