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.CsvFile;
import org.openmetadata.schema.type.csv.CsvHeader; import org.openmetadata.schema.type.csv.CsvHeader;
import org.openmetadata.schema.type.csv.CsvImportResult; 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.Entity;
import org.openmetadata.service.TypeRegistry; import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.jdbi3.EntityRepository; 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.BulkOperationResult;
import org.openmetadata.schema.type.api.BulkResponse; import org.openmetadata.schema.type.api.BulkResponse;
import org.openmetadata.schema.type.csv.CsvImportResult; 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.schema.utils.EntityInterfaceUtil;
import org.openmetadata.service.Entity; import org.openmetadata.service.Entity;
import org.openmetadata.service.OpenMetadataApplicationConfig; 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) { private void validateTableType(JsonNode fieldValue, String propertyConfig, String fieldName) {
TableConfig tableConfig = TableConfig tableConfig =
JsonUtils.convertValue(JsonUtils.readTree(propertyConfig), TableConfig.class); JsonUtils.convertValue(JsonUtils.readTree(propertyConfig), TableConfig.class);
org.openmetadata.schema.type.customproperties.Table tableValue = org.openmetadata.schema.type.customProperties.Table tableValue =
JsonUtils.convertValue( JsonUtils.convertValue(
JsonUtils.readTree(String.valueOf(fieldValue)), JsonUtils.readTree(String.valueOf(fieldValue)),
org.openmetadata.schema.type.customproperties.Table.class); org.openmetadata.schema.type.customProperties.Table.class);
Set<String> configColumns = tableConfig.getColumns(); Set<String> configColumns = tableConfig.getColumns();
try { try {
JsonUtils.validateJsonSchema( JsonUtils.validateJsonSchema(
tableValue, org.openmetadata.schema.type.customproperties.Table.class); tableValue, org.openmetadata.schema.type.customProperties.Table.class);
Set<String> fieldColumns = new HashSet<>(); Set<String> fieldColumns = new HashSet<>();
fieldValue.get("columns").forEach(column -> fieldColumns.add(column.asText())); 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.EntityReference;
import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.Relationship; import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.customproperties.EnumConfig; import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig; import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity; import org.openmetadata.service.Entity;
import org.openmetadata.service.TypeRegistry; import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.exception.CatalogExceptionMessage; 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_DATA_PROFILE,
MetadataOperation.VIEW_SAMPLE_DATA, MetadataOperation.VIEW_SAMPLE_DATA,
MetadataOperation.VIEW_USAGE, MetadataOperation.VIEW_USAGE,
MetadataOperation.VIEW_PROFILER_GLOBAL_CONFIGURATION,
MetadataOperation.EDIT_TESTS, MetadataOperation.EDIT_TESTS,
MetadataOperation.EDIT_QUERIES, MetadataOperation.EDIT_QUERIES,
MetadataOperation.EDIT_DATA_PROFILE, 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.settings.SettingsType;
import org.openmetadata.schema.system.ValidationResponse; import org.openmetadata.schema.system.ValidationResponse;
import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.util.EntitiesCount; import org.openmetadata.schema.util.EntitiesCount;
import org.openmetadata.schema.util.ServicesCount; import org.openmetadata.schema.util.ServicesCount;
import org.openmetadata.sdk.PipelineServiceClientInterface; 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.resources.Collection;
import org.openmetadata.service.security.Authorizer; import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.JwtFilter; 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.ResultList;
import org.openmetadata.service.util.email.EmailUtil; import org.openmetadata.service.util.email.EmailUtil;
@ -145,8 +148,18 @@ public class SystemResource {
schema = @Schema(implementation = Settings.class))) schema = @Schema(implementation = Settings.class)))
}) })
public Settings getProfilerConfigurationSetting( public Settings getProfilerConfigurationSetting(
@Context UriInfo uriInfo, @Context SecurityContext securityContext) { @Context UriInfo uriInfo,
authorizer.authorizeAdminOrBot(securityContext); @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()); 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.TagLabel.TagSource;
import org.openmetadata.schema.type.TaskStatus; import org.openmetadata.schema.type.TaskStatus;
import org.openmetadata.schema.type.csv.CsvImportResult; 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.Entity;
import org.openmetadata.service.exception.CatalogExceptionMessage; import org.openmetadata.service.exception.CatalogExceptionMessage;
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater; 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.ChangeDescription;
import org.openmetadata.schema.type.CustomPropertyConfig; import org.openmetadata.schema.type.CustomPropertyConfig;
import org.openmetadata.schema.type.EntityReference; import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.customproperties.EnumConfig; import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig; import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity; import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.EntityResourceTest; import org.openmetadata.service.resources.EntityResourceTest;
import org.openmetadata.service.resources.types.TypeResource; import org.openmetadata.service.resources.types.TypeResource;

View File

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

View File

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

View File

@ -3,7 +3,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "EnumConfig", "title": "EnumConfig",
"type": "object", "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", "description": "Applies to Enum type, this config is used to define list of enum values",
"properties": { "properties": {
"multiSelect": { "multiSelect": {

View File

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