From c36d337e468432bd2f0b2128d3fa6627117bc2e7 Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Fri, 14 Feb 2025 14:32:02 +0000 Subject: [PATCH] Integration tests glossaries/dashboard bugfix (#1765) ### Feature or Bugfix - Bugfix ### Detail - MetadataForm Entity methods => uri(), catalog method => uri_column() - frontend visibility bugfix ### Relates - ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Sofia Sazonova --- .../dataall/modules/catalog/indexers/registry.py | 4 ++-- .../modules/dashboards/db/dashboard_models.py | 4 ++++ .../modules/datasets_base/db/dataset_models.py | 4 ++++ .../redshift_datasets/db/redshift_models.py | 2 +- .../modules/s3_datasets/db/dataset_models.py | 14 +++++++++++++- .../versions/797dd1012be1_resource_lock_table.py | 2 +- .../versions/8c79fb896983_add_table_for_buckets.py | 2 +- ...9d854e29_implement_dataset_locking_mechanism.py | 2 +- .../components/metadataAttachment.js | 1 - 9 files changed, 27 insertions(+), 8 deletions(-) diff --git a/backend/dataall/modules/catalog/indexers/registry.py b/backend/dataall/modules/catalog/indexers/registry.py index f4a3d9ef7..5586be22d 100644 --- a/backend/dataall/modules/catalog/indexers/registry.py +++ b/backend/dataall/modules/catalog/indexers/registry.py @@ -9,7 +9,7 @@ class Identifiable(Protocol): @classmethod - def uri(cls): ... + def uri_column(cls): ... @dataclass @@ -22,7 +22,7 @@ class GlossaryDefinition: reindexer: Type[BaseIndexer] = None # a callback to reindex glossaries in open search def target_uri(self): - return self.model.uri() + return self.model.uri_column() class GlossaryRegistry(UnionTypeRegistry): diff --git a/backend/dataall/modules/dashboards/db/dashboard_models.py b/backend/dataall/modules/dashboards/db/dashboard_models.py index 24a2ddfe3..a9e4d6f08 100644 --- a/backend/dataall/modules/dashboards/db/dashboard_models.py +++ b/backend/dataall/modules/dashboards/db/dashboard_models.py @@ -36,6 +36,10 @@ class Dashboard(Resource, Base): userRoleForDashboard = query_expression() + @classmethod + def uri_column(cls): + return cls.dashboardUri + def uri(self): return self.dashboardUri diff --git a/backend/dataall/modules/datasets_base/db/dataset_models.py b/backend/dataall/modules/datasets_base/db/dataset_models.py index cfacc64fb..aeedcf0e3 100644 --- a/backend/dataall/modules/datasets_base/db/dataset_models.py +++ b/backend/dataall/modules/datasets_base/db/dataset_models.py @@ -36,6 +36,10 @@ class DatasetBase(Resource, Base): expiryMaxDuration = Column(Integer, nullable=True) __mapper_args__ = {'polymorphic_identity': 'dataset', 'polymorphic_on': datasetType} + @classmethod + def uri_column(cls): + return cls.datasetUri + def owner_name(self): return self.SamlAdminGroupName diff --git a/backend/dataall/modules/redshift_datasets/db/redshift_models.py b/backend/dataall/modules/redshift_datasets/db/redshift_models.py index 683e01693..af5d98881 100644 --- a/backend/dataall/modules/redshift_datasets/db/redshift_models.py +++ b/backend/dataall/modules/redshift_datasets/db/redshift_models.py @@ -39,5 +39,5 @@ class RedshiftTable(Base, Resource): topics = Column(ARRAY(String), nullable=True) @classmethod - def uri(cls): + def uri_column(cls): return cls.rsTableUri diff --git a/backend/dataall/modules/s3_datasets/db/dataset_models.py b/backend/dataall/modules/s3_datasets/db/dataset_models.py index 8835da2eb..bfb445f79 100644 --- a/backend/dataall/modules/s3_datasets/db/dataset_models.py +++ b/backend/dataall/modules/s3_datasets/db/dataset_models.py @@ -21,7 +21,7 @@ class DatasetTableColumn(Resource, Base): columnType = Column(String, default='column') # can be either "column" or "partition" @classmethod - def uri(cls): + def uri_column(cls): return cls.columnUri @@ -63,6 +63,10 @@ def entity_name(self): def uri(self): return self.locationUri + @classmethod + def uri_column(cls): + return cls.locationUri + class DatasetTable(Resource, Base): __metaclass__ = MetadataFormEntity @@ -95,6 +99,10 @@ def entity_name(self): def uri(self): return self.tableUri + @classmethod + def uri_column(cls): + return cls.tableUri + class S3Dataset(DatasetBase): __tablename__ = 's3_dataset' @@ -156,6 +164,10 @@ def entity_name(self): def uri(self): return self.bucketUri + @classmethod + def uri_column(cls): + return cls.bucketUri + class DatasetTableDataFilter(Resource, Base): __tablename__ = 'data_filter' diff --git a/backend/migrations/versions/797dd1012be1_resource_lock_table.py b/backend/migrations/versions/797dd1012be1_resource_lock_table.py index de5f27351..1416756a9 100644 --- a/backend/migrations/versions/797dd1012be1_resource_lock_table.py +++ b/backend/migrations/versions/797dd1012be1_resource_lock_table.py @@ -62,7 +62,7 @@ class DatasetLock(Base): acquiredBy = Column(String, nullable=True) @classmethod - def uri(cls): + def uri_column(cls): return cls.datasetUri diff --git a/backend/migrations/versions/8c79fb896983_add_table_for_buckets.py b/backend/migrations/versions/8c79fb896983_add_table_for_buckets.py index 2f93cb5ea..66f0924cc 100644 --- a/backend/migrations/versions/8c79fb896983_add_table_for_buckets.py +++ b/backend/migrations/versions/8c79fb896983_add_table_for_buckets.py @@ -101,7 +101,7 @@ class DatasetBucket(Resource, Base): environmentEndPoint = query_expression() @classmethod - def uri(cls): + def uri_column(cls): return cls.bucketUri diff --git a/backend/migrations/versions/a1049d854e29_implement_dataset_locking_mechanism.py b/backend/migrations/versions/a1049d854e29_implement_dataset_locking_mechanism.py index 5f3c17831..ffe149a56 100644 --- a/backend/migrations/versions/a1049d854e29_implement_dataset_locking_mechanism.py +++ b/backend/migrations/versions/a1049d854e29_implement_dataset_locking_mechanism.py @@ -88,7 +88,7 @@ class DatasetLock(Base): acquiredBy = Column(String, nullable=True) @classmethod - def uri(cls): + def uri_column(cls): return cls.datasetUri diff --git a/frontend/src/modules/Metadata_Forms/components/metadataAttachment.js b/frontend/src/modules/Metadata_Forms/components/metadataAttachment.js index 3b98c2a00..97f49b3ed 100644 --- a/frontend/src/modules/Metadata_Forms/components/metadataAttachment.js +++ b/frontend/src/modules/Metadata_Forms/components/metadataAttachment.js @@ -237,7 +237,6 @@ export const MetadataAttachment = (props) => { { if (value) { setSelectedForm(value.form);