Allow Python script-only packages#49070
Conversation
**Related issue:** Resolves #48393 Adds `.py` as an accepted script-only software package on the server — mirroring `.sh`, assigned the new `py_packages` source and installable on macOS and Linux hosts. # Checklist for submitter - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually
**Related issue:** Resolves #48394 Adds `.py` to the custom-package upload form and software details page, accepted and detected as a script-only package (advanced options follow `.sh`/`.ps1`), shown with the Python icon and per-platform file-type tooltips, and mapped to the `py_packages` source that renders as "Script-only package (macOS & Linux)". # Checklist for submitter - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually ## Manual QA - [x] Verified live in the browser against a dev server
There was a problem hiding this comment.
Pull request overview
Adds first-class support for uploading Python (.py) script-only software packages, treating them like existing .sh/.ps1 script packages: the uploaded file contents become install_script, the installer is stored under a new py_packages source, and installs are allowed on Linux and macOS (via the existing unix-like exception).
Changes:
- Backend: recognize
.pyas a script package, map it topy_packages, store asplatform=linux, and allow installs on unix-like hosts. - Frontend: accept
.pyuploads, display correct platform/tooltips, and render a Python file icon where appropriate. - Tests: add/extend unit, integration, and GitOps tests to cover
.pyupload/validation/install behavior and UI rendering.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/service/testdata/software-installers/script.py | Adds a .py script fixture for installer testdata. |
| server/service/integration_enterprise_test.go | Adds integration coverage for .py upload validation and persistence behavior. |
| server/fleet/software_installer.go | Adds py_packages source mapping, linux platform mapping, and .py script package detection. |
| server/fleet/software_installer_test.go | Extends unit tests for .py platform/source/script-package helpers. |
| ee/server/service/software_installers.go | Extends install platform exception to .py, adds .py to validation/error strings, script metadata mapping, and script:// validation messaging. |
| ee/server/service/software_installers_test.go | Adds unit tests for python script validation/metadata and unix-like install allowance. |
| cmd/fleetctl/integrationtest/gitops/software_test.go | Updates expected unsupported-file-type errors to include .py. |
| cmd/fleetctl/fleetctl/generate_gitops_test.go | Extends GitOps generation tests to include .py script packages. |
| frontend/utilities/software_uninstall_scripts.ts | Treats .py like other script-only packages for default uninstall-script behavior. |
| frontend/utilities/software_install_scripts.ts | Treats .py like other script-only packages for default install-script behavior. |
| frontend/utilities/file/fileUtils.tsx | Adds .py → “macOS & Linux” platform display mapping. |
| frontend/utilities/file/fileUtils.tests.tsx | Adds .py coverage to file utils tests. |
| frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/SoftwareTitleDetailsPage.tsx | Threads source through to installer details widget. |
| frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/SoftwareInstallerCard/InstallerDetailsWidget/InstallerDetailsWidget.tsx | Renders a Python file icon for py_packages. |
| frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/SoftwareInstallerCard/InstallerDetailsWidget/InstallerDetailsWidget.tests.tsx | Adds tests for Python vs generic package icon selection. |
| frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/LibraryItemAccordion/LibraryItemAccordion.tsx | Threads source into the shared installer widget for icon selection. |
| frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/helpers.tests.ts | Adds a test ensuring py_packages titles are treated as script packages. |
| frontend/pages/SoftwarePage/components/forms/PackageForm/PackageForm.tsx | Accepts .py uploads, displays .py icon, and updates per-platform supported-type tooltips. |
| frontend/pages/SoftwarePage/components/cards/SoftwareDetailsSummary/SoftwareDetailsSummary.tsx | Updates comment to reflect broader “no version/host data” sources. |
| frontend/pages/hosts/details/DeviceUserPage/helpers.ts | Uses SCRIPT_PACKAGE_SOURCES for script-only detection (now including .py). |
| frontend/pages/hosts/details/DeviceUserPage/helpers.tests.ts | Adds test coverage for .py script setup-step detection. |
| frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx | Adds activity feed test coverage for .py script package statuses. |
| frontend/interfaces/software.ts | Adds py_packages conversions and includes .py in SCRIPT_PACKAGE_SOURCES. |
| frontend/interfaces/setup.ts | Updates comments/examples to include .py script packages. |
| frontend/interfaces/package_type.ts | Adds "py" to script-only package types. |
| frontend/components/ActivityDetails/InstallDetails/SoftwareScriptDetailsModal/SoftwareScriptDetailsModal.tsx | Updates comment/examples to include py_packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis change adds Python ( Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #49070 +/- ##
==========================================
- Coverage 68.11% 68.03% -0.08%
==========================================
Files 3709 3743 +34
Lines 235099 237227 +2128
Branches 12352 12522 +170
==========================================
+ Hits 160129 161395 +1266
- Misses 60593 61262 +669
- Partials 14377 14570 +193
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Related issue: Resolves #41470
Adds support for uploading Python (
.py) script-only software packages — accepted as script-only (the file contents become the install script; advanced options and automatic install follow.sh/.ps1), assigned the newpy_packagessource, and installable on macOS and Linux hosts across the UI, REST API, and GitOps.Feature branch combining the backend (#48942) and frontend (#48946) sub-PRs.
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.Testing
Summary by CodeRabbit
New Features
.py) script-only software packages across upload, validation, and GitOps flows.Bug Fixes
.pyas a supported installer type..pyinstalls target macOS/Linux only, with clearer “unsupported host” feedback.