HDFS-8037. CheckAccess in WebHDFS silently accepts malformed FsActions parameters. Contributed by Walter Su.

This commit is contained in:
Haohui Mai 2015-05-07 15:25:26 -07:00
parent f6b908ab07
commit a3abe8d7e4
4 changed files with 60 additions and 3 deletions

View File

@ -30,7 +30,7 @@ public class FsActionParam extends StringParam {
/** Default parameter value. */ /** Default parameter value. */
public static final String DEFAULT = NULL; public static final String DEFAULT = NULL;
private static String FS_ACTION_PATTERN = "[rwx-]{3}"; private static String FS_ACTION_PATTERN = "[r-][w-][x-]";
private static final Domain DOMAIN = new Domain(NAME, private static final Domain DOMAIN = new Domain(NAME,
Pattern.compile(FS_ACTION_PATTERN)); Pattern.compile(FS_ACTION_PATTERN));

View File

@ -324,6 +324,9 @@ Release 2.8.0 - UNRELEASED
HDFS-8321. CacheDirectives and CachePool operations should throw HDFS-8321. CacheDirectives and CachePool operations should throw
RetriableException in safemode. (wheat9) RetriableException in safemode. (wheat9)
HDFS-8037. CheckAccess in WebHDFS silently accepts malformed FsActions
parameters. (wheat9)
Release 2.7.1 - UNRELEASED Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1690,8 +1690,8 @@ See also: [Proxy Users](#Proxy_Users)
| Description | File system operation read/write/execute | | Description | File system operation read/write/execute |
| Type | String | | Type | String |
| Default Value | null (an invalid value) | | Default Value | null (an invalid value) |
| Valid Values | Strings matching regex pattern  "[rwx-]{3} " | | Valid Values | Strings matching regex pattern  "[r-][w-][x-] " |
| Syntax |  "[rwx-]{3} " | | Syntax |  "[r-][w-][x-] " |
See also: [`CHECKACCESS`](#Check_access), See also: [`CHECKACCESS`](#Check_access),

View File

@ -399,4 +399,58 @@ public class TestParam {
Assert.assertEquals("s1", s1.getValue()); Assert.assertEquals("s1", s1.getValue());
Assert.assertEquals("s2", s2.getValue()); Assert.assertEquals("s2", s2.getValue());
} }
@Test
public void testFsActionParam() {
new FsActionParam("rwx");
new FsActionParam("rw-");
new FsActionParam("r-x");
new FsActionParam("-wx");
new FsActionParam("r--");
new FsActionParam("-w-");
new FsActionParam("--x");
new FsActionParam("---");
try {
new FsActionParam("rw");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
try {
new FsActionParam("qwx");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
try {
new FsActionParam("qrwx");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
try {
new FsActionParam("rwxx");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
try {
new FsActionParam("xwr");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
try {
new FsActionParam("r-w");
Assert.fail();
} catch(IllegalArgumentException e) {
LOG.info("EXPECTED: " + e);
}
}
} }