cwe-compound-group / validation.jsonl
mcanoglu's picture
Upload 3 files
5e5d5e0 verified
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"code": " def self.getSuperuserSession()\n return {\n :username => SUPERUSER,\n :usergroups => [],\n }\n end", "label_name": "CWE-384", "label": 1}
{"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}
{"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}
{"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}
{"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}
{"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}