Skip to content

Commit 3c0d12c

Browse files
committed
feat: add ws1 filtering
1 parent 80a4e69 commit 3c0d12c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ ws1:
4646
api_key: "XXX"
4747
user: "XXX"
4848
password: "XXX"
49+
# what policies you want to skip
50+
# leave user or policy blank to ignore it
51+
skip:
52+
- policy: "Disk Encryption"
53+
4954

5055
# email domains used in your Slack workspace for filtering
5156
# e.g. for a Slack account [email protected]

config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ type Config struct {
3535
APIKey string `yaml:"api_key" env:"WS1_API_KEY"`
3636
User string `yaml:"user" env:"WS1_USER"`
3737
Password string `yaml:"password" env:"WS1_PASSWORD"`
38+
39+
SkipFilters []struct {
40+
Policy string `yaml:"policy"`
41+
User string `yaml:"user"`
42+
} `yaml:"skip"`
3843
} `yaml:"ws1"`
3944

4045
Email struct {

pkg/ws1/extractor.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ func GetMessages(config *config.Config, ctx context.Context) (map[string]WS1Resu
122122
for _, policy := range device.ComplianceSummary.DeviceCompliance {
123123
if policy.CompliantStatus { continue }
124124

125+
shouldSkip := false
126+
for _, filter := range config.WS1.SkipFilters {
127+
if filter.Policy != "" && !strings.EqualFold(policy.PolicyName, filter.Policy) {
128+
continue
129+
}
130+
if filter.User != "" && !strings.EqualFold(filter.User, userEmail) {
131+
continue
132+
}
133+
shouldSkip = true
134+
}
135+
if shouldSkip { continue }
136+
125137
userDevice.Findings = append(userDevice.Findings, UserDeviceFinding{
126138
ComplianceName: policy.PolicyName,
127139
})

0 commit comments

Comments
 (0)