forked from apache/atlas
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DQ-22: Data contract PreProcessor #2937
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
27285ad
Add DataContract preprocessor and versioning
bichitra95 5c53ca1
Refactore contract code and release
bichitra95 94d98db
Add unknown attributes to DataContract and fix minor bugs
bichitra95 d64e969
Add attribute hasContract for assets
bichitra95 6ee00aa
Add validation of data contract spec
bichitra95 c79dfa0
Fix audit logs for associated asset
bichitra95 723286a
Update dataset spec structure
bichitra95 3e6f1b2
Minor bug fix
bichitra95 f69d6f6
Refactor with new attributes
bichitra95 3e75d0f
Fix order of attributes in contract and change dataContractVersion to…
bichitra95 2e30f63
Add bootstrap policy for DataContract CRU
bichitra95 32104e9
Fix qualifiedName of the contract
bichitra95 8185bfe
Add asset guid in DataContract asset and minor fixes
bichitra95 e863c13
Inconsistency in relationship fixed for data contract<>asset
bichitra95 2971520
Removed maven release for data-contract branch
bichitra95 4cd524d
Change datasource to data_source in DataContract
bichitra95 8ed00b3
Merge create and update AuthPolicy for DataContract
bichitra95 5434342
Update DataContract attributes from public to private and create gett…
bichitra95 09c500a
Add setter for private attributes and formatted the file
bichitra95 d78cdc1
Address PR review changes
bichitra95 9779ffe
Address code review comments
bichitra95 191b447
Remove redundant code/arguments in contract preprocessor
bichitra95 9f26e46
Add remove user added relationship to control relationship update
bichitra95 418a8cf
Ignoring null value fields
bichitra95 fb0ee62
Upgrade validator version to avoid vulnerability
bichitra95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...e/atlas/repository/store/graph/v2/preprocessor/contract/AbstractContractPreProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package org.apache.atlas.repository.store.graph.v2.preprocessor.contract; | ||
|
||
import org.apache.atlas.RequestContext; | ||
import org.apache.atlas.authorize.AtlasAuthorizationUtils; | ||
import org.apache.atlas.authorize.AtlasEntityAccessRequest; | ||
import org.apache.atlas.authorize.AtlasPrivilege; | ||
import org.apache.atlas.exception.AtlasBaseException; | ||
import org.apache.atlas.model.TypeCategory; | ||
import org.apache.atlas.model.instance.AtlasEntity; | ||
import org.apache.atlas.model.instance.AtlasEntityHeader; | ||
import org.apache.atlas.repository.graphdb.AtlasGraph; | ||
import org.apache.atlas.repository.graphdb.AtlasVertex; | ||
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; | ||
import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; | ||
import org.apache.atlas.repository.store.graph.v2.preprocessor.PreProcessor; | ||
import org.apache.atlas.type.AtlasEntityType; | ||
import org.apache.atlas.type.AtlasTypeRegistry; | ||
import org.apache.atlas.utils.AtlasPerfMetrics; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.apache.atlas.AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND; | ||
import static org.apache.atlas.AtlasErrorCode.TYPE_NAME_INVALID; | ||
import static org.apache.atlas.repository.Constants.*; | ||
|
||
public abstract class AbstractContractPreProcessor implements PreProcessor { | ||
private static final Logger LOG = LoggerFactory.getLogger(AbstractContractPreProcessor.class); | ||
|
||
public final AtlasTypeRegistry typeRegistry; | ||
public final EntityGraphRetriever entityRetriever; | ||
public final AtlasGraph graph; | ||
|
||
|
||
AbstractContractPreProcessor(AtlasGraph graph, AtlasTypeRegistry typeRegistry, | ||
EntityGraphRetriever entityRetriever) { | ||
this.graph = graph; | ||
this.typeRegistry = typeRegistry; | ||
this.entityRetriever = entityRetriever; | ||
} | ||
|
||
void authorizeContractCreateOrUpdate(AtlasEntity contractEntity, AtlasEntity.AtlasEntityWithExtInfo associatedAsset) throws AtlasBaseException { | ||
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("authorizeContractUpdate"); | ||
try { | ||
AtlasEntityHeader entityHeader = new AtlasEntityHeader(associatedAsset.getEntity()); | ||
|
||
//First authorize entity update access | ||
verifyAssetAccess(entityHeader, AtlasPrivilege.ENTITY_UPDATE, contractEntity, AtlasPrivilege.ENTITY_UPDATE); | ||
|
||
} finally { | ||
RequestContext.get().endMetricRecord(metricRecorder); | ||
} | ||
} | ||
|
||
|
||
private void verifyAssetAccess(AtlasEntityHeader asset, AtlasPrivilege assetPrivilege, | ||
AtlasEntity contract, AtlasPrivilege contractPrivilege) throws AtlasBaseException { | ||
verifyAccess(asset, assetPrivilege); | ||
verifyAccess(contract, contractPrivilege); | ||
} | ||
|
||
private void verifyAccess(AtlasEntity entity, AtlasPrivilege privilege) throws AtlasBaseException { | ||
verifyAccess(new AtlasEntityHeader(entity), privilege); | ||
} | ||
|
||
private void verifyAccess(AtlasEntityHeader entityHeader, AtlasPrivilege privilege) throws AtlasBaseException { | ||
String errorMessage = privilege.name() + " entity: " + entityHeader.getTypeName(); | ||
AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, privilege, entityHeader), errorMessage); | ||
} | ||
|
||
AtlasEntity.AtlasEntityWithExtInfo getAssociatedAsset(String datasetQName, String typeName) throws AtlasBaseException { | ||
|
||
Map<String, Object> uniqAttributes = new HashMap<>(); | ||
uniqAttributes.put(QUALIFIED_NAME, datasetQName); | ||
|
||
AtlasEntityType entityType = ensureEntityType(typeName); | ||
|
||
AtlasVertex entityVertex = AtlasGraphUtilsV2.getVertexByUniqueAttributes(graph, entityType, uniqAttributes); | ||
|
||
return entityRetriever.toAtlasEntityWithExtInfo(entityVertex); | ||
} | ||
|
||
AtlasEntityType ensureEntityType(String typeName) throws AtlasBaseException { | ||
AtlasEntityType ret = typeRegistry.getEntityTypeByName(typeName); | ||
|
||
if (ret == null) { | ||
throw new AtlasBaseException(TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), typeName); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got a CVE of severity medium here! please fix it. Can't let it to be a backlog
https://github.com/atlanhq/atlas-metastore/actions/runs/8890490131
Check how difficult it is to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically dependency review is failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GHSA-845h-985r-jrqh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, I tried with the latest version for Java 8 supported https://central.sonatype.com/artifact/org.hibernate.validator/hibernate-validator/6.2.5.Final
This is not working as the repository/gorupId got changed from
org.hibernate
toorg.hibernate.validator
which is why the validator is not working (possible issue might be due to conflict in dependency).I have limited knowledge of how dependency works in Java. If you can help debug further, I am happy to jump on an call and solve this.