fleet/server/datastore
Lucas Manuel Rodriguez 53b7a0628a
Prevent IT admins from deleting a secret variable in use (#32161)
#31977

Tested with:
224 scripts, 102 Apple configuration profiles, 105 Apple declarations,
37 Windows configuration profiles. Scattered in 7 teams.

No variables on profiles/scripts:
- scan scripts: 22.079416ms
- scan apple profiles: 1.865083ms
- scan apple declarations: 683.75µs
- scan windows profiles: 531.167µs

A variable "X" on with profiles/scripts that have variable "Y":
- scan scripts: 26.305459ms
- scan apple profiles: 1.841708ms
- scan apple declarations: 756.917µs
- scan windows profiles: 571.875µs

---

## Testing

- [X] Added/updated automated tests

- [X] QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

- [X] Confirmed that the fix is not expected to adversely impact load
test results
- [X] Alerted the release DRI if additional load testing is needed

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- New Features
- Prevents deleting a secret that’s still in use. The system now checks
scripts, Apple/Windows MDM profiles, and Apple declarations across teams
before allowing deletion.
- The delete dialog now shows a clear message indicating which item (and
team) is using the secret, replacing the previous generic error.
- Deletion succeeds once all references are removed, ensuring safer
secret management.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-22 11:22:37 -03:00
..
cached_mysql Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
filesystem Added signed URLs (#25197) 2025-01-09 12:56:54 -06:00
mysql Prevent IT admins from deleting a secret variable in use (#32161) 2025-08-22 11:22:37 -03:00
mysqlredis Refactor EnrollOrbit/EnrollHost (#30872) 2025-07-15 17:22:02 -03:00
redis Add macOS redis cluster support (#29433) 2025-05-27 11:38:59 -04:00
s3 Feat: Perform S3 Uploads with Upload Manager (#32010) 2025-08-20 15:20:53 -04:00