Skip to content

Commit 3db083b

Browse files
committed
show-log.shをreport.shに置き換え、ログ解析機能を改善。README.mdとMakefileを更新して新しいスクリプトを反映。
1 parent abd99ad commit 3db083b

File tree

6 files changed

+73
-66
lines changed

6 files changed

+73
-66
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565

6666
- name: Show logs
6767
if: always()
68-
run: ./show-log.sh || true
68+
run: ./report/report.sh || true
6969

7070
- name: Run assertions
7171
run: ${{ matrix.assert_script }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_restrict_mode: ## RESTRICTモードテスト
4747
--platform linux/arm64 \
4848
--progress=plain -f test/Dockerfile.restrict test/ \
4949
--load -t buildcage-test
50-
@./show-log.sh || true
50+
@./report/report.sh || true
5151
@./test/assert-restrict-mode.sh
5252
@$(MAKE) clean
5353

@@ -61,6 +61,6 @@ test_audit_mode: ## AUDITモードテスト
6161
--platform linux/arm64 \
6262
--progress=plain -f test/Dockerfile.audit test/ \
6363
--load -t buildcage-test
64-
@./show-log.sh || true
64+
@./report/report.sh || true
6565
@./test/assert-audit-mode.sh
6666
@$(MAKE) clean

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ make test_restrict_mode
209209

210210
```bash
211211
# 全通信ログ
212-
./show-log.sh
212+
./report/report.sh
213213
214214
# リアルタイムログ監視
215215
docker compose logs -f builder
@@ -242,11 +242,11 @@ docker compose logs -f builder
242242
│ ├── action.yml # GitHub Action: dash14/buildcage/setup@main
243243
│ └── compose.action.yml # GitHub Actions用Compose設定(imageタグ付き)
244244
├── report/
245-
│ └── action.yml # GitHub Action: dash14/buildcage/report@main
245+
│ ├── action.yml # GitHub Action: dash14/buildcage/report@main
246+
│ └── report.sh # ログ解析スクリプト
246247
├── compose.yml # Docker Compose設定
247248
├── compose.test.yml # テスト用オーバーライド設定
248249
├── Makefile # 操作用コマンド集
249-
├── show-log.sh # ログ解析スクリプト
250250
├── docker/
251251
│ ├── Dockerfile # マルチステージBuildKit + nginx + dnsmasq
252252
│ └── files/ # Builderコンテナ設定ファイル
@@ -284,7 +284,7 @@ docker buildx build --builder buildcage --progress=plain -f test/Dockerfile.rest
284284
make clean
285285
make run_audit_mode
286286
docker buildx build --builder buildcage --no-cache --progress=plain -f test/Dockerfile.restrict test/
287-
./show-log.sh
287+
./report/report.sh
288288

289289
# 必要ドメインを許可リストに追加
290290
make clean

report/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
COMPOSE_FILE: ${{ github.action_path }}/../setup/compose.action.yml
1717
FAIL_ON_BLOCKED: ${{ inputs.fail_on_blocked }}
1818
run: |
19-
"${{ github.action_path }}/../show-log.sh" || {
19+
"${{ github.action_path }}/report.sh" || {
2020
if [ "$FAIL_ON_BLOCKED" = "true" ]; then
2121
exit 1
2222
fi

report/report.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
LOGS=$(docker compose logs --no-log-prefix builder 2>/dev/null)
4+
5+
echo ""
6+
echo "HTTP Proxy communication logs:"
7+
echo "======================================"
8+
echo "$LOGS" | grep -E '^\['
9+
echo ""
10+
11+
# モード自動検出
12+
if echo "$LOGS" | grep -q '\[AUDIT\]'; then
13+
MODE=audit
14+
elif echo "$LOGS" | grep -q '\[BLOCKED\]\|\[ALLOWED\]'; then
15+
MODE=restrict
16+
else
17+
echo "No proxy logs found."
18+
exit 0
19+
fi
20+
21+
echo "Accessed hosts summary:"
22+
echo "------------------------------------"
23+
24+
if [ "$MODE" = "audit" ]; then
25+
echo "🔍 Audited hosts (audit mode - all logged):"
26+
echo "$LOGS" | \
27+
grep '\[AUDIT\]' | \
28+
grep -oE '"[^"]*"' | \
29+
tr -d '"' | \
30+
grep -v '^$' | \
31+
sort | uniq -c | sort -rn | \
32+
while read count host; do
33+
echo " $count x $host"
34+
done
35+
else
36+
echo "✅ Allowed hosts (proxied to real servers):"
37+
echo "$LOGS" | \
38+
grep '\[ALLOWED\]' | \
39+
grep -oE '"[^"]*"' | \
40+
tr -d '"' | \
41+
grep -v '^$' | \
42+
sort | uniq -c | sort -rn | \
43+
while read count host; do
44+
echo " $count x $host"
45+
done
46+
47+
echo ""
48+
echo "❌ Blocked hosts (rejected):"
49+
echo "$LOGS" | \
50+
grep '\[BLOCKED\]' | \
51+
grep -oE '"[^"]*"' | \
52+
tr -d '"' | \
53+
grep -v '^$' | \
54+
sort | uniq -c | sort -rn | \
55+
while read count host; do
56+
echo " $count x $host"
57+
done
58+
59+
BLOCKED_COUNT=$(echo "$LOGS" | grep '\[BLOCKED\]' | wc -l)
60+
if [ "$BLOCKED_COUNT" -gt 0 ]; then
61+
echo ""
62+
echo "⚠️ Warning: $BLOCKED_COUNT blocked connection(s) detected"
63+
exit 1
64+
fi
65+
fi

show-log.sh

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)