mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(athena): read and check a request naming no catalog as AwsDataCatalog (#7061)
Athena's GetDataCatalog, ListDatabases, ListTableMetadata and GetTableMetadata handlers read the catalog name with has() and asText(), so a JSON null became a catalog named `null`: GetDataCatalog then answered InvalidRequestException rather than the AwsDataCatalog it answers for a request naming none. They now read it through the handler's text(), as GetWorkGroup and StartQueryExecution read WorkGroup, so a JSON null names no catalog. Under IAM enforcement, a GetDataCatalog naming no catalog was checked on `*` though Floci answers AwsDataCatalog, so a grant on that catalog was refused and a deny on it did not apply, and the three catalog reads given a JSON null CatalogName were checked on `datacatalog/null` as well as on AwsDataCatalog. The request-resources table now reads a request naming none, or a JSON null, as naming AwsDataCatalog for all four, as it reads Athena's primary workgroup. The table's regeneration also takes up drift in AWS's Service Reference since the last sync, which the online check of both IAM tables fails on: AWS now lists cognito-idp:DescribeTermsByClient among the actions it authorizes DescribeTermsByClient as, so the authorized-actions map no longer maps it to DescribeTerms and the request-resources table checks it as its own action, and the map gains MediaConnect's new BatchGetDestinationEndpoint and BatchGetSourceEndpoint. Floci serves none of these operations.
This commit is contained in:
1 parent
f40d784f66
commit
bfd3bcbbce
8 files changed
+69
-21
No files matched your search
@@ -124,10 +124,8 @@ public class AthenaJsonHandler {
|
||||
}
|
||||
yield Response.ok(response).build();
|
||||
}
|
||||
case "GetDataCatalog" -> {
|
||||
String name = request.has("Name") ? request.get("Name").asText() : AthenaService.DEFAULT_CATALOG;
|
||||
yield Response.ok(Map.of("DataCatalog", athenaService.getDataCatalog(region, name))).build();
|
||||
}
|
||||
case "GetDataCatalog" -> Response.ok(
|
||||
Map.of("DataCatalog", athenaService.getDataCatalog(region, text(request, "Name")))).build();
|
||||
case "CreateDataCatalog" -> {
|
||||
Map<String, Object> catalog = athenaService.createDataCatalog(region,
|
||||
text(request, "Name"),
|
||||
@@ -156,16 +154,16 @@ public class AthenaJsonHandler {
|
||||
yield Response.ok(Map.of()).build();
|
||||
}
|
||||
case "ListDatabases" -> {
|
||||
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
|
||||
String catalog = catalogName(request);
|
||||
yield Response.ok(Map.of("DatabaseList", athenaService.listDatabases(catalog))).build();
|
||||
}
|
||||
case "ListTableMetadata" -> {
|
||||
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
|
||||
String catalog = catalogName(request);
|
||||
String database = request.path("DatabaseName").asText(request.path("Database").asText(""));
|
||||
yield Response.ok(Map.of("TableMetadataList", athenaService.listTableMetadata(catalog, database))).build();
|
||||
}
|
||||
case "GetTableMetadata" -> {
|
||||
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
|
||||
String catalog = catalogName(request);
|
||||
String database = request.path("DatabaseName").asText(request.path("Database").asText(""));
|
||||
String tableName = request.get("TableName").asText();
|
||||
yield Response.ok(Map.of("TableMetadata", athenaService.getTableMetadata(catalog, database, tableName))).build();
|
||||
@@ -194,6 +192,11 @@ public class AthenaJsonHandler {
|
||||
return node == null || node.isNull() ? null : node.asText();
|
||||
}
|
||||
|
||||
private static String catalogName(JsonNode request) {
|
||||
String named = text(request, "CatalogName");
|
||||
return named != null ? named : AthenaService.DEFAULT_CATALOG;
|
||||
}
|
||||
|
||||
private static Map<String, String> parameters(JsonNode request) {
|
||||
JsonNode node = request.get("Parameters");
|
||||
if (node == null || !node.isObject()) {
|
||||
|
||||
Reference in new issue
Block a user