Commit ab2adb7
feat: add search filter to payload list API (#3288)
* feat: add name filter query parameter to payload list API (#3055)
Add optional `?name=` query parameter to `GET /api/v2/payloads` that
performs a case-insensitive substring match on payload filenames,
enabling callers to search/filter the payload list without retrieving
and filtering the full set client-side.
* fix: address Copilot review feedback on payload name filter
- Change name_filter annotation to Optional[str]
- Filter only on PurePosixPath.name to avoid matching directory segments
when add_path=True (e.g. 'plugins/stockpile/payloads/file.txt' should
only match on 'file.txt')
- Strengthen filter tests to assert non-matching payloads are excluded
* Fix flake8 E127: correct continuation line indentation in test_payloads_api.py
* Address Copilot review: use PurePath for cross-platform compatibility
Replace PurePosixPath with PurePath in both the payload handler and
tests so basename extraction works correctly on Windows where paths
may use backslash separators. Move pathlib import to module scope.
* Address Copilot review: schema fix, stronger tests, combination test
- Add allow_none=True to PayloadQuerySchema name field
- Parametrize filter tests (matches + case-insensitive)
- Strengthen assertions to verify no false positives
- Add combination test with sort=true and add_path=true
* Fix flake8 E127: continuation line indentation
---------
Co-authored-by: deacon-mp <mperry@mitre.org>1 parent e568f4a commit ab2adb7
File tree
3 files changed
+40
-1
lines changed- app/api/v2
- handlers
- schemas
- tests/api/v2/handlers
3 files changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
52 | 82 | | |
53 | 83 | | |
54 | 84 | | |
0 commit comments