mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 23:59:27 -05:00
fix(ses): refuse a list token whose scope only starts with the request's (#4870)
* fix(ses): refuse a list token whose scope only starts with the request's A tenant-list token named its scope by plain concatenation, so a scope that began with another one, which a name containing the token's own separator can do, passed the prefix check and was read as a position in the wrong list. The token now carries the scope's length. * test(ses): replay a list token on a resource whose name it starts with Cover the scope fix through ListResourceTenants itself: a token issued for an identity whose name continues another identity's with the token separator is refused on the shorter one and still continues its own list.
This commit is contained in:
1 parent
d72923ab33
commit
62bcfb95ed
5 files changed
+54
-8
No files matched your search
@@ -30,6 +30,7 @@ import java.time.Instant;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -370,7 +371,7 @@ public class SesImportJobService implements Resettable {
|
||||
/** The filter is checked before the page size and token, and a token is bound to it, as on the tenant lists. */
|
||||
public PaginatedResult<ImportJob> listImportJobs(String region, String destinationType,
|
||||
SesListPaging paging, Integer pageSize, String nextToken) {
|
||||
return paging.page(region, "/" + destinationType, listImportJobs(region, destinationType),
|
||||
return paging.page(region, Objects.toString(destinationType, ""), listImportJobs(region, destinationType),
|
||||
SesImportJobService::cursor, pageSize, nextToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,9 @@ public enum SesListPaging {
|
||||
|
||||
/**
|
||||
* {@code scope} names what else the request selected, a tenant or a filter, for the lists whose
|
||||
* tokens SES refuses once that changes.
|
||||
* tokens SES refuses once that changes. The token carries the scope's length, so a scope that
|
||||
* merely starts with another, which a name holding the token's own separator can do, is not
|
||||
* taken for it.
|
||||
*/
|
||||
<T> PaginatedResult<T> page(String region, String scope, List<T> all, Function<T, String> cursorOf,
|
||||
Integer pageSize, String nextToken) {
|
||||
@@ -190,7 +192,8 @@ public enum SesListPaging {
|
||||
if (emptyToken) {
|
||||
throw invalidToken.apply(nextToken);
|
||||
}
|
||||
return Pagination.paginate(all, cursorOf, limit, nextToken, namespace + "@" + region + scope,
|
||||
String boundTo = scope.isEmpty() ? "" : "#" + scope.length() + "#" + scope;
|
||||
return Pagination.paginate(all, cursorOf, limit, nextToken, namespace + "@" + region + boundTo,
|
||||
invalidToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
@@ -421,7 +422,7 @@ public class SesTenantService {
|
||||
public PaginatedResult<TenantResourceAssociation> listTenantResources(Tenant tenant, String typeFilter,
|
||||
String region, SesListPaging paging,
|
||||
Integer pageSize, String nextToken) {
|
||||
return paging.page(region, "/" + tenant.tenantId() + "/" + typeFilter,
|
||||
return paging.page(region, tenant.tenantId() + "/" + Objects.toString(typeFilter, ""),
|
||||
listTenantResources(tenant, typeFilter, region), TenantResourceAssociation::resourceArn,
|
||||
pageSize, nextToken);
|
||||
}
|
||||
@@ -444,7 +445,7 @@ public class SesTenantService {
|
||||
public PaginatedResult<TenantResourceAssociation> listResourceTenants(AssociationResource ref, String region,
|
||||
SesListPaging paging, Integer pageSize,
|
||||
String nextToken) {
|
||||
return paging.page(region, "/" + ref.arn(), listResourceTenants(ref, region),
|
||||
return paging.page(region, ref.arn(), listResourceTenants(ref, region),
|
||||
SesTenantService::associationCursor, pageSize, nextToken);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user