diff --git a/backend/grants_shared/README.md b/backend/grants_shared/README.md index fe35966..b62a001 100644 --- a/backend/grants_shared/README.md +++ b/backend/grants_shared/README.md @@ -41,7 +41,7 @@ uv version --bump patch ### Release to PyPi After your change has been merged to main, you can -publish a new release in PyPi with our [Github action](https://github.com/HHS/grants-shared/actions/workflows/publish-grants-shared.yml) +publish a new release in PyPi with our [Github action](https://github.com/HHS/grants-shared/actions/workflows/publish-grants-shared-backend.yml) ## Usage diff --git a/backend/grants_shared/pyproject.toml b/backend/grants_shared/pyproject.toml index 6cda64b..d539534 100644 --- a/backend/grants_shared/pyproject.toml +++ b/backend/grants_shared/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "grants-shared" -version = "0.3.1" +version = "0.3.2" description = "Shared code used by the Simpler Grants.gov & Grants Management repos" readme = "README.md" license = "CC0-1.0" diff --git a/backend/grants_shared/src/grants_shared/logs/pii.py b/backend/grants_shared/src/grants_shared/logs/pii.py index f20b78c..97d4bbf 100644 --- a/backend/grants_shared/src/grants_shared/logs/pii.py +++ b/backend/grants_shared/src/grants_shared/logs/pii.py @@ -77,6 +77,7 @@ def mask_pii(record: logging.LogRecord) -> bool: "hostname", "process", "thread", + "file_size_bytes", } diff --git a/backend/grants_shared/tests/grants_shared/logs/test_pii.py b/backend/grants_shared/tests/grants_shared/logs/test_pii.py index 20107b1..a4ec50e 100644 --- a/backend/grants_shared/tests/grants_shared/logs/test_pii.py +++ b/backend/grants_shared/tests/grants_shared/logs/test_pii.py @@ -65,3 +65,28 @@ def test_mask_pii_logging_floats(input_value, expected_output): # Check that the message was properly masked assert record.msg == expected_output + + +def test_mask_pii_skips_allowed_fields(): + record = logging.LogRecord( + name="test", + level=logging.INFO, + pathname="test.py", + lineno=1, + msg="hello", + args=(), + exc_info=None, + ) + + # Extra values just get added as fields to the log record + record.__dict__["some_field"] = "123-45-6789" + record.__dict__["file_size_bytes"] = "123-45-6789" + record.__dict__["another_field"] = "host 123456789" + record.__dict__["hostname"] = "host 123456789" + + pii.mask_pii(record) + + assert record.some_field == "*********" + assert record.file_size_bytes == "123-45-6789" + assert record.another_field == "host *********" + assert record.hostname == "host 123456789" diff --git a/backend/grants_shared/uv.lock b/backend/grants_shared/uv.lock index 866ea89..47dd95f 100644 --- a/backend/grants_shared/uv.lock +++ b/backend/grants_shared/uv.lock @@ -467,7 +467,7 @@ wheels = [ [[package]] name = "grants-shared" -version = "0.3.1" +version = "0.3.2" source = { virtual = "." } dependencies = [ { name = "apiflask" },