-
Notifications
You must be signed in to change notification settings - Fork 633
26824 refactor list host software #27304
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
Conversation
Include vulnerability filtering conditions on vpp apps and latest host software installs/uninstalls
server/datastore/mysql/software.go
Outdated
last_uninstall_script_execution_id, | ||
status | ||
` | ||
|
||
var globalOrTeamID uint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is too long and needs to be broken down better.
It does have a few logical parts.
- get installed software
- get upcoming installs
- get upcoming uninstalls
- get vpp installs
- get available software for installs
- get information about all those software titles using IN (...ids...)
- some post processing to adjust to required object to be returned from method
SELECT | ||
* | ||
FROM | ||
(SELECT * FROM upcoming_vpp_install UNION SELECT * FROM last_vpp_install) AS lvia |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe we need to add vulnerabilities joins for this. After VPP software is installed on the host we track those through host software.
// Clear out all the previous software titles as we are only filtering for available software | ||
if opts.OnlyAvailableForInstall { | ||
bySoftwareID = make(map[uint]*hostSoftware, len(availableSoftwareTitles)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this approach, since we still fire off all the queries above but just discard the results. Should figure out a way to optimize here, and only fire off the available software query.
AND true | ||
` + vppOnlySelfServiceClause + ` | ||
-- GROUP BY for vpp apps | ||
%s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this second query just for VPP apps? Can we merge this with the query above and avoid the union?
} else { | ||
namedArgs["host_compatible_platforms"] = []string{host.FleetPlatform()} | ||
} | ||
stmtAvailable = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fact check this query. Does it need to contain all this stuff to pull up "available to install software". Can we break it down into two pieces software/vpp to reduce complexity.
One other matter I have been slightly ignore is labels. |
1c1c994
to
bf7d259
Compare
bf7d259
to
d0a1ec7
Compare
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/
,orbit/changes/
oree/fleetd-chrome/changes
.See Changes files for more information.
SELECT *
is avoided, SQL injection is prevented (using placeholders for values in statements)cmd/osquery-perf
for new osquery data ingestion features.COLLATE utf8mb4_unicode_ci
).runtime.GOOS
).