Skip to content

Commit e5b49e4

Browse files
committed
security: align audits with release bridge location
1 parent af60c5f commit e5b49e4

4 files changed

Lines changed: 36 additions & 30 deletions

File tree

bin/doctor.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,14 @@ else
279279
fi
280280
fi
281281

282-
if [ -d "$BAUDBOT_HOME/runtime/slack-bridge" ] && [ -f "$BAUDBOT_HOME/runtime/slack-bridge/bridge.mjs" ]; then
283-
pass "slack bridge deployed"
282+
BRIDGE_DIR="$BAUDBOT_CURRENT_LINK/slack-bridge"
283+
if [ -d "$BRIDGE_DIR" ] && [ -f "$BRIDGE_DIR/bridge.mjs" ]; then
284+
pass "slack bridge deployed ($BRIDGE_DIR)"
284285
else
285-
if [ "$IS_ROOT" -ne 1 ] && [ -d "$BAUDBOT_HOME/runtime" ]; then
286+
if [ "$IS_ROOT" -ne 1 ] && { [ -d "$BAUDBOT_CURRENT_LINK" ] || [ -e "$BAUDBOT_CURRENT_LINK" ]; }; then
286287
warn "cannot verify slack bridge files as non-root (run: sudo baudbot doctor)"
287288
else
288-
fail "slack bridge not deployed (run: baudbot deploy)"
289+
fail "slack bridge not deployed (expected: $BRIDGE_DIR; run: sudo baudbot update)"
289290
fi
290291
fi
291292

bin/security-audit.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ else
219219
ok "~/.pi/agent/skills/ is a real directory"
220220
fi
221221

222-
# Check runtime bridge exists
222+
BRIDGE_DIR="$BAUDBOT_CURRENT_LINK/slack-bridge"
223223
# shellcheck disable=SC2088
224-
if [ -d "$BAUDBOT_HOME/runtime/slack-bridge" ]; then
225-
ok "Runtime bridge directory exists"
224+
if [ -d "$BRIDGE_DIR" ]; then
225+
ok "Release bridge directory exists ($BRIDGE_DIR)"
226226
else
227-
finding "WARN" "~/runtime/slack-bridge/ not found" \
228-
"Run: deploy.sh"
227+
finding "WARN" "release bridge directory not found" \
228+
"Expected: $BRIDGE_DIR (run: sudo baudbot update)"
229229
fi
230230

231231
# Check version stamp exists
@@ -251,10 +251,14 @@ if [ -f "$MANIFEST_FILE" ]; then
251251
for critical_file in \
252252
".pi/agent/extensions/tool-guard.ts" \
253253
".pi/agent/extensions/tool-guard.test.mjs" \
254-
"runtime/slack-bridge/security.mjs" \
255-
"runtime/slack-bridge/security.test.mjs"; do
254+
"release/slack-bridge/security.mjs" \
255+
"release/slack-bridge/security.test.mjs"; do
256256

257-
full_path="$BAUDBOT_HOME/$critical_file"
257+
if [[ "$critical_file" == release/* ]]; then
258+
full_path="$BAUDBOT_CURRENT_LINK/${critical_file#release/}"
259+
else
260+
full_path="$BAUDBOT_HOME/$critical_file"
261+
fi
258262
if [ ! -f "$full_path" ]; then
259263
finding "WARN" "Missing critical file: $critical_file" "Run deploy.sh"
260264
missing=$((missing + 1))
@@ -649,17 +653,17 @@ if [ "$DEEP" -eq 1 ]; then
649653
fi
650654

651655
# Check that bridge security.mjs exists and is tested
652-
if [ -f "$BAUDBOT_HOME/runtime/slack-bridge/security.mjs" ]; then
653-
ok "Bridge security module exists (runtime)"
654-
if [ -f "$BAUDBOT_HOME/runtime/slack-bridge/security.test.mjs" ]; then
655-
ok "Bridge security tests exist (runtime)"
656+
if [ -f "$BRIDGE_DIR/security.mjs" ]; then
657+
ok "Bridge security module exists (release)"
658+
if [ -f "$BRIDGE_DIR/security.test.mjs" ]; then
659+
ok "Bridge security tests exist (release)"
656660
else
657-
finding "WARN" "No tests for bridge security module in runtime" \
658-
"Run deploy.sh to copy from source"
661+
finding "WARN" "No tests for bridge security module in release" \
662+
"Run: sudo baudbot update"
659663
fi
660664
else
661665
finding "WARN" "Bridge security module not found" \
662-
"Expected in ~/runtime/slack-bridge/security.mjs — run deploy.sh"
666+
"Expected in $BRIDGE_DIR/security.mjs — run: sudo baudbot update"
663667
fi
664668
echo ""
665669

bin/security-audit.test.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trap cleanup EXIT
1919
setup_base() {
2020
local home="$1"
2121
rm -rf "$home"
22-
mkdir -p "$home/.config" "$home/.ssh" "$home/.pi" "$home/baudbot/slack-bridge" "$home/baudbot/.git"
22+
mkdir -p "$home/.config" "$home/.ssh" "$home/.pi" "$home/opt/baudbot/current/slack-bridge" "$home/baudbot/.git"
2323

2424
# Secrets file
2525
echo "SLACK_BOT_TOKEN=xoxb-test" > "$home/.config/.env"
@@ -38,8 +38,8 @@ setup_base() {
3838
echo -e "[user]\n\tname = test\n\temail = test@test.com" > "$home/.gitconfig"
3939

4040
# Bridge security module
41-
echo "// security" > "$home/baudbot/slack-bridge/security.mjs"
42-
echo "// tests" > "$home/baudbot/slack-bridge/security.test.mjs"
41+
echo "// security" > "$home/opt/baudbot/current/slack-bridge/security.mjs"
42+
echo "// tests" > "$home/opt/baudbot/current/slack-bridge/security.test.mjs"
4343

4444
# Audit log (fallback location)
4545
mkdir -p "$home/logs"
@@ -50,7 +50,7 @@ setup_base() {
5050
run_audit() {
5151
local home="$1"
5252
shift
53-
BAUDBOT_HOME="$home" bash "$SCRIPT" "$@" 2>&1 || true
53+
BAUDBOT_HOME="$home" BAUDBOT_RELEASE_ROOT="$home/opt/baudbot" bash "$SCRIPT" "$@" 2>&1 || true
5454
}
5555

5656
expect_contains() {
@@ -183,7 +183,7 @@ echo ""
183183
echo "Test: missing bridge security module"
184184
HOME8="$TMPDIR/no-bridge-sec"
185185
setup_base "$HOME8"
186-
rm -f "$HOME8/baudbot/slack-bridge/security.mjs"
186+
rm -f "$HOME8/opt/baudbot/current/slack-bridge/security.mjs"
187187

188188
output=$(run_audit "$HOME8")
189189
expect_contains "reports missing security module" "$output" "Bridge security module not found"
@@ -195,7 +195,7 @@ echo ""
195195
echo "Test: missing bridge tests"
196196
HOME9="$TMPDIR/no-bridge-tests"
197197
setup_base "$HOME9"
198-
rm -f "$HOME9/baudbot/slack-bridge/security.test.mjs"
198+
rm -f "$HOME9/opt/baudbot/current/slack-bridge/security.test.mjs"
199199

200200
output=$(run_audit "$HOME9")
201201
expect_contains "reports missing tests" "$output" "No tests for bridge security"
@@ -224,7 +224,7 @@ HOME11="$TMPDIR/exitcode"
224224
setup_base "$HOME11"
225225
echo "SLACK_ALLOWED_USERS=U12345" >> "$HOME11/.config/.env"
226226
set +e
227-
BAUDBOT_HOME="$HOME11" bash "$SCRIPT" >/dev/null 2>&1
227+
BAUDBOT_HOME="$HOME11" BAUDBOT_RELEASE_ROOT="$HOME11/opt/baudbot" bash "$SCRIPT" >/dev/null 2>&1
228228
code=$?
229229
set -e
230230
if [ "$code" -le 2 ]; then
@@ -239,7 +239,7 @@ HOME11b="$TMPDIR/exitcode-crit"
239239
setup_base "$HOME11b"
240240
chmod 644 "$HOME11b/.config/.env"
241241
set +e
242-
BAUDBOT_HOME="$HOME11b" bash "$SCRIPT" >/dev/null 2>&1
242+
BAUDBOT_HOME="$HOME11b" BAUDBOT_RELEASE_ROOT="$HOME11b/opt/baudbot" bash "$SCRIPT" >/dev/null 2>&1
243243
code=$?
244244
set -e
245245
if [ "$code" -eq 2 ]; then

test/security-audit.test.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function setupFixture(homeDir) {
1313
fs.mkdirSync(path.join(homeDir, ".config"), { recursive: true });
1414
fs.mkdirSync(path.join(homeDir, ".ssh"), { recursive: true });
1515
fs.mkdirSync(path.join(homeDir, ".pi/agent"), { recursive: true });
16-
fs.mkdirSync(path.join(homeDir, "runtime/slack-bridge"), { recursive: true });
16+
fs.mkdirSync(path.join(homeDir, "opt/baudbot/current/slack-bridge"), { recursive: true });
1717
fs.mkdirSync(path.join(homeDir, "baudbot/.git/hooks"), { recursive: true });
1818
fs.mkdirSync(path.join(homeDir, "logs"), { recursive: true });
1919

@@ -29,8 +29,8 @@ function setupFixture(homeDir) {
2929
path.join(homeDir, ".pi/agent/baudbot-version.json"),
3030
JSON.stringify({ short: "testsha", deployed_at: "2026-01-01T00:00:00Z" }),
3131
);
32-
fs.writeFileSync(path.join(homeDir, "runtime/slack-bridge/security.mjs"), "// security\n");
33-
fs.writeFileSync(path.join(homeDir, "runtime/slack-bridge/security.test.mjs"), "// tests\n");
32+
fs.writeFileSync(path.join(homeDir, "opt/baudbot/current/slack-bridge/security.mjs"), "// security\n");
33+
fs.writeFileSync(path.join(homeDir, "opt/baudbot/current/slack-bridge/security.test.mjs"), "// tests\n");
3434
fs.writeFileSync(path.join(homeDir, "logs/commands.log"), "");
3535
}
3636

@@ -43,6 +43,7 @@ function runAudit(homeDir, args = []) {
4343
BAUDBOT_HOME: homeDir,
4444
BAUDBOT_SRC: path.join(homeDir, "baudbot"),
4545
BAUDBOT_AGENT_USER: "baudbot_agent",
46+
BAUDBOT_RELEASE_ROOT: path.join(homeDir, "opt/baudbot"),
4647
},
4748
});
4849

0 commit comments

Comments
 (0)