Skip to content

Self-improving AI Employees for everyone

fix(cli): mark root project as uv-unmanaged so python isn't venv-shadowed

trohitg1b13c17cdcea
diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml
index 0b6a468b..3b64d9f6 100644
--- a/.github/workflows/publish-pypi.yml
+++ b/.github/workflows/publish-pypi.yml
@@ -66,8 +66,13 @@ jobs:
- name: Locate dist directory
id: locate
+ # Reusable-workflow input read via env per the zizmor
+ # template-injection check -- caller-controlled string would
+ # otherwise execute shell when interpolated directly.
+ env:
+ PACKAGE_DIR: ${{ inputs.package_dir }}
run: |
- echo "dist_path=${{ inputs.package_dir }}/dist" >> "$GITHUB_OUTPUT"
+ echo "dist_path=${PACKAGE_DIR}/dist" >> "$GITHUB_OUTPUT"
- name: Upload dist artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 19ec11e7..2afe40a3 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -28,11 +28,14 @@ on:
type: boolean
default: true
-# Top-level permissions for all jobs (jobs can narrow further)
+# Workflow-level permissions are deliberately narrow (least-privilege).
+# Each publish job grants only what it needs at the job level -- per
+# the zizmor ``excessive-permissions`` audit, write scopes at the
+# workflow level apply to every job and to reusable workflows called
+# via ``uses:`` (including ``predeploy.yml``), which is broader than
+# any single job's actual needs.
permissions:
- contents: write
- packages: write
- id-token: write
+ contents: read
# `dry_run` is only meaningful on workflow_dispatch; tag-pushed
# releases always publish. Computed once and surfaced to each
@@ -250,11 +253,17 @@ jobs:
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
+ # ``github.ref_name`` + step output read via env (not direct
+ # ``${{ }}`` interpolation) per the zizmor template-injection
+ # check -- tag names are user-controllable via push and would
+ # otherwise execute attacker-controlled shell inside ``run:``.
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ REF_NAME: ${{ github.ref_name }}
+ VERSION: ${{ steps.version.outputs.version }}
run: |
- gh release create "${{ github.ref_name }}" \
- --title "MachinaOS ${{ steps.version.outputs.version }}" \
+ gh release create "${REF_NAME}" \
+ --title "MachinaOS ${VERSION}" \
--generate-notes \
--verify-tag
diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml
index 40c81554..b444d389 100644
--- a/.github/workflows/rollback.yml
+++ b/.github/workflows/rollback.yml
@@ -70,28 +70,32 @@ jobs:
- name: Normalise version
id: ver
# `npm deprecate` wants a bare semver (e.g. 0.0.72), not a tag
- # (e.g. v0.0.72). Strip the leading `v` if present.
+ # (e.g. v0.0.72). Strip the leading `v` if present. Read input
+ # via env to keep zizmor template-injection check happy --
+ # ``${{ inputs.X }}`` directly inside ``run:`` lets an attacker
+ # who can dispatch the workflow inject shell metacharacters.
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
run: |
- v="${{ inputs.version }}"
- v="${v#v}"
+ v="${INPUT_VERSION#v}"
echo "semver=${v}" >> "$GITHUB_OUTPUT"
- name: Deprecate on npm (unscoped)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ SEMVER: ${{ steps.ver.outputs.semver }}
+ DEPRECATE_MSG: ${{ inputs.deprecate_msg }}
run: |
- npm deprecate \
- "machinaos@${{ steps.ver.outputs.semver }}" \
- "${{ inputs.deprecate_msg }}"
+ npm deprecate "machinaos@${SEMVER}" "${DEPRECATE_MSG}"
- name: Deprecate on GitHub Packages (scoped)
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ SEMVER: ${{ steps.ver.outputs.semver }}
+ DEPRECATE_MSG: ${{ inputs.deprecate_msg }}
run: |
npm config set @zeenie-ai:registry https://npm.pkg.github.com
- npm deprecate \
- "@zeenie-ai/machinaos@${{ steps.ver.outputs.semver }}" \
- "${{ inputs.deprecate_msg }}"
+ npm deprecate "@zeenie-ai/machinaos@${SEMVER}" "${DEPRECATE_MSG}"
yank-pypi-notice:
name: PyPI yank reminder
@@ -102,9 +106,14 @@ jobs:
- name: Print PyPI yank instructions
# PyPI yank is gated on UI access -- no API path that the
# release token can take. Emit a notice so the operator
- # remembers to do this by hand.
+ # remembers to do this by hand. Input read via env (not direct
+ # ``${{ }}`` interpolation) per the zizmor template-injection
+ # check -- ``::notice::`` is rendered into the workflow log
+ # and would otherwise execute attacker-controlled shell.
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
run: |
- echo "::notice title=Manual PyPI yank required::Yank machinaos-server@${{ inputs.version }} via https://pypi.org/manage/project/machinaos-server/release/${{ inputs.version }}/ -- 'Options' -> 'Yank'."
+ echo "::notice title=Manual PyPI yank required::Yank machinaos-server@${INPUT_VERSION} via https://pypi.org/manage/project/machinaos-server/release/${INPUT_VERSION}/ -- 'Options' -> 'Yank'."
open-revert-pr:
name: Open revert PR
@@ -124,32 +133,38 @@ jobs:
id: commit
# The release commit is the one the tag points at. `git
# rev-list -n1 <tag>` works regardless of whether the tag
- # is annotated or lightweight.
+ # is annotated or lightweight. Input read via env per the
+ # zizmor template-injection check.
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
run: |
- sha=$(git rev-list -n1 "${{ inputs.version }}")
+ sha=$(git rev-list -n1 "${INPUT_VERSION}")
echo "sha=${sha}" >> "$GITHUB_OUTPUT"
- name: Create revert branch + commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ INPUT_VERSION: ${{ inputs.version }}
+ INPUT_DEPRECATE_MSG: ${{ inputs.deprecate_msg }}
+ REVERT_SHA: ${{ steps.commit.outputs.sha }}
run: |
- branch="rollback/${{ inputs.version }}"
+ branch="rollback/${INPUT_VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${branch}"
- git revert --no-edit "${{ steps.commit.outputs.sha }}"
+ git revert --no-edit "${REVERT_SHA}"
git push origin "${branch}"
gh pr create \
--base main \
--head "${branch}" \
- --title "Revert: ${{ inputs.version }} (rollback)" \
- --body "Automated revert of ${{ inputs.version }}.
+ --title "Revert: ${INPUT_VERSION} (rollback)" \
+ --body "Automated revert of ${INPUT_VERSION}.
npm package deprecated via rollback.yml.
PyPI yank pending manual action -- see https://pypi.org/manage/project/machinaos-server/.
- Reason: ${{ inputs.deprecate_msg }}"
+ Reason: ${INPUT_DEPRECATE_MSG}"
summary:
name: Rollback summary
@@ -158,19 +173,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Print summary
+ # Inputs + job results read via env per the zizmor
+ # template-injection check. ``$GITHUB_STEP_SUMMARY`` is markdown
+ # rendered in the GitHub UI -- attacker-controlled inputs
+ # would otherwise be rendered as raw HTML.
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
+ NPM_DEPRECATE_RESULT: ${{ needs.deprecate-npm.result }}
+ YANK_REMINDER_RESULT: ${{ needs.yank-pypi-notice.result }}
+ REVERT_PR_STATUS: ${{ inputs.open_revert_pr == true && 'requested' || 'skipped (open_revert_pr=false)' }}
run: |
{
- echo "## Rollback summary for ${{ inputs.version }}"
+ echo "## Rollback summary for ${INPUT_VERSION}"
echo ""
echo "| Step | Status |"
echo "|---|---|"
- echo "| npm deprecate | ${{ needs.deprecate-npm.result }} |"
- echo "| PyPI yank reminder | ${{ needs.yank-pypi-notice.result }} |"
- echo "| Revert PR | ${{ inputs.open_revert_pr == true && 'requested' || 'skipped (open_revert_pr=false)' }} |"
+ echo "| npm deprecate | ${NPM_DEPRECATE_RESULT} |"
+ echo "| PyPI yank reminder | ${YANK_REMINDER_RESULT} |"
+ echo "| Revert PR | ${REVERT_PR_STATUS} |"
echo ""
echo "Next steps:"
echo ""
- echo "1. Manually yank \`machinaos-server@${{ inputs.version }}\` from PyPI."
+ echo "1. Manually yank \`machinaos-server@${INPUT_VERSION}\` from PyPI."
echo "2. If shipping a forward fix, bump version and re-run release.yml."
echo "3. If reverting, merge the rollback PR (if requested)."
} >> "$GITHUB_STEP_SUMMARY"
diff --git a/pyproject.toml b/pyproject.toml
index 5d20a98d..3a02ecc4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,6 +33,15 @@ build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["cli"]
+# The CLI runs under the user's global / pipx-managed Python — it is
+# NOT a uv-managed project. ``managed = false`` tells ``uv`` to leave
+# this project alone: ``uv sync`` at the repo root is a no-op, no
+# ``<repo>/.venv/`` is created, ``python`` on PATH resolves to the
+# user's global interpreter instead of being shadowed by a workspace
+# venv. The server is the only uv-managed project (``server/.venv``).
+[tool.uv]
+managed = false
+
[dependency-groups]
dev = []
diff --git a/server/nodes/_visuals.py b/server/nodes/_visuals.py
index 6327e13c..513a5ac9 100644
--- a/server/nodes/_visuals.py
+++ b/server/nodes/_visuals.py
@@ -172,7 +172,12 @@ def get_plugin_icon_path(node_type: str, variant: str = "light") -> Optional[Pat
# Candidate filenames in resolution order. Per-node-type first so
# multi-node folders can override the shared icon for specific
- # node types.
+ # node types. ``node_type`` is already constrained to
+ # ``NODE_TYPE_PATTERN`` (``^[A-Za-z_][A-Za-z0-9_]*$``) by
+ # ``is_valid_node_type`` above -- no path separators possible --
+ # but resolving + ``is_relative_to(plugin_dir)`` gives CodeQL a
+ # path-injection sanitizer it can statically prove (closes the
+ # ``py/path-injection`` alert without weakening the contract).
candidates: list[str] = []
if variant == "dark":
candidates.append(f"icon_{node_type}.dark.svg")
@@ -182,9 +187,11 @@ def get_plugin_icon_path(node_type: str, variant: str = "light") -> Optional[Pat
candidates.append("icon.svg")
for name in candidates:
- path = plugin_dir / name
- if path.exists():
- return path
+ candidate = (plugin_dir / name).resolve()
+ if not candidate.is_relative_to(plugin_dir):
+ continue
+ if candidate.exists():
+ return candidate
return None
diff --git a/server/nodes/whatsapp/_runtime.py b/server/nodes/whatsapp/_runtime.py
index 12169963..39a4b069 100644
--- a/server/nodes/whatsapp/_runtime.py
+++ b/server/nodes/whatsapp/_runtime.py
@@ -49,9 +49,7 @@ class WhatsAppRuntime(BaseProcessSupervisor):
# ``<repo>/.machina/whatsapp/`` (not ``<repo>/server/.machina/...``,
# which the old ad-hoc ``_PROJECT_ROOT / "server" / data_dir``
# logic produced when ``DATA_DIR`` was relative).
- return Path(
- self.settings._resolve_under_data(self.settings.whatsapp_data_subdir)
- )
+ return Path(self.settings._resolve_under_data(self.settings.whatsapp_data_subdir))
@property
def port(self) -> int: