FIX #17042 - Allow non admin/bot to read profiler global config (#18292)

* fix: custom properties folder name in generation to match expected package name (i.e. customProperties -- uppercase P)

* fix: allow non admin/bot to read profiler global config with the right permission

* style: ran java linting

* fix: custom properties import casing
This commit is contained in:
Teddy 2024-10-17 09:27:34 +02:00 committed by GitHub
parent 2093c24f83
commit fc51d7feb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 30 additions and 15 deletions

View File

@ -69,7 +69,7 @@ import org.openmetadata.schema.type.csv.CsvErrorType;
import org.openmetadata.schema.type.csv.CsvFile;
import org.openmetadata.schema.type.csv.CsvHeader;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.jdbi3.EntityRepository;

View File

@ -144,7 +144,7 @@ import org.openmetadata.schema.type.api.BulkAssets;
import org.openmetadata.schema.type.api.BulkOperationResult;
import org.openmetadata.schema.type.api.BulkResponse;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.schema.utils.EntityInterfaceUtil;
import org.openmetadata.service.Entity;
import org.openmetadata.service.OpenMetadataApplicationConfig;
@ -1495,15 +1495,15 @@ public abstract class EntityRepository<T extends EntityInterface> {
private void validateTableType(JsonNode fieldValue, String propertyConfig, String fieldName) {
TableConfig tableConfig =
JsonUtils.convertValue(JsonUtils.readTree(propertyConfig), TableConfig.class);
org.openmetadata.schema.type.customproperties.Table tableValue =
org.openmetadata.schema.type.customProperties.Table tableValue =
JsonUtils.convertValue(
JsonUtils.readTree(String.valueOf(fieldValue)),
org.openmetadata.schema.type.customproperties.Table.class);
org.openmetadata.schema.type.customProperties.Table.class);
Set<String> configColumns = tableConfig.getColumns();
try {
JsonUtils.validateJsonSchema(
tableValue, org.openmetadata.schema.type.customproperties.Table.class);
tableValue, org.openmetadata.schema.type.customProperties.Table.class);
Set<String> fieldColumns = new HashSet<>();
fieldValue.get("columns").forEach(column -> fieldColumns.add(column.asText()));

View File

@ -42,8 +42,8 @@ import org.openmetadata.schema.type.CustomPropertyConfig;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.customproperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.exception.CatalogExceptionMessage;

View File

@ -122,6 +122,7 @@ public class TableResource extends EntityResource<Table, TableRepository> {
MetadataOperation.VIEW_DATA_PROFILE,
MetadataOperation.VIEW_SAMPLE_DATA,
MetadataOperation.VIEW_USAGE,
MetadataOperation.VIEW_PROFILER_GLOBAL_CONFIGURATION,
MetadataOperation.EDIT_TESTS,
MetadataOperation.EDIT_QUERIES,
MetadataOperation.EDIT_DATA_PROFILE,

View File

@ -34,6 +34,7 @@ import org.openmetadata.schema.settings.Settings;
import org.openmetadata.schema.settings.SettingsType;
import org.openmetadata.schema.system.ValidationResponse;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.util.EntitiesCount;
import org.openmetadata.schema.util.ServicesCount;
import org.openmetadata.sdk.PipelineServiceClientInterface;
@ -46,6 +47,8 @@ import org.openmetadata.service.jdbi3.SystemRepository;
import org.openmetadata.service.resources.Collection;
import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.JwtFilter;
import org.openmetadata.service.security.policyevaluator.OperationContext;
import org.openmetadata.service.security.policyevaluator.ResourceContext;
import org.openmetadata.service.util.ResultList;
import org.openmetadata.service.util.email.EmailUtil;
@ -145,8 +148,18 @@ public class SystemResource {
schema = @Schema(implementation = Settings.class)))
})
public Settings getProfilerConfigurationSetting(
@Context UriInfo uriInfo, @Context SecurityContext securityContext) {
authorizer.authorizeAdminOrBot(securityContext);
@Context UriInfo uriInfo,
@Context SecurityContext securityContext,
@Parameter(
description = "Entity type for which to get the global profiler configuration",
schema = @Schema(type = "string"))
@QueryParam("entityType")
@DefaultValue("table")
String entityType) {
ResourceContext resourceContext = new ResourceContext(entityType);
OperationContext operationContext =
new OperationContext(entityType, MetadataOperation.VIEW_PROFILER_GLOBAL_CONFIGURATION);
authorizer.authorize(securityContext, operationContext, resourceContext);
return systemRepository.getConfigWithKey(SettingsType.PROFILER_CONFIGURATION.value());
}

View File

@ -89,7 +89,7 @@ import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.schema.type.TagLabel.TagSource;
import org.openmetadata.schema.type.TaskStatus;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.CatalogExceptionMessage;
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater;

View File

@ -48,8 +48,8 @@ import org.openmetadata.schema.entity.type.CustomProperty;
import org.openmetadata.schema.type.ChangeDescription;
import org.openmetadata.schema.type.CustomPropertyConfig;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.customproperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.EntityResourceTest;
import org.openmetadata.service.resources.types.TypeResource;

View File

@ -21,6 +21,7 @@
"ViewTests",
"ViewQueries",
"ViewDataProfile",
"ViewProfilerGlobalConfiguration",
"ViewSampleData",
"ViewTestCaseFailedRowsSample",
"EditAll",

View File

@ -104,7 +104,7 @@
"title": "Table",
"description": "A table-type custom property having rows and columns where all column data types are strings.",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.Table",
"javaType": "org.openmetadata.schema.type.customProperties.Table",
"properties": {
"columns": {
"type": "array",

View File

@ -3,7 +3,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "EnumConfig",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.EnumConfig",
"javaType": "org.openmetadata.schema.type.customProperties.EnumConfig",
"description": "Applies to Enum type, this config is used to define list of enum values",
"properties": {
"multiSelect": {

View File

@ -4,7 +4,7 @@
"title": "TableConfig",
"description": "Custom property configuration for table-type property where all column data types are strings.",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.TableConfig",
"javaType": "org.openmetadata.schema.type.customProperties.TableConfig",
"properties": {
"columns": {
"type": "array",