feat: Sophos Central integration (Phase 1 — plumbing) - #232
Draft
ubercylon8 wants to merge 1 commit into
Draft
Conversation
Phase 1 of the Sophos AV/EDR integration mirroring the Defender integration.
Ships credentials plumbing + a live OAuth2 + whoami connection test. No
background sync yet — phases 2-4 will add ingestion, correlation, and
auto-resolve.
Plan: docs/sophos-integration-plan.md
Public surface:
- GET /api/integrations/sophos — masked settings + discovered metadata
- POST /api/integrations/sophos — save credentials (partial update)
- DELETE /api/integrations/sophos — disconnect (refuses when env-managed)
- POST /api/integrations/sophos/test — real token + whoami round-trip,
returns discovered tenant/region/tier
Sophos differs from Defender in that only client_id/client_secret are
operator-supplied; tenant_id, data_region, and tier are discovered via
Sophos's whoami endpoint and cached in settings. Env-var override
(SOPHOS_CLIENT_ID / SOPHOS_CLIENT_SECRET) covers credentials only —
discovered fields always come from a real whoami call.
44 new tests (33 backend, 11 backend-serverless). Full suites green
(backend 1254/1254; backend-serverless 1 pre-existing flake in
schedules.service unrelated to this change).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Semgrep SAST ResultsNo security findings. All checks passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 of the Sophos AV/EDR integration mirroring the existing Microsoft Defender integration. Ships credentials plumbing and a live OAuth2 + whoami connection test. Lays the foundation for phases 2–4 (sync, correlation, auto-resolve + dashboard).
Master plan:
docs/sophos-integration-plan.mdWhat this PR adds
Backend public surface (
/api/integrations/sophos):GET— masked settings + discovered tenant/region/tierPOST— save credentials (partial update supported)DELETE— disconnect (refuses when env-managed, mirroring Defender)POST /test— real OAuth2 token + whoami round-trip, returns the discovered tenant ID, data-region URL, and tierInternals:
SophosCentralClientwith token caching, whoami bootstrap, 429/401 retry semantics matchingMicrosoftGraphClientIntegrationsSettingsServicegains 7 new Sophos methods + AES-256-GCM encryption forclient_id/client_secretSOPHOS_CLIENT_ID,SOPHOS_CLIENT_SECRET,SOPHOS_TENANT_LABEL) — credentials only; discovered fields always come from a real whoami callbackend-serverless/(async storage via Vercel Blob, encryption via HKDF)Key design decisions
whoami, not operator-supplied. Including atenant_idinput would mislead users into typing one in only for it to be ignored.backend/src/services/sophos/mirrorsbackend/src/services/defender/rather than introducing a sharedVendorClientabstraction. Defender code is untouched.f0rtika.sophos_detected/f0rtika.sophos_stage_detectedalongside the existingf0rtika.defender_detected, avoiding a hot re-enrichment of historical test docs.last_alert_sync,auto_resolve_modeetc. live inSophosIntegrationSettingsfrom day one so future phases don't require anintegrations.jsonmigration.Tests
backend(Docker)backend-serverless(Vercel)schedules.service.test.ts(commitf5749e5, unrelated)frontendbuildThe new tests cover: token cache hit/miss, whoami parsing, dataRegion trailing-slash normalization, 429 honoring
Retry-After, 401 token-refresh once, partner/organization idType rejection, encryption round-trip, env-var override precedence, env-deletion refusal, route happy paths, route auth-failure paths.What this PR does NOT do
achilles-sophosES index, alert/endpoint sync, and Vercel Cron wiringf0rtika.sophos_detectedflags on test docsallowedActions-aware alert resolutionSophosConfigsettings card andSophosTabanalytics widgetTest plan
cd backend && npm test— full suite green (1254 tests)cd backend-serverless && npm test— full suite green except known pre-existing schedule flakecd backend && npm run build— cleancd backend-serverless && npm run build— cleancd frontend && npm run build— clean./scripts/start.sh -k --daemonandcurl -X POST localhost:3000/api/integrations/sophos/test -H 'Content-Type: application/json' -d '{}'returns deterministic "Missing credentials" JSON/testagainst a real tenant returnssuccess: truewith the rightdata_regionandtier🤖 Generated with Claude Code