mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 08:31:53 -05:00
The seven operations that still answered an absent member from a check of their own are read against the vendored shapes now, which leaves every STS operation that models a member reading its constraints from the model: `AssumeRole`, `AssumeRoleWithSAML`, `AssumeRoleWithWebIdentity`, `AssumeRoot`, `DecodeAuthorizationMessage`, `GetDelegatedAccessToken` and `GetFederationToken`. `GetCallerIdentity` carries no member, so there is nothing to read for it. Two answers move, both onto the form the model and the rest of this package give. A member the request leaves out is named as a constraint message spells it, `roleSessionName` rather than `RoleSessionName`, and every absent member is reported together in the order the model lists them, where the check it replaces answered the first it found. A member sent empty is a value the request carries, so it breaks its own minimum length rather than reading as absent. That is the reading #6811 settled for the two services and what `validateRequired` was the last of in this handler. What the seven gain is every bound beside the required members, none of which was read at all: `RoleArn` at 20 to 2048 characters, `RoleSessionName` at 2 to 64, `ExternalId`, `SourceIdentity`, `SerialNumber`, `TokenCode`, `Policy`, `PolicyArns`, `Tags`, `TransitiveTagKeys` and `ProvidedContexts` on `AssumeRole`, `SAMLAssertion` at 4 to 100000, `WebIdentityToken` at 4 to 20000, `ProviderId` at 4 to 2048, `Name` at 2 to 32, `EncodedMessage` at 1 to 10240, and the `DurationSeconds` and `MinimumSessionTokenSize` ranges each operation declares. `AssumeRoot`'s own length check on `TargetPrincipal` said what the model says, so it comes off with the rest. One reading is this emulator's own, and `docs/services/sts.md` says so. `TradeInToken` is required and declares no length, so a request sending it empty carries a value: it reaches the lookup and is answered `ExpiredTradeInTokenException`, the refusal any token that cannot be redeemed gets, where the check it replaces called it absent. Nothing published says what AWS answers an empty trade-in token. Each operation keeps the refusals it answers ahead of the constraints: `GetFederationToken` and `GetSessionToken` turn away session credentials first, and `AssumeRoot` refuses the global endpoint first. Three test fixtures carried values AWS refuses and now carry values it takes. A `RoleSessionName` of `s` is one character where the model declares two, and a `WebIdentityToken` of `jwt` three where it declares four, so the fixtures that sent them are a character longer, as are the two assertions that read a session name back out of an assumed-role ARN and a condition key. The name the shared role-session fixture opens under has one writer now, `EnforcementFixtures.SESSION_NAME`, read by every test asserting on that session rather than spelled again in each: an `aws:userid` condition, a `PrincipalArn` condition, two authorization-denial messages and the ARN two trust-policy cases read back. Each of those carried the one-character name, which is a 403 where the case wants a 200, or a prefix match that no longer pins the whole ARN.
55 lines
2.2 KiB
Python
Executable File
55 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Vendor STS request constraints from botocore's Apache-2.0 service model.
|
|
|
|
`StsRequestShapes` checks the operations listed here against the vendored file through the shared
|
|
`QueryConstraintCheck`, the same walk IAM reads its own file with: required members, lengths,
|
|
patterns, enum values and ranges, as the model states them. The list grows an operation at a time,
|
|
each one taken off the hand-written checks in the same change, so a wave is always reviewable
|
|
against the messages it replaces.
|
|
|
|
Run from anywhere in the repo:
|
|
python3 tools/aws/regen_sts_shapes.py # rewrite the vendored file in place
|
|
python3 tools/aws/regen_sts_shapes.py --check # exit 1 when the vendored file is stale
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import request_shapes
|
|
from request_shapes import REPO_ROOT
|
|
|
|
OUTPUT = REPO_ROOT / "src/main/resources/aws/sts-request-shapes.json"
|
|
MODEL = Path("sts/2011-06-15")
|
|
|
|
# Every operation STS models with a constraint of its own, which is all eleven but
|
|
# `GetCallerIdentity`, whose request carries no member at all.
|
|
#
|
|
# `GetAccessKeyInfo` was the parity case: its hand-written check already answered `accessKeyId` in
|
|
# Smithy's form, from the same bounds and the same pattern. `GetSessionToken` and
|
|
# `GetWebIdentityToken` came next, for members read by nothing at all. The seven below answered an
|
|
# absent member through `validateRequired`, which named the parameter as the request writes it and
|
|
# read a blank value as an absent one, so taking them over rewords those answers onto the form the
|
|
# model and the rest of this package give, which is what `docs/services/sts.md` records.
|
|
OPERATIONS = (
|
|
"GetAccessKeyInfo",
|
|
"GetSessionToken",
|
|
"GetWebIdentityToken",
|
|
"AssumeRole",
|
|
"AssumeRoleWithSAML",
|
|
"AssumeRoleWithWebIdentity",
|
|
"AssumeRoot",
|
|
"DecodeAuthorizationMessage",
|
|
"GetDelegatedAccessToken",
|
|
"GetFederationToken",
|
|
)
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
return request_shapes.main(argv, script=__file__, model=MODEL, output=OUTPUT,
|
|
description=__doc__, operations=OPERATIONS)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|