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

filter threats that don't belong to specified ComputerName #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions api/threats.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
MitigationStatusDescription string `json:"mitigationStatusDescription"`
}

func (c *Client) GetThreats(values url.Values) (threats []*Threat, err error) {
func (c *Client) GetThreats(values url.Values, computername string) (threats []*Threat, err error) {
// nolint: noctx
req, err := c.NewRequest("GET", "v2.1/threats?"+values.Encode(), nil)
if err != nil {
Expand All @@ -55,8 +55,10 @@
if err != nil {
return
}

if computername != "" && computername != t.AgentRealtimeInfo.AgentComputerName {

Check failure on line 58 in api/threats.go

View workflow job for this annotation

GitHub Actions / lint

if statements should only be cuddled with assignments (wsl)
continue
}
threats = append(threats, t)

Check failure on line 61 in api/threats.go

View workflow job for this annotation

GitHub Actions / lint

append only allowed to cuddle with appended value (wsl)
}

return
Expand Down
2 changes: 1 addition & 1 deletion check.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *Config) Run() (rc int, output string, err error) {
values.Set("computerName__contains", c.ComputerName)
}

threats, err := client.GetThreats(values)
threats, err := client.GetThreats(values, c.ComputerName)
if err != nil {
return
}
Expand Down
Loading