Conversation
| // Team specific auth check | ||
| if err := svc.authz.Authorize(ctx, &fleet.HostSoftwareInstallerResultAuthz{HostTeamID: res.HostTeamID}, fleet.ActionRead); err != nil { | ||
| return nil, err | ||
| if res.HostDeletedAt == nil { |
There was a problem hiding this comment.
Note that if the host was deleted, the only authorization done is "list hosts" above. Should there be a different authz for that case?
There was a problem hiding this comment.
I tried to come up with something else but I couldn't, the other alternative is to keep some host information around.
We never merged this, and if you remember: but at some point we tried to solve a similar problem, (but for users that were deleted), we were considering having a table like deleted_user_data that kept information like this.
Something like that would be more tricky for hosts because the table is so huge that there will be the temptation to slowly move all the fields.
| // get the software install details, does not work because the installer does | ||
| // not exist anymore. | ||
| softwareRes = getSoftwareInstallResultsResponse{} | ||
| s.DoJSON("GET", "/api/latest/fleet/software/install/results/"+installID, nil, http.StatusNotFound, &softwareRes) |
There was a problem hiding this comment.
Note that deleting a software installer will still result in not being able to view the activity details. This PR only handles the host's soft-deletion (to keep scope reasonable and mostly in-line with estimation).
roperzh
left a comment
There was a problem hiding this comment.
based on your comment I wonder if we should scope software installers in a completely different ticket.
asking because I think we also need to update places like the one below to ignore software installers with a NOT NULL deleted_at, is that correct?
fleet/server/datastore/mysql/software_installers.go
Lines 340 to 381 in 4b82ff6
(I'm not sure if similar considerations also applies to scripts)
| // Team specific auth check | ||
| if err := svc.authz.Authorize(ctx, &fleet.HostSoftwareInstallerResultAuthz{HostTeamID: res.HostTeamID}, fleet.ActionRead); err != nil { | ||
| return nil, err | ||
| if res.HostDeletedAt == nil { |
There was a problem hiding this comment.
I tried to come up with something else but I couldn't, the other alternative is to keep some host information around.
We never merged this, and if you remember: but at some point we tried to solve a similar problem, (but for users that were deleted), we were considering having a table like deleted_user_data that kept information like this.
Something like that would be more tricky for hosts because the table is so huge that there will be the temptation to slowly move all the fields.
Oh that's a great catch, that's correct and I'm not sure if we have something similar for scripts, I'll check. Wondering if we're opening up a can of worms with that fix (or that approach to the fix), given how error-prone it will be to make queries that target those tables and don't explicitly join with |
|
Ok what I think I'll do is scope it back down to scripts only, as @roperzh suggested. Not only do software installers involve other queries, but the installer activities will still fail if the installer is removed, whereas the scripts work in all cases (removing the named script doesn't remove the host script results entry, it just removes the relationship with the saved script). |
ec69a95 to
47a7b4b
Compare
I did a search for all uses of |
…available in activities (#19457)
Checklist for submitter
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)