Some checks failed
Build and Test / build (debug, clang) (push) Has been cancelled
Build and Test / build (debug, gcc) (push) Has been cancelled
Build and Test / build (release, clang) (push) Has been cancelled
Build and Test / build (release, gcc) (push) Has been cancelled
Build and Test / macos (push) Has been cancelled
Build and Test / docker (push) Has been cancelled
Second half of the sandbox-safe tracker transport. A small relay in the host network namespace bridges OpenSnitch to the sandboxed daemon, so the daemon keeps PrivateNetwork=true + RestrictAddressFamilies=AF_UNIX and never sees argv/env. - `strawberry opensnitch relay` (new CLI verb, Map::flag -> --opensnitch-relay): binds the OpenSnitch loopback port via the existing OpenSnitchEventListener (root-peer check, argv/env dropped at parse), and forwards each redacted tuple (encode_connection) to the daemon's AF_UNIX ingest socket, reconnecting on failure. Foreground loop until SIGTERM/SIGINT; drops (not blocks) when the socket is down. Linux-only. The listener callback runs on one thread, so the sink needs no lock. - scripts/strawberry-trackerd.service: runs the relay in the host namespace with only CAP_NET_BIND_SERVICE, no PrivateNetwork, and /proc/net kept readable for the peer check (no ProcSubset=pid); otherwise the same tight sandbox as strawberry-update.service. install.sh installs+manifests+starts it when OpenSnitch is present and privacy_trackers is not false. - docs/tracker-attribution.md: replace the "known limitation" with the relay architecture (rejected alternatives noted). API_CONTRACT: privacy.listener now describes the ingest socket + relay; also documents feed-add max_severity (B1). Suite 51/51; clang static analyzer and clang-tidy clean on main.cpp and cli_commands.cpp. Full relay->OpenSnitch end-to-end needs host validation (sudo + a real OpenSnitch); the socket path is covered by E9. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
202 lines
8.8 KiB
Bash
Executable file
202 lines
8.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# Install Strawberry from a build tree (builddir/). Run as root:
|
|
# sudo ./scripts/install.sh
|
|
# On macOS this runs scripts/macos_install.sh.
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
exec bash ./scripts/macos_install.sh "$@"
|
|
fi
|
|
. ./scripts/install_common.sh
|
|
|
|
echo "=== Strawberry Security Scanner Installation ==="
|
|
echo
|
|
|
|
# Check if running as root
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Please run as root (sudo)"
|
|
exit 1
|
|
fi
|
|
|
|
# Access group: members can read findings and use the desktop app's controls
|
|
# (reload rules, rescan). Nobody else can see the evidence.
|
|
if ! getent group strawberry >/dev/null; then
|
|
echo "Creating 'strawberry' group..."
|
|
groupadd --system strawberry
|
|
fi
|
|
|
|
# Create directories. Rules are root-only (anyone who can edit them can blind
|
|
# the scanner); evidence is readable by the strawberry group only.
|
|
echo "Creating directories..."
|
|
install -d -m 0755 /etc/strawberry
|
|
install -d -m 0700 /etc/strawberry/rules
|
|
install -d -m 0750 -g strawberry /var/lib/strawberry
|
|
install -d -m 0750 -g strawberry /var/lib/strawberry/feeds
|
|
# Evidence: a legacy database.db file (imported into the event store by the
|
|
# daemon on its next start, old file kept as database.db.migrated-<ts>) or
|
|
# the event store directory. Either way the strawberry group reads evidence;
|
|
# telemetry/ stays root-only through its own 0700/0600 modes.
|
|
f=/var/lib/strawberry/database.db
|
|
if [ -f "$f" ]; then
|
|
chgrp strawberry "$f" && chmod 0640 "$f"
|
|
elif [ -d "$f" ]; then
|
|
chgrp -R strawberry "$f"
|
|
chmod 0750 "$f"
|
|
[ -d "$f/evidence" ] && chmod 0750 "$f/evidence"
|
|
fi
|
|
|
|
# Copy configuration
|
|
if [ -f "config/strawberry.conf" ]; then
|
|
echo "Installing configuration..."
|
|
if [ -f /etc/strawberry/strawberry.conf ]; then
|
|
echo " keeping existing /etc/strawberry/strawberry.conf"
|
|
else
|
|
install -m 0644 config/strawberry.conf /etc/strawberry/strawberry.conf
|
|
fi
|
|
fi
|
|
|
|
# Copy example YARA rules
|
|
if [ -f "config/example_rules.yar" ]; then
|
|
echo "Installing example YARA rules..."
|
|
install -m 0600 config/example_rules.yar /etc/strawberry/rules/example_rules.yar
|
|
fi
|
|
|
|
# Install binary
|
|
if [ -f "builddir/src/strawberry" ]; then
|
|
echo "Installing binary..."
|
|
install -m 0755 builddir/src/strawberry /usr/local/bin/strawberry
|
|
install_completions /usr/local/bin/strawberry
|
|
install_traces /usr/local
|
|
else
|
|
echo "Error: Binary not found. Please build first with 'meson compile -C builddir'"
|
|
exit 1
|
|
fi
|
|
|
|
# Install the eBPF exec monitor object (without it the daemon falls back to
|
|
# slower procfs polling, which misses short-lived processes)
|
|
if [ -f "builddir/src/process_monitor.bpf.o" ]; then
|
|
echo "Installing eBPF object..."
|
|
install -d -m 0755 /usr/local/share/strawberry
|
|
install -m 0644 builddir/src/process_monitor.bpf.o /usr/local/share/strawberry/process_monitor.bpf.o
|
|
else
|
|
echo "Warning: builddir/src/process_monitor.bpf.o not found; the daemon will use procfs polling"
|
|
fi
|
|
|
|
# Desktop app + tray indicator (optional; built when Qt6 is available)
|
|
if [ -f "builddir/app/strawberry-tray" ]; then
|
|
echo "Installing desktop app..."
|
|
install -m 0755 builddir/app/strawberry-tray /usr/local/bin/strawberry-tray
|
|
install -d -m 0755 /usr/local/share/applications
|
|
install -m 0644 packaging/strawberry-tray.desktop /usr/local/share/applications/strawberry-tray.desktop
|
|
else
|
|
echo "Note: builddir/app/strawberry-tray not built (needs Qt6); skipping the desktop app"
|
|
fi
|
|
|
|
# MCP server for agents (optional; built when nlohmann_json is available)
|
|
if [ -f "builddir/mcp/strawberry-mcp" ]; then
|
|
echo "Installing MCP server..."
|
|
install -m 0755 builddir/mcp/strawberry-mcp /usr/local/bin/strawberry-mcp
|
|
fi
|
|
|
|
# Install systemd units: the scanner, plus the sandboxed rule updater
|
|
# (daily timer + "Update now" path trigger).
|
|
# Hashes of the unit files this installer writes into a persistence location
|
|
# (written first): the daemon records these writes as evidence instead of
|
|
# raising findings, as long as the installed content still matches.
|
|
manifest_args=()
|
|
for unit in strawberry.service strawberry-update.service strawberry-update.timer strawberry-update.path \
|
|
strawberry-trackerd.service; do
|
|
manifest_args+=("scripts/$unit" "/etc/systemd/system/$unit")
|
|
done
|
|
write_installed_manifest /var/lib/strawberry/installed-files.sha256 root "${manifest_args[@]}"
|
|
|
|
if [ -f "scripts/strawberry.service" ]; then
|
|
echo "Installing systemd units..."
|
|
install -m 0644 scripts/strawberry.service /etc/systemd/system/strawberry.service
|
|
for unit in strawberry-update.service strawberry-update.timer strawberry-update.path strawberry-trackerd.service; do
|
|
install -m 0644 "scripts/$unit" "/etc/systemd/system/$unit"
|
|
done
|
|
systemctl daemon-reload
|
|
# Pick up the new binary if the service is already running.
|
|
systemctl try-restart strawberry || true
|
|
|
|
echo "Enabling automatic YARA rule updates (daily)..."
|
|
systemctl enable --now strawberry-update.timer strawberry-update.path
|
|
# Fetch the default feed (YARA Forge core) now, in the background.
|
|
systemctl start --no-block strawberry-update.service || true
|
|
fi
|
|
|
|
# OpenSnitch: containment rules can pin a binary by hash only when OpenSnitch
|
|
# computes checksums. Offer to turn that on.
|
|
if [ -f /etc/opensnitchd/default-config.json ] && [ -x /usr/local/bin/strawberry ]; then
|
|
if grep -q '"EnableChecksums": *true' /etc/opensnitchd/default-config.json; then
|
|
echo "OpenSnitch checksums already enabled (containment rules are hash-pinned)."
|
|
elif [ -t 0 ]; then
|
|
read -r -p "Enable OpenSnitch checksums so network containment is pinned to the exact binary? [Y/n] " answer
|
|
if [ "$answer" != "n" ] && [ "$answer" != "N" ]; then
|
|
/usr/local/bin/strawberry opensnitch enable-checksums --config /etc/strawberry/strawberry.conf \
|
|
&& systemctl try-restart opensnitchd || true
|
|
fi
|
|
else
|
|
echo "Tip: sudo strawberry opensnitch enable-checksums && sudo systemctl restart opensnitchd"
|
|
fi
|
|
fi
|
|
|
|
# Tracker attribution (advisory, never blocks; docs/tracker-attribution.md).
|
|
# OpenSnitch sends connection events to the host-namespace relay
|
|
# (strawberry-trackerd) on a loopback port only root can bind; the relay strips
|
|
# command lines and environments and forwards the program, tracker domain, port
|
|
# and time to the daemon over an AF_UNIX socket, so the daemon keeps its network
|
|
# sandbox and never sees those secrets. Turn it off with privacy_trackers=false.
|
|
if [ -f /etc/opensnitchd/default-config.json ] && [ -x /usr/local/bin/strawberry ] \
|
|
&& ! grep -q '^privacy_trackers=false' /etc/strawberry/strawberry.conf 2>/dev/null; then
|
|
if events_out=$(/usr/local/bin/strawberry opensnitch enable-events --config /etc/strawberry/strawberry.conf); then
|
|
if [[ "$events_out" == *"will send"* ]]; then
|
|
echo "OpenSnitch configured to send connection events to the tracker relay."
|
|
systemctl try-restart opensnitchd || true
|
|
fi
|
|
else
|
|
echo "Warning: could not set up OpenSnitch connection events (tracker attribution stays off)"
|
|
fi
|
|
echo "Starting the tracker-attribution relay (strawberry-trackerd)..."
|
|
systemctl enable --now strawberry-trackerd.service || \
|
|
echo " (could not start strawberry-trackerd; check 'systemctl status strawberry-trackerd')"
|
|
fi
|
|
|
|
# Offer to grant the invoking desktop user access.
|
|
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
|
if [[ " $(id -nG "$SUDO_USER") " == *" strawberry "* ]]; then
|
|
echo "User '$SUDO_USER' is already in the strawberry group."
|
|
elif [ -t 0 ]; then
|
|
read -r -p "Add '$SUDO_USER' to the strawberry group (view findings, use controls)? [y/N] " answer
|
|
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
|
usermod -aG strawberry "$SUDO_USER"
|
|
echo "Added. Log out and back in for it to take effect."
|
|
fi
|
|
else
|
|
echo "To use the desktop app: sudo usermod -aG strawberry $SUDO_USER (then log out/in)"
|
|
fi
|
|
fi
|
|
|
|
echo
|
|
echo "Installation complete!"
|
|
echo
|
|
echo "To start the scanner now and on every boot:"
|
|
echo " sudo systemctl enable --now strawberry"
|
|
echo
|
|
echo "Rule updates: daily via strawberry-update.timer (first run started now)."
|
|
echo " status: strawberry policy show logs: journalctl -u strawberry-update"
|
|
echo
|
|
echo "Configuration: /etc/strawberry/strawberry.conf"
|
|
PROFILE=$(sed -n 's/^scan_profile=//p' /etc/strawberry/strawberry.conf 2>/dev/null | tail -1)
|
|
echo "Scan profile: ${PROFILE:-balanced (default)} (efficient | balanced | aggressive;"
|
|
echo " set scan_profile= in the config; matching systemd limits: systemctl edit strawberry)"
|
|
echo "State/Data: /var/lib/strawberry/"
|
|
echo "YARA Rules: /etc/strawberry/rules/"
|
|
echo "Logs: journalctl -u strawberry"
|
|
echo
|
|
echo "Desktop app: launch 'Strawberry' from your app launcher, or start the tray"
|
|
echo "indicator with your session. For sway, add to your sway config:"
|
|
echo " exec strawberry-tray"
|