fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
5k stars 572 forks source link

Activity feed: Surface `team_id` and `team_name` in policy and query activities #27689

Open RachelElysia opened 1 month ago

RachelElysia commented 1 month ago

Reference: March 31, 2025, Software Design Review (18-minute mark) – Noah and Eugene discussion.


mostlikelee commented 1 month ago

related to #25499 , so the software team may want to take this

eugkuo commented 1 month ago

related to https://github.com/fleetdm/fleet/issues/25499 , so the software team may want to take this

@mostlikelee Speaking of this, didn't someone file a ticket about updating activity things on our last call? I'm not sure where that ticket is to link it.

cc @noahtalerman

drvcodenta commented 1 month ago

Hi team, This issue looks beginner-friendly — I’d love to take it up as my first contribution to Fleet.

I’ve gone through the context and the linked issues. The goal is clear:

noahtalerman commented 1 month ago

Hey @drvcodenta! Please feel free to open a PR when you get the chance.

We added this feature request to Feature fest to weigh it for prioritization. Heads up that this feature request has to be prioritized at the next feature fest to merge in your PR: https://fleetdm.com/handbook/company/product-groups#criteria-for-prioritization

If it's prioritized, we'll assign a member of the Fleet team to the feature request. They'll be responsible for helping merge in your PR.

noahtalerman commented 1 month ago

Gong snippet: TODO March 31, 2025, Software Design Review, 18 minutes in - @noahtalerman @eugkuo chat about use case for having this addition but not wanting to blow up scope on a different feature ticket

Problem

When adding, editing, and deleting a policy (also a query), we are not surfacing the team information for those activities in the activity API or activity feed UI. See screenshot:

Image

We do surface the team_id and team_name for adding, editing, and deleting software. See screenshot:

Image

What have you tried?

Potential solutions

What is the expected workflow as a result of your proposal?

When looking at the global activity on the dashboard, I can clearly see if a policy (or query) has been edited for a specific team or if it was a global policy (or query).
drvcodenta commented 1 month ago

Hi, While working on this issue, I noticed that editing a global policy doesn't create any activity log (no ActivityTypeEditedPolicy is generated and there is no function defined for that purpose in the global_policies). I wanted to know if there is a philosophical reason behind this gap? Or is it likely just an oversight?

RachelElysia commented 1 month ago

@drvcodenta super appreciate you jumping on this ticket!!!

I just added, edited, and deleted a "All teams" (global) policy in the UI and got these activities:

    {
      "created_at": "2025-04-15T18:41:10.419719Z",
      "id": 836,
      "actor_full_name": "Rachel",
      "actor_id": 1,
      "actor_gravatar": "",
      "actor_email": "***",
      "type": "deleted_policy",
      "details": {
        "policy_id": 74,
        "policy_name": "Edit policy"
      },
      "fleet_initiated": false
    },
    {
      "created_at": "2025-04-15T18:41:02.559709Z",
      "id": 835,
      "actor_full_name": "Rachel",
      "actor_id": 1,
      "actor_gravatar": "",
      "actor_email": "***",
      "type": "edited_policy",
      "details": {
        "policy_id": 74,
        "policy_name": "Edit policy"
      },
      "fleet_initiated": false
    },
    {
      "created_at": "2025-04-15T18:40:57.950179Z",
      "id": 834,
      "actor_full_name": "Rachel",
      "actor_id": 1,
      "actor_gravatar": "",
      "actor_email": "***",
      "type": "created_policy",
      "details": {
        "policy_id": 74,
        "policy_name": "Add policy"
      },
      "fleet_initiated": false
    },

Are you not seeing the same on your end?

drvcodenta commented 1 month ago

Interesting!! Yes, I actually don't see any log of the activity when I edit an "All teams"(global) policy on my End Idk why it's causing this weird Behaviour🤔 I also checked for ActivityTypeEditedPolicy inside global_policy.go --> I didn't find any function, so I thought maybe it was intentionally left out for some reason. For reference, here's the process I followed to edit an all teams policy

https://github.com/user-attachments/assets/dc83e140-5606-4b9b-b101-943046cf7a02

RachelElysia commented 1 month ago

@drvcodenta thanks for the detailed screenrecording!! That is so weird!!! I'll take a look again later today, and get back to ya

drvcodenta commented 1 month ago

@RachelElysia I have submitted a patch that solves the issue except for the case of activity type edited policy in all Teams. I’ve attached a screenshot with a sample output for reference. Please let me know if any changes are needed!

drvcodenta commented 1 month ago

I was planning to add the function for activity type edited policy in all teams myself but since it's actually working in your case, i decided to not add it as it may add some unnecessary code.