Skip to content

FEAT Add GUI initializers - #2271

Open
hannahwestra25 wants to merge 14 commits into
microsoft:mainfrom
hannahwestra25:hannahwestra25-gui-initializers
Open

FEAT Add GUI initializers#2271
hannahwestra25 wants to merge 14 commits into
microsoft:mainfrom
hannahwestra25:hannahwestra25-gui-initializers

Conversation

@hannahwestra25

@hannahwestra25 hannahwestra25 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

Add GUI Initializer Management

Implements Part 1 of the initializer/target persistence design: design gist.

Summary

The GUI could not manage built-in initializers — .pyrit_conf was the only way to configure them, requiring a config edit and restart. This PR adds GUI-driven initializer management backed by a new InitializerSettings database table: .pyrit_conf stays the deployment-owned, read-only baseline, and GUI-added initializer invocations (parameters, order_index) are saved as database rows. At startup, the backend merges the baseline with the saved additional invocations into one effective, ordered list — the scanner, which drives the same backend process, sees the same merged list. Save and Apply now stay separate: Save only persists the invocation; Apply now re-runs that initializer live without restarting CentralMemory.

What's included

  • Backend: InitializerSetting model + migration, memory interface support, and service/routes for listing (baseline + additional invocations + source), validating, creating, updating, applying, and removing an additional initializer invocation. All registered initializers are exposed to the GUI-facing list. Settings reference the registered initializer by name (initializer_name) rather than embedding its full catalog metadata — the frontend joins the name against the registered-initializer catalog. order_index is auto-assigned on create (appended after existing rows) and preserved on update, so additional initializers run in a deterministic order.

  • Frontend: An Initializers page (opened from Target Configuration) with three parts:

    • a Browse available initializers dialog listing every registered initializer as a read-only reference of what exists and the parameters it accepts;
    • a single read-only Baseline initializers box reflecting the .pyrit_conf baseline that ran at startup;
    • an Additional initializers section where you pick any registered initializer from a dropdown and Add it. Adding opens a parameter-config dialog before creating the invocation; each added row is read-only and offers Edit (reopens the config dialog), Apply now, and Remove.

Future work

  1. Save GUI-created targets (RegisteredTargets table pointing to TargetIdentifiers) so targets survive a restart, plus restore logic at startup (children rebuilt in order, name-conflict checks, unavailable-target reporting).

  2. Custom initializer management in the GUI — backend already supports guarded upload/removal; GUI surfacing is a separate security-focused follow-up.

initializer_gui.mp4

Uploading image.png…

Tests and Documentation

  • unit tests for the model, memory layer, service (including name-reference resolution and deterministic order_index assignment), the startup baseline+additional merge, and React components
  • manually loaded GUI

hannahwestra25 and others added 8 commits July 24, 2026 16:58
Adds a DB-backed initializer settings feature: persistence, merge/apply-now
API, and a frontend Initializers config tab.

- pyrit/models/initializer_setting.py: new InitializerSetting model
- pyrit/memory: schema, memory_interface support, and alembic migration
  for initializer settings
- pyrit/backend: routes/service/models for listing, saving, applying, and
  resetting initializer settings, merged with baseline config-file
  initializers
- pyrit/setup/configuration_loader.py: public initializer_configs
  accessor used by the backend instead of a private attribute
- frontend/src/components/Config: new ConfigPage, InitializerConfig, and
  InitializerTable components for viewing and editing initializers in
  the GUI, including Save/Apply now/Reset actions per initializer and a
  no-op guard that disables Save until parameters change

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42217662-8f83-4440-9b89-2d3645e6af08
…th card layout in a settings dialog

- Backend: filter scorer/technique/load_default_datasets/preload_scenario_metadata out of GET /initializers/settings since they have no visible effect in the browser-only GUI (scanner-only registries).
- Frontend: replace the multi-column InitializerTable with a card-per-initializer InitializerList, since only 'target' is ever shown now.
- Frontend: revert Targets/Initializers tabs on the Config page back to a single Target Configuration view; initializer settings are now reached via an 'Initializer Settings' button that opens a dialog.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42217662-8f83-4440-9b89-2d3645e6af08
…tartup

Address PR review notes:
- Remove the half-wired 'enabled' flag across domain model, DB column,
  migration, REST models, service, route, config-loader merge, TS types,
  InitializerList, and tests (no GUI toggle ever set it false).
- Drop empty InitializerSettingResponse; save route returns InitializerSetting.
- Restore initializer_service module docstring (list/register/unregister).
- Simplify _GUI_HIDDEN_INITIALIZER_NAMES comment.
- Merge saved InitializerSetting overrides with the .pyrit_conf baseline at
  the backend-facing entry point: build Central Memory up front via
  _create_memory_instance and pass it into initialize_pyrit_async, keeping
  DB-awareness scoped to ConfigurationLoader.
- Document initializer configuration precedence in doc/gui/0_gui.md.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
apply_initializer_async ran the initializer's build/validate/initialize_async
inline on the event loop. Because an initializer's initialize_async can perform
blocking I/O (e.g. target construction acquiring Entra tokens), this froze the
single-threaded backend for the duration of the apply, causing concurrent
requests (health polls, other pages) to fail with 'backend can't be reached'.

Run the blocking work via asyncio.to_thread so the event loop stays responsive.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
The GUI's effective initializer list shows only the target initializer under the default config, so the user-facing 'Initializer Settings' button and dialog now read 'Auto-Register Targets' with target-centric copy. Component and backend names stay generic since custom .pyrit_conf entries can still surface multiple rows.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
Comment thread doc/gui/0_gui.md Outdated
Comment thread doc/gui/0_gui.md Outdated
Comment thread pyrit/backend/models/initializers.py Outdated
Comment thread pyrit/backend/services/initializer_service.py Outdated
Comment thread pyrit/setup/configuration_loader.py Outdated
Comment thread pyrit/backend/services/initializer_service.py Outdated
Comment thread pyrit/backend/routes/initializers.py Outdated
Comment thread frontend/src/components/Config/TargetConfig.tsx Outdated
Comment thread pyrit/backend/models/initializers.py Outdated
Comment thread pyrit/setup/configuration_loader.py Outdated
hannahwestra25 and others added 6 commits July 28, 2026 12:31
Change the persisted-initializer design from name-keyed overrides (merged
into the .pyrit_conf baseline at startup) to an ordered list of additional
initializers, each with a surrogate id, that run after the baseline. This
allows multiple invocations of the same initializer type and aligns with the
framework's existing multi-instance initializer semantics.

- New AdditionalInitializer domain model + AdditionalInitializers table
- ConfigurationLoader and module-level initialize_pyrit_async are DB-unaware
  again; the backend composition root owns running additional initializers
- Backend models use composition instead of subclassing; routes/services no
  longer import the configuration loader (baseline passed via app.state)
- GUI: Initializers moved to its own page with a left-nav entry; read-only
  baseline section plus an editable additional-initializers list
- Update docs and tests

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
Move the registered-initializer catalog into a header dialog, merge the
baseline cards into a single read-only box, and let users add any
registered initializer via a dropdown. Adding now opens a parameter
config dialog before creating; additional-initializer rows are read-only
with an Edit dialog for changing parameters. Broaden the backend service
to expose all registered initializers in the GUI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
Refactor BaselineInitializerSetting/AdditionalInitializerSetting to reference the registered initializer by name instead of embedding it, resolving catalog metadata on the frontend. Auto-assign order_index on create and preserve it on update for deterministic run order. Stabilize Fluent dialog tests by tolerating the transient aria-hidden modalizer state.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76ab1772-aef5-48ad-a83f-a3fb28270993
…itializers

# Conflicts:
#	frontend/src/components/Sidebar/Navigation.tsx
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a98b9a92-b8c2-4aca-86b3-4759f9991373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants