Skip to content

Commit 1ae371e

Browse files
committed
Update necessary permissions
1 parent 801e6ba commit 1ae371e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,20 @@ final class TikaImpl {
9494
private static final AutoDetectParser PARSER_INSTANCE = new AutoDetectParser(PARSERS);
9595

9696
/** singleton tika instance */
97-
private static final Tika TIKA_INSTANCE = new Tika(PARSER_INSTANCE.getDetector(), PARSER_INSTANCE);
97+
private static final Tika TIKA_INSTANCE = getTikaInstance();
98+
99+
private static Tika getTikaInstance() {
100+
SpecialPermission.check();
101+
try {
102+
return AccessController.doPrivileged((PrivilegedExceptionAction<Tika>)
103+
() -> new Tika(PARSER_INSTANCE.getDetector(), PARSER_INSTANCE));
104+
} catch (PrivilegedActionException e) {
105+
throw new RuntimeException(e.getCause());
106+
}
107+
}
98108

99109
/**
110+
*
100111
* parses with tika, throwing any exception hit while parsing the document
101112
*/
102113
static String parse(final byte content[], final Metadata metadata, final int limit) throws TikaException, IOException {
@@ -122,7 +133,7 @@ static String parse(final byte content[], final Metadata metadata, final int lim
122133
// apply additional containment for parsers, this is intersected with the current permissions
123134
// its hairy, but worth it so we don't have some XML flaw reading random crap from the FS
124135
private static final AccessControlContext RESTRICTED_CONTEXT = new AccessControlContext(
125-
new ProtectionDomain[] {
136+
new ProtectionDomain[]{
126137
new ProtectionDomain(null, getRestrictedPermissions())
127138
}
128139
);

plugins/ingest-attachment/src/main/plugin-metadata/plugin-security.policy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ grant {
3333
permission java.lang.RuntimePermission "accessDeclaredMembers";
3434
// PDFBox checks for the existence of this class
3535
permission java.lang.RuntimePermission "accessClassInPackage.sun.java2d.cmm.kcms";
36+
// TODO: Remove once https://issues.apache.org/jira/browse/TIKA-2731 is resolved
37+
permission java.util.PropertyPermission "*", "read,write";
3638
};

0 commit comments

Comments
 (0)