Skip to content

Commit d171235

Browse files
committed
feat: harden security, improve error handling, add integration tests
- agent: proper error propagation in loop, remove unwrap calls - channels: lark/signal/whatsapp input validation and error handling - config/schema: major refactor for type-safe configuration parsing - gateway: API config endpoint, improved module initialization - memory: markdown/snapshot/traits safety improvements - providers: add Codex provider, fix OpenAI error handling - security: audit/detect/secrets hardening with input validation - tools: browser/shell/gateway/web_fetch security boundaries - tests: add 5 cross-module integration tests - docs: consolidate RUN_TESTS.md, remove obsolete docs
1 parent 7ebbc28 commit d171235

34 files changed

Lines changed: 4872 additions & 944 deletions

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ firmware/*/target
44
*.db-journal
55
.DS_Store
66
._*
7-
.wt-pr37/
87
__pycache__/
98
*.pyc
109
docker-compose.override.yml
@@ -30,7 +29,6 @@ venv/
3029
credentials.json
3130
.worktrees/
3231

33-
# Web console
34-
web/node_modules/
35-
web/.svelte-kit/
32+
# Console UI build output
33+
console/dist/
3634
pdk/rust/examples/voice-talk-realtime/target/

RUN_TESTS.md

Lines changed: 44 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,40 @@
1-
# 🧪 Test Execution Guide
1+
# Test Execution Guide
22

33
## Quick Reference
44

55
```bash
6-
# Full automated test suite (~2 min)
7-
./test_telegram_integration.sh
6+
# Unit tests (~30 sec)
7+
cargo test --lib
88

9-
# Quick smoke test (~10 sec)
10-
./quick_test.sh
11-
12-
# Just compile and unit test (~30 sec)
9+
# Telegram-specific unit tests
1310
cargo test telegram --lib
14-
```
15-
16-
## 📝 What Was Created For You
17-
18-
### 1. **test_telegram_integration.sh** (Main Test Suite)
19-
- **20+ automated tests** covering all fixes
20-
- **6 test phases**: Code quality, build, config, health, features, manual
21-
- **Colored output** with pass/fail indicators
22-
- **Detailed summary** at the end
23-
24-
```bash
25-
./test_telegram_integration.sh
26-
```
27-
28-
### 2. **quick_test.sh** (Fast Validation)
29-
- **4 essential tests** for quick feedback
30-
- **<10 second** execution time
31-
- Perfect for **pre-commit** checks
3211

33-
```bash
34-
./quick_test.sh
35-
```
12+
# Full test suite
13+
cargo test --all-features
3614

37-
### 3. **generate_test_messages.py** (Test Helper)
38-
- Generates test messages of various lengths
39-
- Tests message splitting functionality
40-
- 8 different message types
41-
42-
```bash
43-
# Generate a long message (>4096 chars)
44-
python3 test_helpers/generate_test_messages.py long
45-
46-
# Show all message types
47-
python3 test_helpers/generate_test_messages.py all
48-
```
49-
50-
### 4. **TESTING_TELEGRAM.md** (Complete Guide)
51-
- Comprehensive testing documentation
52-
- Troubleshooting guide
53-
- Performance benchmarks
54-
- CI/CD integration examples
15+
# Quick compile check
16+
cargo check --all-features
17+
```
5518

56-
## 🚀 Step-by-Step: First Run
19+
## Step-by-Step: First Run
5720

58-
### Step 1: Run Automated Tests
21+
### Step 1: Run Unit Tests
5922

6023
```bash
61-
cd /Users/abdzsam/zeroclaw
62-
63-
# Make scripts executable (already done)
64-
chmod +x test_telegram_integration.sh quick_test.sh
24+
cd /path/to/prx
6525

6626
# Run the full test suite
67-
./test_telegram_integration.sh
68-
```
69-
70-
**Expected output:**
71-
```
72-
⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡
73-
74-
███████╗███████╗██████╗ ██████╗ ██████╗██╗ █████╗ ██╗ ██╗
75-
...
76-
77-
🧪 TELEGRAM INTEGRATION TEST SUITE 🧪
78-
79-
Phase 1: Code Quality Tests
80-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81-
82-
Test 1: Compiling test suite
83-
✓ PASS: Test suite compiles successfully
84-
85-
Test 2: Running Telegram unit tests
86-
✓ PASS: All Telegram unit tests passed (24 tests)
87-
...
88-
89-
Test Summary
90-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
91-
Total Tests: 20
92-
Passed: 20
93-
Failed: 0
94-
Warnings: 0
95-
96-
Pass Rate: 100%
97-
98-
✓ ALL AUTOMATED TESTS PASSED! 🎉
27+
cargo test --all-features
9928
```
10029

10130
### Step 2: Configure Telegram (if not done)
10231

10332
```bash
10433
# Interactive setup
105-
zeroclaw onboard --interactive
34+
prx onboard --interactive
10635

10736
# Or channels-only setup
108-
zeroclaw onboard --channels-only
37+
prx onboard --channels-only
10938
```
11039

11140
When prompted:
@@ -116,14 +45,14 @@ When prompted:
11645
### Step 3: Verify Health
11746

11847
```bash
119-
zeroclaw channel doctor
48+
prx channel doctor
12049
```
12150

12251
**Expected output:**
12352
```
124-
🩺 ZeroClaw Channel Doctor
53+
OpenPRX Channel Doctor
12554
126-
Telegram healthy
55+
Telegram healthy
12756
12857
Summary: 1 healthy, 0 unhealthy, 0 timed out
12958
```
@@ -134,7 +63,7 @@ Summary: 1 healthy, 0 unhealthy, 0 timed out
13463

13564
```bash
13665
# Terminal 1: Start the channel
137-
zeroclaw channel start
66+
prx channel start
13867
```
13968

14069
**In Telegram:**
@@ -144,55 +73,31 @@ zeroclaw channel start
14473

14574
#### Test 2: Long Message (Split Test)
14675

147-
```bash
148-
# Generate a long message
149-
python3 test_helpers/generate_test_messages.py long
150-
```
151-
152-
- **Copy the output**
153-
- **Paste into Telegram** to your bot
76+
- Send a message longer than 4096 characters to your bot
15477
- **Verify**:
15578
- Message is split into 2+ chunks
156-
- First chunk ends with `(continues...)`
157-
- Middle chunks have `(continued)` and `(continues...)`
158-
- Last chunk starts with `(continued)`
15979
- All chunks arrive in order
16080

161-
#### Test 3: Word Boundary Splitting
162-
163-
```bash
164-
python3 test_helpers/generate_test_messages.py word
165-
```
166-
167-
- Send to bot
168-
- **Verify**: Splits at word boundaries (not mid-word)
169-
170-
## 🎯 Test Results Checklist
81+
## Test Results Checklist
17182

17283
After running all tests, verify:
17384

17485
### Automated Tests
175-
- [ ] ✅ All 20 automated tests passed
176-
- [ ] ✅ Build completed successfully
177-
- [ ] ✅ Binary size <10MB
178-
- [ ] ✅ Health check completes in <5s
179-
- [ ] ✅ No clippy warnings
86+
- [ ] All unit tests pass
87+
- [ ] Build completed successfully
88+
- [ ] No clippy warnings
18089

18190
### Manual Tests
182-
- [ ] ✅ Bot responds to basic messages
183-
- [ ] ✅ Long messages split correctly
184-
- [ ] ✅ Continuation markers appear
185-
- [ ] ✅ Word boundaries respected
186-
- [ ] ✅ Allowlist blocks unauthorized users
187-
- [ ] ✅ No errors in logs
91+
- [ ] Bot responds to basic messages
92+
- [ ] Long messages split correctly
93+
- [ ] Allowlist blocks unauthorized users
94+
- [ ] No errors in logs
18895

18996
### Performance
190-
- [ ] ✅ Response time <3 seconds
191-
- [ ] ✅ Memory usage <10MB
192-
- [ ] ✅ No message loss
193-
- [ ] ✅ Rate limiting works (100ms delays)
97+
- [ ] Response time <3 seconds
98+
- [ ] No message loss
19499

195-
## 🐛 Troubleshooting
100+
## Troubleshooting
196101

197102
### Issue: Tests fail to compile
198103

@@ -209,10 +114,10 @@ cargo update
209114

210115
```bash
211116
# Check config
212-
cat ~/.zeroclaw/config.toml | grep -A 5 telegram
117+
cat ~/.openprx/config.toml | grep -A 5 telegram
213118

214119
# Reconfigure
215-
zeroclaw onboard --channels-only
120+
prx onboard --channels-only
216121
```
217122

218123
### Issue: Health check fails
@@ -228,76 +133,35 @@ curl "https://api.telegram.org/bot<YOUR_TOKEN>/getMe"
228133

229134
```bash
230135
# Enable debug logging
231-
RUST_LOG=debug zeroclaw channel start
136+
RUST_LOG=debug prx channel start
232137

233138
# Look for:
234139
# - "Telegram channel listening for messages..."
235140
# - "ignoring message from unauthorized user" (if allowlist issue)
236141
# - Any error messages
237142
```
238143

239-
## 📊 Performance Benchmarks
240-
241-
After all fixes, you should see:
144+
## Performance Benchmarks
242145

243146
| Metric | Target | Command |
244147
|--------|--------|---------|
245-
| Unit test pass | 24/24 | `cargo test telegram --lib` |
148+
| Unit test pass | all pass | `cargo test --lib` |
246149
| Build time | <30s | `time cargo build --release` |
247-
| Binary size | ~3-4MB | `ls -lh target/release/zeroclaw` |
248-
| Health check | <5s | `time zeroclaw channel doctor` |
150+
| Health check | <5s | `time prx channel doctor` |
249151
| First response | <3s | Manual test in Telegram |
250-
| Message split | <50ms | Check debug logs |
251-
| Memory usage | <10MB | `ps aux \| grep zeroclaw` |
252152

253-
## 🔄 CI/CD Integration
153+
## CI/CD Integration
254154

255155
Add to your workflow:
256156

257157
```bash
258-
# Pre-commit hook
259-
#!/bin/bash
260-
./quick_test.sh
261-
262158
# CI pipeline
263-
./test_telegram_integration.sh
159+
cargo fmt --all -- --check
160+
cargo clippy --all-targets --all-features -- -D warnings
161+
cargo test --all-features
264162
```
265163

266-
## 📚 Next Steps
267-
268-
1. **Run the tests:**
269-
```bash
270-
./test_telegram_integration.sh
271-
```
272-
273-
2. **Fix any failures** using the troubleshooting guide
274-
275-
3. **Complete manual tests** using the checklist
276-
277-
4. **Deploy to production** when all tests pass
278-
279-
5. **Monitor logs** for any issues:
280-
```bash
281-
zeroclaw daemon
282-
# or
283-
RUST_LOG=info zeroclaw channel start
284-
```
285-
286-
## 🎉 Success!
287-
288-
If all tests pass:
289-
- ✅ Message splitting works (4096 char limit)
290-
- ✅ Health check has 5s timeout
291-
- ✅ Empty chat_id is handled safely
292-
- ✅ All 24 unit tests pass
293-
- ✅ Code is production-ready
294-
295-
**Your Telegram integration is ready to go!** 🚀
296-
297-
---
298-
299-
## 📞 Support
164+
## Support
300165

301-
- Issues: https://github.com/theonlyhennygod/zeroclaw/issues
302-
- Docs: `./TESTING_TELEGRAM.md`
303-
- Help: `zeroclaw --help`
166+
- Issues: https://github.com/openprx/prx/issues
167+
- Help: `prx --help`

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Instead, please report them responsibly:
1414

1515
1. **Email**: Send details to the maintainers via GitHub private vulnerability reporting
16-
2. **GitHub**: Use [GitHub Security Advisories](https://github.com/theonlyhennygod/openprx/security/advisories/new)
16+
2. **GitHub**: Use [GitHub Security Advisories](https://github.com/openprx/prx/security/advisories/new)
1717

1818
### What to Include
1919

0 commit comments

Comments
 (0)