Skip to content

Conversation

@ygjia
Copy link

@ygjia ygjia commented Sep 2, 2025

Why are the changes needed?

Close #7186

How was this patch tested?

Add new UTs and verified in a cluster with ranger hive spark service.

Was this patch authored or co-authored using generative AI tooling?

No

@ygjia
Copy link
Author

ygjia commented Sep 13, 2025

Kindly ping @pan3793 , I’ve added a Ranger policy to cover the RuleFunctionAuthorization tests. Ready for review~

@ygjia ygjia requested a review from pan3793 September 15, 2025 02:22
@ygjia
Copy link
Author

ygjia commented Sep 20, 2025

Kindly ping @pan3793 @bowenliang123 @packyan
Would you mind taking a look when convenient? Thank you!

@ygjia
Copy link
Author

ygjia commented Nov 25, 2025

Kindly ping @pan3793
Would you mind taking a look when convenient? Thank you!

@ygjia ygjia closed this Dec 1, 2025
@ygjia ygjia reopened this Dec 1, 2025
@pan3793
Copy link
Member

pan3793 commented Dec 1, 2025

cc @bowenliang123 and @wForget, do you have time to take a look?


override def apply(v1: SparkSessionExtensions): Unit = {
v1.injectCheckRule(AuthzConfigurationChecker)
v1.injectCheckRule(RuleFunctionAuthorization)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use injectOptimizerRule like RuleAuthorization? We should apply this rule after RuleApplyPermanentViewMarker to avoid checking functions in the view.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the injectOptimizerRule stage, some UDFs may be optimized away, which can prevent permission control. For example, in the SQL:

SELECT my_to_upper("AaaAe") AS col_upper, my_constant() AS col_constant;

Here, my_to_upper converts a string to uppercase, and my_constant returns a constant value. Using injectCheckRule, these two UDFs can be detected,

Project [HiveSimpleUDF#xxx.xxx.hive.custom.ToUpperCaseUDF(AaaAe) AS col_upper#4, HiveSimpleUDF#xxx.xxx.hive.custom.ConstantUDF() AS col_constant#5]
+- OneRowRelation
image

but during the injectOptimizerRule stage, they will be optimized to their resulting values.

Project [AAAAE AS col_upper#4, 10086 AS col_constant#5]
+- OneRowRelation
image

import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._

case class RuleFunctionAuthorization(spark: SparkSession) extends (LogicalPlan => Unit) {
override def apply(plan: LogicalPlan): Unit = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this rule configurable? It might not always be necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me add a config to make this rule configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask] [Authz] Introduce RuleFunctionAuthorization for persistent function calls authorization

3 participants