Skip to content

only include policies in device endpoints for premium users - #6077

Merged
roperzh merged 6 commits into
mainfrom
device-root-premium-policies
Jun 7, 2022
Merged

only include policies in device endpoints for premium users#6077
roperzh merged 6 commits into
mainfrom
device-root-premium-policies

Conversation

@roperzh

@roperzh roperzh commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

This removes policy information from GET /api/_version_/fleet/device/{token} from non-premium Fleet instances.

Starting the server with ./build/fleet serve --dev --dev_license

$ curl -s https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a | jq '.host.policies // "not present"'
[
  {
    "id": 3,
    "name": "Antivirus healthy (Linux)",
    "query": "SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM processes WHERE (name = 'clamd') OR (name = 'freshclam')) WHERE score == 1;",
    "description": "Checks that both ClamAV's daemon and its updater service (freshclam) are running.",
    "author_id": 1,
    "author_name": "Roberto",
    "author_email": "test@example.com",
    "team_id": null,
    "resolution": "Ensure ClamAV and Freshclam are installed and running.",
    "platform": "darwin,linux",
    "created_at": "2022-05-23T20:53:36Z",
    "updated_at": "2022-06-03T13:17:42Z",
    "response": ""
  }
]

Starting the server with ./build/fleet serve --dev

$ curl -s https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a | jq '.host.policies // "not present"'
"not present"

This doesn't break the UI (I also manually tested) because a license check is used before trying to display any data (nice!)

{isPremiumTier && (
<TabPanel>
<PoliciesCard
policies={host?.policies || []}
isLoading={isLoadingHost}
deviceUser
togglePolicyDetailsModal={togglePolicyDetailsModal}
/>
</TabPanel>

cc: @gillespi314 do you think this makes sense?

Related to: #5806

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes (in changes/ and/or orbit/changes/).
  • Added/updated tests
  • Manual QA for all new/changed functionality

@roperzh
roperzh requested a review from a team as a code owner June 3, 2022 13:38
@roperzh
roperzh requested a review from gillespi314 June 3, 2022 13:39
Comment thread server/service/hosts.go Outdated
Comment thread server/service/hosts.go Outdated
Comment thread server/fleet/hosts.go
Comment thread server/fleet/service.go Outdated
juan-fdz-hawa
juan-fdz-hawa previously approved these changes Jun 3, 2022
Comment thread server/fleet/hosts.go Outdated
@roperzh
roperzh temporarily deployed to Docker Hub June 6, 2022 13:19 Inactive
@codecov-commenter

codecov-commenter commented Jun 6, 2022

Copy link
Copy Markdown

Codecov Report

Merging #6077 (312480d) into main (842ebbb) will increase coverage by 0.00%.
The diff coverage is 85.18%.

@@           Coverage Diff           @@
##             main    #6077   +/-   ##
=======================================
  Coverage   59.16%   59.17%           
=======================================
  Files         366      366           
  Lines       33972    33986   +14     
=======================================
+ Hits        20101    20112   +11     
- Misses      11839    11846    +7     
+ Partials     2032     2028    -4     
Impacted Files Coverage Δ
orbit/cmd/orbit/orbit.go 1.64% <ø> (+<0.01%) ⬆️
server/fleet/hosts.go 71.15% <ø> (ø)
server/service/hosts.go 70.65% <81.81%> (+0.46%) ⬆️
server/service/devices.go 57.40% <100.00%> (+1.63%) ⬆️
server/vulnerabilities/sync.go 58.00% <0.00%> (-2.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e37e1f3...312480d. Read the comment docs.

Comment thread server/service/hosts.go
Comment thread server/service/hosts.go
@roperzh
roperzh temporarily deployed to Docker Hub June 6, 2022 16:53 Inactive
@roperzh
roperzh requested a review from michalnicp June 6, 2022 16:54
@roperzh
roperzh merged commit 19f995d into main Jun 7, 2022
@roperzh
roperzh deleted the device-root-premium-policies branch June 7, 2022 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants