Skip to content
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

HIVE-25468: Create/Drop functions are authorized in HMS #2595

Closed

Conversation

saihemanth-cloudera
Copy link
Contributor

What changes were proposed in this pull request?

Created authorizable events for create and drop function commands in HMS.

Why are the changes needed?

This addresses the security issue in HMS.

Does this PR introduce any user-facing change?

Yeah, respective policies should be added in ranger/sentry

How was this patch tested?

Local machine, and remote cluster.

try {
func.setOwnerName(SecurityUtils.getUGI().getShortUserName());
} catch (Exception ex) {
LOG.error("Cannot obtain username", ex);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please improve this error message. If I look at this error message in vaccum, it does not indicate where it occurred.

public class CreateFunctionEvent extends HiveMetaStoreAuthorizableEvent {
private static final Logger LOG = LoggerFactory.getLogger(CreateFunctionEvent.class);

private String COMMAND_STR = "create function";
Copy link
Contributor

Choose a reason for hiding this comment

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

static final ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other events related to the database and table are also using the static final LOG variable, so I thought I would follow the same.

Function function = event.getFunction();
List<ResourceUri> uris = function.getResourceUris();
ret.add(new HivePrivilegeObject(HivePrivilegeObject.HivePrivilegeObjectType.FUNCTION, function.getDbName(), function.getFunctionName(), null,
null, HivePrivilegeObject.HivePrivObjectActionType.OTHER, null, function.getClassName(), function.getOwnerName(), function.getOwnerType()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Dont we need to check the DELETE permissions for the functions here? Shouldnt the ActionType be HivePrivilegeObject.HivePrivObjectActionType.DELETE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to send HivePrivilegeObject.HivePrivObjectActionType as OTHER since Ranger is expecting OTHER as action type. If the action type is other, Ranger would check HivePrivilege Object type and do the required action.

public class DropFunctionEvent extends HiveMetaStoreAuthorizableEvent {
private static final Logger LOG = LoggerFactory.getLogger(DropFunctionEvent.class);

private String COMMAND_STR = "drop function";
Copy link
Contributor

Choose a reason for hiding this comment

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

static final ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other events related to the database and table are also using the static final LOG variable, so I thought I would follow the same.

Copy link
Contributor

@nrg4878 nrg4878 left a comment

Choose a reason for hiding this comment

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

Changes look good to me. +1

@nrg4878
Copy link
Contributor

nrg4878 commented Sep 13, 2021

Fix has been committed to master. Please close the PR and the jira.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants