You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "jongyoul (via GitHub)" <gi...@apache.org> on 2023/07/10 13:25:07 UTC

[GitHub] [zeppelin] jongyoul opened a new pull request, #4631: [HOTFIX] Check permission when updating cron information

jongyoul opened a new pull request, #4631:
URL: https://github.com/apache/zeppelin/pull/4631

   ### What is this PR for?
   Checking if the proper users have been set when updating note especially for corn information
   
   
   ### What type of PR is it?
   Hot Fix
   
   ### Todos
   * [x] - Add logic to check if Shiro is enabled in order to enable cron
   * [x] - Add validation logic when updating cron-related information
   
   ### What is the Jira issue?
   * N/A
   
   ### How should this be tested?
   * Improper cron users should be blocked
   
   ### Screenshots (if appropriate)
   
   ### Questions:
   * Does the license files need to update? No
   * Is there breaking changes for older versions? No
   * Does this needs documentation? Maybe - Will do it with another PR. 
   


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


Re: [PR] [HOTFIX] Check permission when updating cron information [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on code in PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#discussion_r1485532093


##########
zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java:
##########
@@ -879,17 +879,60 @@ public void updateNote(String noteId,
           return null;
         }
 
-        if (!(Boolean) note.getConfig().get("isZeppelinNotebookCronEnable")) {
+        if (!zConf.isZeppelinNotebookCronEnable()) {
+          boolean hasCronSettings = false;
           if (config.get("cron") != null) {
-            config.remove("cron");
+            LOGGER.warn("cron should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingUser") != null) {
+            LOGGER.warn("cronExecutingUser should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingRoles") != null) {
+            LOGGER.warn("cronExecutingRoles should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (hasCronSettings) {
+            callback.onFailure(new IllegalArgumentException("Wrong configs"), context);
+            return null;
+          }
+        } else {
+          String requestCronUser = (String) config.get("cronExecutingUser");
+          List<String> requestCronRoles = (List<String>) config.get("cronExecutingRoles");

Review Comment:
   Thank you for your suggestion. I'll adopt it.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] jongyoul commented on pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#issuecomment-1639103003

   @huage1994 Yep. Thank you. I'm also checking it but didn't fix it yet. Let me fix it soon.


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


Re: [PR] [HOTFIX] Check permission when updating cron information [zeppelin]

Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on code in PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#discussion_r1482545315


##########
zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java:
##########
@@ -879,17 +879,60 @@ public void updateNote(String noteId,
           return null;
         }
 
-        if (!(Boolean) note.getConfig().get("isZeppelinNotebookCronEnable")) {
+        if (!zConf.isZeppelinNotebookCronEnable()) {
+          boolean hasCronSettings = false;
           if (config.get("cron") != null) {
-            config.remove("cron");
+            LOGGER.warn("cron should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingUser") != null) {
+            LOGGER.warn("cronExecutingUser should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingRoles") != null) {
+            LOGGER.warn("cronExecutingRoles should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (hasCronSettings) {
+            callback.onFailure(new IllegalArgumentException("Wrong configs"), context);
+            return null;
+          }
+        } else {
+          String requestCronUser = (String) config.get("cronExecutingUser");
+          List<String> requestCronRoles = (List<String>) config.get("cronExecutingRoles");

Review Comment:
   I think the Set data structure would be appropriate here.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


Re: [PR] [HOTFIX] Check permission when updating cron information [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul merged PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] jongyoul commented on a diff in pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on code in PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#discussion_r1258447761


##########
zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java:
##########
@@ -871,17 +871,60 @@ public void updateNote(String noteId,
           return null;
         }
 
-        if (!(Boolean) note.getConfig().get("isZeppelinNotebookCronEnable")) {
+        if (!zConf.isZeppelinNotebookCronEnable()) {
+          boolean hasCronSettings = false;
           if (config.get("cron") != null) {
-            config.remove("cron");
+            LOGGER.warn("cron should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingUser") != null) {
+            LOGGER.warn("cronExecutingUser should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingRoles") != null) {
+            LOGGER.warn("cronExecutingRoles should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (hasCronSettings) {
+            callback.onFailure(new IllegalArgumentException("Wrong configs"), context);
+            return null;
+          }
+        } else {
+          String requestCronUser = (String) config.get("cronExecutingUser");
+          List<String> requestCronRoles = (List<String>) config.get("cronExecutingRoles");
+
+          if (!authorizationService.hasRunPermission(Collections.singleton(requestCronUser), note.getId())) {
+            LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+            callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+            return null;
+          } else {
+            // This part should be restarted but we need to prepare to notice who can be a cron user in advance
+            if (!context.getUserAndRoles().contains(requestCronUser)) {
+              LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+              callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+              return null;
+            }
+
+            if (context.getUserAndRoles().containsAll(requestCronRoles)) {

Review Comment:
   There was a report for illegal access and calls that the attackers can set corn-related things freely without any validation logic. This is a brute-force way to minimize the possibility. We should prepare the way for who can be a cron user for notes but before preparing the way, I think it should be set only by those who have run permissions and the roles.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


Re: [PR] [HOTFIX] Check permission when updating cron information [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#issuecomment-1938768243

   I made ci green at first


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] jongyoul commented on a diff in pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on code in PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#discussion_r1258448696


##########
zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java:
##########
@@ -871,17 +871,60 @@ public void updateNote(String noteId,
           return null;
         }
 
-        if (!(Boolean) note.getConfig().get("isZeppelinNotebookCronEnable")) {
+        if (!zConf.isZeppelinNotebookCronEnable()) {
+          boolean hasCronSettings = false;
           if (config.get("cron") != null) {
-            config.remove("cron");
+            LOGGER.warn("cron should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingUser") != null) {
+            LOGGER.warn("cronExecutingUser should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingRoles") != null) {
+            LOGGER.warn("cronExecutingRoles should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (hasCronSettings) {
+            callback.onFailure(new IllegalArgumentException("Wrong configs"), context);
+            return null;
+          }
+        } else {
+          String requestCronUser = (String) config.get("cronExecutingUser");
+          List<String> requestCronRoles = (List<String>) config.get("cronExecutingRoles");
+
+          if (!authorizationService.hasRunPermission(Collections.singleton(requestCronUser), note.getId())) {
+            LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+            callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+            return null;
+          } else {
+            // This part should be restarted but we need to prepare to notice who can be a cron user in advance
+            if (!context.getUserAndRoles().contains(requestCronUser)) {
+              LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+              callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+              return null;
+            }
+
+            if (context.getUserAndRoles().containsAll(requestCronRoles)) {

Review Comment:
   Oh... logic is wrong ;;;;



-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] jongyoul commented on pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#issuecomment-1628955221

   @zjffdu @Reamer @huage1994 This is a security feature. Please check this issue in a bit hurry. :-)


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] Reamer commented on a diff in pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on code in PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#discussion_r1258415612


##########
zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java:
##########
@@ -871,17 +871,60 @@ public void updateNote(String noteId,
           return null;
         }
 
-        if (!(Boolean) note.getConfig().get("isZeppelinNotebookCronEnable")) {
+        if (!zConf.isZeppelinNotebookCronEnable()) {
+          boolean hasCronSettings = false;
           if (config.get("cron") != null) {
-            config.remove("cron");
+            LOGGER.warn("cron should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingUser") != null) {
+            LOGGER.warn("cronExecutingUser should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (config.get("cronExecutingRoles") != null) {
+            LOGGER.warn("cronExecutingRoles should be null when cron is disabled");
+            hasCronSettings = true;
+          }
+          if (hasCronSettings) {
+            callback.onFailure(new IllegalArgumentException("Wrong configs"), context);
+            return null;
+          }
+        } else {
+          String requestCronUser = (String) config.get("cronExecutingUser");
+          List<String> requestCronRoles = (List<String>) config.get("cronExecutingRoles");
+
+          if (!authorizationService.hasRunPermission(Collections.singleton(requestCronUser), note.getId())) {
+            LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+            callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+            return null;
+          } else {
+            // This part should be restarted but we need to prepare to notice who can be a cron user in advance
+            if (!context.getUserAndRoles().contains(requestCronUser)) {
+              LOGGER.error("Wrong cronExecutingUser: {}", requestCronUser);
+              callback.onFailure(new IllegalArgumentException(requestCronUser), context);
+              return null;
+            }
+
+            if (context.getUserAndRoles().containsAll(requestCronRoles)) {

Review Comment:
   I don't quite understand this check. What is wrong with it?



##########
zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java:
##########
@@ -596,6 +596,10 @@ public String getShiroPath() {
     return new File(shiroPath).exists() ? shiroPath : StringUtils.EMPTY;
   }
 
+  public boolean isAuthenticationEnabled() {
+    return StringUtils.EMPTY != getShiroPath();

Review Comment:
   I think [StringUtils.isblank(...)](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isBlank-java.lang.CharSequence-) is better.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

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


[GitHub] [zeppelin] huage1994 commented on pull request #4631: [HOTFIX] Check permission when updating cron information

Posted by "huage1994 (via GitHub)" <gi...@apache.org>.
huage1994 commented on PR #4631:
URL: https://github.com/apache/zeppelin/pull/4631#issuecomment-1637762678

   The CI  error logs looks like to be related to this PR.
   ```
   Error:  Tests run: 38, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 229.767 s <<< FAILURE! - in org.apache.zeppelin.notebook.NotebookTest
   Error:  testSchedule  Time elapsed: 5.534 s  <<< FAILURE!
   org.opentest4j.AssertionFailedError: expected: not <null>
   	at org.apache.zeppelin.notebook.NotebookTest.testSchedule(NotebookTest.java:635)
   
   Error:  testScheduleDisabledWithName  Time elapsed: 60.538 s  <<< FAILURE!
   org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
   	at org.apache.zeppelin.notebook.NotebookTest.testScheduleDisabledWithName(NotebookTest.java:805)
   
   Error:  testSchedulePoolUsage  Time elapsed: 30.51 s  <<< FAILURE!
   org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
   	at org.apache.zeppelin.notebook.NotebookTest.testSchedulePoolUsage(NotebookTest.java:714)
   ```
   


-- 
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: reviews-unsubscribe@zeppelin.apache.org

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