morrySnow commented on code in PR #32137: URL: https://github.com/apache/doris/pull/32137#discussion_r1525740614
########## fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/ranger/RangerAccessController.java: ########## @@ -74,4 +86,70 @@ public static void checkRequestResults(Collection<RangerAccessResult> results, S } } } + + @Override + public List<? extends RowFilterPolicy> evalRowFilterPolicies(UserIdentity currentUser, String ctl, String db, + String tbl) { + RangerAccessResourceImpl resource = createResource(ctl, db, tbl); + RangerAccessRequestImpl request = createRequest(currentUser); + request.setResource(resource); + + if (LOG.isDebugEnabled()) { + LOG.debug("ranger request: {}", request); + } + List<RangerRowFilterPolicy> res = Lists.newArrayList(); + RangerAccessResult policy = getPlugin().evalRowFilterPolicies(request, getAccessResultProcessor()); + if (LOG.isDebugEnabled()) { + LOG.debug("ranger response: {}", policy); + } + if (policy == null) { + return res; + } + String filterExpr = policy.getFilterExpr(); + if (StringUtils.isEmpty(filterExpr)) { + return res; + } + res.add(new RangerRowFilterPolicy(currentUser, ctl, db, tbl, policy.getPolicyId(), policy.getPolicyVersion(), + filterExpr)); + return res; + } + + @Override + public Optional<DataMaskPolicy> evalDataMaskPolicy(UserIdentity currentUser, String ctl, String db, String tbl, + String col) { + RangerAccessResourceImpl resource = createResource(ctl, db, tbl, col); + RangerAccessRequestImpl request = createRequest(currentUser); + request.setResource(resource); + + if (LOG.isDebugEnabled()) { + LOG.debug("ranger request: {}", request); + } + RangerAccessResult policy = getPlugin().evalDataMaskPolicies(request, getAccessResultProcessor()); + if (LOG.isDebugEnabled()) { + LOG.debug("ranger response: {}", policy); + } + if (policy == null) { + return Optional.empty(); + } + String maskType = policy.getMaskType(); + if (StringUtils.isEmpty(maskType)) { + return Optional.empty(); + } + String transformer = policy.getMaskTypeDef().getTransformer(); + if (StringUtils.isEmpty(transformer)) { + return Optional.empty(); + } + return Optional.of(new RangerDataMaskPolicy(currentUser, ctl, db, tbl, col, policy.getPolicyId(), + policy.getPolicyVersion(), maskType, transformer.replace("{col}", col))); Review Comment: should not just replace by col, u should call `org.apache.doris.nereids.util.Utils#quoteIfNeeded` and wrap it by ` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org