Use SecretStrSubstNo to compose strings that contain secrets
SecretStrSubstNo is the secret-preserving counterpart of StrSubstNo. It inserts SecretText arguments into %1, %2, and similar placeholders and returns SecretText without materializing the result as plain text.
- microsoftlayer
- securitydomain
- 2examples
- 2pull requests
Rule on GitHub · microsoft layer · security · BC 23.. · tier official · derived
Description
SecretStrSubstNo is the secret-preserving counterpart of StrSubstNo. It inserts SecretText arguments into %1, %2, and similar placeholders and returns SecretText without materializing the result as plain text. It is the right tool for values such as a Token %1 authorization header or a URI with an API key placeholder.
Best Practice
Compose every secret-bearing string through SecretStrSubstNo, ensure the format contains a placeholder for each secret, and keep the result as SecretText. Pass it to HttpRequestMessage.SetSecretRequestUri, HttpHeaders.Add, or HttpContent.WriteFrom. See sample: secretstrsubstno-for-composing-secrets.good.al.
Anti Pattern
Keeping a credential in Text and inserting it with StrSubstNo, or calling SecretStrSubstNo with a format that has no placeholder for the secret. The first exposes the value as plain text; the second silently omits it. See sample: secretstrsubstno-for-composing-secrets.bad.al.
Examples
- Good: secretstrsubstno-for-composing-secrets.good.al
- Bad: secretstrsubstno-for-composing-secrets.bad.al
Names
- SecretText.SecretStrSubstNo(Text [, SecretText,…]) Method (names SecretStrSubstNo)
- Text.StrSubstNo(Text [, Any,…]) Method (names StrSubstNo)
Changed by
- #174 Make BCQuality documentation easier for partners to get started, 2026-09-09
- #92 Correct security and privacy knowledge guidance, 2026-07-14
From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).