BUG: SeedDatasetFilter matches harm_categories, modalities and size case-sensitively, unlike tags
维护者通常 2 天内回复
评估
调研方向
从 pyrit/datasets/seed_datasets/seed_metadata.py 开始,其中 SeedDatasetFilter 会规范化标签,而 SeedDatasetMetadata._coerce_metadata_values 会规范化元数据值。检查现有的筛选器测试,并添加覆盖 harm_categories、modalities 和 size 中大写值的测试,同时覆盖标签。完成标准是:在这些维度上,大写和小写的筛选值返回相同的数据集。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
SeedDatasetFilter (pyrit/datasets/seed_datasets/seed_metadata.py) normalizes only tags (strip + lowercase), but dataset metadata is normalized on every axis: SeedDatasetMetadata._coerce_metadata_values lowercases and strips every string value of tags, size, modalities, source_type and harm_categories. So a filter value with an uppercase letter matches on tags but silently matches no dataset on any other axis. For example, SeedDatasetFilter(harm_categories={"Violence"}) returns no datasets, while harm_categories={"violence"} returns 5.
Steps/Code to Reproduce
import asyncio
from pyrit.datasets.seed_datasets.seed_dataset_provider import SeedDatasetProvider
from pyrit.datasets.seed_datasets.seed_metadata import SeedDatasetFilter
async def main():
for kwargs in (
{"tags": {"safety"}}, {"tags": {"Safety"}},
{"harm_categories": {"violence"}}, {"harm_categories": {"Violence"}},
{"modalities": {"text"}}, {"modalities": {"Text"}},
{"size": {"large"}}, {"size": {"Large"}},
):
names = await SeedDatasetProvider.get_all_dataset_names_async(filters=SeedDatasetFilter(**kwargs))
print(kwargs, len(names))
asyncio.run(main())
Expected Results
The case of a filter value does not matter on any axis, as it already does not for tags:
{'tags': {'safety'}} 68
{'tags': {'Safety'}} 68
{'harm_categories': {'violence'}} 5
{'harm_categories': {'Violence'}} 5
{'modalities': {'text'}} 76
{'modalities': {'Text'}} 76
{'size': {'large'}} 28
{'size': {'Large'}} 28
Actual Results
{'tags': {'safety'}} 68
{'tags': {'Safety'}} 68
{'harm_categories': {'violence'}} 5
{'harm_categories': {'Violence'}} 0
{'modalities': {'text'}} 76
{'modalities': {'Text'}} 0
{'size': {'large'}} 28
{'size': {'Large'}} 0
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (6224d531) in editable mode
- 主要语言
- Python
- 星标
- 4.7k
- 派生
- 980
- 平均合并
- 2 天 7 小时
- 30 天内合并 PR
- 446
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG: Garak and ML-VLSU loaders still load one example when max_examples is 0 or negative可能已有人在做 @ShivamSharma43 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
BUG: ComicJailbreak max_examples counts goals that render nothing, so templates=["code"] with max_examples=10 fails可能已有人在做 @ShivamSharma43 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
Conversation drawer shows the previous attack's conversations after switching attacks可能已有人在做 @ManoharPaturi 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/PyRIT#3575 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
Conversation draft turns permanently dirty when applied conversions match no piece可能已有人在做 @ManoharPaturi 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
microsoft/PyRIT#3573 · 已指派 1 人 ·
维护者通常 2 天内回复
-
New finding dialog loses a severity only edit without an unsaved changes warning可能已有人在做 @ManoharPaturi 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/PyRIT#3569 · 已指派 1 人 ·
维护者通常 2 天内回复
相似的 Issue
-
app: scripts status: backlog type: documentation
难度 2/5 1-3 小时 新手友好度 86/100
netbox-community/netbox-scripts#68 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
marin-community/marin#10765 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
flathub/com.unity.UnityHub#230 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
namespace operations
难度 1/5 1 小时以内 新手友好度 63/100
EclipseFdn/open-vsx.org#14910 ·
维护者通常 1 天内回复