Skip to content

Commit

Permalink
Fix team 0 validation on os_versions detail (#20772)
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikelee committed Jul 29, 2024
1 parent 8336c33 commit 1ad3885
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/service/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@ func (svc *Service) OSVersion(ctx context.Context, osID uint, teamID *uint, incl
return nil, nil, err
}

if teamID != nil {
if teamID != nil && *teamID != 0 {
// This auth check ensures we return 403 if the user doesn't have access to the team
if err := svc.authz.Authorize(ctx, &fleet.AuthzSoftwareInventory{TeamID: teamID}, fleet.ActionRead); err != nil {
return nil, nil, err
Expand Down
4 changes: 4 additions & 0 deletions server/service/integration_enterprise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4334,6 +4334,10 @@ func (s *integrationEnterpriseTestSuite) TestOSVersions() {
require.NoError(t, s.ds.UpdateOSVersions(context.Background()))
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/os_versions"), nil, http.StatusOK, &osVersionsResp, "team_id", "0")
require.Len(t, osVersionsResp.OSVersions, 1)
osVersionResp = getOSVersionResponse{}
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/os_versions/%d", osinfo.OSVersionID), nil, http.StatusOK, &osVersionResp, "team_id", "0")
require.Equal(t, &expectedOSVersion, osVersionResp.OSVersion)
require.Equal(t, 1, osVersionResp.OSVersion.HostsCount)
}

func (s *integrationEnterpriseTestSuite) TestMDMNotConfiguredEndpoints() {
Expand Down

0 comments on commit 1ad3885

Please sign in to comment.