Skip to content

Add "ExcludeFleetMaintainedApps" option to software titles query#25649

Merged
sgress454 merged 10 commits intomainfrom
sgress454/25427-add-exclude-fma-from-software-titles
Jan 30, 2025
Merged

Add "ExcludeFleetMaintainedApps" option to software titles query#25649
sgress454 merged 10 commits intomainfrom
sgress454/25427-add-exclude-fma-from-software-titles

Conversation

@sgress454
Copy link
Copy Markdown
Contributor

@sgress454 sgress454 commented Jan 21, 2025

for #25427

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)

This PR adds a new ExcludeFleetMaintainedApps option to the ListSoftwareTitles datastore method, and the equivalent exclude_fleet_maintained_apps to the GET /api/v1/fleet/software/titles API.

The new functionality works by doing a left join from the software_titles table to the fleet_library_apps table by bundle identifier, and excluding any rows that are present in the fleet_library_apps table.

New tests verify that the filtering works as expected and doesn't interfere with other functions of the method.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.60%. Comparing base (65f9ef4) to head (0cea579).
Report is 126 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #25649    +/-   ##
========================================
  Coverage   63.59%   63.60%            
========================================
  Files        1622     1625     +3     
  Lines      155091   155466   +375     
  Branches     4051     4051            
========================================
+ Hits        98637    98886   +249     
- Misses      48684    48779    +95     
- Partials     7770     7801    +31     
Flag Coverage Δ
backend 64.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +871 to +882
// Testing with Platform filter
titles, count, _, err = ds.ListSoftwareTitles(
context.Background(), fleet.SoftwareTitleListOptions{
ListOptions: fleet.ListOptions{},
Platform: string(fleet.MacOSPlatform),
AvailableForInstall: true,
TeamID: &team1.ID,
}, globalTeamFilter,
)
require.NoError(t, err)
require.Len(t, titles, 1)
require.Equal(t, "installer1", titles[0].Name)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related, but this would have caught an issue with the code that another test suite failed on (thankfully).

Comment thread server/datastore/mysql/software_titles_test.go
@sgress454
Copy link
Copy Markdown
Contributor Author

@dantecatalfamo all linting accounted for, tests are 🟢

Comment thread server/datastore/mysql/software_titles.go Outdated
dantecatalfamo
dantecatalfamo previously approved these changes Jan 28, 2025
Copy link
Copy Markdown
Member

@dantecatalfamo dantecatalfamo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I added a comment that you might want to consider, but otherwise good 2 go

@sgress454
Copy link
Copy Markdown
Contributor Author

@dantecatalfamo made the suggested change

@sgress454 sgress454 merged commit 8419b8e into main Jan 30, 2025
@sgress454 sgress454 deleted the sgress454/25427-add-exclude-fma-from-software-titles branch January 30, 2025 17:22
sgress454 added a commit that referenced this pull request Jan 30, 2025
for #25427 

This PR updates the calls to the "list software titles" API to include
the `exclude_fleet_maintained_apps=true` flag.

I tested this with #25649
successfully.
sgress454 added a commit that referenced this pull request Feb 17, 2025
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.

2 participants