Files
shopdb-flask/DEPLOYMENT-STATUS-2026-09-14.md
Proudlock 5cd5332397
Some checks failed
CI / backend (push) Has been cancelled
CI / naming (push) Has been cancelled
CI / gates (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / lean-build (push) Has been cancelled
Add agent fingerprinting, client certificate auth, and security audit documentation
This commit adds:
- Database migrations for app_delta fingerprints and client certificates
- Scripts for certificate generation and fingerprint backfilling
- Comprehensive security audit reports and findings tracking
- Implementation documentation for certificate authentication
- Test utilities for certificate renewal and fingerprinting
- GE-ENFORCE collector fix documentation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-09-15 09:18:12 -04:00

270 lines
8.2 KiB
Markdown

# Deployment Status - 2026-09-14
## Current State
### Backend (Docker)
- **Flask API**: Running (restarted at 12:46 PM to reload code)
- **MySQL**: Running (healthy)
- **Version**: Backend 1.17.0 with delta optimization
- **Code**: Volume-mounted from host (has latest changes)
- **Status**: ✓ Ready to receive fingerprints
### Agent (SFTest VM - 192.168.100.10)
- **Service**: Running
- **Version**: 1.18.0 (with fingerprint computation)
- **Status**: ✓ Sending fingerprints in payload
- **Next Report**: Every 15 minutes (last attempt: 12:44 PM → 500 error)
### Issue Found
**Problem**: Flask returned 500 error on collector POST at 12:44 PM
**Root Cause**: Flask container wasn't reloaded after code changes (volume-mounted but cached in memory)
**Fix Applied**: Restarted flask-shopdb-api-1 container at 12:46 PM
**Next Step**: Wait for agent's next 15-minute report cycle to verify delta mode activation
---
## What's Deployed
### Backend Changes (1.17.0)
1. ✓ Advisory locks for applications (pg_advisory_xact_lock)
2. ✓ Advisory locks for events (pg_advisory_xact_lock)
3. ✓ UNIQUE constraint on (assetid, app_fingerprint)
4. ✓ Pre-compiled regex for fingerprint validation
5. ✓ Delta logic (_replace_applications with set operations)
6. ✓ Legacy fallback for agents without fingerprints
7. ✓ Migration 0020 applied (app_fingerprint column exists)
### Agent Changes (1.18.0)
1. ✓ SHA256 fingerprint computation (ComputeApplicationFingerprint)
2. ✓ Fingerprint included in collector payload
3. ✓ Algorithm matches Python backend exactly
4. ✓ UTF-8 encoding, lowercase hex output
---
## Architecture
```
┌─────────────────────────────────────┐
│ SFTest VM (192.168.100.10) │
│ │
│ ShopDbEndpointAgent v1.18.0 │
│ - Collects app inventory │
│ - Computes SHA256 fingerprints │
│ - Posts to collector API │
│ every 15 minutes │
└──────────────┬──────────────────────┘
│ HTTPS POST
│ /api/collector/endpoints
▼
┌─────────────────────────────────────┐
│ Host PC (192.168.100.1) │
│ │
│ Docker: flask-shopdb-api-1 │
│ - Receives collector payload │
│ - Validates fingerprints │
│ - Computes delta (set operations) │
│ - Only touches changed apps │
│ │
│ Docker: flask-shopdb-db-1 (MySQL) │
│ - Stores application inventory │
│ - app_fingerprint column (SHA256) │
│ - UNIQUE constraint enforced │
└─────────────────────────────────────┘
```
**NOT in Docker**: Agent/Tray are Windows executables on the VM, not in containers
---
## Monitoring Next Report
### Expected Timeline
- Last report attempt: 12:44:10 PM (500 error)
- Flask restarted: 12:46:00 PM
- Next report: ~12:59 PM (15 minutes after 12:44)
### Success Indicators
**Backend Logs** (should show):
```
[collector] asset_id=2528 hostname=DESKTOP-HF1K9M4 apps_added=0 apps_removed=0 unchanged=50 (delta mode)
```
**vs Legacy Mode** (should NOT show):
```
[collector] asset_id=2528 hostname=DESKTOP-HF1K9M4 apps_stored=50 (legacy mode)
```
### Database Query
```sql
-- Check if fingerprints are being stored
SELECT
assetid,
displayname,
app_fingerprint,
recordedat
FROM endpointapplications
WHERE assetid = 2528 -- SFTest VM asset
ORDER BY recordedat DESC
LIMIT 10;
```
Expected: `app_fingerprint` column populated with 64-char hex strings
---
## Performance Validation
### Before (Agent 1.16.0 / Backend without delta)
```
DELETE FROM endpointapplications WHERE assetid=2528; -- 50 rows
INSERT INTO endpointapplications VALUES (...); -- 50 rows
Total: 100 database operations per report
```
### After (Agent 1.18.0 / Backend 1.17.0 with delta)
**First report after upgrade** (expected):
```
SELECT app_fingerprint FROM endpointapplications WHERE assetid=2528; -- 1 query
(finds 0 existing fingerprints because backfill hasn't run yet)
DELETE FROM endpointapplications WHERE assetid=2528; -- 0 rows (none with fingerprints)
INSERT INTO endpointapplications VALUES (...); -- 50 rows (all new)
Total: 51 operations (one-time setup)
```
**Subsequent reports with no changes** (expected):
```
SELECT app_fingerprint FROM endpointapplications WHERE assetid=2528; -- 1 query (returns 50 fps)
Compare: incoming 50 fps vs existing 50 fps
Delta: 0 to add, 0 to remove, 50 unchanged
Total: 1 database operation (99% reduction!)
```
**Subsequent reports with 1 app changed** (typical):
```
SELECT app_fingerprint FROM endpointapplications WHERE assetid=2528; -- 1 query
Compare: incoming 50 fps vs existing 50 fps
Delta: 1 to add (new version), 1 to remove (old version), 49 unchanged
DELETE WHERE app_fingerprint='old_fp'; -- 1 row
INSERT VALUES ('new_fp', ...); -- 1 row
Total: 3 database operations (97% reduction vs baseline)
```
---
## Troubleshooting
### If Next Report Shows 500 Error
**Check**:
1. Flask logs: `docker logs flask-shopdb-api-1 --tail 50`
2. Python traceback in logs
3. Plugin imports OK: `docker exec flask-shopdb-api-1 sh -c "python -c 'from plugins.endpoints.plugin import EndpointsPlugin'"`
**Fix**: Restart container if code not reloaded
### If Next Report Shows "Legacy Mode"
**Possible Causes**:
1. Agent not sending fingerprints (check agent version)
2. Backend not detecting fingerprints (check payload parsing)
3. Fingerprint validation failing (check backend regex)
**Check Agent Payload** (in Flask logs):
```
Look for: "fingerprint": "a22de9ae7e641954..."
```
### If Delta Mode Activated But All Apps Show as Changed
**Possible Causes**:
1. Algorithm mismatch (C# vs Python)
2. Encoding difference (UTF-8 expected)
3. Case sensitivity (lowercase expected)
**Verify**:
Compare C# output vs Python backfill script output for same app
---
## Rollout Status
### Completed
- ✓ Backend 1.17.0 deployed to Docker
- ✓ Agent 1.18.0 deployed to SFTest VM (1 endpoint)
- ✓ Migration 0020 applied
- ✓ Flask restarted to reload code
### In Progress
- ⏳ Waiting for next agent report (~12:59 PM)
- ⏳ Validating delta mode activation
- ⏳ Measuring actual performance impact
### Pending
- Backend: Run backfill script (populate fingerprints for existing records)
- Agent: Deploy to pilot group (10% of fleet)
- Agent: Deploy to full fleet (remaining 90%)
---
## Expected Timeline
**Today (2026-09-14)**:
- 12:59 PM: Next agent report (should succeed with delta mode)
- 1:00 PM: Verify fingerprints in database
- 1:15 PM: Next report (verify 99% reduction)
**This Week**:
- Run backfill script on production database
- Monitor SFTest for 24-48 hours
- Verify delta mode stability
**Next Week**:
- Deploy agent 1.18.0 to 10% of fleet
- Monitor fingerprint adoption rate
- Measure actual write reduction
**Month 1**:
- Complete fleet rollout
- Verify 99% write reduction achieved
- Document actual vs expected performance
---
## Success Criteria
### Phase 1: SFTest Validation (Today)
- [ ] Next report succeeds (no 500 error)
- [ ] Backend logs show "delta mode"
- [ ] Fingerprints populated in database
- [ ] Subsequent report shows 1 operation (vs 100 before)
### Phase 2: Pilot (Week 1)
- [ ] 10% of fleet running agent 1.18.0
- [ ] Fingerprint adoption rate: 10%
- [ ] No errors in logs
- [ ] Write volume reduced proportionally
### Phase 3: Full Rollout (Month 1)
- [ ] 100% of fleet running agent 1.18.0
- [ ] Fingerprint adoption rate: 100%
- [ ] Database writes: 1.92M/day → 19K/day (99% reduction)
- [ ] No performance degradation
---
## Summary
**Backend**: ✓ Ready (restarted at 12:46 PM)
**Agent**: ✓ Ready (version 1.18.0 running)
**Next Milestone**: Agent report at ~12:59 PM
**Expected**: Delta mode activates, 99% write reduction begins
**Status**: Waiting for next 15-minute report cycle to validate end-to-end functionality.