mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
fee688bd051a5bde4e2e8a4d5e0f5d75c7ffe00a
60
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
078931597e |
fix(iam): check five more services on the resources their requests name (#6927)
Under IAM enforcement, Budgets, Cost and Usage Reports, Service Quotas, Textract and Translate requests were checked on `*`, so a grant scoped to a budget, a report definition, a quota, an adapter or a terminology was refused, and a deny scoped to one never applied. The generated table of the resources requests name now reads them, 103 operations, from AWS's Service Reference and botocore as it reads the first three batches: their namespaces move from the generator's NOT_COVERED to NAMESPACES and the table is regenerated, nothing in it edited by hand; 717 operations over 17 namespaces. Each resource type's ARN format is the one Floci mints or reads: `budget/<name>` with no Region (Budgets' tag handler parses it), `definition/<name>`, and `<service code>/<quota code>` (Service Quotas' QuotaArn). Three corrections, each with its reason: CreateBudget and UpdateBudget name their budget by Budget.BudgetName and NewBudget.BudgetName, and PutReportDefinition its report by ReportDefinition.ReportName, inside a structure the rule does not read. Without them UpdateBudget and PutReportDefinition were checked only on their BillingViewArn, a billing view's ARN by botocore's pattern, so a caller allowed on one budget or report could give its ARN there and name another. Verified Permissions minted a policy store's ARN with a Region, where AWS gives none: its CreatePolicyStore example answers arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111, the Service Reference's format alike. It now mints it without one, in the Region's partition. Not read yet, each with its reason in NOT_COVERED: Verified Permissions, whose policyStoreId may name a store by its alias, which AWS authorizes as the action on the store the alias points to and GetPolicyStoreAlias on the alias, and whose aliasName carries the `policy-store-alias/` its format already gives; Auto Scaling, whose group and launch configuration ARNs Floci mints without AWS's id (`autoScalingGroup:<name>` for `autoScalingGroup:<id>:autoScalingGroupName/<name>`), which ECS reads back; SWF, whose domain format the Service Reference gives no Region while the SWF Developer Guide gives one; and CloudHSM, whose formats end in names while its requests give ids. |
||
|
|
34269655ba |
feat(sts): read every modelled operation's constraints from the model (#6925)
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. |
||
|
|
e24bc36f64 |
feat(ecr): support account settings (#6855)
* feat(ecr): support account settings * fix(ecr): validate account settings against request model |
||
|
|
c9c1c0990b |
feat(sts): read a Query request's declared constraints from the model (#6891)
`GetAccessKeyInfo`, `GetSessionToken` and `GetWebIdentityToken` are held to the constraints botocore's STS model declares, which `tools/aws/regen_sts_shapes.py` vendors into `aws/sts-request-shapes.json` and `StsRequestShapes` reads through the same `QueryConstraintCheck` walk IAM reads its own file with. The two services share the protocol, the message wording and the generator, so what is new is which operations are read rather than how. What it adds is on `GetSessionToken`: `SerialNumber`, `TokenCode` and `MinimumSessionTokenSize` are declared and nothing read them, so a serial number under 9 characters, a token code that is not six digits and a size past 4096 answer `ValidationError` where they answered credentials. The size is still only validated, the token staying the length this emulator mints. `GetAccessKeyInfo` and `GetWebIdentityToken` keep the messages they already answered, from the same bounds and the same patterns, and about 130 lines of hand-written audience, tag and access-key checks come out. One answer moves: a value breaking two constraints is answered for both, where the if-else chain stopped at the first. That is the reading #6402 settled and #6580 already took for an empty role name. `jwtAlgorithmType` publishes a fixed length of 5 and no enum, the two values coming from the reference, so the walk takes a documented constraint keyed by member name and reports it in that member's place, which keeps a collected message in the model's order. It is reported only for a member the request carries that breaks nothing the model declares, which is the exclusivity the hand-written helper had. A value that is no number at all stays `InvalidParameterValue`, answered before the constraints, since the model declares a range and says nothing about what counts as a number; a digit string is a number of any width, so a `DurationSeconds` of `99999999999` breaks the maximum rather than being called no integer, as #6625 settled for an oversized `MaxItems`. Each operation asks for its violations where its own check ran rather than ahead of the switch, because `GetSessionToken` refuses session credentials before it reads anything. The whitespace around a number comes off wherever this handler reads one. The check takes a padded value and holds it to its range, so the read behind it parses the same text: parsing the value as the request spelled it threw there and fell back to the default, so a ` 3600 ` asking for an hour would have been handed the twelve hours `GetSessionToken` defaults to, or the five minutes a web identity token defaults to. IAM reads its own `MaxItems` that way already. The generator is not new code. `request_shapes.main` already drives the five generators that vendor member types, so it takes an `operations` argument now and both Query-protocol generators hand it their model, output and operations the same two-line way, which takes the hand-rolled driver out of `regen_iam_shapes.py` as well. ECR and Resource Groups still carry theirs and are a refactor of their own. The generator contract tests move with it: that a vendored file carries exactly the operations its generator lists and resolves every shape it names is one parametrized test over all four constraints generators rather than a copy per generator, and `build_constraints`'s own properties are tested once, where the shared module already tested them. The model transform the driver takes is driven through it as well, the file it writes carrying what the transform left and the staleness check calling that file current only when it prepares the model the same way, and IAM's own tests read the vendored file for each paged request reduced. Three sentences this handler wrote out by hand go the same way. The two range refusals and the length refusal on `TargetPrincipal` come from `SmithyValidationErrors`, which already wrote them word for word, and the "Must be an integer." refusal has one writer and three callers. The length comparison counts code points rather than UTF-16 units as a result, which is the reading the rest of the package uses. |
||
|
|
385ffcfdd0 | feat(lambdaweb): set the WebFunctionAuthType condition keys on endpoint routes (#6893) | ||
|
|
5a84d08383 |
fix(iam): read iam:PermissionsBoundary from the stored role or user an action names (#6897)
On the 15 actions where the Service Reference lists iam:PermissionsBoundary and the request carries no boundary, such as AttachRolePolicy, PutUserPolicy and GetRole, the key is the boundary stored on the role or user named by RoleName or UserName. The generator writes these pairs to a fromTarget section, and IamConditionContextResolver looks the boundary up through IamService. A role or user without one carries no value for the key. |
||
|
|
407ac4e210 |
fix(iam): check CodeBuild and Kinesis Data Analytics on the resources their requests name (#6884)
Under IAM enforcement, CodeBuild and Kinesis Data Analytics (Amazon Managed Service for Apache Flink) requests were checked on `*`, so a grant scoped to a project, a report group or an application was refused, and a deny scoped to one never applied. The generated table of the resources requests name now reads them, 92 operations, from AWS's Service Reference and botocore as it reads the first two batches: their namespaces move from the generator's NOT_COVERED to NAMESPACES and the table is regenerated, nothing in it edited by hand; 614 operations over 12 namespaces. Each resource type's ARN format is the one Floci's handler mints, which the tests check against the ARN each create returns: `project/<name>`, `report-group/<name>`, `build/<project>:<number>` and `application/<name>`. Kinesis Data Analytics v1, the KinesisAnalytics_20150814 target of SQL applications, is not read: Floci serves v2 only, and v1's operations share v2's names with other members. It joins EventBridge V2 in the generator's CLIENTS_NOT_READ, with its reason. CodeBuild authorizes a build on its project: the CodeBuild User Guide's permissions reference gives BatchGetBuilds, StopBuild, RetryBuild and BatchDeleteBuilds the resource project/project-name. Their requests name builds by id, which is `<project>:<id>` (its CODEBUILD_BUILD_ID example is codebuild-demo-project:b1e6661e-...), so four corrections read the project from the id up to its `:`. For them the table may read a member filling a variable up to a character `before`, as it already read an ARN member, in the generator, the loader and the reader. Without them a policy granting StartBuild and BatchGetBuilds on a project, as a pipeline's CodeBuild action role has, allowed starting a build and refused watching it. A list filling a type's one variable may mix names and ARNs: CodeBuild's BatchGetProjects takes either for each of `names`. Each value that is an ARN of the type now names that resource and the others are read as names, where the reader took ARNs as given only when every value was one, and otherwise put an ARN inside the name's format, refusing a caller granted both projects. Not in this change: a build batch, whose id the documents give no format for and which Floci does not serve, and a report, named by a report ARN where AWS checks its report group, stay on `*`. |
||
|
|
096d336fab |
fix(iam): check five more services on the resources their requests name (#6810)
Under IAM enforcement, Amazon Data Firehose, Cognito identity pools,
Cloud Map, ACM and CodePipeline requests were checked on `*`, so a
grant scoped to a delivery stream, an identity pool, a namespace or a
service, a certificate, a pipeline or a webhook was refused, and a deny
scoped to one never applied.
The generated table of the resources requests name now reads them, 149
operations, from AWS's Service Reference and botocore as it reads the
first batch: their namespaces move from the generator's NOT_COVERED to
NAMESPACES, and the table is regenerated, nothing in it edited by hand.
Each resource type's ARN format is the one Floci's handler mints, which
the tests check against the ARN each create returns:
- `deliverystream/<name>`, `identitypool/<id>`, `namespace/<id>`,
`service/<id>`, `certificate/<id>` and a pipeline's bare name.
- A CodePipeline webhook: AWS's is `webhook:<name>` (the Service
Reference's format, and the CodePipeline User Guide's
"arn:aws:codepipeline:eu-central-1:ACCOUNT_ID:webhook:my-webhook"),
where Floci minted `webhook/<name>`; it now mints AWS's.
Corrections, each with its reason:
- StartPipelineExecution and GetPipelineState name their pipeline by a
bare `name` ("The name of the pipeline to start"), which the rule
reads only for an operation named after the type, as Step Functions'
StartExecution names its execution, not its state machine, by `name`.
- CreatePipeline and UpdatePipeline name it by `pipeline.name`, and
PutWebhook the webhook by `webhook.name` and the pipeline it connects
to by `webhook.targetPipeline`. `pipeline.roleArn` holds the role
CodePipeline assumes, an IAM role's ARN by botocore's pattern, and
names no pipeline: read as one, a pipeline-shaped value there was the
only resource an UpdatePipeline was checked on, so a grant on one
pipeline let a request change another.
- CreateCustomActionType and DeleteCustomActionType are checked on
`actiontype:Custom/<category>/<provider>/<version>`: a custom action
type's owner is Custom, which the request does not give, and AWS's
CreateCustomActionType example answers "owner": "Custom".
- Cloud Map's CreateService names its namespace by NamespaceId or,
when it gives none or a JSON null, by DnsConfig.NamespaceId, which
botocore keeps ("Use NamespaceId in Service instead") and the handler
reads then; read by NamespaceId alone, a deny on the namespace did
not hold for a request giving it in DnsConfig. A member given a JSON
null now counts as absent in a resource's `when` and `unless`, as a
handler reading it with asText(null) takes it, unless the table reads
it as a value through `absent` (EventBridge's bus, `default`).
For those, the table may fill a variable from a structure's field
(`pipeline.name`), and give a variable no member gives the one value
its handler uses (`fixed`), in the generator, the loader and the
reader.
A create that names another resource beside the one it makes has its
tags checked on the one it makes alone, which the table marks `made`:
the resource of the type, or with an ARN format's leading resource
word, related to the operation's name past its verb. PutWebhook's tags
go on the webhook, not the pipeline it connects to, and CreateService's
on `service/*`, not the namespace; no other operation in the table is
marked.
Application Auto Scaling stays unread, its reason in NOT_COVERED: a
scalable target's ARN ends in an id the service mints, while requests
name the target by ServiceNamespace, ResourceId and ScalableDimension,
and read as a member ResourceId would fill that id.
RequestResourceMembersTest's test of every resource in the table now
expects, with the resource a request names, the resources of its
operation that every request names: Cloud Map's CreateService names
the service it creates with every variable open.
|
||
|
|
52eb4b9a9c |
fix(iam): read condition keys a request carries in a member under another name (#6858)
BY_HAND in tools/aws/regen_iam_condition_keys.py names the member for four pairs: iam:ServiceSpecificCredentialServiceName from ServiceName and iam:ServiceSpecificCredentialAgeDays from CredentialAgeDays on CreateServiceSpecificCredential, and iam:DelegationDuration from SessionDuration and iam:TemplateArn from Permissions.PolicyTemplateArn on CreateDelegationRequest. --check fails when a BY_HAND member leaves botocore, its type no longer fits the key, or the reference stops listing the pair. The other notRead pairs now say where AWS takes the value from. |
||
|
|
3212ce3c15 |
fix(iam): page ListUsers, ListGroups and policy lists with MaxItems and Marker (#6267)
* fix(iam): page ListUsers, ListGroups and policy lists with MaxItems and Marker
ListUsers, ListGroups, ListAttached{User,Group,Role}Policies and
List{User,Group,Role}Policies read neither MaxItems nor Marker and always
answered IsTruncated=false with every entry. They now go through the same
paginate helper ListRoles and ListPolicies use: an omitted MaxItems returns
100 items as the API reference documents, a MaxItems outside 1 to 1000 is a
ValidationError, a Marker the handler did not issue is InvalidInput, and a
Marker appears only on a truncated page.
Users, groups and inline policy names are listed in name order and attached
policies in ARN order, so a Marker keeps pointing at the same place between
calls even when the entry it names is removed in between.
* fix(iam): resume the newly paged IAM lists only from their own markers
ListUsers, ListGroups and the attached and inline policy lists read a
Marker they could not verify as a list offset, so Marker=1 silently
skipped the first entry, and a marker issued for one role's list resumed
another role's list after the same policy. These lists have only ever
issued signed markers, so their cursor now carries the action and, for a
per-principal list, the principal, and any other marker is InvalidInput.
ListRoles, ListPolicies and the other readers keep their existing marker
handling.
Also covers the omitted-MaxItems default on ListUsers and ListGroups with
101 entries: 100 on the first page, IsTruncated and a Marker that fetches
the last one.
* fix(iam): bind the newly paged IAM lists' markers to the request account
IAM entities are stored per account, but the marker cursor named only the
action and principal, so a marker issued in one account resumed the same
listing in another account after the same name and skipped its earlier
entries. The cursor now carries the account the request reads from, and a
marker from another account is InvalidInput.
* feat(iam): generate the IAM paginator table from botocore
tools/aws/regen_iam_paginators.py writes src/main/resources/aws/iam-paginators.json
from botocore's iam/2010-05-08 model, as the other tools/aws generators do: every
operation whose request models Marker, with its input and output token, limit
key, truncation flag and result keys, the MaxItems bounds of maxItemsType
(1 to 1000), the default page size the limit's documentation states ("defaults
to 100"), and markerType's bounds.
The 34 operations botocore's paginators-1.json lists take their tokens and
result keys from it. The six that model Marker without a paginator
(GetServiceLastAccessedDetails, GetServiceLastAccessedDetailsWithEntities,
GetOrganizationsAccessReport, ListServiceSpecificCredentials,
ListDelegationRequests, ListPoliciesGrantingServiceAccess) are read from
their request and response shapes and marked paginator: false.
ListServiceSpecificCredentials documents no default and
ListPoliciesGrantingServiceAccess models no MaxItems; the table records
both as such rather than inventing a value.
make aws-data-sync regenerates it and make aws-data-check fails when it is
stale against the pinned botocore.
* fix(iam): page every IAM list through one path driven by the paginator table
IamQueryHandler paged eight lists by hand through paginateScoped, a few more
through paginate, and left the rest (the tag readers, ListAccessKeys,
ListInstanceProfiles, ListPolicyVersions, GetGroup, ListGroupsForUser,
ListEntitiesForPolicy, GetAccountAuthorizationDetails, the simulations and
others) ignoring MaxItems and Marker with IsTruncated=false. Every operation
the generated aws/iam-paginators.json lists now pages through one paginate
path that reads its entry: the limit's bounds and default, the members that
resume and continue it, and the result keys pagedList and pagedLists write
under. paginateScoped, paginateByMarker and the hardcoded 100/1000 are gone.
ListEntitiesForPolicy and GetAccountAuthorizationDetails page their several
lists as one, in the paginator's order.
Marker semantics, chosen deliberately: a Marker is opaque and resumes only the
listing that issued it, on every paged operation. AWS documents it as "the
value of the Marker element in the response that you received", so a value
Floci did not issue, a bare number included, is InvalidInput; ListRoles,
ListPolicies and the report readers no longer read one as an index. The
marker names the last item of its page, so a deletion or creation ahead of
it skips nothing and repeats nothing, and it is signed (not prefixed) over
the account, the operation and every request member except Marker and
MaxItems, so a marker from another operation, principal, filter or account
is refused while the page size may change between calls. Signing the scope
instead of carrying it keeps issued markers short. markerType's 320-character
bound is not checked separately: every other value is refused as unissued,
and a long ARN key could otherwise push an issued marker past it.
MaxItems is now checked before Marker, as a malformed request is rejected
before anything is read from it. An omitted MaxItems is the documented 100;
ListServiceSpecificCredentials, which documents no default, returns its whole
list.
IamListPaginationIntegrationTest.everyPaginatedOperationHonoursMaxItemsAndMarker
iterates the table's 34 paginated operations, each with a fixture listing two
items, and checks the MaxItems bounds, a one-item page, resumption without
loss or repetition, the default page, and refusal of an unissued, bare-index
or other operation's marker. Its fixture map must name exactly the table's
operations, so one AWS starts paging later fails until it has one.
ListAccountAliases can hold one alias, so it is checked for everything but a
cut page. The tests the table test subsumes are removed; the ordering, anchor,
cross-listing and cross-account tests stay. Two ServiceLastAccessed tests
that walked by bare index now use issued markers.
* fix(iam): hold paged requests to the model through IamRequestShapes
MaxItems and Marker are request constraints, and main now checks a
request against the model before it runs. Every operation the paginator
table pages joins that wave in regen_iam_shapes.py, and the bounds leave
iam-paginators.json (which keeps only defaultItems, the documented page
size) and limit(), which now only parses the number and applies the
default. A pytest pins that every operation the paginator table carries
is in the wave, so a list AWS starts paging later cannot slip past the
bounds.
Six paged operations join with Marker and MaxItems alone: the three
report readers, whose JobId is answered by hand as "length equal to 36"
and whose SortKey enum is checked by hand; ListPoliciesGrantingServiceAccess,
whose empty ServiceNamespaces is answered InvalidInput; and the two
Simulate operations, whose ContextEntries nest a list inside a list of
structures, which the walk refuses. Vendoring their whole request would
reword answers main already settled; vendoring nothing would leave their
paging unbounded (SimulateCustomPolicy with MaxItems=0 was a 500).
Markers fit markerType's 320 characters. A marker embeds the key of the
item its page ended on, so a policy ARN with a long path produced one
of 610 characters, which the model check would now refuse on the way
back. SignedMarkers takes a maximum length: a cursor that would exceed
it is carried as a SHA-256 digest (119 characters once signed and
encoded), and the instance keeps the digest -> key mapping. That keeps
the existing resume semantics exactly: the marker still resolves to the
full key, so a deleted anchor resumes at the first key after it, and
the signature still binds account, operation and filter. Two stateless
alternatives were rejected: a truncated key prefix plus digest cannot
order a deleted anchor against items sharing the prefix, and a position
index skips or repeats when items ahead of it are deleted. The cost is
one map entry per distinct long key a page has ended on, never evicted
(marked ponytail in the code); markers already do not survive a
restart, as the signing key is per instance. Keys short enough to embed
are carried as before.
Checkstyle (./mvnw checkstyle:check) reported six errors in files this
PR touches: javax import order and two inline org.w3c.dom.Node in the
pagination test, and an inline java.util.Base64 in SignedMarkersTest.
The test now parses through XmlParser.parseDocument instead of its own
DocumentBuilderFactory. The switch statements in ListEntitiesForPolicy
and the test's holder fixture are switch expressions.
Tests: aMarkerEndingOnALongPolicyArnFitsTheModelAndResumesPastItsDeletion
attaches three policies under a 391-character path, pages with
MaxItems=1, deletes the anchor and resumes through the model check.
Constructing SignedMarkers without the limit fails it (610 characters);
restoring the pre-wave iam-request-shapes.json fails the table-driven
test (MaxItems=0 answered 500, MaxItems=1001 answered 200).
* fix(iam): bind a caller-resolved list's marker to the resolved user
ListAccessKeys, ListMFADevices, ListSSHPublicKeys, ListSigningCertificates
and ListServiceSpecificCredentials default an omitted UserName to the
caller. The marker was signed over the raw request members, so two users
in one account who both omitted UserName shared a scope and one's marker
resumed the other's listing. These handlers now page over the request
with UserName set to the resolved user, so the marker is bound to the
user the list was read for, named or implicit.
* fix(iam): bound the SignedMarkers digest map and trim the pagination test
SignedMarkers held every long cursor it had issued a digest for, in a map
that never shrank. It is now an access-ordered LinkedHashMap capped at
10,000 entries, the idiom CloudWatch Logs uses for its Insights queries. A
marker whose digest was evicted resolves to null, the same as an unknown
digest, so callers refuse it as an invalid marker.
IamListPaginationIntegrationTest spent most of its time in RestAssured's
per-request overhead on the hundred-item fixtures. Those creates and
deletes now go concurrently through java.net.http. The users and groups
default test keeps its first-page checks of the default of 100 and drops
the second page, which the roles default test and the every-operation test
already cover. The SSH public key fixture is generated once per run.
|
||
|
|
f926968167 |
fix(s3control): take TagResource and UntagResource tag condition keys from generated data (#6677)
The Service Authorization Reference lists aws:RequestTag/${TagKey} and
aws:TagKeys as condition keys for s3:TagResource, and aws:TagKeys for
s3:UntagResource. botocore's s3control model says where the request
carries them: TagResource's Tags list in the body, UntagResource's
TagKeys in the tagKeys query parameters.
With IAM enforcement on, Floci checked both S3 Control actions with no
request tag keys. A policy that allows TagResource only for certain tag
values, or UntagResource only for certain keys, matched no request, so
a request it allows was denied, and a ForAllValues condition on
aws:TagKeys allowed UntagResource whatever keys it named.
tools/aws/regen_s3control_tag_condition_keys.py now generates
s3control-tag-condition-keys.json from the two sources, as the DynamoDB
condition key table is generated: every s3 action the reference gives
either key, and every S3 Control operation's request members that feed
them, found as the tag-on-create table finds tag members.
IamConditionContextResolver reads it for a request on an S3 Control
route. The make targets check the members offline against the pinned
botocore in CI and the actions online against AWS in the IAM data drift
workflow. S3's own bucket and object tag keys stay as written, since
they were measured against AWS and do not all match the reference.
|
||
|
|
967e87d7f7 | fix(iam): set iam: condition keys from a table generated from the Service Reference (#6762) | ||
|
|
97ecbdd656 |
fix(iam): authorize S3 Control routes as their own s3 actions (#6681)
* fix(iam): authorize S3 Control routes as their own s3 actions S3 Control clients sign with the s3 scope, so under IAM enforcement its /v20180820 routes fell through to the S3 data-plane rules and were checked as s3:GetObject, PutObject or DeleteObject on a bucket named v20180820, which no policy can name: a role allowed s3:ListTagsForResource on a bucket was denied its tag list, and Terraform's AWS provider, which reads bucket tags through S3 Control, never fell back to GetBucketTagging, leaving aws_s3_bucket unrefreshable. Map the routes to the actions the Service Authorization Reference gives them: ListTagsForResource, TagResource and UntagResource are checked against the ARN the route names, as written and decoded as the handler decodes it; ListAccessPoints and the account-level Block Public Access, to which the S3 User Guide gives no resource, against every bucket in the request's partition; the account control takes the PutAccountPublicAccessBlock and GetAccountPublicAccessBlock actions. A data-plane operation under the same prefix keeps its own bucket-and-object ARN. A denial now answers in S3 Control's own ErrorResponse envelope, the only one the s3control SDK deserializers read, so the message naming the missing action survives to the client. Closes #6537 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(iam): answer the three control-route gaps the review found A tagging query on a control route still reached the data-plane override, so GET /v20180820/tags/<arn>?tagging was checked as s3:GetObjectTagging while the handler read the bucket's tags: the control rules now match before the query overrides, and a caller holding only the object action is denied where one holding the control action passes. A tagging ARN in the regional form was rewritten to the global form downstream and its bucket misread, so a policy naming the regional form the API reference requires was denied; the provider now keeps a control tagging ARN as written and reads the bucket it names. The account actions returned arn:<partition>:s3:::*, which a bucket-scoped statement matches; they now return the literal wildcard, so a bucket-scoped statement grants no account-wide action, the convention the KMS no-resource actions follow. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(iam): drive S3 Control route authorization from AWS's own data The s3control model is vendored in rest-routes.json, regen_rest_routes carries it under the s3 scope, as s3control signs with s3, and IamRestRouteCoverageTest checks every S3 Control route Floci serves against the Service Reference. The hand-written S3_CONTROL_RULES and S3_CONTROL_ACTIONS lists are gone: the control routes are entries of the one rules table, flagged to match before the S3 data-plane query overrides so ?tagging on a tagging route cannot re-point the authorization, and a denial answers in S3 Control's ErrorResponse envelope by following the route instead of an action-name list. The account-level Block Public Access is the one written-down exception, as the reference files S3's and S3 Control's Get, Put and DeletePublicAccessBlock under the bucket actions and the Block Public Access page gives the account level its own actions. A tagging ARN is read once, by the handler, the IAM check and the bucket-policy lookup together: S3ControlArnUtils decodes and parses it with AwsArnUtils.parse, and the regional form's account is the account whose bucket the request acts on, so a grant on arn:aws:s3:us-east-1:222222222222:bucket/reports no longer lets a caller in 111111111111 read and change the tags of its own same-named bucket: it reads and writes 222222222222's bucket, and answers NoSuchBucket when that account holds no bucket of the name. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(s3): read the policy provider's ARNs without decoding them The provider received every ARN already decoded, the data plane's from the request path and a control tagging one re-minted by the rule that read it off the wire, but the one-parse helper decoded again, so an object key carrying a plus sign or a literal percent sequence changed its bytes before IAM checked it: a policy on arn:aws:s3:::example/a+b.txt denied the very object it named. The provider parses without decoding now; the wire decode stays where it belongs, at the control request boundary. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> |
||
|
|
52c9c51a7b |
fix(dynamodb): enforce the default Select for IAM (#6702)
* fix(dynamodb): enforce effective read selection in IAM policies Preserve generated action and request-member coverage, effective read projections, PartiQL attributes and independent BatchGetItem contexts. Rebase on current main and scope condition data verification to its vendored file, generator, tests and imported modules, retaining all existing IAM data gates. Signed-off-by: Andre Kurait <akurait@amazon.com> * fix(dynamodb): derive transaction read conditions from modeled members Use the generated transaction Get member paths before GetItem IAM extraction, so ignored legacy projection members cannot authorize whole-item reads. Signed-off-by: Andre Kurait <akurait@amazon.com> --------- Signed-off-by: Andre Kurait <akurait@amazon.com> |
||
|
|
b0cd70401b |
feat(iam): check lambda:PassNetworkConnector from a table generated from the Service Reference (#6699)
* feat(lambdaweb): check lambda:PassNetworkConnector as AWS does A revision that sets egressNetworkConnectorArn needs lambda:PassNetworkConnector on the connector version ARN as given. Lambda checks it after the connector ARN checks and before it looks the connector up. A refusal names the first policy type that refuses, in the order identity policies, permissions boundary, session policy. An explicit deny in a managed policy or a boundary also names that policy's ARN. * fix(lambdaweb): apply service control policies to the account root when passing a connector * fix(lambdaweb): name the managed policy that denies a session token caller * feat(iam): check lambda:PassNetworkConnector from a generated table Move the check out of Lambda Web into the IAM enforcement filter, where iam:PassRole is checked. tools/aws/regen_iam_passed_network_connectors.py joins AWS's Service Reference and botocore's models into src/main/resources/aws/iam-passed-network-connectors.json, and the filter reads it for Web Functions, MicroVM images and MicroVMs. A MicroVM request that names no egress connector, or an empty list, passes the Lambda-managed INTERNET_EGRESS connector, and RunMicrovm with no ingress connector passes HTTP_INGRESS, as AWS checks them. AppSync's data source operations are listed too, but botocore's model has no member for their connector, so they are not read. The refusal text now comes from AccessDeniedMessages, which LambdaTaskAuthorizer and GetStackOutputRoleAuthorizer use as well. |
||
|
|
0410a2b4ea |
fix(iam): check PutEvents on each entry's event bus (#6704)
PutEvents was checked on `*`: the request-resources table gave it no resources, as its bus is a field of each entry, which no rule read. A policy allowing or denying events:PutEvents on one event bus therefore did not hold for publishing. Each entry's EventBusName is "the name or ARN of the event bus to receive the event", and "if you omit this, the default event bus is used". Bus policies grant events:PutEvents on `event-bus/<name>`. The EventBridge User Guide checks events:PutEvents against "the bus, once per entry in the request", and says "Publishing is authorized against the bus ARN for every entry in the request. If one entry fails an authorization condition, EventBridge denies the whole request." It says so in its section on the Custom Event Bus, which keeps the events: IAM namespace of the Classic one; nothing in the guide says otherwise for a Classic bus, whose API model lists AccessDeniedException among the error codes of an entry without saying when. The table now reads PutEvents' `Entries[].EventBusName`, a field of each of a list's structures, one resource for each entry: - The generator takes a correction filling a variable from such a field, and finds a field whose pattern takes an ARN before a name inside a list's structures, as it does a top-level member, so the field gets `arnOf` from botocore. - The loader reads `Name[].Field` in `fill`, and in `absent` and `arnOf` when it fills a variable. - The reader gives one value for each entry, the `absent` value for an entry that names no bus, gives a null or a blank, as the handler's `asText(null)` does, and none for no entries, which stay on `*`. Each value that is an ARN puts its own entry's bus in that ARN's account and Region, checked as given and as the caller's, which the handler publishes to; until now the first ARN a request gave set the account and Region of every value. The filter checks every resource, so one entry for a bus the caller may not publish to refuses the whole request, as the guide gives it. Not in this change: the events:source and events:detail-type condition keys (Floci supplies neither), EndpointId (the handler ignores it), and PutPartnerEvents, which stays on `*`. The upstream drift check on a pull request now verifies only the vendored IAM files the pull request changes, each with its generator, its tests and the modules that generator imports. It verified all six files whichever one a pull request touched, so this change, which touches only the table of the resources requests name, failed on the service namespace list, which AWS's index stopped matching when it dropped `codestar`: drift in a file the change leaves alone. The pull request's job passes the paths its merge commit changes to `make iam-data-verify CHANGED=...`, which names each check it skips; the weekly and manual runs, and a diff that cannot be read, still check every file, so the namespace list's drift is reported there. |
||
|
|
0ec28aee68 |
feat(iam): read a Query list's constraints from the model (#6625)
The Query walk the managed-policy family reads its constraints through read scalars only, and refused an operation whose input carries a list when the vendored file loaded. It reads a list now, and a structure, which is what the rest of this track is gated on: 34 of IAM's 180 operations carry a list or a map, and 6 of STS's 11 do. A list arrives numbered under its own name, Audience.member.1 or the bare Audience.1, and a member of a list of structures carries its fields under that prefix, as Tags.member.1.Key does. Each is named in a message the way this package already names one, filter.1.member and tags.1.member.key, under the index the request spelled rather than the position the member sits at, which is what #6478 settled. The count is held to the list's own bounds with the value left out of the message, which is the form checkListLength and the audience check both already answer: quoting it would echo every member of the list back. A list of no members is how an absent list arrives on this protocol, so a required one reads as null rather than as a list breaking a minimum of 1, and only a minimum above 1 is reachable at all. A structure member arrives as TaskPolicyArn.Arn and is named taskPolicyArn.arn, and a request naming none of its fields is a request without the member. GetAccountAuthorizationDetails is the operation this wave opts in, and the one where the model adds refusals rather than rewording an answer already given: the handler reads none of its three declared members, so a Filter outside the model's enum, a MaxItems outside 1 to 1000 and a Marker breaking its length or its pattern are all answered with a 200 today. They are a 400 ValidationError now, which is the ordering #6402 settled for this package. A map is still refused when the file loads, and so is anything nested deeper than a list of structures. The refusal is the point rather than a gap: this package answers a map against the whole map today, Map keys must satisfy constraint on PutAccountProperties, where the protocol numbers a map's entries as Properties.entry.N.key, and no source here says which of the two AWS answers. Reading one would reword a merged answer on the strength of a guess. The reader the walk needs went into AwsQueryLists rather than into a third copy. That file already reads a list's values, and StsQueryHandler holds a private copy that captures the prefix and the index for the same reason this one does; the STS wave is where that copy goes. A number too large for a long is a number all the same, which the range check reads as one now. It compared through a long before, so a MaxItems of 9223372036854775808 failed to parse, read as no number at all and reached the operation past a maximum of 1000. The bound it breaks is one that fits in a long either way, so the comparison carries no width of its own, and the value is written as the number reads rather than as the request spelled it, a leading plus or zero gone, which is what a parsed value already answered. Seven unit tests cover the new forms, two of them on the reader, which is where one of them found that a key naming its own member read as a member numbered after it: the index is a number or the key is not a member's. Four wire tests cover the operation. Removing the list branch fails four of the six list and structure tests and two of the four wire tests: the two that stay green are MaxItems and Marker, scalars the walk already read, so they prove the operation was opted in rather than the walk. |
||
|
|
d10db3ce9b |
feat(ecr): repository creation templates (#5955)
* feat(ecr): repository creation templates CreateRepositoryCreationTemplate, DescribeRepositoryCreationTemplates, UpdateRepositoryCreationTemplate and DeleteRepositoryCreationTemplate store templates per account and Region, keyed by prefix, with each field checked against the service model. An update replaces the fields it sets, and an empty string or list clears one. Templates are recorded, not applied, as nothing in Floci creates repositories through replication, pull through cache or create-on-push. Closes #5804 * refactor(ecr): check repository creation templates against the vendored model The four template actions join the registry settings in ecr-request-shapes.json, so the handler checks their requests against the ECR model's types, lengths, patterns and enums and answers in ECR's "failed to satisfy constraint" form. The handwritten copies of those rules go. What the model can't state stays in the service: appliedFor naming at least one value, and policy text being a JSON object. The model gives imageTagMutabilityExclusionFilters at least one entry, so an update sending an empty list is now refused rather than clearing the filters. Terraform omits the member when the filters are removed and moves to a mode without exclusions, so an update that leaves the template in such a mode now drops the filters. Before, they stayed, and every plan showed them again. * fix(ecr): lock creation template writes, share one JSON object check and fold a trailing slash Create, update and delete each read a template and then wrote it without a lock, so two creates of one prefix could both succeed and an update racing a delete wrote the deleted template back. They now take the registry lock the registry settings use. The template policies and the registry policy share one JSON object check that also refuses text after the object, such as {}{}. ECR assumes a / after every prefix, so prod and prod/ are now one template. The test helper imports Executable. * fix(ecr): describe each template once when prefixes differ only by a slash Describe removed duplicate prefixes before folding the trailing slash, so prefixes prod and prod/ returned the template twice, and with maxResults 1 a token followed by an empty page. It now removes duplicates by template key. The lock tests use the shared testing ParkingStore instead of their own copy. |
||
|
|
ec21cf38c7 |
feat(rds): DescribeCertificates, ModifyCertificates and an instance's CA certificate (#6106)
* feat(rds): DescribeCertificates, ModifyCertificates and an instance's CA certificate DescribeCertificates lists the Region's RDS certificate authorities with the thumbprint and validity AWS reports, vendored from the certificate bundles AWS publishes by tools/aws/regen_rds_ca_certificates.py, and pages them. ModifyCertificates sets or removes the account's default for new instances. CreateDBInstance, ModifyDBInstance, the two instance restores and CreateDBInstanceReadReplica take CACertificateIdentifier, and instances report it with CertificateDetails. AWS::RDS::DBInstance takes the property and resolves the two CertificateDetails attributes. The identifier is metadata: the auth proxy keeps presenting Floci's own CA. Closes #5806 * fix(rds): follow the user guide on CAs and leave a blank CA alone - An instance stored without a CA reports rds-ca-rsa2048-g1, since an override applies only to instances created after it. - ap-south-1, ap-southeast-4, ca-west-1, eu-central-2, eu-south-2 and il-central-1 offer only rds-ca-rsa2048-g1, as the user guide says. - A blank CACertificateIdentifier on modify leaves the instance's CA. - --download skips a Region only on 403 or 404 and exits 1 on other failures. - Reuse regionFromArn, add a createDbInstance stub helper and import Executable in the tests. |
||
|
|
ad92d5f2c1 | fix(ecr): validate scanning batch repository names (#6587) | ||
|
|
bb48983b9c |
feat(iam): read the managed-policy family's constraints from the model (#6580)
The declared constraints on IAM's managed-policy operations are read from the pinned model rather than from a hand-written check, through the vendored data tools/aws/regen_iam_shapes.py generates and a Query walk of it. Twelve operations go first: GetPolicy, DeletePolicy, the four policy-version operations, and the six attach and detach pairs. The vendored file carries that wave rather than all 180 operations, as the ECR and Resource Groups files carry theirs, and grows a wave at a time. The machinery was already here for the JSON protocols. request_shapes build_constraints vendors required members, lengths, patterns and enums; RequestConstraintCheck walks a JSON body against them; SmithyValidationErrors already writes the awsQuery wording. What was missing is the walk a Query request needs, which is why QueryConstraintCheck sits beside RequestConstraintCheck rather than inside it: a JSON body arrives as a tree, where a Query request arrives as flat parameters named after the members that carry them, and the violations are collected into one "N validation errors detected" message in the model's member order instead of the first one being thrown. A test sends two broken members in the opposite order to the model's and gets the model's order back, so the ordering is the model's rather than the wire's. What changes for a caller is the status, in the direction #6402 settled for this package: a PolicyArn under arnType's 20 characters, a VersionId outside policyVersionIdType's pattern or an absent required member used to reach the store and answer NoSuchEntity 404, where AWS's validation layer runs ahead of the operation and answers ValidationError 400. AttachRolePolicy's RoleName is the parity case for every value but one: IamService.validateRoleName already answered it from the same bounds and the same pattern, and for a name outside its pattern the message is unchanged by the model taking it over, which a test pins. An empty name is that one value, and the one place the wording moves rather than the status. validateRoleName stops at the first constraint an empty name breaks and reports the minimum alone, where the model also reports the pattern it breaks, so these twelve operations answer two violations where they answered one. That is the reading #6402 merged for a value breaking two of its constraints, and it makes validateRoleName the drift rather than the reference. The operations still on the hand-written check keep the single violation until a later wave takes them over, which a test holds still on CreateRole so that the wave which does has to settle the wording first. Two answers are the package's own rather than new. A member breaking two constraints is reported twice, which is what #6402 merged for a ServiceSpecificCredentialId that breaks both its length and its pattern, so an empty PolicyDocument reports its minimum and its pattern. The offending value stays quoted, as SmithyValidationErrors and validateRoleName already quote it; whether current IAM quotes it at all is an open question, and reading the constraints in one place is what would make that one helper to change rather than every message in the package. Scalars only so far. An operation whose input shape carries a list or a map is refused when the vendored file loads rather than passed over with its constraints unread, since reading one means reading Name.member.N and Name.entry.N.key and naming each index as the request spelled it. A boolean is declared and holds no constraint to be read against, so a SetAsDefault that is neither true nor false still reaches the operation, which reads anything but true as false. A test pins that rather than changing it, since what AWS answers for a malformed boolean is unrecorded here. |
||
|
|
c5e873ff84 |
fix(iam): check ARNs inside structures and EventBridge's resources (#6561)
The table of request resources read only top-level members, so an
operation naming its resource inside a structure was checked on *:
SetRulePriorities' RulePriorities[].RuleArn and a state machine alias's
routingConfiguration[].stateMachineVersionArn. A member ending in Arn or
Arns one level inside a structure, or inside each of a list's
structures, now names a resource as a top-level one does, the value's
format deciding which of the action's types it is. Such a member never
fills a variable, holds a type or names a create's parent. A form's list
is read to the first element without the field, as the ELB handler
loops.
EventBridge joins the table (71 operations). Its rules are named by the
rule's name on the event bus EventBusName names, by name or by ARN, and
on the default bus when it names none ("If you omit this, the default
event bus is used"), whose rules are rule/<name>, with no bus.
Corrections give the eight rule operations the default bus's rule when
EventBusName is default or absent, and the custom bus's otherwise, with
two new keys: unless, the complement of when, and absent, the value a
missing member is read as. DescribeEventBus naming no bus is checked on
event-bus/default ("If you omit this, the default event bus is
displayed"). A member whose botocore pattern takes an ARN before a name,
(arn:...:event-bus/)?<name>, is recorded as arnOf: an ARN given for it
is read as that type's one variable, and the resource is in the ARN's
account and Region, so a bus of another account, its default bus
included, names that account's rule, as DescribeRule's CreatedBy says,
checked as given and as the caller's own, which Floci acts on. An ARN
leaving its account and Region empty, which EventBridge's handler takes
as the caller's bus of that name, names the caller's, and a JSON null
for a member read as a value when absent is absent too, as the handler's
asText(null) reads it, so a null EventBusName is the default bus.
EventBridge V2's client, AWSEventsV2 over Smithy RPC v2 CBOR, which
Floci does not serve, shares the operations' names and is left out
(clientsNotRead), and verify ignores it.
EventBridge mints a connection's ARN as connection/<name>/<id> and an
API destination's as api-destination/<name>/<id>, as botocore's ARN
patterns give them, and checks a connection on it (the user guide grants
events:RetrieveConnectionCredentials on connection/<name>/*), while the
Service Reference's formats stop at the name. MINTED_IDS records those
types (mintedIds), and a request naming one by its name is checked on
the ARN its service stores it under, which a StoredResourceArns the
service registers finds for the caller in the request's Region
(EventBridgeService does), or on <name>/* when there is none yet, a
create's included.
Not in this change: PutEvents, whose entries each name their bus, stays
on *, and UpdateEventBus with no Name, which no document says is the
default bus, stays on * too.
|
||
|
|
932af22f4a |
fix(iam): check requests on the resources they name (#6511)
Under IAM enforcement a request is checked against the resources it acts on. ResourceArnBuilder builds their ARNs by hand for 17 namespaces; every other request was checked on *, so a grant scoped to a resource was refused and a deny scoped to one never applied. AWS's Service Reference lists the resource types each action acts on and each type's ARN formats, but not which request member names a resource; botocore's models give the members. A new generator, tools/aws/regen_iam_request_resources.py, joins the two into src/main/resources/aws/iam-request-resources.json: for each operation, the action it is checked as, that action's resource types and the resources its request names, by a member holding a resource's ARN or by members filling the variables of a type's format, matched by name. A variable nothing fills is left open, as a service mints a new resource's id; a type nothing names is not checked, as an action lists the optional resources its requests may use; and types named only through the same members are alternatives, of which the one named in full is kept. Corrections give a v2 CreateLoadBalancer the load balancer of its Type, application when it gives none (a Type outside application, network and gateway is now refused, as AWS refuses it, rather than read as an application load balancer the table does not name), and read StartExecution's and StartSyncExecution's stateMachineArn up to a #, as Floci runs the machine before Step Functions Local's test case. A state machine's version or alias, stateMachine:<name>:<qualifier>, is checked on the state machine's ARN, as Step Functions authorizes it, so an execution started through one is the state machine's too. RequestResources reads them from a JSON or CBOR body or a Query form, for the namespaces the table reads, and ResourceArnBuilder uses them where it has no branch. They are read for the operation the request is dispatched as, which IamEnforcementFilter resolves and checks the action of (the Query action, the JSON target or the Smithy RPC v2 path's operation), never for an X-Amz-Target or Action the request names again, and as the handlers read them: a list only from a list, a number or a null as its text. A member whose botocore shape is an account id gives the account of the types named by variables: ECR's registryId selects the registry its handler acts in, and a JSON null is no registry, the caller's, as ECR reads it. ECR's BatchGetRepositoryScanningConfiguration, whose AWS request has no registryId, no longer reads one: it acts in the caller's registry, where IAM checks it. An ARN value counts when it matches the format of a type the action acts on; one naming another account or Region is checked as given and as each resource of that name a handler may act on instead, in its account or the caller's and its Region or the request's (ECR's tag handlers keep the ARN's account in the request's Region). A request naming none, or whose action acts on no resource type, stays on *, as AWS checks it. A create's tagging action is checked on the same resources, except where the create makes a resource under a parent its action acts on: CreateListener acts on a load balancer and CreateRule on a listener, and their tags are checked on the new listener or rule, built from the parent's ARN with the type word replaced and its own id open. The table gives these from the formats: a child type's is its parent's with one id appended. So the AWS Load Balancer Controller's policy, which allows AddTags at creation only on target groups and application and network load balancers, and on listeners and rules, now holds. The first namespaces read are Elastic Load Balancing, ECR, Step Functions and Cognito user pools (298 operations); the 99 others Floci serves are listed as not read yet, with their reason, and RequestResourceNamespacesIntegrationTest fails for a served namespace in none of the lists. make iam-request-resources-check, part of aws-data-check, re-derives every operation from the pinned botocore; make iam-request-resources-verify, part of iam-data-verify, checks the actions, types and formats against AWS, and the IAM data drift workflow also runs on a change to the table or its generator. Not in this change: the 99 other namespaces, Query lists other than Name.member.N, identifiers inside structures (SetRulePriorities, CreateStateMachineAlias' routing configuration) and EventBridge. |
||
|
|
bab7af3a21 |
fix(apigateway): return a usage plan's API stages, throttle and quota (#6360)
* fix(apigateway): return a usage plan's API stages, throttle and quota * fix(apigateway): refuse a usage plan create whose text or number member is a list, map or wrong scalar * fix(apigateway): refuse an unknown usage plan quota period before any other create check * fix(apigateway): check a usage plan create body against API Gateway's vendored request shapes * fix(apigateway): read a usage plan create body the way API Gateway does * fix(apigateway): truncate a usage plan's integer limits without a double rounding * refactor(apigateway): reuse SmithyValidationErrors and a shared request shape lookup |
||
|
|
64f4f9e489 |
fix(iam): check a create's tags on its own and its tagging action (#6452)
Under IAM enforcement a request that tags the resource it creates was checked only for the operation's own action. AWS also checks the service's tagging action, as the SNS API reference says: "To be able to tag a topic on creation, you must have the sns:CreateTopic and sns:TagResource permissions." A caller allowed to create but not to tag could set at creation the tags that a tag-based policy trusts. The operation's own action did not see the tags either: aws:RequestTag and aws:TagKeys were set only for Logs, S3 and EC2 RunInstances, so a policy allowing sqs:CreateQueue only with aws:RequestTag/team never matched, and one denying it when aws:RequestTag/team is null refused a tagged create. AWS's Service Reference lists the tagging action among each operation's authorized actions and marks the actions that only tag, but does not say which request member carries the tags; botocore's models do. A new generator, tools/aws/regen_iam_tag_on_create.py, joins the two into src/main/resources/aws/iam-tag-on-create.json: 581 operations over 69 namespaces, those Floci authorizes by operation. An operation is in it when the reference lists, beside its own, an action that only tags and adds tags; its tags are read from a top-level member named Tags, TagList, TagSpecifications or the like that holds a tag list or map. 569 are read from the table (579 members), CloudWatch Logs CreateLogGroup is checked by hand as before, and 11 carry no tags this file can read, each with its reason. A correction gives SQS's Query name, Tag.N, and one drops an EC2 IPAM pool's allocation rule, which tags nothing. When a request carries tags, IamEnforcementFilter checks the tagging action for each resource's tags apart, with them as aws:RequestTag/<key> and aws:TagKeys, and, where the action takes it, the operation as its namespace's CreateAction key (ec2:CreateAction is RunInstances for an instance launched with tags). A tag specification's tags are checked on the resource of the type it names, from the ARN the reference gives the type with its name left open (arn:aws:ec2:<Region>:<account>:instance/*), which the table carries for EC2 and RDS; other tags on the resources the operation is checked on. Lambda's CreateFunction is now checked on the function its body names, which the reference gives it, rather than on *, so a grant scoped to the function covers both its action and its tags. The operation's own action is checked with the same two keys, once for each resource's tags, where the reference lists them for it or for a resource it acts on (542 of the 569), keeping any a service's own condition keys set. The table is keyed by operation, so the filter now carries the operation it resolved beside the action, which differs for an operation AWS authorizes under another name (Budgets' CreateBudget is budgets:ModifyBudget). The tags are read as the Floci handler that applies them reads them, so the check sees the tags the resource gets. A form's are read under the SDK's spelling, from 1 to the first number with no key, and under the further spellings the RDS, DocumentDB, Neptune, ElastiCache and Redshift handlers read, numbered as each numbers them; EC2's from every tag specification under either TagSpecification spelling, to the first naming no resource type. A body's member is read under its own name, and CloudWatch's PutMetricAlarm and PutCompositeAlarm also under tags, and a CodeDeploy tag as Key and Value or key and value, each as text whatever it holds, as its handler reads. The tagging action is also checked for tags under any other spelling a handler might read (a name, key or value in any case, any list spelling and number, an object's structures), so none a handler applies goes unchecked. The operation's own action is checked with every reading, its handler's, any other spelling's, and none where its handler reads none, and refused if any is denied, so a deny on a tag holds and a required tag counts only where the handler applies it. make iam-tag-on-create-check, part of aws-data-check, re-derives every member from the pinned botocore; make iam-tag-on-create-verify, part of iam-data-verify, checks every operation against AWS, and the IAM data drift workflow also runs on a change to the table or its generator. Not checked: sts:TagSession in a role's trust policy, service-specific request tag keys such as rds:req-tag, EC2 RequestSpotFleet's nested tags, and the REST services whose routes no rule maps yet. |
||
|
|
b36fd2f0be |
fix(iam): authorize Budgets operations as ModifyBudget and ViewBudget (#6436)
Under IAM enforcement a Budgets operation other than a budget action was authorized as its own name, budgets:CreateBudget and the like, which is no IAM action. A policy granting budgets:ModifyBudget was denied CreateBudget, and one granting budgets:ViewBudget was denied DescribeBudgets, while a policy naming the operation, which grants nothing on AWS, let it through. AWS's Service Reference authorizes these operations as budgets:ModifyBudget or budgets:ViewBudget. Beside that action it lists the aws-portal Billing console permissions and, for CreateBudget, the tag-on-create budgets:TagResource, so the authorized-action generator counted two or three actions and left them out. It now counts neither: the aws-portal actions gate the Billing console, and the Billing and Cost Management user guide says programmatic requests to AWS Budgets are not affected by them; a namespace's tagging action beside exactly one other is the tag-on-create permission. That adds the 15 Budgets operations and IoT FleetWise BatchCreateVehicle, which Floci does not serve, to the vendored map. Not checked: budgets:TagResource when CreateBudget or CreateBudgetAction carries tags. |
||
|
|
1276a8857f |
fix(iam): check iam:PassRole from a table generated from the Service Reference (#6422)
Under IAM enforcement a request that names a role is checked for iam:PassRole only where PassedRoles has a case for its operation, so most of the operations AWS's Service Reference lists with iam:PassRole went through without it: a caller allowed to create a CodeBuild project, a Firehose stream, a Glue job or an SSM association could hand it any role in the account. Adding a case per operation took one pull request per few services. The Service Reference names, for each operation, the services its role goes to, but not the request member that names it; botocore's models give the members. tools/aws/regen_iam_passed_roles.py joins the two into src/main/resources/aws/iam-passed-roles.json: every operation listing iam:PassRole in the namespaces Floci serves over JSON, Query and Smithy RPC v2 CBOR, and in the REST services whose routes are authorized as operations, each either read from the table, read by hand in PassedRoles, or not read with a reason. Generation fails on an operation in none of the three. A member names a role when its name ends in Role, RoleArn or RoleName (a plural, or one followed by Update or Override) and it holds a string or a list or map of them, not an enum. A member whose documentation says it takes a role by name is checked on the ARN IAM holds the role under. A role the Service Reference passes to no named service, as it does Cognito's, is checked with no iam:PassedToService. The generator records its corrections with their reasons: members that pass no role (the roles a Budgets action attaches a policy to, a CodePipeline action's role, which the pipeline's role assumes, SSM target accounts' execution roles, the roles a Glue job's generated nodes assume with STS, Firehose's Snowflake role), members the rule does not see (a Cognito user pool's SMS caller roles, a Glue connection's ROLE_ARN property and a view's definer, Service Catalog's AssumeRole and LAUNCH_ROLE keys), and which service a member's role goes to where the reference names several. PassedRoles reads a table member from a JSON or CBOR body, or from Query form parameters in either list form. Its own cases now return null for an operation they do not read, and the table covers the rest. New cases read SNS's role attributes (a topic's delivery status roles, a platform application's, a Firehose subscription's and the SMS one, as the SNS handlers read the map; an attribute with no value names none), a CloudWatch Logs subscription filter policy's RoleArn, a Service Catalog launch constraint's role, by the type Service Catalog holds for the constraint on an update and in any case, since Floci keeps the type as given, and an SWF decision's Lambda role from the attributes its type names. Not read: requests that name no role, roles that are a runbook's parameter, operations whose roles go to several services without the reference saying which member goes where (EMR RunJobFlow, EKS UpdateClusterConfig, CloudWatch Logs CreateImportTask, SageMaker CreateTrainingSession), XML bodies (S3 PutBucketReplication), EC2's RequestSpotFleet, and REST services whose routes no rule maps yet. make iam-passed-roles-check, part of aws-data-check, re-derives every member from the pinned botocore; make iam-passed-roles-verify, part of iam-data-verify, checks every operation against AWS; the IAM data drift workflow now also runs on a change to the table or its generator. PassedRoleNamespacesIntegrationTest fails for a namespace Floci serves that the table neither reads nor names as not read yet. |
||
|
|
15de90c3ff |
feat(stepfunctions): add the emr-serverless optimized integrations (#6386)
A Task can now use the six optimized EMR Serverless integrations the
Step Functions guide lists: createApplication, startApplication,
stopApplication, deleteApplication, startJobRun and cancelJobRun, each
request-response and .sync. Each calls Floci's EMR Serverless in the
state machine's Region. They failed with "Unsupported resource" before.
A Task names the API's members in PascalCase where the API writes them
in camelCase, so a request and a response are mapped against botocore's
EMR Serverless model, now vendored as aws/emr-serverless-shapes.json by
tools/aws/regen_emr_serverless_shapes.py: a structure's members are
renamed, a map keeps the keys the state machine wrote (tags,
InitialCapacity's DRIVER, a configuration's Properties such as
spark.executor.memory), and a member the model does not have is
dropped. A member, ApplicationId and JobRunId included, may be written
in either case. One the model has and Floci's request class lacks is
refused rather than dropped, and a test holds the classes to the model.
request_shapes.py can now keep output shapes for it. A request
without ClientToken gets a random one, as the SDK fills an idempotency
token in; the guide's examples leave it out.
The result is the API's response in PascalCase, or {"ApplicationId"}
where the API answers nothing, as the guide's table says. The guide
finds no difference between a .sync response and the API's, so a .sync
result is the starting call's own: state machines read a
createApplication.sync result's ApplicationId and a startJobRun.sync
result's JobRunId. A .sync Task records TaskSubmitted and polls
GetApplication or GetJobRun until the state the guide names, as the
elasticmapreduce ones do; a run that ends FAILED or CANCELLED, or an
application that can no longer get there, fails the Task with
States.TaskFailed and the describe response as the cause. A wait that
ends early cancels the run of a startJobRun.sync, stops the application
of a startApplication.sync and deletes the one a createApplication.sync
made, the call each integration's IAM policy grants beyond its own and
its read. EMR Serverless answering that the application or run is gone
or past undoing is logged and leaves the Task ending as it was; any
other failure is raised.
An EMR Serverless error keeps its code under EmrServerless., the
exception prefix the guide gives the service; no record shows the
optimized integration's. A Task without the ApplicationId, or a
cancelJobRun without the JobRunId, it acts on fails with
States.TaskFailed before EMR Serverless sees it.
CreateApplication now stores the configurations UpdateApplication
already did (runtime, monitoring, scheduler, disk encryption,
interactive, Identity Center and job-level cost allocation), and
ImageConfiguration keeps applicationLevelDigestResolution. Both were
dropped, from a Task and from the API alike. A runtime configuration
kept only its properties, lifted out of their member: Jackson bound the
properties member to the field of that name holding every member read.
It keeps its classification and properties now, on update as well.
GetApplication no longer returns the application's clientToken, which
its Application has no member for and which the .sync waits read. The
token stays with the stored application, which CreateApplication's
retries are matched on.
The .sync wait loop the elasticmapreduce integrations had is now shared
by both, as are their request and failure helpers, and the two EMR
Step Functions tests share their state machine helpers.
Part of #6046 (part 11).
|
||
|
|
ec5597eb5c |
fix(iam): check EKS's REST routes and roles, and routes with a trailing slash (#6323)
Under IAM enforcement a REST request whose route no rule maps is let through unchecked. No EKS
route had a rule, so any signed caller could create, read, change or delete clusters, node groups,
Fargate profiles, add-ons, access entries and Pod Identity associations with no EKS permission, and
without iam:PassRole on the roles they named. A Pod Identity association hands its service
account's pods the credentials of its role, so a caller could have pods run as any role in the
account.
Every operation of the eks model now has a rule and is checked as the action of its own name, as
the Service Authorization Reference gives it, including the routes Floci does not serve yet, and
IamRestRouteCoverageTest checks the whole model. Floci takes an access entry's principal as the
rest of the path, so a GET or DELETE under an entry reads or deletes an entry: the entry's access
policy routes, which Floci does not serve, run as DescribeAccessEntry and DeleteAccessEntry and are
checked as those.
Each is checked against the resource the reference gives it, in the caller's account, where EKS
looks everything up:
- a cluster against the ARN EKS holds it under, or cluster/<name> in the request's Region for one
it holds none of, and CreateCluster against the cluster its body names, as the EKS user guide's
example policy for creating a cluster grants it;
- a node group, Fargate profile, add-on, access entry or Pod Identity association against the ARN
EKS holds it under, which ends in an id the request does not carry, read through
EksService.findResourceArn with the lookups its handlers make; listing and creating them, and the
other routes under a cluster, against the cluster;
- DescribeUpdate against the add-on the update was made to, since the updates Floci keeps are its
add-ons' and EKS returns one whether or not the request names its add-on, and otherwise the
cluster;
- a tagging request against the caller's cluster named after the ARN's last /, as EKS tags it.
The roles each operation passes need iam:PassRole, with iam:PassedToService the value the Service
Reference gives: the cluster role, node role, Fargate pod execution role and an add-on's service
account and Pod Identity roles go to eks.amazonaws.com, a Pod Identity association's roleArn to
pods.eks.amazonaws.com ("The IAM principal that is creating the association must have
iam:PassRole."), and an EC2_LINUX or EC2_WINDOWS access entry's principal to ec2.amazonaws.com.
The router also matches a path with a trailing slash as the path without it, while the rules
matched the slash: POST /clusters/, GET /schedules/ and GET /2015-03-31/functions/<name>/ reached
their operation unchecked. A route is now matched without its trailing slash, as the router
matches it. An S3 path is matched as sent, as before: an S3 key may end in a slash, as a folder
marker's does, and S3's rules already take a bucket's one trailing slash.
docs/services/iam.md says which EKS routes are mapped, what each is checked against and the roles
they pass.
|
||
|
|
3944d6edc2 |
fix(dsql): enforce IAM and the cluster's policy on the control plane (#6328)
* fix(dsql): enforce IAM and the cluster's policy on the control plane
A cluster's resource-based policy governs DSQL's control plane as well as
its connections (measured, eu-west-1): a Deny of dsql:GetCluster,
UpdateCluster, TagResource or GetVpcEndpointServiceName refuses that call,
and a call it does not name still answers. With IAM enforcement on, Floci
left every DSQL control plane route unchecked: no rule in
IamActionRegistry mapped one, so the policies, identity or resource, were
never read there.
IamActionRegistry maps every operation of DSQL's model to its action, the
stream operations Floci does not serve included, and
IamRestRouteCoverageTest now checks all of them against botocore's routes,
vendored for DSQL by regen_rest_routes.py. ResourceArnBuilder names the
resource each call is checked against, as the Service Authorization
Reference gives it: the cluster, the stream, or the ARN a tagging route
names, minted in the request's partition. CreateCluster and ListClusters
are checked against cluster/*, as DSQL checks them (measured; the
reference lists ListClusters with no resource). The enforcement filter
then reads the cluster's policy through DsqlResourcePolicyProvider, as it
reads a topic's or a function's.
* fix(dsql): check tagging at /tags too, where the ARN is in the query or body
Asked in review: Floci serves DSQL's tagging at /tags as well as at
/tags/{arn}, naming the ARN in the resourceArn query parameter or body field,
and the rules matched only the path form, so a bare /tags call reached DSQL's
tag handler unchecked. The rules now match both, as Scheduler's do, and the
control plane test tags, lists and untags through each form.
|
||
|
|
29384867cf |
fix(iam): check the Lambda MicroVM and network connector routes (#6122)
Under IAM enforcement no Lambda MicroVM or network connector route was mapped to an IAM action, so every call went unchecked, and the roles they take with it. - Every MicroVM route (2025-09-09) and network connector route (2026-04-04) is mapped, and IamRestRouteCoverageTest now checks every operation of both models. An image or connector request is checked against microvm-image:<name> or network-connector:<id> in the request's account and Region, an identifier given as an ARN taken for its name, as the service looks it up. RunMicrovm is checked against the image its imageIdentifier names, an action on a running MicroVM against the image it runs, and a managed image's versions against that image, which aws owns. Creating an image or a connector and the list operations name no resource, so they are checked against *. - Lambda's own tag routes, /2017-03-31/tags/<arn>, which MicroVM images share with functions, are mapped and checked against the resource they tag: the caller's own function, image or connector of the ARN's Region and name, whatever account the ARN names, as Lambda looks it up, a target without the arn: prefix read as the MicroVM tag handler reads it, and an event source mapping's ARN as written. - iam:PassRole, to lambda.amazonaws.com as the Service Reference gives: CreateMicrovmImage and UpdateMicrovmImage (buildRoleArn), RunMicrovm (executionRoleArn), and CreateNetworkConnector and UpdateNetworkConnector (OperatorRole). This finishes the Lambda half of the follow-up on #5938. |
||
|
|
77c5d74a7d |
fix(iam): check the EventBridge Scheduler and Pipes routes (#6044)
Under IAM enforcement no Scheduler or Pipes route was mapped to an IAM action, so every call to either went unchecked, and the roles they take with it. - Every Scheduler and Pipes route is mapped, tagging at /tags as well as /tags/<arn>, and IamRestRouteCoverageTest now checks every operation of both models. Each request is checked against the resource the Service Reference gives: schedule/<group>/<name>, the group read where Scheduler reads it (the body's GroupName on a create or an update, groupName otherwise, else default), schedule-group/<name>, pipe/<name>, the ARN a tagging route names, and * where the request names none. Scheduler and Pipes ARNs are minted in the request's partition, as those services mint theirs. - SchedulerController joins the Scheduler descriptor, so a schedule request is checked as Scheduler whatever scope signs it. Otherwise one signed for another service was checked by that service's rules. - The shared tagging routes, /tags and /v1/tags, hand a request to the service its ARN names, so it is checked as that service, against the ARN the controller acts on: the body's resourceArn on POST /tags, the query's on the other bare routes. Otherwise a Pipes grant could tag a schedule group, a scope with no tagging rule went unchecked, and a query ARN could stand in for the body's. - iam:PassRole: CreateSchedule and UpdateSchedule pass the target's RoleArn to scheduler.amazonaws.com, and CreatePipe and UpdatePipe their RoleArn to pipes.amazonaws.com, as the Scheduler user guide's example policies and the EventBridge user guide say. |
||
|
|
95bf6df474 |
feat(dsql): add Aurora DSQL's control plane and AWS::DSQL::Cluster (#6048)
* feat(dsql): add Aurora DSQL's control plane and AWS::DSQL::Cluster The first half of #6014. Aurora DSQL's REST JSON control plane, with the answers measured on AWS (eu-west-1): CreateCluster, GetCluster, ListClusters, UpdateCluster, DeleteCluster, GetVpcEndpointServiceName, the cluster policy calls and tagging on cluster ARNs. Identifiers are 26 characters of lowercase base32 as DSQL's are, and malformed or unknown ones are refused with DSQL's messages; a cluster created without deletionProtectionEnabled is protected, and deleting a protected one is refused. CreateCluster answers CREATING and the cluster is ACTIVE right after. AWS::DSQL::Cluster waits for ACTIVE, returns the identifier from Ref and Identifier, ResourceArn, Status, CreationTime, Endpoint, VpcEndpoint and VpcEndpointServiceName through Fn::GetAtt, and a protected cluster makes the stack's deletion fail, as on AWS. A cluster has no database behind it here: its endpoint is named as on AWS, <id>.dsql.<region>.localhost.floci.io, but not served. Serving it is the second half of #6014, its own pull request. * fix(dsql): answer the control plane's edge cases as DSQL does Review of #6048, each answer measured on DSQL (eu-west-1) first: - ListClusters carries on from a page token whose cluster was deleted in between, as AWS does: the token now holds the sort position of the next page's first cluster rather than its identifier. - deletionProtectionEnabled is read as DSQL reads it: text is false when it spells false in any case and true otherwise; empty text, a number, an object and a list fail with SerializationException. - The tag calls refuse another account's cluster ARN with 403 AccessDeniedException instead of reading it in the caller's account. - A client token reused with other parameters answers 409 ConflictException; with the same ones, the earlier cluster. - AWS_OWNED_KMS_KEY names AWS's own key on create and update. AWS::DSQL::Cluster reads DeletionProtectionEnabled and PolicyDocument with AWS::NoValue as left out, and an update that drops the multi-Region properties clears them, as it already reset the key and deletion protection. ListTagsForResource copies the tags under the cluster's lock, and a cluster's lock goes with the cluster. * fix(dsql): answer errors, policies, updates and multi-Region clusters as DSQL does A review asked for the attribute coverage, the reason ValidationException carries, a real untag assertion and tests of the stack-update path. Measuring them on DSQL (eu-west-1, 2026-10-20) found more that did not match, fixed here too. - Attributes are written with resource.getAttributes().put, which the schema coverage test reads; EncryptionDetails, an object an output refuses on AWS, is recorded as a gap. - DSQL leaves reason out of its model-validation errors. Only the page token's refusal carries it, with fieldList naming next-token and its own text. maxResults no longer quotes the value. - Tag calls answer what DSQL answers: 403 for an ARN that is not a cluster ARN, 400 BadRequestException for another Region's, 404 NotFoundException for no cluster. The 403s name the caller. - Policy versions are epoch milliseconds, DeleteClusterPolicy answers the deleted version, and the missing-policy and stale-version errors carry DSQL's texts and resourceType. - Policies are checked and kept as DSQL does: its three refusal texts, a service principal, a principal that names no one, a public grant, and the lockout check when both policy actions are denied to the caller, unless bypassPolicyLockoutSafetyCheck. The kept form is Jackson's pretty printer in DSQL's element order, with condition operators and keys in HashMap order, as measured. - The public check shares its condition keys with Lambda web functions through PublicAccessConditions, and S3 now takes its fixed-value and SourceIp range tests from there. Sharing the whole rule was tried and dropped: DSQL was measured to treat some operators otherwise than LambdaWeb's and S3's rules do (ForAnyValue:, ArnLike "*", StringEquals "*"), so the operator rules stay per service. The lockout check is IamPolicyEvaluator's. - A multi-Region cluster is PENDING_SETUP and lists itself until it and each peer name one another, then ACTIVE; its deletion answers PENDING_DELETE. - AWS::DSQL::Cluster reads its properties through CfnPropertyTypes, so a PolicyDocument object or DeletionProtectionEnabled "yes" fails as on AWS, where Boolean.valueOf made "yes" false. An update leaves a property the template no longer sets as it was, deletion protection, KMS key and multi-Region alike, and removes only the tags and the policy; an earlier change put them back to their defaults, which was not measured and is not what CloudFormation does. A policy the template does not change keeps its version, and create settles on PENDING_SETUP too. DsqlServiceTest, DsqlClusterPoliciesTest and DsqlCfnProvisionerTest cover these in isolation, the integration tests over the wire. * fix(dsql): keep the public access rule to DSQL and forget a deleted policy's version A review asked to leave S3 and Lambda web functions out of this change, and pointed at DSQL's own block public access page. The shared helper is dropped and S3 and Lambda web functions are as on main; folding their copies into one helper belongs to a separate change. DSQL now has its own keys: the trusted ones its page lists, and aws:SourceIp, aws:SourceVpcArn and the three aws:Vpce* keys, which the page leaves out but DSQL accepts (measured, eu-west-1, 2026-10-20). As the page says, a policy variable never restricts: StringEquals with ${aws:PrincipalArn}, ${aws:SourceVpc} or a role/${aws:username} ARN is public on DSQL. ArnEquals reads like ArnLike, as IAM matches both the same way, so a value that is no ARN, ${aws:SourceArn} among them, matches nothing and restricts, as measured. DeleteClusterPolicy left the deleted version on the cluster, so a put naming it went through; it is now cleared, and a put that names a version on a cluster with no policy is refused as not found. |
||
|
|
d09b3215d5 |
fix(cloudformation): carry EC2 MetadataOptions from templates and instances (#6050)
* fix(cloudformation): carry EC2 MetadataOptions from templates and instances AWS::EC2::LaunchTemplate dropped LaunchTemplateData.MetadataOptions, and AWS::EC2::Instance read only the image, type and key from its launch template and ignored its own MetadataOptions. A CDK instance with requireImdsv2 therefore launched with HttpTokens=optional, and DescribeInstances reported that whatever the template declared. The template now stores the block, the instance launches with its own options over its template's, and an update that changes them applies them in place with ModifyInstanceMetadataOptions, as the property's "No interruption" update behavior allows. A hop limit that is not an integer fails the resource. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): check MetadataOptions first and reset dropped ones An update that keeps an AWS::EC2::Instance applied its MetadataOptions last, after resizing it and rewriting its security groups, user data and profile, so a bad value failed the update with the instance half changed while the stack reported a rollback. The options are now checked with EC2's own rules before anything changes, which needs Ec2Service.validateMetadataOptions to be public. An update that stopped declaring an option, its own or through its launch template (CDK's requireImdsv2 turned off), left the instance with it. The provisioner now records what it declared and returns an option it no longer declares to the launch default, as it already does for an instance profile it stops declaring. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): replace an instance whose launch template changes LaunchTemplate is a replacement property of AWS::EC2::Instance, and Floci's change-set preview already says so, but an update kept the instance whatever happened to it: removing the template (CDK's requireImdsv2 turned off) reset the instance's options in place where AWS launches a new instance. The provisioner now records which template it declared and replaces the instance when the update names another one, adds one or drops it. A new version of the same template is still applied in place, because Floci's AWS::EC2::LaunchTemplate publishes a version on every stack update. The record of declared MetadataOptions now keeps only the member names, which is all the reset needs, instead of a serialized model object. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): track template versions and roll records back The previous commit left a new version of the same launch template in place, on the grounds that the template's provisioner publishes a version on every stack update. It publishes one only when the template itself changes, so an instance naming Fn::GetAtt LatestVersionNumber sees its LaunchTemplate change exactly when AWS replaces it. The recorded spec now includes the version, and the change-set preview and the update agree: another template or version, or none, replaces the instance; one added to an instance launched without one keeps it, and an instance launched without one now carries no record at all. When a later resource failed a replacing update, the rollback restored the prior instance but kept the attempt's __FlociDeclared records, so a retry compared against the wrong declaration (a retried template drop kept the instance requiring tokens). The records as they stood before the replacement are saved and put back by rollbackUpdate, and cleared when the update completes. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): keep an instance whose launch template changes Replacing an instance on another launch template, version or none could not be made to agree with the change-set preview: a Version given by Fn::GetAtt LatestVersionNumber previews no replacement, and the template publishes a new, identical version for a Metadata-only change. Keep the instance in place, as upstream does, and reconcile what the template declares; the docs state this as a deviation from AWS. A rollback whose delete of the replacement throws has already named the prior instance again, and a rollback that then skips the resource never calls back, so put the prior instance's declared records back before rethrowing. A saved copy that cannot be read now fails the rollback. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): keep a rollback's delete failure over a bad record When the replacement's delete fails and the saved declarations cannot be read, report the delete failure with the read failure suppressed, rather than replacing it. The docs and the provisioner comment said every launch template change keeps the instance; an ImageId or KeyName the template supplies still replaces it, and a change set still previews a literal LaunchTemplate change as a replacement. Tests pin the replacement and a retried rollback. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * chore(cloudformation): vendor EC2 instance and launch template property types AWS::EC2::Instance and AWS::EC2::LaunchTemplate are to read their MetadataOptions through CfnPropertyTypes, so the generator lists them and checks the MetadataOptions members they rely on. Only their entries are added to the vendored file: a fresh generation also carries new AWS::ECS::TaskDefinition members AWS has published since, which belong to their own sync. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): refuse EC2 MetadataOptions of the wrong type AWS::EC2::Instance and AWS::EC2::LaunchTemplate read a MetadataOptions member given as a list or an object, such as HttpTokens: [required], as absent, so the instance launched with HttpTokens=optional; a block that was not an object was dropped the same way. Read the block through CfnPropertyTypes against the shape each resource schema declares, as AWS::AutoScaling::LaunchConfiguration is: a block or member of the wrong type now fails the resource with CloudFormation's template validation error, and a hop limit that is not a whole number says what it is ("found: Float") rather than a message Floci made up. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): let AWS::NoValue omit launch template metadata options The launch template read its MetadataOptions from LaunchTemplateData after resolving it, which turns AWS::NoValue into an empty string, so since the previous commit a block or hop limit left out with Fn::If and AWS::NoValue failed the template as the wrong type. Read the block as the template writes it, with AWS::NoValue already left out, as the instance does. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * refactor(cloudformation): drop the launch template's unreachable options fallback When LaunchTemplateData is absent or an intrinsic call, its resolved form has no MetadataOptions member either, so the fallback to it always gave null. Say so and use null. A test row also covers a launch template whose MetadataOptions is a string. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): put back metadata options a stack rollback undoes An update that kept the instance and changed its MetadataOptions left them changed when a later resource failed and the stack rolled back: rollbackUpdate undid replacements only, so the instance kept options the stack no longer declared, and the stack reported that the update could not be rolled back. The update now saves the options it replaces, with their region and the instance's __FlociDeclared records, and changes them last, after the tags, so nothing else in the step can fail after them. rollbackUpdate puts both back. The rollback counts as done only when the update changed nothing else on the instance; the instance type, groups, user data, profile and tags still have no rollback, so the stack keeps saying so for them, with the options put back all the same. Ec2Tags.reconcile now reports whether it changed anything, so a tag change counts. A committed or cleared update drops the saved copy. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(ec2): describe CloudFormation MetadataOptions and launch template updates The EC2 notes now say that AWS::EC2::LaunchTemplate stores MetadataOptions and AWS::EC2::Instance launches with its own over its template's, what a wrong type and AWS::NoValue do, that an update applies and resets options in place and a rollback puts them back, and that a changed or dropped LaunchTemplate keeps the instance where AWS replaces it, unless the ImageId or KeyName it supplies changed. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(cloudformation): pin the tag change and order in an options rollback A tag change in the same in-place update makes a rollback put the MetadataOptions back but report the update undone, and a tag failure leaves the options unchanged, since they are the update's last change. The validation comment now lists tags among what runs before them. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): roll back declaration-only updates and refuse blank options An update that kept the instance saved a rollback record only when it changed the instance's MetadataOptions. One that changed only what was declared, such as declaring a default the instance already had, left rollbackUpdate nothing to restore, so a later resource's failure ended the stack with "Rollback is not implemented". Every update that keeps the instance now saves its __FlociDeclared records, with the prior options only when it changes them, and a rollback restores what was saved and counts as done when nothing else on the instance changed. A MetadataOptions member given as an empty or padded string read as absent, so HttpTokens: "" launched with the default. The text is now kept as written and EC2's checks refuse it, as EC2 does; AWS::NoValue still leaves a member out. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * chore(cloudformation): sync the vendored property types with AWS The vendored file lacked the AWS::ECS::TaskDefinition SharingStrategy and NvidiaMpsAllocation members AWS has published since it was last generated, so the drift check, which runs when a change touches the file, failed. This is make cfn-property-types-sync, and the file now matches AWS's schemas. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(cloudformation): cover tag-only and declaration-only rollbacks A rolled-back update that changed only tags puts the declarations back and reports that it could not undo the update, without touching the options. A stack whose update only declares the default HttpTokens the instance already has ends UPDATE_ROLLBACK_COMPLETE when a later resource fails, and a string member left out with Fn::If and AWS::NoValue keeps its default. The ec2 notes say that a blank member is refused and that an update that changed no EC2 setting rolls back in full, which covers any property Floci does not apply, not only MetadataOptions. A stale test name and comment are corrected. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * revert(cloudformation): leave AWS's ECS schema change to its own sync The drift check fails on main as well: AWS has added SharingStrategy and NvidiaMpsAllocation to AWS::ECS::TaskDefinition since main vendored the file, and a fresh generation from main's own tree shows the same three ECS shapes. The AWS::EC2::Instance and AWS::EC2::LaunchTemplate entries this PR vendors already match AWS. The resync is an unrelated change, so the vendored file goes back to this PR's EC2-only addition; the check stays red until main syncs. This reverts commit |
||
|
|
1f96bf42f1 |
feat(ecr): registry policy, replication and scanning configuration (#5817)
* feat(ecr): registry policy, replication and scanning configuration PutRegistryPolicy, GetRegistryPolicy, DeleteRegistryPolicy, PutReplicationConfiguration, DescribeRegistry, PutRegistryScanningConfiguration and GetRegistryScanningConfiguration store the registry's own settings per account and Region and return them as written. Floci does not replicate or scan images or evaluate the policy, as with repository policies. - The policy must be a JSON object; a missing one is RegistryPolicyNotFoundException. - Replication destinations, filters and rule counts are checked against the service model, and an empty rules list clears the configuration. - Scanning defaults to BASIC with no rules, and CONTINUOUS_SCAN is refused with BASIC. Closes #5803 * fix(ecr): put the registry setting writes under one lock PutRegistryPolicy, DeleteRegistryPolicy, PutReplicationConfiguration and PutRegistryScanningConfiguration read the registry's one settings record, change a field and write it back. Terraform applies the three resources in parallel, so two writers could start from the same record and the later write dropped the other's setting. The read, change and write now happen under a lock per account and Region. * refactor(ecr): check registry setting requests against the vendored model The Resource Groups request walker moves to core.common as RequestConstraintCheck, so a service can check a JSON request against botocore's constraints: member types, required members, lengths and counts, number ranges, patterns and enums, each answered in the service's own words. Resource Groups keeps its BadRequestException messages. - tools/aws/request_shapes.py gains build_constraints, which regen_resource_groups_shapes.py now calls; its vendored file is unchanged. - tools/aws/regen_ecr_shapes.py vendors ecr-request-shapes.json for the seven registry setting actions, and aws-data-sync and aws-data-check run it. - EcrJsonHandler checks those requests first, answering InvalidParameterException in ECR's form. The hand-written checks the model states are gone; a policy that is not a JSON object and CONTINUOUS_SCAN with BASIC stay, as the model cannot say them. |
||
|
|
be2cb677d0 |
feat(resourcegroups): support EC2 capacity reservation pools (#6011)
Signed-off-by: Andre Kurait <akurait@amazon.com> |
||
|
|
24a960a599 |
fix(iam): check the API Gateway and Lambda routes the action map names, and test them (#6036)
Under IAM enforcement a REST request is checked as the action its route maps to, and a route no rule maps is let through unchecked. On #5604 the S3 and API Gateway entries of iam-authorized-actions.json were noted as never read, since those requests are authorized by route, with a test comparing them with the route table asked for. This adds that test, against each operation's real route, and fixes what it found. - IamRestRouteCoverageTest builds a request on each operation's route, as botocore's model gives it, and checks that the registry resolves every S3, API Gateway and Lambda entry of iam-authorized-actions.json to the action the entry names. The routes are vendored, one operation to a line, in src/test/resources/aws/rest-routes.json by the new tools/aws/regen_rest_routes.py, which make aws-data-sync and aws-data-check now run. - API Gateway: only /account and /restapis were mapped, so API keys, usage plans, client certificates, base path mappings, domain names and all of the v2 API went unchecked. The management API is now checked as apigateway:<method> on any route, as AWS authorizes it, and RejectDomainNameAccessAssociation and PutRoutingRule as their own actions. The v2 operations AWS checks only as actions of their own names, routing rules and portals, are not served by Floci. - Lambda: InvokeWithResponseStream went unchecked; it is now checked as lambda:InvokeFunction, against the qualified function as an invoke is. GetLayerVersionByArn is checked as lambda:GetLayerVersion. It shares its path with ListLayers, so a rule can now require a query parameter. - S3: the two bucket metadata configuration entries are not applied. Floci serves no metadata configuration, and such a request falls through to ListObjects or DeleteBucket, so it stays checked as the operation that runs. |
||
|
|
fcb41966a8 |
fix(cloudformation): read an ECS task definition's properties as the ECS handler does (#6018)
Measured on CloudFormation (eu-west-1): an AWS::ECS::TaskDefinition gets
no template validation. CloudFormation hands the ECS handler every
scalar as text, and the handler converts each to the type the resource
schema declares: an integer is a sign and digits once trimmed, within
32 bits ("+128", " 128", "0128"), and a boolean is true or false in
lower, upper or title case once trimmed. A value it cannot convert
("abc", 4.5 or true for an integer, "yes", "tRuE" or "1" for a
boolean), and an object, a list and a scalar standing for one another,
fail the resource with every violation of the unconverted model, where
every scalar is a String, so a Memory of 128 is listed beside the value
that failed. At each object its missing required members come first,
then its members in the schema's order. When every value converts, the
required members the model lacks fail it alone, grouped where their
paths meet as the schema validator groups them.
Floci read the properties as plain JSON: a Memory of "abc" and a
container without an image were registered, and an Essential of
"False" registered an essential container.
AWS::ECS::TaskDefinition joins the generated cfn-property-types.json,
whose structures now carry the members the schema requires, read into
RequestShapeModel's shapes. CfnPropertyTypes' walk over the shapes is
shared by the template validation Reader and the new HandlerReader,
which differ in how a scalar converts and in what a mismatch does.
|
||
|
|
e5a206554f |
refactor(cloudformation): read property types from the vendored resource schemas (#5988)
* refactor(cloudformation): read property types from the vendored resource schemas Follow-up asked on #5958: the types EventsCfnProvisioner checked a rule target's members against were written by hand from describe-type, and LambdaCfnProvisioner named the JSON type of each property it reads. They now come from src/main/resources/aws/cfn-property-types.json, which tools/aws/regen_cfn_property_types.py generates from the resource schemas AWS publishes for us-east-1, in the request shapes' layout so RequestShapeModel reads it: a structure, list, map or scalar per shape, and "json" for what a schema leaves free. The schemas come from AWS's live archive rather than a pinned package. cfn-lint ships copies, but widens some types: a Lambda environment variable's value takes any JSON type there and a string in the published schema, where CloudFormation refuses an object or a list with "Property [AB] expected type: String, found: JSONObject" (measured). The archive keeps no older copy, so the generator follows the IAM data's split: --check is offline and structural and runs on every pull request, --verify compares a fresh generation with the vendored file and runs in cfn-schema-drift.yml, weekly and on changes to the file or its generator. CfnPropertyTypes.Reader walks the vendored shapes instead of type trees, maps included: a map's values are read as its value shape, and a mismatch names the key, as CloudFormation does ("Property [h] expected type: String, found: JSONObject", measured). Every member of a rule target is now read against its schema type, not only the four #5958 typed, and Lambda reads the properties it already typed through the same reader, nested members included (VpcConfig.SubnetIds, EphemeralStorage. Size, ImageConfig.Command, TracingConfig.Mode, Environment.Variables). The messages for the newly checked members were measured on CloudFormation (eu-west-1) and are in the tests. * fix(cloudformation): keep a literal list's blank entries where the template put them Review of #5988: the reader read every list of strings through the engine's resolveStringList, which drops blank entries, so a rule target's HttpParameters.PathParameterValues ["", "b"] became ["b"] and moved "b" into the first wildcard. CloudFormation passes a literal list on as written (measured: SecurityGroups ["", "sg-..."] reaches the target as both). A literal list is now read through the engine's new resolveLiteralList, which keeps blanks and still expands a list-valued intrinsic in place; a list an intrinsic yields keeps the engine's reading. Lambda's literal lists, read through the same reader, keep their blanks too, for Lambda to judge as on AWS. resolveLiteralList delegates to the private resolveListElements rather than opening it: tests that mock the engine and call resolveStringList's real code would otherwise get the mock's empty list from it, as IamUserCfnProvisionerTest did. * refactor(cloudformation): read a launch configuration's MetadataOptions by its schema shape Review of #5988: #5964, merged after this branch opened, read AWS::AutoScaling::LaunchConfiguration's MetadataOptions through the type trees this PR removes. The generator now vendors that resource type too, and AutoScalingGroupCfnProvisioner reads the block by the shape its published schema declares (HttpTokens and HttpEndpoint strings, HttpPutResponseHopLimit an integer, the same types #5964 wrote by hand), so its tests pass unchanged. The hop limit's type is an anchor of the generator's offline check. |
||
|
|
98b2429e58 |
fix(ecs): launch a container with its linuxParameters, checked as RegisterTaskDefinition does (#5951)
* fix(ecs): launch a container with its linuxParameters, checked as RegisterTaskDefinition does
RegisterTaskDefinition kept a container's linuxParameters and
DescribeTaskDefinition returned them, but the container was launched
without any of them. A worker that set initProcessEnabled so its orphaned
browser processes would be reaped ran with its own command as PID 1, and
they stayed zombies until the container ended; capabilities, devices,
/dev/shm size, tmpfs mounts and swap limits were ignored the same way.
ECS documents each member as a docker run option, and the container is
now created with them: initProcessEnabled is --init (through
ContainerSpec.init, the flag main already has for it), capabilities are
--cap-add and --cap-drop, devices are --device (read, write and mknod when
no permissions are given, at the host path when no container path is),
sharedMemorySize is --shm-size in MiB, each tmpfs entry is a --tmpfs of
its size in MiB with its mount options, maxSwap is --memory-swap as the
container's hard limit plus that many MiB, and swappiness is
--memory-swappiness. ContainerSpec gains LinuxOptions for the rest,
applied in ContainerLifecycleManager's HostConfig; a constructor with the
former signature keeps every other caller unchanged.
A container behind a security group already had NET_ADMIN and NET_RAW
dropped, because the group is enforced by nftables in the namespace the
task's containers share. Docker applies a named --cap-add over a
--cap-drop, so those two are now also removed from what the container
asks to add; ALL can stay, since Docker grants every capability but the
dropped ones then (measured: docker run --cap-add ALL --cap-drop NET_ADMIN
--cap-drop NET_RAW reports CapEff 000001ffffffcfff, bits 12 and 13 clear).
Measured on RegisterTaskDefinition (eu-west-1, 2026-10-03 and 2026-10-16),
with the SDK's own validation off, and now checked the same way before
anything is stored:
- every capability must be one the KernelCapabilities reference lists, in
any case and without a CAP_ prefix ("Unrecognized Linux capabilities in
add: [CAP_NET_ADMIN]", likewise for drop);
- a device needs a hostPath ("Device cannot have empty hostPath") and only
read, write and mknod as permissions, as written ("Invalid permission:
READ for device /dev/null");
- a tmpfs mount needs a containerPath, a size above zero and options the
Tmpfs reference lists, as written ("The NOEXEC tmpfs mount option
specified is invalid.");
- sharedMemorySize must be above zero, maxSwap zero or more and needs a
swappiness ("When a container has a swap memory, it must also specify a
swappiness value."), from 0 to 100;
- the checks run capabilities, devices, tmpfs, then swap, all before the
Fargate rules;
- on Fargate a non-empty devices list, sharedMemorySize, maxSwap and
swappiness are refused in that order ("Fargate compatible task
definitions do not support devices", with no trailing period, unlike
AWS's other Fargate refusals), and any capability added but SYS_PTRACE
as written ("NET_ADMIN is not allowed on Fargate.");
- a swappiness without maxSwap is accepted and dropped, and capabilities
are stored with both an add and a drop list.
EcsLinuxParameters holds all of it, validation, the stored form and the
launch, and reads the members through one set of helpers, so EcsService
only calls it.
Not done: swap is not limited for a container with no hard memory limit,
since Docker cannot limit swap without one, and a daemon on cgroup v2
discards swappiness, as Amazon Linux 2023 does on ECS.
Tests: EcsLinuxParametersTest and ContainerLifecycleManagerLinuxOptionsTest
for what reaches Docker, EcsLinuxParametersDockerIntegrationTest for a
real container (PID 1, capabilities, device, /dev/shm, tmpfs),
EcsFargateEdgeCaseIntegrationTest for the measured refusals and the stored
form, and EcsLinuxParametersRegistrationTest in sdk-test-java for the
same through the SDK.
* fix(ecs): read linuxParameters as RegisterTaskDefinition does, and guard devices like host volumes
Review of #5951 (Qodo).
A device hands the container the host's hardware, and reached Docker with
no check, where a host volume at the same path is refused by default.
HostVolumePolicy now covers each device's hostPath too, naming the field
it checks: refused unless floci.services.ecs.host-volume-roots holds it or
allow-unsafe-host-volumes is set, at RegisterTaskDefinition after AWS's
own checks (so their messages still come first) and again at launch,
through EcsContainerManager.checkDeviceHostPaths. The registration check
sits in EcsService rather than beside the host volume one in
EcsJsonHandler, so a template's definition gets it too.
Measured with raw requests on RegisterTaskDefinition (eu-west-1,
2026-10-18):
- a member of the wrong JSON type is refused with an
InvalidParameterException from the deserializer, before any rule on the
values: "Unexpected field type" for a scalar where an object or a list
is expected, "Unexpected value type in payload" for a device or a tmpfs
mount that is not an object, "Start of structure or map found where not
expected" for an object where a list or a scalar is expected,
"NUMBER_VALUE cannot be converted to String", "STRING_VALUE cannot be
converted to Integer", "TRUE_VALUE ...", "NUMBER_VALUE cannot be
converted to Boolean", "Unexpected token received from parser" for text
that is not true or false, and no message at all for a list where none
is expected;
- numbers are read as integers, the fraction dropped (sharedMemorySize
1.9 is stored as 1, 0.5 as 0 and refused) and the range capped
(3000000000 is 2147483647); a boolean may come as text in any case; a
null member or list entry is absent, and a null device is an empty one.
Floci kept such values as written and silently skipped what it could not
read, so a definition stored one size and launched another. The stored
form now holds what AWS stores.
Tests: EcsFargateEdgeCaseIntegrationTest for every measured shape, the
stored numbers, booleans and nulls, and a device refused by default; the
Docker test allows /dev/null through host-volume-roots. All fail on the
previous head.
* refactor(ecs): check linuxParameters' JSON types against the vendored ECS model
Review of #5951. EcsLinuxParameters hand-wrote the deserializer's type
check member by member, where Floci already drives that check from
botocore for DynamoDB and SES v2 (RequestShapeModel, with the shapes
vendored by tools/aws/request_shapes.py).
tools/aws/regen_ecs_shapes.py vendors botocore's ECS model as
src/main/resources/aws/ecs-request-shapes.json (botocore 1.43.113, the
release requirements.txt pins), registered in make aws-data-sync and
aws-data-check and in the shared generator's tests. EcsRequestShapes
walks a container's linuxParameters against the LinuxParameters shape
with ECS's InvalidParameterException messages, the ones measured on
RegisterTaskDefinition; EcsLinuxParameters' own member list is gone.
The messages and their order are unchanged.
The device change named host volumes only in two more descriptions of
floci.services.ecs.host-volume-roots: docs/configuration/
environment-variables.md and the configuration table in
docs/services/ecs.md now name devices too, as does the host volume
section and the allow-unsafe-host-volumes Javadoc.
Tests: EcsRequestShapesTest for every measured message against the
vendored model; EcsFargateEdgeCaseIntegrationTest passes unchanged.
* refactor(core): walk request shapes once, with each service's messages
Review of #5951: EcsRequestShapes walked the vendored model the same way
DynamoDbRequestShapes and SesV2RequestShapes do (a null is absent, an
unknown member is skipped, a structure's values are read as members and a
list's or a map's as elements, a boolean reads from "true" or "false" in
any case, a scalar of the wrong kind is named by its JSON token), with only
the error code and a few messages apart. That walk is now
RequestShapeCheck, next to RequestShapeModel in core.common, and each
service hands it its deserializer's wording as RequestShapeCheck.Messages:
DynamoDB's SerializationException with DECIMAL_VALUE and the base-64
message for a blob, SES v2's SerializationException with its "can not be
converted to a" wording and only strings and blobs checked, as probed, and
ECS's InvalidParameterException with no message for a list where none is
expected.
The three services' tests pass unchanged. SES v2's wording becomes
constants in SesV2Json, which its member helpers and the walk share.
|
||
|
|
30d8d3ff5c |
fix(core): route a Query action by its service's botocore model (#5879)
A Query request without a usable credential scope is routed by its Action and Version, and IAM enforcement authorizes it under the service that routing picks. The names each service routed were kept by hand in AwsQueryController and had drifted from what the services serve: 170 names Floci dispatches, across eight services, reached no service and fell through to SQS. They answered UnsupportedOperation in SQS's namespace and were authorized as SQS actions. Each Query service's API versions and operations now come from its botocore models: tools/aws/regen_query_services.py writes them, from the pinned botocore, to aws/query-services.json, and make aws-data-check fails when the file is stale. Every name a service defines reaches it, implemented here or not. Floci keeps the list of services and their order, Cognito's names, which no Query model holds, and ElastiCache's ValidateIamAuthToken, which no model defines. A name several services define goes to the first of them when the request names no Version. Ten such names get a pinned owner instead, the service that serves them here, where the order would pick an earlier one that does not. The routing parity test checks every dispatched action with and without a Version and no longer needs its list of known gaps. |
||
|
|
6aac097c82 |
chore(tools): generate the request shapes from one shared script (#5816)
regen_dynamodb_shapes.py and regen_sesv2_shapes.py carried the same build() and main(); the SES v2 one only added the filter that drops members bound to the URI, query string or headers, which leaves DynamoDB's model unchanged since it has none. request_shapes.py now holds load_model(), a build() that takes the generator's name, render() and main(), and each script names its model and output. Both vendored files regenerate unchanged. |
||
|
|
e24a2882bc |
fix(ses): check v2 send request bodies against the service model (#5765)
* fix(ses): check v2 send request bodies against the service model SendEmail, SendBulkEmail and SendCustomVerificationEmail read their members by hand, so a member of the wrong JSON type was coerced, read as empty, or rejected with a Floci-specific BadRequestException, depending on which member it was. AWS deserializes the whole body against the model first and answers the first member of the wrong type, in body order, with a SerializationException and its deserializer message. tools/aws/regen_sesv2_shapes.py vendors the body shapes of botocore's SES v2 model into src/main/resources/aws/sesv2-request-shapes.json, kept in sync by make aws-data-check like the DynamoDB shapes. SesV2RequestShapes checks a body against them, and the three send endpoints call it before reading any member. The type checks it makes redundant are removed from the send helpers. A null address list element still passes and fails as "Invalid email address null.", as on AWS. Only the string, blob, list, structure and map messages have been probed, so number, boolean and timestamp members are left to their controllers. * fix(ses): report a null v2 send address where SES does A null element of a v2 send address list was rejected for the whole request while the body was read. SES lets it through deserialization and reports it later: SendEmail answers "Invalid email address null." after its content and sender checks and before the tenant lookup, and SendBulkEmail reports it as the INVALID_PARAMETER status of the entry it belongs to, of every entry for a null Reply-To, or as "Destination cannot be empty" when no entry of the request has a non-null recipient. The address lists now keep the null, SendEmail checks for it ahead of the tenant gate, and the bulk entry check reports it per entry. Two ordered integration tests that shared an @Order value get their own. * chore(core): share the vendored request-shape model DynamoDbRequestShapes and SesV2RequestShapes each carried the same Shape and Model records and the same parse() and load(), and load() repeated VendoredResources.read. RequestShapeModel in core.common now holds that half and both checks use it; each keeps its own walk and its protocol's messages. |
||
|
|
77384dc3de |
feat(redshift-serverless): validate requests against the AWS model constraints (#5641)
* feat(redshift-serverless): validate requests against the AWS model constraints Generate the input constraints (required members, length, pattern, enum, number range, list size) from botocore's Redshift Serverless model with tools/aws/regen_redshift_serverless_shapes.py and vendor them under src/main/resources/aws, like the DynamoDB request shapes. A new RedshiftServerlessRequestShapes check runs before dispatch and answers a ValidationException. Pagination members are left to the services, which keep reporting InvalidPaginationException. Move the request parsing and error helpers that the JSON handler, the usage limit service and the service each carried a copy of into ServerlessSupport, so the resource families that follow share one implementation. * fix(redshift-serverless): address review findings on request validation - Match a model pattern against the whole value, so an unanchored pattern such as the account id no longer accepts a value that merely contains a match. - Count string lengths in Unicode code points, so a tag of 200 supplementary characters is not rejected for exceeding 256 UTF-16 units. - Validate only the actions the handler implements, so a modeled but unsupported action keeps answering UnknownOperationException. - Read every string member through ServerlessSupport.text and reject a tag key or value that is not a string, so a numeric nextToken or tag member is a ValidationException instead of being treated as absent or coerced. - Regenerate the vendored shapes from botocore 1.43.113, the version tools/aws/requirements.txt pins. - Cover the rejected-request case with a state check, and add the pattern, code point, page token and tag regressions. * refactor(redshift-serverless): use VendoredResources, ServerlessSupport.notFound and update docs |
||
|
|
3afb5b430e |
fix(partitions): source the China CloudFront suffix and GovCloud API Gateway zones (#5618)
* fix(partitions): source the China CloudFront suffix and GovCloud API Gateway zones Two values listed as open questions have a published source in the China and GovCloud user guides, so they become vendored facts in aws/region-facts.json instead of a commercial constant. A generated CloudFront distribution domain name ended in cloudfront.net in every partition. The China guide's CloudFront page names the default domain there as *.cloudfront.cn (https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html), and the commercial suffix is the one in the example name of the botocore CloudFront model (Distribution$DomainName, DistributionSummary$DomainName). floci.services.cloudfront.domain-suffix loses its cloudfront.net default and becomes optional: unset, the suffix follows the request's partition, with the commercial one where a partition has no CloudFront; set, it applies in every partition as before. CloudFront distributions and streaming distributions, Cognito and AppSync custom domains and edge-optimized API Gateway domains all resolve it through CloudFrontEdgeDomain.domainSuffix. A regional API Gateway custom domain reported one placeholder hosted zone id in every region. The GovCloud guide's API Gateway page states the regional endpoint zone for us-gov-west-1 (Z1K6XKP9SAGWDV) and us-gov-east-1 (Z3SE9ATJYCRCZJ) (https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-abp.html); those two regions now report it, and the generator resolves each region through its description in partitions.json. No source gives the zone for any other region, which keeps the placeholder and stays an open question. The generator reads both sentences from either rendering of a guide page: the page text, or the Markdown AWS serves at the same URL with .md, which escapes the asterisk in the CloudFront sentence. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * fix(partitions): require each sourced fact and resolve edge domains in the request's partition The GovCloud API Gateway page parser accepted a page stating only one region's regional hosted zone, so an edited guide would have dropped the other zone from region-facts.json without failing. It now requires a zone for every aws-us-gov region. The region-facts self check validated cloudfrontDomainSuffix only when it was present. It now requires the suffix for aws and aws-cn, and the regional hosted zone for both GovCloud regions, as it already requires consoleHost; a missing commercial suffix would otherwise have reached the orElseThrow in CloudFrontEdgeDomain.domainSuffix at runtime. CloudFrontEdgeDomain.create resolved its partition from the region alone, falling back to the commercial one, so an AppSync or API Gateway custom domain in a region no partition publishes (allowed under allow-unknown-regions) took the commercial suffix and hosted zone in a China deployment. It now takes the partition the caller's RegionResolver resolves, which falls back to the deployment's partition, as the CloudFront and Cognito paths already do. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com> |
||
|
|
d84a764cf9 |
fix(deps): bump botocore to 1.43.113 and regenerate the vendored AWS data (#5613)
Regenerate partitions.json and dynamodb-request-shapes.json from botocore 1.43.113. The partition data gains the training-session-runtime.sagemaker endpoint prefix under the sagemaker signing name and lists kafkaconnect in aws-eusc. Neither changes a service Floci serves: the new SageMaker prefix is not published in any partition yet and api.sagemaker already is in all of them, and kafkaconnect is not implemented. The DynamoDB request shapes are unchanged apart from the provenance line. Signed-off-by: Hector Ventura <hectorvent@gmail.com> |
||
|
|
63e0302c12 |
fix(apigateway): validate and normalize imported integration types (#5543)
Signed-off-by: Andre Kurait <akurait@amazon.com> |
||
|
|
eba058266b |
fix(iam): authorize an operation as the action AWS checks for it (#5604)
Under enforcement a request naming its operation, in a Query Action or an X-Amz-Target header, was authorized as <namespace>:<Operation>, the operation's own name. AWS authorizes some operations as an action of another name: SQS SendMessageBatch, DeleteMessageBatch and ChangeMessageVisibilityBatch as sqs:SendMessage, sqs:DeleteMessage and sqs:ChangeMessageVisibility, and SNS PublishBatch as sns:Publish. None of the batch names is an IAM action, so a policy AWS honours for a batch call was denied, and a policy naming the batch operation granted something AWS does not check. AWS publishes the mapping in the Operations of each Service Reference file. tools/aws/regen_iam_authorized_actions.py vendors the operations authorized by exactly one action of their own namespace under another name, 235 over 33 namespaces, into src/main/resources/aws/iam-authorized-actions.json. Everything else keeps its own name. The generator leaves out operations that list: - several actions, whose extras apply only when tags or a role are passed; - no action, which is missing data; - an action of another namespace; - another action while one of the operation's own name exists; - a tagging action alone; - the same action for several SDK clients, which AWS can authorize differently, as S3 and S3 Control's GetPublicAccessBlock; or whose name is listed again with another answer. A record of the wrong shape fails the run instead of being skipped. make iam-authorized-actions-check gates the file's shape on pull requests that touch it, and iam-authorized-actions-verify, run by the IAM Data Drift workflow, checks every entry against AWS. IamAuthorizedActions reads the file through the new core.common VendoredResources, rather than adding one more copy of the read-or-fail block a dozen catalogs carry, and the Query and X-Amz-Target paths ask it for the action. DynamoDB TransactGetItems, which AWS authorizes as dynamodb:GetItem, keeps its own name: the transaction check recognizes the call by it and checks every Get as dynamodb:GetItem on its own table, with its own dynamodb:LeadingKeys. Renamed, the call would skip that check and be authorized as one GetItem whose body has no top-level Key, which a ForAllValues condition accepts, so a fine-grained policy would grant every key. The check for operations AWS serves without credentials reads the Query action directly, rather than through resolve with a placeholder scope, now that resolve returns the authorized action. A Query request naming no action is not one of them. An SDK compatibility test covers SendMessageBatch and PublishBatch, granted by the single-item action and refused under the batch name, with enforcement on. |
||
|
|
8bd88bfb40 |
fix(codepipeline): link approval notifications to the partition's console host (#5595)
* fix(codepipeline): link approval notifications to the partition's console host The approval-needed notification built consoleLink and approvalReviewLink on the commercial console host for every pipeline, so a pipeline in China or GovCloud sent its approver to a console where the pipeline does not exist. The console host becomes a vendored per-partition fact, consoleHost in aws/region-facts.json, read by the generator from the user-guide snapshots under local/aws/aws-docs/partition-guides: cn/console.md for aws-cn (console.amazonaws.cn), gov/configure-account.md for aws-us-gov (console.amazonaws-us-gov.com) and gov/govcloud-organizations.md for the commercial host. The China guide also spells the host console.www.amazonaws.cn once, in cn/managing-aws.md; the console page's own statement is the one used. A guide page that lost its sentence, or states two hosts with it, fails the generation instead of leaving a stale value. CodePipelineEventPublisher resolves the host from the execution's region, since it runs on a worker thread without a request context. No source states a console host for the ISO or EUSC partitions, which keep the commercial one and are listed as an open question. The path after the host stays the commercial console's: no source gives the per-service path per partition. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * fix(codepipeline): parse the China console host from the Markdown guide page, require sourced hosts AWS serves each user-guide page as Markdown at the same URL with .md in place of .html, and that rendering writes the China console host as a link, "[https://console.amazonaws.cn](https://console.amazonaws.cn).". The aws-cn pattern only took the page-text form, so a snapshot saved from the Markdown page failed the generator, and with it the rest of "make aws-data-sync". The pattern now takes both forms. The docstring names the three guide page URLs and the path each is saved under. self_check now requires consoleHost for the three partitions that have a source (aws, aws-cn, aws-us-gov). The shape-only check used when the sources are not checked out accepted a file without them, which would link approval notifications to the commercial console. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com> |
||
|
|
94a801e05f |
fix(deps): bump botocore to 1.43.111 and regenerate the vendored AWS data (#5498)
Regenerate partitions.json and dynamodb-request-shapes.json from the installed botocore 1.43.111 package. DynamoDB's request type check now covers ExportTableToPointInTime FilterSpecification. The partition data also lists eventsv2 (aws), runtime.sagemaker (aws-iso-e), dax (aws-us-gov) and the cloudwatch-omni / eventsv2 signing-name mappings. None of these change a service Floci serves: dax and eventsv2 are not implemented, and the sagemaker, events and cloudwatch signing names resolve as before. local/aws was not checked out, so the provenance label names the installed package and regionFlags are carried over from the previous file; the data is otherwise identical to a local/aws generation. |