Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OC-17141 #3490

Merged
merged 1 commit into from Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
OC-17141: fix reported SQL injection issues
  • Loading branch information
Tao Li committed Jan 26, 2022
commit b152cc63019230c9973965a98e4386ea5322c18f
Expand Up @@ -622,7 +622,12 @@ public void getBasicDefinitions(String crfVersionOID, BasicDefinitionsBean basic
ArrayList<MeasurementUnitBean> units = basicDef.getMeasurementUnits();
String uprev = "";
this.setStudyMeasurementUnitsTypesExpected();
ArrayList rows = this.select(this.getStudyMeasurementUnitsSql(crfVersionOID));

//OC-17141
HashMap<Integer, Object> param = new HashMap<Integer, Object>();
param.put(new Integer(1), crfVersionOID);
ArrayList rows = this.select(getStudyMeasurementUnitsSqlbyCrfVersionOid(),param);

Iterator it = rows.iterator();
while (it.hasNext()) {
HashMap row = (HashMap) it.next();
Expand Down Expand Up @@ -3536,6 +3541,12 @@ protected String getStudyMeasurementUnitsSql(String crfVersionOid) {
"where cv.oc_OID in (\'"+crfVersionOid +"\') and cv.crf_version_id = vm.crf_version_id and vm.item_id = item.item_id " +
"and item.units = mu.name order by mu.oc_oid";
}

protected String getStudyMeasurementUnitsSqlbyCrfVersionOid() {
return "select distinct mu.oc_oid as mu_oid, mu.name from crf_version cv, versioning_map vm, item, measurement_unit mu " +
"where cv.oc_OID in (?) and cv.crf_version_id = vm.crf_version_id and vm.item_id = item.item_id " +
"and item.units = mu.name order by mu.oc_oid";
}

protected String getEventGroupItemWithUnitSql(String studyIds, String sedIds, String itemIds, String dateConstraint, int datasetItemStatusId,
String studySubjectIds) {
Expand Down
Expand Up @@ -18,8 +18,11 @@ Class<EventCrfFlag> domainClass() {
}

public EventCrfFlag findByEventCrfPath(int tagId, String path) {
String query = "from " + getDomainClassName() + " where path = '" + path + "' and tagId=" + tagId;
String query = "from " + getDomainClassName() + " where path = :path and tagId= :tagId";
org.hibernate.Query q = getCurrentSession().createQuery(query);
q.setInteger("tagId", tagId);
q.setString("path", path);

return (EventCrfFlag) q.uniqueResult();

}
Expand Down
Expand Up @@ -18,20 +18,26 @@ Class<ItemDataFlag> domainClass() {


public List<ItemDataFlag> findAllByEventCrfPath(int tag_id , String eventCrfPath ) {

String query = " from " + getDomainClassName() + " where "
+ " tag_id= " + tag_id + " and path LIKE '" + eventCrfPath +".%'" ;
+ " tag_id = :tag_id and path LIKE :eventCrfPath";

org.hibernate.Query q = getCurrentSession().createQuery(query);
q.setInteger("tag_id", tag_id);
q.setString("eventCrfPath", eventCrfPath + ".%");

return (List<ItemDataFlag>) q.list();
}

public ItemDataFlag findByItemDataPath(int tag_id , String itemDataPath ) {

String query = " from " + getDomainClassName() + " where "
+ " tag_id= " + tag_id + " and path= '" + itemDataPath +"'" ;
+ " tag_id= :tag_id and path= :itemDataPath ";

org.hibernate.Query q = getCurrentSession().createQuery(query);
q.setInteger("tag_id", tag_id);
q.setString("itemDataPath", itemDataPath);

return (ItemDataFlag) q.uniqueResult();
}

Expand Down