본문으로 건너뛰기

상품 검색 보안 강화.

PHP 7 · GODO25
변경 파일 수: 1개
변경 파일 목록
총 1개
Component (1)
Goods.phpGoods/
변경 파일 코드
추가삭제
Component/Goods/Goods.php+14
변경 전Goods.php
$this->search['reSearchKey'] = gd_isset(array_values($getValue['reSearchKey']));
$this->search['reSearch'] = gd_isset($getValue['reSearch']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$this->search['cateGoods'] = ArrayUtils::last(gd_isset($getValue['cateGoods']));
$this->search['brand'] = gd_isset($getValue['brand']);
$this->search['quickBrandGoods'] = gd_isset($getValue['quickBrandGoods']);
 
변경 후Goods.php
$this->search['reSearchKey'] = gd_isset(array_values($getValue['reSearchKey']));
$this->search['reSearch'] = gd_isset($getValue['reSearch']);
 
// 검색 필드키 화이트리스트 검증 (SQL 식별자 인젝션 방어 - 허용된 검색키만 컬럼명으로 결합)
$allowedSearchKey = array_merge(array_keys($this->search['combineSearch']), ['brandNm']);
if ($this->search['key'] && !in_array($this->search['key'], $allowedSearchKey, true)) {
$this->search['key'] = 'all';
}
if (is_array($this->search['reSearchKey'])) {
foreach ($this->search['reSearchKey'] as $reSearchKeyIdx => $reSearchKeyVal) {
if (!in_array($reSearchKeyVal, $allowedSearchKey, true)) {
unset($this->search['reSearchKey'][$reSearchKeyIdx]);
unset($this->search['reSearchKeyword'][$reSearchKeyIdx]);
}
}
}
 
$this->search['cateGoods'] = ArrayUtils::last(gd_isset($getValue['cateGoods']));
$this->search['brand'] = gd_isset($getValue['brand']);
$this->search['quickBrandGoods'] = gd_isset($getValue['quickBrandGoods']);