Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-library/pull/33#discussion_r62298938
  
    --- Diff: 
software/database/src/main/java/org/apache/brooklyn/entity/database/postgresql/PostgreSqlSshDriver.java
 ---
    @@ -328,9 +340,39 @@ private void initializeNewDatabase() {
                             " --command="+ createUserCommand),
                     sudoAsUser("postgres", getInstallDir() + "/bin/psql -p " + 
entity.getAttribute(PostgreSqlNode.POSTGRESQL_PORT) + 
                                     " --command="+ createDatabaseCommand),
    +                createRolesAdditionalCommand,
                     callPgctl("stop", true))
                     .failOnNonZeroResultCode().execute();
         }
    +
    +    private String buildCreateRolesQuery() {
    +        Map<String, Map> roles = entity.getConfig(PostgreSqlNode.ROLES);
    +        String createRolesQuery = "\"";
    +
    +        for (Map.Entry role: roles.entrySet()) {
    +            createRolesQuery = 
createRolesQuery.concat(String.format("CREATE ROLE %s", role.getKey()));
    --- End diff --
    
    Actually I'm not sure you're going to be able to use prepared statements 
with DDL like CREATE ROLE, at least not with Postgres.  (Worth a look to see 
whether it's supported anyway.)  At the very least, as Thomas says, you should 
be validating the input before using it in a statement.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to