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

DLP-1479: made DLP ContextAwareness a pointer #1510

Merged
merged 2 commits into from Mar 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1510.txt
@@ -0,0 +1,3 @@
```release-note:bug
dlp: added optional ContextAwareness support
```
13 changes: 7 additions & 6 deletions dlp_profile.go
Expand Up @@ -50,12 +50,13 @@ type DLPContextAwareness struct {
// DLPProfile represents a DLP Profile, which contains a set
// of entries.
type DLPProfile struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
AllowedMatchCount int `json:"allowed_match_count"`
ContextAwareness DLPContextAwareness `json:"context_awareness,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
AllowedMatchCount int `json:"allowed_match_count"`

ContextAwareness *DLPContextAwareness `json:"context_awareness,omitempty"`

// The following fields are omitted for predefined DLP
// profiles.
Expand Down
21 changes: 5 additions & 16 deletions dlp_profile_test.go
Expand Up @@ -75,13 +75,7 @@ func TestDLPProfiles(t *testing.T) {
"updated_at": "2022-10-18T08:00:57Z",
"type": "custom",
"description": "just a custom profile example",
"allowed_match_count": 1,
"context_awareness": {
"enabled": false,
"skip": {
"files": false
}
}
"allowed_match_count": 1
}
]
}
Expand All @@ -98,7 +92,7 @@ func TestDLPProfiles(t *testing.T) {
Type: "predefined",
Description: "",
AllowedMatchCount: 0,
ContextAwareness: DLPContextAwareness{
ContextAwareness: &DLPContextAwareness{
Enabled: BoolPtr(true),
Skip: DLPContextAwarenessSkip{
Files: BoolPtr(true),
Expand Down Expand Up @@ -126,12 +120,7 @@ func TestDLPProfiles(t *testing.T) {
Type: "custom",
Description: "just a custom profile example",
AllowedMatchCount: 1,
ContextAwareness: DLPContextAwareness{
Enabled: BoolPtr(false),
Skip: DLPContextAwarenessSkip{
Files: BoolPtr(false),
},
},
// Omit ContextAwareness to test ContextAwareness optionality
Entries: []DLPEntry{
{
ID: "ef79b054-12d4-4067-bb30-b85f6267b91c",
Expand Down Expand Up @@ -211,7 +200,7 @@ func TestGetDLPProfile(t *testing.T) {
Type: "custom",
Description: "just a custom profile example",
AllowedMatchCount: 42,
ContextAwareness: DLPContextAwareness{
ContextAwareness: &DLPContextAwareness{
Enabled: BoolPtr(false),
Skip: DLPContextAwarenessSkip{
Files: BoolPtr(false),
Expand Down Expand Up @@ -586,7 +575,7 @@ func TestUpdateDLPPredefinedProfile(t *testing.T) {
Type: "predefined",
Description: "example predefined profile",
AllowedMatchCount: 0,
ContextAwareness: DLPContextAwareness{
ContextAwareness: &DLPContextAwareness{
Enabled: BoolPtr(true),
Skip: DLPContextAwarenessSkip{
Files: BoolPtr(true),
Expand Down