HDFS-17980. Propagate Rename.TO_TRASH in authorization context for external enforcers. - #8741
sadanand48 wants to merge 3 commits into
Conversation
…ternal enforcers.
|
🎊 +1 overall
This message was automatically generated. |
jojochuang
left a comment
There was a problem hiding this comment.
looks good just some nits
| operationType.set(opType); | ||
| } | ||
|
|
||
| public static void setRenameToTrash(boolean value) { |
There was a problem hiding this comment.
please add javadoc to explain what this flag mean.
| } finally { | ||
| FSPermissionChecker.setRenameToTrash(false); |
Sorry, didn't get this point. For the external authorization plugins, is it enough to use operation name and src/dest path? How will Ranger use this rename options. Thanks. |
This is mainly for compliance tracking in Ranger Audits as when trash is enabled rm and mv operations look identical . |
|
💔 -1 overall
This message was automatically generated. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Description of PR
When HDFS Trash is enabled, rm is executed as an internal rename to .Trash using Options.Rename.TO_TRASH.
Today, external authorization plugins (for example Ranger via checkPermissionWithContext) receive operationName=rename, but do not get an explicit trash-intent signal. As a result, rm (to trash) and mv appear identical from authorization/audit context.
This JIRA proposes adding and propagating a dedicated context flag (for example renameToTrash) in INodeAttributeProvider.AuthorizationContext so external enforcers can distinguish:
rm with trash enabled -> operationName=rename, renameToTrash=true
mv -> operationName=rename, renameToTrash=false
rm skipTrash > operationName=delete
Scope (HDFS side)
Add renameToTrash field to AuthorizationContext and its builder/accessors.
Propagate the flag through FSPermissionChecker when building context for checkPermissionWithContext.
In FSNamesystem.renameTo(..., Options.Rename... options), set the flag based on presence of Options.Rename.TO_TRASH, and clear it in finally to avoid ThreadLocal leakage.
How was this patch tested?
Unit tests
For code changes:
declared according to the connector-specific documentation? Note: Automated CI
testing doesn't cover all cases so manual testing with cloud storage is still
required.
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
If an AI tool was used:
where is the name of the AI tool used.
https://www.apache.org/legal/generative-tooling.html