Skip to content

Various fixes to cape2.sh#3030

Open
edmcman wants to merge 14 commits into
kevoreilly:masterfrom
edmcman:install-patches
Open

Various fixes to cape2.sh#3030
edmcman wants to merge 14 commits into
kevoreilly:masterfrom
edmcman:install-patches

Conversation

@edmcman
Copy link
Copy Markdown

@edmcman edmcman commented May 15, 2026

No description provided.

edmcman added 4 commits May 15, 2026 07:08
Three sites used \$PYTHON_MGR directly (or hardcoded 'run') instead of
\$PYTHON_MGR \$PYTHON_MGR_CMD, breaking the uv code path:
- install_yara_python: uv pip install yara-python
- install_CAPE: uv pip install -r pyproject.toml
- install_volatility3: hardcoded 'run' instead of \$PYTHON_MGR_CMD
- install_CAPE: replace uv pip install -r pyproject.toml with
  uv sync --no-install-project; the former fails because poetry-core
  refuses to build an editable package when package-mode=false
- install_yara_python: drop $PYTHON_MGR_CMD so uv uses uv pip install
  rather than uv run pip install; uv run triggers a project sync
  (and the same build failure) before running any command
Add PYTHON_MGR_PIP ("run pip" / "pip") so $PYTHON_MGR $PYTHON_MGR_PIP install X
resolves to the correct subcommand for each manager — poetry uses "run pip" while
uv uses "pip" directly (uv run pip install triggers a project sync that fails on
package-mode=false projects).

Rename PYTHON_MGR_INSTALL -> PYTHON_MGR_INSTALL_PYPROJECT and fix its uv value
from "" (no-op) to "sync --no-install-project", enabling install_CAPE() and
install_guacamole() to collapse their USE_UV branches into a single line.

Also collapse four other USE_UV pip install branches (distributed, yara-python,
libvirt, capa) into unconditional lines using $PYTHON_MGR_PIP, and fix a pip3
typo in install_volatility3().
Two bugs broke CAPE services on boot with --use-uv:
1. cape-rooter ExecStartPre ran `uv config cache-dir ...` because the
   removal sed ran after the poetry→uv replacement, so its pattern
   (/poetry ) no longer matched. Fix: remove ExecStartPre lines first.
2. All services failed with build_editable because uv tried to install
   CAPEv2 as an editable package; poetry-core refused due to
   package-mode = false. Fix: add [tool.uv] package = false so uv
   natively skips the install step.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the installer/cape2.sh script to abstract Python package management between Poetry and UV, simplifying the installation logic and updating project configuration files. The review identified several areas for improvement: a hardcoded Poetry path should be replaced with the abstracted variable for consistency, a removed environment variable necessary for building dependencies without Rust should be restored, and the systemd service file cleanup should use the sed delete command to avoid blank lines. Additionally, directory handling in the Volatility 3 installation should be unified to ensure reliable execution across both package managers.

Comment thread installer/cape2.sh Outdated
Comment thread installer/cape2.sh Outdated
Comment thread installer/cape2.sh Outdated
Comment thread installer/cape2.sh Outdated
edmcman and others added 6 commits May 15, 2026 08:49
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
install_suricata must run before install_systemd so suricata is present
when systemctl first starts the service. Also create pcap and suricata
groups if absent — the OISF PPA package does not create them.
@edmcman edmcman marked this pull request as ready for review May 15, 2026 19:48
Copilot AI review requested due to automatic review settings May 15, 2026 19:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates CAPEv2’s installer workflow to better support uv alongside Poetry, and aligns project metadata/lockfiles with the new optional YARA-related dependency setup.

Changes:

  • Refactors installer/cape2.sh to standardize Python package installation commands across Poetry/uv and adjusts install ordering/systemd tweaks.
  • Adds uv-specific configuration in pyproject.toml and updates uv.lock to include a yara extra (via plyara), while dropping some previously-locked dev metadata.
  • Ignores .venv in .gitignore to prevent committing local virtual environments.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

File Description
installer/cape2.sh Unifies installer pip/install invocations for Poetry vs uv; adds uv venv creation and systemd adjustments.
pyproject.toml Adds [tool.uv] package = false and defines yara optional dependency (plyara).
uv.lock Updates lock content to include yara extra and plyara, and changes lock header/metadata.
.gitignore Ignores .venv directory.

Comment thread installer/cape2.sh
Comment thread installer/cape2.sh Outdated
edmcman added 4 commits May 15, 2026 15:55
…al flags

Previously IFACE_IP was only set when $# -eq 3, making it impossible to pass
both an interface IP and flags like --use-uv simultaneously. Change to -ge 2
and read IFACE_IP from $2 directly (sandbox_version was set but never used).
dependencies() runs before install_CAPE() which is where CAPE_ROOT is
created/cloned. On a fresh install, the uv venv call would fail because
the directory doesn't exist yet.
PYTHON_MGR vars were only set to uv inside the CLI arg-parsing loop,
so USE_UV=True in the environment (or cape-config.sh) would install uv
but still run poetry commands. Extract assignment into set_python_mgr()
and call it after sourcing cape-config.sh so all three entry points
(env var, config file, --use-uv flag) work correctly.
Extract shell-profile export into idempotent _set_libvirt_default_uri helper
and call it from install_libvirt so the variable is set on server installs too.
Also fixes ~/.zsh typo (should be ~/.zshrc).
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.

2 participants