[forensics] Fix redaction application with empty characters

Previously, redaction would find a match using regex and record the
match as plain text. After all matches were found, the redactions would
be applied by finding the plain text within the original content and
making the replacement.

This scheme would result in incorrect behavior if a plain text match was
a subset of another, later plain text match such as "abc" and "abcd"
resulting in "<REDACTED-HEX: 1>" and "<REDACTED-HEX: 1>d", with the
trailing "d" not redacted by mistake.

This CL changes from the plain text find-replace scheme to one which
records the position within the original content and makes the
replacements at those positions.

Note that a 2-step approach is necessary because we want to insert an ID
for the redacted hex, and want this ID to match for multiple instances
of the same original text being redacted. So a 1-step re2::GlobalReplace
would not work because all text matching a pattern would have the same
ID.

Fixed: 350095296
Tested: `fx test //src/developer/forensics`
Change-Id: I5bbc94eb8c2f600c6e6098c03260801fbe7b75a7
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1082700
Reviewed-by: Alex Pankhurst <pankhurst@google.com>
Commit-Queue: Thomas Gales <tgales@google.com>
3 files changed
tree: c6442ad1857e5a7a25dd7f11a40de0b061ee246c
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. infra/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .editorconfig
  17. .git-blame-ignore-revs
  18. .gitattributes
  19. .gitignore
  20. .gitmodules
  21. .gn
  22. .ignore
  23. analysis_options.yaml
  24. AUTHORS
  25. BUILD.gn
  26. CODE_OF_CONDUCT.md
  27. CONTRIBUTING.md
  28. fuchsia.code-workspace
  29. LICENSE
  30. OWNERS
  31. PATENTS
  32. pyproject.toml
  33. pyrightconfig.json
  34. README.md
  35. rustfmt.toml
  36. shac.star
  37. shac.textproto
README.md

Fuchsia

What is Fuchsia?

Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.

We expect everyone interacting with our project to respect our code of conduct.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.