Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_sentinel_data_connector_microsoft_threat_intelligence - remove deprecated property bing_safety_phishing_url_lookback_date #27171

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading