
Svajjarapu023153 (Community Member) asked a question.
Here is the SQL query hard coded and used the prepared statment dynamically to set the parameters, and add batch. Finally execute the batch.
Batch SQL execution already constructed with parameter queries and SQL is hard coded and no chance of external input in alter the query.
However, Veracode shows this two lines as flaws.
try{
private final String addUser = "insert into users(id, organization_id, username, autocopy, enabled) values (%s,%1$s,?,?,?)";
PreparedStatement psAddUser psAddUser = myConn.prepareStatement(addUser);
for (final UserAndOrgID nu : usersToAdd) {
final AegisUUID newidVal = AegisUUID.randomUUID();
DatabaseUtilities.setValue(psAddUser, 1, newidVal);
DatabaseUtilities.setValue(psAddUser, 2, nu.orgID);
psAddUser.setString(3, nu.name);
psAddUser.setNull(4, java.sql.Types.VARCHAR);
psAddUser.setBoolean(5, false);
psAddUser.setBoolean(6, true);
psAddUser.addBatch();
psAddWorkspace.setString(3, "default");
psAddWorkspace.addBatch();
}
psAddUser.executeBatch();
myConn.commit();
} finally {
DatabaseUtilities.close(psAddUser);
DatabaseUtilities.close(psAddWorkspace);
myConn.close();
}
Please provide recommendation to fix this flaw, thanks in advance.
.png)
Hi @Svajjarapu023153 (Community Member) ,
Could you share more about what DatabaseUtilities.setValue is doing?
If you are not able to share more details I would recommend creating a support case by clicking your avatar in the top right corner of the community and selecting "Contact Support" and in that mention the URL to the Veracode Platform Triage Flaws page as well as the flaw id.
Thank you,
Boy Baukema
Hi Boy,
Thank you for the response, DatabaseUtilities.setValue() just sets the value in prepared statement.
Here is the code snippet. preparedStatement.setString(index, value.toString()). Please provide your suggestion to resolve this flaw. Thanks in advanced.
Hi @Svajjarapu023153 (Community Member) ,
Unfortunately, I can't say based on this why it was reported. I would recommend creating a support case by clicking your avatar in the top right corner of the community and selecting "Contact Support" and in that mention the URL to this post, the Veracode Platform Triage Flaws page (starts with: https://analysiscenter.veracode.com/auth/index.jsp#ReviewResultsAllFlaws ) and the flaw id.
Thank you,
Boy Baukema