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

Regenerate Implementation Layer with Interface Scoping Changes #17368

Closed
11 tasks done
alzimmermsft opened this issue Nov 9, 2020 · 1 comment · Fixed by #28575
Closed
11 tasks done

Regenerate Implementation Layer with Interface Scoping Changes #17368

alzimmermsft opened this issue Nov 9, 2020 · 1 comment · Fixed by #28575
Labels
Client This issue points to a problem in the data-plane of the library. common common module used by all azure SDKs (e.g. client, Mgmt) Epic

Comments

@alzimmermsft
Copy link
Member

alzimmermsft commented Nov 9, 2020

When an application uses SecurityManager there us the possibility that RestProxy would throw an exception when instantiating a client. This is thrown when ReflectPermission isn't given to the implementation interface and the interface isn't publicly scoped. Given that, by default, the implementation interface is generated in the implementation package this could be made public preventing the chance for this issue being thrown. The latest versions of AutoRest has been updated to generate the implementation interface as public preventing this issue from happening by configuring the following:

service-interface-as-public: true

Perform the following to test and verify whether your clients are affected by the issue, if they are you'll need to regenerate with the newest code generator.

  1. Create a policy file with this configuration:
grant {
  permission java.util.PropertyPermission "*", "read";
  permission java.lang.RuntimePermission "getenv.*";
};
  1. Build a test application that creates every client in your package. Note: Use a mock HttpClient, all that needs to be done is the client being built.
  2. Run the test application with SecurityManager turned on. Pass -Djava.security.manager and -Djava.security.policy=<location of the policy file you created>.
  3. Create a test application which performs the following:
private static final HttpClient FAKE_HTTP_CLIENT = request -> Mono.empty();

public static void main(String[] args) {
    // For each async service client in the SDK create an instance of it using the fake HttpClient.
    // The following example is using azure-storage-blob.
    BlobServiceAsyncClient blobServiceAsyncClient = new BlobServiceClientBuilder()
        .connectionString(CONNECTION_STRING)
        .httpClient(FAKE_HTTP_CLIENT)
        .buildAsyncClient();
    
    BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuilder()
        .connectionString(CONNECTION_STRING)
        .containerName("container")
        .httpClient(FAKE_HTTP_CLIENT)
        .buildAsyncClient();
}
@alzimmermsft alzimmermsft added Client This issue points to a problem in the data-plane of the library. common common module used by all azure SDKs (e.g. client, Mgmt) Epic labels Nov 9, 2020
rjernst added a commit to fcofdez/elasticsearch that referenced this issue Dec 2, 2020
The azure sdk internally dynamically constructs its client classes.
However, one of these, for the blob storage is private. This has been
fixed upstream, but until that is released, the client is unuseable
without the newProxyInPackage permission. Rather than grant that
permission, this commit makes the class in question public by patching
the azure class file when building the azure repository plugin.

relates Azure/azure-sdk-for-java#17368
@vcolin7
Copy link
Member

vcolin7 commented Feb 6, 2021

It's important to mention that to make interfaces public you need to add service-interface-as-public: true to the markdown file used for auto-rest generation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. common common module used by all azure SDKs (e.g. client, Mgmt) Epic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants