Replies: 1 comment 2 replies
-
Something like this could be generally useful, definitely. I actually implemented something similar to this in our app - we have a reducer that reports certain actions to New Relic using their breadcrumbs feature and I needed to ensure we redacted sensitive action parameters e.g. passwords or any PII. The high level reducer function just takes an ActionFilter type, which is just a witness style wrapper around an (Action) -> Action? closure. This lets you return nil to exclude an action entirely or you can return a new action with redacted parameters. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I - like many I'm sure - have found the debug output capabilities of the TCA to be immensely helpful in both understanding how the architecture works, as well as in troubleshooting bugs. However, it comes with the downside of potentially leaking sensitive information. While it is only enabled in debug builds (and only if you use
debug()
or one of it's equivalents on your reducer), this could still be problematic.I originally thought this would need a change within the TCA itself, but then realized I could introduce my own redaction via a custom type conforming to
CustomDebugOutputConvertible
, such as:I'm not entirely convinced that such a type should be embedded within the TCA to help with this edge case, but perhaps the documentation should mention the risk of leaking sensitive information and point users towards
CustomDebugOutputConvertible
? Originally I was usingCustomStringConvertible
andCustomDebugStringConvertible
without luck, before finding thatCustomDebugOutputConvertible
was needed (the switch statement inDebug.swift
looks like it only falls back toCustomStringConvertible
/CustomDebugStringConvertible
for primitive properties that have no children of their own.Alternatively, perhaps the
DebugEnvironment
could have a function that determines if a given label (and it's values) should be included/excluded from debug output, which would allow one to specify a blacklist.Edit: Perhaps an even better approach for a generic Redacted type would be:
Though if you had some runtime capabilities that depended on reflection, this might be undesirable.
Beta Was this translation helpful? Give feedback.
All reactions