Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Reviewer's GuideImplementationRemove the demo identity helper from the default provisioning seeder while keeping connector, alert, and case seeding, preventing provisioning from creating the known-password administrator.
TestsAdd regression coverage that traps calls to the demo identity helper and verifies both starter-data seeders still run.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
knowlet
added a commit
that referenced
this pull request
Nov 19, 2026
…emo admin (beenuar#1966) ## Summary Default managed-tenant provisioning no longer creates or relocates the published demo administrator. On beenuar/AiSOC main at `5f64fb73` (v23.5.1), `_default_demo_seeder` still imports and calls `seed_demo._ensure_user`, which upserts the deterministic user `demo@example.com` with password `aisoc-demo`, role `admin`, and `is_active=True` (and moves an existing row into the newly provisioned tenant). Because `provision_from_waitlist` defaults to `seed_demo=True` and the HTTP provision endpoint (`POST /v1/admin/tenants/provision`) exposes no seeder field, a normal promote takes that path and publishes a known-password admin into managed tenants. This branch removes that path. ## Type of change - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Refactor / tech debt - [ ] CI / infra change ## Related issues Addresses the same provisioning path reported in knowlet/AiSOC #11 and #12. ## Changes - `services/api/app/services/tenant_provision/provisioner.py` — `_default_demo_seeder` now seeds connectors, alerts, and cases only; it no longer imports or calls `_ensure_user`, so default provisioning never publishes the demo admin. - `services/api/app/scripts/seed_demo.py` — `_ensure_user` refuses any tenant other than the canonical demo tenant before it reads or writes the deterministic user, so the known-password identity can only ever land in the canonical demo tenant. - `services/api/app/.../migrations/163_retire_managed_demo_admin.sql` — retires already-seeded non-demo administrators and leaves the canonical demo tenant alone. Numbered 163 because `161_disposition_source.sql` is already on current beenuar main. - New tenants still receive the inactive, invite-pending administrator tied to the waitlist email (`hashed_password="!invite-pending"`, `role="tenant_admin"`, `is_active=False`) — unchanged. - Tests: `services/api/tests/test_tenant_provision.py`, `services/api/tests/test_demo_seed.py`, and `tests/isolation/test_auth_escalation_live.py`. ## Testing - [x] Unit tests added / updated - [ ] Integration tests pass locally - [x] Manually tested (describe steps below) <details> <summary>Manual test steps</summary> 1. `python -m pytest services/api/tests/test_tenant_provision.py services/api/tests/test_demo_seed.py` — 4 passed (`test_default_demo_seeder_never_creates_demo_identity`, `test_demo_credentials_refuse_a_non_demo_tenant`, `test_demo_seeder_called_when_enabled`, `test_demo_seeder_failure_does_not_break_provisioning`). 2. `ruff check` — All checks passed; `ruff format --check` — already formatted. </details> ## Screenshots (if UI changes) N/A — no UI changes. ## Checklist - [x] My code follows the style guidelines of this project (`ruff`, `eslint`, `gofmt`) - [x] I have performed a self-review of my own code - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally - [ ] I have updated documentation as needed (README, CHANGELOG, CONTRIBUTING) - [x] My changes do not introduce new linter warnings - [x] I have checked for sensitive data / credentials in my diff ## Eval harness (required for substrate / playbook / detection changes) - [x] Not applicable — this PR does not touch substrate, playbooks, detections, or eval inputs - [ ] No axis regressed - [ ] An axis regressed; rationale and follow-up are described in the Summary above --------- Signed-off-by: knowlet <knowlet@pm.me>
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.
Provisioning now seeds starter SOC data without creating or reassigning the deterministic demo administrator.
_default_demo_seederno longer imports or calls_ensure_user, removing the provisioning path to the published demo credentials.seed_demo=trueno longer creates an active wildcard-role account for the new tenant.Static Verification Checks
Default identity sink removed (Passed) — services/api/app/services/tenant_provision/provisioner.py _default_demo_seeder imports only data seeders, establishing the known-password identity sink is unreachable from default provisioning.
HTTP callers cannot bypass (Passed) — provision_from_waitlist and provision_tenant expose no caller-controlled seeder, establishing HTTP inputs cannot restore the removed identity path.
Invite onboarding remains intact (Passed) — provisioner.py still creates an inactive invite-pending tenant administrator, establishing normal onboarding retains its intended identity flow.
Starter content remains seeded (Passed) — test_default_demo_seeder_never_creates_demo_identity asserts both data helpers run and the identity trap remains untouched, establishing starter content is preserved.
Final diff boundary review (Passed) — Static inspection of git diff found identity removal and preserved data calls, establishing closure without runtime execution.
Finding:
acf_131850631d40f60981dc8e262995f8c8Patch:
arp_34fea74ea824ae1ac3079bffd493078eBase commit:
2a0d550165b9f82108a3fe1c487c44aa96ed1b24Patch SHA-256:
65f55fe7a50c3e08c9e58b8e5700a1d47a7d72e7e2b4c1d254a5ef0a3108f73cSummary by Sourcery
Remove the known-password demo identity from default tenant provisioning while retaining starter SOC data and invite-based administrator onboarding.
Bug Fixes:
Enhancements:
Tests:
Summary by cubic
Prevents production provisioning from creating the deterministic demo administrator with published credentials.
_default_demo_seederno longer calls_ensure_user; it seeds connectors, alerts, and cases only.Written for commit e8e06aa. Summary will update on new commits.