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 |
---|---|---|---|---|---|---|---|
protected function _sendMail($admin, $admin_pass)
{
$admin_name = $admin->name;
$admin_email = $admin->email;
$client_url = $this->di['url']->link('/');
$admin_url = $this->di['url']->adminLink('/');
$content = "Hello, $admin_name. " . PHP_EOL;
$content .= 'You have successfully installed FOSSBilling at ' . BB_URL . PHP_EOL;
$content .= 'Access the client area at: ' . $client_url . PHP_EOL;
$content .= 'Access the admin area at: ' . $admin_url . ' with login details:' . PHP_EOL;
$content .= 'Email: ' . $admin_email . PHP_EOL;
$content .= 'Password: ' . $admin_pass . PHP_EOL . PHP_EOL;
$content .= 'Read the FOSSBilling documentation to get started https://fossbilling.org/docs' . PHP_EOL;
$content .= 'Thank you for using FOSSBilling.' . PHP_EOL;
$subject = sprintf('FOSSBilling is ready at "%s"', BB_URL);
$systemService = $this->di['mod_service']('system');
$from = $systemService->getParamValue('company_email');
$emailService = $this->di['mod_service']('Email');
$emailService->sendMail($admin_email, $from, $subject, $content);
} | 0 | 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 | vulnerable |
public function createAdmin(array $data)
{
$admin = $this->di['db']->dispense('Admin');
$admin->role = 'admin';
$admin->admin_group_id = 1;
$admin->name = 'Administrator';
$admin->email = $data['email'];
$admin->pass = $this->di['password']->hashIt($data['password']);
$admin->protected = 1;
$admin->status = 'active';
$admin->created_at = date('Y-m-d H:i:s');
$admin->updated_at = date('Y-m-d H:i:s');
$newId = $this->di['db']->store($admin);
$this->di['logger']->info('Main administrator %s account created', $admin->email);
$this->_sendMail($admin, $data['password']);
$data['remember'] = true;
return $newId;
} | 0 | 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 | vulnerable |
public function testInjector()
{
$di = $this->di;
$this->assertInstanceOf('Box_Mod', $di['mod']('admin'));
$this->assertInstanceOf('Box_Log', $di['logger']);
$this->assertInstanceOf('Box_Crypt', $di['crypt']);
$this->assertTrue(isset($di['pdo']));
$this->assertTrue(isset($di['db']));
$this->assertInstanceOf('Box_Pagination', $di['pager']);
$this->assertInstanceOf('Box_Url', $di['url']);
$this->assertInstanceOf('Box_EventManager', $di['events_manager']);
$this->assertInstanceOf('\Box_Session', $di['session']);
$this->assertInstanceOf('Box_Authorization', $di['auth']);
$this->assertInstanceOf('Twig\Environment', $di['twig']);
$this->assertInstanceOf('\FOSSBilling\Tools', $di['tools']);
$this->assertInstanceOf('\FOSSBilling\Validate', $di['validator']);
$this->assertTrue(isset($di['mod']));
$this->assertTrue(isset($di['mod_config']));
$this->assertInstanceOf('Box\\Mod\\Cron\\Service', $di['mod_service']('cron'));
$this->assertInstanceOf('\FOSSBilling\ExtensionManager', $di['extension_manager']);
$this->assertInstanceOf('\Box_Update', $di['updater']);
$this->assertInstanceOf('\Server_Package', $di['server_package']);
$this->assertInstanceOf('\Server_Client', $di['server_client']);
$this->assertInstanceOf('\Server_Account', $di['server_account']);
$this->assertTrue(isset($di['server_manager']));
$this->assertInstanceOf('\FOSSBilling\Requirements', $di['requirements']);
$this->assertInstanceOf('\Box\Mod\Theme\Model\Theme', $di['theme']);
$this->assertInstanceOf('\Model_Cart', $di['cart']);
$this->assertInstanceOf('\GeoIp2\Database\Reader', $di['geoip']);
$this->assertInstanceOf('\Box_Password', $di['password']);
$this->assertInstanceOf('\Box_Translate', $di['translate']());
} | 0 | 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 | vulnerable |
public function testGetSessionCartExists()
{
$service = new \Box\Mod\Cart\Service();
$session_id = 'rrcpqo7tkjh14d2vmf0car64k7';
$model = new \Model_Cart();
$model->loadBean(new \DummyBean());
$model->session_id = $session_id;
$dbMock = $this->getMockBuilder('Box_Database')->getMock();
$dbMock->expects($this->atLeastOnce())
->method('findOne')
->will($this->returnValue($model));
$sessionMock = $this->getMockBuilder("\Box_Session")
->disableOriginalConstructor()
->getMock();
$sessionMock->expects($this->atLeastOnce())
->method("getId")
->will($this->returnValue($session_id));
$di = new \Pimple\Container();
$di['db'] = $dbMock;
$di['session'] = $sessionMock;
$service->setDi($di);
$result = $service->getSessionCart();
$this->assertInstanceOf('Model_Cart', $result);
$this->assertEquals($result->session_id, $session_id);
} | 0 | 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 | vulnerable |
public function testlogin()
{
$data = array(
'email' => '[email protected]',
'password' => 'sezam',
'remember' => true,
);
$model = new \Model_Client();
$model->loadBean(new \DummyBean());
$serviceMock = $this->getMockBuilder('\Box\Mod\Client\Service')->getMock();
$serviceMock->expects($this->atLeastOnce())
->method('authorizeClient')
->with($data['email'], $data['password'])
->will($this->returnValue($model));
$serviceMock->expects($this->atLeastOnce())
->method('toSessionArray')
->will($this->returnValue(array()));
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
$eventMock->expects($this->atLeastOnce())->
method('fire');
$sessionMock = $this->getMockBuilder('\Box_Session')
->disableOriginalConstructor()
->getMock();
$sessionMock->expects($this->atLeastOnce())
->method("set");
$toolsMock = $this->getMockBuilder('\FOSSBilling\Tools')->getMock();
//$toolsMock->expects($this->atLeastOnce())->method('validateAndSanitizeEmail');
$validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock();
$validatorMock->expects($this->atLeastOnce())
->method('checkRequiredParamsForArray')
->will($this->returnValue(null));
$di = new \Pimple\Container();
$di['events_manager'] = $eventMock;
$di['session'] = $sessionMock;
$di['logger'] = new \Box_Log();
$di['validator'] = $validatorMock;
$di['tools'] = $toolsMock;
$client = new \Box\Mod\Client\Api\Guest();
$client->setDi($di);
$client->setService($serviceMock);
$results = $client->login($data);
$this->assertIsArray($results);
} | 0 | 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 | vulnerable |
public function testLogout()
{
$sessionMock = $this->getMockBuilder('\Box_Session')
->disableOriginalConstructor()
->getMock();
$di = new \Pimple\Container();
$di['session'] = $sessionMock;
$di['logger'] = new \Box_Log();
$adminApi = new \Box\Mod\Profile\Api\Admin();
$adminApi->setDi($di);
$result = $adminApi->logout();
$this->assertTrue($result);
} | 0 | 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 | vulnerable |
public function testLogoutClient()
{
$sessionMock = $this->getMockBuilder("\Box_Session")
->disableOriginalConstructor()
->getMock();
$sessionMock->expects($this->atLeastOnce())
->method("delete");
$di = new \Pimple\Container();
$di['logger'] = new \Box_Log();
$di['session'] = $sessionMock;
$model = new \Model_Client();
$model->loadBean(new \DummyBean());
$service = new Service();
$service->setDi($di);
$result = $service->logoutClient($model, 'new password');
$this->assertTrue($result);
} | 0 | 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 | vulnerable |
public function testLogin()
{
$email = '[email protected]';
$password = 'pass';
$ip = '127.0.0.1';
$admin = new \Model_Admin();
$admin->loadBean(new \DummyBean());
$admin->id = 1;
$admin->email = $email;
$admin->name = 'Admin';
$admin->role = 'admin';
$emMock = $this->getMockBuilder('\Box_EventManager')
->getMock();
$emMock->expects($this->atLeastOnce())
->method('fire')
->will($this->returnValue(true));
$dbMock = $this->getMockBuilder('\Box_Database')
->getMock();
$dbMock->expects($this->atLeastOnce())
->method('findOne')
->will($this->returnValue($admin));
$sessionMock = $this->getMockBuilder('\Box_Session')
->disableOriginalConstructor()
->getMock();
$sessionMock->expects($this->atLeastOnce())
->method('set')
->will($this->returnValue(null));
$authMock = $this->getMockBuilder('\Box_Authorization')->disableOriginalConstructor()->getMock();
$authMock->expects($this->atLeastOnce())
->method('authorizeUser')
->with($admin, $password)
->willReturn($admin);
$di = new \Pimple\Container();
$di['events_manager'] = $emMock;
$di['db'] = $dbMock;
$di['session'] = $sessionMock;
$di['logger'] = new \Box_Log();
$di['auth'] = $authMock;
$service = new \Box\Mod\Staff\Service();
$service->setDi($di);
$result = $service->login($email, $password, $ip);
$expected = array(
'id' => 1,
'email' => $email,
'name' => 'Admin',
'role' => 'admin',
);
$this->assertEquals($expected, $result);
} | 0 | 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 | vulnerable |
public function testclearPendingMessages()
{
$di = new \Pimple\Container();
$sessionMock = $this->getMockBuilder('\Box_Session')->disableOriginalConstructor()->getMock();
$sessionMock->expects($this->atLeastOnce())
->method('delete')
->with('pending_messages');
$di['session'] = $sessionMock;
$this->service->setDi($di);
$result = $this->service->clearPendingMessages();
$this->assertTrue($result);
} | 0 | 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 | vulnerable |
public function testgetPendingMessages_GetReturnsNotArray()
{
$di = new \Pimple\Container();
$sessionMock = $this->getMockBuilder('\Box_Session')->disableOriginalConstructor()->getMock();
$sessionMock->expects($this->atLeastOnce())
->method('get')
->with('pending_messages')
->willReturn(null);
$di['session'] = $sessionMock;
$this->service->setDi($di);
$result = $this->service->getPendingMessages();
$this->assertIsArray($result);
} | 0 | 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 | vulnerable |
public function testsetPendingMessage()
{
$serviceMock = $this->getMockBuilder('\Box\Mod\System\Service')
->setMethods(array('getPendingMessages'))
->getMock();
$serviceMock->expects($this->atLeastOnce())
->method('getPendingMessages')
->willReturn(array());
$di = new \Pimple\Container();
$sessionMock = $this->getMockBuilder('\Box_Session')->disableOriginalConstructor()->getMock();
$sessionMock->expects($this->atLeastOnce())
->method('set')
->with('pending_messages');
$di['session'] = $sessionMock;
$serviceMock->setDi($di);
$message = 'Important Message';
$result = $serviceMock->setPendingMessage($message);
$this->assertTrue($result);
} | 0 | 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 | vulnerable |
public function testgetPendingMessages()
{
$di = new \Pimple\Container();
$sessionMock = $this->getMockBuilder('\Box_Session')->disableOriginalConstructor()->getMock();
$sessionMock->expects($this->atLeastOnce())
->method('get')
->with('pending_messages')
->willReturn(array());
$di['session'] = $sessionMock;
$this->service->setDi($di);
$result = $this->service->getPendingMessages();
$this->assertIsArray($result);
} | 0 | 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 | vulnerable |
public function getSimpleResultSet($q, $values, $per_page = 100, $page = null)
{
if (is_null($page)){
$page = $_GET['page'] ?? 1;
}
$per_page = $_GET['per_page'] ?? $per_page;
$offset = ($page - 1) * $per_page;
$sql = $q;
$sql .= sprintf(' LIMIT %s,%s', $offset, $per_page);
$result = $this->di['db']->getAll($sql, $values);
$exploded = explode('FROM', $q);
$sql = 'SELECT count(1) FROM ' . $exploded[1];
$total = $this->di['db']->getCell($sql , $values);
$pages = ($per_page > 1) ? (int)ceil($total / $per_page) : 1;
return array(
"pages" => $pages,
"page" => $page,
"per_page" => $per_page,
"total" => $total,
"list" => $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 getSimpleResultSet($q, $values, $per_page = 100, $page = null)
{
if (is_null($page)){
$page = $_GET['page'] ?? 1;
}
$per_page = $_GET['per_page'] ?? $per_page;
$offset = ($page - 1) * $per_page;
$sql = $q;
$sql .= sprintf(' LIMIT %s,%s', $offset, $per_page);
$result = $this->di['db']->getAll($sql, $values);
$exploded = explode('FROM', $q);
$sql = 'SELECT count(1) FROM ' . $exploded[1];
$total = $this->di['db']->getCell($sql , $values);
$pages = ($per_page > 1) ? (int)ceil($total / $per_page) : 1;
return array(
"pages" => $pages,
"page" => $page,
"per_page" => $per_page,
"total" => $total,
"list" => $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 |
public function getAdvancedResultSet($q, $values, $per_page = 100)
{
$page = $page = $_GET['page'] ?? 1;
$per_page = $_GET['per_page'] ?? $per_page;
$offset = ($page - 1) * $per_page;
$q = str_replace('SELECT ', 'SELECT SQL_CALC_FOUND_ROWS ', $q);
$q .= sprintf(' LIMIT %s,%s', $offset, $per_page);
$result = $this->di['db']->getAll($q, $values);
$total = $this->di['db']->getCell('SELECT FOUND_ROWS();');
$pages = ($per_page > 1) ? (int)ceil($total / $per_page) : 1;
return array(
"pages" => $pages,
"page" => $page,
"per_page" => $per_page,
"total" => $total,
"list" => $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 getAdvancedResultSet($q, $values, $per_page = 100)
{
$page = $page = $_GET['page'] ?? 1;
$per_page = $_GET['per_page'] ?? $per_page;
$offset = ($page - 1) * $per_page;
$q = str_replace('SELECT ', 'SELECT SQL_CALC_FOUND_ROWS ', $q);
$q .= sprintf(' LIMIT %s,%s', $offset, $per_page);
$result = $this->di['db']->getAll($q, $values);
$total = $this->di['db']->getCell('SELECT FOUND_ROWS();');
$pages = ($per_page > 1) ? (int)ceil($total / $per_page) : 1;
return array(
"pages" => $pages,
"page" => $page,
"per_page" => $per_page,
"total" => $total,
"list" => $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 |
public function getPairs($data)
{
$limit = $data['per_page'] ?? 30;
[$sql, $params] = $this->getSearchQuery($data, "SELECT c.id, CONCAT_WS('', c.first_name, ' ', c.last_name) as full_name");
$sql = $sql . ' LIMIT ' . $limit;
return $this->di['db']->getAssoc($sql, $params);
} | 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 getPairs($data)
{
$limit = $data['per_page'] ?? 30;
[$sql, $params] = $this->getSearchQuery($data, "SELECT c.id, CONCAT_WS('', c.first_name, ' ', c.last_name) as full_name");
$sql = $sql . ' LIMIT ' . $limit;
return $this->di['db']->getAssoc($sql, $params);
} | 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 |
move_uploaded_file($f['tmp_name'], $dest . $filename);
}
} | 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 |
move_uploaded_file($f['tmp_name'], $dest . $filename);
}
} | 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 testuploadAssets()
{
$files = array(
'file1' => array(
'error' => UPLOAD_ERR_NO_FILE,
),
'file2' => array(
'error' => UPLOAD_ERR_OK,
'tmp_name' => 'tmpName',
),
);
$service = new \Box\Mod\Theme\Service();
$service->setDi($this->di);
$themeModel = $service->getTheme('huraga');
$service->uploadAssets($themeModel, $files);
} | 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 testuploadAssets()
{
$files = array(
'file1' => array(
'error' => UPLOAD_ERR_NO_FILE,
),
'file2' => array(
'error' => UPLOAD_ERR_OK,
'tmp_name' => 'tmpName',
),
);
$service = new \Box\Mod\Theme\Service();
$service->setDi($this->di);
$themeModel = $service->getTheme('huraga');
$service->uploadAssets($themeModel, $files);
} | 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 testuploadAssets_Exception()
{
$themeMock = $this->getMockBuilder('\Box\Mod\Theme\Model\Theme')->disableOriginalConstructor()->getMock();
$themeMock->expects($this->atLeastOnce())
->method('getPathAssets');
$files = array(
'test0' => array(
'error' => UPLOAD_ERR_CANT_WRITE
),
);
$this->expectException(\Box_Exception::class);
$this->expectExceptionMessage(sprintf("Error uploading file %s Error code: %d", 'test0', UPLOAD_ERR_CANT_WRITE));
$this->service->uploadAssets($themeMock, $files);
} | 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 testuploadAssets_Exception()
{
$themeMock = $this->getMockBuilder('\Box\Mod\Theme\Model\Theme')->disableOriginalConstructor()->getMock();
$themeMock->expects($this->atLeastOnce())
->method('getPathAssets');
$files = array(
'test0' => array(
'error' => UPLOAD_ERR_CANT_WRITE
),
);
$this->expectException(\Box_Exception::class);
$this->expectExceptionMessage(sprintf("Error uploading file %s Error code: %d", 'test0', UPLOAD_ERR_CANT_WRITE));
$this->service->uploadAssets($themeMock, $files);
} | 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 testuploadAssets()
{
$themeMock = $this->getMockBuilder('\Box\Mod\Theme\Model\Theme')->disableOriginalConstructor()->getMock();
$themeMock->expects($this->atLeastOnce())
->method('getPathAssets');
$files = array(
'test2' => array(
'error' => UPLOAD_ERR_NO_FILE
),
'test1' => array(
'error' => UPLOAD_ERR_OK,
'tmp_name' => 'tempName',
),
);
$this->service->uploadAssets($themeMock, $files);
} | 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 testuploadAssets()
{
$themeMock = $this->getMockBuilder('\Box\Mod\Theme\Model\Theme')->disableOriginalConstructor()->getMock();
$themeMock->expects($this->atLeastOnce())
->method('getPathAssets');
$files = array(
'test2' => array(
'error' => UPLOAD_ERR_NO_FILE
),
'test1' => array(
'error' => UPLOAD_ERR_OK,
'tmp_name' => 'tempName',
),
);
$this->service->uploadAssets($themeMock, $files);
} | 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 |
$result = ['result' => null, 'error' => ['message' => $e->getMessage(), 'code' => $code]]; | 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 change_password($data)
{
$required = [
'current_password' => 'Current password required',
'new_password' => 'New password required',
'confirm_password' => 'New password confirmation required',
];
$validator = $this->di['validator'];
$validator->checkRequiredParamsForArray($required, $data);
$validator->isPasswordStrong($data['new_password']);
if ($data['new_password'] != $data['confirm_password']) {
throw new \Exception('Passwords do not match');
}
$staff = $this->getIdentity();
if(!$this->di['password']->verify($data['current_password'], $staff->pass)) {
throw new \Exception('Current password incorrect');
}
return $this->getService()->changeAdminPassword($staff, $data['new_password']);
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
public function change_password($data)
{
$required = [
'current_password' => 'Current password required',
'new_password' => 'New password required',
'confirm_password' => 'New password confirmation required',
];
$this->di['validator']->checkRequiredParamsForArray($required, $data);
$this->di['validator']->isPasswordStrong($data['new_password']);
if ($data['new_password'] != $data['confirm_password']) {
throw new \Exception('Passwords do not match');
}
$client = $this->getIdentity();
if(!$this->di['password']->verify($data['current_password'], $client->pass)) {
throw new \Exception('Current password incorrect');
}
return $this->getService()->changeClientPassword($client, $data['new_password']);
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
public function testchange_password()
{
$data = array(
'id' => 1,
'password' => 'strongPass',
'password_confirm' => 'strongPass',
);
$model = new \Model_Client();
$model->loadBean(new \DummyBean());
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
$dbMock->expects($this->atLeastOnce())
->method('getExistingModelById')->will($this->returnValue($model));
$dbMock->expects($this->atLeastOnce())
->method('store')->will($this->returnValue(1));
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
$eventMock->expects($this->atLeastOnce())->
method('fire');
$passwordMock = $this->getMockBuilder('\Box_Password')->getMock();
$passwordMock->expects($this->atLeastOnce())
->method('hashIt')
->with($data['password']);
$di = new \Pimple\Container();
$di['db'] = $dbMock;
$di['events_manager'] = $eventMock;
$di['logger'] = new \Box_Log();
$di['password'] = $passwordMock;
$validatorMock = $this->getMockBuilder('\FOSSBilling\Validate')->disableOriginalConstructor()->getMock();
$validatorMock->expects($this->atLeastOnce())
->method('checkRequiredParamsForArray')
->will($this->returnValue(null));
$di['validator'] = $validatorMock;
$admin_Client = new \Box\Mod\Client\Api\Admin();
$admin_Client->setDi($di);
$result = $admin_Client->change_password($data);
$this->assertTrue($result);
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
protected function getFile()
{
$task_id = $this->request->getIntegerParam('task_id');
$file_id = $this->request->getIntegerParam('file_id');
$model = 'projectFileModel';
if ($task_id > 0) {
$model = 'taskFileModel';
}
$file = $this->$model->getById($file_id);
if (empty($file)) {
throw new PageNotFoundException();
}
if (isset($file['task_id']) && $file['task_id'] != $task_id) {
throw new AccessForbiddenException();
}
$file['model'] = $model;
return $file;
} | 0 | PHP | CWE-639 | Authorization Bypass Through User-Controlled Key | The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. | https://cwe.mitre.org/data/definitions/639.html | vulnerable |
public function move()
{
$task = $this->getTask();
if ($this->request->isPost()) {
$values = $this->request->getValues();
list($valid, ) = $this->taskValidator->validateProjectModification($values);
if ($valid && $this->taskProjectMoveModel->moveToProject($task['id'],
$values['project_id'],
$values['swimlane_id'],
$values['column_id'],
$values['category_id'],
$values['owner_id'])) {
$this->flash->success(t('Task updated successfully.'));
return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'])));
}
$this->flash->failure(t('Unable to update your task.'));
}
return $this->chooseDestination($task, 'task_duplication/move');
} | 0 | PHP | CWE-862 | Missing Authorization | The product does not perform an authorization check when an actor attempts to access a resource or perform an action. | https://cwe.mitre.org/data/definitions/862.html | vulnerable |
public function copy()
{
$task = $this->getTask();
if ($this->request->isPost()) {
$values = $this->request->getValues();
list($valid, ) = $this->taskValidator->validateProjectModification($values);
if ($valid) {
$task_id = $this->taskProjectDuplicationModel->duplicateToProject(
$task['id'], $values['project_id'], $values['swimlane_id'],
$values['column_id'], $values['category_id'], $values['owner_id']
);
if ($task_id > 0) {
$this->flash->success(t('Task created successfully.'));
return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true);
}
}
$this->flash->failure(t('Unable to create your task.'));
}
return $this->chooseDestination($task, 'task_duplication/copy');
} | 0 | PHP | CWE-862 | Missing Authorization | The product does not perform an authorization check when an actor attempts to access a resource or perform an action. | https://cwe.mitre.org/data/definitions/862.html | vulnerable |
public function __construct(ProcessHandlerRegistry $registry, Security $security)
{
$this->registry = $registry;
$this->security = $security;
} | 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(
string $projectDir,
string $legacyDir,
string $legacySessionName,
string $defaultSessionName,
LegacyScopeState $legacyScopeState,
SessionInterface $session,
ModuleNameMapperInterface $moduleNameMapper,
BaseActionDefinitionProviderInterface $baseActionDefinitionProvider,
LegacyActionResolverInterface $legacyActionResolver,
AclManagerInterface $acl
) {
parent::__construct(
$projectDir,
$legacyDir,
$legacySessionName,
$defaultSessionName,
$legacyScopeState,
$session
);
$this->moduleNameMapper = $moduleNameMapper;
$this->baseActionDefinitionProvider = $baseActionDefinitionProvider;
$this->legacyActionResolver = $legacyActionResolver;
$this->acl = $acl;
} | 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 handleAccessControl()
{
if ($GLOBALS['current_user']->isDeveloperForAnyModule()) {
return;
}
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == "RetrieveEmail") {
return;
}
if (!is_admin($GLOBALS['current_user']) && !empty($GLOBALS['adminOnlyList'][$this->controller->module]) && !empty($GLOBALS['adminOnlyList'][$this->controller->module]['all']) && (empty($GLOBALS['adminOnlyList'][$this->controller->module][$this->controller->action]) || $GLOBALS['adminOnlyList'][$this->controller->module][$this->controller->action] != 'allow')) {
$this->controller->hasAccess = false;
return;
}
// Bug 20916 - Special case for check ACL access rights for Subpanel QuickCreates
if (isset($_POST['action']) && $_POST['action'] == 'SubpanelCreates') {
$actual_module = $_POST['target_module'];
if (!empty($GLOBALS['modListHeader']) && !in_array($actual_module, $GLOBALS['modListHeader'])) {
$this->controller->hasAccess = false;
}
return;
}
if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) {
$GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
}
if (in_array($this->controller->module, $GLOBALS['modInvisList']) &&
((in_array('Activities', $GLOBALS['moduleList']) &&
in_array('Calendar', $GLOBALS['moduleList'])) &&
in_array($this->controller->module, $GLOBALS['modInvisListActivities']))
) {
$this->controller->hasAccess = false;
return;
}
} | 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 static function redirect(
$url
) {
/*
* If the headers have been sent, then we cannot send an additional location header
* so we will output a javascript redirect statement.
*/
if (!empty($_REQUEST['ajax_load'])) {
ob_get_clean();
$ajax_ret = array(
'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n",
'menu' => array(
'module' => $_REQUEST['module'],
'label' => translate($_REQUEST['module']),
),
);
$json = getJSONobj();
echo $json->encode($ajax_ret);
} else {
if (headers_sent()) {
echo "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n";
} else {
//@ob_end_clean(); // clear output buffer
session_write_close();
header('HTTP/1.1 301 Moved Permanently');
header("Location: " . $url);
}
}
if (!defined('SUITE_PHPUNIT_RUNNER')) {
exit();
}
} | 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 |
function smarty_function_sugarvar($params, &$smarty)
{
if(empty($params['key'])) {
$smarty->trigger_error("sugarvar: missing 'key' parameter");
return;
}
$object = (empty($params['objectName']))?$smarty->get_template_vars('parentFieldArray'): $params['objectName'];
$displayParams = $smarty->get_template_vars('displayParams');
if(empty($params['memberName'])){
$member = $smarty->get_template_vars('vardef');
$member = $member['name'];
}else{
$members = explode('.', $params['memberName']);
$member = $smarty->get_template_vars($members[0]);
for($i = 1; $i < count($members); $i++){
$member = $member[$members[$i]];
}
}
$_contents = '$'. $object . '.' . $member . '.' . $params['key'];
if(empty($params['stringFormat']) && empty($params['string'])) {
$_contents = '{' . $_contents;
if(!empty($displayParams['htmlescape'])){
$_contents .= '|escape:\'html\'';
}
if(!empty($params['htmlentitydecode'])){
$_contents .= '|escape:\'html_entity_decode\'';
}
if(!empty($displayParams['strip_tags'])){
$_contents .= '|strip_tags';
}
if(!empty($displayParams['url2html'])){
$_contents .= '|url2html';
}
if(!empty($displayParams['nl2br'])){
$_contents .= '|nl2br';
}
$_contents .= '}';
}
return $_contents;
} | 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 setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass = true)
{
parent::setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass);
$editor = "";
if (isset($vardef['editor']) && $vardef['editor'] == "html") {
if (!isset($displayParams['htmlescape'])) {
$displayParams['htmlescape'] = false;
}
if ($_REQUEST['action'] == "EditView") {
require_once(__DIR__ . "/../../../../include/SugarTinyMCE.php");
$tiny = new SugarTinyMCE();
$editor = $tiny->getInstance($vardef['name'], 'email_compose_light');
}
}
$this->ss->assign("tinymce", $editor);
} | 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 isValid($emailAddress)
{
// Inspired by the regex used in symfony/validator
// See: https://github.com/symfony/validator/blob/dae70b74fe173461395cfd61a5c5245e05e511f5/Constraints/EmailValidator.php#L72
return (bool) preg_match('/^\S+\@\S+\.\S+$/', $emailAddress);
} | 0 | PHP | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
public function getValidEmails()
{
return [
// old domains
['[email protected]'],
['[email protected]'],
['[email protected]'],
// new released domains
['[email protected]'],
['[email protected]'],
['[email protected]'],
// new non released domains
['[email protected]'],
['[email protected]'],
['[email protected]'],
['[email protected]'],
['[email protected]'],
['[email protected]'],
['[email protected]'],
// We will ignore quoted string local parts
// this would blow up the simple regex method
// array('"much.more unusual"@example.com'),
];
} | 0 | PHP | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
public function testInvalidEmails($email)
{
static::assertFalse($this->SUT->isValid($email));
} | 0 | PHP | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
public function testValidEmails($email)
{
static::assertTrue($this->SUT->isValid($email));
} | 0 | PHP | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
public function getinvalidEmails()
{
return [
['test'],
['[email protected]'],
['@example'],
['@example.de'],
['@.'],
[' @foo.de'],
['@foo.'],
['foo@ .de'],
['foo@bar. '],
];
} | 0 | PHP | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
$file = Url::assemble($location, $name);
if (File::exists($file)) {
$svg = StaticStringy::collapseWhitespace(
File::get($file)
);
break;
}
}
$attributes = $this->renderAttributesFromParams(['src', 'title', 'desc']);
if ($this->params->get('title') || $this->params->get('desc')) {
$svg = $this->setTitleAndDesc($svg);
}
return str_replace(
'<svg',
collect(['<svg', $attributes])->filter()->implode(' '),
$svg
);
} | 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 |
private function tag($tag)
{
return Parse::template($tag, []);
} | 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 |
protected function extraRules($fields)
{
$assetFieldRules = $fields->all()
->filter(function ($field) {
return $field->fieldtype()->handle() === 'assets';
})
->mapWithKeys(function ($field) {
return [$field->handle().'.*' => 'file'];
})
->all();
return $assetFieldRules;
} | 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 putFile($sourcePath, $destinationFileName = null)
{
if (!$destinationFileName) {
$destinationFileName = $this->disk_name;
}
$destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory();
if (!$this->isLocalStorage()) {
return $this->copyLocalToStorage($sourcePath, $destinationPath . $destinationFileName);
}
/*
* Using local storage, tack on the root path and work locally
* this will ensure the correct permissions are used.
*/
$destinationPath = $this->getLocalRootPath() . '/' . $destinationPath;
/*
* Verify the directory exists, if not try to create it. If creation fails
* because the directory was created by a concurrent process then proceed,
* otherwise trigger the error.
*/
if (
!FileHelper::isDirectory($destinationPath) &&
!FileHelper::makeDirectory($destinationPath, 0777, true, true)
) {
trigger_error(error_get_last()['message'], E_USER_WARNING);
}
return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName);
} | 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 moveFile($oldPath, $newPath, $isRename = false)
{
$oldPath = self::validatePath($oldPath);
$fullOldPath = $this->getMediaPath($oldPath);
$newPath = self::validatePath($newPath);
$fullNewPath = $this->getMediaPath($newPath);
// If the file extension is changed to SVG, ensure that it has been sanitized
$oldExt = pathinfo($oldPath, PATHINFO_EXTENSION);
$newExt = pathinfo($newPath, PATHINFO_EXTENSION);
if ($oldExt !== $newExt && $newExt === 'svg') {
$contents = $this->getStorageDisk()->get($fullOldPath);
$contents = Svg::sanitize($contents);
$this->getStorageDisk()->put($fullOldPath, $contents);
}
return $this->getStorageDisk()->move($fullOldPath, $fullNewPath);
} | 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 getSaveValue($value)
{
return strlen($value) ? $value : null;
} | 0 | PHP | 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 | vulnerable |
protected function getDocumentPreviewPdf(Asset\Document $asset)
{
$stream = null;
if ($asset->getMimeType() == 'application/pdf') {
$stream = $asset->getStream();
}
if (!$stream && $asset->getPageCount() && \Pimcore\Document::isAvailable() && \Pimcore\Document::isFileTypeSupported($asset->getFilename())) {
try {
$document = \Pimcore\Document::getInstance();
$stream = $document->getPdf($asset);
} catch (\Exception $e) {
// nothing to do
}
}
return $stream;
} | 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 testFile()
{
$file = __DIR__ . '/fixtures/download.txt';
$response = Response::file($file);
$this->assertSame('text/plain', $response->type());
$this->assertSame(200, $response->code());
$this->assertSame('test', $response->body());
$response = Response::file($file, [
'code' => '201',
'headers' => [
'Pragma' => 'no-cache'
]
]);
$this->assertSame('text/plain', $response->type());
$this->assertSame(201, $response->code());
$this->assertSame('test', $response->body());
$this->assertSame([
'Pragma' => 'no-cache'
], $response->headers());
} | 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 testValidatePasswordHttpCode()
{
$user = new User([
'email' => '[email protected]',
'password' => User::hashPassword('correct-horse-battery-staple')
]);
$caught = 0;
try {
$user->validatePassword('short');
} catch (\Kirby\Exception\InvalidArgumentException $e) {
$this->assertSame(400, $e->getHttpCode());
$caught++;
}
try {
$user->validatePassword('longbutinvalid');
} catch (\Kirby\Exception\InvalidArgumentException $e) {
$this->assertSame(401, $e->getHttpCode());
$caught++;
}
$this->assertSame(2, $caught);
} | 0 | 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 | vulnerable |
public function currentUserFromSession($session = null)
{
$session = $this->session($session);
$id = $session->data()->get('kirby.userId');
if (is_string($id) !== true) {
return null;
}
if ($user = $this->kirby->users()->find($id)) {
// in case the session needs to be updated, do it now
// for better performance
$session->commit();
return $user;
}
return null;
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
protected function readPassword()
{
return F::read($this->root() . '/.htpasswd');
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
public function testUserSession2()
{
$session = (new AutoSession($this->app->root('sessions')))->createManually();
$session->set('kirby.userId', 'homer');
$user = $this->auth->user($session);
$this->assertSame('[email protected]', $user->email());
$this->assertSame([
'challenge' => null,
'email' => '[email protected]',
'status' => 'active'
], $this->auth->status()->toArray());
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
public function testUserSession1()
{
$session = $this->app->session();
$session->set('kirby.userId', 'marge');
$user = $this->auth->user();
$this->assertSame('[email protected]', $user->email());
$this->assertSame([
'challenge' => null,
'email' => '[email protected]',
'status' => 'active'
], $this->auth->status()->toArray());
// impersonation is not set
$this->assertNull($this->auth->currentUserFromImpersonation());
// value is cached
$session->set('kirby.userId', 'homer');
$user = $this->auth->user();
$this->assertSame('[email protected]', $user->email());
$this->assertSame([
'challenge' => null,
'email' => '[email protected]',
'status' => 'active'
], $this->auth->status()->toArray());
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
$phpunit->assertTrue($newUser->validatePassword('topsecret2018'));
$phpunit->assertEmpty($oldUser->password());
$calls++;
} | 0 | PHP | CWE-613 | Insufficient Session Expiration | According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization." | https://cwe.mitre.org/data/definitions/613.html | vulnerable |
static function (?NodeInterface $node, string $name) use ($nodes, $names) {
return $node === null && !in_array($name, $names, true)
|| $node !== null && !in_array($node, $nodes, true);
}, | 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 |
new Behavior\Handler\ClosureHandler(
static function (NodeInterface $node, ?DOMNode $domNode) {
return $domNode !== null ? new DOMText(trim($domNode->nodeValue)) : null;
} | 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 |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
function encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 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 encode($string = '', $skey = 'cxphp')
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key] .= $value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
} | 0 | PHP | CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak. | https://cwe.mitre.org/data/definitions/640.html | vulnerable |
public function openAction($uuid = null)
{
$this->view->selected_uuid = $uuid;
// include dialog form definitions
$this->view->formDialogEdit = $this->getForm("dialogEdit");
$this->view->pick('OPNsense/Cron/index');
} | 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 renderPage($module, $scope)
{
$this->view->pick('OPNsense/Diagnostics/log');
$this->view->module = $module;
$this->view->scope = $scope;
$this->view->service = '';
$this->view->default_log_severity = 'Warning';
$service = $module == 'core' ? $scope : $module;
/* XXX manually hook up known services and log severities for now */
switch ($service) {
case 'filter':
$this->view->default_log_severity = 'Informational';
break;
case 'ipsec':
$this->view->service = 'ipsec';
break;
case 'resolver':
$this->view->service = 'unbound';
break;
case 'suricata':
$this->view->service = 'ids';
break;
case 'squid':
$this->view->service = 'proxy';
break;
case 'system':
$this->view->default_log_severity = 'Notice';
break;
default:
/* no service API at the moment */
break;
}
} | 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 haltAction()
{
$backend = new Backend();
$backend->configdRun('system halt', true);
return [
'status' => 'ok'
];
} | 0 | 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 | vulnerable |
public function rebootAction()
{
$backend = new Backend();
$backend->configdRun('system reboot', true);
return [
'status' => 'ok'
];
} | 0 | 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 | vulnerable |
$array = ['message' => $exception->getMessage()]; | 0 | PHP | CWE-204 | Observable Response Discrepancy | The product provides different responses to incoming requests in a way that reveals internal state information to an unauthorized actor outside of the intended control sphere. | https://cwe.mitre.org/data/definitions/204.html | vulnerable |
$last = function ($schema, $query, $context, $vars) {
return GraphQL::executeQuery($schema, $query, null, $context, $vars);
}; | 0 | PHP | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
public function queryAndReturnResult(GraphQLSchema $schema, $query, ?array $vars = [])
{
if ($this->errorHandler) {
set_error_handler($this->errorHandler);
}
$context = $this->getContext();
$last = function ($schema, $query, $context, $vars) {
return GraphQL::executeQuery($schema, $query, null, $context, $vars);
};
return $this->callMiddleware($schema, $query, $context, $vars ?? [], $last);
} | 0 | PHP | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
private function assertFailure(array $result)
{
$errors = $result['errors'] ?? [];
if (empty($errors)) {
$this->fail('Failed to assert that query was not successful');
}
} | 0 | PHP | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
private function assertMissingField(array $result, string $fieldName)
{
$errors = $result['errors'] ?? [];
foreach ($errors as $error) {
if (preg_match('/^Cannot query field "' . $fieldName . '"/', $error['message'] ?? '')) {
return;
}
}
$this->fail('Failed to assert that result was missing field "' . $fieldName . '"');
} | 0 | PHP | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
private function assertSuccess(array $result)
{
$errors = $result['errors'] ?? [];
if (!empty($errors)) {
$this->fail('Failed to assert successful query. Got errors: ' . json_encode($errors, JSON_PRETTY_PRINT));
}
$error = $result['error'] ?? null;
if ($error) {
$this->fail('Failed to assert successful query. Got error: ' . $error);
}
} | 0 | PHP | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
$params[":id_$idx"] = new Parameter("id_$idx", $id, $idType);
++$idx;
}
$queryBuilder = $repository->createQueryBuilder('o');
if ($params) {
$queryBuilder
->where(sprintf("o.$idField IN (%s)", implode(', ', array_keys($params))))
->setParameters(new ArrayCollection($params));
}
$options['choices'] = $queryBuilder->getQuery()->getResult();
} else {
$options['choices'] = $repository->createQueryBuilder('o')
->where("o.$idField = :id")
->setParameter('id', $data['autocomplete'], $idType)
->getQuery()
->getResult();
}
}
// reset some critical lazy options
unset($options['em'], $options['loader'], $options['empty_data'], $options['choice_list'], $options['choices_as_values']);
$form->add('autocomplete', EntityType::class, $options);
} | 0 | PHP | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
function check_template($template)
{
// Check to see if our database password is in the template
if(preg_match('#\$config\[(([\'|"]database[\'|"])|([^\'"].*?))\]\[(([\'|"](database|hostname|password|table_prefix|username)[\'|"])|([^\'"].*?))\]#i', $template))
{
return true;
}
// System calls via backtick
if(preg_match('#\$\s*\{#', $template))
{
return true;
}
// Any other malicious acts?
// Courtesy of ZiNgA BuRgA
if(preg_match("~\\{\\$.+?\\}~s", preg_replace('~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\>|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\'"]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~', '', $template)))
{
return true;
}
return false;
} | 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 html_input($type = 'text', $name = '', $value = '', $attributes = []) {
if ($type === 'password') {
$attributes['autocomplete'] = 'off';
}
$attributes['type'] = $type;
$attributes['name'] = $name;
$attributes['value'] = $value;
return html_tag_short('input', $attributes, 'input form-control');
} | 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 |
function html_input($type = 'text', $name = '', $value = '', $attributes = []) {
if ($type === 'password') {
$attributes['autocomplete'] = 'off';
}
$attributes['type'] = $type;
$attributes['name'] = $name;
$attributes['value'] = $value;
return html_tag_short('input', $attributes, 'input form-control');
} | 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 |
function html_input($type = 'text', $name = '', $value = '', $attributes = []) {
if ($type === 'password') {
$attributes['autocomplete'] = 'off';
}
$attributes['type'] = $type;
$attributes['name'] = $name;
$attributes['value'] = $value;
return html_tag_short('input', $attributes, 'input form-control');
} | 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 |
private function uploadPackage(){
$this->cms_uploader->enableRemoteUpload();
if (!$this->cms_uploader->isUploaded($this->upload_name) && !$this->cms_uploader->isUploadedFromLink($this->upload_name)){
$last_error = $this->cms_uploader->getLastError();
if($last_error){
cmsUser::addSessionMessage($last_error, 'error');
}
return false;
}
files_clear_directory(cmsConfig::get('upload_path') . $this->installer_upload_path);
$result = $this->cms_uploader->upload($this->upload_name, $this->upload_exts, 0, $this->installer_upload_path);
if (!$result['success']){
cmsUser::addSessionMessage($result['error'], 'error');
return false;
}
return $result['name'];
} | 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 getXHRFileSize(){
if (isset($_SERVER["CONTENT_LENGTH"])){
return (int)$_SERVER["CONTENT_LENGTH"];
} else {
return false;
}
} | 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 remove($file_path){
return @unlink($file_path);
} | 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 saveXHRFile($destination, $orig_name=''){
$target = @fopen($destination, 'wb');
$input = @fopen("php://input", 'rb');
if (!$target){
return array(
'success' => false,
'error' => LANG_UPLOAD_ERR_CANT_WRITE,
'name' => $orig_name,
'path' => ''
);
}
if (!$input){
return array(
'success' => false,
'error' => LANG_UPLOAD_ERR_NO_FILE,
'name' => $orig_name,
'path' => ''
);
}
while ($buff = fread($input, 4096)) {
fwrite($target, $buff);
}
@fclose($target);
@fclose($input);
$real_size = filesize($destination);
if (!$real_size || $real_size != $this->getXHRFileSize()){
@unlink($destination);
return array(
'success' => false,
'error' => LANG_UPLOAD_ERR_PARTIAL,
'name' => $orig_name,
'path' => ''
);
}
if($this->allowed_mime !== false){
if(!$this->isMimeTypeAllowed($destination)){
@unlink($destination);
return array(
'error' => LANG_UPLOAD_ERR_MIME.'. '.sprintf(LANG_PARSER_FILE_EXTS_FIELD_HINT, implode(', ', $this->allowed_mime_ext)),
'success' => false,
'name' => $orig_name,
'path' => ''
);
}
}
return array(
'success' => true,
'path' => $destination,
'url' => str_replace($this->site_cfg->upload_path, '', $destination),
'name' => $orig_name,
'size' => $real_size
);
} | 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 setFileName($name) {
$this->file_name = mb_substr(trim($name), 0, 64); return $this;
} | 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 enableRemoteUpload() {
$this->allow_remote = true; return $this;
} | 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 isImage($src){
$size = getimagesize($src);
return $size !== false;
} | 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 |
private function getFileName($path, $file_ext, $file_name = false) {
if(!$file_name){
if($this->file_name){
$file_name = str_replace('.'.$file_ext, '', files_sanitize_name($this->file_name.'.'.$file_ext));
} else {
$file_name = substr(md5(microtime(true)), 0, 8);
}
}
if (file_exists($path.$file_name.'.'.$file_ext)) {
return $this->getFileName($path, $file_ext, $file_name.'_'.md5(microtime(true)));
}
return $file_name.'.'.$file_ext;
} | 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 getUploadDestinationDirectory(){
return files_get_upload_dir($this->user_id);
} | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.