Skip to content

Commit

Permalink
azurerm_sentinel_data_connector_microsoft_threat_intelligence - rem…
Browse files Browse the repository at this point in the history
…ove deprecated property `bing_safety_phishing_url_lookback_date` (#27171)

* remove deprecated property bing_safety_phishing_url_lookback_date

* update doc
  • Loading branch information
catriona-m authored Aug 23, 2024
1 parent a78ea70 commit 06775c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2022-10-01/workspaces"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel/validate"
Expand All @@ -27,7 +26,6 @@ type DataConnectorMicrosoftThreatIntelligenceModel struct {
Name string `tfschema:"name"`
WorkspaceId string `tfschema:"log_analytics_workspace_id"`
TenantId string `tfschema:"tenant_id"`
BingSafetyPhishingUrlLookBackDate string `tfschema:"bing_safety_phishing_url_lookback_date"`
MicrosoftEmergingThreatFeedLookBackDate string `tfschema:"microsoft_emerging_threat_feed_lookback_date"`
}

Expand All @@ -37,7 +35,7 @@ type DataConnectorMicrosoftThreatIntelligenceDataType struct {
}

func (s DataConnectorMicrosoftThreatIntelligenceResource) Arguments() map[string]*schema.Schema {
res := map[string]*schema.Schema{
return map[string]*schema.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
Expand All @@ -64,32 +62,10 @@ func (s DataConnectorMicrosoftThreatIntelligenceResource) Arguments() map[string
"microsoft_emerging_threat_feed_lookback_date": {
Type: pluginsdk.TypeString,
ForceNew: true,
Optional: !features.FourPointOh(),
Required: features.FourPointOh(),
Required: true,
ValidateFunc: validation.IsRFC3339Time,
AtLeastOneOf: func() []string {
if !features.FourPointOh() {
return []string{"bing_safety_phishing_url_lookback_date", "microsoft_emerging_threat_feed_lookback_date"}
}
return []string{}
}(),
},
}

if !features.FourPointOh() {
// this has been removed in newer API version, and it's actually not working in current API version
// TODO Remove in 4.0
res["bing_safety_phishing_url_lookback_date"] = &schema.Schema{
Deprecated: "This field is deprecated and will be removed in version 4.0 of the AzureRM Provider.",
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.IsRFC3339Time,
AtLeastOneOf: []string{"bing_safety_phishing_url_lookback_date", "microsoft_emerging_threat_feed_lookback_date"},
}
}

return res
}

func (s DataConnectorMicrosoftThreatIntelligenceResource) Attributes() map[string]*schema.Schema {
Expand Down Expand Up @@ -140,7 +116,6 @@ func (s DataConnectorMicrosoftThreatIntelligenceResource) Create() sdk.ResourceF
Kind: securityinsight.KindBasicDataConnectorKindMicrosoftThreatIntelligence,
MSTIDataConnectorProperties: &securityinsight.MSTIDataConnectorProperties{
DataTypes: &securityinsight.MSTIDataConnectorDataTypes{
BingSafetyPhishingURL: expandSentinelDataConnectorMicrosoftThreatIntelligenceBingSafetyPhishingUrl(metaModel),
MicrosoftEmergingThreatFeed: expandSentinelDataConnectorMicrosoftThreatIntelligenceMicrosoftEmergingThreatFeed(metaModel),
},
TenantID: &tenantId,
Expand Down Expand Up @@ -193,14 +168,6 @@ func (s DataConnectorMicrosoftThreatIntelligenceResource) Read() sdk.ResourceFun
}

if dt := dc.DataTypes; dt != nil {
if dt.BingSafetyPhishingURL != nil {
if strings.EqualFold(string(dt.BingSafetyPhishingURL.State), string(securityinsight.DataTypeStateEnabled)) {
state.BingSafetyPhishingUrlLookBackDate, err = flattenSentinelDataConnectorMicrosoftThreatIntelligenceTime(*dt.BingSafetyPhishingURL.LookbackPeriod)
if err != nil {
return fmt.Errorf("flattening `bing_safety_phishing_url`: %+v", err)
}
}
}
if dt.MicrosoftEmergingThreatFeed != nil {
if strings.EqualFold(string(dt.MicrosoftEmergingThreatFeed.State), string(securityinsight.DataTypeStateEnabled)) {
state.MicrosoftEmergingThreatFeedLookBackDate, err = flattenSentinelDataConnectorMicrosoftThreatIntelligenceTime(*dt.MicrosoftEmergingThreatFeed.LookbackPeriod)
Expand Down Expand Up @@ -240,20 +207,6 @@ func (s DataConnectorMicrosoftThreatIntelligenceResource) IDValidationFunc() plu
return validate.DataConnectorID
}

func expandSentinelDataConnectorMicrosoftThreatIntelligenceBingSafetyPhishingUrl(input DataConnectorMicrosoftThreatIntelligenceModel) *securityinsight.MSTIDataConnectorDataTypesBingSafetyPhishingURL {
if input.BingSafetyPhishingUrlLookBackDate == "" {
return &securityinsight.MSTIDataConnectorDataTypesBingSafetyPhishingURL{
LookbackPeriod: utils.String(""),
State: securityinsight.DataTypeStateDisabled,
}
}

return &securityinsight.MSTIDataConnectorDataTypesBingSafetyPhishingURL{
LookbackPeriod: utils.String(input.BingSafetyPhishingUrlLookBackDate),
State: securityinsight.DataTypeStateEnabled,
}
}

func expandSentinelDataConnectorMicrosoftThreatIntelligenceMicrosoftEmergingThreatFeed(input DataConnectorMicrosoftThreatIntelligenceModel) *securityinsight.MSTIDataConnectorDataTypesMicrosoftEmergingThreatFeed {
if input.MicrosoftEmergingThreatFeedLookBackDate == "" {
return &securityinsight.MSTIDataConnectorDataTypesMicrosoftEmergingThreatFeed{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ The following arguments are supported:

* `log_analytics_workspace_id` - (Required) The ID of the Log Analytics Workspace. Changing this forces a new Data Connector to be created.

* `microsoft_emerging_threat_feed_lookback_date` - (Optional) The lookback date for the Microsoft Emerging Threat Feed in RFC3339. Changing this forces a new Data Connector to be created.

-> **Note:** `microsoft_emerging_threat_feed_lookback_date` will be required in version 4.0 of the provider.

-> **NOTE:** At least one of `bing_safety_phishing_url_lookback_date` and `microsoft_emerging_threat_feed_lookback_date` must be specified.
* `microsoft_emerging_threat_feed_lookback_date` - (Required) The lookback date for the Microsoft Emerging Threat Feed in RFC3339. Changing this forces a new Data Connector to be created.

---

Expand Down

0 comments on commit 06775c7

Please sign in to comment.