Repository navigation
fix(pii-safe): detect PII in nested type arguments - #11571
Conversation
|
✅ Validation Passed: All report and feature-flag labels are correctly set. |
|
Could a maintainer apply |
There was a problem hiding this comment.
Treating a nested @HasPii type argument as sufficient allows an unmasked generic property to bypass the existing safety check.
The generated toString() delegates to the outer generic type’s toString(), which is not guaranteed to preserve masking:
@PiiSafe.HasPii
data class MessageAddress(@get:PiiSafe.Mask val value: String)
class LeakyEnvelope<T>(val value: T) {
override fun toString() = (value as MessageAddress).value
}
@PiiSafe.HasPii
data class MessageEnvelope(val secret: LeakyEnvelope<MessageAddress>) Before this change, MessageEnvelope fails compilation because secret needs @Mask or @Hide. With this change, it compiles and produces:
MessageEnvelope(secret = private)
Could we keep recursive type-argument detection for HasPiiPropagationChecker, but only allow a directly @HasPii property OR an explicitly @Mask/@Hide property to satisfy HasPiiRequiresAnnotatedPropertyChecker?
|
Thanks — you're right. Recursive type-argument detection now remains only in
I added the Verification on the refreshed branch:
|
|
Thanks for your contribution! Your pull request has been merged and will be part of Thunderbird 25. We appreciate the time and effort you put into improving Thunderbird. If you haven’t already, you’re welcome to join our Matrix chat for contributors. It’s where we discuss development and help each other out. https://matrix.to/#/#tb-android-dev:mozilla.org |
Contribution Summary
Linked Issue/Ticket: Fixes #11570
RFC / Technical Design (if applicable): N/A — focused compiler-plugin bug fix
Description
HasPiiPropagationChecker, so an unannotated data class cannot hide a PII-bearing type inside nested containers.HasPiiRequiresAnnotatedPropertyCheckerstrict: a@HasPiidata class is valid only when a property is directly@HasPiior explicitly uses@Mask/@Hide; a nested PII type alone is insufficient because the outer generic'stoString()may leak it.Map<String, List<MessageAddress>>propagation and an unmaskedLeakyEnvelope<MessageAddress>property.Before the initial implementation, the two nested-type regressions ran with the six existing focused tests and both failed. A review regression then demonstrated that the shared recursive predicate allowed an unmasked generic property to compile (1 of 4 annotation-required tests failed before the correction). After separating the policies, all eight focused tests pass.
Screen Shots
N/A — no UI changes.
AI Disclosure
Select one of the following (mandatory)
OpenAI Codex generated the implementation, tests, and pull request text. No manual human code review was performed before submission; the exact automated checks run are listed below.
Verification
Passed:
./gradlew :library:pii-safe:compiler-plugin:test --tests 'net.thunderbird.piisafe.compiler.fir.checkers.HasPiiPropagationCheckerTest' --tests 'net.thunderbird.piisafe.compiler.fir.checkers.HasPiiRequiresAnnotatedPropertyCheckerTest'— 8 tests./gradlew :library:pii-safe:compiler-plugin:check— full module tests (41), Detekt, and Spotless./gradlew detekt spotlessCheck— repository-widegit diff --checkNot run locally:
./gradlew test lint detekt spotlessCheckcould not reachtestorlintbecause this host has no Android SDK (ANDROID_HOME/sdk.dir). Repository-widedetektandspotlessCheckwere rerun separately and passed.connectedAndroidTestwas not run because no Android SDK/device is available; the changed module is a JVM compiler plugin and its focused/full module tests passed.Contribution Checklist
gradlew spotlessCheckto check andgradlew spotlessApplyto format your source code; will be checked by CI).gradlew testDebugUnitTest; will be checked by CI). The relevant JVM module suite passes; the repository-wide Android task is blocked locally by the missing SDK as documented above.