You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/08/24 17:16:28 UTC

[GitHub] [druid] abhishekagarwal87 opened a new pull request, #12959: Improve error message

abhishekagarwal87 opened a new pull request, #12959:
URL: https://github.com/apache/druid/pull/12959

   Few Misc changes
    - We include the resource info in the error message that the user is trying to access. A query can touch many resources at the same time - table, context parameters, etc. it will be useful to fix the query if user knows precisely what they are not allowed to.  
    - If the task completes with zero rows, we now treat it as an ingestion failure. Its almost always a result of misconfiguration and results in confusion. 
    - If time could not be parsed for any row, we get zero intervals in reports. For that too, we return a task fail result with an actionable error message. 
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] LakshSingla commented on a diff in pull request #12959: Improve error message

Posted by GitBox <gi...@apache.org>.
LakshSingla commented on code in PR #12959:
URL: https://github.com/apache/druid/pull/12959#discussion_r954104824


##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authorization/BasicRoleBasedAuthorizer.java:
##########
@@ -90,7 +94,11 @@ public Access authorize(AuthenticationResult authenticationResult, Resource reso
     Map<String, BasicAuthorizerRole> roleMap = roleProvider.getRoleMap(name);
 
     if (roleNames.isEmpty()) {
-      return new Access(false);
+      LOG.info("No roles found for authorizer [%s] and user [%s]", name, authenticationResult.getIdentity());
+      return new Access(false, StringUtils.format("You don't have '%s' permission for Resource [%s:%s]",
+          action.name(),
+          resource.getType(),
+          resource.getName()));

Review Comment:
   Is it safe to expose the name of the resource to the end user?
   If the error message when a resource doesn't exist versus when a resource exists but the user is not authorized to access it is not the same, might lead to the user knowing which resources are present in the cluster.
   
   Edit: From the test case, and it seems like we are returning the same error message for both the scenarios, so I think it should be cool to expose the resource name to the user. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] paul-rogers commented on pull request #12959: Improve error message

Posted by GitBox <gi...@apache.org>.
paul-rogers commented on PR #12959:
URL: https://github.com/apache/druid/pull/12959#issuecomment-1226218365

   Because of a recent Travis change that introduced a "silent" merge conflict, you will need to rebase this PR on the latest master to pick up the newest Travis file.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] LakshSingla commented on a diff in pull request #12959: Improve error message

Posted by GitBox <gi...@apache.org>.
LakshSingla commented on code in PR #12959:
URL: https://github.com/apache/druid/pull/12959#discussion_r954116699


##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authorization/BasicRoleBasedAuthorizer.java:
##########
@@ -106,8 +114,16 @@ public Access authorize(AuthenticationResult authenticationResult, Resource reso
         }
       }
     }
-
-    return new Access(false);
+    LOG.info("User [%s] is not allowed to [%s] the resource [%s:%s]",

Review Comment:
   ```suggestion
       LOG.info("User [%s] does not have [%s] permission for the resource [%s:%s]",
   ```
   nit: Making the log consistent with the error message 



##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authorization/BasicRoleBasedAuthorizer.java:
##########
@@ -90,7 +94,11 @@ public Access authorize(AuthenticationResult authenticationResult, Resource reso
     Map<String, BasicAuthorizerRole> roleMap = roleProvider.getRoleMap(name);
 
     if (roleNames.isEmpty()) {
-      return new Access(false);
+      LOG.info("No roles found for authorizer [%s] and user [%s]", name, authenticationResult.getIdentity());
+      return new Access(false, StringUtils.format("You don't have '%s' permission for Resource [%s:%s]",
+          action.name(),
+          resource.getType(),
+          resource.getName()));

Review Comment:
   Is it safe to expose the name of the resource to the end user?
   If the error message when a resource doesn't exist versus when a resource exists but the user is not authorized to access it is not the same, might lead to the user knowing which resources are present in the cluster. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Improve error message (druid)

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 closed pull request #12959: Improve error message 
URL: https://github.com/apache/druid/pull/12959


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 commented on a diff in pull request #12959: Improve error message

Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #12959:
URL: https://github.com/apache/druid/pull/12959#discussion_r955931030


##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authorization/BasicRoleBasedAuthorizer.java:
##########
@@ -90,7 +94,11 @@ public Access authorize(AuthenticationResult authenticationResult, Resource reso
     Map<String, BasicAuthorizerRole> roleMap = roleProvider.getRoleMap(name);
 
     if (roleNames.isEmpty()) {
-      return new Access(false);
+      LOG.info("No roles found for authorizer [%s] and user [%s]", name, authenticationResult.getIdentity());
+      return new Access(false, StringUtils.format("You don't have '%s' permission for Resource [%s:%s]",
+          action.name(),
+          resource.getType(),
+          resource.getName()));

Review Comment:
   The PR doesn't change the error code in any way. We are appending the information to the error. I think it is safe to expose the name of the resource that they are trying to access. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org