From 738bf63f128e2fca217e095c67ee56029142ceb3 Mon Sep 17 00:00:00 2001 From: anoopsjohn Date: Sun, 6 Jul 2014 19:17:17 +0530 Subject: [PATCH] HBASE-11465 [VisibilityController] Reserved tags check not happening for Append/Increment. (Anoop) --- .../visibility/VisibilityController.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java index 4501c0be9d3..9cd21d8d555 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java @@ -57,8 +57,10 @@ import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.MetaTableAccessor; +import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; +import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; @@ -75,6 +77,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.RegionObserver; import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment; import org.apache.hadoop.hbase.exceptions.DeserializationException; +import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException; import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.FilterBase; import org.apache.hadoop.hbase.filter.FilterList; @@ -1193,6 +1196,28 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb return this.superUsers.contains(activeUser.getShortName()); } + @Override + public Result preAppend(ObserverContext e, Append append) + throws IOException { + for (CellScanner cellScanner = append.cellScanner(); cellScanner.advance();) { + if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { + throw new FailedSanityCheckException("Append contains cell with reserved type tag"); + } + } + return null; + } + + @Override + public Result preIncrement(ObserverContext e, Increment increment) + throws IOException { + for (CellScanner cellScanner = increment.cellScanner(); cellScanner.advance();) { + if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { + throw new FailedSanityCheckException("Increment contains cell with reserved type tag"); + } + } + return null; + } + @Override public Cell postMutationBeforeWAL(ObserverContext ctx, MutationType opType, Mutation mutation, Cell oldCell, Cell newCell) throws IOException {