Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
291c462
Leave out target types that require a path callers may not set
varunj-msft Oct 26, 2026
797831b
Test a target whose required path is the server upload folder
varunj-msft Oct 26, 2026
214a0fa
Merge origin/main
varunj-msft Nov 2, 2026
521ec7e
TEST: Cover saved converter copies in the server path check
varunj-msft Nov 2, 2026
66fd155
FEAT: Report the documents a storage listing cannot use
varunj-msft Nov 2, 2026
2d8c465
Report non-files and missing containers instead of skipping them
varunj-msft Nov 2, 2026
5dec828
Report an entry that can't be checked instead of failing the whole li…
varunj-msft Nov 2, 2026
bf662b7
FEAT: Read saved registry recipes
varunj-msft Nov 2, 2026
e8b0604
Merge the server path check for API input
varunj-msft Nov 2, 2026
9143ea6
FEAT: Rebuild saved registry entries in dependency order
varunj-msft Nov 2, 2026
c29d812
FEAT: Restore saved registry entries and stay not ready if any fail
varunj-msft Nov 2, 2026
cfa4fc0
Limit technique descriptions like the create request and export the r…
varunj-msft Nov 2, 2026
33735f1
Merge the recipe model limits and exports
varunj-msft Nov 2, 2026
11d0519
Keep restore failure messages safe and complete, and check technique …
varunj-msft Nov 2, 2026
8ab7116
Merge the restore message and credential fixes
varunj-msft Nov 2, 2026
b7bf012
Document the recipes setting in the example config and pin the restor…
varunj-msft Nov 2, 2026
e45865b
Test that a description at the limit is accepted
varunj-msft Nov 3, 2026
b6927a9
Merge the description limit test
varunj-msft Nov 3, 2026
c94ffbd
Show only the error type when a URL in it may carry credentials
varunj-msft Nov 3, 2026
ac849a9
Merge the safer failure messages
varunj-msft Nov 3, 2026
26377ea
Point the restore message at where failures are listed and guard the …
varunj-msft Nov 3, 2026
8663852
Cut failure messages at any URL query or fragment and hide any with u…
varunj-msft Nov 3, 2026
4159905
Merge the stricter failure messages
varunj-msft Nov 3, 2026
9a419b4
Escape text that isn't UTF-8 in restore reports so they can be sent a…
varunj-msft Nov 3, 2026
8fb8095
Merge the report text escaping
varunj-msft Nov 3, 2026
9a67367
Read error text as plain normalized text and say when part of it is h…
varunj-msft Nov 3, 2026
82c957f
Merge the plain, normalized failure text
varunj-msft Nov 3, 2026
274b4ce
Escape entry names in restore reports too
varunj-msft Nov 3, 2026
95f9492
Merge the entry name escaping
varunj-msft Nov 3, 2026
a60323a
Show error text with its original characters
varunj-msft Nov 3, 2026
e7558a4
Test that a reference name that isn't valid text can still be reported
varunj-msft Nov 3, 2026
0e8490c
Merge the original-character error text and escaped entry names
varunj-msft Nov 3, 2026
686d475
Test that the runtime status can report a reference name that isn't v…
varunj-msft Nov 3, 2026
c391b0d
Escape report text only when it is sent as JSON
varunj-msft Nov 3, 2026
0b44db6
Merge the JSON-only report escaping
varunj-msft Nov 3, 2026
f986da5
Check each character on its own so long error messages stay fast
varunj-msft Nov 3, 2026
807a904
Merge the per-character check and JSON-only report escaping
varunj-msft Nov 3, 2026
c86bfe6
Check the exact message for every form of each mark and bound the wor…
varunj-msft Nov 3, 2026
454d05b
Merge the exact look-alike message checks
varunj-msft Nov 3, 2026
9f91282
Test that the runtime status can list a file name that isn't valid text
varunj-msft Nov 3, 2026
a455494
Pass the look-alike check's arguments by keyword
varunj-msft Nov 3, 2026
ce8b684
Test that a technique waits for a saved converter in either list and …
varunj-msft Nov 3, 2026
d48a12c
Merge the converter-list and attack-type tests
varunj-msft Nov 3, 2026
74412fe
Test that restore runs after the startup scripts, at startup and on a…
varunj-msft Nov 3, 2026
784cd45
Keep the offline browser fixture away from saved registry entries
varunj-msft Nov 3, 2026
507567b
Check the opened file before reading it and skip links deleted since …
varunj-msft Nov 3, 2026
9d37ba3
Merge the opened-file check
varunj-msft Nov 3, 2026
ff2c836
Merge the opened-file check
varunj-msft Nov 3, 2026
3afdcaa
Merge origin/main
varunj-msft Nov 3, 2026
de2f4e3
Let restore set the path parameters a target lets callers set, as the…
varunj-msft Nov 3, 2026
e821e7e
Merge the opened-file check, main and the caller path parameters
varunj-msft Nov 3, 2026
a45ac23
Close a file that isn't regular before reporting it and report entrie…
varunj-msft Nov 3, 2026
60477e8
Merge the file handle fix
varunj-msft Nov 3, 2026
28f2262
Merge the file handle fix
varunj-msft Nov 3, 2026
ad21f0c
Give only targets the path parameters their class lets callers set
varunj-msft Nov 3, 2026
3dc4768
Merge the file handle fix and the target-only caller paths
varunj-msft Nov 3, 2026
db245dc
Test a file replaced just before it's opened and stop a blocked read …
varunj-msft Nov 4, 2026
5d3d2d0
Merge the opened-file tests
varunj-msft Nov 4, 2026
07a617f
Merge the opened-file tests
varunj-msft Nov 4, 2026
2b4f1cc
Merge the opened-file tests
varunj-msft Nov 4, 2026
80754a2
Read saved recipes separately from building them
varunj-msft Nov 4, 2026
7965020
Merge the separate recipe read
varunj-msft Nov 4, 2026
bd84ef0
Build restored entries on the runtime loop and read them in a worker …
varunj-msft Nov 4, 2026
1a192f7
Show every signed-in user why saved registry entries couldn't be rest…
varunj-msft Nov 4, 2026
4fb7f35
Retry restoring saved registry entries without a restart
varunj-msft Nov 4, 2026
27ef572
Drop a late retry answer when the runtime failed again between polls
varunj-msft Nov 4, 2026
fa1ae56
Keep Retry in reach and say when the failure list couldn't be loaded
varunj-msft Nov 5, 2026
1af1d00
Stop a scan whose launch scripts would replace a saved entry
varunj-msft Nov 5, 2026
17d6fe0
Report a saved-entry clash when a launch script wraps the refusal
varunj-msft Nov 5, 2026
b829bb8
Merge origin/main
varunj-msft Nov 5, 2026
a230568
Refuse saved targets that would authenticate with a key
varunj-msft Nov 5, 2026
232857e
Check where saved targets send requests
varunj-msft Nov 5, 2026
034522d
Accept only plain addresses and paths as saved target destinations
varunj-msft Nov 5, 2026
d10f3cf
Save targets created through the API
varunj-msft Nov 5, 2026
0cbed4c
Count targets that a restart doesn't bring back as Temporary
varunj-msft Nov 5, 2026
d1bdd82
List presets, suites, and initializers through the checked listing
varunj-msft Nov 5, 2026
f5ed760
Merge the shared document listing
varunj-msft Nov 5, 2026
4b55b17
Merge the shared document listing
varunj-msft Nov 5, 2026
a1866d5
Merge the shared document listing
varunj-msft Nov 5, 2026
e8dc897
Merge the shared document listing
varunj-msft Nov 5, 2026
09a98af
Merge the shared document listing
varunj-msft Nov 5, 2026
5ce5bb9
Merge the shared document listing
varunj-msft Nov 5, 2026
84ac7c2
Merge the shared document listing
varunj-msft Nov 5, 2026
76dbf9c
Report a preset, suite, or initializer folder that can't be read as u…
varunj-msft Nov 5, 2026
f823e4b
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
99da684
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
2c58145
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
5a0afa6
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
6bb9aec
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
a4790e9
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
35ed34c
Merge the storage error mapping for unreadable folders
varunj-msft Nov 5, 2026
d70837c
Test each saved target URL rule on its own
varunj-msft Nov 5, 2026
4ce3214
Describe what a saved target can use more precisely
varunj-msft Nov 5, 2026
5669748
Merge the saved target rule tests and doc
varunj-msft Nov 5, 2026
1ef0838
Describe saving targets more precisely
varunj-msft Nov 5, 2026
b3b8ac5
Test the remaining saved target URL rules on their own
varunj-msft Nov 6, 2026
8a44952
Say which saved target addresses are checked
varunj-msft Nov 6, 2026
14125fc
Merge the remaining saved target rule tests and doc
varunj-msft Nov 6, 2026
078dc72
Describe what saving a target refuses more precisely
varunj-msft Nov 6, 2026
6800d15
Merge origin/main
varunj-msft Nov 6, 2026
74839cd
Merge origin/main
varunj-msft Nov 6, 2026
ee3e64f
Merge origin/main
varunj-msft Nov 6, 2026
15e7a9e
Take out the restore retry changes merged here by mistake
varunj-msft Nov 6, 2026
368b914
Merge origin/main
varunj-msft Nov 6, 2026
fd7bd4a
Merge origin/main
varunj-msft Nov 6, 2026
844a424
Say a Temporary target is also gone after a reinitialization
varunj-msft Nov 6, 2026
7d9ac2f
Log why storage is unavailable, without its path or URL
varunj-msft Nov 7, 2026
7b5bfeb
Merge the storage error logging
varunj-msft Nov 7, 2026
22806d8
Merge the storage error logging
varunj-msft Nov 7, 2026
34011c9
Hide a restore message with a percent escape, which can hide a creden…
varunj-msft Nov 7, 2026
8a0113f
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
8d51b6c
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
6ddd960
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
91bb36b
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
dc4125c
Stop a launch whose script catches the duplicate-name error for a sav…
varunj-msft Nov 7, 2026
febc8c3
Merge the duplicate-name refusal for saved entries
varunj-msft Nov 7, 2026
303dfa8
Merge the duplicate-name refusal for saved entries
varunj-msft Nov 7, 2026
e03fd18
Merge origin/main
varunj-msft Nov 7, 2026
36462db
Merge origin/main
varunj-msft Nov 7, 2026
031dc61
Merge origin/main
varunj-msft Nov 8, 2026
7f8ab0d
Merge origin/main
varunj-msft Nov 8, 2026
19205b1
Import the saved recipe models from their package, as main now requires
varunj-msft Nov 8, 2026
0348a0b
Merge origin/main
varunj-msft Nov 8, 2026
bba3afd
Import from public packages, as main now requires
varunj-msft Nov 8, 2026
d4ccd50
Merge origin/main
varunj-msft Nov 8, 2026
ed01798
Merge origin/main
varunj-msft Nov 8, 2026
98766ec
Record a saved entry's name clash wherever a launch script can catch it
varunj-msft Nov 8, 2026
6fb1e00
Merge origin/main
varunj-msft Nov 8, 2026
405c2bd
Import from public packages, as main now requires
varunj-msft Nov 8, 2026
d35eea9
Merge origin/main
varunj-msft Nov 8, 2026
13bd3ab
Check a target that takes no credentials as the default auth mode
varunj-msft Nov 8, 2026
2b97d83
Merge origin/main
varunj-msft Nov 8, 2026
622bbb8
Report storage failures with one error and answer them with 503
varunj-msft Nov 9, 2026
1cae0b9
Merge the single storage error
varunj-msft Nov 9, 2026
eba7bf2
Escape file names once and simplify the saved recipe models
varunj-msft Nov 9, 2026
9f24124
Merge the recipe model simplification
varunj-msft Nov 9, 2026
2bbfc8f
Report restore bugs as build errors and log each failure once
varunj-msft Nov 9, 2026
3735dbc
Merge the restore logging and build error fixes
varunj-msft Nov 9, 2026
ca7563d
Stay ready when a saved entry can't be restored, and hold its name
varunj-msft Nov 9, 2026
a9dfc86
Merge the stay-ready restore
varunj-msft Nov 10, 2026
67416f1
Reset the registries between runtime tests, as a real startup does
varunj-msft Nov 10, 2026
e6e419e
Merge the runtime test isolation
varunj-msft Nov 10, 2026
81c0317
Stop a launch whose script takes the name of a saved entry that failed
varunj-msft Nov 10, 2026
6ee84f0
Merge origin/main
varunj-msft Nov 10, 2026
d43a7e8
Merge origin/main
varunj-msft Nov 10, 2026
0664063
Merge origin/main
varunj-msft Nov 10, 2026
3b3ac59
Merge origin/main
varunj-msft Nov 10, 2026
04fe60f
Merge origin/main
varunj-msft Nov 10, 2026
6911327
Merge origin/main
varunj-msft Nov 10, 2026
ee45962
Refuse OpenAI targets while the server sets OPENAI_CUSTOM_HEADERS
varunj-msft Nov 10, 2026
6a98d17
Merge origin/main
varunj-msft Nov 10, 2026
4a3f2e5
Use final origin names, record startup entries at registration, and t…
varunj-msft Nov 10, 2026
51d4fff
Explain that a credential refusal also covers using this server's cre…
varunj-msft Nov 10, 2026
a3d4f92
Merge the credential explanation
varunj-msft Nov 10, 2026
8614025
Use one recipe format version, keep the auth mode, and escape failure…
varunj-msft Nov 10, 2026
5a3f18b
Merge the recipe format changes
varunj-msft Nov 10, 2026
b3c7847
Build restored entries with a builder the caller supplies
varunj-msft Nov 10, 2026
af4075f
Merge the restore builder changes
varunj-msft Nov 10, 2026
061807a
Warn that writing saved entries is administrator authority, and test …
varunj-msft Nov 10, 2026
1740964
Merge the restore builder changes
varunj-msft Nov 10, 2026
01d99d7
Merge the restore builder changes
varunj-msft Nov 10, 2026
600717f
Merge the restore builder changes
varunj-msft Nov 10, 2026
7a547aa
Say restore can't tell who wrote a saved file
varunj-msft Nov 10, 2026
986cc90
Test the parser's depth limit without depending on the stack size
varunj-msft Nov 10, 2026
1096925
Merge the parser depth test fix
varunj-msft Nov 10, 2026
f25b520
Merge the parser depth test fix
varunj-msft Nov 10, 2026
1845b64
Merge the parser depth test fix
varunj-msft Nov 10, 2026
bd2224b
Merge the parser depth test fix
varunj-msft Nov 10, 2026
b454e75
Merge the parser depth test fix
varunj-msft Nov 10, 2026
fb90af8
Read saved entries in a worker thread when restore isn't given what w…
varunj-msft Nov 10, 2026
c44d2ce
Merge the worker-thread read
varunj-msft Nov 10, 2026
abd116a
Stay not ready when a saved entry can't be restored, and let apply retry
varunj-msft Nov 10, 2026
0bfa6cc
Drop the refusal of held names from launches
varunj-msft Nov 10, 2026
c62118f
Merge the not-ready restore
varunj-msft Nov 10, 2026
c0aa46d
Merge the not-ready restore
varunj-msft Nov 10, 2026
f59306e
Read saved recipes off the event loop by default, and harden URL reda…
richlundeen Nov 10, 2026
7d90d68
Merge the not-ready restore
varunj-msft Nov 10, 2026
0f0c53d
Treat a class a launch script puts in place of another as temporary
varunj-msft Nov 10, 2026
f1ff143
Keep an "@" in a URL's path when redacting URLs in text
richlundeen Nov 10, 2026
009e761
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
21f22a4
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
e9103ff
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
57b069a
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
cc4ae4d
Merge main
varunj-msft Nov 10, 2026
9f4c71e
Merge main
varunj-msft Nov 10, 2026
5121026
Merge main
varunj-msft Nov 10, 2026
d15f7fd
Merge main
varunj-msft Nov 11, 2026
187191c
Answer suite readiness storage failures through the shared storage ha…
varunj-msft Nov 11, 2026
bb2a620
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
db7451a
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
b200c92
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
374c620
Merge main
varunj-msft Nov 11, 2026
7ac059c
Answer suite readiness storage failures through the shared storage ha…
varunj-msft Nov 11, 2026
e08b67a
Merge main
varunj-msft Nov 11, 2026
7fa4ca4
Expect storage errors from main's version-checked delete tests the wa…
varunj-msft Nov 11, 2026
9bf5886
Merge main
varunj-msft Nov 11, 2026
626d2d4
Merge main
varunj-msft Nov 11, 2026
4a86017
Merge main
varunj-msft Nov 11, 2026
9568edb
Merge main
varunj-msft Nov 11, 2026
c506195
Merge main
varunj-msft Nov 11, 2026
1ba526f
Merge main
varunj-msft Nov 11, 2026
9cdf7e7
Merge main
varunj-msft Nov 11, 2026
40d36ed
Merge main
varunj-msft Nov 11, 2026
6a52054
Merge main
varunj-msft Nov 11, 2026
23a7ec1
Merge main
varunj-msft Nov 11, 2026
70fbc3d
Merge main
varunj-msft Nov 11, 2026
0e7a21f
Exempt the storage error handler from the keyword-only check
varunj-msft Nov 11, 2026
c35fa01
Merge keyword-only fixes
varunj-msft Nov 11, 2026
953dcce
Merge keyword-only fixes
varunj-msft Nov 11, 2026
d6079a1
Merge keyword-only fixes
varunj-msft Nov 11, 2026
21556ed
Merge keyword-only fixes
varunj-msft Nov 11, 2026
14004e9
Merge keyword-only fixes
varunj-msft Nov 11, 2026
3abc824
Merge keyword-only fixes
varunj-msft Nov 11, 2026
bf97225
Log every problem with a saved file that isn't valid
varunj-msft Nov 11, 2026
5e6faed
Merge the full schema-validation log
varunj-msft Nov 11, 2026
7625f89
Merge the full schema-validation log
varunj-msft Nov 11, 2026
8dbd4c2
Merge the full schema-validation log
varunj-msft Nov 11, 2026
35199cc
Leave the error behind a storage failure out of the logs
varunj-msft Nov 12, 2026
efcdfa9
Test a blob upload that fails with a transport or authentication error
varunj-msft Nov 12, 2026
0fdebdc
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c413994
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c057e30
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
dc97ec7
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
a9478df
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
dc0c058
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c9b795a
Merge main
varunj-msft Nov 12, 2026
38c981c
Merge main
varunj-msft Nov 12, 2026
eb71448
Merge main
varunj-msft Nov 12, 2026
1be067e
Merge main
varunj-msft Nov 12, 2026
162fc2a
Merge main
varunj-msft Nov 12, 2026
6c0c3dd
Merge main
varunj-msft Nov 12, 2026
3d0950d
Merge main
varunj-msft Nov 12, 2026
4e8d9c2
Return 409 when a suite's launch scripts would replace a saved entry
varunj-msft Nov 12, 2026
b1bbbe6
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
9ce29cb
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
15e00de
Merge main
varunj-msft Nov 12, 2026
0c5baa8
Merge main
varunj-msft Nov 12, 2026
d4337d8
Merge main
varunj-msft Nov 12, 2026
48bc6d1
Merge main
varunj-msft Nov 12, 2026
805ca2a
Merge main into part 7
varunj-msft Nov 13, 2026
b9c50e1
Merge part 7 into part 8
varunj-msft Nov 13, 2026
cdbe6ad
Keep the recipe storage setup apart from the saved target requirements
varunj-msft Nov 13, 2026
450b1e5
Merge part 7 into part 8
varunj-msft Nov 13, 2026
699ab5b
Move saving a target into the registry library
varunj-msft Nov 13, 2026
713f7d1
Merge main into part 8
varunj-msft Nov 13, 2026
048283e
Merge main into part 8
varunj-msft Nov 13, 2026
f273bff
Merge main into part 8
varunj-msft Nov 14, 2026
54d9332
Check saved entries against restore's inputs and settle cancelled saves
varunj-msft Nov 14, 2026
87de386
Bound the URL scheme when redacting text
varunj-msft Nov 14, 2026
33650ff
Merge main into part 8
varunj-msft Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/getting_started/pyrit_conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ A SAS query string may be included; otherwise, PyRIT uses `DefaultAzureCredentia

### `registry_recipes_source`

Stores saved targets, converters, scorers, and techniques in a local directory or Azure Blob container, so they come back when the backend restarts. An Azure URI may include a blob-name prefix:
Stores saved targets, converters, scorers, and techniques in a local directory or Azure Blob container, so they come back when the backend restarts. Targets created through `POST /api/targets` with `"persist": true` are saved here. An Azure URI may include a blob-name prefix:

```yaml
registry_recipes_source: https://account.blob.core.windows.net/pyrit-storage/registry-recipes
Expand All @@ -206,7 +206,7 @@ A SAS query string may be included; otherwise, PyRIT uses `DefaultAzureCredentia

Each kind has its own folder under the source (`targets/`, `converters/`, `scorers/`, `techniques/`), with one JSON file per saved entry named after the entry. A file holds the create request the entry was made with, and restore builds the entry through the API's create for its kind.

A saved file doesn't record who saved it, so the backend rebuilds every entry in this source as an administrator, at startup and after a live apply. A file here can, for example, make the backend run a model's repository code, or use the server's identity on a storage container that the file names. Write access to this source is administrator authority on the backend: grant it only to principals you already trust as backend administrators, and use a dedicated directory or blob prefix that less-trusted users and services cannot write to.
Restore can't tell who wrote a saved file, even one that names the user who saved it, so the backend rebuilds every entry in this source as an administrator, at startup and after a live apply. A file here can, for example, make the backend run a model's repository code, or use the server's identity on a storage container that the file names. Write access to this source is administrator authority on the backend: grant it only to principals you already trust as backend administrators, and use a dedicated directory or blob prefix that less-trusted users and services cannot write to.

The backend restores saved entries at startup and after a live apply, once the configured initializers have registered theirs. If any saved entry can't be restored, the backend doesn't become ready (state `failed`, outcome `restore-failed`), so a scan can't quietly run without an entry it expects. Until then, only the configuration and status routes answer; the rest return 503. Administrators see each failure with its reason in `GET /api/config/runtime` and on the GUI's Configuration page; everyone else sees that an administrator has to fix saved entries. Fix or delete the listed files, or, when a folder couldn't be listed, check that the backend can read this source. Then apply the configuration, if `enable_live_reinitialization` is on and the backend runs as one worker and one replica, which live apply requires; otherwise, restart the backend. Files whose names aren't valid entry names (up to 64 lowercase letters, digits, and underscores, starting with a letter) aren't failures and don't block startup; administrators can see them under `restore_ignored` in `GET /api/config/runtime`.

Expand All @@ -215,6 +215,7 @@ The backend restores saved entries at startup and after a live apply, once the c
A saved file never holds a credential: restore refuses a file that stores a value for a parameter its class marks as a credential, such as `api_key`. A saved target also can't use a key from this server: it signs in with Microsoft Entra ID (`"auth_mode": "identity"`), which uses this server's Azure identity for everyone using the app, or needs no key. Targets from the server's configuration that it uses, such as a round-robin's members, keep their own sign-in. Restore refuses a target file that breaks these rules:

- It can't read an empty key from an environment variable or leave an address to this server's settings. An address the server would otherwise fill in must be a full http(s) or ws(s) address.
- It sets each setting its target type would otherwise read from this server's environment, such as an OpenAI target's `model_name`, and only parameters the create API accepts, so no Python objects such as `httpx_client_kwargs`.
- The addresses each target type declares (such as `endpoint`, `container_url` for Blob storage, or an A2A agent card path) can't hold a user name, password, SAS token, fragment, path parameters (`;`, `&`, `=`), or a query other than `api-version`, and a path can't have a query at all.
- In identity mode, an OpenAI target file sets `"headers": "{}"` in its `params` so that the server's `OPENAI_ADDITIONAL_REQUEST_HEADERS` aren't added. The OpenAI SDK adds the headers in `OPENAI_CUSTOM_HEADERS` to every request, so while the server sets it, OpenAI targets can't be saved and saved ones aren't restored. The SDK's `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID` still apply to every OpenAI target on this server.
- GitHub Copilot, Hugging Face, HackAPrompt, LiteLLM, HTTP, and Copilot WebSocket targets can't be saved yet.
Expand Down
28 changes: 27 additions & 1 deletion frontend/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";

import { defineConfig, devices } from "@playwright/test";

import type { UserPreferences } from "./src/types";
Expand All @@ -24,6 +28,28 @@ const VITE_SERVER_OPTIONS =
const E2E_BACKEND_PORT = process.env.PYRIT_E2E_BACKEND_PORT ?? "18000";
const E2E_BACKEND_URL = `http://127.0.0.1:${E2E_BACKEND_PORT}`;

/**
* Copies the seeded backend's configuration into a fresh folder that also holds
* its saved targets, converters, scorers, and techniques, so a run never reads
* or writes the ones saved on the machine running it.
*/
function createSeededBackendConfigFile(): string {
const folder = mkdtempSync(path.join(tmpdir(), "pyrit-seeded-backend-"));
Comment thread
varunj-msft marked this conversation as resolved.
Resolved
// The runner stops the backend before it exits, so nothing still uses the folder by then.
process.once("exit", () => rmSync(folder, { recursive: true, force: true }));
const configFile = path.join(folder, "browser_config.yaml");
const config = readFileSync(new URL("../tests/end_to_end/browser_config.yaml", import.meta.url), "utf-8");
const recipesSource = JSON.stringify(path.join(folder, "registry_recipes"));
writeFileSync(configFile, `${config}\nregistry_recipes_source: ${recipesSource}\n`);
return configFile;
}

// Workers load this file too, but only the main process starts the backend.
const SEEDED_BACKEND_CONFIG_FILE =
SEEDED_MODE && process.env.TEST_WORKER_INDEX === undefined
? createSeededBackendConfigFile()
: "";

export default defineConfig({
testDir: "./e2e",
testIgnore: ["**/analytics.spec.ts", "**/paired-outcomes.spec.ts", "**/scenario-hierarchy.spec.ts", "**/scenario-datasets.spec.ts", "**/scenario-techniques.spec.ts", "**/scan-launch.seeded.spec.ts"],
Expand Down Expand Up @@ -113,7 +139,7 @@ export default defineConfig({
command:
`cd .. && uv run --no-sync python -m pyrit.backend.pyrit_backend ` +
`--auth-mode local --host 127.0.0.1 --port ${E2E_BACKEND_PORT} --log-level warning ` +
"--config-file tests/end_to_end/browser_config.yaml",
`--config-file "${SEEDED_BACKEND_CONFIG_FILE}"`,
env: { PYRIT_DEV_MODE: "true" },
url: `${E2E_BACKEND_URL}/api/health`,
reuseExistingServer: false,
Expand Down
35 changes: 35 additions & 0 deletions pyrit/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ its database collation.
### Targets
- `GET /api/targets` - List available prompt targets
- `GET /api/targets/{id}` - Get target details
- `POST /api/targets` - Create a target
- `POST /api/targets/{id}/detect-capabilities` - Run live capability checks and
apply the result to the registered target. Send `{"expected_hash": "<identifier hash>"}`.
Detection uses a private target, has a four-minute operation deadline, and
Expand Down Expand Up @@ -82,6 +83,40 @@ overrides; reconstruction preserves declarations from the source target.
Per-send values use
[`request_generation_config` metadata](../../doc/code/targets/0_prompt_targets.md#runtime-generation-configuration).

A created target is Temporary: a restart or a configuration apply removes it. With `"persist": true` (and `register`
left on), the target is saved under `registry_recipes_source` and restored at every start, and the signed-in user is
recorded as the one who saved it. A saved target can't hold or use a key: it signs in with Microsoft Entra ID
(`"auth_mode": "identity"`, through this server's Azure identity) or needs no key. An OpenAI target's empty `headers`
is set to `"{}"` first, so a saved one doesn't send this server's `OPENAI_ADDITIONAL_REQUEST_HEADERS`. The save
itself is the registry library's `prepare_saved_params_async` and `save_then_register_async`, so Python code saves a
target the same way; the API adds the signed-in user, the configured source, and the responses below.

| A request with `persist` that... | Gets |
|---|---|
| names the target with anything but up to 64 lowercase letters, digits, and underscores, starting with a letter | **422** |
| would save a key, or use one of this server's keys or address settings | **400** |
| gives an address that can carry a credential, or, where this server's setting would apply, one that isn't a full http(s) or ws(s) address | **400** |
| saves a target type that can't be saved, or one that a scan's launch scripts added or put in place of another | **400** |
| saves an OpenAI target while this server sets `OPENAI_CUSTOM_HEADERS`, whose headers the OpenAI SDK adds to every request | **400** |
| uses a Temporary target | **400** |
| takes a name that a target or a saved file already has | **409** |
| can't be written to storage | **503** |

A request refused with **400** can be sent again without `persist`. When storage can't be written, the server log names
the target and its folder, since the target comes back at the next start if the write reached storage anyway.

Each listed target's `origin` is `saved`, `configuration` (registered by the server's startup scripts), or `temporary`
(gone after a restart or a configuration apply, such as a target created without `persist` or registered by a scan's
launch scripts). A saved target can only use targets that come back after a restart; targets from configuration keep
their own sign-in.

A saved target records the create request without its name: the target type, `auth_mode`, and the parameters as the
API accepted them. Restore sends it through the same create, so it passes the same checks and follows the class's
constructor. A class that moves within PyRIT still restores. Renaming or removing a class or a constructor parameter
changes the saved format: such a change raises `schema_version` and adds a migration for older files, with a test that
restores one. A file that still doesn't match fails to restore with the reason, and the backend stays not ready until
the file is fixed or deleted, so nothing runs without the saved target.

### Dataset creation, batch mutation, and deletion

`POST /api/datasets` creates a named dataset synchronously from multipart form data.
Expand Down
8 changes: 6 additions & 2 deletions pyrit/backend/mappers/target_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Any

from pyrit.models import CapabilityName, TargetIdentifier
from pyrit.models.catalog import TargetInstance
from pyrit.models.catalog import RegistryEntryOrigin, TargetInstance
from pyrit.prompt_target import PromptTarget

# Capability flag names that should never be surfaced as identifier-level params:
Expand Down Expand Up @@ -52,7 +52,9 @@ def _target_specific_params(target_identifier: TargetIdentifier) -> dict[str, An
return {**extra, **explicit_specific} or None


def target_object_to_instance(target_registry_name: str, target_obj: PromptTarget) -> TargetInstance:
def target_object_to_instance(
target_registry_name: str, target_obj: PromptTarget, *, origin: RegistryEntryOrigin | None = None
) -> TargetInstance:
"""
Build a TargetInstance DTO from a registry target object.

Expand All @@ -63,6 +65,7 @@ def target_object_to_instance(target_registry_name: str, target_obj: PromptTarge
Args:
target_registry_name: The human-friendly target registry name.
target_obj: The domain PromptTarget object from the registry.
origin: Where the registered target comes from, or None for an inner target.

Returns:
TargetInstance DTO with metadata derived from the object.
Expand All @@ -83,6 +86,7 @@ def target_object_to_instance(target_registry_name: str, target_obj: PromptTarge
supports_history_replay=supports_history_replay,
target_specific_params=_target_specific_params(target_identifier),
inner_targets=_build_inner_targets(target_obj),
origin=origin,
)


Expand Down
28 changes: 27 additions & 1 deletion pyrit/backend/models/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@

from pyrit.backend.models.common import MAX_ITEMS, REGISTRY_INSTANCE_NAME_PATTERN, IdentifierStr, PaginationInfo
from pyrit.common import AuthMode
from pyrit.models import GenerationRange, JSONValue, Parameter, TargetCapabilities, TargetIdentifier
from pyrit.models import (
GenerationRange,
JSONValue,
Parameter,
TargetCapabilities,
TargetIdentifier,
validate_registry_name,
)
from pyrit.models.catalog import TargetInstance
from pyrit.models.component_spec import SourceInstanceSpec

Expand Down Expand Up @@ -75,6 +82,14 @@ class CreateTargetRequest(BaseModel):
description="Unique registry name; omitted only for legacy UI compatibility",
)
register: bool = Field(True, description="Register the object; false returns only its descriptor")
persist: bool = Field(
False,
description=(
"Save the target so it comes back after the backend restarts or is reinitialized (true), or keep it "
"only until then (false). A saved target needs a name of lowercase letters, digits, and underscores, "
"and can't hold or use a key: it authenticates with Microsoft Entra ID ('identity') or needs no key."
),
)
source: SourceInstanceSpec | None = None
type: IdentifierStr = Field(..., description="Target type (e.g., 'OpenAIChatTarget')")
params: dict[IdentifierStr, JSONValue] = Field(
Expand Down Expand Up @@ -104,6 +119,17 @@ def _validate_source(self) -> "CreateTargetRequest":
raise ValueError("a copy uses its source's auth mode, so auth_mode can't be set")
return self

@model_validator(mode="after")
def _validate_persist(self) -> "CreateTargetRequest":
if not self.persist:
return self
if not self.register:
raise ValueError("persist requires register=true")
if self.name is None:
raise ValueError("persist requires a name")
validate_registry_name(self.name)
return self


class UnregisteredTarget(BaseModel):
"""A constructed target descriptor with no registry key or object handle."""
Expand Down
32 changes: 30 additions & 2 deletions pyrit/backend/routes/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from fastapi import APIRouter, HTTPException, Query, Request, status

from pyrit.backend.middleware.auth import has_admin_access
from pyrit.backend.middleware.auth import AuthenticatedUser, has_admin_access
from pyrit.backend.models import (
CreateTargetRequest,
ProblemDetail,
Expand All @@ -23,8 +23,9 @@
UnregisteredTarget,
)
from pyrit.backend.services import get_target_service
from pyrit.models.catalog import TargetInstance
from pyrit.models.catalog import SavedEntryOwner, TargetInstance
from pyrit.prompt_target.common.discover_target_capabilities import CapabilityDiscoveryError
from pyrit.registry import SavedEntryConflictError, SavedEntryStorageError

router = APIRouter(prefix="/targets", tags=["targets"])

Expand Down Expand Up @@ -81,6 +82,22 @@ def _target_upload_directory(request: Request) -> str | None:
return directory


def _saved_entry_owner(request: Request) -> SavedEntryOwner | None:
"""
Return the signed-in user to record on a saved target.

Args:
request: The incoming FastAPI request.

Returns:
SavedEntryOwner | None: The user's object ID and name, or None when sign-in is off.
"""
user = getattr(request.state, "user", None)
if not isinstance(user, AuthenticatedUser):
return None
return SavedEntryOwner(oid=user.oid, name=user.name or user.email)


@router.get(
"",
response_model=TargetListResponse,
Expand Down Expand Up @@ -136,6 +153,11 @@ async def list_target_types(request: Request) -> TargetTypeResponse: # pyrit-as
"description": "Administrator access is required to run model repository code or to use the "
"server's stored credentials",
},
409: {
"model": ProblemDetail,
"description": "A target to save has the name of a registered or saved target",
},
503: {"model": ProblemDetail, "description": "Saved targets can't be written right now"},
},
)
async def create_target(
Expand All @@ -161,7 +183,13 @@ async def create_target(
request=body,
upload_directory=_target_upload_directory(request),
is_admin=has_admin_access(request),
owner=_saved_entry_owner(request) if body.persist else None,
recipes_source=getattr(request.app.state, "registry_recipes_source", None),
)
except SavedEntryConflictError as e:
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=str(e)) from e
except SavedEntryStorageError as e:
raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail=str(e)) from e
except PermissionError as e:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
Expand Down
Loading
Loading