filter to only apple (vpp) apps in refresh job (#37506)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->

The `refresh_vpp_app_versions` cron job wasn't updated to take Android
apps (a type of app store app) into account, leading to errors like
these ([internal Slack
thread](https://fleetdm.slack.com/archives/C03EG80BM2A/p1765934577063429)).

This adds a simple filter to the query that fetches the VPP apps.

# Checklist for submitter

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

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)

## Testing

- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually
This commit is contained in:
Jahziel Villasana-Espinoza
2025-12-18 16:17:24 -05:00
committed by GitHub
parent a487c19951
commit 204c5183c2
3 changed files with 13 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
- Updated the refresh_vpp_app_versions cron job to only attempt to refresh versions for Apple app store apps.
+7 -2
View File
@@ -1928,10 +1928,15 @@ SELECT
name,
latest_version,
platform
FROM vpp_apps`
FROM vpp_apps WHERE platform IN (?)`
query, args, err := sqlx.In(query, fleet.ApplePlatforms)
if err != nil {
return nil, ctxerr.Wrap(ctx, err, "get all vpp apps: building query")
}
var apps []*fleet.VPPApp
if err := sqlx.SelectContext(ctx, ds.reader(ctx), &apps, query); err != nil {
if err := sqlx.SelectContext(ctx, ds.reader(ctx), &apps, query, args...); err != nil {
return nil, ctxerr.Wrap(ctx, err, "getting all VPP apps")
}
+5
View File
@@ -2023,6 +2023,11 @@ func testGetAllVPPApps(t *testing.T, ds *Datastore) {
_, err = ds.InsertVPPAppWithTeam(ctx, app3, nil)
require.NoError(t, err)
// Include an Android app. it shouldn't show up since this is an Apple-only operation.
app4 := &fleet.VPPApp{Name: "vpp_app_4", VPPAppTeam: fleet.VPPAppTeam{VPPAppID: fleet.VPPAppID{AdamID: "com.an.android.app", Platform: fleet.AndroidPlatform}}, BundleIdentifier: "com.an.android.app"}
_, err = ds.InsertVPPAppWithTeam(ctx, app4, nil)
require.NoError(t, err)
// this method doesn't pull the VPPAppTeamID
app1.AppTeamID = 0
app2.AppTeamID = 0