Find hardcoded private keys

Proprietary

Find private keys embedded in source: PEM text (-----BEGIN PRIVATE KEY-----, -----BEGIN RSA PRIVATE KEY-----, -----BEGIN EC PRIVATE KEY-----, ...) and XML key blobs with private parameters in string literals, and keys imported from data written in source (a byte array or collection literal, or Convert.FromBase64String of a constant) by ImportRSAPrivateKey, ImportPkcs8PrivateKey, ImportECPrivateKey and ImportEncryptedPkcs8PrivateKey. Embedded keys cannot be rotated or replaced with post-quantum keys without a code change.

OpenRewrite.CSharp.Recipes.Cryptography.FindHardcodedPrivateKey
mod run . --recipe=OpenRewrite.CSharp.Recipes.Cryptography.FindHardcodedPrivateKey

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.