Skip to content
Open
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
22 changes: 13 additions & 9 deletions apport/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,15 +1895,8 @@ def crash_signature_addresses(self) -> str | None:

return f"{self['ExecutablePath']}:{self['Signal']}:{':'.join(stack)}"

# TODO: Split into smaller functions/methods
# pylint: disable-next=too-complex
def anonymize(self) -> None:
"""Remove user identifying strings from the report.

This particularly removes the user name, host name, and IPs
from attributes which contain data read from the environment, and
removes the ProcCwd attribute completely.
"""
@staticmethod
def _get_replacements() -> list[tuple[re.Pattern[str], str]]:
replacements = []
# Do not replace "root"
if os.getuid() > 0:
Expand All @@ -1926,6 +1919,17 @@ def anonymize(self) -> None:
if len(hostname) >= 2:
replacements.append((re.compile(rf"\b{re.escape(hostname)}\b"), "hostname"))

return replacements

def anonymize(self) -> None:
"""Remove user identifying strings from the report.

This particularly removes the user name, host name, and IPs
from attributes which contain data read from the environment, and
removes the ProcCwd attribute completely.
"""
replacements = self._get_replacements()

try:
del self["ProcCwd"]
except KeyError:
Expand Down
Loading