Skip to content

Commit 127a273

Browse files
authored
fix(posture/accept-risk): allow expires_in=Never value (#641)
1 parent f9d57d8 commit 127a273

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sysdig/resource_sysdig_secure_accept_posture_risk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func resourceSysdigSecureAcceptPostureControlCreate(ctx context.Context, d *sche
127127
t := d.Get(SchemaEndTimeKey).(string)
128128
endTime, _ = strconv.ParseInt(t, 10, 64)
129129
}
130-
if endTime <= time.Now().UTC().UnixMilli() {
130+
if endTime > 0 && endTime <= time.Now().UTC().UnixMilli() {
131131
return diag.Errorf("Error creating accept risk. error status: %s err: %s", "ExpiresAt must be in the future", fmt.Errorf("ExpiresAt must be in the future"))
132132
}
133133
req.ExpiresAt = strconv.FormatInt(endTime, 10)

sysdig/resource_sysdig_secure_accept_posture_risk_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ func TestAcceptSecurePostureRisk(t *testing.T) {
1919
},
2020
},
2121
Steps: []resource.TestStep{
22+
{
23+
Config: acceptPostureRiskWithoutExpirationDate(),
24+
},
2225
{
2326
Config: acceptPostureRiskResource(),
2427
},
@@ -50,3 +53,14 @@ resource "sysdig_secure_posture_accept_risk" "accept_resource" {
5053
filter = "name in ('system:controller:daemon-set-s') and kind in ('ClusterRole')"
5154
}`
5255
}
56+
57+
func acceptPostureRiskWithoutExpirationDate() string {
58+
return `
59+
resource "sysdig_secure_posture_accept_risk" "accept_resource" {
60+
description = "test accept posture risk resource"
61+
control_name = "ServiceAccounts with cluster access"
62+
reason = "Risk Transferred"
63+
expires_in = "Never"
64+
filter = "name in ('system:controller:daemon-set-s') and kind in ('ClusterRole')"
65+
}`
66+
}

0 commit comments

Comments
 (0)