public DataSource dsDatasource(Environment env) throws Exception {
HikariDataSource dataSource = new HikariDataSource();
dataSource.setUsername(username);
String password = env.getProperty(convertToHashicorpLabel());
dataSource.setPassword(password != null ? password : dbPassword);
if (dataSource.getPassword() == null) {
throw new Exception("Datasource password is null");
}
dataSource.setJdbcUrl(url);
dataSource.setDriverClassName(driverClassName);
dataSource.setMaximumPoolSize(maxPoolSize);
dataSource.setMinimumIdle(minPoolSize);
dataSource.setPoolName(poolName);
return dataSource;
}
private String convertToHashicorpLabel() {
return username + "_label";
}
}
Above is java method, when i run the checkmarx report it is showing a heap inspection vulnerability at this line String password = env.getProperty(convertToHashicorpLabel());. Can some please help in fixing that.