You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by rsafonseca <gi...@git.apache.org> on 2015/06/17 21:00:11 UTC

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

GitHub user rsafonseca opened a pull request:

    https://github.com/apache/cloudstack/pull/476

    Fix 2 findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRI…

    …NG warnings in ConfigurationManagerImpl.java

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rsafonseca/cloudstack findbugs81

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/476.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #476
    
----
commit e13f4914cfb1ae2916a978aa2dd194966f0a0578
Author: Rafael da Fonseca <rs...@gmail.com>
Date:   2015-06-17T18:59:43Z

    Fix 2 findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING warnings in ConfigurationManagerImpl.java

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by karuturi <gi...@git.apache.org>.
Github user karuturi commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/476#discussion_r32721772
  
    --- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---
    @@ -926,7 +926,7 @@ protected void checkIfPodIsDeletable(final long podId) {
                     dbName = "cloud";
                 }
     
    -            String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
    +            String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
     
                 if(tableName.equals("vm_instance")) {
                     selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
    --- End diff --
    
    wondering why are we even using a prepareStatement here (and doing a fix to satisfy findbugs). Why dont we use createStatement() and execute sql directly?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by karuturi <gi...@git.apache.org>.
Github user karuturi commented on the pull request:

    https://github.com/apache/cloudstack/pull/476#issuecomment-113126424
  
    @bhaisaab did travis CI run on the updated PR?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by karuturi <gi...@git.apache.org>.
Github user karuturi commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/476#discussion_r32710471
  
    --- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---
    @@ -926,7 +926,7 @@ protected void checkIfPodIsDeletable(final long podId) {
                     dbName = "cloud";
                 }
     
    -            String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
    +            String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
     
                 if(tableName.equals("vm_instance")) {
                     selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
    --- End diff --
    
    should we also move the state to a variable?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by karuturi <gi...@git.apache.org>.
Github user karuturi commented on the pull request:

    https://github.com/apache/cloudstack/pull/476#issuecomment-113129131
  
    @bhaisaab ignore my previous comment. looks like code change was in the other PR.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by rsafonseca <gi...@git.apache.org>.
Github user rsafonseca commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/476#discussion_r32715161
  
    --- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---
    @@ -926,7 +926,7 @@ protected void checkIfPodIsDeletable(final long podId) {
                     dbName = "cloud";
                 }
     
    -            String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
    +            String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
     
                 if(tableName.equals("vm_instance")) {
                     selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
    --- End diff --
    
    shouldn't be necessary :)
    findbugs is smart enough to check that the returned string is static and cannot be polluted by user input
    that's only not the case for other variables that it can't track the origin


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: Fix 2 findbugs SQL_PREPARED_STATEMENT_GEN...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cloudstack/pull/476


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---