BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slash
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
AzureBlobStorageTarget._send_prompt_to_target_async と _parse_url を読みます。issue では、これらが URL の構築とアップロードの解析を行う箇所として示されています。末尾が / のコンテナー URL と、フォルダーのプレフィックスがある URL の提供されたケースで再現します。アップロードされた blob の名前と返される URL の両方が期待される結果と一致し、スラッシュが二重にならなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
AzureBlobStorageTarget._send_prompt_to_target_async builds the returned URL by appending to the configured container URL:
blob_url = self._container_url + "/" + file_name
When container_url (or AZURE_STORAGE_ACCOUNT_CONTAINER_URL) ends with /, for example https://acct.blob.core.windows.net/xpia/, the URL gets // before the file name. The upload goes through _parse_url, which ignores the empty segment, so the blob is uploaded as doc.txt. The returned URL .../xpia//doc.txt names a blob /doc.txt, which does not exist, so anything that uses the returned URL (for example the XPIA workflows) points at a missing blob.
With a folder prefix and a trailing slash (.../xpia/folder/), _parse_url returns the prefix folder/, so the blob itself is uploaded as folder//doc.txt instead of folder/doc.txt.
Steps/Code to Reproduce
import asyncio
from unittest.mock import AsyncMock, MagicMock, patch
from pyrit.setup import IN_MEMORY, initialize_pyrit_async
async def main():
await initialize_pyrit_async(memory_db_type=IN_MEMORY)
from pyrit.models import Message, MessagePiece
from pyrit.prompt_target import AzureBlobStorageTarget
for container_url in ["https://acct.blob.core.windows.net/xpia/", "https://acct.blob.core.windows.net/xpia/folder/"]:
target = AzureBlobStorageTarget(container_url=container_url, sas_token="sv=test")
client = AsyncMock()
client.get_blob_client = MagicMock(return_value=AsyncMock(exists=AsyncMock(return_value=False)))
piece = MessagePiece(role="user", original_value="payload", prompt_metadata={"file_name": "doc.txt"})
with patch("azure.storage.blob.aio.ContainerClient.from_container_url", return_value=client):
response = await target.send_prompt_async(message=Message(message_pieces=[piece]))
print("container_url:", container_url)
print(" uploaded blob:", client.get_blob_client.call_args.kwargs["blob"])
print(" returned URL :", response[0].get_value())
asyncio.run(main())
Expected Results
The trailing slash makes no difference:
container_url: https://acct.blob.core.windows.net/xpia/
uploaded blob: doc.txt
returned URL : https://acct.blob.core.windows.net/xpia/doc.txt
container_url: https://acct.blob.core.windows.net/xpia/folder/
uploaded blob: folder/doc.txt
returned URL : https://acct.blob.core.windows.net/xpia/folder/doc.txt
Actual Results
The returned URL does not match the uploaded blob, and the prefixed blob gets an empty path segment:
container_url: https://acct.blob.core.windows.net/xpia/
uploaded blob: doc.txt
returned URL : https://acct.blob.core.windows.net/xpia//doc.txt
container_url: https://acct.blob.core.windows.net/xpia/folder/
uploaded blob: folder//doc.txt
returned URL : https://acct.blob.core.windows.net/xpia/folder//doc.txt
Screenshots
N/A
Versions
- OS: Windows 11
- Python version: 3.11.9
- PyRIT version: installed from main (eeb9ba9d) in editable mode
- 主要言語
- Python
- スター
- 4.6k
- フォーク
- 962
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 417
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/PyRIT のほかの issue
-
BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file name対応中かも @ShivamSharma43 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信
-
BUG: PathTraversalOutputScorer misses canonical Windows target windows/win.ini and IIS web.config対応中かも @Kaap10 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemes対応中かも @Kaap10 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
BUG: StaticPromptInjectionScorer misses modern LLM chat template tokens (Meta Llama 3+, Google Gemma, Microsoft Phi-3/4)対応中かも @Kaap10 が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
-
BUG: Overlapping scorer-evaluation globs duplicate CSVs and change accuracy対応中かも @its-amann が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/PyRIT#3430 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
microsoft/PyRIT の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fossasia/visdom-dev#77 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws-cloudformation/cfn-lint#4890 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
volcengine/OpenViking#6521 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
AstrBotDevs/AstrBot#10720 ·
メンテナーはふだん 1 日以内に返信