BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slash
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc AzureBlobStorageTarget._send_prompt_to_target_async và _parse_url, được issue xác định là các điểm tạo URL và phân tích quá trình tải lên. Tái hiện sự cố với các trường hợp được cung cấp cho URL container kết thúc bằng / và URL có tiền tố thư mục. Hoàn thành khi cả tên blob đã tải lên và các URL trả về đều khớp với kết quả mong đợi, không có dấu gạch chéo kép.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 4.6k
- Fork
- 962
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 423
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/PyRIT
-
BUG: OpenAIImageTarget uploads edited images under a generated local path instead of their file nameCó thể đã có người làm @ShivamSharma43 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: PathTraversalOutputScorer misses canonical Windows target windows/win.ini and IIS web.configCó thể đã có người làm @Kaap10 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: XXEOutputScorer misses direct external DTD references and Java netdoc: / gopher: URI schemesCó thể đã có người làm @Kaap10 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: StaticPromptInjectionScorer misses modern LLM chat template tokens (Meta Llama 3+, Google Gemma, Microsoft Phi-3/4)Có thể đã có người làm @Kaap10 đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: Overlapping scorer-evaluation globs duplicate CSVs and change accuracyCó thể đã có người làm @its-amann đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/PyRIT#3430 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/PyRIT
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
WLAN-Pi/wlanpi-profiler#341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised throughCó thể đã có người làm @Fire162 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
graphql-python/graphql-core#287 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
roman-corgi/ctc-dip#160 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows hostCó thể đã có người làm @Aaqibhafeezkhan đã nhận hôm nay. Đang mởbug good first issue mentored python size: XS up-for-grabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dheerajjha/mcp-migrate#366 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày