Consider sanitizing all known secret values in text when serializing recordings #2378
Labels
Central-EngSys
This issue is owned by the Engineering System team.
EngSys
This issue is impacting the engineering system.
Currently we rely on known secret variable names or JSONPath to denote secret values in test recordings. For example, anywhere a variable named "MySecret" is used would be sanitized, or - after spending the compute to deserialize a JSON payload (if JSON; XML not supported currently) - a property matching some JSONPath should be sanitized.
But where secret values exist in text, relying only on JSONPath still requires a developer to input this and is prone to mistakes. While JSONPath also solves problems where secrets are output from services and not known at dev time (i.e. we need to keep support), I think it's worth considering something similar to what I did in Search: https://github.com/Azure/azure-sdk-for-net/blob/71054d50e35c7ebf5eee0a185c48dab702f6fb82/sdk/search/Azure.Search.Documents/tests/Utilities/SearchRecordedTestSanitizer.cs#L93-L125
Effectively, using both an as-is copy and JSON-encoded copy of the secret value search all text matching this value when saving a recording and sanitizing it. Because this could be expensive by default, we could still have developers opt into it, but wouldn't need to know all possible JSONPaths up front (and mitigates the case where the service may add some different patterns).
The text was updated successfully, but these errors were encountered: