Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Scope Fleet-maintained apps and custom packages via labels #24976

Merged
merged 31 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53d9840
SSVL: database schema changes (#24591)
mna Dec 10, 2024
412c4b4
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 10, 2024
2dfd8ed
SSVL: db migration add microsecond precision to timestamps (#24620)
mna Dec 10, 2024
129eabe
Update software installer types (#24626)
gillespi314 Dec 10, 2024
2893d0b
Merge branch 'main' into feat-labels-scoped-software
gillespi314 Dec 11, 2024
7b5e9b3
Update schema
gillespi314 Dec 11, 2024
23a6146
SSVL: prevent deletion of a label if used to scope software installer…
mna Dec 11, 2024
8ecf75a
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 16, 2024
12bf988
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 16, 2024
7e3a7ba
feat: filter host software by label scoping (#24801)
jahzielv Dec 16, 2024
4f95490
SSVL: Add labels to upload endpoint; add validations and related data…
gillespi314 Dec 17, 2024
0876a9d
Add UI for scoping software to fleet apps and custom packages via la…
ghernandez345 Dec 17, 2024
eb41e7c
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 17, 2024
fa2c399
Add label scope to create FMA endpoint (#24830)
gillespi314 Dec 17, 2024
79ac8fa
SSVL: implement gitops support for labels include/exclude on software…
mna Dec 17, 2024
14fc86d
SSVL: update activities to add labels include/exclude (backend change…
mna Dec 18, 2024
8043ef3
Add labels to update custom installer endpoint (#24857)
gillespi314 Dec 18, 2024
fe8324b
feat: skip automatic install policy if installer is not scoped to hos…
jahzielv Dec 18, 2024
054c561
SSVL: activity fix and integration test cleanup (#24866)
mna Dec 18, 2024
9057bf6
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 18, 2024
aaeb7ef
feat: some testing updates (#24890)
jahzielv Dec 19, 2024
89862b0
Merge branch 'main' into feat-labels-scoped-software
ghernandez345 Dec 19, 2024
b4516df
SSVL: add timestamp-based check for the exclude-any case (#24889)
mna Dec 19, 2024
3681b8f
Activities UI and api integation/tests for the scoped software via la…
ghernandez345 Dec 19, 2024
1e949c8
Add unit tests for software label validations (#24894)
gillespi314 Dec 19, 2024
e6efcf7
finish UI api integration for editing a custom package (#24929)
ghernandez345 Dec 19, 2024
863e680
update the label error message (#24932)
ghernandez345 Dec 19, 2024
8694e98
Fix decoder for software installer label payloads; update tests (#24934)
gillespi314 Dec 20, 2024
4a4ebfb
fix: better filtering to handle de-scoping after uninstall edge case …
jahzielv Dec 20, 2024
c780027
Merge branch 'main' into feat-labels-scoped-software
gillespi314 Dec 20, 2024
c79875c
Add changes file
gillespi314 Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/22813-software-scope-labels
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added features to scope Fleet-maintained apps and custom packages via labels in UI, API, and CLI.
1 change: 1 addition & 0 deletions changes/24533-skip-policy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Adds functionality for skipping automatic installs if the software is not scoped to the host via labels.
1 change: 1 addition & 0 deletions changes/24534-hide-software-2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add functionality to filter host software based on label scoping.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Added a validation to prevent label deletion if it is used to scope the hosts targeted by a software installer.
1 change: 1 addition & 0 deletions changes/24538-24542-UI-for-scope-software-via-labels
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- add UI for scoping software via labels
1 change: 1 addition & 0 deletions changes/24663-software-scoped-via-labels-gitops
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Added `fleetctl gitops` support to scope software installers by labels, with the `labels_include_any` or `labels_exclude_any` conditions.
1 change: 1 addition & 0 deletions changes/24792-update-software-installer-activities
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Added the `labels_include_any` and `labels_exclude_any` fields to the software installer activities.
40 changes: 40 additions & 0 deletions cmd/fleetctl/gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,10 @@ func TestGitOpsTeamSofwareInstallers(t *testing.T) {
{"testdata/gitops/team_software_installer_post_install_not_found.yml", "no such file or directory"},
{"testdata/gitops/team_software_installer_no_url.yml", "software URL is required"},
{"testdata/gitops/team_software_installer_invalid_self_service_value.yml", "\"packages.self_service\" must be a bool, found string"},
{"testdata/gitops/team_software_installer_invalid_both_include_exclude.yml", `only one of "labels_exclude_any" or "labels_include_any" can be specified`},
{"testdata/gitops/team_software_installer_valid_include.yml", ""},
{"testdata/gitops/team_software_installer_valid_exclude.yml", ""},
{"testdata/gitops/team_software_installer_invalid_unknown_label.yml", "some or all the labels provided don't exist"},
// team tests for setup experience software/script
{"testdata/gitops/team_setup_software_valid.yml", ""},
{"testdata/gitops/team_setup_software_invalid_script.yml", "no_such_script.sh: no such file"},
Expand Down Expand Up @@ -1939,6 +1943,22 @@ func TestGitOpsTeamSofwareInstallers(t *testing.T) {
Teams: nil,
}, nil
}
labelToIDs := map[string]uint{
fleet.BuiltinLabelMacOS14Plus: 1,
"a": 2,
"b": 3,
}
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
// for this test, recognize labels a and b (as well as the built-in macos 14+ one)
ret := make(map[string]uint)
for _, lbl := range labels {
id, ok := labelToIDs[lbl]
if ok {
ret[lbl] = id
}
}
return ret, nil
}

_, err = runAppNoChecks([]string{"gitops", "-f", c.file})
if c.wantErr == "" {
Expand Down Expand Up @@ -1992,6 +2012,10 @@ func TestGitOpsNoTeamSoftwareInstallers(t *testing.T) {
{"testdata/gitops/no_team_software_installer_post_install_not_found.yml", "no such file or directory"},
{"testdata/gitops/no_team_software_installer_no_url.yml", "software URL is required"},
{"testdata/gitops/no_team_software_installer_invalid_self_service_value.yml", "\"packages.self_service\" must be a bool, found string"},
{"testdata/gitops/no_team_software_installer_invalid_both_include_exclude.yml", `only one of "labels_exclude_any" or "labels_include_any" can be specified`},
{"testdata/gitops/no_team_software_installer_valid_include.yml", ""},
{"testdata/gitops/no_team_software_installer_valid_exclude.yml", ""},
{"testdata/gitops/no_team_software_installer_invalid_unknown_label.yml", "some or all the labels provided don't exist"},
// No team tests for setup experience software/script
{"testdata/gitops/no_team_setup_software_valid.yml", ""},
{"testdata/gitops/no_team_setup_software_invalid_script.yml", "no_such_script.sh: no such file"},
Expand Down Expand Up @@ -2021,6 +2045,22 @@ func TestGitOpsNoTeamSoftwareInstallers(t *testing.T) {
Teams: nil,
}, nil
}
labelToIDs := map[string]uint{
fleet.BuiltinLabelMacOS14Plus: 1,
"a": 2,
"b": 3,
}
ds.LabelIDsByNameFunc = func(ctx context.Context, labels []string) (map[string]uint, error) {
// for this test, recognize labels a and b (as well as the built-in macos 14+ one)
ret := make(map[string]uint)
for _, lbl := range labels {
id, ok := labelToIDs[lbl]
if ok {
ret[lbl] = id
}
}
return ret, nil
}

t.Setenv("APPLE_BM_DEFAULT_TEAM", "")
globalFile := "./testdata/gitops/global_config_no_paths.yml"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: No team
controls:
policies:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby.yml
post_install_script:
path: lib/post_install_ruby.sh
uninstall_script:
path: lib/uninstall_ruby.sh
labels_include_any:
- a
labels_exclude_any:
- b
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: No team
controls:
policies:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby.yml
post_install_script:
path: lib/post_install_ruby.sh
uninstall_script:
path: lib/uninstall_ruby.sh
labels_exclude_any:
- zzz
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: No team
controls:
policies:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby.yml
post_install_script:
path: lib/post_install_ruby.sh
uninstall_script:
path: lib/uninstall_ruby.sh
labels_exclude_any:
- a
- b
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: No team
controls:
policies:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby.yml
post_install_script:
path: lib/post_install_ruby.sh
uninstall_script:
path: lib/uninstall_ruby.sh
labels_include_any:
- a
- b
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "${TEST_TEAM_NAME}"
team_settings:
secrets:
- secret: "ABC"
features:
enable_host_users: true
enable_software_inventory: true
host_expiry_settings:
host_expiry_enabled: true
host_expiry_window: 30
agent_options:
controls:
policies:
queries:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby_apply.yml
post_install_script:
path: lib/post_install_ruby.sh
labels_include_any:
- a
labels_exclude_any:
- b
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "${TEST_TEAM_NAME}"
team_settings:
secrets:
- secret: "ABC"
features:
enable_host_users: true
enable_software_inventory: true
host_expiry_settings:
host_expiry_enabled: true
host_expiry_window: 30
agent_options:
controls:
policies:
queries:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby_apply.yml
post_install_script:
path: lib/post_install_ruby.sh
labels_include_any:
- zzz
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "${TEST_TEAM_NAME}"
team_settings:
secrets:
- secret: "ABC"
features:
enable_host_users: true
enable_software_inventory: true
host_expiry_settings:
host_expiry_enabled: true
host_expiry_window: 30
agent_options:
controls:
policies:
queries:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby_apply.yml
post_install_script:
path: lib/post_install_ruby.sh
labels_exclude_any:
- b
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "${TEST_TEAM_NAME}"
team_settings:
secrets:
- secret: "ABC"
features:
enable_host_users: true
enable_software_inventory: true
host_expiry_settings:
host_expiry_enabled: true
host_expiry_window: 30
agent_options:
controls:
policies:
queries:
software:
packages:
- url: ${SOFTWARE_INSTALLER_URL}/ruby.deb
install_script:
path: lib/install_ruby.sh
pre_install_query:
path: lib/query_ruby_apply.yml
post_install_script:
path: lib/post_install_ruby.sh
labels_include_any:
- a
- url: ${SOFTWARE_INSTALLER_URL}/other.deb
self_service: true
42 changes: 39 additions & 3 deletions docs/Contributing/Audit-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,8 @@ This activity contains the following fields:
- "team_id": The ID of the team to which this software was added. `null` if it was added to no team.
- "self_service": Whether the software is available for installation by the end user.
- "software_title_id": ID of the added software title.
- "labels_include_any": Target hosts that have any label in the array.
- "labels_exclude_any": Target hosts that don't have any label in the array.

#### Example

Expand All @@ -1252,7 +1254,17 @@ This activity contains the following fields:
"team_name": "Workstations",
"team_id": 123,
"self_service": true,
"software_title_id": 2234
"software_title_id": 2234,
"labels_include_any": [
{
"name": "Engineering",
"id": 12
},
{
"name": "Product",
"id": 17
}
]
}
```

Expand All @@ -1266,6 +1278,8 @@ This activity contains the following fields:
- "team_name": Name of the team on which this software was updated. `null` if it was updated on no team.
- "team_id": The ID of the team on which this software was updated. `null` if it was updated on no team.
- "self_service": Whether the software is available for installation by the end user.
- "labels_include_any": Target hosts that have any label in the array.
- "labels_exclude_any": Target hosts that don't have any label in the array.

#### Example

Expand All @@ -1275,7 +1289,17 @@ This activity contains the following fields:
"software_package": "FalconSensor-6.44.pkg",
"team_name": "Workstations",
"team_id": 123,
"self_service": true
"self_service": true,
"labels_include_any": [
{
"name": "Engineering",
"id": 12
},
{
"name": "Product",
"id": 17
}
]
}
```

Expand All @@ -1289,6 +1313,8 @@ This activity contains the following fields:
- "team_name": Name of the team to which this software was added. `null` if it was added to no team.
- "team_id": The ID of the team to which this software was added. `null` if it was added to no team.
- "self_service": Whether the software was available for installation by the end user.
- "labels_include_any": Target hosts that have any label in the array.
- "labels_exclude_any": Target hosts that don't have any label in the array.

#### Example

Expand All @@ -1298,7 +1324,17 @@ This activity contains the following fields:
"software_package": "FalconSensor-6.44.pkg",
"team_name": "Workstations",
"team_id": 123,
"self_service": true
"self_service": true,
"labels_include_any": [
{
"name": "Engineering",
"id": 12
},
{
"name": "Product",
"id": 17
}
]
}
```

Expand Down
Loading
Loading