mcanoglu commited on
Commit
5e5d5e0
1 Parent(s): 49b2210

Upload 3 files

Browse files
Files changed (3) hide show
  1. test.jsonl +57 -0
  2. train.jsonl +0 -0
  3. validation.jsonl +56 -0
test.jsonl ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"code": "\t\tfunction uninstallPage()\n\t\t{\n\t\t\t$id = $this->getId();\n\n\t\t\tif(empty($_POST['uninstall_confirm']))\n\t\t\t{\n\n\t\t\t\t$plug_vars = e107::getPlug()->load($id)->getMeta();\n\n\t\t\t\t$name = e107::getPlug()->getName();\n\t\t\t\t$this->addTitle(EPL_ADLAN_63);\n\t\t\t\t$this->addTitle($name);\n\n\t\t\t\treturn $this->pluginConfirmUninstall($plug_vars);\n\t\t\t}\n\n\t\t\t$post = e107::getParser()->filter($_POST);\n\n\n\n\t\t//\t$id = e107::getPlugin\n\n\t\t\t$text = e107::getPlugin()->uninstall($id, $post);\n\n\t\t\te107::getMessage()->add($text, E_MESSAGE_SUCCESS);\n\t\t\t$log = e107::getPlugin()->getLog();\n\t\t\te107::getDebug()->log($log);\n\n\t\t\t$this->redirectAction('list');\n\t\t}", "label_name": "CWE-352", "label": 0}
2
+ {"code": " function restart($sMessage = '')\n {\n $_COOKIE['sessionID'] = phpAds_SessionStart();\n OA_Auth::displayLogin($sMessage, $_COOKIE['sessionID']);\n }", "label_name": "CWE-384", "label": 1}
3
+ {"code": "function select_atversion(){ \n global $sort_versions;\n $menu = '<form action=\"'.$_SERVER['PHP_SELF'].'\" method=\"post\">'; \n $menu.= '<select name=\"atversions\">';\n $menu.= '<option value=\"0\">'._AT(\"all\").'</option>';\n foreach($sort_versions as $version){\n if($version == VERSION){\n $menu .= '<option value=\"'.$version.'\" selected=\"selected\">'.$version.'</option>';\n }else{\n $menu .= '<option value=\"'.$version.'\" >'.$version.'</option>';\n }\n }\n $menu .='</select>';\n $menu .='<input type=\"submit\" value=\"'. _AT('filter').'\"/></form>';\n return $menu;\n}", "label_name": "CWE-352", "label": 0}
4
+ {"code": " public static function dropdown($vars) {\n if(is_array($vars)){\n //print_r($vars);\n $name = $vars['name'];\n $where = \"WHERE \";\n if(isset($vars['parent'])) {\n $where .= \" `parent` = '{$vars['parent']}' \";\n }else{\n $where .= \"1 \";\n }\n $order_by = \"ORDER BY \";\n if(isset($vars['order_by'])) {\n $order_by .= \" {$vars['order_by']} \";\n }else{\n $order_by .= \" `name` \";\n }\n if (isset($vars['sort'])) {\n $sort = \" {$vars['sort']}\";\n }\n }\n $cat = Db::result(\"SELECT * FROM `cat` {$where} {$order_by} {$sort}\");\n $drop = \"<select name=\\\"{$name}\\\" class=\\\"form-control\\\"><option></option>\";\n if(Db::$num_rows > 0 ){\n foreach ($cat as $c) {\n # code...\n if($c->parent == ''){\n if(isset($vars['selected']) && $c->id == $vars['selected']) $sel = \"SELECTED\"; else $sel = \"\";\n $drop .= \"<option value=\\\"{$c->id}\\\" $sel style=\\\"padding-left: 10px;\\\">{$c->name}</option>\";\n foreach ($cat as $c2) {\n # code...\n if($c2->parent == $c->id){\n if(isset($vars['selected']) && $c2->id == $vars['selected']) $sel = \"SELECTED\"; else $sel = \"\";\n $drop .= \"<option value=\\\"{$c2->id}\\\" $sel style=\\\"padding-left: 10px;\\\">&nbsp;&nbsp;&nbsp;{$c2->name}</option>\";\n }\n }\n }\n \n }\n }\n $drop .= \"</select>\";\n\n return $drop;\n }", "label_name": "CWE-352", "label": 0}
5
+ {"code": " self::$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);\n return self::$mysqli;\n }\n }", "label_name": "CWE-352", "label": 0}
6
+ {"code": " public static function makeConfig ($file) {\n $config = \"<?php if(!defined('GX_LIB')) die(\\\"Direct Access Not Allowed!\\\");\n/**\n* GeniXCMS - Content Management System\n* \n* PHP Based Content Management System and Framework\n*\n* @package GeniXCMS\n* @since 0.0.1 build date 20140925\n* @version 0.0.1\n* @link https://github.com/semplon/GeniXCMS\n* @author Puguh Wijayanto (www.metalgenix.com)\n* @copyright 2014-2015 Puguh Wijayanto\n* @license http://www.opensource.org/licenses/mit-license.php MIT\n*\n*/\n\n// DB CONFIG\ndefine('DB_HOST', '\".Session::val('dbhost').\"');\ndefine('DB_NAME', '\".Session::val('dbname').\"');\ndefine('DB_PASS', '\".Session::val('dbpass').\"');\ndefine('DB_USER', '\".Session::val('dbuser').\"');\ndefine('DB_DRIVER', 'mysqli');\n\n\ndefine('THEME', 'default');\ndefine('GX_LANG', 'english');\ndefine('SMART_URL', false); //set 'true' if you want use SMART URL (SEO Friendly URL)\ndefine('GX_URL_PREFIX', '.html');\ndefine('SECURITY', '\".Typo::getToken(200).\"'); // for security purpose, will be used for creating password\n\n \";\n try{\n $f = fopen($file, \"w\");\n $c = fwrite($f, $config);\n fclose($f);\n }catch (Exception $e) {\n echo $e->getMessage();\n }\n \n return $config;\n }", "label_name": "CWE-352", "label": 0}
7
+ {"code": " $data .= '<input type=\"hidden\" name=\"'.htmlspecialchars($key).'\" value=\"'.htmlspecialchars($value).'\" />';\n }\n echo \"<html><head><title>CSRF check failed</title></head>\n <body>\n <p>CSRF check failed. Your form session may have expired, or you may not have\n cookies enabled.</p>\n <form method='post' action=''>$data<input type='submit' value='Try again' /></form>\n <p>Debug: $tokens</p></body></html>\n\";\n}", "label_name": "CWE-352", "label": 0}
8
+ {"code": " public function delete(){\n $cat_id = I(\"cat_id/d\")? I(\"cat_id/d\") : 0;\n $cat = D(\"Catalog\")->where(\" cat_id = '$cat_id' \")->find();\n $item_id = $cat['item_id'];\n \n $login_user = $this->checkLogin();\n if (!$this->checkItemEdit($login_user['uid'] , $item_id)) {\n $return['error_code'] = -1 ;\n $return['error_message'] = L('no_permissions');\n $this->sendResult($return);\n return;\n }\n\n if ($cat_id > 0 ) {\n \n $ret = D(\"Catalog\")->deleteCat($cat_id);\n\n }\n if ($ret) {\n $this->sendResult($ret);\n }else{\n $return['error_code'] = -1 ;\n $return['error_message'] = 'request fail' ;\n $this->sendResult($return);\n }\n }", "label_name": "CWE-352", "label": 0}
9
+ {"code": "\tpublic static function GetNewTransactionId()\n\t{\n\t\tif (!is_dir(APPROOT.'data/transactions'))\n\t\t{\n\t\t\tif (!is_writable(APPROOT.'data'))\n\t\t\t{\n\t\t\t\tthrow new Exception('The directory \"'.APPROOT.'data\" must be writable to the application.');\n\t\t\t}\n\t\t\t/** @noinspection MkdirRaceConditionInspection */\n\t\t\tif (!@mkdir(APPROOT.'data/transactions'))\n\t\t\t{\n\t\t\t\tthrow new Exception('Failed to create the directory \"'.APPROOT.'data/transactions\". Ajust the rights on the parent directory or let an administrator create the transactions directory and give the web sever enough rights to write into it.');\n\t\t\t}\n\t\t}\n\t\tif (!is_writable(APPROOT.'data/transactions'))\n\t\t{\n\t\t\tthrow new Exception('The directory \"'.APPROOT.'data/transactions\" must be writable to the application.');\n\t\t}\n\t\tself::CleanupOldTransactions();\n\t\t$id = basename(tempnam(APPROOT.'data/transactions', static::GetUserPrefix()));\n\t\tself::Info('GetNewTransactionId: Created transaction: '.$id);\n\n\t\treturn (string)$id;\n\t}", "label_name": "CWE-352", "label": 0}
10
+ {"code": "\tpublic static function IsTransactionValid($id, $bRemoveTransaction = true)\n\t{\n\t\t// Constraint the transaction file within APPROOT.'data/transactions'\n\t\t$sTransactionDir = realpath(APPROOT.'data/transactions');\n\t\t$sFilepath = utils::RealPath($sTransactionDir.'/'.$id, $sTransactionDir);\n\t\tif (($sFilepath === false) || (strlen($sTransactionDir) == strlen($sFilepath)))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tclearstatcache(true, $sFilepath);\n\t\t$bResult = file_exists($sFilepath);\n\t\tif ($bResult)\n\t\t{\n\t\t\tif ($bRemoveTransaction)\n\t\t\t{\n\t\t\t\t$bResult = @unlink($sFilepath);\n\t\t\t\tif (!$bResult)\n\t\t\t\t{\n\t\t\t\t\tself::Error('IsTransactionValid: FAILED to remove transaction '.$id);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tself::Info('IsTransactionValid: OK. Removed transaction: '.$id);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tself::Info(\"IsTransactionValid: Transaction '$id' not found. Pending transactions for this user:\\n\".implode(\"\\n\", self::GetPendingTransactions()));\n\t\t}\n\t\treturn $bResult;\n\t}", "label_name": "CWE-352", "label": 0}
11
+ {"code": "\t\t\t\t$this->doDelete( $type, $dump );\n\t\t\t}\n\t\t}\n\n\t\t$pager = new DataDumpPager( $this->getContext(), $this->getPageTitle() );\n\n\t\t$out->addModuleStyles( 'mediawiki.special' );\n\n\t\t$pager->getForm();\n\t\t$out->addParserOutputContent( $pager->getFullOutput() );\n\t}", "label_name": "CWE-352", "label": 0}
12
+ {"code": " public function setPassword(Request $request, string $token)\n {\n $this->validate($request, [\n 'password' => ['required', 'min:8'],\n ]);\n\n try {\n $userId = $this->inviteService->checkTokenAndGetUserId($token);\n } catch (Exception $exception) {\n return $this->handleTokenException($exception);\n }\n\n $user = $this->userRepo->getById($userId);\n $user->password = bcrypt($request->get('password'));\n $user->email_confirmed = true;\n $user->save();\n\n $this->inviteService->deleteByUser($user);\n $this->showSuccessNotification(trans('auth.user_invite_success', ['appName' => setting('app-name')]));\n $this->loginService->login($user, auth()->getDefaultDriver());\n\n return redirect('/');\n }", "label_name": "CWE-352", "label": 0}
13
+ {"code": " public function buildView(FormView $view, FormInterface $form, array $options)\n {\n if (!isset($options['api_data'])) {\n return;\n }\n\n $apiData = $options['api_data'];\n\n if (!\\is_array($apiData)) {\n throw new \\InvalidArgumentException('Option \"api_data\" must be an array for form \"' . $form->getName() . '\"');\n }\n\n if (!isset($apiData['select'])) {\n return;\n }\n\n if (!isset($apiData['route'])) {\n throw new \\InvalidArgumentException('Missing \"route\" option for \"api_data\" option for form \"' . $form->getName() . '\"');\n }\n\n if (!isset($apiData['route_params'])) {\n $apiData['route_params'] = [];\n }\n\n $formPrefixes = [];\n $parent = $form->getParent();\n do {\n $formPrefixes[] = $parent->getName();\n } while (($parent = $parent->getParent()) !== null);\n\n $formPrefix = implode('_', array_reverse($formPrefixes));\n\n $formField = $formPrefix . '_' . $apiData['select'];\n\n $view->vars['attr'] = array_merge($view->vars['attr'], [\n 'data-form-prefix' => $formPrefix,\n 'data-related-select' => $formField,\n 'data-api-url' => $this->router->generate($apiData['route'], $apiData['route_params']),\n ]);\n\n if (isset($apiData['empty_route_params'])) {\n $view->vars['attr'] = array_merge($view->vars['attr'], [\n 'data-empty-url' => $this->router->generate($apiData['route'], $apiData['empty_route_params']),\n ]);\n }\n }", "label_name": "CWE-352", "label": 0}
14
+ {"code": "rcube_webmail.prototype.enigma_export = function(selected)\n{\n var keys = selected ? this.keys_list.get_selection().join(',') : '*';\n\n if (!keys.length)\n return;\n\n this.goto_url('plugin.enigmakeys', {_a: 'export', _keys: keys});\n};", "label_name": "CWE-352", "label": 0}
15
+ {"code": "\tdeleteTheme: function() {\n\t\treturn confirm( themes.data.settings.confirmDelete );\n\t},", "label_name": "CWE-352", "label": 0}
16
+ {"code": "\twp.updates.beforeunload = function() {\n\t\tif ( wp.updates.updateLock ) {\n\t\t\treturn wp.updates.l10n.beforeunload;\n\t\t}\n\t};", "label_name": "CWE-352", "label": 0}
17
+ {"code": "\twp.updates.credentialError = function( response, type ) {\n\t\twp.updates.updateQueue.push( {\n\t\t\t'type': type,\n\t\t\t'data': {\n\t\t\t\t// Not cool that we're depending on response for this data.\n\t\t\t\t// This would feel more whole in a view all tied together.\n\t\t\t\tplugin: response.plugin,\n\t\t\t\tslug: response.slug\n\t\t\t}\n\t\t} );\n\t\twp.updates.showErrorInCredentialsForm( response.error );\n\t\twp.updates.requestFilesystemCredentials();\n\t};", "label_name": "CWE-352", "label": 0}
18
+ {"code": " success:function (data, textStatus) {\n showMessage('success', 'Homepage set.');\n $('#setHomePage').addClass('orange');\n },", "label_name": "CWE-352", "label": 0}
19
+ {"code": "function checkAddingNode(){\n var nodeName = $(\"#add_node\").children(\"form\").find(\"[name='new_nodename']\").val().trim();\n if (nodeName == \"\") {\n $(\"#add_node_submit_btn\").button(\"option\", \"disabled\", false);\n return false;\n }\n\n $.ajax({\n type: 'GET',\n url: '/manage/check_pcsd_status',\n data: {\"nodes\": nodeName},\n timeout: pcs_timeout,\n success: function (data) {\n var mydata = jQuery.parseJSON(data);\n if (mydata[nodeName] == \"Unable to authenticate\") {\n auth_nodes_dialog([nodeName], function(){$(\"#add_node_submit_btn\").trigger(\"click\");});\n $(\"#add_node_submit_btn\").button(\"option\", \"disabled\", false);\n } else if (mydata[nodeName] == \"Offline\") {\n alert(\"Unable to contact node '\" + nodeName + \"'\");\n $(\"#add_node_submit_btn\").button(\"option\", \"disabled\", false);\n } else {\n create_node($(\"#add_node\").children(\"form\"));\n }\n },\n error: function (XMLHttpRequest, textStatus, errorThrown) {\n alert(\"ERROR: Unable to contact server\");\n $(\"#add_node_submit_btn\").button(\"option\", \"disabled\", false);\n }\n });\n}", "label_name": "CWE-384", "label": 1}
20
+ {"code": " $scope.initialize = function(customHandler) {\n var value = $cookies.get('requisitions_page_size');\n if (value) {\n $scope.pageSize = value;\n }\n growl.success('Retrieving requisition ' + $scope.foreignSource + '...');\n RequisitionsService.getRequisition($scope.foreignSource).then(\n function(requisition) { // success\n $scope.requisition = requisition;\n $scope.filteredNodes = requisition.nodes;\n $scope.updateFilteredNodes();\n if (customHandler) {\n customHandler();\n }\n },\n $scope.errorHandler\n );\n };", "label_name": "CWE-352", "label": 0}
21
+ {"code": " this.changeUserSettings = function(attr,value){\n \t$.get(this.wwwDir+ 'user/setsettingajax/'+attr+'/'+value);\n };", "label_name": "CWE-352", "label": 0}
22
+ {"code": " def test_reset_student_attempts_delete(self):\n \"\"\" Test delete single student state. \"\"\"\n url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {\n 'problem_to_reset': self.problem_urlname,\n 'unique_student_identifier': self.student.email,\n 'delete_module': True,\n })\n self.assertEqual(response.status_code, 200)\n # make sure the module has been deleted\n self.assertEqual(\n StudentModule.objects.filter(\n student=self.module_to_reset.student,\n course_id=self.module_to_reset.course_id,\n # module_id=self.module_to_reset.module_id,\n ).count(),\n 0\n )", "label_name": "CWE-352", "label": 0}
23
+ {"code": " def test_list_email_content_error(self, task_history_request):\n \"\"\" Test handling of error retrieving email \"\"\"\n invalid_task = FakeContentTask(0, 0, 0, 'test')\n invalid_task.make_invalid_input()\n task_history_request.return_value = [invalid_task]\n url = reverse('list_email_content', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {})\n self.assertEqual(response.status_code, 200)\n\n self.assertTrue(task_history_request.called)\n returned_email_info = json.loads(response.content)['emails']\n self.assertEqual(len(returned_email_info), 1)\n returned_info = returned_email_info[0]\n for info in ['created', 'sent_to', 'email', 'number_sent', 'requester']:\n self.assertEqual(returned_info[info], None)", "label_name": "CWE-352", "label": 0}
24
+ {"code": " def test_rescore_entrance_exam_with_invalid_exam(self):\n \"\"\" Test course has entrance exam id set while re-scoring. \"\"\"\n url = reverse('rescore_entrance_exam', kwargs={'course_id': unicode(self.course.id)})\n response = self.client.get(url, {\n 'unique_student_identifier': self.student.email,\n })\n self.assertEqual(response.status_code, 400)", "label_name": "CWE-352", "label": 0}
25
+ {"code": " def test_get_students_who_may_enroll(self):\n \"\"\"\n Test whether get_students_who_may_enroll returns an appropriate\n status message when users request a CSV file of students who\n may enroll in a course.\n \"\"\"\n url = reverse(\n 'get_students_who_may_enroll',\n kwargs={'course_id': unicode(self.course.id)}\n )\n # Successful case:\n response = self.client.get(url, {})\n res_json = json.loads(response.content)\n self.assertIn('status', res_json)\n self.assertNotIn('currently being created', res_json['status'])\n # CSV generation already in progress:\n with patch('instructor_task.api.submit_calculate_may_enroll_csv') as submit_task_function:\n error = AlreadyRunningError()\n submit_task_function.side_effect = error\n response = self.client.get(url, {})\n res_json = json.loads(response.content)\n self.assertIn('status', res_json)\n self.assertIn('currently being created', res_json['status'])", "label_name": "CWE-352", "label": 0}
26
+ {"code": " def test_get_sale_records_features_csv(self):\n \"\"\"\n Test that the response from get_sale_records is in csv format.\n \"\"\"\n for i in range(2):\n course_registration_code = CourseRegistrationCode(\n code='sale_invoice{}'.format(i),\n course_id=self.course.id.to_deprecated_string(),\n created_by=self.instructor,\n invoice=self.sale_invoice_1,\n invoice_item=self.invoice_item,\n mode_slug='honor'\n )\n course_registration_code.save()\n\n url = reverse(\n 'get_sale_records',\n kwargs={'course_id': self.course.id.to_deprecated_string()}\n )\n response = self.client.get(url + '/csv', {})\n self.assertEqual(response['Content-Type'], 'text/csv')", "label_name": "CWE-352", "label": 0}
27
+ {"code": " def test_modify_access_revoke(self):\n url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {\n 'unique_student_identifier': self.other_staff.email,\n 'rolename': 'staff',\n 'action': 'revoke',\n })\n self.assertEqual(response.status_code, 200)", "label_name": "CWE-352", "label": 0}
28
+ {"code": " def get_email_content_response(self, num_emails, task_history_request, with_failures=False):\n \"\"\" Calls the list_email_content endpoint and returns the repsonse \"\"\"\n self.setup_fake_email_info(num_emails, with_failures)\n task_history_request.return_value = self.tasks.values()\n url = reverse('list_email_content', kwargs={'course_id': self.course.id.to_deprecated_string()})\n with patch('instructor.views.api.CourseEmail.objects.get') as mock_email_info:\n mock_email_info.side_effect = self.get_matching_mock_email\n response = self.client.get(url, {})\n self.assertEqual(response.status_code, 200)\n return response", "label_name": "CWE-352", "label": 0}
29
+ {"code": " def test_get_student_progress_url(self):\n \"\"\" Test that progress_url is in the successful response. \"\"\"\n url = reverse('get_student_progress_url', kwargs={'course_id': self.course.id.to_deprecated_string()})\n url += \"?unique_student_identifier={}\".format(\n quote(self.students[0].email.encode(\"utf-8\"))\n )\n response = self.client.get(url)\n self.assertEqual(response.status_code, 200)\n res_json = json.loads(response.content)\n self.assertIn('progress_url', res_json)", "label_name": "CWE-352", "label": 0}
30
+ {"code": " def test_reset_student_attempts_invalid_entrance_exam(self):\n \"\"\" Test reset for invalid entrance exam. \"\"\"\n url = reverse('reset_student_attempts_for_entrance_exam',\n kwargs={'course_id': unicode(self.course_with_invalid_ee.id)})\n response = self.client.get(url, {\n 'unique_student_identifier': self.student.email,\n })\n self.assertEqual(response.status_code, 400)", "label_name": "CWE-352", "label": 0}
31
+ {"code": "def list_forum_members(request, course_id):\n \"\"\"\n Lists forum members of a certain rolename.\n Limited to staff access.\n\n The requesting user must be at least staff.\n Staff forum admins can access all roles EXCEPT for FORUM_ROLE_ADMINISTRATOR\n which is limited to instructors.\n\n Takes query parameter `rolename`.\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n course = get_course_by_id(course_id)\n has_instructor_access = has_access(request.user, 'instructor', course)\n has_forum_admin = has_forum_access(\n request.user, course_id, FORUM_ROLE_ADMINISTRATOR\n )\n\n rolename = request.GET.get('rolename')\n\n # default roles require either (staff & forum admin) or (instructor)\n if not (has_forum_admin or has_instructor_access):\n return HttpResponseBadRequest(\n \"Operation requires staff & forum admin or instructor access\"\n )\n\n # EXCEPT FORUM_ROLE_ADMINISTRATOR requires (instructor)\n if rolename == FORUM_ROLE_ADMINISTRATOR and not has_instructor_access:\n return HttpResponseBadRequest(\"Operation requires instructor access.\")\n\n # filter out unsupported for roles\n if rolename not in [FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, FORUM_ROLE_COMMUNITY_TA]:\n return HttpResponseBadRequest(strip_tags(\n \"Unrecognized rolename '{}'.\".format(rolename)\n ))\n\n try:\n role = Role.objects.get(name=rolename, course_id=course_id)\n users = role.users.all().order_by('username')\n except Role.DoesNotExist:\n users = []\n\n def extract_user_info(user):\n \"\"\" Convert user to dict for json rendering. \"\"\"\n return {\n 'username': user.username,\n 'email': user.email,\n 'first_name': user.first_name,\n 'last_name': user.last_name,\n }\n\n response_payload = {\n 'course_id': course_id.to_deprecated_string(),\n rolename: map(extract_user_info, users),\n }\n return JsonResponse(response_payload)", "label_name": "CWE-352", "label": 0}
32
+ {"code": " def decorator(func): # pylint: disable=missing-docstring\n def wrapped(*args, **kwargs): # pylint: disable=missing-docstring\n request = args[0]\n\n error_response_data = {\n 'error': 'Missing required query parameter(s)',\n 'parameters': [],\n 'info': {},\n }\n\n for (param, extra) in required_params:\n default = object()\n if request.GET.get(param, default) == default:\n error_response_data['parameters'].append(param)\n error_response_data['info'][param] = extra\n\n if len(error_response_data['parameters']) > 0:\n return JsonResponse(error_response_data, status=400)\n else:\n return func(*args, **kwargs)\n return wrapped", "label_name": "CWE-352", "label": 0}
33
+ {"code": " def test_file(self, tmpdir):\n filename = tmpdir / 'foo'\n filename.ensure()\n url = QUrl.fromLocalFile(str(filename))\n req = QNetworkRequest(url)\n reply = filescheme.handler(req)\n assert reply is None", "label_name": "CWE-352", "label": 0}
34
+ {"code": " public void onSubmit()\n {\n final String sessionCsrfToken = getCsrfSessionToken();\n final String postedCsrfToken = this.csrfTokenField.getInput();\n if (StringUtils.equals(sessionCsrfToken, postedCsrfToken) == false) {\n log.error(\"Cross site request forgery alert. csrf token doesn't match! session csrf token=\"\n + sessionCsrfToken\n + \", posted csrf token=\"\n + postedCsrfToken);\n throw new InternalErrorException(\"errorpage.csrfError\");\n }\n }", "label_name": "CWE-352", "label": 0}
35
+ {"code": " public DropFileContainer(final String id, final String mimeType) {\n super(id);\n this.mimeType = mimeType;\n main = new WebMarkupContainer(\"main\");\n add(main);\n }", "label_name": "CWE-352", "label": 0}
36
+ {"code": " public void accessAllowed() {\n expect(backend.isRemoteAccessAllowed(\"localhost\",\"127.0.0.1\")).andReturn(true);\n replay(backend);\n\n handler.checkClientIPAccess(\"localhost\",\"127.0.0.1\");\n }", "label_name": "CWE-352", "label": 0}
37
+ {"code": " public void handle(HttpExchange pExchange) throws IOException {\n if (requestHandler == null) {\n throw new IllegalStateException(\"Handler not yet started\");\n }\n\n JSONAware json = null;\n URI uri = pExchange.getRequestURI();\n ParsedUri parsedUri = new ParsedUri(uri,context);\n try {\n // Check access policy\n InetSocketAddress address = pExchange.getRemoteAddress();\n requestHandler.checkClientIPAccess(address.getHostName(),address.getAddress().getHostAddress());\n String method = pExchange.getRequestMethod();\n\n // Dispatch for the proper HTTP request method\n if (\"GET\".equalsIgnoreCase(method)) {\n setHeaders(pExchange);\n json = executeGetRequest(parsedUri);\n } else if (\"POST\".equalsIgnoreCase(method)) {\n setHeaders(pExchange);\n json = executePostRequest(pExchange, parsedUri);\n } else if (\"OPTIONS\".equalsIgnoreCase(method)) {\n performCorsPreflightCheck(pExchange);\n } else {\n throw new IllegalArgumentException(\"HTTP Method \" + method + \" is not supported.\");\n }\n } catch (Throwable exp) {\n json = requestHandler.handleThrowable(\n exp instanceof RuntimeMBeanException ? ((RuntimeMBeanException) exp).getTargetException() : exp);\n } finally {\n sendResponse(pExchange,parsedUri,json);\n }\n }", "label_name": "CWE-352", "label": 0}
38
+ {"code": " private static final RestrictorCheck CORS_CHECK = new RestrictorCheck() {\n /** {@inheritDoc} */\n public boolean check(Restrictor restrictor, Object... args) {\n return restrictor.isCorsAccessAllowed((String) args[0]);\n }\n };", "label_name": "CWE-352", "label": 0}
39
+ {"code": " public boolean isCorsAccessAllowed(String pOrigin) {\n return checkRestrictorService(CORS_CHECK,pOrigin);\n }", "label_name": "CWE-352", "label": 0}
40
+ {"code": " public boolean isCorsAccessAllowed(String pOrigin) {\n return cors;\n }", "label_name": "CWE-352", "label": 0}
41
+ {"code": " def initialize(session, config_classes, nodes, cluster_name)\n @config_classes = config_classes\n @nodes = nodes\n @cluster_name = cluster_name\n @session = session\n end", "label_name": "CWE-384", "label": 1}
42
+ {"code": " def send(force=false)\n nodes_txt = @nodes.join(', ')\n @configs.each { |cfg|\n $logger.info(\n \"Sending config '#{cfg.class.name}' version #{cfg.version} #{cfg.hash}\"\\\n + \" to nodes: #{nodes_txt}\"\n )\n }\n\n data = self.prepare_request_data(@configs, @cluster_name, force)\n node_response = {}\n threads = []\n @nodes.each { |node|\n threads << Thread.new {\n code, out = send_request_with_token(\n @session, node, 'set_configs', true, data, true, nil, 30,\n @additional_tokens\n )\n if 200 == code\n begin\n node_response[node] = JSON.parse(out)\n rescue JSON::ParserError\n end\n elsif 404 == code\n node_response[node] = {'status' => 'not_supported'}\n else\n begin\n response = JSON.parse(out)\n if true == response['notauthorized'] or true == response['notoken']\n node_response[node] = {'status' => 'notauthorized'}\n end\n rescue JSON::ParserError\n end\n end\n if not node_response.key?(node)\n node_response[node] = {'status' => 'error'}\n end\n # old pcsd returns this instead of 404 if pacemaker isn't running there\n if node_response[node]['pacemaker_not_running']\n node_response[node] = {'status' => 'not_supported'}\n end\n }\n }\n threads.each { |t| t.join }\n\n node_response.each { |node, response|\n $logger.info(\"Sending config response from #{node}: #{response}\")\n }\n\n return node_response\n end", "label_name": "CWE-384", "label": 1}
43
+ {"code": "def remove_node(session, new_nodename, all=false)\n if all\n # we check for a quorum loss warning in remote_remove_nodes\n out, stderror, retval = run_cmd(\n session, PCS, \"cluster\", \"node\", \"remove\", new_nodename, \"--force\"\n )\n else\n out, stderror, retval = run_cmd(\n session, PCS, \"cluster\", \"localnode\", \"remove\", new_nodename\n )\n end\n $logger.info(\"Removing #{new_nodename} from pcs_settings.conf\")\n corosync_nodes = get_corosync_nodes()\n pcs_config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text())\n pcs_config.update_cluster($cluster_name, corosync_nodes)\n sync_config = Cfgsync::PcsdSettings.from_text(pcs_config.text())\n # on version conflict just go on, config will be corrected eventually\n # by displaying the cluster in the web UI\n Cfgsync::save_sync_new_version(\n sync_config, corosync_nodes, $cluster_name, true\n )\n return retval, out + stderror\nend", "label_name": "CWE-384", "label": 1}
44
+ {"code": "def remove_acl_permission(session, acl_perm_id)\n stdout, stderror, retval = run_cmd(\n session, PCS, \"acl\", \"permission\", \"delete\", acl_perm_id.to_s\n )\n if retval != 0\n if stderror.empty?\n return \"Error removing permission\"\n else\n return stderror.join(\"\\n\").strip\n end\n end\n return \"\"\nend", "label_name": "CWE-384", "label": 1}
45
+ {"code": "def get_corosync_version()\n begin\n stdout, stderror, retval = run_cmd(\n PCSAuth.getSuperuserSession, COROSYNC, \"-v\"\n )\n rescue\n stdout = []\n end\n if retval == 0\n match = /version\\D+(\\d+)\\.(\\d+)\\.(\\d+)/.match(stdout.join())\n if match\n return match[1..3].collect { | x | x.to_i }\n end\n end\n return nil\nend", "label_name": "CWE-384", "label": 1}
46
+ {"code": "def get_cluster_name()\n if ISRHEL6\n stdout, stderror, retval = run_cmd(\n PCSAuth.getSuperuserSession, COROSYNC_CMAPCTL, \"cluster\"\n )\n if retval == 0\n stdout.each { |line|\n match = /^cluster\\.name=(.*)$/.match(line)\n return match[1] if match\n }\n end\n begin\n cluster_conf = Cfgsync::ClusterConf.from_file().text()\n rescue\n return ''\n end\n conf_dom = REXML::Document.new(cluster_conf)\n if conf_dom.root and conf_dom.root.name == 'cluster'\n return conf_dom.root.attributes['name']\n end\n return ''\n end\n\n stdout, stderror, retval = run_cmd(\n PCSAuth.getSuperuserSession, COROSYNC_CMAPCTL, \"totem.cluster_name\"\n )\n if retval != 0 and not ISRHEL6\n # Cluster probably isn't running, try to get cluster name from\n # corosync.conf\n begin\n corosync_conf = CorosyncConf::parse_string(\n Cfgsync::CorosyncConf.from_file().text()\n )\n # mimic corosync behavior - the last cluster_name found is used\n cluster_name = nil\n corosync_conf.sections('totem').each { |totem|\n totem.attributes('cluster_name').each { |attrib|\n cluster_name = attrib[1]\n }\n }\n return cluster_name if cluster_name\n rescue\n return ''\n end\n return \"\"\n else\n return stdout.join().gsub(/.*= /,\"\").strip\n end\nend", "label_name": "CWE-384", "label": 1}
47
+ {"code": "def add_node_attr(session, node, key, value)\n stdout, stderr, retval = run_cmd(\n session, PCS, \"property\", \"set\", \"--node\", node, key.to_s + '=' + value.to_s\n )\n return retval\nend", "label_name": "CWE-384", "label": 1}
48
+ {"code": "def get_wizard(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::READ)\n return 403, 'Permission denied'\n end\n wizard = PCSDWizard.getWizard(params[\"wizard\"])\n if wizard != nil\n return erb wizard.collection_page\n else\n return \"Error finding Wizard - #{params[\"wizard\"]}\"\n end\nend", "label_name": "CWE-384", "label": 1}
49
+ {"code": "def fence_device_form(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::READ)\n return 403, 'Permission denied'\n end\n\n @cur_resource = get_resource_by_id(params[:resource], get_cib_dom(session))\n\n if @cur_resource.instance_of?(ClusterEntity::Primitive) and @cur_resource.stonith\n @resource_agents = getFenceAgents(session, @cur_resource.agentname)\n @existing_resource = true\n @fenceagent = @resource_agents[@cur_resource.type]\n erb :fenceagentform\n else\n \"Can't find fence device\"\n end\nend", "label_name": "CWE-384", "label": 1}
50
+ {"code": "def resource_clone(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n\n unless params[:resource_id]\n return [400, 'resource_id has to be specified.']\n end\n \n _, stderr, retval = run_cmd(\n session, PCS, 'resource', 'clone', params[:resource_id]\n )\n if retval != 0\n return [400, 'Unable to create clone resource from ' +\n \"'#{params[:resource_id]}': #{stderr.join('')}\"\n ]\n end\n return 200\nend", "label_name": "CWE-384", "label": 1}
51
+ {"code": "def remote_remove_nodes(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::FULL)\n return 403, 'Permission denied'\n end\n count = 0\n out = \"\"\n node_list = []\n options = []\n while params[\"nodename-\" + count.to_s]\n node_list << params[\"nodename-\" + count.to_s]\n count = count + 1\n end\n options << \"--force\" if params[\"force\"]\n\n cur_node = get_current_node_name()\n if i = node_list.index(cur_node)\n node_list.push(node_list.delete_at(i))\n end\n\n # stop the nodes at once in order to:\n # - prevent resources from moving pointlessly\n # - get possible quorum loss warning\n stop_params = node_list + options\n stdout, stderr, retval = run_cmd(\n session, PCS, \"cluster\", \"stop\", *stop_params\n )\n if retval != 0\n return [400, stderr.join]\n end\n\n node_list.each {|node|\n retval, output = remove_node(session, node, true)\n out = out + output.join(\"\\n\")\n }\n config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text())\n if config.get_nodes($cluster_name) == nil or config.get_nodes($cluster_name).length == 0\n return [200,\"No More Nodes\"]\n end\n return out\nend", "label_name": "CWE-384", "label": 1}
52
+ {"code": "def get_sw_versions(params, request, session)\n versions = {\n \"rhel\" => get_rhel_version(),\n \"pcs\" => get_pcsd_version(),\n \"pacemaker\" => get_pacemaker_version(),\n \"corosync\" => get_corosync_version(),\n \"cman\" => get_cman_version(),\n }\n return JSON.generate(versions)\nend", "label_name": "CWE-384", "label": 1}
53
+ {"code": "def set_node_utilization(params, reqest, session)\n unless allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n\n unless params[:node] and params[:name]\n return 400, 'node and name are required'\n end\n\n node = params[:node]\n name = params[:name]\n value = params[:value] || ''\n\n _, stderr, retval = run_cmd(\n session, PCS, 'node', 'utilization', node, \"#{name}=#{value}\"\n )\n\n if retval != 0\n return [400, \"Unable to set utilization '#{name}=#{value}' for node \" +\n \"'#{res_id}': #{stderr.join('')}\"\n ]\n end\n return 200\nend", "label_name": "CWE-384", "label": 1}
54
+ {"code": "def resource_start(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n stdout, stderr, retval = run_cmd(\n session, PCS, \"resource\", \"enable\", params[:resource]\n )\n if retval == 0\n return JSON.generate({\"success\" => \"true\"})\n else\n return JSON.generate({\"error\" => \"true\", \"stdout\" => stdout, \"stderror\" => stderr})\n end\nend", "label_name": "CWE-384", "label": 1}
55
+ {"code": "def cluster_destroy(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::FULL)\n return 403, 'Permission denied'\n end\n out, errout, retval = run_cmd(session, PCS, \"cluster\", \"destroy\")\n if retval == 0\n return [200, \"Successfully destroyed cluster\"]\n else\n return [400, \"Error destroying cluster:\\n#{out}\\n#{errout}\\n#{retval}\\n\"]\n end\nend", "label_name": "CWE-384", "label": 1}
56
+ {"code": "def remote_pcsd_restart(params, request, session)\n pcsd_restart()\n return [200, 'success']\nend", "label_name": "CWE-384", "label": 1}
57
+ {"code": "export async function formParse(req: any): Promise<FormParseResult> {\n\t// It's not clear how to get mocked requests to be parsed successfully by\n\t// formidable so we use this small hack. If it's mocked, we are running test\n\t// units and the request body is already an object and can be returned.\n\tif (req.__isMocked) {\n\t\tconst output: any = {};\n\t\tif (req.files) output.files = req.files;\n\t\toutput.fields = req.body || {};\n\t\treturn output;\n\t}\n\n\t// Note that for Formidable to work, the content-type must be set in the\n\t// headers\n\treturn new Promise((resolve: Function, reject: Function) => {\n\t\tconst form = formidable({ multiples: true });\n\t\tform.parse(req, (error: any, fields: any, files: any) => {\n\t\t\tif (error) {\n\t\t\t\treject(error);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresolve({ fields, files });\n\t\t});\n\t});\n}", "label_name": "CWE-352", "label": 0}
train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
validation.jsonl ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"code": " public function __construct()\n {\n parent::__construct();\n\n $this->middleware(\n static function ($request, $next) {\n app('view')->share('title', (string)trans('firefly.transactions'));\n app('view')->share('mainTitleIcon', 'fa-exchange');\n\n return $next($request);\n }\n );\n }", "label_name": "CWE-352", "label": 0}
2
+ {"code": " public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/admin/teams/1/duplicate');\n $this->assertIsRedirect($client, '/edit');\n $client->followRedirect();\n $node = $client->getCrawler()->filter('#team_edit_form_name');\n self::assertEquals(1, $node->count());\n self::assertEquals('Test team [COPY]', $node->attr('value'));\n }", "label_name": "CWE-352", "label": 0}
3
+ {"code": "\t\t\t\tesc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),\n\t\t\t\t$r->new_version\n\t\t\t);", "label_name": "CWE-352", "label": 0}
4
+ {"code": " function __construct($uid, $folder = null, $is_safe = false)\n {\n // decode combined UID-folder identifier\n if (preg_match('/^\\d+-.+/', $uid)) {\n list($uid, $folder) = explode('-', $uid, 2);\n }\n\n $this->uid = $uid;\n $this->app = rcube::get_instance();\n $this->storage = $this->app->get_storage();\n $this->folder = strlen($folder) ? $folder : $this->storage->get_folder();\n\n // Set current folder\n $this->storage->set_folder($this->folder);\n $this->storage->set_options(array('all_headers' => true));\n\n $this->headers = $this->storage->get_message($uid);\n\n if (!$this->headers) {\n return;\n }\n\n $this->mime = new rcube_mime($this->headers->charset);\n $this->subject = $this->headers->get('subject');\n list(, $this->sender) = each($this->mime->decode_address_list($this->headers->from, 1));\n\n $this->set_safe($is_safe || $_SESSION['safe_messages'][$this->folder.':'.$uid]);\n $this->opt = array(\n 'safe' => $this->is_safe,\n 'prefer_html' => $this->app->config->get('prefer_html'),\n 'get_url' => $this->app->url(array(\n 'action' => 'get',\n 'mbox' => $this->folder,\n 'uid' => $uid))\n );\n\n if (!empty($this->headers->structure)) {\n $this->get_mime_numbers($this->headers->structure);\n $this->parse_structure($this->headers->structure);\n }\n else {\n $this->body = $this->storage->get_body($uid);\n }\n\n // notify plugins and let them analyze this structured message object\n $this->app->plugins->exec_hook('message_load', array('object' => $this));\n }", "label_name": "CWE-352", "label": 0}
5
+ {"code": " $q = self::$mysqli->query($vars) ;\n if($q === false) {\n user_error(\"Query failed: \".self::$mysqli->error.\"<br />\\n$vars\"); \n return false; \n }\n }\n \n return $q;\n }", "label_name": "CWE-352", "label": 0}
6
+ {"code": "\tpublic function __construct()\n\t{\n\t\t$this->headers = \\App\\Controller\\Headers::getInstance();\n\t\tif (!self::$activatedLocale && \\App\\Config::performance('CHANGE_LOCALE')) {\n\t\t\t\\App\\Language::initLocale();\n\t\t\tself::$activatedLocale = true;\n\t\t}\n\t\tif (!self::$activatedCsrf) {\n\t\t\tif ($this->csrfActive && \\App\\Config::security('csrfActive')) {\n\t\t\t\trequire_once 'config/csrf_config.php';\n\t\t\t\t\\CsrfMagic\\Csrf::init();\n\t\t\t\t$this->csrfActive = true;\n\t\t\t} else {\n\t\t\t\t$this->csrfActive = false;\n\t\t\t}\n\t\t\tself::$activatedCsrf = true;\n\t\t}\n\t}", "label_name": "CWE-352", "label": 0}
7
+ {"code": " public static function insert($vars) {\n if(is_array($vars)) {\n $slug = Typo::slugify($vars['title']);\n $vars = array_merge($vars, array('slug' => $slug));\n //print_r($vars);\n $ins = array(\n 'table' => 'options',\n 'key' => $vars\n );\n $post = Db::insert($ins);\n }\n return $post;\n }", "label_name": "CWE-352", "label": 0}
8
+ {"code": " public function enableCurrency(TransactionCurrency $currency)\n {\n app('preferences')->mark();\n\n $this->repository->enable($currency);\n session()->flash('success', (string)trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));\n Log::channel('audit')->info(sprintf('Enabled currency %s.', $currency->code));\n\n return redirect(route('currencies.index'));\n }", "label_name": "CWE-352", "label": 0}
9
+ {"code": " public function delete(){\n $item_id = I(\"item_id/d\"); \n $login_user = $this->checkLogin();\n $uid = $login_user['uid'] ;\n if(!$this->checkItemManage($uid , $item_id)){\n $this->sendError(10303);\n return ;\n } \n $item_member_id = I(\"item_member_id/d\");\n\n if ($item_member_id) {\n $member_array = D(\"ItemMember\")->where(\" item_id = '%d' and item_member_id = '%d' \",array($item_id,$item_member_id))->find();\n $ret = D(\"ItemMember\")->where(\" item_id = '%d' and item_member_id = '%d' \",array($item_id,$item_member_id))->delete();\n\n }\n if ($ret) {\n $this->sendResult($ret);\n }else{\n $this->sendError(10101);\n }\n }", "label_name": "CWE-352", "label": 0}
10
+ {"code": " public function delete(){\n $item_id = I(\"item_id/d\"); \n $id = I(\"id/d\"); \n $login_user = $this->checkLogin();\n $uid = $login_user['uid'] ;\n if(!$this->checkItemEdit($uid , $item_id)){\n $this->sendError(10303);\n return ;\n } \n $ret = D(\"ItemVariable\")->where(\" item_id = '%d' and id = '%d' \",array($item_id,$id))->delete();\n if ($ret) {\n $this->sendResult($ret);\n }else{\n $this->sendError(10101);\n }\n }", "label_name": "CWE-352", "label": 0}
11
+ {"code": " public function index(Request $request)\n {\n /** @var User $user */\n $user = auth()->user();\n $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');\n $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;\n $collection = $this->repository->getAll();\n $total = $collection->count();\n $collection = $collection->slice(($page - 1) * $pageSize, $pageSize);\n $currencies = new LengthAwarePaginator($collection, $total, $pageSize, $page);\n $currencies->setPath(route('currencies.index'));\n\n $defaultCurrency = $this->repository->getCurrencyByPreference(app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR')));\n $isOwner = true;\n if (!$this->userRepository->hasRole($user, 'owner')) {\n $request->session()->flash('info', (string) trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));\n $isOwner = false;\n }\n\n return prefixView('currencies.index', compact('currencies', 'defaultCurrency', 'isOwner'));\n }", "label_name": "CWE-352", "label": 0}
12
+ {"code": "\tpublic function validateWriteAccess($skipRequestTypeCheck = false)\n\t{\n\t\tif (!$skipRequestTypeCheck && 'POST' !== $_SERVER['REQUEST_METHOD']) {\n\t\t\tthrow new \\App\\Exceptions\\Csrf('Invalid request - validate Write Access');\n\t\t}\n\t\t$this->validateReadAccess();\n\t\tif (class_exists('CSRFConfig') && !\\CsrfMagic\\Csrf::check(false)) {\n\t\t\tthrow new \\App\\Exceptions\\Csrf('Unsupported request');\n\t\t}\n\t}", "label_name": "CWE-352", "label": 0}
13
+ {"code": " $form .= \"<option value='\".$advertiser['clientid'].\"'>\".htmlspecialchars(MAX_buildName($advertiser['clientid'], $advertiser['clientname'])).\"</option>\";\n }\n $form .= \"</select><input type='image' class='submit' src='\" . OX::assetPath() . \"/images/\".$GLOBALS['phpAds_TextDirection'].\"/go_blue.gif'></form>\";\n addPageFormTool($GLOBALS['strMoveTo'], 'iconTrackerMove', $form);\n\n //delete\n $deleteConfirm = phpAds_DelConfirm($GLOBALS['strConfirmDeleteTracker']);\n addPageLinkTool($GLOBALS[\"strDelete\"], MAX::constructUrl(MAX_URL_ADMIN, \"tracker-delete.php?token=\" . urlencode(phpAds_SessionGetToken()) . \"&clientid=\".$advertiserId.\"&trackerid=\".$trackerId.\"&returnurl=advertiser-trackers.php\"), \"iconDelete\", null, $deleteConfirm);\n addPageShortcut($GLOBALS['strBackToTrackers'], MAX::constructUrl(MAX_URL_ADMIN, \"advertiser-trackers.php?clientid=$advertiserId\"), \"iconBack\");\n }", "label_name": "CWE-352", "label": 0}
14
+ {"code": " public function uninstall($templatename)\n {\n if (Permission::model()->hasGlobalPermission('templates', 'update')) {\n if (!Template::hasInheritance($templatename)) {\n TemplateConfiguration::uninstall($templatename);\n } else {\n Yii::app()->setFlashMessage(sprintf(gT(\"You can't uninstall template '%s' because some templates inherit from it.\"), $templatename), 'error');\n }\n } else {\n Yii::app()->setFlashMessage(gT(\"We are sorry but you don't have permissions to do this.\"), 'error');\n }\n\n $this->getController()->redirect(array(\"admin/themeoptions\"));\n }", "label_name": "CWE-352", "label": 0}
15
+ {"code": " public function destroy(Request $request, TransactionCurrency $currency)\n {\n /** @var User $user */\n $user = auth()->user();\n if (!$this->userRepository->hasRole($user, 'owner')) {\n\n $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));\n Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));\n\n return redirect(route('currencies.index'));\n\n }\n\n if ($this->repository->currencyInUse($currency)) {\n $request->session()->flash('error', (string) trans('firefly.cannot_delete_currency', ['name' => e($currency->name)]));\n Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code));\n\n return redirect(route('currencies.index'));\n }\n\n if ($this->repository->isFallbackCurrency($currency)) {\n $request->session()->flash('error', (string) trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));\n Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code));\n\n return redirect(route('currencies.index'));\n }\n\n Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code));\n $this->repository->destroy($currency);\n\n $request->session()->flash('success', (string) trans('firefly.deleted_currency', ['name' => $currency->name]));\n\n return redirect($this->getPreviousUri('currencies.delete.uri'));\n }", "label_name": "CWE-352", "label": 0}
16
+ {"code": "\tfunction check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {\n\t\tif ( -1 == $action ) {\n\t\t\t_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );\n\t\t}\n\n\t\t$adminurl = strtolower( admin_url() );\n\t\t$referer = strtolower( wp_get_referer() );\n\t\t$result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false;\n\n\t\t/**\n\t\t * Fires once the admin request has been validated or not.\n\t\t *\n\t\t * @since 1.5.1\n\t\t *\n\t\t * @param string $action The nonce action.\n\t\t * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between\n\t\t * 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.\n\t\t */\n\t\tdo_action( 'check_admin_referer', $action, $result );\n\n\t\tif ( ! $result && ! ( -1 == $action && strpos( $referer, $adminurl ) === 0 ) ) {\n\t\t\twp_nonce_ays( $action );\n\t\t\tdie();\n\t\t}\n\n\t\treturn $result;\n\t}", "label_name": "CWE-352", "label": 0}
17
+ {"code": " function __construct()\n {\n # code...\n self::$smtphost = Options::get('smtphost');\n self::$smtpuser = Options::get('smtpuser');\n self::$smtppass = Options::get('smtppass');\n self::$smtpssl = Options::get('smtpssl');\n self::$siteemail = Options::get('siteemail');\n self::$sitename = Options::get('sitename');\n }", "label_name": "CWE-352", "label": 0}
18
+ {"code": "\tpublic function show_screen_options() {\n\t\tglobal $wp_meta_boxes;\n\n\t\tif ( is_bool( $this->_show_screen_options ) )\n\t\t\treturn $this->_show_screen_options;\n\n\t\t$columns = get_column_headers( $this );\n\n\t\t$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );\n\n\t\tswitch ( $this->base ) {\n\t\t\tcase 'widgets':\n\t\t\t\t$this->_screen_settings = '<p><a id=\"access-on\" href=\"widgets.php?widgets-access=on\">' . __('Enable accessibility mode') . '</a><a id=\"access-off\" href=\"widgets.php?widgets-access=off\">' . __('Disable accessibility mode') . \"</a></p>\\n\";\n\t\t\t\tbreak;\n\t\t\tcase 'post' :\n\t\t\t\t$expand = '<fieldset class=\"editor-expand hidden\"><legend>' . __( 'Additional settings' ) . '</legend><label for=\"editor-expand-toggle\">';\n\t\t\t\t$expand .= '<input type=\"checkbox\" id=\"editor-expand-toggle\"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';\n\t\t\t\t$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';\n\t\t\t\t$this->_screen_settings = $expand;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t$this->_screen_settings = '';\n\t\t\t\tbreak;\n\t\t}\n\n\t\t/**\n\t\t * Filters the screen settings text displayed in the Screen Options tab.\n\t\t *\n\t\t * This filter is currently only used on the Widgets screen to enable\n\t\t * accessibility mode.\n\t\t *\n\t\t * @since 3.0.0\n\t\t *\n\t\t * @param string $screen_settings Screen settings.\n\t\t * @param WP_Screen $this WP_Screen object.\n\t\t */\n\t\t$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );\n\n\t\tif ( $this->_screen_settings || $this->_options )\n\t\t\t$show_screen = true;\n\n\t\t/**\n\t\t * Filters whether to show the Screen Options tab.\n\t\t *\n\t\t * @since 3.2.0\n\t\t *\n\t\t * @param bool $show_screen Whether to show Screen Options tab.\n\t\t * Default true.\n\t\t * @param WP_Screen $this Current WP_Screen instance.\n\t\t */\n\t\t$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );\n\t\treturn $this->_show_screen_options;\n\t}", "label_name": "CWE-352", "label": 0}
19
+ {"code": " function logon($username, $password, &$sessionId)\n {\n global $_POST, $_COOKIE;\n global $strUsernameOrPasswordWrong;\n\n /**\n * @todo Please check if the following statement is in correct place because\n * it seems illogical that user can get session ID from internal login with\n * a bad username or password.\n */\n\n if (!$this->_verifyUsernameAndPasswordLength($username, $password)) {\n return false;\n }\n\n $_POST['username'] = $username;\n $_POST['password'] = $password;\n\n $_POST['login'] = 'Login';\n\n $_COOKIE['sessionID'] = uniqid('phpads', 1);\n $_POST['phpAds_cookiecheck'] = $_COOKIE['sessionID'];\n\n $this->preInitSession();\n if ($this->_internalLogin($username, $password)) {\n // Check if the user has administrator access to Openads.\n if (OA_Permission::isUserLinkedToAdmin()) {\n\n $this->postInitSession();\n\n $sessionId = $_COOKIE['sessionID'];\n return true;\n } else {\n\n $this->raiseError('User must be OA installation admin');\n return false;\n }\n } else {\n\n $this->raiseError($strUsernameOrPasswordWrong);\n return false;\n }\n }", "label_name": "CWE-384", "label": 1}
20
+ {"code": "\t\t\t\t$text .= varset($val['helpText']) ? \"<div class='field-help'>\".$val['helpText'].\"</div>\" : \"\";\n\t\t\t\t$text .= \"</td>\\n</tr>\\n\";\n\t\t\t}\n\n\n\t\t\t$text .=\"<tr>\n\t\t\t<td>\".EPL_ADLAN_59.\"</td>\n\t\t\t<td>{$del_text}\n\t\t\t<div class='field-help'>\".EPL_ADLAN_60.\"</div>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<div class='buttons-bar center'>\";\n\n\t\t\t$text .= $frm->admin_button('uninstall_confirm',EPL_ADLAN_3,'submit');\n\t\t\t$text .= $frm->admin_button('uninstall_cancel',EPL_ADLAN_62,'cancel');\n\n\t\t\t/*\n\t\t\t$text .= \"<input class='btn' type='submit' name='uninstall_confirm' value=\\\"\".EPL_ADLAN_3.\"\\\" />&nbsp;&nbsp;\n\t\t\t<input class='btn' type='submit' name='uninstall_cancel' value='\".EPL_ADLAN_62.\"' onclick=\\\"location.href='\".e_SELF.\"'; return false;\\\"/>\";\n\t\t\t*/\n // $frm->admin_button($name, $value, $action = 'submit', $label = '', $options = array());\n\n\t\t\t$text .= \"</div>\n\t\t\t</fieldset>\n\t\t\t</form>\n\t\t\t\";\n\n\t\t\treturn $text;\n\t\t\te107::getRender()->tablerender(EPL_ADLAN_63.SEP.$tp->toHtml($plug_vars['@attributes']['name'], \"\", \"defs,emotes_off, no_make_clickable\"),$mes->render(). $text);\n\n\t\t}", "label_name": "CWE-352", "label": 0}
21
+ {"code": " public static function ListProfiles($oUser = null)\n\t{\n\t\tif (is_null($oUser))\n\t\t{\n\t\t\t$oUser = self::$m_oUser;\n\t\t}\n\t\tif ($oUser === null)\n\t\t{\n\t\t\t// Not logged in: no profile at all\n\t\t\t$aProfiles = array();\n\t\t}\n\t\telseif ((self::$m_oUser !== null) && ($oUser->GetKey() == self::$m_oUser->GetKey()))\n\t\t{\n\t\t\t// Data about the current user can be found into the session data\n\t\t\tif (array_key_exists('profile_list', $_SESSION))\n\t\t\t{\n\t\t\t\t$aProfiles = $_SESSION['profile_list'];\n\t\t\t}\n\t\t}\n\n\t\tif (!isset($aProfiles))\n\t\t{\n\t\t\t$aProfiles = self::$m_oAddOn->ListProfiles($oUser);\n\t\t}\n\t\treturn $aProfiles;\n\t}", "label_name": "CWE-352", "label": 0}
22
+ {"code": " public function testDeleteCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'Foo bar blub',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('Foo bar blub', $node->html());\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.confirmation-link');\n\n $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();\n $id = $comments[0]->getId();\n\n self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_delete'), $node->attr('href'));\n $this->request($client, '/admin/project/' . $id . '/comment_delete');\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body');\n self::assertStringContainsString('There were no comments posted yet', $node->html());\n }", "label_name": "CWE-352", "label": 0}
23
+ {"code": " public static function dropdown($vars){\n if(is_array($vars)){\n //print_r($vars);\n $name = $vars['name'];\n $where = \"WHERE \";\n if(isset($vars['type'])) {\n $where .= \" `type` = '{$vars['type']}' AND \";\n }else{\n $where .= \" \";\n }\n $where .= \" `status` = '1' \";\n $order_by = \"ORDER BY \";\n if(isset($vars['order_by'])) {\n $order_by .= \" {$vars['order_by']} \";\n }else{\n $order_by .= \" `name` \";\n }\n if (isset($vars['sort'])) {\n $sort = \" {$vars['sort']}\";\n }else{\n $sort = 'ASC';\n }\n }\n $cat = Db::result(\"SELECT * FROM `posts` {$where} {$order_by} {$sort}\");\n $num = Db::$num_rows;\n $drop = \"<select name=\\\"{$name}\\\" class=\\\"form-control\\\"><option></option>\";\n if($num > 0){\n foreach ($cat as $c) {\n # code...\n // if($c->parent == ''){\n if(isset($vars['selected']) && $c->id == $vars['selected']) $sel = \"SELECTED\"; else $sel = \"\";\n $drop .= \"<option value=\\\"{$c->id}\\\" $sel style=\\\"padding-left: 10px;\\\">{$c->title}</option>\";\n // foreach ($cat as $c2) {\n // # code...\n // if($c2->parent == $c->id){\n // if(isset($vars['selected']) && $c2->id == $vars['selected']) $sel = \"SELECTED\"; else $sel = \"\";\n // $drop .= \"<option value=\\\"{$c2->id}\\\" $sel style=\\\"padding-left: 10px;\\\">&nbsp;&nbsp;&nbsp;{$c2->name}</option>\";\n // }\n // }\n // }\n \n }\n }\n $drop .= \"</select>\";\n\n return $drop;\n }", "label_name": "CWE-352", "label": 0}
24
+ {"code": "function rcmail_zipdownload(mode)\n{\n // default .eml download of single message\n if (mode == 'eml') {\n var uid = rcmail.get_single_uid();\n rcmail.goto_url('viewsource', rcmail.params_from_uid(uid, {_save: 1}));\n return;\n }\n\n // multi-message download, use hidden form to POST selection\n if (rcmail.message_list && rcmail.message_list.get_selection().length > 1) {\n var inputs = [], form = $('#zipdownload-form'),\n post = rcmail.selection_post_data();\n\n post._mode = mode;\n post._token = rcmail.env.request_token;\n\n $.each(post, function(k, v) {\n if (typeof v == 'object' && v.length > 1) {\n for (var j=0; j < v.length; j++)\n inputs.push($('<input>').attr({type: 'hidden', name: k+'[]', value: v[j]}));\n }\n else {\n inputs.push($('<input>').attr({type: 'hidden', name: k, value: v}));\n }\n });\n\n if (!form.length)\n form = $('<form>').attr({\n style: 'display: none',\n method: 'POST',\n action: '?_task=mail&_action=plugin.zipdownload.messages'\n })\n .appendTo('body');\n\n form.html('').append(inputs).submit();\n }\n}", "label_name": "CWE-352", "label": 0}
25
+ {"code": " success: function success(data) {\n if ( data.change ) {\n if ( data.valid ) {\n confirmDialog(\n \"db_submit\",\n \"GeneralChangeModal\",\n 0,\n changeDbSettings\n );\n }\n else {\n $(\"#InvalidDialog\").modal('show');\n }\n } else { \t\n changeDbSettings();\n }\n }", "label_name": "CWE-352", "label": 0}
26
+ {"code": "function setHomePage() {\n $.ajax({\n type: 'POST',\n url: baseurl + '/userSettings/setHomePage',\n data: {\n path: window.location.pathname\n },\n success:function (data, textStatus) {\n showMessage('success', 'Homepage set.');\n $('#setHomePage').addClass('orange');\n },\n });\n}", "label_name": "CWE-352", "label": 0}
27
+ {"code": " $scope.save = function() {\n var form = this.nodeForm;\n RequisitionsService.startTiming();\n RequisitionsService.saveNode($scope.node).then(\n function() { // success\n growl.success('The node ' + $scope.node.nodeLabel + ' has been saved.');\n $scope.foreignId = $scope.node.foreignId;\n form.$dirty = false;\n },\n $scope.errorHandler\n );\n };", "label_name": "CWE-352", "label": 0}
28
+ {"code": " $scope.clone = function(foreignSource) {\n var availableForeignSources = [];\n angular.forEach($scope.requisitionsData.requisitions, function(r) {\n if (r.foreignSource !== foreignSource) {\n availableForeignSources.push(r.foreignSource);\n }\n });\n var modalInstance = $uibModal.open({\n backdrop: 'static',\n keyboard: false,\n controller: 'CloneForeignSourceController',\n templateUrl: cloneForeignsourceView,\n resolve: {\n foreignSource: function() { return foreignSource; },\n availableForeignSources: function() { return availableForeignSources; }\n }\n });\n modalInstance.result.then(function(targetForeignSource) {\n bootbox.confirm('This action will override the existing foreign source definition for the requisition named ' + targetForeignSource + ', using ' + foreignSource + ' as a template. Are you sure you want to continue ? This cannot be undone.', function(ok) {\n if (!ok) {\n return;\n }\n RequisitionsService.startTiming();\n RequisitionsService.cloneForeignSourceDefinition(foreignSource, targetForeignSource).then(\n function() { // success\n growl.success('The foreign source definition for ' + foreignSource + ' has been cloned to ' + targetForeignSource);\n },\n $scope.errorHandler\n );\n });\n });\n };", "label_name": "CWE-352", "label": 0}
29
+ {"code": " $scope.save = function() {\n var form = this.fsForm;\n RequisitionsService.startTiming();\n RequisitionsService.saveForeignSourceDefinition($scope.foreignSourceDef).then(\n function() { // success\n growl.success('The definition for the requisition ' + $scope.foreignSource + ' has been saved.');\n form.$dirty = false;\n },\n $scope.errorHandler\n );\n };", "label_name": "CWE-352", "label": 0}
30
+ {"code": "function AddUserPawn() {\n const Players = [...document.getElementsByClassName('Players')[0].children];\n Players.length -= 1;\n if (Players.length === 2) {\n document.getElementById('C0').style.display = 'block';\n document.getElementById('C1').style.display = 'block';\n document.getElementById('C2').style.display = 'none';\n document.getElementById('C3').style.display = 'none';\n } else if (Players.length === 3) {\n document.getElementById('C0').style.display = 'block';\n document.getElementById('C1').style.display = 'block';\n document.getElementById('C2').style.display = 'block';\n document.getElementById('C3').style.display = 'none';\n } else if (Players.length === 4) {\n document.getElementById('C0').style.display = 'block';\n document.getElementById('C1').style.display = 'block';\n document.getElementById('C2').style.display = 'block';\n document.getElementById('C3').style.display = 'block';\n } else {\n document.getElementById('C0').style.display = 'block';\n document.getElementById('C1').style.display = 'none';\n document.getElementById('C2').style.display = 'none';\n document.getElementById('C3').style.display = 'none';\n }\n}", "label_name": "CWE-384", "label": 1}
31
+ {"code": "\t\t\t\tdata: _.isObject( action ) ? action : _.extend( data || {}, { action: action })\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * wp.ajax.send( [action], [options] )\n\t\t *\n\t\t * Sends a POST request to WordPress.\n\t\t *\n\t\t * @param {string} action The slug of the action to fire in WordPress.\n\t\t * @param {object} options The options passed to jQuery.ajax.\n\t\t * @return {$.promise} A jQuery promise that represents the request,\n\t\t * decorated with an abort() method.\n\t\t */\n\t\tsend: function( action, options ) {\n\t\t\tvar promise, deferred;\n\t\t\tif ( _.isObject( action ) ) {\n\t\t\t\toptions = action;\n\t\t\t} else {\n\t\t\t\toptions = options || {};\n\t\t\t\toptions.data = _.extend( options.data || {}, { action: action });\n\t\t\t}\n\n\t\t\toptions = _.defaults( options || {}, {\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: wp.ajax.settings.url,\n\t\t\t\tcontext: this\n\t\t\t});\n\n\t\t\tdeferred = $.Deferred( function( deferred ) {\n\t\t\t\t// Transfer success/error callbacks.\n\t\t\t\tif ( options.success )\n\t\t\t\t\tdeferred.done( options.success );\n\t\t\t\tif ( options.error )\n\t\t\t\t\tdeferred.fail( options.error );\n\n\t\t\t\tdelete options.success;\n\t\t\t\tdelete options.error;\n\n\t\t\t\t// Use with PHP's wp_send_json_success() and wp_send_json_error()\n\t\t\t\tdeferred.jqXHR = $.ajax( options ).done( function( response ) {\n\t\t\t\t\t// Treat a response of 1 as successful for backward compatibility with existing handlers.\n\t\t\t\t\tif ( response === '1' || response === 1 )\n\t\t\t\t\t\tresponse = { success: true };\n\n\t\t\t\t\tif ( _.isObject( response ) && ! _.isUndefined( response.success ) )\n\t\t\t\t\t\tdeferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] );\n\t\t\t\t\telse\n\t\t\t\t\t\tdeferred.rejectWith( this, [response] );\n\t\t\t\t}).fail( function() {\n\t\t\t\t\tdeferred.rejectWith( this, arguments );\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tpromise = deferred.promise();\n\t\t\tpromise.abort = function() {\n\t\t\t\tdeferred.jqXHR.abort();\n\t\t\t\treturn this;\n\t\t\t};\n\n\t\t\treturn promise;\n\t\t}\n\t};\n\n}(jQuery));", "label_name": "CWE-352", "label": 0}
32
+ {"code": "function deleteBudgetLimit(e) {\n var button = $(e.currentTarget);\n var budgetLimitId = button.data('budget-limit-id');\n var url = deleteBudgetLimitUrl.replace('REPLACEME', budgetId.toString();\n return false;\n}\n\nfunction createAltAvailableBudget(e) {\n $('#defaultModal').empty().load(createAltAvailableBudgetUri, function () {\n $('#defaultModal').modal('show');\n });\n return false;\n}\n\nfunction updateAvailableBudget(e) {\n var button = $(e.currentTarget);\n var abId = parseInt(button.data('id'));\n if (0 === abId) {\n $('#defaultModal').empty().load(createAvailableBudgetUri, function () {\n $('#defaultModal').modal('show');\n });\n }\n if (abId > 0) {\n // edit URL.\n $('#defaultModal').empty().load(editAvailableBudgetUri.replace('REPLACEME', abId), function () {\n $('#defaultModal').modal('show');\n });\n }\n return false;\n}\n\n\nfunction drawBudgetedBars() {\n \"use strict\";\n $.each($('.budgeted_bar'), function (i, v) {\n var bar = $(v);\n var budgeted = parseFloat(bar.data('budgeted'));\n var available = parseFloat(bar.data('available'));\n var budgetedTooMuch = budgeted > available;\n var pct;\n if (budgetedTooMuch) {\n // budgeted too much.\n pct = (available / budgeted) * 100;\n bar.find('.progress-bar-danger').css('width', pct + '%');\n bar.find('.progress-bar-warning').css('width', (100 - pct) + '%');\n bar.find('.progress-bar-info').css('width', 0);\n } else {\n pct = (budgeted / available) * 100;\n bar.find('.progress-bar-danger').css('width', 0);\n bar.find('.progress-bar-warning').css('width', 0);\n bar.find('.progress-bar-info').css('width', pct + '%');\n }\n //$('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2));\n });\n}\n\nfunction drawSpentBars() {", "label_name": "CWE-352", "label": 0}
33
+ {"code": "\t\tregisterDenyFilterClickEvent: function () {\n\t\t\tconst thisInstance = this;\n\t\t\tconst listViewFilterBlock = this.getFilterBlock();\n\t\t\tif (listViewFilterBlock != false) {\n\t\t\t\tlistViewFilterBlock.on('mouseup', '.js-filter-deny', (event) => {\n\t\t\t\t\t//to close the dropdown\n\t\t\t\t\tthisInstance.getFilterSelectElement().data('select2').close();\n\t\t\t\t\tconst liElement = $(event.currentTarget).closest('.select2-results__option');\n\t\t\t\t\tapp.openUrlMethodPost(thisInstance.getSelectOptionFromChosenOption(liElement).data('denyurl'));\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t});\n\t\t\t}\n\t\t},", "label_name": "CWE-352", "label": 0}
34
+ {"code": " url: get_cluster_remote_url() + 'cluster_stop',\n data: data,\n timeout: pcs_timeout,\n success: function() {\n },\n error: function(xhr, status, error) {\n if ((status == \"timeout\") || ($.trim(error) == \"timeout\")) {\n /*\n We are not interested in timeout because:\n - it can take minutes to stop a node (resources running on it have\n to be stopped/moved and we do not need to wait for that)\n - if pcs is not able to stop a node it returns an (forceable) error\n immediatelly\n */\n return;\n }\n var message = \"Unable to stop node '\" + node + \" \" + ajax_simple_error(\n xhr, status, error\n );\n if (message.indexOf('--force') == -1) {\n alert(message);\n }\n else {\n message = message.replace(', use --force to override', '');\n if (confirm(message + \"\\n\\nDo you want to force the operation?\")) {\n node_stop(node, true);\n }\n }\n }\n });\n}", "label_name": "CWE-384", "label": 1}
35
+ {"code": "static void doPost(HttpRequest req, HttpResponse res) {\n set_content_type(res, \"text/html\");\n if (ACTION(RUN))\n handle_run(req, res);\n else if (ACTION(STATUS))\n print_status(req, res, 1);\n else if (ACTION(STATUS2))\n print_status(req, res, 2);\n else if (ACTION(SUMMARY))\n print_summary(req, res);\n else if (ACTION(REPORT))\n _printReport(req, res);\n else if (ACTION(DOACTION))\n handle_do_action(req, res);\n else\n handle_action(req, res);\n}", "label_name": "CWE-352", "label": 0}
36
+ {"code": "static void handle_do_action(HttpRequest req, HttpResponse res) {\n Service_T s;\n Action_Type doaction = Action_Ignored;\n const char *action = get_parameter(req, \"action\");\n const char *token = get_parameter(req, \"token\");\n\n if (action) {\n if (is_readonly(req)) {\n send_error(req, res, SC_FORBIDDEN, \"You do not have sufficient privileges to access this page\");\n return;\n }\n if ((doaction = Util_getAction(action)) == Action_Ignored) {\n send_error(req, res, SC_BAD_REQUEST, \"Invalid action \\\"%s\\\"\", action);\n return;\n }\n for (HttpParameter p = req->params; p; p = p->next) {\n if (IS(p->name, \"service\")) {\n s = Util_getService(p->value);\n if (! s) {\n send_error(req, res, SC_BAD_REQUEST, \"There is no service named \\\"%s\\\"\", p->value ? p->value : \"\");\n return;\n }\n s->doaction = doaction;\n LogInfo(\"'%s' %s on user request\\n\", s->name, action);\n }\n }\n /* Set token for last service only so we'll get it back after all services were handled */\n if (token) {\n Service_T q = NULL;\n for (s = servicelist; s; s = s->next)\n if (s->doaction == doaction)\n q = s;\n if (q) {\n FREE(q->token);\n q->token = Str_dup(token);\n }\n }\n Run.flags |= Run_ActionPending;\n do_wakeupcall();\n }\n}", "label_name": "CWE-352", "label": 0}
37
+ {"code": "def list_instructor_tasks(request, course_id):\n \"\"\"\n List instructor tasks.\n\n Takes optional query paremeters.\n - With no arguments, lists running tasks.\n - `problem_location_str` lists task history for problem\n - `problem_location_str` and `unique_student_identifier` lists task\n history for problem AND student (intersection)\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n problem_location_str = strip_if_string(request.GET.get('problem_location_str', False))\n student = request.GET.get('unique_student_identifier', None)\n if student is not None:\n student = get_student_from_identifier(student)\n\n if student and not problem_location_str:\n return HttpResponseBadRequest(\n \"unique_student_identifier must accompany problem_location_str\"\n )\n\n if problem_location_str:\n try:\n module_state_key = course_id.make_usage_key_from_deprecated_string(problem_location_str)\n except InvalidKeyError:\n return HttpResponseBadRequest()\n if student:\n # Specifying for a single student's history on this problem\n tasks = instructor_task.api.get_instructor_task_history(course_id, module_state_key, student)\n else:\n # Specifying for single problem's history\n tasks = instructor_task.api.get_instructor_task_history(course_id, module_state_key)\n else:\n # If no problem or student, just get currently running tasks\n tasks = instructor_task.api.get_running_instructor_tasks(course_id)\n\n response_payload = {\n 'tasks': map(extract_task_features, tasks),\n }\n return JsonResponse(response_payload)", "label_name": "CWE-352", "label": 0}
38
+ {"code": " def test_enrollment_report_features_csv(self):\n \"\"\"\n test to generate enrollment report.\n enroll users, admin staff using registration codes.\n \"\"\"\n InvoiceTransaction.objects.create(\n invoice=self.sale_invoice_1,\n amount=self.sale_invoice_1.total_amount,\n status='completed',\n created_by=self.instructor,\n last_modified_by=self.instructor\n )\n course_registration_code = CourseRegistrationCode.objects.create(\n code='abcde',\n course_id=self.course.id.to_deprecated_string(),\n created_by=self.instructor,\n invoice=self.sale_invoice_1,\n invoice_item=self.invoice_item,\n mode_slug='honor'\n )\n\n admin_user = AdminFactory()\n admin_cart = Order.get_cart_for_user(admin_user)\n PaidCourseRegistration.add_to_order(admin_cart, self.course.id)\n admin_cart.purchase()\n\n # create a new user/student and enroll\n # in the course using a registration code\n # and then validates the generated detailed enrollment report\n test_user = UserFactory()\n self.register_with_redemption_code(test_user, course_registration_code.code)\n\n CourseFinanceAdminRole(self.course.id).add_users(self.instructor)\n UserProfileFactory.create(user=self.students[0], meta='{\"company\": \"asdasda\"}')\n\n self.client.login(username=self.instructor.username, password='test')\n url = reverse('get_enrollment_report', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {})\n self.assertIn('The detailed enrollment report is being created.', response.content)", "label_name": "CWE-352", "label": 0}
39
+ {"code": " def test_reset_student_attempts_deletall(self):\n \"\"\" Make sure no one can delete all students state on a problem. \"\"\"\n url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {\n 'problem_to_reset': self.problem_urlname,\n 'all_students': True,\n 'delete_module': True,\n })\n self.assertEqual(response.status_code, 400)", "label_name": "CWE-352", "label": 0}
40
+ {"code": " def test_modify_access_bad_action(self):\n \"\"\" Test with an invalid action parameter. \"\"\"\n url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {\n 'unique_student_identifier': self.other_staff.email,\n 'rolename': 'staff',\n 'action': 'robot-not-an-action',\n })\n self.assertEqual(response.status_code, 400)", "label_name": "CWE-352", "label": 0}
41
+ {"code": " def test_list_instructor_tasks_problem_student(self, act):\n \"\"\" Test list task history for problem AND student. \"\"\"\n act.return_value = self.tasks\n url = reverse('list_instructor_tasks', kwargs={'course_id': self.course.id.to_deprecated_string()})\n mock_factory = MockCompletionInfo()\n with patch('instructor.views.instructor_task_helpers.get_task_completion_info') as mock_completion_info:\n mock_completion_info.side_effect = mock_factory.mock_get_task_completion_info\n response = self.client.get(url, {\n 'problem_location_str': self.problem_urlname,\n 'unique_student_identifier': self.student.email,\n })\n self.assertEqual(response.status_code, 200)\n\n # check response\n self.assertTrue(act.called)\n expected_tasks = [ftask.to_dict() for ftask in self.tasks]\n actual_tasks = json.loads(response.content)['tasks']\n for exp_task, act_task in zip(expected_tasks, actual_tasks):\n self.assertDictEqual(exp_task, act_task)\n\n self.assertEqual(actual_tasks, expected_tasks)", "label_name": "CWE-352", "label": 0}
42
+ {"code": "def handler(request):\n \"\"\"Scheme handler for qute:// URLs.\n\n Args:\n request: QNetworkRequest to answer to.\n\n Return:\n A QNetworkReply.\n \"\"\"\n try:\n mimetype, data = qutescheme.data_for_url(request.url())\n except qutescheme.NoHandlerFound:\n errorstr = \"No handler found for {}!\".format(\n request.url().toDisplayString())\n return networkreply.ErrorNetworkReply(\n request, errorstr, QNetworkReply.ContentNotFoundError)\n except qutescheme.QuteSchemeOSError as e:\n return networkreply.ErrorNetworkReply(\n request, str(e), QNetworkReply.ContentNotFoundError)\n except qutescheme.QuteSchemeError as e:\n return networkreply.ErrorNetworkReply(request, e.errorstring, e.error)\n except qutescheme.Redirect as e:\n qtutils.ensure_valid(e.url)\n return networkreply.RedirectNetworkReply(e.url)\n\n return networkreply.FixedDataNetworkReply(request, data, mimetype)", "label_name": "CWE-352", "label": 0}
43
+ {"code": " def register_with_redemption_code(self, user, code):\n \"\"\"\n enroll user using a registration code\n \"\"\"\n redeem_url = reverse('register_code_redemption', args=[code])\n self.client.login(username=user.username, password='test')\n response = self.client.get(redeem_url)\n self.assertEquals(response.status_code, 200)\n # check button text\n self.assertTrue('Activate Course Enrollment' in response.content)\n\n response = self.client.post(redeem_url)\n self.assertEquals(response.status_code, 200)", "label_name": "CWE-352", "label": 0}
44
+ {"code": " public RedirectView callback(@RequestParam(defaultValue = \"/\") String redirect,\n @PathVariable String serverId,\n @RequestParam String code,\n @RequestParam String state,\n HttpServletRequest request,\n HttpSession session) throws UnsupportedEncodingException {\n try {\n String cachedState = (String) session.getAttribute(STATE_SESSION_KEY);\n // if (!state.equals(cachedState)) throw new BusinessException(\"state error\");\n oAuth2RequestService.doEvent(serverId, new OAuth2CodeAuthBeforeEvent(code, state, request::getParameter));\n return new RedirectView(URLDecoder.decode(redirect, \"UTF-8\"));\n } finally {\n session.removeAttribute(STATE_SESSION_KEY);\n }\n }", "label_name": "CWE-352", "label": 0}
45
+ {"code": " public void corsNoTags() {\n InputStream is = getClass().getResourceAsStream(\"/access-sample1.xml\");\n PolicyRestrictor restrictor = new PolicyRestrictor(is);\n\n assertTrue(restrictor.isCorsAccessAllowed(\"http://bla.com\"));\n assertTrue(restrictor.isCorsAccessAllowed(\"http://www.jolokia.org\"));\n assertTrue(restrictor.isCorsAccessAllowed(\"https://www.consol.de\"));\n }", "label_name": "CWE-352", "label": 0}
46
+ {"code": "def cluster_stop(params, request, session)\n if params[:name]\n params_without_name = params.reject {|key, value|\n key == \"name\" or key == :name\n }\n code, response = send_request_with_token(\n session, params[:name], 'cluster_stop', true, params_without_name\n )\n else\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n options = []\n if params.has_key?(\"component\")\n if params[\"component\"].downcase == \"pacemaker\"\n options << \"--pacemaker\"\n elsif params[\"component\"].downcase == \"corosync\"\n options << \"--corosync\"\n end\n end\n options << \"--force\" if params[\"force\"]\n $logger.info \"Stopping Daemons\"\n stdout, stderr, retval = run_cmd(session, PCS, \"cluster\", \"stop\", *options)\n if retval != 0\n return [400, stderr.join]\n else\n return stdout.join\n end\n end\nend", "label_name": "CWE-384", "label": 1}
47
+ {"code": "def add_meta_attr_remote(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n retval = add_meta_attr(\n session, params[\"res_id\"], params[\"key\"],params[\"value\"]\n )\n if retval == 0\n return [200, \"Successfully added meta attribute\"]\n else\n return [400, \"Error adding meta attribute\"]\n end\nend", "label_name": "CWE-384", "label": 1}
48
+ {"code": " def self.load_current_node(session, crm_dom=nil)\n node = ClusterEntity::Node.new\n node.corosync = corosync_running?\n node.corosync_enabled = corosync_enabled?\n node.pacemaker = pacemaker_running?\n node.pacemaker_enabled = pacemaker_enabled?\n node.cman = cman_running?\n node.pcsd_enabled = pcsd_enabled?\n\n node_online = (node.corosync and node.pacemaker)\n node.status = node_online ? 'online' : 'offline'\n\n node.uptime = get_node_uptime\n node.id = get_local_node_id\n\n if node_online and crm_dom\n node_el = crm_dom.elements[\"//node[@id='#{node.id}']\"]\n if node_el and node_el.attributes['standby'] == 'true'\n node.status = 'standby'\n else\n node.status = 'online'\n end\n node.quorum = !!crm_dom.elements['//current_dc[@with_quorum=\"true\"]']\n else\n node.status = 'offline'\n end\n\n return node\n end", "label_name": "CWE-384", "label": 1}
49
+ {"code": "def resource_form(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::READ)\n return 403, 'Permission denied'\n end\n\n cib_dom = get_cib_dom(session)\n @cur_resource = get_resource_by_id(params[:resource], cib_dom)\n @groups = get_resource_groups(cib_dom)\n @version = params[:version]\n\n if @cur_resource.instance_of?(ClusterEntity::Primitive) and !@cur_resource.stonith\n @cur_resource_group = @cur_resource.get_group\n @cur_resource_clone = @cur_resource.get_clone\n @cur_resource_ms = @cur_resource.get_master\n @resource = ResourceAgent.new(@cur_resource.agentname)\n if @cur_resource.provider == 'heartbeat'\n @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, HEARTBEAT_AGENTS_DIR + @cur_resource.type)\n elsif @cur_resource.provider == 'pacemaker'\n @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, PACEMAKER_AGENTS_DIR + @cur_resource.type)\n elsif @cur_resource._class == 'nagios'\n @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, NAGIOS_METADATA_DIR + @cur_resource.type + '.xml')\n end\n @existing_resource = true\n if @resource\n erb :resourceagentform\n else\n \"Can't find resource\"\n end\n else\n \"Resource #{params[:resource]} doesn't exist\"\n end\nend", "label_name": "CWE-384", "label": 1}
50
+ {"code": "def allowed_for_local_cluster(session, action)\n pcs_config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text())\n return pcs_config.permissions_local.allows?(\n session[:username], session[:usergroups], action\n )\nend", "label_name": "CWE-384", "label": 1}
51
+ {"code": " def self.getSuperuserSession()\n return {\n :username => SUPERUSER,\n :usergroups => [],\n }\n end", "label_name": "CWE-384", "label": 1}
52
+ {"code": "def get_node_status(session, cib_dom)\n node_status = {\n :cluster_name => $cluster_name,\n :groups => [],\n :constraints => {\n # :rsc_location => [],\n # :rcs_colocation => [],\n # :rcs_order => []\n },\n :cluster_settings => {},\n :need_ring1_address => need_ring1_address?,\n :is_cman_with_udpu_transport => is_cman_with_udpu_transport?,\n :acls => get_acls(session, cib_dom),\n :username => session[:username],\n :fence_levels => get_fence_levels(session, cib_dom),\n :node_attr => node_attrs_to_v2(get_node_attributes(session, cib_dom)),\n :nodes_utilization => get_nodes_utilization(cib_dom),\n :known_nodes => []\n }\n\n nodes = get_nodes_status()\n\n known_nodes = []\n nodes.each { |_, node_list|\n known_nodes.concat node_list\n }\n node_status[:known_nodes] = known_nodes.uniq\n\n nodes.each do |k,v|\n node_status[k.to_sym] = v\n end\n\n if cib_dom\n node_status[:groups] = get_resource_groups(cib_dom)\n node_status[:constraints] = getAllConstraints(cib_dom.elements['/cib/configuration/constraints'])\n end\n\n node_status[:cluster_settings] = getAllSettings(session, cib_dom)\n\n return node_status\nend", "label_name": "CWE-384", "label": 1}
53
+ {"code": "def disable_cluster(session)\n stdout, stderror, retval = run_cmd(session, PCS, \"cluster\", \"disable\")\n return false if retval != 0\n return true\nend", "label_name": "CWE-384", "label": 1}
54
+ {"code": "def get_fence_levels(session, cib_dom=nil)\n unless cib_dom\n cib_dom = get_cib_dom(session)\n return {} unless cib_dom\n end\n\n fence_levels = {}\n cib_dom.elements.each(\n '/cib/configuration/fencing-topology/fencing-level'\n ) { |e|\n target = e.attributes['target']\n fence_levels[target] ||= []\n fence_levels[target] << {\n 'level' => e.attributes['index'],\n 'devices' => e.attributes['devices']\n }\n }\n\n fence_levels.each { |_, val| val.sort_by! { |obj| obj['level'].to_i }}\n return fence_levels\nend", "label_name": "CWE-384", "label": 1}
55
+ {"code": "def send_local_configs_to_nodes(\n session, nodes, force=false, clear_local_permissions=false\n)\n configs = Cfgsync::get_configs_local(true)\n if clear_local_permissions\n pcs_config = PCSConfig.new(configs[Cfgsync::PcsdSettings.name].text())\n pcs_config.permissions_local = Permissions::PermissionsSet.new([])\n configs[Cfgsync::PcsdSettings.name].text = pcs_config.text()\n end\n publisher = Cfgsync::ConfigPublisher.new(\n session, configs.values(), nodes, $cluster_name\n )\n return publisher.send(force)\nend", "label_name": "CWE-384", "label": 1}
56
+ {"code": "def check_auth(params, request, session)\n if params.include?(\"check_auth_only\")\n return [200, \"{\\\"success\\\":true}\"]\n end\n return JSON.generate({\n 'success' => true,\n 'node_list' => get_token_node_list,\n })\nend", "label_name": "CWE-384", "label": 1}