bridge: fix stale runtime slack-bridge path references#160
Conversation
Greptile SummaryThis PR migrates slack-bridge security path references from the legacy agent-owned Key changes:
All tests pass and the change properly maintains security boundaries while migrating to the immutable release model. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 0dea634 |
| echo \"[\$(date -Is)] bridge: starting $BRIDGE_SCRIPT\" >> $BRIDGE_LOG_FILE; \ | ||
| varlock run --path \$HOME/.config/ -- node $BRIDGE_SCRIPT >> $BRIDGE_LOG_FILE 2>&1; \ | ||
| for v in \$(env | grep ^SLACK_BROKER_ | cut -d= -f1 || true); do unset \$v; done; \ | ||
| set -a; source \$HOME/.config/.env; set +a; \ |
There was a problem hiding this comment.
Bug: The script sources .env without error handling. If the file is missing or invalid, the bridge starts without required environment variables, causing an infinite crash loop.
Severity: CRITICAL
Suggested Fix
Ensure the script exits if sourcing the .env file fails. This can be achieved by adding set -e to the beginning of the tmux command string or by checking the exit code of the source command, for example: source \$HOME/.config/.env || exit 1.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: pi/skills/control-agent/startup-cleanup.sh#L149
Potential issue: The script sources the `$HOME/.config/.env` file within a `tmux`
command that does not have `set -e` enabled. If the `source` command fails because the
file is missing, unreadable, or contains syntax errors, the script will not exit.
Instead, it will proceed to launch the Node.js bridge script without the required
environment variables. The bridge script is designed to exit immediately if these
variables are not present. Since this logic is inside a `while true` loop, this will
result in an infinite crash loop, preventing the Slack integration from functioning and
consuming system resources.
Did we get this right? 👍 / 👎 to inform future reviews.
Summary
/opt/baudbot/current/slack-bridge/*chmod-runtime-securitydeny rule to also match/opt/baudbot/current/slack-bridge/security*while keeping legacy runtime matcher for defense-in-depth/optrelease path protectionsstartup-cleanup.shbridge launch loop to bypassvarlock runand load env directly from~/.config/.envafter clearing inheritedSLACK_BROKER_*vars~/runtime/slack-bridgedirectoryValidation
bin/test.sh(15/15 passed)