CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""Tests for perfxpert.providers._sanitization."""
|
|
|
|
import pytest
|
|
|
|
from perfxpert.providers._sanitization import (
|
|
redact_paths,
|
|
sanitize_messages,
|
|
)
|
|
|
|
|
|
def test_redact_paths_absolute():
|
|
"""Test redaction of absolute file paths."""
|
|
text = "/home/user/repo/src/matmul.hip failed"
|
|
out = redact_paths(text)
|
|
assert "/home/user/repo/src/matmul.hip" not in out
|
|
assert "[REDACTED]" in out
|
|
|
|
|
|
def test_redact_paths_relative():
|
|
"""Test redaction of relative paths with traversal."""
|
|
text = "File ../../secret/file.hip was accessed"
|
|
out = redact_paths(text)
|
|
assert "../../secret/file.hip" not in out
|
|
assert "[REDACTED_PATH]" in out
|
|
|
|
|
|
def test_redact_paths_windows():
|
|
"""Test redaction of Windows paths."""
|
|
text = r"C:\Users\dev\project\kernel.cu compiled"
|
|
out = redact_paths(text)
|
|
assert r"C:\Users\dev\project\kernel.cu" not in out
|
|
assert "[REDACTED]" in out
|
|
|
|
|
|
def test_redact_paths_multiple():
|
|
"""Test redaction of multiple paths in one string."""
|
|
text = "/opt/rocm/lib and /tmp/output.db"
|
|
out = redact_paths(text)
|
|
assert "/opt/rocm/lib" not in out
|
|
assert "/tmp/output.db" not in out
|
|
assert out.count("[REDACTED]") >= 2
|
|
|
|
|
|
def test_sanitize_messages_recurses_nested_content():
|
|
messages = [
|
|
{
|
|
"role": "user",
|
|
"content": {
|
|
"db": "/tmp/private/trace.db",
|
|
"notes": ["../../secret/file.hip"],
|
|
},
|
|
}
|
|
]
|
|
out = sanitize_messages(messages)
|
|
assert "/tmp/private/trace.db" not in str(out)
|
|
assert "../../secret/file.hip" not in str(out)
|
|
assert "[REDACTED]" in str(out)
|
|
assert "[REDACTED_PATH]" in str(out)
|