feat(security): dynamic role aliasing in setup_missions

This commit is contained in:
2025-12-28 15:39:38 +01:00
parent b0959a4de1
commit e0e922e9dc

View File

@@ -86,21 +86,23 @@ if ! grep -q "alias dumbo" "$HOME_DIR/.bashrc"; then
# 🎭 Role Aliases (Secure Wrapper)
WRAPPER="/opt/crumbforest/native_crumbcore_v1/scripts/role_wrapper.sh"
ROLES_DIR="/opt/crumbforest/app/crumbforest_roles"
# Helper to add alias if script exists
add_role_alias() {
local role_name=$1
local script_path="/opt/crumbforest/app/crumbforest_roles/${role_name}_zero.sh"
if [ -f "$script_path" ]; then
echo "alias $role_name=\"$WRAPPER $script_path\"" >> "$HOME_DIR/.bashrc"
fi
}
# Add known roles
add_role_alias "dumbo"
add_role_alias "templatus"
add_role_alias "schnippsi"
add_role_alias "bugsy" # Bugsy might have a script too, or just the log tail alias above
# Dynamic Alias Generation
# Scans $ROLES_DIR for *_zero.sh files and creates aliases
# e.g. dumbo_zero.sh -> alias dumbo="..."
if [ -d "$ROLES_DIR" ]; then
for script in "$ROLES_DIR"/*_zero.sh; do
if [ -f "$script" ]; then
# Extract basename without extension (dumbo_zero)
filename=$(basename -- "$script")
role_base="${filename%_zero.sh}"
# Create alias
echo "alias $role_base=\"$WRAPPER $script\"" >> "$HOME_DIR/.bashrc"
fi
done
fi
EOF
fi