Skip to content

diagnostic redaction tests#7

Open
bilalabsh wants to merge 2 commits into
Peter7896:mainfrom
bilalabsh:bilalabsh/diagnostic-redaction-tests
Open

diagnostic redaction tests#7
bilalabsh wants to merge 2 commits into
Peter7896:mainfrom
bilalabsh:bilalabsh/diagnostic-redaction-tests

Conversation

@bilalabsh

Copy link
Copy Markdown

Summary

Closes #1

build.py already writes diagnostic JSON and encrypted .logd files, but nothing in the repository verified that metadata remains clean. There was no coverage for redaction, path formatting, or validation that the JSON references a real artifact. This PR adds that coverage, along with the small build.py changes required to support it.

What Changed

build.py

  • Strips host-specific information from diagnostic text before it is written to JSON (home directory, repository root, temporary directories, username, and hostname).

  • Converts artifact paths to repo-relative paths using forward slashes instead of leaking absolute paths.

  • Adds validate_diagnostic_artifact_pair(), which raises DiagnosticArtifactError when:

    • JSON metadata is missing
    • The corresponding .logd file is missing
    • Commit IDs do not match
    • Paths contain backslashes (\)
    • References are not located under diagnostic/

tests/test_diagnostic_redaction.py

  • Adds 14 offline unit tests.

  • Uses temporary directories for artifact pairing checks, avoiding any dependency on encryptly or a full build.

  • Covers:

    • Redaction token handling

    • Forward-slash path normalization

    • Valid artifact pair validation

    • Failure scenarios:

      • Missing files
      • Mismatched commit IDs
      • Backslashes in paths

diagnostic/

  • Ran python3 build.py on this branch.

  • Generated bundle:

    • diagnostic/build-6b3111c3.logd
    • diagnostic/build-6b3111c3.json

How I Tested

python3 -m unittest tests.test_diagnostic_redaction -v
  • 14/14 tests passing
python3 build.py
  • Successfully generated .logd and .json artifacts
  • Encryption completed successfully via encryptly
  • Please remove the diagnostic build log before merging this PR.

@bilalabsh bilalabsh marked this pull request as draft June 19, 2026 17:18
@bilalabsh bilalabsh marked this pull request as ready for review June 19, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[$40 BOUNTY] [Python] Add diagnostic redaction regression tests

1 participant