BUG: case insensitive keyword selection returns a shifted range when lowercasing expands a character
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
找到 issue 中提到的 KeywordSelectionStrategy.select_range,并检查它如何将不区分大小写的匹配映射回原始文本。使用 keyword="secret" 和 text="İsecret" 复现;即使小写转换导致字符扩展,只要返回的范围能从原始文本中截取出完整关键词,就算完成。payload 没有指定测试文件,因此请为此复现用例查找或添加测试覆盖。
由索引模型根据 Issue 内容生成。
描述
Description
KeywordSelectionStrategy.select_range locates the keyword with text.lower().find(keyword.lower()) in case insensitive mode and then applies that index to the original, unlowered text. str.lower() is not length preserving for every character: a dotted capital I (İ, U+0130) lowercases to two code points, so every such character before the match shifts the returned range.
With keyword="secret" and case_sensitive=False on the text İsecret, the strategy returns the range (2, 7), which slices to ecret: the leading s of the keyword is left out. A SelectiveTextConverter built on this strategy then converts the wrong characters and the actual secret stays in the clear.
Expected Behavior
The selected range must slice to the keyword (plus any requested context) on the original text, whatever lowercase expansion occurs earlier in the string.
Reproduction Steps
- Build
KeywordSelectionStrategy(keyword="secret", case_sensitive=False). - Call
select_range(text="İsecret"). - The returned range slices to
ecreton main.
Minimal Reproduction
strategy = KeywordSelectionStrategy(keyword="secret", case_sensitive=False)
start, end = strategy.select_range(text="İsecret")
"İsecret"[start:end] # "ecret" on main
Environment
PyRIT main. Python 3.11.
- 主要语言
- Python
- 星标
- 4.7k
- 派生
- 980
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 422
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
Conversation drawer shows the previous attack's conversations after switching attacks可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
相似的 Issue
-
bug P1
难度 2/5 1-3 小时 新手友好度 76/100
Toloka/tolokaforge#1947 ·
维护者通常 1 天内回复
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpoints可能已有人在做 @balajiaru 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
letsencrypt/cp-cps#361 ·
-
难度 2/5 1-3 小时 新手友好度 65/100