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

Add YARA queries to osquery-perf #25272

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion cmd/osquery-perf/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2135,12 +2135,17 @@ func (a *agent) runLiveYaraQuery(query string) (results []map[string]string, sta
}
request.Header.Add("Content-type", "application/json")

// Make the request. For load testing purposes we don't actually care about the response.
// Make the request.
response, err := http.DefaultClient.Do(request)
if err != nil {
ss := fleet.OsqueryStatus(1)
return []map[string]string{}, &ss, ptr.String(fmt.Sprintf("yara request failed to run: %v", err)), nil
}
// For load testing purposes we don't actually care about the response, but check that we at least got one.
if _, err := io.Copy(io.Discard, response.Body); err != nil {
ss := fleet.OsqueryStatus(1)
return []map[string]string{}, &ss, ptr.String(fmt.Sprintf("error reading response from yara API: %v", err)), nil
}
defer response.Body.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer response.Body.Close() should be before the io.Copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed


// Return a response indicating that the file is clean.
Expand Down
Loading