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

[BUG] Fix java.lang.SecurityException in repository-gcs plugin #10642

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Force merge with `only_expunge_deletes` honors max segment size ([#10036](https://github.com/opensearch-project/OpenSearch/pull/10036))
- Add the means to extract the contextual properties from HttpChannel, TcpCChannel and TrasportChannel without excessive typecasting ([#10562](https://github.com/opensearch-project/OpenSearch/pull/10562))
- [Remote Store] Add Remote Store backpressure rejection stats to `_nodes/stats` ([#10524](https://github.com/opensearch-project/OpenSearch/pull/10524))
- [BUG] Fix java.lang.SecurityException in repository-gcs plugin ([#10642](https://github.com/opensearch-project/OpenSearch/pull/10642))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ StorageOptions createStorageOptions(
}
storageOptionsBuilder.setCredentials(serviceAccountCredentials);
}
return storageOptionsBuilder.build();
return SocketAccess.doPrivilegedException(() -> storageOptionsBuilder.build());
reta marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.repositories.gcs;

import org.apache.logging.log4j.core.util.Throwables;
import org.opensearch.SpecialPermission;
import org.opensearch.common.CheckedRunnable;

Expand Down Expand Up @@ -71,4 +72,16 @@
throw (IOException) e.getCause();
}
}

public static <T> T doPrivilegedException(PrivilegedExceptionAction<T> operation) {
SpecialPermission.check();
try {
return AccessController.doPrivileged(operation);
} catch (PrivilegedActionException e) {
Throwables.rethrow(e.getCause());
assert false : "always throws";
return null;

Check warning on line 83 in plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/SocketAccess.java

View check run for this annotation

Codecov / codecov/patch

plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/SocketAccess.java#L80-L83

Added lines #L80 - L83 were not covered by tests
}
}

}
Loading