Skip to content

Allow Python script-only packages#49070

Open
cdcme wants to merge 3 commits into
mainfrom
feat/41470-python-script-only
Open

Allow Python script-only packages#49070
cdcme wants to merge 3 commits into
mainfrom
feat/41470-python-script-only

Conversation

@cdcme

@cdcme cdcme commented Jul 9, 2026

Copy link
Copy Markdown
Member

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 new py_packages source, 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 file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
  • 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

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Added support for Python (.py) script-only software packages across upload, validation, and GitOps flows.
    • Python scripts are recognized and shown with the correct platform/file-type labeling in the UI, including a dedicated Python icon in installer details.
    • Activity feed and setup-step detection now correctly handle Python script activity states.
  • Bug Fixes

    • Improved validation and error messages to include .py as a supported installer type.
    • Enforced Python installer shebang requirements and ensured .py installs target macOS/Linux only, with clearer “unsupported host” feedback.

cdcme added 2 commits July 8, 2026 13:53
**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
@cdcme cdcme requested review from a team as code owners July 9, 2026 19:15
Copilot AI review requested due to automatic review settings July 9, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 .py as a script package, map it to py_packages, store as platform=linux, and allow installs on unix-like hosts.
  • Frontend: accept .py uploads, display correct platform/tooltips, and render a Python file icon where appropriate.
  • Tests: add/extend unit, integration, and GitOps tests to cover .py upload/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.

Comment thread ee/server/service/software_installers.go
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 448fb651-001a-4881-8cc6-2f0fbfd70290

📥 Commits

Reviewing files that changed from the base of the PR and between c4e7e7e and b20862b.

📒 Files selected for processing (1)
  • changes/41470-python-script-only-packages

Walkthrough

This change adds Python (.py) support to script-only software packages across server, GitOps, integration tests, and frontend code. The backend now maps .py to py_packages, targets Linux, validates script uploads and installs on unix-like hosts, and treats .py as a script package. The frontend now recognizes py_packages in types, icons, file handling, activity rendering, and setup helpers. Tests and fixtures were added or updated throughout to cover upload, validation, installation, and display behavior.

Possibly related PRs

  • fleetdm/fleet#47944: Extends LibraryItemAccordion to pass through source="py_packages" for Python package rendering.
  • fleetdm/fleet#48315: Updates script-only package handling and advanced script-field behavior that this change extends to .py packages.
  • fleetdm/fleet#48370: Also touches generate_gitops_test.go around script-only package comment/version expectations.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: adding Python script-only package support.
Description check ✅ Passed The description includes the related issue, checklist, and testing notes; omitted sections appear non-critical.
Linked Issues check ✅ Passed The changes cover .py uploads, script-only behavior, UI updates, platform mapping, install eligibility, and edge-case handling.
Out of Scope Changes check ✅ Passed The diff stays focused on Python script-only package support, with tests and docs only; no unrelated scope stands out.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/41470-python-script-only

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.03%. Comparing base (646ebd0) to head (b20862b).
⚠️ Report is 44 commits behind head on main.

Files with missing lines Patch % Lines
ee/server/service/software_installers.go 50.00% 2 Missing ⚠️
...ePage/components/forms/PackageForm/PackageForm.tsx 33.33% 2 Missing ⚠️
frontend/utilities/software_install_scripts.ts 0.00% 1 Missing ⚠️
frontend/utilities/software_uninstall_scripts.ts 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
backend 69.61% <75.00%> (-0.11%) ⬇️
frontend 59.29% <60.00%> (+0.01%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Allow Python script-only packages

2 participants