code
stringlengths 14
2.05k
| label
int64 0
1
| programming_language
stringclasses 7
values | cwe_id
stringlengths 6
14
| cwe_name
stringlengths 5
98
⌀ | description
stringlengths 36
379
⌀ | url
stringlengths 36
48
⌀ | label_name
stringclasses 2
values |
---|---|---|---|---|---|---|---|
function privReadEndCentralDirZip4G(&$p_central_dir){
$zip = fopen($this->zipname,'rb');
$from = $p_central_dir['offset'];
$size = filesize($this->zipname);
while($from < $size){
fseek($zip,$from);
$sign = unpack('Vid',@fread($zip, 4));
//debug_out($from,$sign,0x02014b50);
if($sign['id'] == 0x02014b50){
$p_central_dir['offset'] = $from;
break;
}else{
$from = $from + 0xFFFFFFFF + 1;//
}
}
fclose($zip);
return 1;
}
| 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
function privReadEndCentralDirZip4G(&$p_central_dir){
$zip = fopen($this->zipname,'rb');
$from = $p_central_dir['offset'];
$size = filesize($this->zipname);
while($from < $size){
fseek($zip,$from);
$sign = unpack('Vid',@fread($zip, 4));
//debug_out($from,$sign,0x02014b50);
if($sign['id'] == 0x02014b50){
$p_central_dir['offset'] = $from;
break;
}else{
$from = $from + 0xFFFFFFFF + 1;//
}
}
fclose($zip);
return 1;
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function coverMake($cachePath,$path,$coverName,$size){
if(IO::fileNameExist($cachePath,$coverName)){return 'exists;';}
if(!is_dir(TEMP_FILES)){mk_dir(TEMP_FILES);}
$info = IO::info($path);$ext = $info['ext'];
$thumbFile = TEMP_FILES . $coverName;
$localFile = $this->localFile($path);
$movie = '3gp,avi,mp4,m4v,mov,mpg,mpeg,mpe,mts,m2ts,wmv,ogv,webm,vob,flv,f4v,mkv,rmvb,rm';
$isVideo = in_array($ext,explode(',',$movie));
// 过短的视频封面图,不指定时间;
$videoThumbTime = true;
if( $isVideo && is_array($info['fileInfoMore']) &&
isset($info['fileInfoMore']['playtime']) &&
floatval($info['fileInfoMore']['playtime']) <= 3 ){
$videoThumbTime = false;
}
if($isVideo){
// 不是本地文件; 切片后获取:mp4,mov,mpg,webm,f4v,ogv,avi,mkv,wmv;(部分失败)
if(!$localFile){
$localTemp = $thumbFile.'.'.$ext;
$localFile = $localTemp;
file_put_contents($localTemp,IO::fileSubstr($path,0,1024*600));
}
$this->thumbVideo($localFile,$thumbFile,$videoThumbTime);
} else {
if(!$localFile){$localFile = $this->pluginLocalFile($path);}
if($ext == 'ttf'){
$this->thumbFont($localFile,$thumbFile,$size);
}else{
$this->thumbImage($localFile,$thumbFile,$size,$ext);
}
}
if($localTemp){@unlink($localTemp);}
if(@file_exists($thumbFile)){
Cache::remove($coverName);
return IO::move($thumbFile,$cachePath);
}
Cache::set($coverName,'no',600);
del_file($thumbFile);
return 'convert error! localFile='.get_path_this($localFile);
} | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
public function coverMake($cachePath,$path,$coverName,$size){
if(IO::fileNameExist($cachePath,$coverName)){return 'exists;';}
if(!is_dir(TEMP_FILES)){mk_dir(TEMP_FILES);}
$info = IO::info($path);$ext = $info['ext'];
$thumbFile = TEMP_FILES . $coverName;
$localFile = $this->localFile($path);
$movie = '3gp,avi,mp4,m4v,mov,mpg,mpeg,mpe,mts,m2ts,wmv,ogv,webm,vob,flv,f4v,mkv,rmvb,rm';
$isVideo = in_array($ext,explode(',',$movie));
// 过短的视频封面图,不指定时间;
$videoThumbTime = true;
if( $isVideo && is_array($info['fileInfoMore']) &&
isset($info['fileInfoMore']['playtime']) &&
floatval($info['fileInfoMore']['playtime']) <= 3 ){
$videoThumbTime = false;
}
if($isVideo){
// 不是本地文件; 切片后获取:mp4,mov,mpg,webm,f4v,ogv,avi,mkv,wmv;(部分失败)
if(!$localFile){
$localTemp = $thumbFile.'.'.$ext;
$localFile = $localTemp;
file_put_contents($localTemp,IO::fileSubstr($path,0,1024*600));
}
$this->thumbVideo($localFile,$thumbFile,$videoThumbTime);
} else {
if(!$localFile){$localFile = $this->pluginLocalFile($path);}
if($ext == 'ttf'){
$this->thumbFont($localFile,$thumbFile,$size);
}else{
$this->thumbImage($localFile,$thumbFile,$size,$ext);
}
}
if($localTemp){@unlink($localTemp);}
if(@file_exists($thumbFile)){
Cache::remove($coverName);
return IO::move($thumbFile,$cachePath);
}
Cache::set($coverName,'no',600);
del_file($thumbFile);
return 'convert error! localFile='.get_path_this($localFile);
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
private function thumbVideo($file,$cacheFile,$videoThumbTime){
$command = $this->getFFmpeg();
if(!$command){
echo "Ffmpeg ".LNG("fileThumb.check.notFound");
return false;
}
$tempPath = $cacheFile;
if($GLOBALS['config']['systemOS'] == 'linux' && is_writable('/tmp/')){
mk_dir('/tmp/fileThumb');
$tempPath = '/tmp/fileThumb/'.rand_string(15).'.jpg';
}
$maxWidth = 800;
$timeAt = $videoThumbTime ? '-ss 00:00:03' : '';
$script = $command.' -i "'.$file.'" -y -f image2 '.$timeAt.' -vframes 1 '.$tempPath.' 2>&1';
$out = shell_exec($script);
if(!file_exists($tempPath)) {
if ($this->thumbVideoByLink($cacheFile)) return;
return $this->log('video thumb error,'.$out.';cmd='.$script);
}
move_path($tempPath,$cacheFile);
$cm = new ImageThumb($cacheFile,'file');
$cm->prorate($cacheFile,$maxWidth,$maxWidth);
} | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
private function thumbVideo($file,$cacheFile,$videoThumbTime){
$command = $this->getFFmpeg();
if(!$command){
echo "Ffmpeg ".LNG("fileThumb.check.notFound");
return false;
}
$tempPath = $cacheFile;
if($GLOBALS['config']['systemOS'] == 'linux' && is_writable('/tmp/')){
mk_dir('/tmp/fileThumb');
$tempPath = '/tmp/fileThumb/'.rand_string(15).'.jpg';
}
$maxWidth = 800;
$timeAt = $videoThumbTime ? '-ss 00:00:03' : '';
$script = $command.' -i "'.$file.'" -y -f image2 '.$timeAt.' -vframes 1 '.$tempPath.' 2>&1';
$out = shell_exec($script);
if(!file_exists($tempPath)) {
if ($this->thumbVideoByLink($cacheFile)) return;
return $this->log('video thumb error,'.$out.';cmd='.$script);
}
move_path($tempPath,$cacheFile);
$cm = new ImageThumb($cacheFile,'file');
$cm->prorate($cacheFile,$maxWidth,$maxWidth);
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function videoPreview($plugin){
$pickCount = 300;// 总共截取图片数(平均时间内截取)
$path = $plugin->filePath($GLOBALS['in']['path']);
$fileInfo = IO::info($path);
$fileInfo = Action('explorer.list')->pathInfoMore($fileInfo);
$tempFileName = 'preview-'.KodIO::hashPath($fileInfo).'.jpg';
$findSource = IO::fileNameExist($plugin->cachePath,$tempFileName);
if($findSource){return IO::fileOut(KodIO::make($findSource));}
$command = $plugin->getFFmpeg();
if(!$command){return show_json('command error',false);}
$localFile = $plugin->localFile($path);
if(!$localFile ){return show_json('not local file',false);}
$videoInfo = $this->parseVideoInfo($command,$localFile);
$this->storeVideoMetadata($fileInfo,$videoInfo);
if(!$videoInfo || $videoInfo['playtime'] <= 30){return show_json('time too short!',false);}
// $pickCount = $totalTime; 每秒生成一张图片; 可能很大
// 宽列数固定10幅图, 行数为总截取图除一行列数; https://blog.51cto.com/u_15639793/5297432
if(Cache::get($tempFileName)) return show_json('running');
Cache::set($tempFileName,'running',600);
ignore_timeout();
$tempPath = TEMP_FILES.$tempFileName;
$fps = $pickCount / $videoInfo['playtime'];
$sizeW = 150;
$tile = '10x'.ceil($pickCount / 10).'';
$scale = 'scale='.$sizeW.':-2'; //,pad='.$sizeW.':'.$sizeH.':-1:-1 -q:v 1~5 ;质量从最好到最差;
$args = '-sws_flags accurate_rnd -q:v 4 -an'; //更多参数; 设置图片缩放算法(不设置缩小时可能产生绿色条纹花屏);
$cmd = 'ffmpeg -y -i "'.$localFile.'" -vf "fps='.$fps.','.$scale.',tile='.$tile.'" '.$args.' "'.$tempPath.'"';
$this->log('[videoPreview start] '.$fileInfo['name'].';size='.size_format($fileInfo['size']),0,0);$timeStart = timeFloat();
$this->log('[videoPreview run] '.$cmd,0,0);
@shell_exec($cmd);//pr($cmd);exit;
Cache::remove($tempFileName);
$success = file_exists($tempPath) && filesize($tempPath) > 100;
$msg = $success ? 'success' : 'error';
$this->log('[videoPreview end] '.$fileInfo['name'].';time='.(timeFloat() - $timeStart).'s;'.$msg,0,0); | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
public function videoPreview($plugin){
$pickCount = 300;// 总共截取图片数(平均时间内截取)
$path = $plugin->filePath($GLOBALS['in']['path']);
$fileInfo = IO::info($path);
$fileInfo = Action('explorer.list')->pathInfoMore($fileInfo);
$tempFileName = 'preview-'.KodIO::hashPath($fileInfo).'.jpg';
$findSource = IO::fileNameExist($plugin->cachePath,$tempFileName);
if($findSource){return IO::fileOut(KodIO::make($findSource));}
$command = $plugin->getFFmpeg();
if(!$command){return show_json('command error',false);}
$localFile = $plugin->localFile($path);
if(!$localFile ){return show_json('not local file',false);}
$videoInfo = $this->parseVideoInfo($command,$localFile);
$this->storeVideoMetadata($fileInfo,$videoInfo);
if(!$videoInfo || $videoInfo['playtime'] <= 30){return show_json('time too short!',false);}
// $pickCount = $totalTime; 每秒生成一张图片; 可能很大
// 宽列数固定10幅图, 行数为总截取图除一行列数; https://blog.51cto.com/u_15639793/5297432
if(Cache::get($tempFileName)) return show_json('running');
Cache::set($tempFileName,'running',600);
ignore_timeout();
$tempPath = TEMP_FILES.$tempFileName;
$fps = $pickCount / $videoInfo['playtime'];
$sizeW = 150;
$tile = '10x'.ceil($pickCount / 10).'';
$scale = 'scale='.$sizeW.':-2'; //,pad='.$sizeW.':'.$sizeH.':-1:-1 -q:v 1~5 ;质量从最好到最差;
$args = '-sws_flags accurate_rnd -q:v 4 -an'; //更多参数; 设置图片缩放算法(不设置缩小时可能产生绿色条纹花屏);
$cmd = 'ffmpeg -y -i "'.$localFile.'" -vf "fps='.$fps.','.$scale.',tile='.$tile.'" '.$args.' "'.$tempPath.'"';
$this->log('[videoPreview start] '.$fileInfo['name'].';size='.size_format($fileInfo['size']),0,0);$timeStart = timeFloat();
$this->log('[videoPreview run] '.$cmd,0,0);
@shell_exec($cmd);//pr($cmd);exit;
Cache::remove($tempFileName);
$success = file_exists($tempPath) && filesize($tempPath) > 100;
$msg = $success ? 'success' : 'error';
$this->log('[videoPreview end] '.$fileInfo['name'].';time='.(timeFloat() - $timeStart).'s;'.$msg,0,0); | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function processFind($search){
$cmd = "ps -eo user,pid,ppid,args | grep '".$search."' | grep -v grep | awk '{print $2}'";
if($GLOBALS['config']['systemOS'] != 'windows'){return trim(@shell_exec($cmd));}
// windows 获取pid;
$cmd = 'WMIC process where "Commandline like \'%%%'.$search.'%%%\'" get Caption,Processid,Commandline';
$res = trim(@shell_exec($cmd));
$resArr = explode("\n",trim($res));
if(!$resArr || count($resArr) <= 3) return '';
$lineFind = $resArr[count($resArr) - 3];// 最后两个一个为wmic,和cmd;
$res = preg_match("/.*\s+(\d+)\s*$/",$lineFind,$match);
if($res && is_array($match) && $match[1]){return $match[1];}
return '';
} | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
public function processFind($search){
$cmd = "ps -eo user,pid,ppid,args | grep '".$search."' | grep -v grep | awk '{print $2}'";
if($GLOBALS['config']['systemOS'] != 'windows'){return trim(@shell_exec($cmd));}
// windows 获取pid;
$cmd = 'WMIC process where "Commandline like \'%%%'.$search.'%%%\'" get Caption,Processid,Commandline';
$res = trim(@shell_exec($cmd));
$resArr = explode("\n",trim($res));
if(!$resArr || count($resArr) <= 3) return '';
$lineFind = $resArr[count($resArr) - 3];// 最后两个一个为wmic,和cmd;
$res = preg_match("/.*\s+(\d+)\s*$/",$lineFind,$match);
if($res && is_array($match) && $match[1]){return $match[1];}
return '';
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
private function convert2pdf($file,$cacheFile,$ext){
$command = $this->getSoffice();
if(!$command){
Action($this->pluginName)->showTips(LNG('officeViewer.libreOffice.sofficeError'), 'LibreOffice');
}
//linux下$cacheFile不可写问题,先生成到/tmp下;再复制出来
$tempPath = $cacheFile;
if($GLOBALS['config']['systemOS'] == 'linux' && is_writable('/tmp/')){
mk_dir('/tmp/libreOffice');
$tempPath = '/tmp/libreOffice/'.rand_string(15).'.pdf';
}
$fname = get_path_this($tempPath);
$fpath = get_path_father($tempPath);
// 转换类型'pdf'改为'新文件名.pdf',会生成'源文件名.新文件名.pdf'
$export = 'export HOME=/tmp/libreOffice && ';
$script = $export.$command . ' --headless --invisible --convert-to '.$fname.' "'.$file.'" --outdir '.$fpath;
$out = shell_exec($script);
$tname = substr(end(explode('/', $file)), 0, -strlen('.'.$ext));
$tfile = $fpath . $tname . '.' . $fname; // 源文件名.filename.pdf
if(!file_exists($tfile)){
write_log('libreoffice convert error: '.$script."\n".$out,'error');
}
$res = move_path($tfile,$cacheFile);
if (!$res) write_log('libreoffice move file error: '.$tfile.'=>'.$cacheFile, 'error');
} | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
private function convert2pdf($file,$cacheFile,$ext){
$command = $this->getSoffice();
if(!$command){
Action($this->pluginName)->showTips(LNG('officeViewer.libreOffice.sofficeError'), 'LibreOffice');
}
//linux下$cacheFile不可写问题,先生成到/tmp下;再复制出来
$tempPath = $cacheFile;
if($GLOBALS['config']['systemOS'] == 'linux' && is_writable('/tmp/')){
mk_dir('/tmp/libreOffice');
$tempPath = '/tmp/libreOffice/'.rand_string(15).'.pdf';
}
$fname = get_path_this($tempPath);
$fpath = get_path_father($tempPath);
// 转换类型'pdf'改为'新文件名.pdf',会生成'源文件名.新文件名.pdf'
$export = 'export HOME=/tmp/libreOffice && ';
$script = $export.$command . ' --headless --invisible --convert-to '.$fname.' "'.$file.'" --outdir '.$fpath;
$out = shell_exec($script);
$tname = substr(end(explode('/', $file)), 0, -strlen('.'.$ext));
$tfile = $fpath . $tname . '.' . $fname; // 源文件名.filename.pdf
if(!file_exists($tfile)){
write_log('libreoffice convert error: '.$script."\n".$out,'error');
}
$res = move_path($tfile,$cacheFile);
if (!$res) write_log('libreoffice move file error: '.$tfile.'=>'.$cacheFile, 'error');
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function getSoffice(){
$check = 'LibreOffice';
$data = Action($this->pluginName)->_appConfig('lb');
$bin = isset($data['soffice']) ? $data['soffice'] : '';
$bin = '"'.trim(iconv_system($bin)).'"'; // win路径空格处理
$result = $this->checkBin($bin,$check);
return $result ? $bin : false;
} | 0 | PHP | CWE-77 | Improper Neutralization of Special Elements used in a Command ('Command Injection') | The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/77.html | vulnerable |
public function getSoffice(){
$check = 'LibreOffice';
$data = Action($this->pluginName)->_appConfig('lb');
$bin = isset($data['soffice']) ? $data['soffice'] : '';
$bin = '"'.trim(iconv_system($bin)).'"'; // win路径空格处理
$result = $this->checkBin($bin,$check);
return $result ? $bin : false;
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function checkAccessToken(){
$model = $this->loadModel('Plugin');
$config = $model->getConfig('fileView');
if(!$config['apiKey']){
return;
}
$timeTo = isset($this->in['timeTo'])?intval($this->in['timeTo']):'';
$token = md5($config['apiKey'].$this->in['path'].$timeTo);
//show_tips(array($config['apiKey'],$token,$this->in));
if($token != $this->in['token']){
show_tips('token 错误!');
}
if($timeTo != '' && $timeTo <= time()){
show_tips('token已失效!');
}
}
| 0 | PHP | CWE-434 | Unrestricted Upload of File with Dangerous Type | The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. | https://cwe.mitre.org/data/definitions/434.html | vulnerable |
public function checkAccessToken(){
$model = $this->loadModel('Plugin');
$config = $model->getConfig('fileView');
if(!$config['apiKey']){
return;
}
$timeTo = isset($this->in['timeTo'])?intval($this->in['timeTo']):'';
$token = md5($config['apiKey'].$this->in['path'].$timeTo);
//show_tips(array($config['apiKey'],$token,$this->in));
if($token != $this->in['token']){
show_tips('token 错误!');
}
if($timeTo != '' && $timeTo <= time()){
show_tips('token已失效!');
}
}
| 0 | PHP | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
public function checkAccessToken(){
$model = $this->loadModel('Plugin');
$config = $model->getConfig('fileView');
if(!$config['apiKey']){
return;
}
$timeTo = isset($this->in['timeTo'])?intval($this->in['timeTo']):'';
$token = md5($config['apiKey'].$this->in['path'].$timeTo);
//show_tips(array($config['apiKey'],$token,$this->in));
if($token != $this->in['token']){
show_tips('token 错误!');
}
if($timeTo != '' && $timeTo <= time()){
show_tips('token已失效!');
}
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function checkAccessToken(){
$model = $this->loadModel('Plugin');
$config = $model->getConfig('fileView');
if(!$config['apiKey']){
return;
}
$timeTo = isset($this->in['timeTo'])?intval($this->in['timeTo']):'';
$token = md5($config['apiKey'].$this->in['path'].$timeTo);
//show_tips(array($config['apiKey'],$token,$this->in));
if($token != $this->in['token']){
show_tips('token 错误!');
}
if($timeTo != '' && $timeTo <= time()){
show_tips('token已失效!');
}
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function get_path_ext($path){
$name = get_path_this($path);
$ext = '';
if(strstr($name,'.')){
$ext = substr($name,strrpos($name,'.')+1);
$ext = strtolower($ext);
}
if (strlen($ext)>3 && preg_match("/([\x81-\xfe][\x40-\xfe])/", $ext, $match)) {
$ext = '';
}
return htmlspecialchars($ext);
}
| 0 | PHP | CWE-434 | Unrestricted Upload of File with Dangerous Type | The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. | https://cwe.mitre.org/data/definitions/434.html | vulnerable |
function get_path_ext($path){
$name = get_path_this($path);
$ext = '';
if(strstr($name,'.')){
$ext = substr($name,strrpos($name,'.')+1);
$ext = strtolower($ext);
}
if (strlen($ext)>3 && preg_match("/([\x81-\xfe][\x40-\xfe])/", $ext, $match)) {
$ext = '';
}
return htmlspecialchars($ext);
}
| 0 | PHP | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
function get_path_ext($path){
$name = get_path_this($path);
$ext = '';
if(strstr($name,'.')){
$ext = substr($name,strrpos($name,'.')+1);
$ext = strtolower($ext);
}
if (strlen($ext)>3 && preg_match("/([\x81-\xfe][\x40-\xfe])/", $ext, $match)) {
$ext = '';
}
return htmlspecialchars($ext);
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function get_path_ext($path){
$name = get_path_this($path);
$ext = '';
if(strstr($name,'.')){
$ext = substr($name,strrpos($name,'.')+1);
$ext = strtolower($ext);
}
if (strlen($ext)>3 && preg_match("/([\x81-\xfe][\x40-\xfe])/", $ext, $match)) {
$ext = '';
}
return htmlspecialchars($ext);
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function hash_path($path,$addExt=false){
$password = 'kodcloud';
if(isset($GLOBALS['config']['settingSystem']['systemPassword'])){
$password = $GLOBALS['config']['settingSystem']['systemPassword'];
}
$pre = substr(md5($path.$password),0,8);
$result = $pre.md5($path);
if(file_exists($path)){
$result = $pre.md5($path.filemtime($path));
if(filesize($path) < 50*1024*1024){
$fileMd5 = @md5_file($path);
if($fileMd5){
$result = $fileMd5;
}
}
}
if($addExt){
$result = $result.'.'.get_path_ext($path);
}
return $result;
}
| 0 | PHP | CWE-434 | Unrestricted Upload of File with Dangerous Type | The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. | https://cwe.mitre.org/data/definitions/434.html | vulnerable |
function hash_path($path,$addExt=false){
$password = 'kodcloud';
if(isset($GLOBALS['config']['settingSystem']['systemPassword'])){
$password = $GLOBALS['config']['settingSystem']['systemPassword'];
}
$pre = substr(md5($path.$password),0,8);
$result = $pre.md5($path);
if(file_exists($path)){
$result = $pre.md5($path.filemtime($path));
if(filesize($path) < 50*1024*1024){
$fileMd5 = @md5_file($path);
if($fileMd5){
$result = $fileMd5;
}
}
}
if($addExt){
$result = $result.'.'.get_path_ext($path);
}
return $result;
}
| 0 | PHP | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
function hash_path($path,$addExt=false){
$password = 'kodcloud';
if(isset($GLOBALS['config']['settingSystem']['systemPassword'])){
$password = $GLOBALS['config']['settingSystem']['systemPassword'];
}
$pre = substr(md5($path.$password),0,8);
$result = $pre.md5($path);
if(file_exists($path)){
$result = $pre.md5($path.filemtime($path));
if(filesize($path) < 50*1024*1024){
$fileMd5 = @md5_file($path);
if($fileMd5){
$result = $fileMd5;
}
}
}
if($addExt){
$result = $result.'.'.get_path_ext($path);
}
return $result;
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function hash_path($path,$addExt=false){
$password = 'kodcloud';
if(isset($GLOBALS['config']['settingSystem']['systemPassword'])){
$password = $GLOBALS['config']['settingSystem']['systemPassword'];
}
$pre = substr(md5($path.$password),0,8);
$result = $pre.md5($path);
if(file_exists($path)){
$result = $pre.md5($path.filemtime($path));
if(filesize($path) < 50*1024*1024){
$fileMd5 = @md5_file($path);
if($fileMd5){
$result = $fileMd5;
}
}
}
if($addExt){
$result = $result.'.'.get_path_ext($path);
}
return $result;
}
| 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function prorate($toFile, $toW, $toH){
if(!$this->im){
return false;
}
$toWH = $toW / $toH;
$srcWH = $this->srcW / $this->srcH;
if ($toWH<=$srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($this->srcH / $this->srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($this->srcW / $this->srcH);
}
if ($this->srcW > $toW || $this->srcH > $toH) {
$cImg = $this->creatImage($this->im, $ftoW, $ftoH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
} else {
$cImg = $this->creatImage($this->im, $this->srcW, $this->srcH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
}
} | 0 | PHP | CWE-434 | Unrestricted Upload of File with Dangerous Type | The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. | https://cwe.mitre.org/data/definitions/434.html | vulnerable |
function prorate($toFile, $toW, $toH){
if(!$this->im){
return false;
}
$toWH = $toW / $toH;
$srcWH = $this->srcW / $this->srcH;
if ($toWH<=$srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($this->srcH / $this->srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($this->srcW / $this->srcH);
}
if ($this->srcW > $toW || $this->srcH > $toH) {
$cImg = $this->creatImage($this->im, $ftoW, $ftoH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
} else {
$cImg = $this->creatImage($this->im, $this->srcW, $this->srcH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
}
} | 0 | PHP | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
function prorate($toFile, $toW, $toH){
if(!$this->im){
return false;
}
$toWH = $toW / $toH;
$srcWH = $this->srcW / $this->srcH;
if ($toWH<=$srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($this->srcH / $this->srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($this->srcW / $this->srcH);
}
if ($this->srcW > $toW || $this->srcH > $toH) {
$cImg = $this->creatImage($this->im, $ftoW, $ftoH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
} else {
$cImg = $this->creatImage($this->im, $this->srcW, $this->srcH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
}
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
function prorate($toFile, $toW, $toH){
if(!$this->im){
return false;
}
$toWH = $toW / $toH;
$srcWH = $this->srcW / $this->srcH;
if ($toWH<=$srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($this->srcH / $this->srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($this->srcW / $this->srcH);
}
if ($this->srcW > $toW || $this->srcH > $toH) {
$cImg = $this->creatImage($this->im, $ftoW, $ftoH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
} else {
$cImg = $this->creatImage($this->im, $this->srcW, $this->srcH, 0, 0, 0, 0, $this->srcW, $this->srcH);
return $this->echoImage($cImg, $toFile);
}
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
protected function fixTags($tags) {
// move @ tags out of variable namespace
foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix;
}
return $tags;
} | 0 | PHP | CWE-434 | Unrestricted Upload of File with Dangerous Type | The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. | https://cwe.mitre.org/data/definitions/434.html | vulnerable |
protected function fixTags($tags) {
// move @ tags out of variable namespace
foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix;
}
return $tags;
} | 0 | PHP | CWE-94 | Improper Control of Generation of Code ('Code Injection') | The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. | https://cwe.mitre.org/data/definitions/94.html | vulnerable |
protected function fixTags($tags) {
// move @ tags out of variable namespace
foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix;
}
return $tags;
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
protected function fixTags($tags) {
// move @ tags out of variable namespace
foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix;
}
return $tags;
} | 0 | PHP | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
public function get_data($query = '')
{
$page_number = ($this->get_pagenum() - 1) * $this->limit;
$orderby = "ORDER BY {$this->tb_prefix}sms_subscribes.date DESC";
$where = "";
if (isset($_REQUEST['orderby'])) {
$orderby = "ORDER BY {$this->tb_prefix}sms_subscribes.{$_REQUEST['orderby']} {$_REQUEST['order']}";
}
if (!$query) {
if (isset($_GET['group_id']) && $_GET['group_id']) {
$group_id = sanitize_text_field($_GET['group_id']);
$where = "WHERE group_ID = {$group_id}";
}
if (isset($_GET['country_code']) && $_GET['country_code']) {
$country_code = sanitize_text_field($_GET['country_code']);
if ($where) {
$where .= " AND mobile LIKE '{$country_code}%'";
} else {
$where = "WHERE mobile LIKE '{$country_code}%'";
}
}
$query = $this->db->prepare("SELECT * FROM {$this->tb_prefix}sms_subscribes {$where} {$orderby} LIMIT %d OFFSET %d", $this->limit, $page_number);
} else {
$query .= $this->db->prepare(" LIMIT %d OFFSET %d", $this->limit, $page_number);
}
$result = $this->db->get_results($query, ARRAY_A);
return $result;
} | 0 | PHP | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | vulnerable |
public function column_name($item)
{
/**
* Sanitize the input
*/
$page = sanitize_text_field($_REQUEST['page']);
//Build row actions
$actions = array(
'edit' => sprintf('<a href="#" onclick="wp_sms_edit_subscriber(%s)">' . __('Edit', 'wp-sms') . '</a>', $item['ID']),
'delete' => sprintf('<a href="?page=%s&action=%s&ID=%s">' . __('Delete', 'wp-sms') . '</a>', $page, 'delete', $item['ID']),
);
//Return the title contents
return sprintf('%1$s %3$s',
/*$1%s*/
esc_html($item['name']),
/*$2%s*/
$item['ID'],
/*$2%s*/
$this->row_actions($actions)
);
} | 0 | PHP | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | vulnerable |
public function __construct(
Dispatcher $events,
SessionAuthenticator $authenticator,
Rememberer $rememberer,
Factory $view,
UrlGenerator $url
) {
$this->events = $events;
$this->authenticator = $authenticator;
$this->rememberer = $rememberer;
$this->view = $view;
$this->url = $url;
} | 0 | PHP | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
public function __construct(
string $appName,
IRequest $request,
ISession $session,
IUserSession $userSession,
SAMLSettings $samlSettings,
UserBackend $userBackend,
IConfig $config,
IURLGenerator $urlGenerator,
LoggerInterface $logger,
IL10N $l,
UserResolver $userResolver,
UserData $userData,
ICrypto $crypto
) {
parent::__construct($appName, $request);
$this->session = $session;
$this->userSession = $userSession;
$this->samlSettings = $samlSettings;
$this->userBackend = $userBackend;
$this->config = $config;
$this->urlGenerator = $urlGenerator;
$this->logger = $logger;
$this->l = $l;
$this->userResolver = $userResolver;
$this->userData = $userData;
$this->crypto = $crypto;
} | 0 | PHP | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
private static Optional<String> getScheme(String uri) {
var s = StringUtils.trimToEmpty(uri).toLowerCase(Locale.ROOT);
return s.indexOf(':') >= 0 ? Optional.of(StringUtils.substringBefore(s, ':')) : Optional.empty();
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
public void setAttributes(Node node, String tagName, Map<String, String> attributes) {
if (node instanceof Link) {
Link l = (Link) node;
String destination = StringUtils.trimToEmpty(l.getDestination());
var scheme = getScheme(destination);
scheme.ifPresent(resolvedScheme -> {
if (!Set.of("http", "https").contains(resolvedScheme)) {
log.info("User tried to set an url with scheme {}, only http/https are accepted, href has been removed", resolvedScheme);
attributes.remove("href");
}
});
if (UrlUtils.isAbsoluteUrl(destination)) {
// accept only http or https protocols if we have an absolute link, else we override with an empty string
attributes.put("target", "_blank");
attributes.put("rel", "nofollow noopener noreferrer");
var newTabLabel = A11Y_NEW_TAB_LABEL.get();
if (newTabLabel != null) {
attributes.put("aria-label", ((Text)node.getFirstChild()).getLiteral() + " " + newTabLabel);
}
}
}
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
public void acceptOnlyHttpOrHttpsProtocols() {
assertEquals("<p><a href=\"http://google.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">google</a></p>\n", MustacheCustomTag.renderToHtmlCommonmarkEscaped("[google](http://google.com)"));
assertEquals("<p><a href=\"https://google.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">google</a></p>\n", MustacheCustomTag.renderToHtmlCommonmarkEscaped("[google](https://google.com)"));
assertEquals("<p><a>google</a></p>\n", MustacheCustomTag.renderToHtmlCommonmarkEscaped("[google](any:google.com)"));
assertEquals("<p><a>google</a></p>\n", MustacheCustomTag.renderToHtmlCommonmarkEscaped("[google](other:google.com)"));
assertEquals("<p><a>google</a></p>\n", MustacheCustomTag.renderToHtmlCommonmarkEscaped("[google](protocols:/google.com)"));
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
Group createNew(String name, String description, int organizationId) {
AffectedRowCountAndKey<Integer> insert = groupRepository.insert(escapeHtml4(name), escapeHtml4(description), organizationId);
return groupRepository.getById(insert.getKey());
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
public Optional<GroupModification> update(int listId, GroupModification modification) {
if(groupRepository.getOptionalById(listId).isEmpty() || CollectionUtils.isEmpty(modification.getItems())) {
return Optional.empty();
}
List<String> existingValues = groupRepository.getAllValuesIncludingNotActive(listId);
List<GroupMemberModification> notPresent = modification.getItems().stream()
.filter(i -> i.getId() == null && !existingValues.contains(i.getValue().strip().toLowerCase()))
.distinct()
.collect(Collectors.toList());
if(!notPresent.isEmpty()) {
var insertResult = insertMembers(listId, notPresent);
if(!insertResult.isSuccess()) {
var error = Objects.requireNonNull(insertResult.getFirstErrorOrNull());
throw new DuplicateGroupItemException(error.getDescription());
}
}
groupRepository.update(listId, escapeHtml4(modification.getName()), escapeHtml4(modification.getDescription()));
return loadComplete(listId);
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
default int[] insert(int groupId, List<GroupMemberModification> members) {
MapSqlParameterSource[] params = members.stream()
.map(i -> new MapSqlParameterSource("groupId", groupId)
.addValue("value", i.getValue().toLowerCase())
.addValue("description", escapeHtml4(i.getDescription())))
.toArray(MapSqlParameterSource[]::new);
return getNamedParameterJdbcTemplate().batchUpdate("insert into group_member(a_group_id_fk, value, description) values(:groupId, :value, :description)", params);
} | 1 | Java | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | safe |
public static String pathOffset(String path, RoutingContext context) {
final Route route = context.currentRoute();
// cannot make any assumptions
if (route == null) {
return path;
}
if (!route.isExactPath()) {
String rest = context.pathParam("*");
if (rest != null) {
// normalize
if (rest.length() > 0) {
// remove any attempt to escape the web root and use UNIX style path separators
rest = HttpUtils.removeDots(rest.replace('\\', '/'));
if (rest.charAt(0) == '/') {
return rest;
} else {
return "/" + rest;
}
} else {
return "/";
}
}
}
int prefixLen = 0;
String mountPoint = context.mountPoint();
if (mountPoint != null) {
prefixLen = mountPoint.length();
// special case we need to verify if a trailing slash is present and exclude
if (mountPoint.charAt(mountPoint.length() - 1) == '/') {
prefixLen--;
}
}
// we can only safely skip the route path if there are no variables or regex
if (!route.isRegexPath()) {
String routePath = route.getPath();
if (routePath != null) {
prefixLen += routePath.length();
// special case we need to verify if a trailing slash is present and exclude
if (routePath.charAt(routePath.length() - 1) == '/') {
prefixLen--;
}
}
}
return prefixLen != 0 ? path.substring(prefixLen) : path;
} | 1 | Java | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | safe |
public void testEscapeToClasspathFromRegEx() throws Exception {
router.clear();
router.routeWithRegex(".*").handler(StaticHandler.create("www"));
// attempt to escape to classpath, given that the handler is mounted on a regex,
testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found");
} | 1 | Java | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | safe |
public void testEscapeToClasspathFromFixedPath() throws Exception {
router.clear();
router.routeWithRegex("/").handler(StaticHandler.create("www"));
// attempt to escape to classpath, given that the handler is mounted on a regex,
testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found");
} | 1 | Java | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | safe |
public void testEscapeToClasspathFromWildcard() throws Exception {
router.clear();
router.route("/*").handler(StaticHandler.create("www"));
// attempt to escape to classpath, given that the handler is mounted on a wildcard,
// reading the wildcard must return a sanitized path and therefore not allow to escape.
testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found");
} | 1 | Java | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | safe |
public void testEscapeToClasspathFromNull() throws Exception {
router.clear();
router.route().handler(StaticHandler.create("www"));
// attempt to escape to classpath, given that the handler is mounted on a catch all path
testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found");
} | 1 | Java | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | safe |
private void migrate110(File dataDir, Stack<Integer> versions) {
var updateIds = new HashSet<>();
for (File file: dataDir.listFiles()) {
if (file.getName().startsWith("Users.xml")) {
VersionedXmlDoc dom = VersionedXmlDoc.fromFile(file);
for (Element element: dom.getRootElement().elements()) {
element.element("accessToken").setText(CryptoUtils.generateSecret());
}
dom.writeToFile(file, false);
}
}
} | 1 | Java | CWE-338 | Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) | The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong. | https://cwe.mitre.org/data/definitions/338.html | safe |
public static String generateSecret() {
return generateSecret(DEFAULT_SECRET_LEN);
} | 1 | Java | CWE-338 | Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) | The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong. | https://cwe.mitre.org/data/definitions/338.html | safe |
public static String generateSecret(int count) {
return RandomStringUtils.random(count, 0, 0, true, true, null,
new SecureRandom());
} | 1 | Java | CWE-338 | Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) | The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong. | https://cwe.mitre.org/data/definitions/338.html | safe |
protected void onInitialize() {
super.onInitialize();
IModel<String> valueModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getUser().getAccessToken();
}
};
add(new TextField<String>("value", valueModel) {
@Override
protected String[] getInputTypes() {
return new String[] {"password"};
}
});
add(new CopyToClipboardLink("copy", valueModel));
add(new Link<Void>("regenerate") {
@Override
public void onClick() {
getUser().setAccessToken(CryptoUtils.generateSecret());
OneDev.getInstance(UserManager.class).save(getUser());
Session.get().success("Access token regenerated");
setResponsePage(getPage());
}
}.add(new ConfirmClickModifier("This will invalidate current token and generate a new one, do you want to continue?")));
} | 1 | Java | CWE-338 | Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) | The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong. | https://cwe.mitre.org/data/definitions/338.html | safe |
public ConfigDatabase(
JDBCLoaderProperties properties,
final DataSource dataSource,
final XStreamInfoSerialBinding binding,
CacheProvider cacheProvider) {
this.properties = properties;
this.binding = binding;
this.template = new NamedParameterJdbcTemplate(dataSource);
// cannot use dataSource at this point due to spring context config hack
// in place to support tx during testing
this.dataSource = dataSource;
this.catalogRowMapper = new InfoRowMapper<CatalogInfo>(CatalogInfo.class, binding);
this.configRowMapper = new InfoRowMapper<Info>(Info.class, binding);
if (cacheProvider == null) {
cacheProvider = DefaultCacheProvider.findProvider();
}
cache = cacheProvider.getCache("catalog");
identityCache = cacheProvider.getCache("catalogNames");
serviceCache = cacheProvider.getCache("services");
locks = new ConcurrentHashMap<>();
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public ConfigDatabase(
JDBCLoaderProperties properties,
DataSource dataSource,
XStreamInfoSerialBinding binding) {
this(properties, dataSource, binding, null);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
private Dialect dialect() {
if (dialect == null) {
this.dialect = Dialect.detect(dataSource, properties.isDebugMode());
}
return dialect;
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public <T extends CatalogInfo> int count(final Class<T> of, final Filter filter) {
QueryBuilder<T> sqlBuilder = QueryBuilder.forCount(dialect, of, dbMappings).filter(filter);
final String sql = sqlBuilder.build();
final Filter unsupportedFilter = sqlBuilder.getUnsupportedFilter();
final boolean fullySupported = Filter.INCLUDE.equals(unsupportedFilter);
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Original filter: " + filter);
LOGGER.finer("Supported filter: " + sqlBuilder.getSupportedFilter());
LOGGER.finer("Unsupported filter: " + sqlBuilder.getUnsupportedFilter());
}
final int count;
if (fullySupported) {
final Map<String, Object> namedParameters = sqlBuilder.getNamedParameters();
logStatement(sql, namedParameters);
count = template.queryForObject(sql, namedParameters, Integer.class);
} else {
LOGGER.fine(
"Filter is not fully supported, doing scan of supported part to return the number of matches");
// going the expensive route, filtering as much as possible
CloseableIterator<T> iterator = query(of, filter, null, null, (SortBy) null);
try {
return Iterators.size(iterator);
} finally {
iterator.close();
}
}
return count;
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public String escapeComment(String comment) {
String escaped = ESCAPE_CLOSING_COMMENT_PATTERN.matcher(comment).replaceAll("*\\\\/");
return ESCAPE_OPENING_COMMENT_PATTERN.matcher(escaped).replaceAll("/\\\\*");
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public boolean isDebugMode() {
return debugMode;
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public StringBuilder appendComment(Object sql, Object... objects) {
return appendComment((StringBuilder) sql, objects);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public StringBuilder appendComment(StringBuilder sql, Object... objects) {
if (!debugMode) {
return sql;
}
sql.append(" /* ");
for (Object object : objects) {
sql.append(escapeComment(String.valueOf(object)));
}
return sql.append(" */\n");
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void setDebugMode(boolean debugMode) {
this.debugMode = debugMode;
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public static Dialect detect(DataSource dataSource, boolean debugMode) {
Dialect dialect;
try {
Connection conn = dataSource.getConnection();
String driver = conn.getMetaData().getDriverName();
if (driver.contains("Oracle")) {
dialect = new OracleDialect();
} else {
dialect = new Dialect();
}
conn.close();
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
dialect.setDebugMode(debugMode);
return dialect;
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public StringBuilder appendIfDebug(StringBuilder sql, String ifEnabled, String ifDisabled) {
return sql.append(debugMode ? ifEnabled : ifDisabled);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(PropertyIsNil filter, Object extraData) {
final PropertyName propertyName = (PropertyName) filter.getExpression();
final String propertyTypesParam = propertyTypesParam(propertyName);
append(
extraData,
"oid IN (SELECT oid FROM object_property WHERE property_type IN (:",
propertyTypesParam,
") AND value IS NULL)");
return dialect.appendComment(extraData, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
private Object handleInstanceOf(IsInstanceOf instanceOf, Object extraData) {
Expression expression1 = instanceOf.getParameters().get(0);
Class<?> clazz = expression1.evaluate(null, Class.class);
Integer typeId = dbMappings.getTypeId(clazz);
if (typeId == null) {
return visit(Filter.EXCLUDE, extraData);
}
append(extraData, "type_id = ", typeId.toString());
return dialect.appendComment(extraData, "isInstanceOf ", clazz.getName());
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(IncludeFilter filter, Object extraData) {
return dialect.appendComment(append(extraData, "1 = 1"), "INCLUDE");
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(And filter, Object extraData) {
return visit(filter, "AND", extraData);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
protected Object visit(BinaryLogicOperator filter, String type, Object extraData) {
StringBuilder sql = (StringBuilder) extraData;
List<Filter> children = filter.getChildren();
checkArgument(children.size() > 0);
sql.append('(');
dialect.appendIfDebug(sql, "\n ", "");
for (Iterator<Filter> it = children.iterator(); it.hasNext(); ) {
it.next().accept(this, sql);
if (it.hasNext()) {
dialect.appendIfDebug(sql, " ", " ");
sql.append(type);
dialect.appendIfDebug(sql, "\n ", " ");
}
}
return sql.append(')');
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public FilterToCatalogSQL(Dialect dialect, Class<?> queryType, DbMappings dbMappings) {
this.dialect = dialect;
this.queryType = queryType;
this.dbMappings = dbMappings;
List<Integer> concreteQueryTypes = dbMappings.getConcreteQueryTypes(queryType);
namedParams.put("types", concreteQueryTypes);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(Not filter, Object extraData) {
Filter child = filter.getFilter();
// these filter types are already enclosed in parentheses
boolean extraParens =
!(child instanceof And || child instanceof Or || child instanceof PropertyIsNull);
append(extraData, "NOT ", extraParens ? "(" : "");
child.accept(this, extraData);
return append(extraData, extraParens ? ")" : "");
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(ExcludeFilter filter, Object extraData) {
return dialect.appendComment(append(extraData, "0 = 1"), "EXCLUDE");
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(Or filter, Object extraData) {
return visit(filter, "OR", extraData);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public Object visit(PropertyIsNull filter, Object extraData) {
final PropertyName propertyName = (PropertyName) filter.getExpression();
final String propertyTypesParam = propertyTypesParam(propertyName);
append(
extraData,
"(oid IN (SELECT oid FROM object_property WHERE property_type IN (:",
propertyTypesParam,
") AND value IS NULL) OR oid NOT IN (SELECT oid FROM object_property WHERE property_type IN (:",
propertyTypesParam,
")))");
return dialect.appendComment(extraData, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void applyOffsetLimit(
StringBuilder sql, @Nullable Integer offset, @Nullable Integer limit) {
// some db's require limit to be present of offset is
if (offset != null && limit == null) {
limit = Integer.MAX_VALUE; // ensure we don't wrap around
}
if (limit != null && offset == null) {
offset = 0;
limit += 1; // not zero-based
}
if (offset != null && limit != null) {
sql.insert(
0,
"SELECT * FROM (SELECT query.*, rownum rnum FROM ("
+ (isDebugMode() ? "\n" : ""));
sql.append(") query");
appendIfDebug(sql, "\n", " ");
if (limit != Integer.MAX_VALUE) {
limit = offset + limit;
}
sql.append("WHERE rownum <= ").append(limit).append(")");
appendIfDebug(sql, "\n", " ");
sql.append("WHERE rnum > ").append(offset);
}
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public String build() {
String whereClause = buildWhereClause();
StringBuilder query = new StringBuilder();
if (isCountQuery) {
query.append("SELECT COUNT(oid) FROM object WHERE type_id IN (:types)");
dialect.appendComment(query, queryType.getName());
if (whereClause != null) {
dialect.appendIfDebug(query, "", " ");
query.append("AND ").append(whereClause);
}
} else {
if (sortOrder != null) {
querySortBy(query, whereClause, sortOrder);
} else {
query.append("SELECT id FROM object WHERE type_id IN (:types)");
dialect.appendComment(query, queryType.getName());
dialect.appendIfDebug(query, "", " ");
if (whereClause != null) {
query.append("AND ").append(whereClause);
dialect.appendIfDebug(query, whereClause.endsWith("\n") ? "" : " ", " ");
}
query.append("ORDER BY oid");
}
applyOffsetLimit(query);
}
return query.toString().trim();
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void setDebugMode(boolean debugMode) {
setProperty("debugMode", String.valueOf(debugMode));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public boolean isDebugMode() {
return Boolean.parseBoolean(getProperty("debugMode", "false"));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public ConfigDatabase configDatabase() {
return new ConfigDatabase(
new JDBCLoaderProperties(null),
dataSource(),
new XStreamInfoSerialBinding(new XStreamPersisterFactory()));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsEqualToSensitiveDebugEnabledEscaping() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value = :value0) /* [ name = FOO*\\/BAR ] */\n";
Filter filter = FACTORY.equal(FACTORY.property("name"), FACTORY.literal("FOO*/BAR"), true);
verifyForIds(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsNotEqualToInsensitiveDebugDisabled() {
String expected =
"NOT (oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND UPPER(value) = :value0)) ";
Filter filter = FACTORY.notEqual(FACTORY.property("name"), FACTORY.literal("quux"), false);
verifyForIds(expected, false, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForCountIsNotEqualToInsensitiveDebugEnabled() {
String expected =
"NOT (oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND UPPER(value) = :value0) /* [ name = quux ] */\n)";
Filter filter = FACTORY.notEqual(FACTORY.property("name"), FACTORY.literal("quux"), false);
verifyForCount(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsUnknownProperty() {
dialect.setDebugMode(false);
String expected = "SELECT id FROM object WHERE type_id IN (:types) ORDER BY oid";
Filter filter = Predicates.equal("foo.bar.baz", "quux");
QueryBuilder<?> builder =
QueryBuilder.forIds(dialect, WorkspaceInfo.class, dbMappings).filter(filter);
String actual = builder.build();
assertEquals(expected, actual);
assertEquals(Filter.INCLUDE, builder.getSupportedFilter());
assertEquals(filter, builder.getUnsupportedFilter());
assertFalse(builder.isOffsetLimitApplied());
assertEquals(1, builder.getNamedParameters().size());
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForCountIsLikeSensitiveDebugDisabled() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value LIKE :value0)";
Filter filter = FACTORY.like(FACTORY.property("name"), "%quux%", "%", "_", "\\", true);
verifyForCount(expected, false, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsLikeSensitiveDebugEnabledEscaping2() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value LIKE :value0) /* [ name is like %FOO*\\/BAR% ] */\n";
Filter filter = FACTORY.like(FACTORY.property("name"), "%FOO*/BAR%", "%", "_", "\\", true);
verifyForIds(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsEqualToInsensitiveDebugEnabled() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND UPPER(value) = :value0) /* [ name = quux ] */\n";
Filter filter = FACTORY.equal(FACTORY.property("name"), FACTORY.literal("quux"), false);
verifyForIds(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsLikeSensitiveDebugEnabledEscaping1() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value LIKE :value0) /* [ name is like %\\'FOO% ] */\n";
Filter filter = FACTORY.like(FACTORY.property("name"), "%\\'FOO%", "%", "_", "\\", true);
verifyForIds(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForCountIsEqualToSensitiveDebugEnabled() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value = :value0) /* [ name = quux ] */";
Filter filter = FACTORY.equal(FACTORY.property("name"), FACTORY.literal("quux"), true);
verifyForCount(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsNotNullDebugEnabled() {
String expected =
"NOT (oid IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0) AND value IS NULL) OR oid NOT IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0))) /* [ name IS NULL ] */\n";
verifyForIds(expected, true, Predicates.not(Predicates.isNull("name")));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForCountIsNotNullDebugEnabled() {
String expected =
"NOT (oid IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0) AND value IS NULL) OR oid NOT IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0))) /* [ name IS NULL ] */";
verifyForCount(expected, true, Predicates.not(Predicates.isNull("name")));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIncludeWithOffSetAndLimitDebugDisabled() {
dialect.setDebugMode(false);
String expected =
"SELECT id FROM object WHERE type_id IN (:types) ORDER BY oid LIMIT 10 OFFSET 5";
String actual =
QueryBuilder.forIds(dialect, WorkspaceInfo.class, dbMappings)
.offset(5)
.limit(10)
.build();
assertEquals(expected, actual);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsNotEqualToSensitiveDebugEnabledEscaping() {
String expected =
"NOT (oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND value = :value0) /* [ name = FOO*\\/BAR ] */\n) ";
Filter filter =
FACTORY.notEqual(FACTORY.property("name"), FACTORY.literal("FOO*/BAR"), true);
verifyForIds(expected, true, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsOrIsInstanceofDebugDisabled() {
String expected = "(type_id = 14 OR 0 = 1) ";
Filter filter =
Predicates.or(
Predicates.isInstanceOf(LayerInfo.class),
Predicates.isInstanceOf(String.class));
verifyForIds(expected, false, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsEqualToInsensitiveDebugDisabled() {
String expected =
"oid IN (SELECT oid FROM object_property WHERE property_type "
+ "IN (:ptype0) AND UPPER(value) = :value0) ";
Filter filter = FACTORY.equal(FACTORY.property("name"), FACTORY.literal("quux"), false);
verifyForIds(expected, false, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
private void verifyQuery(
QueryBuilder<?> builder,
String expected,
boolean debugMode,
Filter filter,
SortBy... order) {
dialect.setDebugMode(debugMode);
String actual = builder.filter(filter).sortOrder(order).build();
assertEquals(expected, actual);
if (Filter.INCLUDE.equals(filter)) {
assertEquals(Filter.INCLUDE, builder.getSupportedFilter());
} else {
assertNotEquals(Filter.INCLUDE, builder.getSupportedFilter());
}
assertEquals(Filter.INCLUDE, builder.getUnsupportedFilter());
assertEquals(!actual.startsWith("SELECT COUNT"), builder.isOffsetLimitApplied());
assertFalse(builder.getNamedParameters().isEmpty());
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIncludeWithLimitDebugDisabled() {
dialect.setDebugMode(false);
String expected = "SELECT id FROM object WHERE type_id IN (:types) ORDER BY oid LIMIT 10";
String actual =
QueryBuilder.forIds(dialect, WorkspaceInfo.class, dbMappings).limit(10).build();
assertEquals(expected, actual);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForCountAndIsInstanceofDebugDisabled() {
String expected = "(type_id = 14 AND 0 = 1)";
Filter filter =
Predicates.and(
Predicates.isInstanceOf(LayerInfo.class),
Predicates.isInstanceOf(String.class));
verifyForCount(expected, false, filter);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsSort3DebugDisabled() {
String expected =
"SELECT id FROM (SELECT oid, id FROM object WHERE type_id IN (:types)) object "
+ "LEFT JOIN (SELECT oid, value prop0 FROM object_property "
+ "WHERE property_type IN (:sortProperty0)) subSelect0 ON object.oid = subSelect0.oid "
+ "LEFT JOIN (SELECT oid, value prop1 FROM object_property "
+ "WHERE property_type IN (:sortProperty1)) subSelect1 ON object.oid = subSelect1.oid "
+ "LEFT JOIN (SELECT oid, value prop2 FROM object_property "
+ "WHERE property_type IN (:sortProperty2)) subSelect2 ON object.oid = subSelect2.oid "
+ "ORDER BY prop0 ASC, prop1 DESC, prop2 ASC";
verifyForIds(
expected,
false,
Predicates.acceptAll(),
Predicates.asc("foo"),
Predicates.desc("bar"),
Predicates.asc("baz"));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIncludeWithLimitDebugEnabled() {
dialect.setDebugMode(true);
String expected =
"SELECT id FROM object WHERE type_id IN (:types) /* org.geoserver.catalog.WorkspaceInfo */"
+ "\nORDER BY oid LIMIT 10";
String actual =
QueryBuilder.forIds(dialect, WorkspaceInfo.class, dbMappings).limit(10).build();
assertEquals(expected, actual);
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
public void testForIdsIsNullDebugEnabled() {
String expected =
"(oid IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0) AND value IS NULL) OR oid NOT IN (SELECT oid FROM object_property WHERE property_type IN (:"
+ "ptype0))) /* [ name IS NULL ] */\n";
verifyForIds(expected, true, Predicates.isNull("name"));
} | 1 | Java | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.