Qual: Remove SQL injection suppressions from Phan baseline (#39450)
* Qual: Remove SQL injection suppressions from Phan baseline # Qual: Remove SQL injection suppressions from Phan baseline - Removed SqlInjection suppressions from baseline.txt - Removed SqlInjectionUnquotedEscape suppressions from baseline.txt * Qual: Improve SQL query escaping and formatting in contact list # Qual: Improve SQL query escaping and formatting in contact list Improved the SQL query escaping for compatibility with SqlInjection. Does not fix the inappropriate/incomplete escaping through usage of the 'escapeforlike' for REGEX or PGSQL '~'. * Qual: Add SQLInjection suppression comments # Qual: Add SQLInjection suppression comments Added SQLInjection suppression directives: - In modules_import.class.php, for json_encode operations. - In html.formproduct.class.php, for expression "sanitized" by $db->order(). - In html.formwebportal.class.php, for the WHERE clause conditions (supposes safe argument). --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
5048e74146
commit
ab8daf516f
5 changed files with 10 additions and 14 deletions
|
|
@ -15,8 +15,6 @@ return [
|
|||
// PhanTypeMismatchProperty : 15+ occurrences
|
||||
// PhanTypeInvalidDimOffset : 10+ occurrences
|
||||
// PhanTypeMismatchDimFetch : 10+ occurrences
|
||||
// SqlInjection : 7 occurrences
|
||||
// SqlInjectionUnquotedEscape : 6 occurrences
|
||||
// PhanTypeArraySuspiciousNull : 5 occurrences
|
||||
// PhanUndeclaredMethod : 5 occurrences
|
||||
// PhanTypeExpectedObjectPropAccess : 4 occurrences
|
||||
|
|
@ -30,7 +28,6 @@ return [
|
|||
|
||||
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
|
||||
'file_suppressions' => [
|
||||
'htdocs/blockedlog/admin/filecheck_diff.php' => ['SqlInjection'],
|
||||
'htdocs/comm/action/index.php' => ['PhanTypeMismatchProperty'],
|
||||
'htdocs/comm/action/pertype.php' => ['PhanTypeExpectedObjectPropAccess'],
|
||||
'htdocs/comm/action/peruser.php' => ['PhanTypeMismatchArgument'],
|
||||
|
|
@ -49,7 +46,6 @@ return [
|
|||
'htdocs/compta/sociales/card.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/compta/tva/clients.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset'],
|
||||
'htdocs/contact/list.php' => ['SqlInjectionUnquotedEscape'],
|
||||
'htdocs/core/actions_addupdatedelete.inc.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/core/actions_massactions.inc.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/core/actions_sendmails.inc.php' => ['PhanUndeclaredProperty'],
|
||||
|
|
@ -86,7 +82,6 @@ return [
|
|||
'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/holiday/mod_holiday_immaculate.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/import/modules_import.class.php' => ['SqlInjection'],
|
||||
'htdocs/core/modules/member/modules_cards.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/mrp/mod_mo_advanced.php' => ['PhanUndeclaredProperty'],
|
||||
|
|
@ -146,7 +141,7 @@ return [
|
|||
'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/product/class/api_products.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'],
|
||||
'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty', 'SqlInjection'],
|
||||
'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/product/class/productfournisseurprice.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
|
||||
'htdocs/product/inventory/class/inventory.class.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/product/price.php' => ['PhanUndeclaredProperty'],
|
||||
|
|
@ -205,7 +200,6 @@ return [
|
|||
'htdocs/variants/tpl/productattributevalueline_view.tpl.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/webhook/class/target.class.php' => ['PhanUndeclaredMethod'],
|
||||
'htdocs/webhook/target_card.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/webportal/class/html.formwebportal.class.php' => ['SqlInjection'],
|
||||
'htdocs/webservices/server_project.php' => ['PhanUndeclaredProperty'],
|
||||
],
|
||||
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
|
||||
|
|
|
|||
|
|
@ -755,12 +755,12 @@ if (isModEnabled('socialnetworks')) {
|
|||
if ($value['active'] && strlen($search_[$key])) {
|
||||
$searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
|
||||
if (in_array($db->type, array('mysql', 'mysqli'))) {
|
||||
$sql .= " AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
|
||||
$sql .= " AND p.socialnetworks REGEXP '".$db->escape("\"".$db->escapeforlike($key)."\":\"[^\"]*".$db->escapeforlike($searchkeyinjsonformat))."'";
|
||||
} elseif ($db->type == 'pgsql') {
|
||||
$sql .= " AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
|
||||
$sql .= " AND p.socialnetworks ~ '".$db->escape("\"".$db->escapeforlike($key)."\":\"[^\"]*".$db->escapeforlike($searchkeyinjsonformat))."'";
|
||||
} else {
|
||||
// Works with all database but not reliable because search only for social network code starting with earched value
|
||||
$sql .= " AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key))."\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat))."%'";
|
||||
// Works with all database but not reliable because search only for social network code starting with searched value
|
||||
$sql .= " AND p.socialnetworks LIKE '".$db->escape("%\"".$db->escapeforlike($key."\":\"".$searchkeyinjsonformat)."%")."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1462,12 +1462,12 @@ class ModeleImports
|
|||
if (empty($sql_listvalues[$socialkey]) || $sql_listvalues[$socialkey] == "null") {
|
||||
$json = new stdClass();
|
||||
$json->$socialnetwork = $newval;
|
||||
$sql_listvalues[$socialkey] = json_encode($json);
|
||||
$sql_listvalues[$socialkey] = json_encode($json); // Supposed proper escape elsewhere!! @phan-suppress-current-line SqlInjection
|
||||
} else {
|
||||
$jsondata = $sql_listvalues[$socialkey];
|
||||
$json = json_decode($jsondata);
|
||||
$json->$socialnetwork = $newval;
|
||||
$sql_listvalues[$socialkey] = json_encode($json);
|
||||
$sql_listvalues[$socialkey] = json_encode($json); // Supposed proper escape elsewhere!! @phan-suppress-current-line SqlInjection
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class FormProduct
|
|||
}
|
||||
}
|
||||
$sortfield = implode(',', $arraysortfield);
|
||||
$sortorder_unsanitized = implode(',', $arraysortorder); // $db->order sanitizes
|
||||
$sortorder_unsanitized = implode(',', $arraysortorder); // $db->order sanitizes @phan-suppress-current-line SqlInjection
|
||||
$sql .= $this->db->order($sortfield, $sortorder_unsanitized);
|
||||
|
||||
dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
|
||||
|
|
|
|||
|
|
@ -653,8 +653,10 @@ class FormWebPortal extends Form
|
|||
//We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||
$sql .= " as main, " . $this->db->prefix() . $this->db->sanitize($InfoFieldList[0]) . "_extrafields as extra";
|
||||
// We trust this argument `$InfoFieldList[4]` @phan-suppress-next-line SqlInjection
|
||||
$sqlwhere .= " WHERE extra.fk_object=main." . $this->db->sanitize($InfoFieldList[2]) . " AND " . $InfoFieldList[4];
|
||||
} else {
|
||||
// We trust this argument `$InfoFieldList[4]` @phan-suppress-next-line SqlInjection
|
||||
$sqlwhere .= " WHERE " . $InfoFieldList[4];
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue