Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

PromptShieldTarget drops prompt text after each </document> tag

未关闭 适合新手
#2,837 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
azure, python
领域
ai, security

调研方向

首先定位 PromptShieldTarget._input_parser,并将其循环与类 docstring 中的示例进行比较。使用提供的输入复现该问题,然后确保每个 标签之后的文本以及文档之间的文本仍保留在 userPrompt 中,同时文档内容仍会被收集;如果有可用的相关 PromptShieldTarget 测试,请重新运行它们。

由索引模型根据 Issue 内容生成。

描述

what happens

PromptShieldTarget._input_parser drops every piece of text that comes after a closing </document> tag. the loop keeps only the segment before each closing tag as the document and never appends contents[1], so trailing prompt text and text between documents is silently excluded from the userPrompt sent to Azure Prompt Shield.

for prefix question <document> doc1 </document> trailing question <document> doc2 </document> end text, the parsed userPrompt is just prefix question and the jailbreak scan never sees trailing question or end text.

repro

input_str = 'q1 <document> d1 </document> q2 <document> d2 </document> q3'
user_prompt = ""
documents = []
for element in input_str.split("<document>"):
    contents = element.split("</document>")
    if len(contents) == 1:
        user_prompt += contents[0]
    else:
        documents.append(contents[0])
print(repr(user_prompt))  # 'q1 ' — q2 and q3 are gone

expected

text after each closing tag flows into the userPrompt, matching how the example in the class docstring reads.

env: main 5503ecb

主要语言
Python
星标
4.5k
派生
896
平均合并
2 天 19 小时
30 天内合并 PR
206

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/PyRIT 的其他 Issue

查看 microsoft/PyRIT 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。