Metadata-Version: 2.4
Name: ha-diagnostics-check
Version: 0.1.0
Summary: Scan Home Assistant integration diagnostics exports for unredacted secrets and personal data.
Author: Niko Filipic
License-Expression: MIT
Project-URL: Repository, https://github.com/buxerr/ha-diagnostics-check
Project-URL: Issues, https://github.com/buxerr/ha-diagnostics-check/issues
Keywords: home-assistant,diagnostics,redaction,privacy,integration,testing,secrets
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Home Assistant Diagnostics Privacy Checker

Scan a Home Assistant integration diagnostics JSON export for likely unredacted API keys, passwords, tokens, emails, addresses, and other personal data. The checker prints JSON paths and rule names only; it never prints the value it found.

Home Assistant recommends diagnostics so users can attach useful data to public issue reports, and its quality guidance requires sensitive values to be redacted. This package gives integration authors a quick local and CI check for exported diagnostics files.

## Install

```sh
python -m pip install ha-diagnostics-check
```

## Check a diagnostics export

Export diagnostics for a config entry or device from Home Assistant, save the JSON file locally, then run:

```sh
ha-diagnostics-check diagnostics.json
ha-diagnostics-check diagnostics.json --json
```

The command exits `0` when no likely sensitive data is found, `1` when it finds a problem, and `2` when it cannot read the file. Use the JSON output to integrate it with CI.

## What it checks

- Sensitive key names such as `api_key`, `password`, `authorization`, `email`, `address`, and coordinates.
- High-confidence value patterns such as bearer credentials, GitHub tokens, private-key headers, and email addresses.
- Nested dictionaries and arrays, including Home Assistant `**REDACTED**` values.

## Test in a Home Assistant integration

Use Home Assistant's own `get_diagnostics_for_config_entry` or `get_diagnostics_for_device` test helper to create the same JSON users download, then run this checker against that file. The helper verifies the integration path; this checker adds a value-pattern scan. It is a heuristic, so review findings and add domain-specific rules for your integration. It does not replace Home Assistant's diagnostics tests or guarantee that all personal data is detected.

## Development

```sh
python -m unittest discover -s tests -v
```

Keywords: Home Assistant integration diagnostics, redact secrets, diagnostics privacy test, API key leak check, Home Assistant CI, Python integration testing.

## License

MIT
