Skip to content

Commit a0aea69

Browse files
authored
Added pauses and syntax highlighting to demo for clarity (#358)
1 parent a458ca6 commit a0aea69

File tree

1 file changed

+29
-3
lines changed
  • examples/sandbox-policy-quickstart

1 file changed

+29
-3
lines changed

examples/sandbox-policy-quickstart/demo.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ cleanup() {
3131
trap cleanup EXIT
3232

3333
BOLD='\033[1m'
34+
DIM='\033[2m'
3435
CYAN='\033[36m'
3536
GREEN='\033[32m'
3637
RED='\033[31m'
3738
YELLOW='\033[33m'
39+
MAGENTA='\033[35m'
3840
RESET='\033[0m'
3941

42+
STEP_PAUSE="${DEMO_PAUSE:-1}"
43+
4044
step() {
45+
sleep "$STEP_PAUSE"
4146
printf "\n${BOLD}${CYAN}▸ %s${RESET}\n\n" "$1"
4247
}
4348

@@ -47,6 +52,19 @@ run() {
4752
return "${PIPESTATUS[0]}"
4853
}
4954

55+
colorize_logs() {
56+
sed \
57+
-e "s/action=deny/$(printf '\033[1;31m')action=deny$(printf '\033[0m')/g" \
58+
-e "s/action=allow/$(printf '\033[1;32m')action=allow$(printf '\033[0m')/g" \
59+
-e "s/dst_host=[^ ]*/$(printf '\033[36m')&$(printf '\033[0m')/g" \
60+
-e "s/dst_port=[^ ]*/$(printf '\033[36m')&$(printf '\033[0m')/g" \
61+
-e "s/binary=[^ ]*/$(printf '\033[1m')&$(printf '\033[0m')/g" \
62+
-e "s/reason=[^\"]*/$(printf '\033[33m')&$(printf '\033[0m')/g" \
63+
-e "s/policy=[^ ]*/$(printf '\033[35m')&$(printf '\033[0m')/g" \
64+
-e "s/\[CONNECT\]/$(printf '\033[1m')[CONNECT]$(printf '\033[0m')/g" \
65+
-e "s/\[FORWARD\]/$(printf '\033[1m')[FORWARD]$(printf '\033[0m')/g"
66+
}
67+
5068
sandbox_exec() {
5169
ssh -F "$SSH_CONFIG" "$SSH_HOST" "$@" 2>&1
5270
}
@@ -92,7 +110,11 @@ printf " ${RED}✗ Blocked by default-deny policy.${RESET}\n"
92110

93111
step "3/7 Checking deny log"
94112
sleep 2
95-
run openshell logs "$SANDBOX_NAME" --since 1m -n 5
113+
printf " ${BOLD}\$ openshell logs ${SANDBOX_NAME} --since 1m -n 10${RESET}\n"
114+
openshell logs "$SANDBOX_NAME" --since 1m -n 10 2>&1 \
115+
| grep -i 'connect\|forward\|deny\|allow' \
116+
| colorize_logs \
117+
| sed 's/^/ /'
96118

97119
# ------------------------------------------------------------------
98120

@@ -128,13 +150,17 @@ printf " ${YELLOW}%s${RESET}\n" "$RESPONSE"
128150

129151
step "7/7 Checking L7 deny log"
130152
sleep 2
131-
run openshell logs "$SANDBOX_NAME" --level warn --since 1m -n 5
153+
printf " ${BOLD}\$ openshell logs ${SANDBOX_NAME} --level warn --since 1m -n 10${RESET}\n"
154+
openshell logs "$SANDBOX_NAME" --level warn --since 1m -n 10 2>&1 \
155+
| grep -i 'connect\|forward\|deny\|allow\|l7\|rest' \
156+
| colorize_logs \
157+
| sed 's/^/ /'
132158

133159
# ------------------------------------------------------------------
134160

135161
printf "\n${BOLD}${GREEN}✓ Demo complete.${RESET}\n\n"
136162
printf " What you saw:\n"
137-
printf " 1. Default deny — all outbound traffic blocked\n"
163+
printf " 1. Default deny — minimal outbound access, explicit approval required\n"
138164
printf " 2. L7 read-only — GET allowed, POST blocked at the HTTP method level\n"
139165
printf " 3. Audit trail — every request logged with method, path, and decision\n\n"
140166
printf " The policy is %s lines of YAML.\n" "$(wc -l < "$POLICY_FILE" | tr -d ' ')"

0 commit comments

Comments
 (0)