-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjudge.sh
More file actions
executable file
·172 lines (153 loc) · 6.38 KB
/
Copy pathjudge.sh
File metadata and controls
executable file
·172 lines (153 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
# ============================================================================
# 🛡️ Mehr Guard Judge Build Helper
# ============================================================================
# Quick setup and run commands for competition judges
# Run: ./judge.sh
# ============================================================================
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo ""
echo -e "${PURPLE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${PURPLE}║${NC} 🛡️ ${CYAN}Mehr Guard Judge Build Helper${NC} ${PURPLE}║${NC}"
echo -e "${PURPLE}║${NC} Kotlin Multiplatform Demo ${PURPLE}║${NC}"
echo -e "${PURPLE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# ============================================================================
# Environment Checks
# ============================================================================
echo -e "${BLUE}📋 Checking Environment...${NC}"
echo ""
# Check Java
if command -v java &> /dev/null; then
JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
echo -e " ${GREEN}✓${NC} Java: $JAVA_VERSION"
else
echo -e " ${RED}✗${NC} Java: NOT FOUND"
echo -e " ${YELLOW}Install: brew install openjdk@17${NC}"
fi
# Check Gradle
if [ -f "./gradlew" ]; then
echo -e " ${GREEN}✓${NC} Gradle Wrapper: Available"
else
echo -e " ${RED}✗${NC} Gradle Wrapper: NOT FOUND"
fi
# Check Node (for web E2E tests)
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version)
echo -e " ${GREEN}✓${NC} Node.js: $NODE_VERSION"
else
echo -e " ${YELLOW}○${NC} Node.js: Not installed (optional, for E2E tests)"
fi
# Check Xcode (for iOS)
if command -v xcodebuild &> /dev/null; then
XCODE_VERSION=$(xcodebuild -version | head -n 1)
echo -e " ${GREEN}✓${NC} Xcode: $XCODE_VERSION"
else
echo -e " ${YELLOW}○${NC} Xcode: Not installed (optional, for iOS build)"
fi
echo ""
# ============================================================================
# Quick Commands
# ============================================================================
echo -e "${BLUE}🚀 Quick Run Commands${NC}"
echo ""
echo -e " ${CYAN}1. Web Demo (Fastest - No build needed!)${NC}"
echo -e " ${GREEN}→ https://raoof128.github.io/?demo=true${NC}"
echo ""
echo -e " ${CYAN}2. Run All Tests${NC}"
echo -e " ${YELLOW}./gradlew :common:allTests${NC}"
echo ""
echo -e " ${CYAN}3. Run Desktop App${NC}"
echo -e " ${YELLOW}./gradlew :desktopApp:run${NC}"
echo ""
echo -e " ${CYAN}4. Build Android APK${NC}"
echo -e " ${YELLOW}./gradlew :androidApp:assembleDebug${NC}"
echo -e " ${GREEN}→ APK: androidApp/build/outputs/apk/debug/androidApp-debug.apk${NC}"
echo ""
echo -e " ${CYAN}5. Run Web Locally${NC}"
echo -e " ${YELLOW}./gradlew :webApp:jsBrowserRun${NC}"
echo -e " ${GREEN}→ Opens at http://localhost:8080${NC}"
echo ""
echo -e " ${CYAN}6. Build iOS Framework${NC}"
echo -e " ${YELLOW}./gradlew :common:linkDebugFrameworkIosSimulatorArm64${NC}"
echo -e " ${GREEN}→ Then open iosApp/MehrGuard.xcodeproj${NC}"
echo ""
# ============================================================================
# What to Test
# ============================================================================
echo -e "${BLUE}🧪 What to Test${NC}"
echo ""
echo -e " ${PURPLE}Sample Malicious URL:${NC} https://paypa1-secure.tk/login"
echo -e " ${PURPLE}Expected Result:${NC} Score 85+, MALICIOUS verdict"
echo -e " ${PURPLE}Triggered Signals:${NC} Brand Impersonation, Suspicious TLD, Typosquatting"
echo ""
echo -e " ${GREEN}Sample Safe URL:${NC} https://google.com"
echo -e " ${GREEN}Expected Result:${NC} Score <20, SAFE verdict"
echo ""
# ============================================================================
# KMP Proof Points
# ============================================================================
echo -e "${BLUE}📐 KMP Architecture Proof${NC}"
echo ""
echo -e " • Shared code: ${CYAN}common/src/commonMain/kotlin/${NC}"
echo -e " • Platform code: ${CYAN}androidApp/, iosApp/, desktopApp/, webApp/${NC}"
echo -e " • Run same test on all platforms: ${YELLOW}./gradlew allTests${NC}"
echo ""
# ============================================================================
# Interactive Menu
# ============================================================================
echo -e "${PURPLE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e "${CYAN}What would you like to do?${NC}"
echo ""
echo " 1) Open Web Demo (browser)"
echo " 2) Run unit tests"
echo " 3) Run desktop app"
echo " 4) Build Android APK"
echo " 5) Run web locally (JS)"
echo " 6) Run web locally (Wasm - NEW)"
echo " 7) Exit"
echo ""
read -p "Enter choice [1-7]: " choice
case $choice in
1)
echo -e "${GREEN}Opening Web Demo...${NC}"
open "https://raoof128.github.io/?demo=true" 2>/dev/null || xdg-open "https://raoof128.github.io/?demo=true" 2>/dev/null || echo "Open: https://raoof128.github.io/?demo=true"
;;
2)
echo -e "${GREEN}Running unit tests...${NC}"
./gradlew :common:allTests
;;
3)
echo -e "${GREEN}Running desktop app...${NC}"
./gradlew :desktopApp:run
;;
4)
echo -e "${GREEN}Building Android APK...${NC}"
./gradlew :androidApp:assembleDebug
echo -e "${GREEN}APK: androidApp/build/outputs/apk/debug/androidApp-debug.apk${NC}"
;;
5)
echo -e "${GREEN}Starting web server (JS)...${NC}"
./gradlew :webApp:jsBrowserRun
;;
6)
echo -e "${GREEN}Starting web server (Wasm)...${NC}"
./gradlew :webApp:wasmJsBrowserRun
;;
7)
echo -e "${CYAN}Goodbye! 👋${NC}"
exit 0
;;
*)
echo -e "${YELLOW}Invalid choice. Run ./judge.sh again.${NC}"
;;
esac