Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/grants_shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/grants_shared/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions backend/grants_shared/src/grants_shared/logs/pii.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def mask_pii(record: logging.LogRecord) -> bool:
"hostname",
"process",
"thread",
"file_size_bytes",
}


Expand Down
25 changes: 25 additions & 0 deletions backend/grants_shared/tests/grants_shared/logs/test_pii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion backend/grants_shared/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading