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

NPE on access control list permissions check #69

Open
codemariner opened this issue Mar 11, 2017 · 2 comments
Open

NPE on access control list permissions check #69

codemariner opened this issue Mar 11, 2017 · 2 comments

Comments

@codemariner
Copy link

Checking for readable, like:

Files.isReadable(path);

results in a NPE. The problem is that the owner is not always populated here

    private boolean hasPermission(EnumSet<Permission> permissions) {
        for (Grant grant : acl.getGrants())
            if (grant.getGrantee().getIdentifier().equals(owner.getId()) && permissions.contains(grant.getPermission()))
                return true;
        return false;
    }
@jarnaiz
Copy link
Member

jarnaiz commented Mar 20, 2017

Hi @codemariner,

First of all, thanks for the feedback :)

When the owner is not populated? I added some tests in version 1.5.3 and I couldnt reproduce it. If you can attach some tests or give me more context, I will try to investigate it and add some checks.

Thanks!

@pradeepcunde
Copy link

pradeepcunde commented Dec 18, 2018

Even I am facing NPE in the same way. This happened when I am using minio as S3 simulator that does not support ACLs. Because of this the Owner gets populated with null id and null name when a call to GET /minio-test/?acl is made. The response for this http call is <AccessControlPolicy><Owner><ID></ID><DisplayName></DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><Type>CanonicalUser</Type></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>[\r][\n].
In the following code in S3AccessControlList class we get NPE at line marked with ** below.

`private boolean hasPermission(EnumSet permissions) {
Iterator var2 = this.acl.getGrantsAsList().iterator();

    Grant grant;
    do {
        if (!var2.hasNext()) {
            return false;
        }

        grant = (Grant)var2.next();
    **} while(!grant.getGrantee().getIdentifier().equals(this.owner.getId()) || !permissions.contains(grant.getPermission()));`
    return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants