Skip to content

Commit 1b02c0d

Browse files
committed
Add support for additional secure drift policy fields
1 parent c277875 commit 1b02c0d

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

sysdig/data_source_sysdig_secure_drift_policy.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ func createDriftPolicyDataSourceSchema() map[string]*schema.Schema {
4747
Computed: true,
4848
Elem: &schema.Resource{
4949
Schema: map[string]*schema.Schema{
50-
"id": ReadOnlyIntSchema(),
51-
"name": ReadOnlyStringSchema(),
52-
"description": DescriptionComputedSchema(),
53-
"tags": TagsSchema(),
54-
"version": VersionSchema(),
55-
"enabled": BoolComputedSchema(),
56-
"exceptions": ExceptionsComputedSchema(),
57-
"prohibited_binaries": ExceptionsComputedSchema(),
58-
"mounted_volume_drift_enabled": BoolComputedSchema(),
50+
"id": ReadOnlyIntSchema(),
51+
"name": ReadOnlyStringSchema(),
52+
"description": DescriptionComputedSchema(),
53+
"tags": TagsSchema(),
54+
"version": VersionSchema(),
55+
"enabled": BoolComputedSchema(),
56+
"exceptions": ExceptionsComputedSchema(),
57+
"prohibited_binaries": ExceptionsComputedSchema(),
58+
"process_based_exceptions": ExceptionsComputedSchema(),
59+
"process_based_prohibited_binaries": ExceptionsComputedSchema(),
60+
"mounted_volume_drift_enabled": BoolComputedSchema(),
61+
"use_regex": BoolComputedSchema(),
5962
},
6063
},
6164
},

sysdig/internal/client/v2/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ type DriftRuleDetails struct {
419419
ProhibitedBinaries *RuntimePolicyRuleList `json:"prohibitedBinaries"`
420420
Mode string `json:"mode"`
421421
MountedVolumeDriftEnabled bool `json:"mountedVolumeDriftEnabled"`
422+
UseRegex bool `json:"useRegex"`
422423
Details `json:"-"`
423424
}
424425

sysdig/resource_sysdig_secure_drift_policy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func resourceSysdigSecureDriftPolicy() *schema.Resource {
6767
"process_based_exceptions": ExceptionsSchema(),
6868
"process_based_prohibited_binaries": ExceptionsSchema(),
6969
"mounted_volume_drift_enabled": BoolSchema(),
70+
"use_regex": BoolSchema(),
7071
},
7172
},
7273
},

sysdig/tfresource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func setTFResourcePolicyRulesDrift(d *schema.ResourceData, policy v2.PolicyRules
216216
"tags": rule.Tags,
217217
"enabled": enabled,
218218
"mounted_volume_drift_enabled": driftDetails.MountedVolumeDriftEnabled,
219+
"use_regex": driftDetails.UseRegex,
219220
}
220221

221222
if exceptionsBlock != nil {
@@ -498,6 +499,7 @@ func setPolicyRulesDrift(policy *v2.PolicyRulesComposite, d *schema.ResourceData
498499
}
499500

500501
mountedVolumeDriftEnabled := d.Get("rule.0.mounted_volume_drift_enabled").(bool)
502+
useRegex := d.Get("rule.0.use_regex").(bool)
501503

502504
rule := &v2.RuntimePolicyRule{
503505
// TODO: Do not hardcode the indexes
@@ -512,6 +514,7 @@ func setPolicyRulesDrift(policy *v2.PolicyRulesComposite, d *schema.ResourceData
512514
ProcessBasedExceptions: &processBasedExceptions,
513515
ProcessBasedDenylist: &processBasedProhibitedBinaries,
514516
MountedVolumeDriftEnabled: mountedVolumeDriftEnabled,
517+
UseRegex: useRegex,
515518
},
516519
}
517520

website/docs/d/secure_drift_policy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,11 @@ The rule block is required and supports:
7878
* `items` - (Required) Specify comma separated list of exceptions, e.g. `/usr/bin/rm, /usr/bin/curl`.
7979
* `prohibited_binaries` - (Optional) A prohibited binary can be a known harmful binary or one that facilitates discovery of your environment.
8080
* `items` - (Required) Specify comma separated list of prohibited binaries, e.g. `/usr/bin/rm, /usr/bin/curl`.
81+
* `process_based_exceptions` - (Optional) List of processes that will be able to execute a drifted file
82+
* `items` - (Required) Specify comma separated list of processes, e.g. `/usr/bin/rm, /usr/bin/curl`.
83+
* `process_based_prohibited_binaries` - (Optional) List of processes that will be prohibited to execute a drifted file
84+
* `items` - (Required) Specify comma separated list of processes, e.g. `/usr/bin/rm, /usr/bin/curl`.
85+
* `mounted_volume_drift_enabled` - (Optional) Treat all binaries from mounted volumes as drifted. Default value is false/disabled.
86+
* `use_regex` - (Optional) Pass exceptions and prohibited binaries as regex strings. Requires agent version 13.2.0 and above
8187

8288

website/docs/r/secure_drift_policy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The rule block is required and supports:
123123
* `process_based_prohibited_binaries` - (Optional) List of processes that will be prohibited to execute a drifted file
124124
* `items` - (Required) Specify comma separated list of processes, e.g. `/usr/bin/rm, /usr/bin/curl`.
125125
* `mounted_volume_drift_enabled` - (Optional) Treat all binaries from mounted volumes as drifted. Default value is false/disabled.
126+
* `use_regex` - (Optional) Pass exceptions and prohibited binaries as regex strings. Requires agent version 13.2.0 and above
126127

127128

128129

0 commit comments

Comments
 (0)