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 |
---|---|---|---|---|---|---|---|
foreach ($tr as $td) {
printf($simple_td_format, $td);
} | 1 | 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 | safe |
foreach ($tr as $td) {
printf($simple_td_format, $td);
} | 1 | 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 | safe |
foreach ($categories as $category) {
$decks .= '<div class="card mb-4"><a href="' . $category['url'] . '">';
if ('' !== $category['image']) {
$decks .= '<img class="card-img-top embed-responsive-item" width="200" alt="' .
$category['name'] . '" src="' . $category['image'] . '" />';
}
$decks .= '</a>' .
'<div class="card-body">' .
'<h4 class="card-title text-center">' .
'<a href="' . Strings::htmlentities($category['url']) . '">' .
Strings::htmlentities($category['name']) . '</a>' .
'</h4>' .
'<p class="card-text">' . Strings::htmlentities($category['description']) . '</p>' .
'</div>' .
'</div>';
if ($key % 2 === 0) {
$decks .= '<div class="w-100 d-none d-sm-block d-md-none"></div>';
}
if ($key % 3 === 0) {
$decks .= '<div class="w-100 d-none d-md-block d-lg-none"></div>';
}
if ($key % 4 === 0) {
$decks .= '<div class="w-100 d-none d-lg-block d-xl-block"></div>';
}
$key++;
} | 1 | 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 | safe |
foreach ($this->Category->categories as $cat) {
if (0 === (int)$cat['parent_id']) {
$categories .= sprintf(
'<li><a href="?action=show&cat=%d">%s</a></li>',
$cat['id'],
Strings::htmlentities($cat['name'])
);
}
} | 1 | 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 | safe |
foreach ($news as $item) {
$url = sprintf(
'%sindex.php?action=news&newsid=%d&newslang=%s',
$this->config->getDefaultUrl(),
$item['id'],
$item['lang']
);
$oLink = new Link($url, $this->config);
if (isset($item['header'])) {
$oLink->itemTitle = Strings::htmlentities($item['header']);
}
$output .= sprintf(
'<h6%s><a id="news_%d" href="%s">%s <i aria-hidden="true" class="fa fa-caret-right"></i></a></h6>',
' class="pmf-news-heading"',
$item['id'],
$oLink->toString(),
Strings::htmlentities($item['header'])
);
$output .= sprintf('%s', $item['content']);
if (strlen($item['link']) > 1) {
$output .= sprintf(
'<br>%s <a href="%s" target="_%s">%s</a>',
$this->pmfLang['msgInfo'],
$item['link'],
$item['target'],
$item['linkTitle']
);
}
$output .= sprintf('<small class="text-muted">%s</small>', $date->format($item['date']));
} | 1 | 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 | safe |
$message = ['error' => $PMF_LANG['ad_passwd_fail']]; | 1 | PHP | CWE-521 | Weak Password Requirements | The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts. | https://cwe.mitre.org/data/definitions/521.html | safe |
foreach ($tagList as $tagId => $tagName) {
$totFaqByTag = count($this->getFaqsByTagName($tagName));
if ($totFaqByTag > 0) {
$tags[$tagName]['id'] = $tagId;
$tags[$tagName]['name'] = Strings::htmlentities($tagName);
$tags[$tagName]['count'] = $totFaqByTag;
}
} | 1 | 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 | safe |
foreach ($allUsers as $userId) {
if (-1 !== $userId) {
$this->user->getUserById($userId);
$options .= sprintf(
'<option value="%d" %s>%s (%s)</option>',
$userId,
(($userId === $id) ? 'selected' : ''),
Strings::htmlentities($this->user->getUserData('display_name')),
$this->user->getLogin()
);
}
} | 1 | 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 | safe |
foreach ($news as $item) {
$url = sprintf(
'%sindex.php?action=news&newsid=%d&newslang=%s',
$this->config->getDefaultUrl(),
$item['id'],
$item['lang']
);
$oLink = new Link($url, $this->config);
if (isset($item['header'])) {
$oLink->itemTitle = Strings::htmlentities($item['header']);
}
$output .= sprintf(
'<h6%s><a id="news_%d" href="%s">%s <i aria-hidden="true" class="fa fa-caret-right"></i></a></h6>',
' class="pmf-news-heading"',
$item['id'],
Strings::htmlentities($oLink->toString()),
Strings::htmlentities($item['header'])
);
$output .= sprintf('%s', $item['content']);
if (strlen($item['link']) > 1) {
$output .= sprintf(
'<br>%s <a href="%s" target="_%s">%s</a>',
$this->pmfLang['msgInfo'],
Strings::htmlentities($item['link']),
$item['target'],
Strings::htmlentities($item['linkTitle'])
);
}
$output .= sprintf('<small class="text-muted">%s</small>', $date->format($item['date']));
} | 1 | 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 | safe |
foreach ($comments as $item) {
$output .= '<div class="row mt-2 mb-2">';
$output .= ' <div class="col-sm-1">';
$output .= ' <div class="thumbnail">';
$output .= $gravatar->getImage($item->getEmail(), ['class' => 'img-thumbnail']);
$output .= ' </div>';
$output .= ' </div>';
$output .= ' <div class="col-sm-11">';
$output .= ' <div class="card">';
$output .= ' <div class="card-header card-header-comments">';
$output .= sprintf(
'<strong><a href="mailto:%s">%s</a></strong>',
$mail->safeEmail($item->getEmail()),
Strings::htmlentities($item->getUsername())
);
$output .= sprintf(' <span class="text-muted">(%s)</span>', $date->format($item->getDate()));
$output .= ' </div>';
$output .= sprintf(
'<div class="card-body">%s</div>',
$this->showShortComment($item->getId(), $item->getComment())
);
$output .= ' </div>';
$output .= ' </div>';
$output .= '</div>';
} | 1 | 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 | safe |
$message = ['error' => 'User ID / email mismatch!']; | 1 | PHP | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
foreach ($onAttributes as $onAttribute) {
$onAttribute->ownerElement->removeAttributeNode($onAttribute);
} | 1 | 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 | safe |
foreach ($news as $item) {
$url = sprintf(
'%sindex.php?action=news&newsid=%d&newslang=%s',
$this->config->getDefaultUrl(),
$item['id'],
$item['lang']
);
$oLink = new Link($url, $this->config);
if (isset($item['header'])) {
$oLink->itemTitle = Strings::htmlentities($item['header']);
}
$output .= sprintf(
'<h6%s><a id="news_%d" href="%s">%s <i aria-hidden="true" class="fa fa-caret-right"></i></a></h6>',
' class="pmf-news-heading"',
$item['id'],
Strings::htmlentities($oLink->toString()),
Strings::htmlentities($item['header'])
);
$output .= sprintf('%s', strip_tags($item['content']));
if (strlen($item['link']) > 1) {
$output .= sprintf(
'<br>%s <a href="%s" target="_%s">%s</a>',
$this->pmfLang['msgInfo'],
Strings::htmlentities($item['link']),
$item['target'],
Strings::htmlentities($item['linkTitle'])
);
}
$output .= sprintf('<small class="text-muted">%s</small>', $date->format($item['date']));
} | 1 | 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 | safe |
foreach ($data as $row) {
$csvRow = array_map(['phpMyFAQ\Report', 'sanitize'], $row);
$actual[] = implode(',', $csvRow);
} | 1 | PHP | CWE-1236 | Improper Neutralization of Formula Elements in a CSV File | The product saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by a spreadsheet product. | https://cwe.mitre.org/data/definitions/1236.html | safe |
foreach ($attachmentList as $attachment) {
$html .= sprintf(
'<li><i class="fa fa-%s" aria-hidden="true"></i> <a href="%s">%s</a></li>',
$this->mapMimeTypeToIcon($attachment->getMimeType()),
$attachment->buildUrl(),
Strings::htmlentities($attachment->getFilename())
);
} | 1 | 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 | safe |
protected function __construct($userinfo = [])
{
$this->initMonolog();
self::$userinfo = $userinfo;
self::$logtypes = [];
if ((Settings::Get('logger.logtypes') == null || Settings::Get('logger.logtypes') == '') && (Settings::Get('logger.enabled') !== null && Settings::Get('logger.enabled'))) {
self::$logtypes[0] = 'syslog';
self::$logtypes[1] = 'mysql';
} else {
if (Settings::Get('logger.logtypes') !== null && Settings::Get('logger.logtypes') != '') {
self::$logtypes = explode(',', Settings::Get('logger.logtypes'));
} else {
self::$logtypes = null;
}
}
if (self::$is_initialized == false) {
foreach (self::$logtypes as $logger) {
switch ($logger) {
case 'syslog':
self::$ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG));
break;
case 'file':
$logger_logfile = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/logs/' . Settings::Get('logger.logfile'));
// is_writable needs an existing file to check if it's actually writable
@touch($logger_logfile);
if (empty($logger_logfile) || !is_writable($logger_logfile)) {
Settings::Set('logger.logfile', 'froxlor.log');
$logger_logfile = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/logs/froxlor.log');
@touch($logger_logfile);
if (empty($logger_logfile) || !is_writable($logger_logfile)) {
// not writable in our own directory? Skip
break;
}
}
self::$ml->pushHandler(new StreamHandler($logger_logfile, Logger::DEBUG));
break;
case 'mysql':
self::$ml->pushHandler(new MysqlHandler(Logger::DEBUG));
break;
}
}
self::$is_initialized = true;
}
} | 1 | 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 | safe |
public function update()
{
$id = $this->getParam('id', true, 0);
$un_optional = $id > 0;
$username = $this->getParam('username', $un_optional, '');
// validation
$result = $this->apiCall('DirProtections.get', [
'id' => $id,
'username' => $username
]);
$id = $result['id'];
// parameters
$password = $this->getParam('directory_password', true, '');
$authname = $this->getParam('directory_authname', true, $result['authname']);
// get needed customer info
$customer = $this->getCustomerData();
// validation
$authname = Validate::validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', [], true);
$password = Validate::validate($password, 'password', '', '', [], true);
$password = Crypt::validatePassword($password, true);
$upd_query = "";
$upd_params = [
"id" => $result['id'],
"cid" => $customer['customerid']
];
if (!empty($password)) {
if ($password == $result['username']) {
Response::standardError('passwordshouldnotbeusername', '', true);
}
$password_enc = Crypt::makeCryptPassword($password, true);
$upd_query .= "`password`= :password_enc";
$upd_params['password_enc'] = $password_enc;
}
if ($authname != $result['authname']) {
if (!empty($upd_query)) {
$upd_query .= ", ";
}
$upd_query .= "`authname` = :authname";
$upd_params['authname'] = $authname;
}
// build update query
if (!empty($upd_query)) {
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET " . $upd_query . " WHERE `id` = :id AND `customerid`= :cid
");
Database::pexecute($upd_stmt, $upd_params, true, true);
Cronjob::inserttask(TaskId::REBUILD_VHOST);
}
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] updated directory-protection '" . $result['username'] . " (" . $result['path'] . ")'");
$result = $this->apiCall('DirProtections.get', [
'id' => $result['id']
]);
return $this->response($result);
} | 1 | PHP | CWE-521 | Weak Password Requirements | The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts. | https://cwe.mitre.org/data/definitions/521.html | safe |
public function update()
{
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
// required parameter
$id = $this->getParam('id');
$result = $this->apiCall('Cronjobs.get', [
'id' => $id
]);
// split interval
$cur_int = explode(" ", $result['interval']);
// parameter
$isactive = $this->getBoolParam('isactive', true, $result['isactive']);
$interval_value = $this->getParam('interval_value', true, $cur_int[0]);
$interval_interval = $this->getParam('interval_interval', true, $cur_int[1]);
// validation
if ($isactive != 1) {
$isactive = 0;
}
$interval_value = Validate::validate($interval_value, 'interval_value', '/^([0-9]+)$/Di', 'stringisempty', [], true);
$interval_interval = Validate::validate($interval_interval, 'interval_interval', '', '', [], true);
if (!in_array(strtoupper($interval_interval), $this->allowed_intervals)) {
Response::standardError('invalidcronjobintervalvalue', implode(", ", $this->allowed_intervals), true);
}
// put together interval value
$interval = $interval_value . ' ' . strtoupper($interval_interval);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CRONRUNS . "`
SET `isactive` = :isactive, `interval` = :int
WHERE `id` = :id
");
Database::pexecute($upd_stmt, [
'isactive' => $isactive,
'int' => $interval,
'id' => $id
], true, true);
// insert task to re-generate the cron.d-file
Cronjob::inserttask(TaskId::REBUILD_CRON);
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] cronjob with description '" . $result['module'] . '/' . $result['cronfile'] . "' has been updated by '" . $this->getUserDetail('loginname') . "'");
$result = $this->apiCall('Cronjobs.get', [
'id' => $id
]);
return $this->response($result);
}
throw new Exception("Not allowed to execute given command.", 403);
} | 1 | 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 | safe |
private function correctErrorDocument(string $errdoc, $throw_exception = false)
{
if (trim($errdoc) != '') {
// not a URL
if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || !Validate::validateUrl($errdoc)) {
// a file
if (substr($errdoc, 0, 1) != '"') {
$errdoc = FileDir::makeCorrectFile($errdoc);
// apache needs a starting-slash (starting at the domains-docroot)
if (!substr($errdoc, 0, 1) == '/') {
$errdoc = '/' . $errdoc;
}
} elseif (preg_match('/^"([^\r\n\t\f\0"]+)"$/', $errdoc)) {
// a string (check for ending ")
// string won't work for lighty
if (Settings::Get('system.webserver') == 'lighttpd') {
Response::standardError('stringerrordocumentnotvalidforlighty', '', $throw_exception);
}
} else {
Response::standardError('invaliderrordocumentvalue', '', $throw_exception);
}
} else {
if (Settings::Get('system.webserver') == 'lighttpd') {
Response::standardError('urlerrordocumentnotvalidforlighty', '', $throw_exception);
}
}
}
return trim($errdoc);
} | 1 | 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 | safe |
public function testCustomerDirOptionsAddMalformedInvalid()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'path' => '/testmalformed',
'error404path' => '"'.PHP_EOL.'IncludeOptional /something/else/'.PHP_EOL.'#'
];
$this->expectExceptionMessage("The value given as ErrorDocument does not seem to be a valid file, URL or string.");
DirOptions::getLocal($customer_userdata, $data)->add();
$data = [
'path' => '/testmalformed',
'error404path' => '"something"oh no a quote within the string"'
];
$this->expectExceptionMessage("The value given as ErrorDocument does not seem to be a valid file, URL or string.");
DirOptions::getLocal($customer_userdata, $data)->add();
} | 1 | 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 | safe |
public function testCustomerDirOptionsAddMalformed()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'path' => '/testmalformed',
'error404path' => '/"'.PHP_EOL.'something/../../../../weird 404.html'.PHP_EOL.'#'
];
$json_result = DirOptions::getLocal($customer_userdata, $data)->add();
$result = json_decode($json_result, true)['data'];
$expected = '/"something/././././weird\ 404.html#';
$this->assertEquals($expected, $result['error404path']);
} | 1 | 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 | safe |
foreach ($setting as $varname => $value) {
// set all group/varname:values which are not in the import file
if (!isset($_data[$setting_group.'.'.$varname])) {
$_data[$setting_group.'.'.$varname] = $value;
}
} | 1 | 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 | safe |
$form_data[str_replace(".", "_", $key)] = $value;
}
// store new data
$settings_data = PhpHelper::loadConfigArrayDir(Froxlor::getInstallDir() . '/actions/admin/settings/');
Settings::loadSettingsInto($settings_data);
if (Form::processForm($settings_data, $form_data, [], null, true)) {
// save to DB
Settings::Flush();
// all good
return true;
} else {
throw new Exception("Importing settings failed");
}
}
throw new Exception("Invalid JSON data: " . json_last_error_msg());
} | 1 | 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 | safe |
public static function export()
{
$settings_definitions = [];
foreach (PhpHelper::loadConfigArrayDir('./actions/admin/settings/')['groups'] as $group) {
foreach ($group['fields'] as $field) {
$settings_definitions[$field['settinggroup']][$field['varname']] = $field;
}
}
$result_stmt = Database::query("
SELECT * FROM `" . TABLE_PANEL_SETTINGS . "` ORDER BY `settingid` ASC
");
$_data = [];
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$index = $row['settinggroup'] . "." . $row['varname'];
if (!in_array($index, self::$no_export)) {
$_data[$index] = $row['value'];
}
if (array_key_exists($row['settinggroup'], $settings_definitions) && array_key_exists($row['varname'],
$settings_definitions[$row['settinggroup']])) {
// Export image file
if ($settings_definitions[$row['settinggroup']][$row['varname']]['type'] === "image") {
if ($row['value'] === "") {
continue;
}
$_data[$index . '.image_data'] = base64_encode(file_get_contents(explode('?', $row['value'],
2)[0]));
}
}
}
// add checksum for validation
$_data['_sha'] = sha1(var_export($_data, true));
$_export = json_encode($_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if (!$_export) {
throw new Exception("Error exporting settings: " . json_last_error_msg());
}
return $_export;
} | 1 | 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 | safe |
private function resetTablelisting()
{
Listing::deleteColumnListingForUser([Request::post('listing') => []]);
return $this->jsonResponse([]);
} | 1 | PHP | CWE-352 | Cross-Site Request Forgery (CSRF) | The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request. | https://cwe.mitre.org/data/definitions/352.html | safe |
private function updateTablelisting()
{
$columns = [];
foreach ((Request::post('columns') ?? []) as $value) {
$columns[] = $value;
}
if (!empty($columns)) {
$columns = Listing::storeColumnListingForUser([Request::post('listing') => $columns]);
return $this->jsonResponse($columns);
}
return $this->errorResponse('At least one column must be selected', 406);
} | 1 | PHP | CWE-352 | Cross-Site Request Forgery (CSRF) | The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request. | https://cwe.mitre.org/data/definitions/352.html | safe |
$path = Froxlor::getInstallDir() . '/img/';
if (!is_dir($path) && !mkdir($path, 0775)) {
throw new Exception("img directory does not exist and cannot be created");
}
// Make sure we can write to the upload directory
if (!is_writable($path)) {
if (!chmod($path, 0775)) {
throw new Exception("Cannot write to img directory");
}
}
if (Validate::validateBase64Image($value)) {
$img_data = base64_decode($value);
$img_filename = explode('?', $_data[$index_split[0] . '.' . $index_split[1]], 2)[0];
$spl = explode('.', $img_filename);
$file_extension = strtolower(array_pop($spl));
unset($spl);
if (!in_array($file_extension, [
'jpeg',
'jpg',
'png',
'gif'
])) {
throw new Exception("Invalid file-extension, use one of: jpeg, jpg, png, gif");
}
$img_filename = 'img/' . bin2hex(random_bytes(16)) . '.' . $file_extension;
file_put_contents(Froxlor::getInstallDir() . '/' . $img_filename, $img_data);
$img_index = $index_split[0].'.'.$index_split[1];
Settings::Set($img_index, $img_filename . '?v=' . time());
}
}
}
// all good
return true;
} else {
throw new Exception("Importing settings failed");
}
}
throw new Exception("Invalid JSON data: " . json_last_error_msg());
} | 1 | 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 | safe |
public static function validateBase64Image(string $base64string) {
if (!extension_loaded('gd')) {
Response::standardError('phpgdextensionnotavailable', null, true);
}
// Decode the base64 string
$data = base64_decode($base64string);
// Create an image from the decoded data
$image = @imagecreatefromstring($data);
// Check if the image was created successfully
if (!$image) {
return false;
}
// Get the MIME type of the image
$mime = image_type_to_mime_type(getimagesizefromstring($data)[2]);
// Check if the MIME type is a valid image MIME type
if (strpos($mime, 'image/') !== 0) {
return false;
}
// If everything is okay, return true
return true;
} | 1 | 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 | safe |
public function __construct()
{
$this->headers = getallheaders();
// set header for the response
header("Accept: application/json");
header("Content-Type: application/json");
// check whether API interface is enabled after all
if (Settings::Get('api.enabled') != 1) {
throw new Exception('API is not enabled. Please contact the administrator if you think this is wrong.', 400);
}
RateLimiter::run();
} | 1 | PHP | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public static function run(bool $install_mode = false)
{
// default interval = 60 sec
self::$reset_time = time() + 60;
if (!$install_mode) {
self::$limit_per_interval = Settings::Get('system.req_limit_per_interval');
self::$reset_time = time() + Settings::Get('system.req_limit_interval');
}
// Get the remaining requests and reset time from the headers
$remaining = isset($_SESSION['HTTP_X_RATELIMIT_REMAINING']) ? (int)$_SESSION['HTTP_X_RATELIMIT_REMAINING'] : self::$limit_per_interval;
$reset = isset($_SESSION['HTTP_X_RATELIMIT_RESET']) ? (int)$_SESSION['HTTP_X_RATELIMIT_RESET'] : self::$reset_time;
// check if reset time is due
if (time() > $reset) {
$remaining = self::$limit_per_interval;
$reset = self::$reset_time;
}
// If we've hit the limit, return an error
if ($remaining <= 0) {
header('HTTP/1.1 429 Too Many Requests');
header("Retry-After: $reset");
exit();
}
// Decrement the remaining requests and update the headers
$remaining--;
$_SESSION['HTTP_X_RATELIMIT_REMAINING'] = $remaining;
$_SESSION['HTTP_X_RATELIMIT_RESET'] = $reset;
header("X-RateLimit-Limit: " . self::$limit_per_interval);
header("X-RateLimit-Remaining: " . $remaining);
header("X-RateLimit-Reset: " . $reset);
} | 1 | PHP | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
$str .= self::tabPrefix($depth, "'{$key}' => $value,\n");
} else {
if ($key == 'password') {
// special case for passwords (nowdoc)
$str .= self::tabPrefix($depth, "'{$key}' => <<<'EOT'\n{$value}\nEOT,\n");
} else {
$str .= self::tabPrefix($depth, "'{$key}' => '{$value}',\n");
}
}
} else {
$str .= self::parseArrayToString($value, $key, ($depth + 1));
}
} | 1 | PHP | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
function finishLogin($userinfo)
{
if (isset($userinfo['userid']) && $userinfo['userid'] != '') {
session_regenerate_id();
CurrentUser::setData($userinfo);
$language = $userinfo['def_language'] ?? Settings::Get('panel.standardlanguage');
CurrentUser::setField('language', $language);
if (isset($userinfo['theme']) && $userinfo['theme'] != '') {
$theme = $userinfo['theme'];
} else {
$theme = Settings::Get('panel.default_theme');
CurrentUser::setField('theme', $theme);
}
$qryparams = [];
if (isset($_SESSION['lastqrystr']) && !empty($_SESSION['lastqrystr'])) {
parse_str(urldecode($_SESSION['lastqrystr']), $qryparams);
unset($_SESSION['lastqrystr']);
}
if ($userinfo['adminsession'] == '1') {
if (Froxlor::hasUpdates() || Froxlor::hasDbUpdates()) {
Response::redirectTo('admin_updates.php?page=overview');
} else {
if (isset($_SESSION['lastscript']) && !empty($_SESSION['lastscript'])) {
$lastscript = $_SESSION['lastscript'];
unset($_SESSION['lastscript']);
if (preg_match("/customer\_/", $lastscript) === 1) {
Response::redirectTo('admin_customers.php', [
"page" => "customers"
]);
} else {
Response::redirectTo($lastscript, $qryparams);
}
} else {
Response::redirectTo('admin_index.php', $qryparams);
}
}
} else {
if (isset($_SESSION['lastscript']) && !empty($_SESSION['lastscript'])) {
$lastscript = $_SESSION['lastscript'];
unset($_SESSION['lastscript']);
Response::redirectTo($lastscript, $qryparams);
} else {
Response::redirectTo('customer_index.php', $qryparams);
}
}
}
return false;
} | 1 | PHP | CWE-384 | Session Fixation | Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions. | https://cwe.mitre.org/data/definitions/384.html | safe |
private function getModFunctionString(int $level = 1, int $max_level = 5, $trace = null)
{
// which class called us
$_class = get_called_class();
if (empty($trace)) {
// get backtrace
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
// check class and function
$class = $trace[$level]['class'];
$func = $trace[$level]['function'];
// is it the one we are looking for?
if ($class != $_class && $level <= $max_level) {
// check one level deeper
return $this->getModFunctionString(++$level, $max_level, $trace);
}
return str_replace("Froxlor\\Api\\Commands\\", "", $class) . ':' . $func;
} | 1 | PHP | NVD-CWE-noinfo | null | null | null | safe |
protected function getBoolParam(string $param = null, bool $optional = false, $default = false)
{
$_default = '0';
if ($default) {
$_default = '1';
}
$param_value = $this->getParam($param, $optional, $_default);
if ($param_value && intval($param_value) != 0) {
return '1';
}
return '0';
} | 1 | PHP | NVD-CWE-noinfo | null | null | null | safe |
protected function getUlParam(string $param = null, string $ul_field = null, bool $optional = false, $default = 0)
{
$param_value = (int)$this->getParam($param, $optional, $default);
$ul_field_value = $this->getBoolParam($ul_field, true, 0);
if ($ul_field_value != '0') {
$param_value = -1;
}
return $param_value;
} | 1 | PHP | NVD-CWE-noinfo | null | null | null | safe |
public function __construct(array $params = null)
{
if (!is_null($params)) {
$params = $this->trimArray($params);
}
$this->cmd_params = $params;
} | 1 | PHP | NVD-CWE-noinfo | null | null | null | safe |
protected function getParam(string $param = null, bool $optional = false, $default = '')
{
// does it exist?
if (!isset($this->cmd_params[$param])) {
if ($optional === false) {
// get module + function for better error-messages
$inmod = $this->getModFunctionString();
throw new Exception('Requested parameter "' . $param . '" could not be found for "' . $inmod . '"', 404);
}
return $default;
}
// is it empty? - test really on string, as value 0 is being seen as empty by php
if (!is_array($this->cmd_params[$param]) && trim($this->cmd_params[$param]) === "") {
if ($optional === false) {
// get module + function for better error-messages
$inmod = $this->getModFunctionString();
throw new Exception('Requested parameter "' . $param . '" is empty where it should not be for "' . $inmod . '"', 406);
}
return '';
}
// everything else is fine
return $this->cmd_params[$param];
} | 1 | PHP | NVD-CWE-noinfo | null | null | null | safe |
public function getFilters()
{
return [
new TwigFilter('formatBytes', [
$this,
'formatBytesFilter'
]),
new TwigFilter('formatIP', [
$this,
'formatIPFilter'
]),
new TwigFilter('idnDecode', [
$this,
'idnDecodeFilter'
]),
new TwigFilter('markdown', [
$this,
'callMarkdown'
])
];
} | 1 | 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 | safe |
private function validateDomainDocumentRoot($path = null, $url = null, $customer = null, $completedomain = null, &$_doredirect = false)
{
// check whether an URL was specified
$_doredirect = false;
if (!empty($url) && Validate::validateUrl($url, true)) {
$path = $url;
$_doredirect = true;
} else {
$path = Validate::validate($path, 'path', '', '', [], true);
}
// check whether path is a real path
if (!preg_match('/^https?\:\/\//', $path) || !Validate::validateUrl($path, true)) {
if (strstr($path, ":") !== false) {
Response::standardError('pathmaynotcontaincolon', '', true);
}
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if ((($path == '') || ($path == '/')) && Settings::Get('system.documentroot_use_default_value') == 1) {
$path = FileDir::makeCorrectDir($customer['documentroot'] . '/' . $completedomain, $customer['documentroot']);
} else {
$path = FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path, $customer['documentroot']);
}
} else {
// no it's not, create a redirect
$_doredirect = true;
}
return $path;
} | 1 | PHP | CWE-59 | Improper Link Resolution Before File Access ('Link Following') | The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. | https://cwe.mitre.org/data/definitions/59.html | safe |
public function testCustomerFtpsAddSymlinkOutsideHomedir()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data']; //
$customer_userdata['documentroot'] = sys_get_temp_dir() . '/';
@unlink($customer_userdata['documentroot'] . '/frx');
symlink(Froxlor::getInstallDir(), $customer_userdata['documentroot'] . '/frx');
$data = [
'ftp_password' => 'h4xXx0r',
'path' => '/frx/sub',
'ftp_description' => 'testing',
'sendinfomail' => TRAVIS_CI == 1 ? 0 : 1
];
$this->expectExceptionMessage('Found symlink pointing outside of customer home directory: /frx');
Ftps::getLocal($customer_userdata, $data)->add();
} | 1 | PHP | CWE-59 | Improper Link Resolution Before File Access ('Link Following') | The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. | https://cwe.mitre.org/data/definitions/59.html | safe |
public function testAdminFtpsAddCustomerRequired()
{
global $admin_userdata;
$data = [
'ftp_password' => 'h4xXx0r',
'path' => '/',
'ftp_description' => 'testing',
'sendinfomail' => 1
];
$this->expectExceptionCode(406);
$this->expectExceptionMessage('Requested parameter "loginname" is empty where it should not be for "Customers:get"');
Ftps::getLocal($admin_userdata, $data)->add();
} | 1 | PHP | CWE-59 | Improper Link Resolution Before File Access ('Link Following') | The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. | https://cwe.mitre.org/data/definitions/59.html | safe |
public function testCustomerFtpsAddNoMoreResources()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data']; //
$customer_userdata['ftps_used'] = 100;
$this->expectExceptionCode(406);
$this->expectExceptionMessage('No more resources available');
Ftps::getLocal($customer_userdata)->add();
} | 1 | PHP | CWE-59 | Improper Link Resolution Before File Access ('Link Following') | The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. | https://cwe.mitre.org/data/definitions/59.html | safe |
public function uploadImageAction(Request $request)
{
$userObj = User::getById($this->getUserId($request));
if (!$userObj) {
throw $this->createNotFoundException();
}
if ($userObj->isAdmin() && !$this->getAdminUser()->isAdmin()) {
throw $this->createAccessDeniedHttpException('Only admin users are allowed to modify admin users');
}
//Check if uploaded file is an image
$avatarFile = $request->files->get('Filedata');
$assetType = Asset::getTypeFromMimeMapping($avatarFile->getMimeType(), $avatarFile);
if (!$avatarFile instanceof UploadedFile || $assetType !== 'image') {
throw new \Exception('Unsupported file format.');
}
$userObj->setImage($_FILES['Filedata']['tmp_name']);
// set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
// Ext.form.Action.Submit and mark the submission as failed
$response = $this->adminJson(['success' => true]);
$response->headers->set('Content-Type', 'text/html');
return $response;
} | 1 | 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 | safe |
$slug = htmlspecialchars($item->getSlug());
$foundSlug = true;
if (strlen($slug) > 0) {
$slugToCompare = preg_replace('/[#\?\*\:\\\\<\>\|"%&@=;]/', '-', $item->getSlug());
if($item->getSlug() !== $slugToCompare){
throw new Model\Element\ValidationException('Slug contains forbidden characters!');
}
$document = Model\Document::getByPath($slug);
if ($document) {
throw new Model\Element\ValidationException('Slug must be unique. Found conflict with document path "' . $slug . '"');
}
if (strlen($slug) < 2 || $slug[0] !== '/') {
throw new Model\Element\ValidationException('Slug must be at least 2 characters long and start with slash');
}
if (strpos($slug, '//') !== false || !filter_var('https://example.com' . $slug, FILTER_VALIDATE_URL)) {
throw new Model\Element\ValidationException('Slug "' . $slug . '" is not valid');
}
}
}
} | 1 | 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 | safe |
foreach ($items as $item) {
$type = $item['type'];
unset($item['type']);
$pipe->addItem($type, $item, htmlspecialchars($mediaName));
} | 1 | 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 | safe |
return ($mediaOrder[$a] < $mediaOrder[$b]) ? -1 : 1;
});
foreach ($mediaData as $mediaName => $items) {
foreach ($items as $item) {
$type = $item['type'];
unset($item['type']);
$pipe->addItem($type, $item, htmlspecialchars($mediaName));
}
}
$pipe->save();
return $this->adminJson(['success' => true]);
} | 1 | 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 | safe |
$sql .= 'SELECT ' . $db->quoteIdentifier($selectField);
} else {
$sql .= 'SELECT *';
}
if (!empty($config['from'])) {
if (strpos(strtoupper(trim($config['from'])), 'FROM') !== 0) {
$sql .= ' FROM ';
}
$sql .= ' ' . str_replace("\n", ' ', $config['from']);
}
if (!empty($config['where'])) {
if (str_starts_with(strtoupper(trim($config['where'])), 'WHERE')) {
$config['where'] = preg_replace('/^\s*WHERE\s*/', '', $config['where']);
}
$sql .= ' WHERE (' . str_replace("\n", ' ', $config['where']) . ')';
}
if (!empty($config['groupby']) && !$ignoreSelectAndGroupBy) {
if (strpos(strtoupper(trim($config['groupby'])), 'GROUP BY') !== 0) {
$sql .= ' GROUP BY ';
}
$sql .= ' ' . str_replace("\n", ' ', $config['groupby']);
}
if ($drillDownFilters) {
$havingParts = [];
$db = Db::get();
foreach ($drillDownFilters as $field => $value) {
if ($value !== '' && $value !== null) {
$havingParts[] = ($db->quoteIdentifier($field) ." = " . $db->quote($value));
}
}
if ($havingParts) {
$sql .= ' HAVING ' . implode(' AND ', $havingParts);
}
}
return $sql;
} | 1 | 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 | safe |
public function getByUuid($uuid)
{
$queryBuilder = $this->db->createQueryBuilder();
$queryBuilder
->select('*')
->from(self::TABLE_NAME)
->where('uuid = :uuid')
->setParameter('uuid', $uuid, Types::STRING);
$data = $queryBuilder
->execute()
->fetchAssociative();
$model = new Model\Tool\UUID();
$model->setValues($data);
return $model;
} | 1 | 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 | safe |
public function exists($uuid)
{
$queryBuilder = $this->db->createQueryBuilder();
$queryBuilder
->select('uuid')
->from(self::TABLE_NAME)
->where('uuid = :uuid')
->setParameter('uuid', $uuid, Types::STRING);
$result = $queryBuilder
->execute()
->fetchOne();
return (bool) $result;
} | 1 | 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 | safe |
public function setConverter($converter)
{
$this->converter = htmlspecialchars((string)$converter);
return $this;
} | 1 | 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 | safe |
public function setReference($reference)
{
$this->reference = htmlspecialchars($reference);
return $this;
} | 1 | 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 | safe |
public function setLongname($longname)
{
$this->longname = htmlspecialchars($longname);
return $this;
} | 1 | 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 | safe |
public function setGroup($group)
{
$this->group = htmlspecialchars($group);
return $this;
} | 1 | 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 | safe |
public function setAbbreviation($abbreviation)
{
$this->abbreviation = htmlspecialchars($abbreviation);
return $this;
} | 1 | 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 | safe |
public function setName($name)
{
$this->name = SecurityHelper::convertHtmlSpecialChars($name);
return $this;
} | 1 | 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 | safe |
public function setPattern($pattern)
{
$this->pattern = SecurityHelper::convertHtmlSpecialChars($pattern);
return $this;
} | 1 | 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 | safe |
$methods[$key] = SecurityHelper::convertHtmlSpecialChars(trim($method));
}
} | 1 | 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 | safe |
public function setController($controller)
{
$this->controller = SecurityHelper::convertHtmlSpecialChars($controller);
return $this;
} | 1 | 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 | safe |
public function setDefaults($defaults)
{
$this->defaults = SecurityHelper::convertHtmlSpecialChars($defaults);
return $this;
} | 1 | 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 | safe |
public function setVariables($variables)
{
$this->variables = SecurityHelper::convertHtmlSpecialChars($variables);
return $this;
} | 1 | 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 | safe |
public function setReverse($reverse)
{
$this->reverse = SecurityHelper::convertHtmlSpecialChars($reverse);
return $this;
} | 1 | 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 | safe |
public function setKey($key)
{
$this->key = SecurityHelper::convertHtmlSpecialChars($key);
return $this;
} | 1 | 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 | safe |
public function setData($data)
{
$this->data = SecurityHelper::convertHtmlSpecialChars($data);
return $this;
} | 1 | 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 | safe |
public function setDescription($description)
{
$this->description = SecurityHelper::convertHtmlSpecialChars($description);
return $this;
} | 1 | 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 | safe |
public function setName($name)
{
$this->name = SecurityHelper::convertHtmlSpecialChars($name);
return $this;
} | 1 | 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 | safe |
public function setConfig($config)
{
$this->config = SecurityHelper::convertHtmlSpecialChars($config);
return $this;
} | 1 | 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 | safe |
public function setName($name, $locale = null)
{
$this->name = SecurityHelper::convertHtmlSpecialChars($name);
return $this;
} | 1 | 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 | safe |
public function loginAction(Request $request, CsrfProtectionHandler $csrfProtection, Config $config)
{
if ($request->get('_route') === 'pimcore_admin_login_fallback') {
return $this->redirectToRoute('pimcore_admin_login', $request->query->all(), Response::HTTP_MOVED_PERMANENTLY);
}
$csrfProtection->regenerateCsrfToken();
$user = $this->getAdminUser();
if ($user instanceof UserInterface) {
return $this->redirectToRoute('pimcore_admin_index');
}
$params = $this->buildLoginPageViewParams($config);
$session_gc_maxlifetime = ini_get('session.gc_maxlifetime');
if (empty($session_gc_maxlifetime)) {
$session_gc_maxlifetime = 120;
}
$params['csrfTokenRefreshInterval'] = ((int)$session_gc_maxlifetime - 60) * 1000;
if ($request->get('too_many_attempts')) {
$params['error'] = SecurityHelper::convertHtmlSpecialChars($request->get('too_many_attempts'));
}
if ($request->get('auth_failed')) {
$params['error'] = 'error_auth_failed';
}
if ($request->get('session_expired')) {
$params['error'] = 'error_session_expired';
}
if ($request->get('deeplink')) {
$params['deeplink'] = true;
}
$params['browserSupported'] = $this->detectBrowser();
$params['debug'] = \Pimcore::inDebugMode();
return $this->render('@PimcoreAdmin/Admin/Login/login.html.twig', $params);
} | 1 | 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 | safe |
public function setData($data)
{
if ($data instanceof ElementInterface) {
$this->setType(Service::getElementType($data));
$data = $data->getId();
}
$this->data = SecurityHelper::convertHtmlSpecialChars($data);
return $this;
} | 1 | 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 | safe |
public function setName($name)
{
$this->name = SecurityHelper::convertHtmlSpecialChars($name);
return $this;
} | 1 | 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 | safe |
public function __construct(\stdClass $config, array $context = [])
{
$this->label = SecurityHelper::convertHtmlSpecialChars($config->label);
$this->childs = $config->childs;
$this->context = $context;
} | 1 | 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 | safe |
public function setLabel($label)
{
$this->label = SecurityHelper::convertHtmlSpecialChars($label);
} | 1 | 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 | safe |
public function setAttribute($attribute)
{
$this->attribute = SecurityHelper::convertHtmlSpecialChars($attribute);
} | 1 | 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 | safe |
public function setParam1($param1)
{
$this->param1 = SecurityHelper::convertHtmlSpecialChars($param1);
} | 1 | 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 | safe |
public function __construct(\stdClass $config, $context = null)
{
if (!Admin::getCurrentUser()->isAdmin()) {
throw new \Exception('AnyGetter only allowed for admin users');
}
parent::__construct($config, $context);
$this->attribute = SecurityHelper::convertHtmlSpecialChars($config->attribute ?? '');
$this->param1 = SecurityHelper::convertHtmlSpecialChars($config->param1 ?? '');
$this->isArrayType = $config->isArrayType ?? false;
$this->forwardAttribute = $config->forwardAttribute ?? '';
$this->forwardParam1 = $config->forwardParam1 ?? '';
$this->returnLastResult = $config->returnLastResult ?? false;
} | 1 | 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 | safe |
foreach ($keys as $key) {
if (array_key_exists($key, $array)) {
$array[$key] = self::convertHtmlSpecialChars($array[$key]);
}
} | 1 | 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 | safe |
$attribs[] = $key.'="'.SecurityHelper::sanitizeHtmlAttributes($value).'"';
}
}
}
$attribs = array_unique($attribs);
if (array_key_exists('attributes', $this->data) && !empty($this->data['attributes'])) {
$attribs[] = $this->data['attributes'];
}
return '<a href="'.$url.'" '.implode(' ', $attribs).'>' . $prefix . ($noText ? '' : htmlspecialchars($this->data['text'])) . $suffix . '</a>';
} | 1 | 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 | safe |
public function getTabindex()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['tabindex']) ?? '';
} | 1 | 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 | safe |
public function getParameters()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['parameters']) ?? '';
} | 1 | 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 | safe |
public function getAccesskey()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['accesskey']) ?? '';
} | 1 | 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 | safe |
public function setDataFromResource($data)
{
$this->data = \Pimcore\Tool\Serialize::unserialize($data);
if (!is_array($this->data)) {
$this->data = [];
}
//sanitize fields
$fieldsToExclude = ['path'];
foreach($this->data as $key => $value) {
if(!in_array($key, $fieldsToExclude)) {
$this->data[$key] = SecurityHelper::sanitizeHtmlAttributes($value);
}
}
return $this;
} | 1 | 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 | safe |
public function getHref()
{
$this->updatePathFromInternal();
$url = $this->data['path'] ?? '';
if (strlen($this->data['parameters'] ?? '') > 0) {
$url .= (strpos($url, '?') !== false ? '&' : '?') . str_replace('?', '', $this->getParameters());
}
if (strlen($this->data['anchor'] ?? '') > 0) {
$anchor = str_replace('"', urlencode('"'), $this->getAnchor());
$url .= '#' . str_replace('#', '', $anchor);
}
return $url;
} | 1 | 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 | safe |
public function getRel()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['rel']) ?? '';
} | 1 | 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 | safe |
public function getClass()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['class']) ?? '';
} | 1 | 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 | safe |
public function getAnchor()
{
return SecurityHelper::sanitizeHtmlAttributes($this->data['anchor']) ?? '';
} | 1 | 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 | safe |
public function isValidConfigName(string $configName) {
if(!preg_match('/^[a-zA-Z0-9_\-]+$/', $configName)) {
throw new \Exception('The customer report name is invalid');
}
} | 1 | 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 | safe |
public static function initLogger()
{
// special request log -> if parameter pimcore_log is set
if (array_key_exists('pimcore_log', $_REQUEST) && self::inDebugMode()) {
$requestLogName = date('Y-m-d_H-i-s');
if (!empty($_REQUEST['pimcore_log'])) {
$requestLogName = str_replace(['/', '\\', '..'], '-', $_REQUEST['pimcore_log']);
}
$requestLogFile = resolvePath(PIMCORE_LOG_DIRECTORY . '/request-' . $requestLogName . '.log');
if (strpos($requestLogFile, PIMCORE_LOG_DIRECTORY) !== 0) {
throw new \Exception('Not allowed');
}
if (!file_exists($requestLogFile)) {
File::put($requestLogFile, '');
}
$requestDebugHandler = new \Monolog\Handler\StreamHandler($requestLogFile);
/** @var \Symfony\Component\DependencyInjection\Container $container */
$container = self::getContainer();
foreach ($container->getServiceIds() as $id) {
if (strpos($id, 'monolog.logger.') === 0) {
$logger = self::getContainer()->get($id);
if ($logger->getName() != 'event') {
// replace all handlers
$logger->setHandlers([$requestDebugHandler]);
}
}
}
}
} | 1 | PHP | CWE-29 | Path Traversal: '\..\filename' | The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory. | https://cwe.mitre.org/data/definitions/29.html | safe |
public function isValidOrderKey($key)
{
return in_array(
$key,
[
'type',
'id',
'key',
'index',
'fullpath',
'maintype',
'subtype',
'published',
'creationDate',
'modificationDate',
'userOwner',
'userModification',
'data',
'properties'
]
);
} | 1 | 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 | safe |
public function isValidOrderKey($key)
{
return in_array($key, ['key', 'type']) || in_array($key, $this->getLanguages());
} | 1 | 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 | safe |
public function statisticsAction(Request $request, Connection $db, KernelInterface $kernel)
{
if (!$request->isXmlHttpRequest()) {
throw $this->createAccessDeniedHttpException();
}
// DB
try {
$tables = $db->fetchAllAssociative('SELECT TABLE_NAME as name,TABLE_ROWS as `rows` from information_schema.TABLES
WHERE TABLE_ROWS IS NOT NULL AND TABLE_SCHEMA = ?', [$db->getDatabase()]);
} catch (\Exception $e) {
$tables = [];
}
try {
$mysqlVersion = $db->fetchOne('SELECT VERSION()');
} catch (\Exception $e) {
$mysqlVersion = null;
}
try {
$data = [
'instanceId' => $this->getInstanceId(),
'pimcore_major_version' => Version::getMajorVersion(),
'pimcore_version' => Version::getVersion(),
'pimcore_hash' => Version::getRevision(),
'php_version' => PHP_VERSION,
'mysql_version' => $mysqlVersion,
'bundles' => array_keys($kernel->getBundles()),
'tables' => $tables,
];
} catch (\Exception $e) {
$data = [];
}
return $this->adminJson($data);
} | 1 | PHP | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | safe |
public function getAvailableSitesAction(Request $request)
{
// we need to check documents permission for listing purposes in sites ext model & url-slugs
$this->checkPermission('documents');
$excludeMainSite = $request->get('excludeMainSite');
$sitesList = new Model\Site\Listing();
$sitesObjects = $sitesList->load();
$sites = [];
if (!$excludeMainSite) {
$sites[] = [
'id' => 'default',
'rootId' => 1,
'domains' => '',
'rootPath' => '/',
'domain' => $this->translator->trans('main_site'),
];
}
foreach ($sitesObjects as $site) {
if ($site->getRootDocument()) {
if ($site->getMainDomain()) {
$sites[] = [
'id' => $site->getId(),
'rootId' => $site->getRootId(),
'domains' => implode(',', $site->getDomains()),
'rootPath' => $site->getRootPath(),
'domain' => $site->getMainDomain(),
];
}
} else {
// site is useless, parent doesn't exist anymore
$site->delete();
}
}
return $this->adminJson($sites);
} | 1 | PHP | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | safe |
function pageSlug() {
$URI = explode(root_domain(), rtrim($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], "/"));
$URI = explode("?", $URI[1]);
return safe_entities(trim($URI[0], '/'));
} | 1 | 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 | safe |
function getEmployeePayableAmount(int $emp_id, string $salary_type) {
global $table_prefix;
$emp_opening_balance_name = "emp_opening_". strtolower($salary_type);
$empPayableAmount = easySelectD("
select
emp_id,
( ( if(salary_amount_sum is null, 0, salary_amount_sum) - if(payment_items_amount_sum is null, 0, payment_items_amount_sum) ) + ({$emp_opening_balance_name}) ) as emp_payable_amount
from {$table_prefix}employees
left join ( select salary_emp_id, salary_type, sum(salary_amount) as salary_amount_sum from {$table_prefix}salaries where is_trash = 0 and salary_type='{$salary_type}' group by salary_emp_id ) as {$table_prefix}salaries on salary_emp_id = emp_id
left join ( select payment_items_employee, sum(payment_items_amount) as payment_items_amount_sum from {$table_prefix}payment_items where is_trash = 0 and payment_items_type='{$salary_type}' group by payment_items_employee ) as get_payments_items on payment_items_employee = emp_id
where emp_id = {$emp_id}
")["data"][0]["emp_payable_amount"];
// if salary type is salary then add the installment amount with payable amount
if($salary_type === "salary") {
$paidLoan = easySelectD("
select sum(loan_installment_paying_amount) as loan_paid_amount from {$table_prefix}loan_installment where is_trash = 0 and loan_installment_provider = '{$emp_id}' group by loan_installment_provider
");
$empPayableAmount -= $paidLoan ? $paidLoan["data"][0]["loan_paid_amount"] : 0;
}
return $empPayableAmount;
} | 1 | 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 | safe |
function write_file(string $data, string $file_location, string $mode ="a") {
// If error msg not empty
if(!empty($data)) {
$fp = fopen(DIR_BASE . $file_location, $mode); // use w for truncate /clear content
fwrite($fp, $data);
fclose($fp);
}
} | 1 | 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 | safe |
function near_unit_qty($product_id, $qty, $unit) {
global $table_prefix;
$getData = easySelectA(array(
"table" => "products as whereProduct",
"fields" => "joinProduct.product_unit as product_unit, equal_unit_qnt, base_qnt",
"join" => array(
"left join {$table_prefix}products as joinProduct on joinProduct.product_name = whereProduct.product_name",
"left join {$table_prefix}product_units on unit_name = joinProduct.product_unit"
),
"where" => array(
"joinProduct.is_trash = 0 and joinProduct.product_unit is not null and whereProduct.product_id" => $product_id
),
"orderby" => array(
"base_qnt" => "DESC"
)
));
if($getData !== false) {
$totalBaseQty = $qty;
$remainQty = 0;
$finalUnitName = "";
$finalQtyBasedOnUnit = 0;
// Generate the base qty based on unit
foreach($getData["data"] as $pKey => $pVal ) {
if( $pVal["product_unit"] === $unit) {
$totalBaseQty *= $pVal["base_qnt"];
break;
}
}
// Now get the unit which base_qnt is grater then or equal to unitDevider
foreach($getData["data"] as $pKey => $pVal ) {
if( $pVal["base_qnt"] <= $totalBaseQty) {
$finalUnitName = $pVal["product_unit"];
$remainQty = ($totalBaseQty % $pVal["base_qnt"]);
$finalQtyBasedOnUnit = ($totalBaseQty - $remainQty) / $pVal["base_qnt"];
break;
}
}
return $finalQtyBasedOnUnit . " " . $finalUnitName . ( $remainQty > 0 ? ", " . near_unit_qty($product_id, $remainQty, $unit) : "");
} else { | 1 | 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 | safe |
function easySelectD($query) {
global $table_prefix; // table prefix;
global $conn; // MySQL connection variable.
$dataFromDB = [];
/* echo $query;
exit(); */
// Run the query and store the result into getResult variable.
$getResult = $conn->query($query);
// Check If the syntax has any error then throw an the error.
if($getResult === false) {
// insert log
create_log($conn->error, debug_backtrace());
// Keep the transaction error record
$conn->get_all_error[] = $conn->error;
return $conn->error; // Return the error
}
// Check if there is more then Zero (0) result.
if($getResult->num_rows > 0) {
// return all data in array format
return array(
"count" => $getResult->num_rows,
"data" => $getResult->fetch_all(true)
);
} else {
// Return false if there is no data.
return false;
}
} | 1 | 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 | safe |
function save_deleted_date($table, $data) {
global $table_prefix; // table prefix;
global $conn; // MySQL connection variable.
// Serialize the data
$data = serialize($data);
// Insert deleted data
$conn->query("INSERT INTO {$table_prefix}deleted_data (deleted_from, deleted_data, deleted_by) VALUES ('{$table}', '{$data}', '{$_SESSION['uid']}')");
} | 1 | 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 | safe |
function save_query($query) {
global $table_prefix; // table prefix;
global $conn; // MySQL connection variable.
$query = json_encode($query);
$conn->query("INSERT INTO {$table_prefix}latest_queries (query_value) VALUES ($query)");
} | 1 | 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 | safe |
function getCustomerPaymentInfo_back(int $customer_id) {
global $table_prefix;
easySelectD(
"select customer_id, if(customer_opening_balance is null, 0, customer_opening_balance) as customer_opening_balance,
if(sales_grand_total is null, 0, sales_grand_total) as sales_grand_total,
if(returns_grand_total is null, 0, returns_grand_total) as returns_grand_total,
if(received_payments_amount is null, 0, received_payments_amount) as total_received_payments,
if(received_payments_bonus is null, 0, received_payments_bonus) as total_given_bonus
from {$table_prefix}customers
left join (
select
sales_customer_id,
sum(sales_grand_total) as sales_grand_total
from {$table_prefix}sales where is_trash = 0 group by sales_customer_id
) as sales on customer_id = sales_customer_id
left join (
select
product_returns_customer_id,
sum(product_returns_grand_total) as returns_grand_total
from {$table_prefix}product_returns where is_trash = 0 group by product_returns_customer_id
) as product_returns on customer_id = product_returns_customer_id
left join (
select
received_payments_from,
sum(received_payments_amount) as received_payments_amount,
sum(received_payments_bonus) as received_payments_bonus
from {$table_prefix}received_payments where is_trash = 0 group by received_payments_from
) as {$table_prefix}received_payments on customer_id = received_payments_from
where customer_id = {$customer_id}"
);
} | 1 | 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 | safe |
function purify_html($html) {
require_once LOAD_LIB . "htmlpurifier-4.15.0/library/HTMLPurifier.auto.php";
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
return $purifier->purify($html);
} | 1 | 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 | safe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.