# The secret half of an AWS access key: forty characters with nothing in them
# to say what they are, and the name written in front of them, which is the
# whole of what says one is there. So the cases below are mostly about the
# name — where a pattern with a prefix of its own would be about the prefix —
# and the ones that hold no value are text this pattern would take if it read
# the value alone.
#
# Every value here is built from the ordered run 0123456789abcdef, which no
# real credential is. Where a case is about the alphabet rather than the count,
# the + and the / are written into that run: they are what separates base64
# from the hexadecimal the run is otherwise read as.

patterns: aws-secret-access-key

# The names the value arrives under. AWS documents the environment variable and
# the shared credentials file; the JSON is what an assume-role call prints into
# a CI log; the rest are the same three words as an SDK, a workflow file and a
# person writing to a colleague spell them. One rule reads all of them — the
# three words in order, a separator or nothing between each pair, case set
# aside — so no case here is a spelling the pattern was told about.

case:     a secret access key in an environment assignment
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef01234567
out:      AWS_SECRET_ACCESS_KEY=«aws-secret-access-key»

case:     a secret access key in a shared credentials file
in:       [default]\naws_secret_access_key = 0123456789abcdef0123456789abcdef01234567
out:      [default]\naws_secret_access_key = «aws-secret-access-key»

case:     a secret access key in the json an assume-role call prints
in:       {"SecretAccessKey":"0123456789abcdef0123456789ab+/ef01234567","Expiration":"2026-08-17T00:00:00Z"}
out:      {"SecretAccessKey":"«aws-secret-access-key»","Expiration":"2026-08-17T00:00:00Z"}

case:     a secret access key under the name an sdk configuration writes
in:       const credentials = { secretAccessKey: "0123456789abcdefABCDEF0123456789abcdef01" };
out:      const credentials = { secretAccessKey: "«aws-secret-access-key»" };

case:     a secret access key under the name a workflow input writes
in:       aws-secret-access-key: 0123456789abcdef0123456789abcdef01234567
out:      aws-secret-access-key: «aws-secret-access-key»

case:     a secret access key on a command line
in:       aws configure set aws_secret_access_key 0123456789abcdef0123456789abcdef01234567
out:      aws configure set aws_secret_access_key «aws-secret-access-key»

case:     the words written out, as somebody pasting one writes them
in:       Secret Access Key: 0123456789abcdef0123456789abcdef01234567
out:      Secret Access Key: «aws-secret-access-key»

case:     a value in single quotes
in:       aws_secret_access_key='0123456789abcdef0123456789abcdef01234567'
out:      aws_secret_access_key='«aws-secret-access-key»'

case:     tabs around the assignment
in:       aws_secret_access_key\t=\t0123456789abcdef0123456789abcdef01234567
out:      aws_secret_access_key\t=\t«aws-secret-access-key»

# The alphabet is base64's own, and a value built from the ordered run alone
# carries ten digits and six letters of it. These two carry the letters to the
# end of both cases, so the characters no other case here writes are written
# somewhere.

case:     a value carrying the lowercase alphabet to its end
in:       aws_secret_access_key=0123456789abcdefghijklmnopqrstuvwxyzABCD
out:      aws_secret_access_key=«aws-secret-access-key»

case:     a value carrying the uppercase alphabet to its end
in:       aws_secret_access_key=0123456789abcdefGHIJKLMNOPQRSTUVWXYZ+/01
out:      aws_secret_access_key=«aws-secret-access-key»

# The name stays in the text. It is what tells a reader which credential leaked
# and which one to rotate, and redacting it would leave a line of asterisks
# saying neither.

case:     the name is left in the text and the value is not
in:       [default]\naws_access_key_id = AKIA0123456789ABCDEF\naws_secret_access_key = 0123456789abcdef0123456789abcdef01234567
out:      [default]\naws_access_key_id = AKIA0123456789ABCDEF\naws_secret_access_key = «aws-secret-access-key»

# The count, which is forty exactly and is the whole of the run it stands in.
# AWS states no length for a secret access key anywhere, so forty is what every
# example it writes is; the pattern's own file weighs what resting on that
# costs.
#
# Holding the value to being the whole of its run is a tightening the access
# key ID pattern beside this one cannot have: it has no assignment in front of
# it to say where a value begins, so it cannot tell a longer run from a key
# written against a capital, and it takes the first twenty of one. Here the
# name says where the value starts and the byte behind the fortieth says
# whether it stopped there, so a longer run is text that is no value at all.

case:     one character short of the count
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef0123456
out:      AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef0123456

case:     one character more than the count
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345678
out:      AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345678

case:     a name in front of a run no value can be
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345670123456789abcdef
out:      AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345670123456789abcdef

# Padding is left out of the alphabet, because forty characters carry thirty
# bytes exactly and a secret written in base64 closes on none. What that decides
# is where a run ends, and it falls both ways: thirty-eight characters of
# somebody else's base64 closed by == measure thirty-eight and are no value,
# where admitting the padding would measure them forty; and padding written
# behind a whole run is part of no value, so the forty in front of it go and the
# == stays.

case:     padding closing a run short of the count
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345==
out:      AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef012345==

case:     padding written behind a whole run
in:       AWS_SECRET_ACCESS_KEY=0123456789abcdef0123456789abcdef01234567==
out:      AWS_SECRET_ACCESS_KEY=«aws-secret-access-key»==

# What has to stand between the name and the value. One character of an
# assignment is asked for, and none of what may stand there is a character a
# value is written with — so a value read behind one begins where a run begins,
# and a name written straight against forty characters is no assignment at all.
# The run of spaces is counted rather than run out, and the count is set past
# any column a name of this length is aligned to: a value set out in a table is
# still located, and the last case here is where that line falls.

case:     a name written straight against the value
in:       secret_access_key0123456789abcdef0123456789abcdef01234567
out:      secret_access_key0123456789abcdef0123456789abcdef01234567

case:     a line break where a space may stand
in:       AWS_SECRET_ACCESS_KEY=\n0123456789abcdef0123456789abcdef01234567
out:      AWS_SECRET_ACCESS_KEY=\n0123456789abcdef0123456789abcdef01234567

case:     a name on one line and a value on the next
in:       AWS_SECRET_ACCESS_KEY\n0123456789abcdef0123456789abcdef01234567
out:      AWS_SECRET_ACCESS_KEY\n0123456789abcdef0123456789abcdef01234567

case:     a value aligned to a column
in:       aws_secret_access_key =          0123456789abcdef0123456789abcdef01234567
out:      aws_secret_access_key =          «aws-secret-access-key»

case:     more spaces than the assignment reads
in:       aws_secret_access_key=                 0123456789abcdef0123456789abcdef01234567
out:      aws_secret_access_key=                 0123456789abcdef0123456789abcdef01234567

# And what no name reaches. Forty characters of this alphabet are a git object,
# a chunk of any base64 blob and a secret access key alike, so the value on its
# own says nothing and this pattern says nothing about it. All three words are
# asked for besides: secret key is a name a framework's signing key, a session
# key and a webhook secret all carry, and the middle word is what keeps the
# name holding the pattern up.

case:     forty characters with no name in front of them
in:       0123456789abcdef0123456789abcdef01234567
out:      0123456789abcdef0123456789abcdef01234567

case:     a git object written out in full
in:       commit 0123456789abcdef0123456789abcdef01234567
out:      commit 0123456789abcdef0123456789abcdef01234567

case:     a name with the middle word left out
in:       AWS_SECRET_KEY=0123456789abcdef0123456789abcdef01234567
out:      AWS_SECRET_KEY=0123456789abcdef0123456789abcdef01234567

case:     a signing key under a name of its own
in:       SECRET_KEY=0123456789abcdef0123456789abcdef01234567
out:      SECRET_KEY=0123456789abcdef0123456789abcdef01234567

case:     the words in the wrong order
in:       ACCESS_SECRET_KEY=0123456789abcdef0123456789abcdef01234567
out:      ACCESS_SECRET_KEY=0123456789abcdef0123456789abcdef01234567

case:     a separator no name is written with
in:       secret.access.key=0123456789abcdef0123456789abcdef01234567
out:      secret.access.key=0123456789abcdef0123456789abcdef01234567

case:     a word closing on the last word of a name
in:       monkey=0123456789abcdef0123456789abcdef01234567
out:      monkey=0123456789abcdef0123456789abcdef01234567

case:     prose naming the credential and holding none
in:       the secret access key is shown once and never again
out:      the secret access key is shown once and never again

case:     a log line
in:       time=2026-08-17T00:00:00Z level=info msg="calling api" url=https://api.example.com/config
out:      time=2026-08-17T00:00:00Z level=info msg="calling api" url=https://api.example.com/config
