{"code": "\tprotected function _archive($dir, $files, $name, $arc) {\n\t\tdie('Not yet implemented. (_archive)');\n\t\treturn false;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "vulnerable"} {"code": " $GLOBALS['PMA_Config']->removeCookie('pmaPass-' . $key);\n if (isset($_COOKIE['pmaPass-' . $key])) {\n unset($_COOKIE['pmaPass-' . $key]);\n }\n }\n } else {\n $GLOBALS['PMA_Config']->removeCookie(\n 'pmaPass-' . $GLOBALS['server']\n );\n if (isset($_COOKIE['pmaPass-' . $GLOBALS['server']])) {\n unset($_COOKIE['pmaPass-' . $GLOBALS['server']]);\n }\n }\n parent::logOut();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "function html_split_string($string, $length = 70, $forgiveness = 10) {\n\t$new_string = '';\n\t$j = 0;\n\t$done = false;\n\n\twhile (!$done) {\n\t\tif (strlen($string) > $length) {\n\t\t\tfor($i = 0; $i < $forgiveness; $i++) {\n\t\t\t\tif (substr($string, $length-$i, 1) == ' ') {\n\t\t\t\t\t$new_string .= substr($string, 0, $length-$i) . '
';\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$string = substr($string, $length-$i);\n\t\t} else {\n\t\t\t$new_string .= $string;\n\t\t\t$done = true;\n\t\t}\n\n\t\t$j++;\n\t\tif ($j > 4) break;\n\t}\n\n\treturn $new_string;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function getHeader()\n {\n $html = '\n '.$this->getTitle().'\n ';\n\n $html .= 'getStaticUrl('css/bootstrap.css').'\" rel=\"stylesheet\">\n getStaticUrl('css/font-awesome.css').'\" rel=\"stylesheet\">\n getStaticUrl('css/global.css').'\" rel=\"stylesheet\">\n getStaticUrl('css/ui-lightness/jquery-ui.css').'\" rel=\"stylesheet\">\n getStaticUrl('../application/modules/user/static/css/user.css').'\" rel=\"stylesheet\">\n \n \n \n \n ';\n return $html;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $task = $this->getTask();\n $comment = $this->getComment();\n\n $this->response->html($this->template->render('comment/remove', array(\n 'comment' => $comment,\n 'task' => $task,\n 'title' => t('Remove a comment')\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tstatic function convertXMLFeedSafeChar($str) {\n\t\t$str = str_replace(\"
\",\"\",$str);\n $str = str_replace(\"
\",\"\",$str);\n $str = str_replace(\"
\",\"\",$str);\n $str = str_replace(\"
\",\"\",$str);\n $str = str_replace(\""\",'\"',$str);\n $str = str_replace(\"'\",\"'\",$str);\n $str = str_replace(\"’\",\"'\",$str);\n $str = str_replace(\"‘\",\"'\",$str);\n $str = str_replace(\"®\",\"\",$str);\n $str = str_replace(\"\ufffd\",\"-\", $str);\n $str = str_replace(\"\ufffd\",\"-\", $str);\n $str = str_replace(\"\ufffd\", '\"', $str);\n $str = str_replace(\"”\",'\"', $str);\n $str = str_replace(\"\ufffd\", '\"', $str);\n $str = str_replace(\"“\",'\"', $str);\n $str = str_replace(\"\\r\\n\",\" \",$str);\n $str = str_replace(\"\ufffd\",\" 1/4\",$str);\n $str = str_replace(\"¼\",\" 1/4\", $str);\n $str = str_replace(\"\ufffd\",\" 1/2\",$str);\n $str = str_replace(\"½\",\" 1/2\",$str);\n $str = str_replace(\"\ufffd\",\" 3/4\",$str);\n $str = str_replace(\"¾\",\" 3/4\",$str);\n $str = str_replace(\"\ufffd\", \"(TM)\", $str);\n $str = str_replace(\"™\",\"(TM)\", $str);\n $str = str_replace(\"®\",\"(R)\", $str);\n $str = str_replace(\"\ufffd\",\"(R)\",$str);\n $str = str_replace(\"&\",\"&\",$str);\n\t\t$str = str_replace(\">\",\">\",$str);\n return trim($str);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction delete_vendor() {\n\t\tglobal $db;\n\t\t\n if (!empty($this->params['id'])){\n\t\t\t$db->delete('vendor', 'id =' .$this->params['id']);\n\t\t}\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function save()\r\n\t{\r\n\t\tglobal $DB;\r\n\r\n\t\tif(!empty($this->id))\r\n\t\t\treturn $this->update();\r\n\t\telse\r\n\t\t\treturn $this->insert();\t\t\t\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function send_feedback() {\r\n $success = false;\r\n if (isset($this->params['id'])) {\r\n $ed = new eventdate($this->params['id']);\r\n// $email_addrs = array();\r\n if ($ed->event->feedback_email != '') {\r\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);\r\n $msgtemplate->assign('params', $this->params);\r\n $msgtemplate->assign('event', $ed);\r\n $email_addrs = explode(',', $ed->event->feedback_email);\r\n //This is an easy way to remove duplicates\r\n $email_addrs = array_flip(array_flip($email_addrs));\r\n $email_addrs = array_map('trim', $email_addrs);\r\n $mail = new expMail();\r\n $success += $mail->quickSend(array(\r\n \"text_message\" => $msgtemplate->render(),\r\n 'to' => $email_addrs,\r\n 'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),\r\n 'subject' => $this->params['subject'],\r\n ));\r\n }\r\n }\r\n\r\n if ($success) {\r\n flashAndFlow('message', gt('Your feedback was successfully sent.'));\r\n } else {\r\n flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function form_selectable_ecell($contents, $id, $width = '', $style_or_class = '', $title = '') {\n\tform_selectable_cell(html_escape($contents), $id, $width, $style_or_class, $title);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function showall_tags() {\n $images = $this->image->find('all');\n $used_tags = array();\n foreach ($images as $image) {\n foreach($image->expTag as $tag) {\n if (isset($used_tags[$tag->id])) {\n $used_tags[$tag->id]->count++;\n } else {\n $exptag = new expTag($tag->id);\n $used_tags[$tag->id] = $exptag;\n $used_tags[$tag->id]->count = 1;\n }\n \n }\n }\n \n assign_to_template(array(\n 'tags'=>$used_tags\n ));\n } ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tpublic function save()\r\n\t{\r\n\t\tglobal $DB;\r\n\r\n\t\tif(!empty($this->id))\r\n\t\t return $this->update();\r\n\t\telse\r\n\t\t return $this->insert();\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function selectObjectBySql($sql) {\n //$logFile = \"C:\\\\xampp\\\\htdocs\\\\supserg\\\\tmp\\\\queryLog.txt\";\n //$lfh = fopen($logFile, 'a');\n //fwrite($lfh, $sql . \"\\n\"); \n //fclose($lfh); \n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return null;\n return mysqli_fetch_object($res);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function searchNew() {\n global $db, $user;\n //$this->params['query'] = str_ireplace('-','\\-',$this->params['query']);\n $sql = \"select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid, \";\n $sql .= \"match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"*' IN BOOLEAN MODE) as relevance, \";\n $sql .= \"CASE when p.model like '\" . $this->params['query'] . \"%' then 1 else 0 END as modelmatch, \";\n $sql .= \"CASE when p.title like '%\" . $this->params['query'] . \"%' then 1 else 0 END as titlematch \";\n $sql .= \"from \" . $db->prefix . \"product as p INNER JOIN \" .\n $db->prefix . \"content_expFiles as cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' INNER JOIN \" . $db->prefix .\n \"expFiles as f ON cef.expFiles_id = f.id WHERE \";\n if (!$user->isAdmin()) $sql .= '(p.active_type=0 OR p.active_type=1) AND ';\n $sql .= \" match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"*' IN BOOLEAN MODE) AND p.parent_id=0 \";\n $sql .= \" HAVING relevance > 0 \";\n //$sql .= \"GROUP BY p.id \";\n $sql .= \"order by modelmatch,titlematch,relevance desc LIMIT 10\";\n\n eDebug($sql);\n $res = $db->selectObjectsBySql($sql);\n eDebug($res, true);\n $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testValidUrlBBCode()\n {\n $parser = new JBBCode\\Parser();\n $parser->addCodeDefinitionSet(new JBBCode\\DefaultCodeDefinitionSet());\n $parser->parse('[url]http://jbbcode.com[/url]');\n $this->assertEquals('http://jbbcode.com',\n $parser->getAsHtml());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function getSubtask()\n {\n $subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));\n\n if (empty($subtask)) {\n throw new PageNotFoundException();\n }\n\n return $subtask;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " foreach ($day as $extevent) {\n $event_cache = new stdClass();\n $event_cache->feed = $extgcalurl;\n $event_cache->event_id = $extevent->event_id;\n $event_cache->title = $extevent->title;\n $event_cache->body = $extevent->body;\n $event_cache->eventdate = $extevent->eventdate->date;\n if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)\n $event_cache->dateFinished = $extevent->dateFinished;\n if (isset($extevent->eventstart))\n $event_cache->eventstart = $extevent->eventstart;\n if (isset($extevent->eventend))\n $event_cache->eventend = $extevent->eventend;\n if (isset($extevent->is_allday))\n $event_cache->is_allday = $extevent->is_allday;\n $found = false;\n if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries\n $found = $db->selectObject('event_cache','feed=\"'.$extgcalurl.'\" AND event_id=\"'.$event_cache->event_id.'\" AND eventdate='.$event_cache->eventdate);\n if (!$found)\n $db->insertObject($event_cache,'event_cache');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " private function setSize($size)\n {\n if (false === is_int($size)) {\n throw new InvalidArgumentException(\n 'Upload file size must be an integer'\n );\n }\n\n $this->size = $size;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function getPurchaseOrderByJSON() {\n\t\t\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\t\t\n\t\techo json_encode($purchase_orders);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function getModelTypes($assoc = false) {\n $modelTypes = Yii::app()->db->createCommand()\n ->selectDistinct('modelName')\n ->from('x2_fields')\n ->where('modelName!=\"Calendar\"')\n ->order('modelName ASC')\n ->queryColumn();\n\n if ($assoc === true) {\n return array_combine($modelTypes, array_map(function($term) {\n return Yii::t('app', X2Model::getModelTitle($term));\n }, $modelTypes));\n }\n $modelTypes = array_map(function($term) {\n return Yii::t('app', $term);\n }, $modelTypes);\n return $modelTypes;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function manage_sitemap() {\r\n global $db, $user, $sectionObj, $sections;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // all we need to do is determine the current section\r\n $navsections = $sections;\r\n if ($sectionObj->parent == -1) {\r\n $current = $sectionObj;\r\n } else {\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function json() {\n $token = Options::get('tokens');\n $token = json_decode($token, true);\n $newtoken = array(\n TOKEN => array(\n 'time' => TOKEN_TIME,\n 'ip' => TOKEN_IP,\n 'url' => TOKEN_URL\n )\n );\n if(is_array($token)){\n $newtoken = array_merge($token, $newtoken);\n }\n\n $newtoken = json_encode($newtoken);\n return $newtoken;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function setReplacementText($txt)\n {\n $this->replacementText = $txt;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tstatic public function getStatusText($_lng, $_status = 0)\n\t{\n\t\tswitch ($_status) {\n\t\t\tcase 0:\n\t\t\t\treturn $_lng['ticket']['open'];\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\treturn $_lng['ticket']['wait_reply'];\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\treturn $_lng['ticket']['replied'];\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn $_lng['ticket']['closed'];\n\t\t\t\tbreak;\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": " public static function insert ($vars) {\n if(is_array($vars)){\n $set = \"\";\n $k = \"\";\n foreach ($vars['key'] as $key => $val) {\n $set .= \"'$val',\";\n $k .= \"`$key`,\";\n }\n \n $set = substr($set, 0,-1);\n $k = substr($k, 0,-1);\n \n $sql = sprintf(\"INSERT INTO `%s` (%s) VALUES (%s) \", $vars['table'], $k, $set) ;\n }else{\n $sql = $vars;\n }\n if(DB_DRIVER == 'mysql') {\n mysql_query('SET CHARACTER SET utf8');\n $q = mysql_query($sql) or die(mysql_error());\n self::$last_id = mysql_insert_id();\n }elseif(DB_DRIVER == 'mysqli'){\n try {\n if(!self::query($sql)){\n printf(\"
Errormessage: %s
\\n\", self::$mysqli->error);\n }else{\n self::$last_id = self::$mysqli->insert_id;\n }\n \n } catch (exception $e) {\n echo $e->getMessage();\n }\n \n }\n \n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " set_error_handler(array($this, 'muteErrorHandler'));\n $info = getimagesize($file);\n restore_error_handler();\n unlink($file);\n if ($info == false) return false;\n $image_code = $info[2];\n } else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function modMenu()\n {\n $json = Options::v('modules');\n $mod = json_decode($json, true);\n //$mod = self::modList();\n //print_r($mod);\n if (is_array($mod)) {\n $list = '';\n asort($mod);\n foreach ($mod as $m) {\n # code...\n if (self::exist($m)) {\n $data = self::data($m);\n if (isset($_GET['mod']) && $_GET['mod'] == $m) {\n $class = 'class=\"active\"';\n } else {\n $class = '';\n }\n $list .= \"
  • \".$data['icon'].' '.$data['name'].'
  • ';\n }\n }\n } else {\n $list = '';\n }\n\n return $list;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function event()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n\n if (empty($values['action_name']) || empty($values['project_id'])) {\n return $this->create();\n }\n\n return $this->response->html($this->template->render('action_creation/event', array(\n 'values' => $values,\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function __wakeup()\n {\n throw new \\BadMethodCallException('Cannot unserialize '.__CLASS__);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": "function OA_runMPE()\n{\n $objResponse = new xajaxResponse();\n $objResponse->addAssign(\"run-mpe\", \"innerHTML\", \"\");\n return $objResponse;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " protected function shouldCleanHtml()\n {\n $user = BackendAuth::getUser();\n return !$user || !$user->hasAccess('backend.allow_unsafe_markdown');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $WHERE[] = ['NOT' => ['name' => $locks]];\n }\n\n // Build query for frequency and allowed hour\n $WHERE[] = ['OR' => [\n ['AND' => [\n ['hourmin' => ['<', $DB->quoteName('hourmax')]],\n 'hourmin' => ['<=', $hour],\n 'hourmax' => ['>', $hour]\n ]],\n ['AND' => [\n 'hourmin' => ['>', $DB->quoteName('hourmax')],\n 'OR' => [\n 'hourmin' => ['<=', $hour],\n 'hourmax' => ['>', $hour]\n ]\n ]]\n ]];\n $WHERE[] = ['OR' => [\n 'lastrun' => null,\n new \\QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ') + ' . $DB->quoteName('frequency') . ' <= unix_timestamp(now())')\n ]];\n }\n\n $iterator = $DB->request([\n 'SELECT' => [\n '*',\n new \\QueryExpression(\"LOCATE('Plugin', \" . $DB->quoteName('itemtype') . \") AS ISPLUGIN\")\n ],\n 'FROM' => $this->getTable(),\n 'WHERE' => $WHERE,\n // Core task before plugins\n 'ORDER' => [\n 'ISPLUGIN',\n new \\QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ')+' . $DB->quoteName('frequency') . '')\n ]\n ]);\n\n if (count($iterator)) {\n $this->fields = $iterator->next();\n return true;\n }\n return false;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\tif(!is_array($sections)) $sections = array();\r\n\t\tforeach($sections as $section)\r\n\t\t{\r\n\t\t\tif(!empty($section['width']) && !in_array($section['width'], $widths))\r\n\t\t\t\tarray_push($widths, $section['width']);\r\n\t\t}\r\n\t}\t\r\n\t\r\n\treturn $widths;\r\n}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public function testPostRoutes($uri, $expectedVersion, $expectedController, $expectedAction, $expectedId)\n {\n $request = new Enlight_Controller_Request_RequestTestCase();\n $request->setMethod('POST');\n\n $response = new Enlight_Controller_Response_ResponseTestCase();\n\n $request->setPathInfo($uri);\n $this->router->assembleRoute($request, $response);\n\n static::assertEquals($expectedController, $request->getControllerName());\n static::assertEquals($expectedAction, $request->getActionName());\n static::assertEquals($expectedVersion, $request->getParam('version'));\n static::assertEquals($expectedId, $request->getParam('id'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": " $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function manage_messages() {\n expHistory::set('manageable', $this->params);\n \n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status_messages',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'body',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n\t\t\t//'columns'=>array('Name'=>'title')\n ));\n\n //eDebug($page);\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function edit_optiongroup_master() {\n expHistory::set('editable', $this->params);\n\n $id = isset($this->params['id']) ? $this->params['id'] : null;\n $record = new optiongroup_master($id);\n assign_to_template(array(\n 'record'=>$record\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function selectArraysBySql($sql) {\n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return array();\n $arrays = array();\n for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)\n $arrays[] = mysqli_fetch_assoc($res);\n return $arrays;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function manage() {\n expHistory::set('manageable', $this->params);\n\n // build out a SQL query that gets all the data we need and is sortable.\n $sql = 'SELECT b.*, c.title as companyname, f.expfiles_id as file_id ';\n $sql .= 'FROM '.DB_TABLE_PREFIX.'_banner b, '.DB_TABLE_PREFIX.'_companies c , '.DB_TABLE_PREFIX.'_content_expFiles f ';\n $sql .= 'WHERE b.companies_id = c.id AND (b.id = f.content_id AND f.content_type=\"banner\")';\n\n\t\t$page = new expPaginator(array(\n\t\t\t'model'=>'banner',\n\t\t\t'sql'=>$sql,\n\t\t\t'order'=>'title',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n\t\t\t'columns'=>array(\n gt('Title')=>'title',\n gt('Company')=>'companyname',\n gt('Impressions')=>'impressions',\n gt('Clicks')=>'clicks'\n )\n ));\n\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " static function displayname() {\n return \"Events\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach ($elem[2] as $field) {\n echo '\n \n    '.$field[1].' :\n ';\n if ($field[3] === \"masked\") {\n echo '\n
    ';\n } else {\n echo '\n
    ';\n }\n echo '\n \n ';\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "\tprotected function _copy($source, $targetDir, $name) {\n\t\t$ret = copy($source, $this->_joinPath($targetDir, $name));\n\t\t$ret && clearstatcache();\n\t\treturn $ret;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function index($id)\n {\n if (!is_numeric($id)) {\n throw new MethodNotAllowedException(__('No template with the provided ID exists, or you are not authorised to see it.'));\n }\n //check permissions\n $template = $this->TemplateElement->Template->checkAuthorisation($id, $this->Auth->user(), false);\n if (!$this->_isSiteAdmin() && !$template) {\n throw new MethodNotAllowedException(__('No template with the provided ID exists, or you are not authorised to see it.'));\n }\n\n $templateElements = $this->TemplateElement->find('all', array(\n 'conditions' => array(\n 'template_id' => $id,\n ),\n 'contain' => array(\n 'TemplateElementAttribute',\n 'TemplateElementText',\n 'TemplateElementFile'\n ),\n 'order' => array('TemplateElement.position ASC')\n ));\n $this->loadModel('Attribute');\n $this->set('validTypeGroups', $this->Attribute->validTypeGroups);\n $this->set('id', $id);\n $this->layout = 'ajaxTemplate';\n $this->set('elements', $templateElements);\n $mayModify = false;\n if ($this->_isSiteAdmin() || $template['Template']['org'] == $this->Auth->user('Organisation')['name']) {\n $mayModify = true;\n }\n $this->set('mayModify', $mayModify);\n $this->render('ajax/ajaxIndex');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testInvalidColorBBCode()\n {\n $parser = new JBBCode\\Parser();\n $parser->addCodeDefinitionSet(new JBBCode\\DefaultCodeDefinitionSet());\n $parser->parse('[color=\" onclick=\"alert(\\'hey ya!\\');]click me[/color]');\n $this->assertEquals('[color=\" onclick=\"alert(\\'hey ya!\\');]click me[/color]',\n $parser->getAsHtml());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function getParam($param, $post_id) {\r\n $sql = \"SELECT * FROM `posts_param` WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' LIMIT 1\";\r\n $q = Db::result($sql);\r\n if (Db::$num_rows > 0) {\r\n return $q[0]->value;\r\n }else{\r\n return '';\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function validate($string, $config, $context) {\n $string = $this->parseCDATA($string);\n\n // Optimizations\n if ($string === '') return false;\n if ($string === '0') return '0';\n if (strlen($string) === 1) return false;\n\n $length = HTMLPurifier_Length::make($string);\n if (!$length->isValid()) return false;\n\n if ($this->min) {\n $c = $length->compareTo($this->min);\n if ($c === false) return false;\n if ($c < 0) return false;\n }\n if ($this->max) {\n $c = $length->compareTo($this->max);\n if ($c === false) return false;\n if ($c > 0) return false;\n }\n\n return $length->toString();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function getFoo2Service()\n {\n return $this->services['Foo\\Foo'] = new \\Foo\\Foo();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function selectArraysBySql($sql) { \n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return array();\n $arrays = array();\n for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)\n $arrays[] = mysqli_fetch_assoc($res);\n return $arrays;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function editTitle() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->title = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testCanGiveCustomReason()\n {\n $r = new Response(200, [], null, '1.1', 'bar');\n $this->assertEquals('bar', $r->getReasonPhrase());\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " protected function getFooService()\n {\n return $this->services['Bar\\\\Foo'] = new \\Bar\\Foo();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function trimElement($chaine, $element)\n{\n if (!empty($chaine)) {\n if (is_array($chaine) === true) {\n $chaine = implode(\";\", $chaine);\n }\n $chaine = trim($chaine);\n if (substr($chaine, 0, 1) == $element) {\n $chaine = substr($chaine, 1);\n }\n if (substr($chaine, strlen($chaine) - 1, 1) == $element) {\n $chaine = substr($chaine, 0, strlen($chaine) - 1);\n }\n }\n return $chaine;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function set($def, $config) {\n return $this->cache->set($def, $config);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function writeHTMLDiv($html) {\n $this->startElement('div');\n\n $purifier = HTMLPurifier::getInstance();\n $html = $purifier->purify($html);\n $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');\n $this->writeRaw($html);\n\n $this->endElement(); // div\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function getParent($id){\n $q = self::getId($id);\n return $q[0]->parent;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\t\t\t\tprint \"\\n\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t?>\n\t\t\t\n\t\t\n\t\tpost_mime_type );\n\n\t\t$title = _draft_or_post_title();\n\t\t$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );\n\t\t$link_start = $link_end = '';\n\n\t\tif ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {\n\t\t\t$link_start = sprintf(\n\t\t\t\t'',\n\t\t\t\tget_edit_post_link( $post->ID ),\n\t\t\t\t/* translators: %s: attachment title */\n\t\t\t\tesc_attr( sprintf( __( '“%s” (Edit)' ), $title ) )\n\t\t\t);\n\t\t\t$link_end = '';\n\t\t}\n\n\t\t$class = $thumb ? ' class=\"has-media-icon\"' : '';\n\t\t?>\n\t\t>\n\t\t\t\n\t\t\t\t\">\n\t\t\t\n\t\t\n\t\t

    \n\t\t\t \n\t\t\tID );\n\t\t\techo wp_basename( $file );\n\t\t\t?>\n\t\t

    \n\t\tid));\n $ret .= scan_container($cLoc, $page->id);\n $ret .= scan_page($page->id);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " return rawurldecode(explode('=', $part)[0]) !== $decodedKey;\n });", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function prepareGenerator($config) {\n $all = $config->getAll();\n $context = new HTMLPurifier_Context();\n $this->generator = new HTMLPurifier_Generator($config, $context);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function parseAndTrimExport($str, $isHTML = false) { //\ufffdDeath from above\ufffd? \ufffd\n //echo \"1
    \"; eDebug($str); \n\n $str = str_replace(\"\ufffd\", \"’\", $str);\n $str = str_replace(\"\ufffd\", \"‘\", $str);\n $str = str_replace(\"\ufffd\", \"®\", $str);\n $str = str_replace(\"\ufffd\", \"-\", $str);\n $str = str_replace(\"\ufffd\", \"—\", $str);\n $str = str_replace(\"\ufffd\", \"”\", $str);\n $str = str_replace(\"\ufffd\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\t\", \" \", $str);\n $str = str_replace(\",\", \"\\,\", $str);\n $str = str_replace(\"\ufffd\", \"¼\", $str);\n $str = str_replace(\"\ufffd\", \"½\", $str);\n $str = str_replace(\"\ufffd\", \"¾\", $str);\n\n if (!$isHTML) {\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n } else {\n $str = str_replace('\"', '\"\"', $str);\n }\n\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n $str = trim(str_replace(\"\ufffd\", \"™\", $str));\n //echo \"2
    \"; eDebug($str,die);\n return $str;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function render($mode, &$renderer, $data) {\n if($mode == 'xhtml') {\n global $conf;\n $id = $data[0];\n $name = $data[1];\n \n //prepare for formating\n $link['target'] = $conf['target']['wiki'];\n $link['style'] = '';\n $link['pre'] = '';\n $link['suf'] = '';\n $link['more'] = '';\n $link['class'] = 'internallink';\n $link['url'] = DOKU_INTERNAL_LINK . $id;\n $link['name'] = ($name) ? $name : $id;\n $link['title'] = ($name) ? $name : $id;\n //add search string\n if($search){\n ($conf['userewrite']) ? $link['url'].='?s=' : $link['url'].='&s=';\n $link['url'] .= urlencode($search);\n }\n \n //output formatted\n $renderer->doc .= $renderer->_formatLink($link);\n }\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " foreach ($data['alertred'] as $alert) {\n # code...\n echo \"
  • $alert
  • \\n\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public function testSetCallbackNonCallable()\n {\n $response = new StreamedResponse(null);\n $response->setCallback(null);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function defaultTextParse($bbcode)\n {\n $parser = new JBBCode\\Parser();\n $parser->addCodeDefinitionSet(new JBBCode\\DefaultCodeDefinitionSet());\n $parser->parse($bbcode);\n return $parser->getAsText();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function validate($v, $config, $context) {\n return $this->clone->validate($v, $config, $context);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function json() {\n $token = Options::get('tokens');\n $token = json_decode($token, true);\n $newtoken = array(\n TOKEN => array(\n 'time' => TOKEN_TIME,\n 'ip' => TOKEN_IP,\n 'url' => TOKEN_URL\n )\n );\n if(is_array($token)){\n $newtoken = array_merge($token, $newtoken);\n }\n\n $newtoken = json_encode($newtoken);\n return $newtoken;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t\tfunction new_user() {\n\t\t\tglobal $db;\n\t\t\t$insert = $db->sql_query(\"INSERT INTO `mod_useronline` (`timestamp`, `ip`) VALUES ('mysql_real_escape_string($this->timestamp)', 'mysql_real_escape_string($this->ip)')\");\n\t\t\tif (!$insert) {\n\t\t\t\t$this->error[$this->i] = \"Unable to record new visitor\\r\\n\";\t\t\t\n\t\t\t\t$this->i ++;\n\t\t\t}\n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function configure() {\n $this->config['defaultbanner'] = array();\n if (!empty($this->config['defaultbanner_id'])) {\n $this->config['defaultbanner'][] = new expFile($this->config['defaultbanner_id']);\n } \n\t parent::configure();\n\t $banners = $this->banner->find('all', null, 'companies_id');\n\t assign_to_template(array(\n 'banners'=>$banners,\n 'title'=>static::displayname()\n ));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tpublic function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false, $x_param = false) {\r\n\t\t$objectid = ( isset($_POST[$this->handler->keyName]) )\r\n\t\t\t\t? (int) $_POST[$this->handler->keyName]\r\n\t\t\t\t: 0;\r\n\t\tif ($debug) {\r\n\t\t\tif ($x_param) {\r\n\t\t\t\t$icmsObj = $this->handler->getD($objectid, true, $x_param);\r\n\t\t\t} else {\r\n\t\t\t\t$icmsObj = $this->handler->getD($objectid);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\tif ($x_param) {\r\n\t\t\t\t$icmsObj = $this->handler->get($objectid, true, false, false, $x_param);\r\n\t\t\t} else {\r\n\t\t\t\t$icmsObj = $this->handler->get($objectid);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @todo multilanguage persistable handler is not fully implemented yet\r\n\t\t */\r\n\r\n\t\t// if handler is the Multilanguage handler, we will need to treat this for multilanguage\r\n\t\tif (is_subclass_of($this->handler, 'icmspersistablemlobjecthandler')) {\r\n\r\n\t\t\tif ($icmsObj->isNew()) {\r\n\t\t\t\t// This is a new object. We need to store the meta data and then the language data\r\n\t\t\t\t// First, we will get rid of the multilanguage data to only store the meta data\r\n\t\t\t\t$icmsObj->stripMultilanguageFields();\r\n\t\t\t\t$newObject =& $this->doStoreFromDefaultForm($icmsObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);\r\n\t\t\t\t/**\r\n\t\t\t\t * @todo we need to trap potential errors here\r\n\t\t\t\t */\r\n\r\n\t\t\t\t// ok, the meta daa is stored. Let's recreate the object and then\r\n\t\t\t\t// get rid of anything not multilanguage\r\n\t\t\t\tunset($icmsObj);\r\n\t\t\t\t$icmsObj = $this->handler->get($objectid);\r\n\t\t\t\t$icmsObj->stripNonMultilanguageFields();\r\n\r\n\t\t\t\t$icmsObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName));\r\n\t\t\t\t$this->handler->changeTableNameForML();\r\n\t\t\t\t$ret =& $this->doStoreFromDefaultForm($icmsObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);\r\n\r\n\t\t\t\treturn $ret;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn $this->doStoreFromDefaultForm($icmsObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);\r\n\t\t}\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public function approve_submit() {\n global $history;\n\n if (empty($this->params['id'])) {\n flash('error', gt('No ID supplied for comment to approve'));\n $lastUrl = expHistory::getLast('editable');\n }\n\n /* The global constants can be overriden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n $simplenote = new expSimpleNote($this->params['id']);\n //FIXME here is where we might sanitize the note before approving it\n $simplenote->body = $this->params['body'];\n $simplenote->approved = $this->params['approved'];\n $simplenote->save();\n\n $lastUrl = makelink($history->history[$history->history['lasts']['type']][count($history->history[$history->history['lasts']['type']])-1]['params']);\n if (!empty($this->params['tab']))\n {\n $lastUrl .= \"#\".$this->params['tab'];\n }\n redirect_to($lastUrl);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function setFrom($address, $name = '', $auto = true)\n {\n $address = trim($address);\n $name = trim(preg_replace('/[\\r\\n]+/', '', $name)); //Strip breaks and trim\n // Don't validate now addresses with IDN. Will be done in send().\n if (($pos = strrpos($address, '@')) === false or\n (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and\n !$this->validateAddress($address)) {\n $error_message = $this->lang('invalid_address') . \" (setFrom) $address\";\n $this->setError($error_message);\n $this->edebug($error_message);\n if ($this->exceptions) {\n throw new phpmailerException($error_message);\n }\n return false;\n }\n $this->From = $address;\n $this->FromName = $name;\n if ($auto) {\n if (empty($this->Sender)) {\n $this->Sender = $address;\n }\n }\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\tstatic function convertXMLFeedSafeChar($str) {\n\t\t$str = str_replace(\"
    \",\"\",$str);\n $str = str_replace(\"
    \",\"\",$str);\n $str = str_replace(\"
    \",\"\",$str);\n $str = str_replace(\"
    \",\"\",$str);\n $str = str_replace(\""\",'\"',$str);\n $str = str_replace(\"'\",\"'\",$str);\n $str = str_replace(\"’\",\"'\",$str);\n $str = str_replace(\"‘\",\"'\",$str); \n $str = str_replace(\"®\",\"\",$str);\n $str = str_replace(\"\ufffd\",\"-\", $str);\n $str = str_replace(\"\ufffd\",\"-\", $str); \n $str = str_replace(\"\ufffd\", '\"', $str);\n $str = str_replace(\"”\",'\"', $str);\n $str = str_replace(\"\ufffd\", '\"', $str);\n $str = str_replace(\"“\",'\"', $str);\n $str = str_replace(\"\\r\\n\",\" \",$str); \n $str = str_replace(\"\ufffd\",\" 1/4\",$str);\n $str = str_replace(\"¼\",\" 1/4\", $str);\n $str = str_replace(\"\ufffd\",\" 1/2\",$str);\n $str = str_replace(\"½\",\" 1/2\",$str);\n $str = str_replace(\"\ufffd\",\" 3/4\",$str);\n $str = str_replace(\"¾\",\" 3/4\",$str);\n $str = str_replace(\"\ufffd\", \"(TM)\", $str);\n $str = str_replace(\"™\",\"(TM)\", $str);\n $str = str_replace(\"®\",\"(R)\", $str);\n $str = str_replace(\"\ufffd\",\"(R)\",$str); \n $str = str_replace(\"&\",\"&\",$str); \n\t\t$str = str_replace(\">\",\">\",$str); \t\t\n return trim($str);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function addAddress($address, $name = '')\n {\n return $this->addAnAddress('to', $address, $name);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " function edit() {\n global $user;\n\n /* The global constants can be overriden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n if (empty($this->params['formtitle']))\n {\n if (empty($this->params['id']))\n {\n $formtitle = gt(\"Add New Note\");\n }\n else\n {\n $formtitle = gt(\"Edit Note\");\n }\n }\n else\n {\n $formtitle = $this->params['formtitle'];\n }\n\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $simpleNote = new expSimpleNote($id);\n //FIXME here is where we might sanitize the note before displaying/editing it\n\n assign_to_template(array(\n 'simplenote'=>$simpleNote,\n 'user'=>$user,\n 'require_login'=>$require_login,\n 'require_approval'=>$require_approval,\n 'require_notification'=>$require_notification,\n 'notification_email'=>$notification_email,\n 'formtitle'=>$formtitle,\n 'content_type'=>$this->params['content_type'],\n 'content_id'=>$this->params['content_id'],\n 'tab'=>empty($this->params['tab'])?0:$this->params['tab']\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction update_vendor() {\n\t\t$vendor = new vendor();\n\n\t\t$vendor->update($this->params['vendor']);\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function DragnDropReRank2() {\n global $router, $db;\n\n $id = $router->params['id'];\n $page = new section($id);\n $old_rank = $page->rank;\n $old_parent = $page->parent;\n $new_rank = $router->params['position'] + 1; // rank\n $new_parent = intval($router->params['parent']);\n\n $db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole\n $db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room\n\n $params = array();\n $params['parent'] = $new_parent;\n $params['rank'] = $new_rank;\n $page->update($params);\n\n self::checkForSectionalAdmins($id);\n expSession::clearAllUsersSessionCache('navigation');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function columnUpdate($table, $col, $val, $where=1) {\n $res = @mysqli_query($this->connection, \"UPDATE `\" . $this->prefix . \"$table` SET `$col`='\" . $val . \"' WHERE $where\");\n /*if ($res == null)\n return array();\n $objects = array();\n for ($i = 0; $i < mysqli_num_rows($res); $i++)\n $objects[] = mysqli_fetch_object($res);*/\n //return $objects;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function createDateTime($seconds = null)\n {\n if (null === $seconds) {\n $seconds = time();\n }\n\n if ($this->mongo instanceof \\MongoDB\\Client) {\n return new \\MongoDB\\BSON\\UTCDateTime($seconds * 1000);\n }\n\n return new \\MongoDate($seconds);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct()\n {\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testUnsubTokenReplacementErrorTest () {\n // error can't be triggered using current method of reducing the backtrack_limit and \n // recursion_limit since there's a call to createExternalUrl directly preceeding the\n // code which does the token replacement\n $this->markTestSkipped ();\n\n $this->setExpectedException (\n 'StringUtilException', '',\n StringUtilException::PREG_REPLACE_ERROR);\n\n ini_set('pcre.backtrack_limit', '0');\n ini_set('pcre.recursion_limit', '0');\n\n Yii::app()->controller = new MarketingController (\n 'campaign', new MarketingModule ('campaign', null));\n $_SERVER['SERVER_NAME'] = 'localhost';\n $cmb = $this->instantiate();\n $contact = $this->contacts('testUser_unsent');\n list($subject,$message,$uniqueId) = $cmb->prepareEmail(\n $this->campaign('testUser'), $contact, false);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\t\t\tif ($current_realm_id == -1 || is_realm_allowed($current_realm_id) || !isset($user_auth_realm_filenames{basename($item_url)})) {\n\t\t\t\t\t\t/* draw normal (non sub-item) menu item */\n\t\t\t\t\t\t$item_url = $config['url_path'] . $item_url;\n\t\t\t\t\t\tif (is_menu_pick_active($item_url)) {\n\t\t\t\t\t\t\tprint \"
  • $item_title
  • \\n\";\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tprint \"
  • $item_title
  • \\n\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " self::removeLevel($kid->id);\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\n $ret .= scan_container($cLoc, $page->id);\n $ret .= scan_page($page->id);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic static function CanTrustFormLayoutContent($sPostedFormManagerData, $aOriginalFormProperties)\n\t{\n\t\t$aPostedFormManagerData = json_decode($sPostedFormManagerData, true);\n\t\t$sPostedFormLayoutType = (isset($aPostedFormManagerData['formproperties']['layout']['type'])) ? $aPostedFormManagerData['formproperties']['layout']['type'] : '';\n\n\t\tif ($sPostedFormLayoutType === 'xhtml') {\n\t\t\treturn true;\n\t\t}\n\n\t\t// we need to parse the content so that autoclose tags are returned correctly (`
    ` => `
    `)\n\t\t$oHtmlDocument = new \\DOMDocument();\n\n\t\t$sPostedFormLayoutContent = (isset($aPostedFormManagerData['formproperties']['layout']['content'])) ? $aPostedFormManagerData['formproperties']['layout']['content'] : '';\n\t\t$oHtmlDocument->loadXML(''.$sPostedFormLayoutContent.'');\n\t\t$sPostedFormLayoutRendered = $oHtmlDocument->saveHTML();\n\n\t\t$sOriginalFormLayoutContent = (isset($aOriginalFormProperties['layout']['content'])) ? $aOriginalFormProperties['layout']['content'] : '';\n\t\t$oHtmlDocument->loadXML(''.$sOriginalFormLayoutContent.'');\n\t\t$sOriginalFormLayoutContentRendered = $oHtmlDocument->saveHTML();\n\n\t\treturn ($sPostedFormLayoutRendered === $sOriginalFormLayoutContentRendered);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " function prepareInputForUpdate($input) {\n\n if (isset($input[\"rootdn_passwd\"])) {\n if (empty($input[\"rootdn_passwd\"])) {\n unset($input[\"rootdn_passwd\"]);\n } else {\n $input[\"rootdn_passwd\"] = Toolbox::encrypt(stripslashes($input[\"rootdn_passwd\"]),\n GLPIKEY);\n }\n }\n\n if (isset($input[\"_blank_passwd\"]) && $input[\"_blank_passwd\"]) {\n $input['rootdn_passwd'] = '';\n }\n\n // Set attributes in lower case\n if (count($input)) {\n foreach ($input as $key => $val) {\n if (preg_match('/_field$/', $key)) {\n $input[$key] = Toolbox::strtolower($val);\n }\n }\n }\n\n //do not permit to override sync_field\n if ($this->isSyncFieldEnabled()\n && isset($input['sync_field'])\n && $this->isSyncFieldUsed()\n ) {\n if ($input['sync_field'] == $this->fields['sync_field']) {\n unset($input['sync_field']);\n } else {\n Session::addMessageAfterRedirect(\n __('Synchronization field cannot be changed once in use.'),\n false,\n ERROR\n );\n return false;\n };\n }\n return $input;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-327", "cwe_name": "Use of a Broken or Risky Cryptographic Algorithm", "description": "The use of a broken or risky cryptographic algorithm is an unnecessary risk that may result in the exposure of sensitive information.", "url": "https://cwe.mitre.org/data/definitions/327.html", "label_name": "vulnerable"} {"code": " $templateBase = $inflector->filter(array(\n 'module' => $moduleName,\n 'controller' => $controllerName,\n 'file' => $fileName\n ));\n\n $templateExtend = $inflector->filter(array(\n 'module' => $moduleName,\n 'controller' => $this->Request()->getControllerName(),\n 'file' => $fileName\n ));\n\n if ($this->View()->templateExists($templateBase)) {\n $template .= '{include file=\"' . $templateBase. '\"}' . \"\\n\";\n }\n if ($this->View()->templateExists($templateExtend)) {\n $template .= '{include file=\"' . $templateExtend. '\"}' . \"\\n\";\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " function update() {\n parent::update();\n expSession::clearAllUsersSessionCache('navigation');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function initializeNavigation() {\r\n $sections = section::levelTemplate(0, 0);\r\n return $sections;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " static function description() { return gt(\"Places navigation links/menus on the page.\"); }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function getPageData()\n {\n $data = parent::getPageData();\n $data['menu'] = 'admin';\n $data['showonmenu'] = false;\n $data['title'] = 'options';\n $data['icon'] = 'fas fa-wrench';\n return $data;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function exception_for($reason)\n{\n return $reason instanceof \\Exception || $reason instanceof \\Throwable\n ? $reason\n : new RejectionException($reason);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testRawCookie()\n {\n $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true);\n $this->assertFalse($cookie->isRaw());\n\n $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true, true);\n $this->assertTrue($cookie->isRaw());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function __construct($message)\n {\n $this->message =& $message;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function teampass_decrypt_pw($encrypted, $salt, $rand_key, $itcount = 2072)\n{\n $encrypted = base64_decode($encrypted);\n $pass_salt = substr($encrypted, -64);\n $encrypted = substr($encrypted, 0, -64);\n $key = teampass_pbkdf2_hash($salt, $pass_salt, $itcount, 16, 32);\n $iv = base64_decode(substr($encrypted, 0, 43) . '==');\n $encrypted = substr($encrypted, 43);\n $mac = substr($encrypted, -64);\n $encrypted = substr($encrypted, 0, -64);\n if ($mac !== hash_hmac('sha256', $encrypted, $salt)) return null;\n return substr(rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, 'ctr', $iv), \"\\0\\4\"), strlen($rand_key));\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function getModelTypes($assoc = false) {\n $modelTypes = Yii::app()->db->createCommand()\n ->selectDistinct('modelName')\n ->from('x2_fields')\n ->where('modelName!=\"Calendar\"')\n ->order('modelName ASC')\n ->queryColumn();\n\n if ($assoc === true) {\n $modelTypes = array_combine($modelTypes, array_map(function($type) {\n return X2Model::model ($type)->getDisplayName (true, false);\n }, $modelTypes));\n asort ($modelTypes);\n return $modelTypes;\n }\n $modelTypes = array_map(function($term) {\n return Yii::t('app', $term);\n }, $modelTypes);\n return $modelTypes;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " private function runCallback() {\n foreach ($this->records as &$record) {\n if (isset($record->ref_type)) {\n $refType = $record->ref_type;\n if (class_exists($record->ref_type)) {\n $type = new $refType();\n $classinfo = new ReflectionClass($type);\n if ($classinfo->hasMethod('paginationCallback')) {\n $item = new $type($record->original_id);\n $item->paginationCallback($record);\n }\n }\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function getConfig($apikey){\r\n $url = \"http://api.themoviedb.org/3/configuration?api_key=\".$apikey;\r\n $config = $this->curl($url);\r\n return $config;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $navs[$i]->link = expCore::makeLink(array('section' => $navs[$i]->id), '', $navs[$i]->sef_name);\r\n if (!$view) {\r\n// unset($navs[$i]); //FIXME this breaks jstree if we remove a parent and not the child\r\n $attr = new stdClass();\r\n $attr->class = 'hidden'; // bs3 class to hide elements\r\n $navs[$i]->li_attr = $attr;\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function getStream()\n {\n $this->validateActive();\n\n if ($this->stream instanceof StreamInterface) {\n return $this->stream;\n }\n\n return new LazyOpenStream($this->file, 'r+');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function GETPOST($paramname,$check='',$method=0)\n{\n\tif (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:'');\n\telseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:'';\n\telseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:'';\n\telseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:'');\n\n\tif (! empty($check))\n\t{\n\t\t// Check if numeric\n\t\tif ($check == 'int' && ! preg_match('/^[-\\.,0-9]+$/i',trim($out))) $out='';\n\t\t// Check if alpha\n\t\t//if ($check == 'alpha' && ! preg_match('/^[ =:@#\\/\\\\\\(\\)\\-\\._a-z0-9]+$/i',trim($out))) $out='';\n\t\t// '\"' is dangerous because param in url can close the href= or src= and add javascript functions.\n\t\tif ($check == 'alpha' && preg_match('/\"/',trim($out))) $out='';\n\t}\n\n\treturn $out;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "\tprotected function _mkdir($path, $name) {\n\t\t$path = $this->_joinPath($path, $name);\n\n\t\tif (@mkdir($path)) {\n\t\t\t@chmod($path, $this->options['dirMode']);\n\t\t\tclearstatcache();\n\t\t\treturn $path;\n\t\t}\n\n\t\treturn false;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function manage_messages() {\n expHistory::set('manageable', $this->params);\n\n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status_messages',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'body',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n\t\t\t//'columns'=>array('Name'=>'title')\n ));\n\n //eDebug($page);\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\t\t$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';\n\t\t\t$themes[ $filter ][ $key ] = $themes['all'][ $key ];\n\t\t}\n\n\t\tif ( $s ) {\n\t\t\t$status = 'search';\n\t\t\t$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );\n\t\t}\n\n\t\t$totals = array();\n\t\tforeach ( $themes as $type => $list )\n\t\t\t$totals[ $type ] = count( $list );\n\n\t\tif ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )\n\t\t\t$status = 'all';\n\n\t\t$this->items = $themes[ $status ];\n\t\tWP_Theme::sort_by_name( $this->items );\n\n\t\t$this->has_items = ! empty( $themes['all'] );\n\t\t$total_this_page = $totals[ $status ];\n\n\t\twp_localize_script( 'updates', '_wpUpdatesItemCounts', array(\n\t\t\t'totals' => $totals,\n\t\t) );\n\n\t\tif ( $orderby ) {\n\t\t\t$orderby = ucfirst( $orderby );\n\t\t\t$order = strtoupper( $order );\n\n\t\t\tif ( $orderby === 'Name' ) {\n\t\t\t\tif ( 'ASC' === $order ) {\n\t\t\t\t\t$this->items = array_reverse( $this->items );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tuasort( $this->items, array( $this, '_order_callback' ) );\n\t\t\t}\n\t\t}\n\n\t\t$start = ( $page - 1 ) * $themes_per_page;\n\n\t\tif ( $total_this_page > $themes_per_page )\n\t\t\t$this->items = array_slice( $this->items, $start, $themes_per_page, true );\n\n\t\t$this->set_pagination_args( array(\n\t\t\t'total_items' => $total_this_page,\n\t\t\t'per_page' => $themes_per_page,\n\t\t) );\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " function manage() {\n expHistory::set('viewable', $this->params);\n // $category = new storeCategory();\n // $categories = $category->getFullTree();\n // \n // // foreach($categories as $i=>$val){\n // // if (!empty($this->values) && in_array($val->id,$this->values)) {\n // // $this->tags[$i]->value = true;\n // // } else {\n // // $this->tags[$i]->value = false;\n // // }\n // // $this->tags[$i]->draggable = $this->draggable; \n // // $this->tags[$i]->checkable = $this->checkable; \n // // }\n //\n // $obj = json_encode($categories); \n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t\tforeach($fields as $field)\r\n\t\t\t{\r\n\t\t\t\tif(substr($key, 0, strlen($field.'-'))==$field.'-')\r\n\t\t\t\t\t$this->dictionary[substr($key, strlen($field.'-'))][$field] = $value;\r\n\t\t\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " $body = str_replace(array(\"\\n\"), \"
    \", $body);\n } else {\n // It's going elsewhere (doesn't like quoted-printable)\n $body = str_replace(array(\"\\n\"), \" -- \", $body);\n }\n $title = $items[$i]->title;\n\n $msg .= \"BEGIN:VEVENT\\n\";\n $msg .= $dtstart . $dtend;\n $msg .= \"UID:\" . $items[$i]->date_id . \"\\n\";\n $msg .= \"DTSTAMP:\" . date(\"Ymd\\THis\", time()) . \"Z\\n\";\n if ($title) {\n $msg .= \"SUMMARY:$title\\n\";\n }\n if ($body) {\n $msg .= \"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:\" . $body . \"\\n\";\n }\n //\tif($link_url) { $msg .= \"URL: $link_url\\n\";}\n if (!empty($this->config['usecategories'])) {\n if (!empty($items[$i]->expCat[0]->title)) {\n $msg .= \"CATEGORIES:\".$items[$i]->expCat[0]->title.\"\\n\";\n } else {\n $msg .= \"CATEGORIES:\".$this->config['uncat'].\"\\n\";\n }\n }\n $msg .= \"END:VEVENT\\n\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " recyclebin::sendToRecycleBin($loc, $parent);\r\n //FIXME if we delete the module & sectionref the module completely disappears\r\n// if (class_exists($secref->module)) {\r\n// $modclass = $secref->module;\r\n// //FIXME: more module/controller glue code\r\n// if (expModules::controllerExists($modclass)) {\r\n// $modclass = expModules::getControllerClassName($modclass);\r\n// $mod = new $modclass($loc->src);\r\n// $mod->delete_instance();\r\n// } else {\r\n// $mod = new $modclass();\r\n// $mod->deleteIn($loc);\r\n// }\r\n// }\r\n }\r\n// $db->delete('sectionref', 'section=' . $parent);\r\n $db->delete('section', 'parent=' . $parent);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tprotected function LoadData()\n\t{\n\t\t$this->dataLoaded = true;\n\n\t\t$args = array();\n\t\t$args[] = $this->hash;\n\t\t$args[] = '--no-merges';\n\n\t\t$canSkip = true;\n\t\tif ($this->skip > 0)\n\t\t\t$canSkip = $this->exe->CanSkip();\n\n\t\tif ($canSkip) {\n\t\t\tif ($this->limit > 0) {\n\t\t\t\t$args[] = '--max-count=' . $this->limit;\n\t\t\t}\n\t\t\tif ($this->skip > 0) {\n\t\t\t\t$args[] = '--skip=' . $this->skip;\n\t\t\t}\n\t\t} else {\n\t\t\tif ($this->limit > 0) {\n\t\t\t\t$args[] = '--max-count=' . ($this->limit + $this->skip);\n\t\t\t}\n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public function getTestData()\n {\n return [\n [[], 'Kimai - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.'],\n [['--name' => true], Constants::NAME],\n [['--candidate' => true], Constants::STATUS],\n [['--short' => true], Constants::VERSION],\n [['--semver' => true], Constants::VERSION . '-' . Constants::STATUS],\n ];\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": "\tpublic function load_from_post()\r\n\t{\r\n\t\tif(intval($_REQUEST['parent'])!=$this->id)\t// protection against selecting this same category as parent of itself\r\n {\r\n $this->parent \t\t= intval($_REQUEST['parent']);\r\n }\r\n\t\t\t\r\n\t\t$this->template \t= $_REQUEST['template'];\r\n\t\t$this->access\t\t= intval($_REQUEST['access']);\r\n\r\n $this->groups\t = $_REQUEST['groups'];\r\n if($this->access < 3)\r\n {\r\n $this->groups = array();\r\n }\r\n\r\n\t\t$this->permission\t= intval($_REQUEST['permission']);\t\t\r\n\t\t$this->visible\t\t= intval($_REQUEST['visible']);\t\t\r\n\t\t\r\n\t\t$this->date_published\t= (empty($_REQUEST['date_published'])? '' : core_date2ts($_REQUEST['date_published']));\t\r\n\t\t$this->date_unpublish\t= (empty($_REQUEST['date_unpublish'])? '' : core_date2ts($_REQUEST['date_unpublish']));\t\r\n\t\t\r\n\t\t// language strings and options\r\n\t\t$this->dictionary = array();\r\n\t\t$this->paths = array();\r\n\r\n\t\t$fields = array('title', 'action-type', 'action-jump-item', 'action-jump-branch', 'action-new-window', 'action-masked-redirect'); //, 'path', 'visible');\r\n\t\tforeach($_REQUEST as $key => $value)\r\n\t\t{\r\n\t\t\tif(empty($value))\r\n {\r\n continue;\r\n }\r\n\t\t\t\r\n\t\t\tforeach($fields as $field)\r\n\t\t\t{\r\n\t\t\t\tif(substr($key, 0, strlen($field.'-'))==$field.'-')\r\n {\r\n $this->dictionary[substr($key, strlen($field.'-'))][$field] = $value;\r\n }\r\n\t\t\t}\r\n\t\t\r\n\t\t\tif(substr($key, 0, strlen('path-'))=='path-')\r\n {\r\n $this->paths[substr($key, strlen('path-'))] = $value;\r\n }\r\n\t\t}\t\t\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function action()\n {\n // Do not proceed if the config file cannot be changed\n if (General::checkFile(CONFIG) === false) {\n redirect(SYMPHONY_URL . '/system/preferences/');\n }\n\n /**\n * Extensions can listen for any custom actions that were added\n * through `AddCustomPreferenceFieldsets` or `AddCustomActions`\n * delegates.\n *\n * @delegate CustomActions\n * @param string $context\n * '/system/preferences/'\n */\n Symphony::ExtensionManager()->notifyMembers('CustomActions', '/system/preferences/');\n\n if (isset($_POST['action']['save'])) {\n $settings = filter_var_array($_POST['settings'], FILTER_SANITIZE_STRING);\n\n /**\n * Just prior to saving the preferences and writing them to the `CONFIG`\n * Allows extensions to preform custom validation logic on the settings.\n *\n * @delegate Save\n * @param string $context\n * '/system/preferences/'\n * @param array $settings\n * An array of the preferences to be saved, passed by reference\n * @param array $errors\n * An array of errors passed by reference\n */\n Symphony::ExtensionManager()->notifyMembers('Save', '/system/preferences/', array(\n 'settings' => &$settings,\n 'errors' => &$this->_errors\n ));\n\n if (!is_array($this->_errors) || empty($this->_errors)) {\n if (is_array($settings) && !empty($settings)) {\n Symphony::Configuration()->setArray($settings, false);\n }\n\n if (Symphony::Configuration()->write()) {\n if (function_exists('opcache_invalidate')) {\n opcache_invalidate(CONFIG, true);\n }\n\n redirect(SYMPHONY_URL . '/system/preferences/success/');\n }\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testIsActive()\n {\n $this->assertFalse($this->proxy->isActive());\n session_start();\n $this->assertTrue($this->proxy->isActive());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct(){\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function _eventBlacklist($filename)\n {\n if ( strpos($filename, 'jquery') !== false\n || strpos($filename, 'codemirror') !== false\n || strpos($filename, 'messages.php') !== false\n || strpos($filename, 'ajax.js') !== false\n || strpos($filename, 'navigation.js') !== false\n || strpos($filename, 'get_image.js.php') !== false\n || strpos($filename, 'cross_framing_protection.js') !== false\n ) {\n return 0;\n } else {\n return 1;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function recent($vars, $type = 'post') {\n $sql = \"SELECT * FROM `posts` WHERE `type` = '{$type}' ORDER BY `date` DESC LIMIT {$vars}\";\n $posts = Db::result($sql);\n if(isset($posts['error'])){\n $posts['error'] = \"No Posts found.\";\n }else{\n $posts = $posts;\n }\n return $posts;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tstatic function validUTF($string) {\n\t\tif(!mb_check_encoding($string, 'UTF-8') OR !($string === mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testRemoveNonExistingQueryValue()\n {\n $uri = new Uri();\n $uri = Uri::withQueryValue($uri, 'a', 'b');\n $uri = Uri::withoutQueryValue($uri, 'c');\n $this->assertSame('a=b', $uri->getQuery());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $src = substr($ref->source, strlen($prefix)) . $section->id;\n if (call_user_func(array($ref->module, 'hasContent'))) {\n $oloc = expCore::makeLocation($ref->module, $ref->source);\n $nloc = expCore::makeLocation($ref->module, $src);\n if ($ref->module != \"container\") {\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc);\n } else {\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc, $section->id);\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic static function sessionDataDecode(&$var, $checkIs = null) {\n\t\tif (self::$base64encodeSessionData) {\n\t\t\t$data = @unserialize(@base64_decode($var));\n\t\t} else {\n\t\t\t$data = $var;\n\t\t}\n\t\t$chk = true;\n\t\tif ($checkIs) {\n\t\t\tswitch ($checkIs) {\n\t\t\t\tcase 'array':\n\t\t\t\t\t$chk = is_array($data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'string':\n\t\t\t\t\t$chk = is_string($data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'object':\n\t\t\t\t\t$chk = is_object($data);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'int':\n\t\t\t\t\t$chk = is_int($data);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!$chk) {\n\t\t\tunset($var);\n\t\t\treturn false;\n\t\t}\n\t\treturn $data;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testNewInstanceWhenNewProtocol()\n {\n $r = new Response(200);\n $this->assertNotSame($r, $r->withProtocolVersion('1.0'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function incFunc($var)\n {\n if (self::functionExist($var)) {\n include GX_THEME.$var.'/function.php';\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach ($day as $extevent) {\r\n $event_cache = new stdClass();\r\n $event_cache->feed = $extgcalurl;\r\n $event_cache->event_id = $extevent->event_id;\r\n $event_cache->title = $extevent->title;\r\n $event_cache->body = $extevent->body;\r\n $event_cache->eventdate = $extevent->eventdate->date;\r\n if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)\r\n $event_cache->dateFinished = $extevent->dateFinished;\r\n if (isset($extevent->eventstart))\r\n $event_cache->eventstart = $extevent->eventstart;\r\n if (isset($extevent->eventend))\r\n $event_cache->eventend = $extevent->eventend;\r\n if (isset($extevent->is_allday))\r\n $event_cache->is_allday = $extevent->is_allday;\r\n $found = false;\r\n if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries\r\n $found = $db->selectObject('event_cache','feed=\"'.$extgcalurl.'\" AND event_id=\"'.$event_cache->event_id.'\" AND eventdate='.$event_cache->eventdate);\r\n if (!$found)\r\n $db->insertObject($event_cache,'event_cache');\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " private function transfer(RequestInterface $request, array $options)\n {\n // save_to -> sink\n if (isset($options['save_to'])) {\n $options['sink'] = $options['save_to'];\n unset($options['save_to']);\n }\n\n // exceptions -> http_error\n if (isset($options['exceptions'])) {\n $options['http_errors'] = $options['exceptions'];\n unset($options['exceptions']);\n }\n\n $request = $this->applyOptions($request, $options);\n $handler = $options['handler'];\n\n try {\n return Promise\\promise_for($handler($request, $options));\n } catch (\\Exception $e) {\n return Promise\\rejection_for($e);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function confirm() {\n global $db;\n \n // make sure we have what we need.\n if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));\n if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));\n \n // verify the id/key pair \n $id = $db->selectValue('subscribers','id', 'id='.$this->params['id'].' AND hash=\"'.$this->params['key'].'\"');\n if (empty($id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));\n \n // activate this users pending subscriptions\n $sub = new stdClass();\n $sub->enabled = 1;\n $db->updateObject($sub, 'expeAlerts_subscribers', 'subscribers_id='.$id);\n \n // find the users active subscriptions\n $ealerts = expeAlerts::getBySubscriber($id);\n assign_to_template(array(\n 'ealerts'=>$ealerts\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " static function cronCheckUpdate($task) {\n\n $result = Toolbox::checkNewVersionAvailable(1);\n $task->log($result);\n\n return 1;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public function addUser(){\n $login_user = $this->checkLogin();\n $this->checkAdmin();\n $username = I(\"post.username\");\n $password = I(\"post.password\");\n $uid = I(\"post.uid\");\n $name = I(\"post.name\");\n if(!$username){\n $this->sendError(10101,'\u7528\u6237\u540d\u4e0d\u5141\u8bb8\u4e3a\u7a7a');\n return ;\n }\n if($uid){\n if($password){\n D(\"User\")->updatePwd($uid, $password);\n }\n if($name){\n D(\"User\")->where(\" uid = '$uid' \")->save(array(\"name\"=>$name));\n }\n $this->sendResult(array());\n }else{\n if (D(\"User\")->isExist($username)) {\n $this->sendError(10101,L('username_exists'));\n return ;\n }\n $new_uid = D(\"User\")->register($username,$password);\n if (!$new_uid) {\n $this->sendError(10101);\n }else{\n if($name){\n D(\"User\")->where(\" uid = '$new_uid' \")->save(array(\"name\"=>$name));\n }\n $this->sendResult($return);\n }\n }\n\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function breadcrumb() {\n global $sectionObj;\n\n expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // Show not only the location of a page in the hierarchy but also the location of a standalone page\n $current = new section($id);\n if ($current->parent == -1) { // standalone page\n $navsections = section::levelTemplate(-1, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n } else {\n $navsections = section::levelTemplate(0, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sections' => $navsections,\n 'current' => $current,\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function showallSubcategories() {\n// global $db;\n\n expHistory::set('viewable', $this->params);\n// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');\n $catid = expSession::get('catid');\n $parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? $this->params['cat'] : 0);\n $category = new storeCategory($parent);\n $categories = $category->getEcomSubcategories();\n $ancestors = $category->pathToNode();\n assign_to_template(array(\n 'categories' => $categories,\n 'ancestors' => $ancestors,\n 'category' => $category\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function update_discount() {\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $discount = new discounts($id);\n // find required shipping method if needed\n if ($this->params['required_shipping_calculator_id'] > 0) {\n $this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']];\n } else {\n $this->params['required_shipping_calculator_id'] = 0;\n }\n \n $discount->update($this->params);\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function validate() {\n $validator = new HTMLPurifier_ConfigSchema_Validator();\n return $validator->validate($this);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __construct() {\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function setHeadItemAttributes( $attributes ) {\n\t\t$this->headItemAttributes = \\Sanitizer::fixTagAttributes( $attributes, 'li' );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public function updateForgottenPassword(array $input) {\n $condition = [\n 'glpi_users.is_active' => 1,\n 'glpi_users.is_deleted' => 0, [\n 'OR' => [\n ['glpi_users.begin_date' => null],\n ['glpi_users.begin_date' => ['<', new QueryExpression('NOW()')]]\n ],\n ], [\n 'OR' => [\n ['glpi_users.end_date' => null],\n ['glpi_users.end_date' => ['>', new QueryExpression('NOW()')]]\n ]\n ]\n ];\n if ($this->getFromDBbyEmail($input['email'], $condition)) {\n if (($this->fields[\"authtype\"] == Auth::DB_GLPI)\n || !Auth::useAuthExt()) {\n\n if (($input['password_forget_token'] == $this->fields['password_forget_token'])\n && (abs(strtotime($_SESSION[\"glpi_currenttime\"])\n -strtotime($this->fields['password_forget_token_date'])) < DAY_TIMESTAMP)) {\n\n $input['id'] = $this->fields['id'];\n Config::validatePassword($input[\"password\"], false); // Throws exception if password is invalid\n if (!$this->update($input)) {\n return false;\n }\n $input2 = [\n 'password_forget_token' => '',\n 'password_forget_token_date' => null,\n 'id' => $this->fields['id']\n ];\n $this->update($input2);\n return true;\n\n } else {\n throw new ForgetPasswordException(__('Your password reset request has expired or is invalid. Please renew it.'));\n }\n\n } else {\n throw new ForgetPasswordException(__(\"The authentication method configuration doesn't allow you to change your password.\"));\n }\n\n } else {\n throw new ForgetPasswordException(__('Email address not found.'));\n }\n\n return false;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-640", "cwe_name": "Weak Password Recovery Mechanism for Forgotten Password", "description": "The software contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak.", "url": "https://cwe.mitre.org/data/definitions/640.html", "label_name": "vulnerable"} {"code": " public function take($value)\n {\n return $this->limit($value);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function configure() {\n expHistory::set('editable', $this->params);\n // little bit of trickery so that that categories can have their own configs\n \n $this->loc->src = \"@globalstoresettings\";\n $config = new expConfig($this->loc);\n $this->config = $config->config;\n $pullable_modules = expModules::listInstalledControllers($this->baseclassname, $this->loc);\n $views = expTemplate::get_config_templates($this, $this->loc);\n \n $gc = new geoCountry(); \n $countries = $gc->find('all');\n \n $gr = new geoRegion(); \n $regions = $gr->find('all');\n \n assign_to_template(array(\n 'config'=>$this->config,\n 'pullable_modules'=>$pullable_modules,\n 'views'=>$views,\n 'countries'=>$countries,\n 'regions'=>$regions,\n 'title'=>static::displayname()\n ));\n } ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $links[] = CHtml::link(CHtml::encode($tag->tag),array('/search/search','term'=>CHtml::encode($tag->tag)));", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function process_subsections($parent_section, $subtpl) {\n global $db, $router;\n\n $section = new stdClass();\n $section->parent = $parent_section->id;\n $section->name = $subtpl->name;\n $section->sef_name = $router->encode($section->name);\n $section->subtheme = $subtpl->subtheme;\n $section->active = $subtpl->active;\n $section->public = $subtpl->public;\n $section->rank = $subtpl->rank;\n $section->page_title = $subtpl->page_title;\n $section->keywords = $subtpl->keywords;\n $section->description = $subtpl->description;\n $section->id = $db->insertObject($section, 'section');\n self::process_section($section, $subtpl);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\tpublic function get($extramediatypes = false) {\n\t\ttry {\n\t\t\treturn $this->getConfig($extramediatypes);\n\t\t} catch (\\Exception $exception) {\n\t\t\treturn $this->jsonError($exception, $this->request, $this->logger);\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)\n {\n $pos = self::mb_stripos($haystack, $needle, 0, $encoding);\n\n return self::getSubpart($pos, $part, $haystack, $encoding);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach ($evs as $key=>$event) {\n if ($condense) {\n $eventid = $event->id;\n $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));\n if (!empty($multiday_event)) {\n unset($evs[$key]);\n continue;\n }\n }\n $evs[$key]->eventstart += $edate->date;\n $evs[$key]->eventend += $edate->date;\n $evs[$key]->date_id = $edate->id;\n if (!empty($event->expCat)) {\n $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);\n// if (substr($catcolor,0,1)=='#') $catcolor = '\" style=\"color:'.$catcolor.';';\n $evs[$key]->color = $catcolor;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function setUp() {\n\t\t$this->databaseBackend = new \\OMV\\Config\\DatabaseBackend(\n\t\t\tsprintf(\"%s/../data/config.xml\", getcwd()),\n\t\t\tFALSE);\n\t\t$this->databaseBackend->load();\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " public function disable()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $swimlane_id = $this->request->getIntegerParam('swimlane_id');\n\n if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {\n $this->flash->success(t('Swimlane updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this swimlane.'));\n }\n\n $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " protected function signDocument(\\DOMDocument $document, $node)\n {\n $this->add509Cert($this->getCertificate()->getPublicKey()->getX509Certificate());\n $this->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);\n $this->addReference($document->documentElement, XMLSecurityDSig::SHA1, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), array('id_name' => 'ID'));\n\n $this->sign($this->getCertificate()->getPrivateKey());\n $this->insertSignature($document->firstChild, $node);\n $this->canonicalizeSignedInfo();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " function reset_stats() {\n// global $db;\n\n // reset the counters\n// $db->sql ('UPDATE '.$db->prefix.'banner SET impressions=0 WHERE 1');\n banner::resetImpressions();\n// $db->sql ('UPDATE '.$db->prefix.'banner SET clicks=0 WHERE 1');\n banner::resetClicks();\n\n // let the user know we did stuff.\n flash('message', gt(\"Banner statistics reset.\"));\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " function getConfig($apikey) {\r\n $url = \"http://api.themoviedb.org/3/configuration?api_key=\".$apikey;\r\n $config = $this->curl($url);\r\n return $config;\r\n }\r", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct($message = null, $code = 0, Exception $previous = null)\n {\n if ($message === null) {\n $message = _('Authentication required');\n }\n parent::__construct($message, $code, $previous);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-307", "cwe_name": "Improper Restriction of Excessive Authentication Attempts", "description": "The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks.", "url": "https://cwe.mitre.org/data/definitions/307.html", "label_name": "vulnerable"} {"code": " function getErrorMessage()\n {\n return $this->error->message;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function path($var)\n {\n return GX_LIB.'Vendor/'.$var.'/';\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function XMLRPCaddUserGroupPriv($name, $affiliation, $nodeid, $permissions) {\n\trequire_once(\".ht-inc/privileges.php\");\n\tglobal $user;\n\n\tif(! is_numeric($nodeid)) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 78,\n\t\t 'errormsg' => 'Invalid nodeid specified');\n\t}\n\n\tif(! checkUserHasPriv(\"userGrant\", $user['id'], $nodeid)) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 52,\n\t\t 'errormsg' => 'Unable to add a user group to this node');\n\t}\n\n\t$validate = array('name' => $name,\n\t 'affiliation' => $affiliation);\n\t$rc = validateAPIgroupInput($validate, 1);\n\tif($rc['status'] == 'error')\n\t\treturn $rc;\n\n\t$groupid = $rc['id'];\n\t#$name = \"$name@$affiliation\";\n\t$perms = explode(':', $permissions);\n\t$usertypes = getTypes('users');\n\tarray_push($usertypes[\"users\"], \"block\");\n\tarray_push($usertypes[\"users\"], \"cascade\");\n\n\t$diff = array_diff($perms, $usertypes['users']);\n\tif(count($diff) || (count($perms) == 1 && $perms[0] == 'cascade')) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 66,\n\t\t 'errormsg' => 'Invalid or missing permissions list supplied');\n\t}\n\n\t$cnp = getNodeCascadePrivileges($nodeid, \"usergroups\");\n\t$np = getNodePrivileges($nodeid, \"usergroups\", $cnp);\n\n\t$diff = array_diff($perms, $np['usergroups'][$name]['privs']);\n\tif(empty($diff))\n\t\treturn array('status' => 'success');\n\n\tupdateUserOrGroupPrivs($groupid, $nodeid, $diff, array(), \"group\");\n\treturn array('status' => 'success');\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " function update_optiongroup_master() {\n global $db;\n\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $og = new optiongroup_master($id);\n $oldtitle = $og->title;\n $og->update($this->params);\n \n // if the title of the master changed we should update the option groups that are already using it.\n if ($oldtitle != $og->title) {\n $db->sql('UPDATE '.$db->prefix.'optiongroup SET title=\"'.$og->title.'\" WHERE title=\"'.$oldtitle.'\"');\n }\n \n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t\t} elseif (isset($graph['data_query_name'])) {\n\t\t\t\tif (isset($prev_data_query_name)) {\n\t\t\t\t\tif ($prev_data_query_name != $graph['data_query_name']) {\n\t\t\t\t\t\t$print = true;\n\t\t\t\t\t\t$prev_data_query_name = $graph['data_query_name'];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$print = false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$print = true;\n\t\t\t\t\t$prev_data_query_name = $graph['data_query_name'];\n\t\t\t\t}\n\n\t\t\t\tif ($print) {\n\t\t\t\t\tif (!$start) {\n\t\t\t\t\t\twhile(($i % $columns) != 0) {\n\t\t\t\t\t\t\tprint \"\";\n\t\t\t\t\t\t\t$i++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tprint \"\\n\";\n\t\t\t\t\t}\n\n\t\t\t\t\tprint \"\n\t\t\t\t\t\t\t\" . __('Data Query:') . ' ' . $graph['data_query_name'] . \"\n\t\t\t\t\t\t\\n\";\n\t\t\t\t\t$i = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ($i == 0) {\n\t\t\t\tprint \"\\n\";\n\t\t\t\t$start = false;\n\t\t\t}\n\n\t\t\t?>\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t\t\t
    ' graph_width='' graph_height=''>
    \n\t\t\t\t\t\t\t\" . htmlspecialchars($graph['title_cache']) . '' : '');?>\n\t\t\t\t\t\t
    ' class='noprint graphDrillDown'>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\n\t\t\t\\n\";\n\t\t\t\t$start = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!$start) {\n\t\t\twhile(($i % $columns) != 0) {\n\t\t\t\tprint \"\";\n\t\t\t\t$i++;\n\t\t\t}\n\n\t\t\tprint \"\\n\";\n\t\t}\n\t} else {", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tpublic function quicksearch($text)\r\n\t{\r\n\t\tglobal $DB;\r\n\t\tglobal $website;\r\n\t\t\r\n\t\t$like = ' LIKE '.protect('%'.$text.'%');\r\n\t\t\r\n\t\t// we search for the IDs at the dictionary NOW (to avoid inefficient requests)\r\n\t\t\r\n\t\t$DB->query('SELECT DISTINCT (nvw.node_id)\r\n\t\t\t\t\t FROM nv_webdictionary nvw\r\n\t\t\t\t\t WHERE nvw.node_type = \"feed\" \r\n\t\t\t\t\t AND nvw.website = '.$website->id.' \r\n\t\t\t\t\t AND nvw.text '.$like, 'array');\r\n\t\t\t\t\t\t \r\n\t\t$dict_ids = $DB->result(\"node_id\");\r\n\t\t\r\n\t\t// all columns to look for\t\r\n\t\t$cols[] = 'i.id' . $like;\r\n\r\n\t\tif(!empty($dict_ids))\r\n\t\t\t$cols[] = 'i.id IN ('.implode(',', $dict_ids).')';\r\n\t\t\t\r\n\t\t$where = ' AND ( ';\t\r\n\t\t$where.= implode( ' OR ', $cols); \r\n\t\t$where .= ')';\r\n\t\t\r\n\t\treturn $where;\r\n\t}\t\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " print_r($single_error);\n }\n\n echo '';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function testMalformedVerbatimClosingTag()\n {\n $parser = new JBBCode\\Parser();\n $parser->addCodeDefinitionSet(new JBBCode\\DefaultCodeDefinitionSet());\n $parser->addBBCode('verbatim', '{param}', false, false);\n $parser->parse('[verbatim]yo this [b]text should not be bold[/b][/verbatim');\n $this->assertEquals('yo this [b]text should not be bold[/b][/verbatim', $parser->getAsHtml());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function save()\n {\n $project = $this->getProject();\n\n $values = $this->request->getValues();\n list($valid, $errors) = $this->categoryValidator->validateCreation($values);\n\n if ($valid) {\n if ($this->categoryModel->create($values) !== false) {\n $this->flash->success(t('Your category have been created successfully.'));\n $this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])), true);\n return;\n } else {\n $errors = array('name' => array(t('Another category with the same name exists in this project')));\n }\n }\n\n $this->create($values, $errors);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " function reparent_standalone() {\r\n $standalone = $this->section->find($this->params['page']);\r\n if ($standalone) {\r\n $standalone->parent = $this->params['parent'];\r\n $standalone->update();\r\n expSession::clearAllUsersSessionCache('navigation');\r\n expHistory::back();\r\n } else {\r\n notfoundController::handle_not_found();\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testSameInstanceWhenSameProtocol()\n {\n $r = new Response();\n $this->assertSame($r, $r->withProtocolVersion('1.1'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function backup($type='json')\r\n {\r\n global $DB;\r\n global $website;\r\n\r\n $out = array();\r\n $DB->query('SELECT * FROM nv_products WHERE website = '.protect($website->id), 'object');\r\n\r\n if($type='json')\r\n $out = json_encode($DB->result());\r\n\r\n return $out;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function upload() {\n if (!AuthUser::hasPermission('file_manager_upload')) {\n Flash::set('error', __('You do not have sufficient permissions to upload a file.'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n\n // CSRF checks\n if (isset($_POST['csrf_token'])) {\n $csrf_token = $_POST['csrf_token'];\n if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/upload')) {\n Flash::set('error', __('Invalid CSRF token found!'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n }\n else {\n Flash::set('error', __('No CSRF token found!'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n\n $mask = Plugin::getSetting('umask', 'file_manager');\n umask(octdec($mask));\n\n $data = $_POST['upload'];\n $path = str_replace('..', '', $data['path']);\n $overwrite = isset($data['overwrite']) ? true : false;\n\n // Clean filenames\n $filename = preg_replace('/ /', '_', $_FILES['upload_file']['name']);\n $filename = preg_replace('/[^a-z0-9_\\-\\.]/i', '', $filename);\n\n $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));\n if (in_array($ext, ['php', 'php3', 'php4', 'inc'])) {\n Flash::set('error', __('Not allowed to upload files with extension :ext', $ext));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n\n if (isset($_FILES)) {\n $file = $this->_upload_file($filename, FILES_DIR . '/' . $path . '/', $_FILES['upload_file']['tmp_name'], $overwrite);\n\n if ($file === false)\n Flash::set('error', __('File has not been uploaded!'));\n }\n redirect(get_url('plugin/file_manager/browse/' . $path));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " private function _getDemoMessage()\n {\n $message = '' . __('phpMyAdmin Demo Server') . ': ';\n if (@file_exists('./revision-info.php')) {\n include './revision-info.php';\n $message .= sprintf(\n __('Currently running Git revision %1$s from the %2$s branch.'),\n ''\n . $revision . '',\n ''\n . $branch . ''\n );\n } else {\n $message .= __('Git information missing!');\n }\n\n return Message::notice($message)->getDisplay();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " public function buildControl() {\r\n $control = new colorcontrol();\r\n if (!empty($this->params['value'])) $control->value = $this->params['value'];\r\n if ($this->params['value'][0] != '#') $this->params['value'] = '#' . $this->params['value'];\r\n $control->default = $this->params['value'];\r\n if (!empty($this->params['hide'])) $control->hide = $this->params['hide'];\r\n if (isset($this->params['flip'])) $control->flip = $this->params['flip'];\r\n $this->params['name'] = !empty($this->params['name']) ? $this->params['name'] : '';\r\n $control->name = $this->params['name'];\r\n $this->params['id'] = !empty($this->params['id']) ? $this->params['id'] : '';\r\n $control->id = isset($this->params['id']) && $this->params['id'] != \"\" ? $this->params['id'] : \"\";\r\n //echo $control->id;\r\n if (empty($control->id)) $control->id = $this->params['name'];\r\n if (empty($control->name)) $control->name = $this->params['id'];\r\n\r\n // attempt to translate the label\r\n if (!empty($this->params['label'])) {\r\n $this->params['label'] = gt($this->params['label']);\r\n } else {\r\n $this->params['label'] = null;\r\n }\r\n echo $control->toHTML($this->params['label'], $this->params['name']);\r\n// $ar = new expAjaxReply(200, gt('The control was created'), json_encode(array('data'=>$code)));\r\n// $ar->send();\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " private function dumpParameter($name)\n {\n if ($this->container->isCompiled() && $this->container->hasParameter($name)) {\n $value = $this->container->getParameter($name);\n $dumpedValue = $this->dumpValue($value, false);\n\n if (!$value || !\\is_array($value)) {\n return $dumpedValue;\n }\n\n if (!preg_match(\"/\\\\\\$this->(?:getEnv\\('(?:\\w++:)*+\\w++'\\)|targetDirs\\[\\d++\\])/\", $dumpedValue)) {\n return sprintf(\"\\$this->parameters['%s']\", $name);\n }\n }\n\n return sprintf(\"\\$this->getParameter('%s')\", $name);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function withQuery($query)\n {\n if (!is_string($query) && !method_exists($query, '__toString')) {\n throw new \\InvalidArgumentException(\n 'Query string must be a string'\n );\n }\n\n $query = (string) $query;\n if (substr($query, 0, 1) === '?') {\n $query = substr($query, 1);\n }\n\n $query = $this->filterQueryAndFragment($query);\n\n if ($this->query === $query) {\n return $this;\n }\n\n $new = clone $this;\n $new->query = $query;\n return $new;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function test_create_nonce_url() {\n $url = yourls_nonce_url( rand_str(), rand_str(), rand_str(), rand_str() );\n $this->assertTrue( is_string($url) );\n // $this->assertIsString($url);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " function ac_sigleme($str, $name, $id) {\n global $cms_db, $sess;\n\n $sess->gc( true );\n\t if( $id >= 1 && $this->session_enabled ) {\n $this->db->query(sprintf(\"delete from %s where name = '%s' and sid != '%s' and user_id = '%s'\",\n $cms_db[sessions],\n addslashes($name),\n $str,\n $id));\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tstatic public function editCategory($_category = null, $_id = 0, $_order = 1)\n\t{\n\t\tif ($_category != null && $_category != '' && $_id != 0) {\n\t\t\tif ($_order < 1) {\n\t\t\t\t$_order = 1;\n\t\t\t}\n\t\t\t\n\t\t\t$upd_stmt = Database::prepare(\"\n\t\t\t\tUPDATE `\" . TABLE_PANEL_TICKET_CATS . \"` SET\n\t\t\t\t\t`name` = :name,\n\t\t\t\t\t`logicalorder` = :lo\n WHERE `id` = :id\n\t\t\t\");\n\t\t\tDatabase::pexecute($upd_stmt, array(\n\t\t\t\t'name' => $_category,\n\t\t\t\t'lo' => $_order,\n\t\t\t\t'id' => $_id\n\t\t\t));\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": "\tpublic function check(&$params){\n $tags = $this->config['options']['tags']['value'];\n $tags = is_array($tags) ? $tags : Tags::parseTags($tags, true);\n if(!empty($tags) && isset($params['tags'])){ // Check passed params to be sure they're set\n if(!is_array($params['tags'])){\n $params['tags'] = explode(',', $params['tags']);\n }\n $params['tags'] = array_map(function($item){ \n return preg_replace('/^#/','', $item); \n }, $params['tags']);\n\n // must have at least 1 tag in the list:\n if(count(array_intersect($params['tags'], $tags)) > 0){\n return $this->checkConditions($params);\n }else{\n return array(false, Yii::t('studio','No tags on the record matched those in the tag trigger criteria.'));\n }\n }else{ // config is invalid or record has no tags (tags are not optional)\n return array(false, empty($tags) ? Yii::t('studio','No tags in the trigger criteria!') : Yii::t('studio','Tags parameter missing!'));\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function passwordvisit_input_password(&$template)\n{\n global $zbp;\n if (isset($_POST['password']) && $_POST['password'] != '') {\n $article = $template->GetTags('article');\n if ($article->Metas->passwordvisit_password != '') {\n if (GetVars('password', 'POST') == $article->Metas->passwordvisit_password) {\n return;\n } else {\n echo '';\n die();\n }\n } else {\n if (GetVars('password', 'POST') == $zbp->Config('passwordvisit')->default_password) {\n return;\n } else {\n echo '';\n die();\n }\n }\n } else {\n $article = $template->GetTags('article');\n if ($zbp->Config('passwordvisit')->all_encrypt || $article->Metas->passwordvisit_enable_encrypt) {\n $article->Content = $zbp->Config('passwordvisit')->default_text . '
    ';\n $template->SetTags('article', $article);\n }\n }\n}", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "\tfunction manage () {\n\t expHistory::set('viewable', $this->params);\n\n\t\t$vendor = new vendor();\n\t\t$vendors = $vendor->find('all');\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\n\t\tassign_to_template(array(\n 'purchase_orders'=>$purchase_orders,\n 'vendors' => $vendors,\n 'vendor_id' => @$this->params['vendor']\n ));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction getTextColumns($table) {\n\t\t$sql = \"SHOW COLUMNS FROM \" . $this->prefix.$table . \" WHERE type = 'text' OR type like 'varchar%'\";\n\t\t$res = @mysqli_query($this->connection, $sql);\n\t\tif ($res == null)\n return array();\n\t\t$records = array();\n\t\twhile($row = mysqli_fetch_object($res)) {\n\t\t\t$records[] = $row->Field;\n\t\t}\n\n\t\treturn $records;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $files[$key]->save();\n }\n\n// eDebug($files,true);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic static function extendTimeLimit($time = null) {\n\t\tstatic $defLimit = null;\n\t\tif (is_null($defLimit)) {\n\t\t\t$defLimit = ini_get('max_execution_time');\n\t\t}\n\t\tif ($defLimit != 0) {\n\t\t\t$time = is_null($time)? $defLimit : max($defLimit, $time);\n\t\t\tset_time_limit($time);\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function remove()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $category = $this->getCategory();\n\n if ($this->categoryModel->remove($category['id'])) {\n $this->flash->success(t('Category removed successfully.'));\n } else {\n $this->flash->failure(t('Unable to remove this category.'));\n }\n\n $this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function testSerializeCleanupSocket()\n {\n $this->socket->expects($this->at(0))->method('connect')->will($this->returnValue(true));\n $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(\"220 Welcome message\\r\\n\"));\n $this->socket->expects($this->at(2))->method('write')->with(\"EHLO localhost\\r\\n\");\n $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(\"250 OK\\r\\n\"));\n\n $smtpTransport = new SmtpTestTransport();\n $smtpTransport->setSocket($this->socket);\n $smtpTransport->connect();\n\n $result = unserialize(serialize($smtpTransport));\n $this->assertAttributeEquals(null, '_socket', $result);\n $this->assertFalse($result->connected());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $action = $this->getAction($project);\n\n $this->response->html($this->helper->layout->project('action/remove', array(\n 'action' => $action,\n 'available_events' => $this->eventManager->getAll(),\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'project' => $project,\n 'title' => t('Remove an action')\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": "function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)\n{\n\t// List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n\t// Char '>' '<' '|' '$' and ';' are special chars for shells.\n\t// Char '/' and '\\' are file delimiters.\n\t$filesystem_forbidden_chars = array('<', '>', '/', '\\\\', '?', '*', '|', '\"', ':', '\u00b0', '$', ';');\n\treturn dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "\tpublic function delete_version() {\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }\n\t \n\t // get the version\n\t $version = new help_version($this->params['id']);\n\t if (empty($version->id)) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }\n\t \n\t // if we have errors than lets get outta here!\n\t if (!expQueue::isQueueEmpty('error')) expHistory::back();\n\t \n\t // delete the version\n\t $version->delete();\n\t \n\t expSession::un_set('help-version');\n\n\t flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));\n\t expHistory::back();\t \n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " protected function getComment()\n {\n $comment = $this->commentModel->getById($this->request->getIntegerParam('comment_id'));\n\n if (empty($comment)) {\n throw new PageNotFoundException();\n }\n\n if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) {\n throw new AccessForbiddenException();\n }\n\n return $comment;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " function fopen($filename, $mode)\n {\n if (\\yiiunit\\framework\\base\\SecurityTest::$fopen !== null) {\n return \\yiiunit\\framework\\base\\SecurityTest::$fopen;\n }\n\n return \\fopen($filename, $mode);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": " return $this->mainPhase($token);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $sort = in_array(strtolower($val), array('asc', 'desc')) ? ' ' . $val : '';\n $array[] = $this->parseKey($key, true) . $sort;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tprotected function LoadSize($blob)\n\t{\n\t\tif (!$blob)\n\t\t\treturn;\n\n\t\t$args = array();\n\t\t$args[] = '-s';\n\t\t$args[] = escapeshellarg($blob->GetHash());\n\n\t\treturn $this->exe->Execute($blob->GetProject()->GetPath(), GIT_CAT_FILE, $args);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " function ac_checkme($id, $name) {\n global $cms_db;\n\n $ret = true;\n $cquery = sprintf(\"select count(*) from %s where sid='%s' and name='%s'\",\n $cms_db['sessions'],\n addslashes($id),\n addslashes($name));\n $squery = sprintf(\"select sid from %s where sid = '%s' and name = '%s'\",\n $cms_db['sessions'],\n addslashes($id),\n addslashes($name));\n $this->db->query($squery);\n if ( $this->db->affected_rows() == 0\n && $this->db->query($cquery)\n\t && $this->db->next_record() && $this->db->f(0) == 0 ) {\n // nothing found here\n $ret = false;\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __toString()\n {\n return self::createUriString(\n $this->scheme,\n $this->getAuthority(),\n $this->path,\n $this->query,\n $this->fragment\n );\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach ($events as $event) {\n $extevents[$date][] = $event;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function uriComponentsEncodingProvider()\n {\n $unreserved = 'a-zA-Z0-9.-_~!$&\\'()*+,;=:@';\n\n return [\n // Percent encode spaces\n ['/pa th?q=va lue#frag ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'],\n // Percent encode multibyte\n ['/\u20ac?\u20ac#\u20ac', '/%E2%82%AC', '%E2%82%AC', '%E2%82%AC', '/%E2%82%AC?%E2%82%AC#%E2%82%AC'],\n // Don't encode something that's already encoded\n ['/pa%20th?q=va%20lue#frag%20ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'],\n // Percent encode invalid percent encodings\n ['/pa%2-th?q=va%2-lue#frag%2-ment', '/pa%252-th', 'q=va%252-lue', 'frag%252-ment', '/pa%252-th?q=va%252-lue#frag%252-ment'],\n // Don't encode path segments\n ['/pa/th//two?q=va/lue#frag/ment', '/pa/th//two', 'q=va/lue', 'frag/ment', '/pa/th//two?q=va/lue#frag/ment'],\n // Don't encode unreserved chars or sub-delimiters\n [\"/$unreserved?$unreserved#$unreserved\", \"/$unreserved\", $unreserved, $unreserved, \"/$unreserved?$unreserved#$unreserved\"],\n // Encoded unreserved chars are not decoded\n ['/p%61th?q=v%61lue#fr%61gment', '/p%61th', 'q=v%61lue', 'fr%61gment', '/p%61th?q=v%61lue#fr%61gment'],\n ];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function cleanLink($fulllink)\n { \n if(substr($fulllink, -1) == '/') $fulllink = substr($fulllink, 0, -1); \n return $fulllink; \n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testForBinExec($value)\n {\n if (substr($value, 0, 7) === \"phar://\") {\n return 'Phar protocol not allowed.';\n }\n $finfo = finfo_open(FILEINFO_MIME_TYPE);\n if ($value === '') {\n return true;\n }\n if (is_executable($value)) {\n if (finfo_file($finfo, $value) == \"application/x-executable\" || finfo_file($finfo, $value) == \"application/x-sharedlib\") {\n finfo_close($finfo);\n return true;\n } else {\n return 'Binary file not executable. It is of type: ' . finfo_file($finfo, $value);\n }\n } else {\n return false;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " foreach ($data['alertred'] as $alert) {\n # code...\n echo \"
  • $alert
  • \\n\";\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $contents = ['form' => tep_draw_form('customer_data_groups', 'customer_data_groups.php', 'page=' . $_GET['page'] . '&action=insert')];", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function addAllowedValues($key, $allowed) {\n $this->info[$key]->allowed = $allowed;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $tags = array_merge($matches, $tags);\n }\n $tags = array_unique($tags);\n return $tags;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function load($mod)\n {\n $file = GX_MOD.'/'.$mod.'/index.php';\n if (file_exists($file)) {\n include $file;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function getTemplateHierarchyFlat($parent, $depth = 1) {\n global $db;\n\n $arr = array();\n $kids = $db->selectObjects('section_template', 'parent=' . $parent, 'rank');\n//\t\t$kids = expSorter::sort(array('array'=>$kids,'sortby'=>'rank', 'order'=>'ASC'));\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\n $page = $kids[$i];\n $page->depth = $depth;\n $page->first = ($i == 0 ? 1 : 0);\n $page->last = ($i == count($kids) - 1 ? 1 : 0);\n $arr[] = $page;\n $arr = array_merge($arr, self::getTemplateHierarchyFlat($page->id, $depth + 1));\n }\n return $arr;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function db_start()\n{\n global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;\n\n switch ($DatabaseType) {\n case 'mysqli':\n $connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort);\n break;\n }\n\n // Error code for both.\n if ($connection === false) {\n switch ($DatabaseType) {\n case 'mysqli':\n $errormessage = mysqli_error($connection);\n break;\n }\n db_show_error(\"\", \"\" . _couldNotConnectToDatabase . \": $DatabaseServer\", $errormessage);\n }\n return $connection;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function download($disposition=false, $expires=false) {\n $disposition = $disposition ?: 'inline';\n $bk = $this->open();\n if ($bk->sendRedirectUrl($disposition))\n return;\n $ttl = ($expires) ? $expires - Misc::gmtime() : false;\n $this->makeCacheable($ttl);\n $type = $this->getType() ?: 'application/octet-stream';\n Http::download($this->getName(), $type, null, 'inline');\n header('Content-Length: '.$this->getSize());\n $this->sendData(false);\n exit();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-434", "cwe_name": "Unrestricted Upload of File with Dangerous Type", "description": "The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.", "url": "https://cwe.mitre.org/data/definitions/434.html", "label_name": "vulnerable"} {"code": " function preview()\n {\n if ($this->params['id'] == 0) { // we want the default editor\n $demo = new stdClass();\n $demo->id = 0;\n $demo->name = \"Default\";\n if ($this->params['editor'] == 'ckeditor') {\n $demo->skin = 'kama';\n } elseif ($this->params['editor'] == 'tinymce') {\n $demo->skin = 'lightgray';\n }\n } else {\n $demo = self::getEditorSettings($this->params['id'], expString::escape($this->params['editor']));\n }\n assign_to_template(\n array(\n 'demo' => $demo,\n 'editor' => $this->params['editor']\n )\n );\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " public function manage_messages() {\n expHistory::set('manageable', $this->params);\n \n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status_messages',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'body',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n\t\t\t//'columns'=>array('Name'=>'title')\n ));\n\n //eDebug($page);\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function get_discount_value()\n {\n if (empty($this->coupon_data)) {\n return false;\n }\n\n $apply_code = false;\n if ($this->sum() >= $this->coupon_data['total_amount']) {\n $apply_code = true;\n }\n\n if ($apply_code) {\n return floatval($this->coupon_data['discount_value']);\n }\n\n return false;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " public function validate($string, $config, $context) {\n\n static $allowed_values = array(\n 'line-through' => true,\n 'overline' => true,\n 'underline' => true,\n );\n\n $string = strtolower($this->parseCDATA($string));\n\n if ($string === 'none') return $string;\n\n $parts = explode(' ', $string);\n $final = '';\n foreach ($parts as $part) {\n if (isset($allowed_values[$part])) {\n $final .= $part . ' ';\n }\n }\n $final = rtrim($final);\n if ($final === '') return false;\n return $final;\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testPages()\n {\n \\MicroweberPackages\\Multilanguage\\MultilanguageHelpers::setMultilanguageEnabled(false);\n\n $this->browse(function (Browser $browser) {\n\n $browser->within(new AdminLogin(), function ($browser) {\n $browser->fillForm();\n });\n\n $routeCollection = Route::getRoutes();\n foreach ($routeCollection as $value) {\n if ($value->getActionMethod() == 'GET') {\n continue;\n }\n if (strpos($value->uri(), 'admin') !== false) {\n $browser->visit($value->uri());\n\n $browser->within(new ChekForJavascriptErrors(), function ($browser) {\n $browser->validate();\n });\n\n // $browser->pause(2000);\n }\n }\n\n\n });\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " function prepareInputForUpdate($input) {\n\n if (isset($input[\"rootdn_passwd\"])) {\n if (empty($input[\"rootdn_passwd\"])) {\n unset($input[\"rootdn_passwd\"]);\n } else {\n $input[\"rootdn_passwd\"] = Toolbox::encrypt(stripslashes($input[\"rootdn_passwd\"]),\n GLPIKEY);\n }\n }\n\n if (isset($input[\"_blank_passwd\"]) && $input[\"_blank_passwd\"]) {\n $input['rootdn_passwd'] = '';\n }\n\n // Set attributes in lower case\n if (count($input)) {\n foreach ($input as $key => $val) {\n if (preg_match('/_field$/', $key)) {\n $input[$key] = Toolbox::strtolower($val);\n }\n }\n }\n\n //do not permit to override sync_field\n if ($this->isSyncFieldEnabled()\n && isset($input['sync_field'])\n && $this->isSyncFieldUsed()\n ) {\n if ($input['sync_field'] == $this->fields['sync_field']) {\n unset($input['sync_field']);\n } else {\n Session::addMessageAfterRedirect(\n __('Synchronization field cannot be changed once in use.'),\n false,\n ERROR\n );\n return false;\n };\n }\n return $input;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-798", "cwe_name": "Use of Hard-coded Credentials", "description": "The software contains hard-coded credentials, such as a password or cryptographic key, which it uses for its own inbound authentication, outbound communication to external components, or encryption of internal data.", "url": "https://cwe.mitre.org/data/definitions/798.html", "label_name": "vulnerable"} {"code": " }elseif(!in_array($k, $arr) && $k != 'paging'){\r\n //self::error('404');\r\n }else{\r\n\r\n self::incFront('default');\r\n\r\n }\r\n\r\n }\r\n\r\n }else{\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function search() {\n// global $db, $user;\n global $db;\n\n $sql = \"select DISTINCT(a.id) as id, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email \";\n $sql .= \"from \" . $db->prefix . \"addresses as a \"; //R JOIN \" . \n //$db->prefix . \"billingmethods as bm ON bm.addresses_id=a.id \";\n $sql .= \" WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('\" . $this->params['query'] .\n \"*' IN BOOLEAN MODE) \";\n $sql .= \"order by match (a.firstname,a.lastname,a.email,a.organization) against ('\" . $this->params['query'] . \"*' IN BOOLEAN MODE) ASC LIMIT 12\";\n $res = $db->selectObjectsBySql($sql);\n foreach ($res as $key=>$record) {\n $res[$key]->title = $record->firstname . ' ' . $record->lastname;\n }\n //eDebug($sql);\n $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testDefaultConstructor()\n {\n $r = new Response();\n $this->assertSame(200, $r->getStatusCode());\n $this->assertSame('1.1', $r->getProtocolVersion());\n $this->assertSame('OK', $r->getReasonPhrase());\n $this->assertSame([], $r->getHeaders());\n $this->assertInstanceOf('Psr\\Http\\Message\\StreamInterface', $r->getBody());\n $this->assertSame('', (string) $r->getBody());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function handler($vars)\n {\n self::$vars();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function manage()\n {\n expHistory::set('manageable',$this->params);\n $gc = new geoCountry();\n $countries = $gc->find('all');\n\n $gr = new geoRegion();\n $regions = $gr->find('all',null,'rank asc,name asc');\n\n assign_to_template(array(\n 'countries'=>$countries,\n 'regions'=>$regions\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function notify_edge_mode() {\n w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');\n w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin_ui.php');\n $message = sprintf(__('

    You can now keep W3 Total Cache up-to-date without having to worry about new features breaking your website. There will be more releases with bug fixes, security fixes and settings updates.

    \n

    Also, you can now try out our new features as soon as they\\'re ready. %s to enable \"edge mode\" and unlock pre-release features. %s

    ', 'w3-total-cache')\n ,'' . __('Click Here', 'w3-total-cache') . ''\n , w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'edge_mode', '', true,'','w3tc_default_hide_note_custom')\n );\n w3_e_notification_box($message, 'edge-mode');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public function testCanConstructWithStatusCode()\n {\n $r = new Response(404);\n $this->assertSame(404, $r->getStatusCode());\n $this->assertSame('Not Found', $r->getReasonPhrase());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function teampass_decrypt_pw($encrypted, $salt, $rand_key, $itcount = 2072)\n{\n $encrypted = base64_decode($encrypted);\n $pass_salt = substr($encrypted, -64);\n $encrypted = substr($encrypted, 0, -64);\n $key = teampass_pbkdf2_hash($salt, $pass_salt, $itcount, 16, 32);\n $iv = base64_decode(substr($encrypted, 0, 43) . '==');\n $encrypted = substr($encrypted, 43);\n $mac = substr($encrypted, -64);\n $encrypted = substr($encrypted, 0, -64);\n if ($mac !== hash_hmac('sha256', $encrypted, $salt)) return null;\n return substr(rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, 'ctr', $iv), \"\\0\\4\"), strlen($rand_key));\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $swimlane = $this->getSwimlane();\n\n $this->response->html($this->helper->layout->project('swimlane/remove', array(\n 'project' => $project,\n 'swimlane' => $swimlane,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic function remove($key)\n\t{\n\t\t$session =& $this->getSessionRef($key);\n\t\tunset($session);\n\t\t\n\t\treturn $this;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function scan_page($parent_id) {\n global $db;\n\n $sections = $db->selectObjects('section','parent=' . $parent_id);\n $ret = '';\n foreach ($sections as $page) {\n $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\n $ret .= scan_container($cLoc, $page->id);\n $ret .= scan_page($page->id);\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function toolbar() {\n// global $user;\n\n $menu = array();\n\t\t$dirs = array(\n\t\t\tBASE.'framework/modules/administration/menus',\n\t\t\tBASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'\n\t\t);\n\n\t\tforeach ($dirs as $dir) {\n\t\t if (is_readable($dir)) {\n\t\t\t $dh = opendir($dir);\n\t\t\t while (($file = readdir($dh)) !== false) {\n\t\t\t\t if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {\n\t\t\t\t\t $menu[substr($file,0,-4)] = include($dir.'/'.$file);\n if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\t\t}\n\n // sort the top level menus alphabetically by filename\n\t\tksort($menu);\t\t\n\t\t$sorted = array();\n\t\tforeach($menu as $m) $sorted[] = $m;\n \n // slingbar position\n if (isset($_COOKIE['slingbar-top'])){\n $top = $_COOKIE['slingbar-top'];\n } else {\n $top = SLINGBAR_TOP;\n }\n \n\t\tassign_to_template(array(\n 'menu'=>(bs3()) ? $sorted : json_encode($sorted),\n \"top\"=>$top\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function navtojson() {\r\n return json_encode(self::navhierarchy());\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function _date2timestamp( $datetime, $wtz=null ) {\r\n if( !isset( $datetime['hour'] )) $datetime['hour'] = 0;\r\n if( !isset( $datetime['min'] )) $datetime['min'] = 0;\r\n if( !isset( $datetime['sec'] )) $datetime['sec'] = 0;\r\n if( empty( $wtz ) && ( !isset( $datetime['tz'] ) || empty( $datetime['tz'] )))\r\n return mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\r\n $output = $offset = 0;\r\n if( empty( $wtz )) {\r\n if( iCalUtilityFunctions::_isOffset( $datetime['tz'] )) {\r\n $offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) * -1;\r\n $wtz = 'UTC';\r\n }\r\n else\r\n $wtz = $datetime['tz'];\r\n }\r\n if(( 'Z' == $wtz ) || ( 'GMT' == strtoupper( $wtz )))\r\n $wtz = 'UTC';\r\n try {\r\n $strdate = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['min'], $datetime['sec'] );\r\n $d = new DateTime( $strdate, new DateTimeZone( $wtz ));\r\n if( 0 != $offset ) // adjust for offset\r\n $d->modify( $offset.' seconds' );\r\n $output = $d->format( 'U' );\r\n unset( $d );\r\n }\r\n catch( Exception $e ) {\r\n $output = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\r\n }\r\n return $output;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($val as $k => $v) {\n unset($process[$key][$k]);\n $stripTags = \\in_array($k, $stripTagsWhiteList) ? false : $stripTagsConf;\n $allowedHtmlTags = \\array_key_exists($k, $allowanceList) ? $allowanceList[$k][self::ALLOWED_HTML_TAGS_KEY] : [];\n $allowedAttributes = \\array_key_exists($k, $allowanceList) ? $allowanceList[$k][self::ALLOWED_ATTRIBUTES_KEY] : [];\n\n if (\\is_string($k)) {\n $filteredKey = self::filterValue($k, $regex, $stripTags, $allowedHtmlTags, $allowedAttributes);\n } else {\n $filteredKey = $k;\n }\n\n if ($filteredKey === '' || $filteredKey === null) {\n continue;\n }\n\n if (\\is_array($v)) {\n $process[$key][$filteredKey] = self::filterArrayValue($v, $regex, $stripTags, $allowedHtmlTags, $allowedAttributes);\n continue;\n }\n\n if (\\is_string($v)) {\n $process[$key][$filteredKey] = self::filterValue($v, $regex, $stripTags, $allowedHtmlTags, $allowedAttributes);\n continue;\n }\n\n $process[$key][$filteredKey] = $v;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function manage() {\n expHistory::set('manageable', $this->params);\n\n // build out a SQL query that gets all the data we need and is sortable.\n $sql = 'SELECT b.*, c.title as companyname, f.expfiles_id as file_id ';\n $sql .= 'FROM '.DB_TABLE_PREFIX.'_banner b, '.DB_TABLE_PREFIX.'_companies c , '.DB_TABLE_PREFIX.'_content_expFiles f ';\n $sql .= 'WHERE b.companies_id = c.id AND (b.id = f.content_id AND f.content_type=\"banner\")';\n\n\t\t$page = new expPaginator(array(\n\t\t\t'model'=>'banner',\n\t\t\t'sql'=>$sql,\n\t\t\t'order'=>'title',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n\t\t\t'columns'=>array(\n gt('Title')=>'title',\n gt('Company')=>'companyname',\n gt('Impressions')=>'impressions',\n gt('Clicks')=>'clicks'\n )\n ));\n\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function restart($sMessage = '')\n {\n $_COOKIE['sessionID'] = phpAds_SessionRegenerateId();\n OA_Auth::displayLogin($sMessage, $_COOKIE['sessionID']);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": " public static function Xclean($vars)\n {\n $var = htmlspecialchars_decode($vars, ENT_QUOTES | ENT_HTML5);\n // $var = html_entity_decode($vars);\n return $var;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct() {\n $this->parser = new HTMLPurifier_URIParser();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " private function getSwimlane()\n {\n $swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));\n\n if (empty($swimlane)) {\n throw new PageNotFoundException();\n }\n\n return $swimlane;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));\n\n $this->response->html($this->helper->layout->project('custom_filter/remove', array(\n 'project' => $project,\n 'filter' => $filter,\n 'title' => t('Remove a custom filter')\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " $logo = \"\";\n }else{\n $logo = \"\";\n }\n return $logo;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static function getHelpVersion($version_id) {\n global $db;\n\n return $db->selectValue('help_version', 'version', 'id=\"'.intval($version_id).'\"');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $task = $this->getTask();\n $link = $this->getTaskLink();\n\n $this->response->html($this->template->render('task_internal_link/remove', array(\n 'link' => $link,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " $count += $db->dropTable($basename);\n }\n \n flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " function selectArraysBySql($sql) {\n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return array();\n $arrays = array();\n for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)\n $arrays[] = mysqli_fetch_assoc($res);\n return $arrays;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\tstatic function validUTF($string) {\n\t\tif(!mb_check_encoding($string, 'UTF-8') OR !($string === mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {\n\t\t\treturn false;\n\t\t}\t\t\n\t\treturn true;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t\t$user = db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($check['user']), 'username');\n\t\t\tform_alternate_row('line' . $check['id']);\n\t\t\t$name = get_data_source_title($check['datasource']);\n\t\t\t$title = $name;\n\t\t\tif (strlen($name) > 50) {\n\t\t\t\t$name = substr($name, 0, 50);\n\t\t\t}\n\t\t\tform_selectable_cell('' . $name . '', $check['id']);\n\t\t\tform_selectable_cell($user, $check['id']);\n\t\t\tform_selectable_cell(date('F j, Y, G:i', $check['started']), $check['id']);\n\t\t\tform_selectable_cell($check['datasource'], $check['id']);\n\t\t\tform_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon($info['active']), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'text-align: center;');\n\t\t\tform_selectable_cell('' . html_escape(strlen(trim($issue_line)) ? $issue_line : '') . '', $check['id']);\n\t\t\tform_checkbox_cell($check['id'], $check['id']);\n\t\t\tform_end_row();\n\t\t}\n\t}else{", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function setTagName($tagName)\n {\n $this->tagName = strtolower($tagName);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function shippingMethodSave(Request $request) {\n\n if (is_array($request->get('Address'))) {\n $request->merge([\n 'city'=>$request->get('Address')['city'],\n 'zip'=>$request->get('Address')['zip'],\n 'state'=>$request->get('Address')['state'],\n 'address'=>$request->get('Address')['address'],\n ]);\n }\n\n session_append_array('checkout_v2', [\n 'shipping_gw'=> $request->get('shipping_gw'),\n 'city'=> $request->get('city'),\n 'address'=> $request->get('address'),\n 'country'=> $request->get('country'),\n 'state'=> $request->get('state'),\n 'zip'=> $request->get('zip'),\n 'other_info'=> $request->get('other_info'),\n ]);\n\n $checkIfShippingEnabled = app()->shipping_manager->getShippingModules(true);\n if ($checkIfShippingEnabled) {\n $validate = $this->_validateShippingMethod();\n if ($validate['valid'] == false) {\n session_set('errors', $validate['errors']);\n return redirect(route('checkout.shipping_method'));\n }\n }\n // Success\n return redirect(route('checkout.payment_method'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": " public function breadcrumb() {\r\n global $sectionObj;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // Show not only the location of a page in the hierarchy but also the location of a standalone page\r\n $current = new section($id);\r\n if ($current->parent == -1) { // standalone page\r\n $navsections = section::levelTemplate(-1, 0);\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n } else {\r\n $navsections = section::levelTemplate(0, 0);\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction delete_vendor() {\n\t\tglobal $db;\n\t\t\n if (!empty($this->params['id'])){\n\t\t\t$db->delete('vendor', 'id =' .$this->params['id']);\n\t\t}\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function showall() {\r\n global $user, $sectionObj, $sections;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // all we need to do is determine the current section\r\n $navsections = $sections;\r\n if ($sectionObj->parent == -1) {\r\n $current = $sectionObj;\r\n } else {\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) {\n\t\t$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'globalnewfiles' );\n\n\t\tif ( $config->get( 'CreateWikiDatabase' ) === $config->get( 'DBname' ) ) {\n\t\t\t$updater->addExtensionTable(\n\t\t\t\t'gnf_files',\n\t\t\t\t__DIR__ . '/../sql/gnf_files.sql'\n\t\t\t);\n\n\t\t\t$updater->modifyExtensionField(\n\t\t\t\t'gnf_files',\n\t\t\t\t'files_timestamp',\n\t\t\t\t__DIR__ . '/../sql/patches/patch-gnf_files-binary.sql' \n\t\t\t);\n\n\t\t\t$updater->modifyTable(\n \t\t\t\t'gnf_files',\n \t\t\t\t__DIR__ . '/../sql/patches/patch-gnf_files-add-indexes.sql',\n\t\t\t\ttrue\n \t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function manage_messages() {\n expHistory::set('manageable', $this->params);\n \n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status_messages',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'body',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n\t\t\t//'columns'=>array('Name'=>'title')\n ));\n\n //eDebug($page);\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function edit_discount() {\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $discount = new discounts($id);\n\n //grab all user groups\n $group = new group();\n\n //create two 'default' groups:\n $groups = array(\n -1 => 'ALL LOGGED IN USERS',\n -2 => 'ALL NON-LOGGED IN USERS'\n );\n //loop our groups and append them to the array\n // foreach ($group->find() as $g){\n //this is a workaround for older code. Use the previous line if possible:\n $allGroups = group::getAllGroups();\n if (count($allGroups))\n {\n foreach ($allGroups as $g)\n {\n $groups[$g->id] = $g->name;\n };\n }\n //find our selected groups for this discount already\n // eDebug($discount);\n $selected_groups = array();\n if (!empty($discount->group_ids))\n {\n $selected_groups = expUnserialize($discount->group_ids);\n }\n\n if ($discount->minimum_order_amount == \"\") $discount->minimum_order_amount = 0;\n if ($discount->discount_amount == \"\") $discount->discount_amount = 0;\n if ($discount->discount_percent == \"\") $discount->discount_percent = 0;\n\n // get the shipping options and their methods\n $shipping_services = array();\n $shipping_methods = array();\n// $shipping = new shipping();\n foreach (shipping::listAvailableCalculators() as $calcid=>$name) {\n if (class_exists($name)) {\n $calc = new $name($calcid);\n $shipping_services[$calcid] = $calc->title;\n $shipping_methods[$calcid] = $calc->availableMethods();\n }\n }\n\n assign_to_template(array(\n 'discount'=>$discount,\n 'groups'=>$groups,\n 'selected_groups'=>$selected_groups,\n 'shipping_services'=>$shipping_services,\n 'shipping_methods'=>$shipping_methods\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function SetFrom($address, $name = '', $auto = 1) {\n $address = trim($address);\n $name = trim(preg_replace('/[\\r\\n]+/', '', $name)); //Strip breaks and trim\n if (!$this->ValidateAddress($address)) {\n $this->SetError($this->Lang('invalid_address').': '. $address);\n if ($this->exceptions) {\n throw new phpmailerException($this->Lang('invalid_address').': '.$address);\n }\n if ($this->SMTPDebug) {\n $this->edebug($this->Lang('invalid_address').': '.$address);\n }\n return false;\n }\n $this->From = $address;\n $this->FromName = $name;\n if ($auto) {\n if (empty($this->ReplyTo)) {\n $this->AddAnAddress('Reply-To', $address, $name);\n }\n if (empty($this->Sender)) {\n $this->Sender = $address;\n }\n }\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function __construct() {\n $this->smtp_conn = 0;\n $this->error = null;\n $this->helo_rply = null;\n\n $this->do_debug = 0;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public static function run()\n {\n $m = self::match();\n // print_r($m);\n if (is_array($m)) {\n # code...\n\n $val = self::extract($m[0], $m[1]);\n // print_r($val);\n if (isset($val) && $val != null) {\n return $val;\n } else {\n $val['error'] = '';\n\n return $val;\n }\n } else {\n $val['error'] = '';\n\n return $val;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function search($q, $page='') {\r\n $q = str_replace(' ', '+', trim($q));\r\n if (isset($page) && $page !='') {\r\n $page = \"&page=\".$page;\r\n } else {\r\n $page = \"\";\r\n }\r\n $url = \"http://api.themoviedb.org/3/search/movie?query=\".$q.\"&api_key=\".$this->apikey.$page;\r\n $search = $this->curl($url);\r\n //echo $search;\r\n return $search;\r\n }\r", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function iisRequestUriProvider()\n {\n return array(\n array(\n array(\n 'X_ORIGINAL_URL' => '/foo/bar',\n ),\n array(),\n '/foo/bar',\n ),\n array(\n array(\n 'X_REWRITE_URL' => '/foo/bar',\n ),\n array(),\n '/foo/bar',\n ),\n array(\n array(),\n array(\n 'IIS_WasUrlRewritten' => '1',\n 'UNENCODED_URL' => '/foo/bar',\n ),\n '/foo/bar',\n ),\n array(\n array(\n 'X_ORIGINAL_URL' => '/foo/bar',\n ),\n array(\n 'HTTP_X_ORIGINAL_URL' => '/foo/bar',\n ),\n '/foo/bar',\n ),\n array(\n array(\n 'X_ORIGINAL_URL' => '/foo/bar',\n ),\n array(\n 'IIS_WasUrlRewritten' => '1',\n 'UNENCODED_URL' => '/foo/bar',\n ),\n '/foo/bar',\n ),\n array(\n array(\n 'X_ORIGINAL_URL' => '/foo/bar',\n ),\n array(\n 'HTTP_X_ORIGINAL_URL' => '/foo/bar',\n 'IIS_WasUrlRewritten' => '1',\n 'UNENCODED_URL' => '/foo/bar',\n ),\n '/foo/bar',\n ),\n array(\n array(),\n array(\n 'ORIG_PATH_INFO' => '/foo/bar',\n ),\n '/foo/bar',\n ),\n array(\n array(),\n array(\n 'ORIG_PATH_INFO' => '/foo/bar',\n 'QUERY_STRING' => 'foo=bar',\n ),\n '/foo/bar?foo=bar',\n ),\n );\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "\tfunction edit() {\n\t if (empty($this->params['content_id'])) {\n\t flash('message',gt('An error occurred: No content id set.'));\n expHistory::back();\n\t }\n /* The global constants can be overridden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $comment = new expComment($id);\n //FIXME here is where we might sanitize the comment before displaying/editing it\n\t\tassign_to_template(array(\n\t\t 'content_id'=>$this->params['content_id'],\n 'content_type'=>$this->params['content_type'],\n\t\t 'comment'=>$comment\n\t\t));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function manage() {\r\n global $db, $router, $user;\r\n\r\n expHistory::set('manageable', $router->params);\r\n assign_to_template(array(\r\n 'canManageStandalones' => self::canManageStandalones(),\r\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\r\n 'user' => $user,\r\n// 'canManagePagesets' => $user->isAdmin(),\r\n// 'templates' => $db->selectObjects('section_template', 'parent=0'),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function enable()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $swimlane_id = $this->request->getIntegerParam('swimlane_id');\n\n if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {\n $this->flash->success(t('Swimlane updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this swimlane.'));\n }\n\n $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function disable()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $swimlane_id = $this->request->getIntegerParam('swimlane_id');\n\n if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {\n $this->flash->success(t('Swimlane updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this swimlane.'));\n }\n\n $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function testNullAttribute()\n {\n $request = (new ServerRequest('GET', '/'))->withAttribute('name', null);\n\n $this->assertSame(['name' => null], $request->getAttributes());\n $this->assertNull($request->getAttribute('name', 'different-default'));\n\n $requestWithoutAttribute = $request->withoutAttribute('name');\n\n $this->assertSame([], $requestWithoutAttribute->getAttributes());\n $this->assertSame('different-default', $requestWithoutAttribute->getAttribute('name', 'different-default'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function doTestEncodeFormulas(bool $legacy = false)\n {\n if ($legacy) {\n $this->encoder = new CsvEncoder(',', '\"', '\\\\', '.', true);\n } else {\n $this->encoder = new CsvEncoder([CsvEncoder::ESCAPE_FORMULAS_KEY => true]);\n }\n\n $this->assertSame(<<<'CSV'\n0\n\"\t=2+3\"\n\nCSV\n , $this->encoder->encode(['=2+3'], 'csv'));\n\n $this->assertSame(<<<'CSV'\n0\n\"\t-2+3\"\n\nCSV\n , $this->encoder->encode(['-2+3'], 'csv'));\n\n $this->assertSame(<<<'CSV'\n0\n\"\t+2+3\"\n\nCSV\n , $this->encoder->encode(['+2+3'], 'csv'));\n\n $this->assertSame(<<<'CSV'\n0\n\"\t@MyDataColumn\"\n\nCSV\n , $this->encoder->encode(['@MyDataColumn'], 'csv'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": " \tfunction show() {\n// assign_to_template(array('record'=>$record,'tag'=>$tag)); //FIXME $record & $tag are undefined\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testXssExternalLinkImg()\n {\n $antiXss = new \\MicroweberPackages\\Helper\\HTMLClean();\n\n $string = '';\n $content = $antiXss->clean($string);\n $this->assertEquals('\"test.jpg\"', $content);\n\n\n $string = '';\n $content = $antiXss->clean($string);\n $this->assertEquals('', $content);\n\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " private function filterQueryAndFragment($str)\n {\n if (!is_string($str)) {\n throw new \\InvalidArgumentException('Query and fragment must be a string');\n }\n\n return preg_replace_callback(\n '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/',\n [$this, 'rawurlencodeMatchZero'],\n $str\n );\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function getPurchaseOrderByJSON() {\n\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\n\t\techo json_encode($purchase_orders);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction manage () {\n\t expHistory::set('viewable', $this->params);\n\t\t\n\t\t$vendor = new vendor();\n\t\t$vendors = $vendor->find('all');\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\t\t\n\t\tassign_to_template(array(\n 'purchase_orders'=>$purchase_orders,\n 'vendors' => $vendors,\n 'vendor_id' => @$this->params['vendor']\n ));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " function getResponse()\n {\n // methodResponses can only have one param - return that\n return $this->message->params[0];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function event()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n\n if (empty($values['action_name']) || empty($values['project_id'])) {\n return $this->create();\n }\n\n return $this->response->html($this->template->render('action_creation/event', array(\n 'values' => $values,\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " function scan_page($parent_id) {\r\n global $db;\r\n\r\n $sections = $db->selectObjects('section','parent=' . $parent_id);\r\n $ret = '';\r\n foreach ($sections as $page) {\r\n $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\r\n $ret .= scan_container($cLoc, $page->id);\r\n $ret .= scan_page($page->id);\r\n }\r\n return $ret;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t\tform_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);\n form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'right');\n form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'right');\n form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'right');\n form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);\n form_end_row();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function json() {\r\n $token = Options::v('tokens');\r\n $token = json_decode($token, true);\r\n $newtoken = array(\r\n TOKEN => array(\r\n 'time' => TOKEN_TIME,\r\n 'ip' => TOKEN_IP,\r\n 'url' => TOKEN_URL\r\n )\r\n );\r\n if(is_array($token)){\r\n $newtoken = array_merge($token, $newtoken);\r\n }\r\n $newtoken = self::ridOld($newtoken);\r\n $newtoken = json_encode($newtoken);\r\n return $newtoken;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function showall() {\n global $user, $sectionObj, $sections;\n\n expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // all we need to do is determine the current section\n $navsections = $sections;\n if ($sectionObj->parent == -1) {\n $current = $sectionObj;\n } else {\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sections' => $navsections,\n 'current' => $current,\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " protected function getCustomDefinitionService()\n {\n return $this->services['Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Fixtures\\\\CustomDefinition'] = new \\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp)\n {\n $ch = curl_init();\n curl_setopt($ch, CURLOPT_URL, $url);\n curl_setopt($ch, CURLOPT_HEADER, false);\n if ($outfp) {\n curl_setopt($ch, CURLOPT_FILE, $outfp);\n } else {\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);\n }\n curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);\n curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);\n curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\n curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);\n curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);\n curl_setopt($ch, CURLOPT_USERAGENT, $ua);\n $result = curl_exec($ch);\n $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);\n curl_close($ch);\n return $outfp ? $outfp : $result;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " $result = $this->defs[$i]->validate($string, $config, $context);\n if ($result !== false) return $result;\n }\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " self::removeLevel($kid->id);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function manage()\n {\n expHistory::set('manageable',$this->params);\n $gc = new geoCountry();\n $countries = $gc->find('all');\n\n $gr = new geoRegion();\n $regions = $gr->find('all',null,'rank asc,name asc');\n\n assign_to_template(array(\n 'countries'=>$countries,\n 'regions'=>$regions\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach($course_RET as $period_day)\n {\n $period_days_append_sql .=\"(sp.start_time<='$period_day[END_TIME]' AND '$period_day[START_TIME]'<=sp.end_time AND DAYS LIKE '%$period_day[DAYS]%') OR \";\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " function __construct(bool $connect = false) {\n global $CFG_GLPI;\n\n $options = [\n 'base_uri' => GLPI_MARKETPLACE_PLUGINS_API_URI,\n 'connect_timeout' => self::TIMEOUT,\n ];\n\n // add proxy string if configured in glpi\n if (!empty($CFG_GLPI[\"proxy_name\"])) {\n $proxy_creds = !empty($CFG_GLPI[\"proxy_user\"])\n ? $CFG_GLPI[\"proxy_user\"].\":\".Toolbox::decrypt($CFG_GLPI[\"proxy_passwd\"], GLPIKEY).\"@\"\n : \"\";\n $proxy_string = \"http://{$proxy_creds}\".$CFG_GLPI['proxy_name'].\":\".$CFG_GLPI['proxy_port'];\n $options['proxy'] = $proxy_string;\n }\n\n // init guzzle client with base options\n $this->httpClient = new Guzzle_Client($options);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-327", "cwe_name": "Use of a Broken or Risky Cryptographic Algorithm", "description": "The use of a broken or risky cryptographic algorithm is an unnecessary risk that may result in the exposure of sensitive information.", "url": "https://cwe.mitre.org/data/definitions/327.html", "label_name": "vulnerable"} {"code": " function categoryBreadcrumb() {\n// global $db, $router;\n\n //eDebug($this->category);\n\n /*if(isset($router->params['action']))\n {\n $ancestors = $this->category->pathToNode();\n }else if(isset($router->params['section']))\n {\n $current = $db->selectObject('section',' id= '.$router->params['section']);\n $ancestors[] = $current;\n if( $current->parent != -1 || $current->parent != 0 )\n {\n while ($db->selectObject('section',' id= '.$router->params['section']);)\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n eDebug($sections);\n $ancestors = $this->category->pathToNode();\n }*/\n\n $ancestors = $this->category->pathToNode();\n // eDebug($ancestors);\n assign_to_template(array(\n 'ancestors' => $ancestors\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function isAuthorizedBackendUserSession()\n {\n if (!$this->hasSessionCookie()) {\n return false;\n }\n $this->initializeSession();\n if (empty($_SESSION['authorized']) || empty($_SESSION['isBackendSession'])) {\n return false;\n }\n return !$this->isExpired();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "\tpublic function set_controller($controller, $action)\n\t{\n\t\tinclude CLASS_DIR . 'module.php';\n\n\t\t$module = new Module($controller);\n\n\t\tdefine ('MODULE_NAME', $module->get_name());\n\n\t\t$class_file = APP_DIR . 'controller/' . MODULE_NAME . '.php';\n\t\t$class_name = ucfirst(MODULE_NAME) . '_Controller';\n\t\t$class_method = ucfirst($action) . '_Action';\n\n\t\t// tworzy obiekt kontrolera:\n\n\t\tif (file_exists($class_file))\n\t\t{\n\t\t\tinclude $class_file;\n\n\t\t\tif (class_exists($class_name))\n\t\t\t{\n\t\t\t\t$this->controller_object = new $class_name($this);\n\n\t\t\t\t$this->set_acl($this);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdie ('Class:

    '.$class_name.'

    not found.');\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdie ('File:

    '.$class_file.'

    not found.');\n\t\t}\n\n\t\t// tworzy obiekt modelu:\n\n\t\t$this->set_model_object(MODULE_NAME);\n\n\t\t// tworzy obiekt widoku:\n\n\t\t$this->set_view_object(MODULE_NAME);\n\n\t\t// wywo\u0142uje akcj\u0119 (metod\u0119) kontrolera:\n\n\t\tif (method_exists($class_name, $class_method))\n\t\t{\n\t\t\t$this->controller_object->{$class_method}();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdie ('Method:

    '.$class_method.'

    in class:

    '.$class_name.'

    not found.');\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function execute(&$params){\n $options = &$this->config['options'];\n $notif = new Notification;\n $notif->user = $this->parseOption('user', $params);\n $notif->createdBy = 'API';\n $notif->createDate = time();\n // file_put_contents('triggerLog.txt',\"\\n\".$notif->user,FILE_APPEND);\n // if($this->parseOption('type',$params) == 'auto') {\n // if(!isset($params['model']))\n // return false;\n // $notif->modelType = get_class($params['model']);\n // $notif->modelId = $params['model']->id;\n // $notif->type = $this->getNotifType();\n // } else {\n $notif->type = 'custom';\n $notif->text = $this->parseOption('text', $params);\n // }\n\n if ($notif->save()) {\n return array (true, \"\");\n } else {\n $errors = $notif->getErrors ();\n return array(false, array_shift($errors));\n }\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function group($id)\n {\n $usr = Db::result(\n sprintf(\n \"SELECT * FROM `user` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1\",\n Typo::int($id),\n Typo::cleanX($id)\n )\n );\n\n return $usr[0]->group;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function delete_item_permissions_check( $request ) {\n\n\t\t$id = (int) $request['id'];\n\n\t\tif ( ! current_user_can( 'delete_user', $id ) ) {\n\t\t\treturn new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );\n\t\t}\n\n\t\treturn true;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " $section = new section(intval($page));\n if ($section) {\n// self::deleteLevel($section->id);\n $section->delete();\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function setItems($items)\n {\n if ($items && !$items instanceof ItemBag) {\n $items = new PayPalItemBag($items);\n }\n\n return $this->setParameter('items', $items);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function update($key, $qty) {\n\t\tif ((int)$qty && ((int)$qty > 0) && isset($this->session->data['cart'][$key])) {\n\t\t\t$this->session->data['cart'][$key] = (int)$qty;\n\t\t} else {\n\t\t\t$this->remove($key);\n\t\t}\n\n\t\t$this->data = array();\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " protected function beginExport($includeHidden = false) {\n if ($includeHidden) {\n $this->click (\"css=#includeHidden\");\n }\n $this->click (\"css=#export-button\");\n $this->waitForTextPresent (\"data successfully exported.\");\n $this->assertAlert (\"Export Complete!\");\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function db_start()\n{\n\tglobal $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;\n\n\tswitch ($DatabaseType) {\n\t\tcase 'mysqli':\n\t\t\t$connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort);\n\t\t\tbreak;\n\t}\n\n\t// Error code for both.\n\tif ($connection === false) {\n\t\tswitch ($DatabaseType) {\n\t\t\tcase 'mysqli':\n\t\t\t\t$errormessage = mysqli_error($connection);\n\t\t\t\tbreak;\n\t\t}\n\t\tdb_show_error(\"\", \"\" . _couldNotConnectToDatabase . \": $DatabaseServer\", $errormessage);\n\t}\n\treturn $connection;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function url($mod) {\r\n $url = Site::$url.\"/inc/mod/\".$mod;\r\n return $url;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function selectArraysBySql($sql) { \n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return array();\n $arrays = array();\n for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)\n $arrays[] = mysqli_fetch_assoc($res);\n return $arrays;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function add($var) {\r\n\r\n $route = self::$_route;\r\n\r\n self::$_route = array_merge($route, $var);\r\n\r\n return self::$_route;\r\n\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($days as $value) {\n $regitem[] = $value;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function setParseContent($parseContent)\n {\n $this->parseContent = $parseContent;\n return $this;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function path_f ($path)\n{\n global $home_dir;\n $abs_dir = $home_dir;\n switch ($path)\n {\n case '.':\n case '': return realpath($abs_dir);\n }\n \n return realpath(realpath($home_dir) . \"/$path\");\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "\tprotected function _mkfile($path, $name) {\n\t\t$path = $this->_joinPath($path, $name);\n\t\t\n\t\tif (($fp = fopen($path, 'w'))) {\n\t\t\tfclose($fp);\n\t\t\tchmod($path, $this->options['fileMode']);\n\t\t\tclearstatcache();\n\t\t\treturn $path;\n\t\t}\n\t\treturn false;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction testCommandCategorieExistence ($name = NULL)\t{\n\t\tglobal $pearDB, $form;\n\t\t$id = NULL;\n\t\t\n\t\tif (isset($form))\n\t\t\t$id = $form->getSubmitValue('cmd_category_id');\n\t\t\n\t\t$DBRESULT = $pearDB->query(\"SELECT `category_name`, `cmd_category_id` FROM `command_categories` WHERE `category_name` = '\".$pearDB->escape($name).\"'\");\n\t\t$cat = $DBRESULT->fetchRow();\n\t\t\n\t\tif ($DBRESULT->numRows() >= 1 && $cat[\"cmd_category_id\"] == $id)\n\t\t\treturn true;\n\t\telse if ($DBRESULT->numRows() >= 1 && $cat[\"cmd_category_id\"] != $id)\n\t\t\treturn false;\n\t\telse\n\t\t\treturn true;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function delete() {\n if (!AuthUser::hasPermission('file_manager_delete')) {\n Flash::set('error', __('You do not have sufficient permissions to delete a file or directory.'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n\n $paths = func_get_args();\n\n $file = urldecode(join('/', $paths));\n\n // CSRF checks\n if (isset($_GET['csrf_token'])) {\n $csrf_token = $_GET['csrf_token'];\n if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/delete/'.$file)) {\n Flash::set('error', __('Invalid CSRF token found!'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n }\n else {\n Flash::set('error', __('No CSRF token found!'));\n redirect(get_url('plugin/file_manager/browse/'));\n }\n\n $file = FILES_DIR . '/' . str_replace('..', '', $file);\n $filename = array_pop($paths);\n $paths = join('/', $paths);\n\n if (is_file($file)) {\n if (!unlink($file))\n Flash::set('error', __('Permission denied!'));\n }\n else {\n if (!$this->_rrmdir($file))\n Flash::set('error', __('Permission denied!'));\n }\n\n redirect(get_url('plugin/file_manager/browse/' . $paths));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "\tfunction lockTable($table,$lockType=\"WRITE\") {\n $sql = \"LOCK TABLES `\" . $this->prefix . \"$table` $lockType\";\n\n $res = mysqli_query($this->connection, $sql);\n return $res;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function Zipped () {\r\n\r\n global $HTTP_ACCEPT_ENCODING;\r\n\r\n if( headers_sent() ){\r\n\r\n $encoding = false;\r\n\r\n }elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){\r\n\r\n $encoding = 'x-gzip';\r\n\r\n }elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){\r\n\r\n $encoding = 'gzip';\r\n\r\n }else{\r\n\r\n $encoding = false;\r\n\r\n }\r\n\r\n if( $encoding ){\r\n\r\n $contents = ob_get_contents();\r\n ob_end_clean();\r\n header('Content-Encoding: '.$encoding);\r\n print(\"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\");\r\n $size = strlen($contents);\r\n $contents = gzcompress($contents, 9);\r\n $contents = substr($contents, 0, $size);\r\n print($contents);\r\n exit();\r\n\r\n }else{\r\n\r\n ob_end_flush();\r\n exit();\r\n\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($events as $event) {\n $extevents[$date][] = $event;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function manage_messages() {\n expHistory::set('manageable', $this->params);\n\n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status_messages',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'body',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n\t\t\t//'columns'=>array('Name'=>'title')\n ));\n\n //eDebug($page);\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " } elseif ($token instanceof HTMLPurifier_Token_End) {\n $nesting--;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $ids = array_map (function ($event) { return $event->id; }, $events);", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testFormsCsrfIsEnabledByDefault()\n {\n if (class_exists(FullStack::class)) {\n $this->markTestSkipped('testing with the FullStack prevents verifying default values');\n }\n $container = $this->createContainerFromFile('form_default_csrf');\n\n $this->assertTrue($container->hasDefinition('security.csrf.token_manager'));\n $this->assertTrue($container->hasParameter('form.type_extension.csrf.enabled'));\n $this->assertTrue($container->getParameter('form.type_extension.csrf.enabled'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static function fixName($name) {\n $name = preg_replace('/[^A-Za-z0-9\\.]/','_',$name);\n if ($name[0] == '.')\n $name[0] = '_';\n return $name;\n// return preg_replace('/[^A-Za-z0-9\\.]/', '-', $name);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function addSelect( $fields ) {\n\t\tif ( !is_array( $fields ) ) {\n\t\t\tthrow new \\MWException( __METHOD__ . ': A non-array was passed.' );\n\t\t}\n\t\tforeach ( $fields as $alias => $field ) {\n\t\t\tif ( !is_numeric( $alias ) && array_key_exists( $alias, $this->select ) && $this->select[$alias] != $field ) {\n\t\t\t\t//In case of a code bug that is overwriting an existing field alias throw an exception.\n\t\t\t\tthrow new \\MWException( __METHOD__ . \": Attempted to overwrite existing field alias `{$this->select[$alias]}` AS `{$alias}` with `{$field}` AS `{$alias}`.\" );\n\t\t\t}\n\t\t\t//String alias and does not exist already.\n\t\t\tif ( !is_numeric( $alias ) && !array_key_exists( $alias, $this->select ) ) {\n\t\t\t\t$this->select[$alias] = $field;\n\t\t\t}\n\n\t\t\t//Speed up by not using in_array() or array_key_exists(). Toss the field names into their own array as keys => true to exploit a speedy look up with isset().\n\t\t\tif ( is_numeric( $alias ) && !isset( $this->selectedFields[$field] ) ) {\n\t\t\t\t$this->select[] = $field;\n\t\t\t\t$this->selectedFields[$field] = true;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "\tpublic function __construct()\n\t{\n\t\tparent::__construct();\n\t\t$this->exposeMethod('getOwners');\n\t\t$this->exposeMethod('getReference');\n\t\t$this->exposeMethod('getUserRole');\n\t\t$this->exposeMethod('verifyPhoneNumber');\n\t\t$this->exposeMethod('findAddress');\n\t\t$this->exposeMethod('verifyIsHolidayDate');\n\t\t$this->exposeMethod('changeFavoriteOwner');\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function page($vars)\n {\n switch (SMART_URL) {\n case true:\n $inFold = (Options::v('permalink_use_index_php') == 'on') ? '/index.php/' : '/';\n if (Options::v('multilang_enable') === 'on') {\n $lang = Language::isActive();\n $lang = !empty($lang) ? $lang.'/' : '';\n $url = Site::$url.$inFold.$lang.self::slug($vars).GX_URL_PREFIX;\n } else {\n $url = Site::$url.$inFold.self::slug($vars).GX_URL_PREFIX;\n }\n break;\n\n default:\n if (Options::v('multilang_enable') === 'on') {\n $lang = Language::isActive();\n $lang = !empty($lang) ? '&lang='.$lang : '';\n $url = Site::$url.\"/?page={$vars}{$lang}\";\n } else {\n $url = Site::$url.\"/?page={$vars}\";\n }\n\n break;\n }\n\n return $url;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function driverRead(CacheItemInterface $item)\n {\n $this->driverConnect();\n // return null if no caching\n // return value if in caching\n $keyword = self::PREFIX . $item->getKey();\n $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ], true)) : false;\n\n if ($x == false) {\n return null;\n } else {\n if (!is_scalar($this->driverUnwrapData($x)) && !is_null($this->driverUnwrapData($x))) {\n throw new phpFastCacheDriverException('Hacking attempt: The decoding returned a non-scalar value, Cookie driver does not allow this.');\n }\n\n return $x;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public function getHTMLFormatted($config, $errors = null) {\n $ret = array();\n\n $this->generator = new HTMLPurifier_Generator($config, $this->context);\n if ($errors === null) $errors = $this->errors;\n\n // 'At line' message needs to be removed\n\n // generation code for new structure goes here. It needs to be recursive.\n foreach ($this->lines as $line => $col_array) {\n if ($line == -1) continue;\n foreach ($col_array as $col => $struct) {\n $this->_renderStruct($ret, $struct, $line, $col);\n }\n }\n if (isset($this->lines[-1])) {\n $this->_renderStruct($ret, $this->lines[-1]);\n }\n\n if (empty($errors)) {\n return '

    ' . $this->locale->getMessage('ErrorCollector: No errors') . '

    ';\n } else {\n return '';\n }\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function getFoo2Service()\n {\n return $this->services['Foo\\\\Foo'] = new \\Foo\\Foo();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function make($id) {\n return new HTMLPurifier_ConfigSchema_Interchange_Id($id);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __construct()\n {\n global $GLOBALS;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " . htmlspecialchars($table['table']) . '`';\n $html .= '';\n }\n }\n } else {\n $html .= '
  • '\n . ($this->_tableType == 'recent'\n ?__('There are no recent tables.')\n :__('There are no favorite tables.'))\n . '
  • ';\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function upload() {\n \n // upload the file, but don't save the record yet...\n if ($this->params['resize'] != 'false') {\n $maxwidth = $this->params['max_width'];\n } else {\n $maxwidth = null;\n }\n $file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload\n\n if (is_object($file)) {\n $resized = !empty($file->resized) ? true : false;\n $user = new user($this->params['usrid']);\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($this->params['cat'])) {\n $expcat = new expCat($this->params['cat']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n\n // a echo so YUI Uploader is notified of the function's completion\n if ($resized) {\n echo gt('File resized and then saved');\n } else {\n echo gt('File saved');\n }\n } else {\n echo gt('File was NOT uploaded!');\n// flash('error',gt('File was not uploaded!'));\n }\n } ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tprotected function _setContent($path, $fp) {\n\t\telFinder::rewind($fp);\n\t\t$fstat = fstat($fp);\n\t\t$size = $fstat['size'];\n\t\t\n\t\t\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function prepare($config, $context) {\n parent::prepare($config, $context);\n $this->config = $config;\n $this->context = $context;\n $this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp');\n $this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions');\n $this->attrValidator = new HTMLPurifier_AttrValidator();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function selectObjectBySql($sql) {\n //$logFile = \"C:\\\\xampp\\\\htdocs\\\\supserg\\\\tmp\\\\queryLog.txt\";\n //$lfh = fopen($logFile, 'a');\n //fwrite($lfh, $sql . \"\\n\");\n //fclose($lfh);\n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return null;\n return mysqli_fetch_object($res);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function IsQmail() {\n if (stristr(ini_get('sendmail_path'), 'qmail')) {\n $this->Sendmail = '/var/qmail/bin/sendmail';\n }\n $this->Mailer = 'sendmail';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " list($type, $params) = $this->getFixType($name);\n switch ($type) {\n case 'attr_transform_pre':\n case 'attr_transform_post':\n $attr = $params['attr'];\n if (isset($params['element'])) {\n $element = $params['element'];\n if (empty($this->info[$element])) {\n $e = $this->addBlankElement($element);\n } else {\n $e = $this->info[$element];\n }\n } else {\n $type = \"info_$type\";\n $e = $this;\n }\n // PHP does some weird parsing when I do\n // $e->$type[$attr], so I have to assign a ref.\n $f =& $e->$type;\n $f[$attr] = $fix;\n break;\n case 'tag_transform':\n $this->info_tag_transform[$params['element']] = $fix;\n break;\n case 'child':\n case 'content_model_type':\n $element = $params['element'];\n if (empty($this->info[$element])) {\n $e = $this->addBlankElement($element);\n } else {\n $e = $this->info[$element];\n }\n $e->$type = $fix;\n break;\n default:\n trigger_error(\"Fix type $type not supported\", E_USER_ERROR);\n break;\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function write($template = '')\n {\n if (!empty($this->script_files)) {\n $this->set_env('request_token', $this->app->get_request_token());\n }\n\n $commands = $this->get_js_commands($framed);\n\n // if all js commands go to parent window we can ignore all\n // script files and skip rcube_webmail initialization (#1489792)\n if ($framed) {\n $this->scripts = array();\n $this->script_files = array();\n $this->header = '';\n $this->footer = '';\n }\n\n // write all javascript commands\n $this->add_script($commands, 'head_top');\n\n // allow (legal) iframe content to be loaded\n $iframe = $this->framed || $this->env['framed'];\n if (!headers_sent() && $iframe && $this->app->config->get('x_frame_options', 'sameorigin') === 'deny') {\n header('X-Frame-Options: sameorigin', true);\n }\n\n // call super method\n $this->_write($template, $this->config->get('skin_path'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static function getHelpVersionId($version) {\n global $db;\n\n return $db->selectValue('help_version', 'id', 'version=\"'.$version.'\"');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function runCallback() {\n foreach ($this->records as &$record) {\n if (isset($record->ref_type)) {\n $refType = $record->ref_type;\n if (class_exists($record->ref_type)) {\n $type = new $refType();\n $classinfo = new ReflectionClass($type);\n if ($classinfo->hasMethod('paginationCallback')) {\n $item = new $type($record->original_id);\n $item->paginationCallback($record);\n }\n }\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function show()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask_converter/show', array(\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function accept(NodeVisitor $visitor)\n {\n $visitor->visitTextNode($this);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function update_optiongroup_master() {\n global $db;\n\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $og = new optiongroup_master($id);\n $oldtitle = $og->title;\n $og->update($this->params);\n \n // if the title of the master changed we should update the option groups that are already using it.\n if ($oldtitle != $og->title) {\n $db->sql('UPDATE '.$db->prefix.'optiongroup SET title=\"'.$og->title.'\" WHERE title=\"'.$oldtitle.'\"');\n }\n \n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function actionGetItems(){\n $sql = 'SELECT id, name as value FROM x2_opportunities WHERE name LIKE :qterm ORDER BY name ASC';\n $command = Yii::app()->db->createCommand($sql);\n $qterm = $_GET['term'].'%';\n $command->bindParam(\":qterm\", $qterm, PDO::PARAM_STR);\n $result = $command->queryAll();\n echo CJSON::encode($result);\n Yii::app()->end();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function generateFromTokens($tokens) {\n if (!$tokens) return '';\n\n // Basic algorithm\n $html = '';\n for ($i = 0, $size = count($tokens); $i < $size; $i++) {\n if ($this->_scriptFix && $tokens[$i]->name === 'script'\n && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) {\n // script special case\n // the contents of the script block must be ONE token\n // for this to work.\n $html .= $this->generateFromToken($tokens[$i++]);\n $html .= $this->generateScriptFromToken($tokens[$i++]);\n }\n $html .= $this->generateFromToken($tokens[$i]);\n }\n\n // Tidy cleanup\n if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) {\n $tidy = new Tidy;\n $tidy->parseString($html, array(\n 'indent'=> true,\n 'output-xhtml' => $this->_xhtml,\n 'show-body-only' => true,\n 'indent-spaces' => 2,\n 'wrap' => 68,\n ), 'utf8');\n $tidy->cleanRepair();\n $html = (string) $tidy; // explicit cast necessary\n }\n\n // Normalize newlines to system defined value\n if ($this->config->get('Core.NormalizeNewlines')) {\n $nl = $this->config->get('Output.Newline');\n if ($nl === null) $nl = PHP_EOL;\n if ($nl !== \"\\n\") $html = str_replace(\"\\n\", $nl, $html);\n }\n return $html;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function edit_internalalias() {\r\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\r\n if ($section->parent == -1) {\r\n notfoundController::handle_not_found();\r\n exit;\r\n } // doesn't work for standalone pages\r\n if (empty($section->id)) {\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function getViewFileParams () {\n if (!isset ($this->_viewFileParams)) {\n $this->_viewFileParams = array_merge (\n parent::getViewFileParams (),\n array (\n 'chartType' => $this->chartType,\n\t\t\t 'chartSettingsDataProvider' => self::getChartSettingsProvider (\n $this->chartType),\n 'eventTypes' =>\n array ('all'=>Yii::t('app', 'All Events')) + Events::$eventLabels,\n 'socialSubtypes' => json_decode (\n\t\t\t Dropdowns::model()->findByPk(113)->options,true),\n 'visibilityFilters' => array (\n '1'=>'Public',\n '0'=>'Private',\n ),\n 'suppressChartSettings' => false,\n 'chartType' => 'usersChart',\n 'widgetUID' => $this->widgetUID,\n 'metricTypes' => User::getUserOptions (),\n )\n );\n }\n return $this->_viewFileParams;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function assertIsBool() {\n if (!is_bool($this->contents)) $this->error('must be a boolean');\n return $this;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic function findAddress(App\\Request $request)\n\t{\n\t\t$instance = \\App\\Map\\Address::getInstance($request->getByType('type'));\n\t\t$response = new Vtiger_Response();\n\t\tif ($instance) {\n\t\t\t$response->setResult($instance->find($request->getByType('value', 'Text')));\n\t\t}\n\t\t$response->emit();\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-434", "cwe_name": "Unrestricted Upload of File with Dangerous Type", "description": "The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.", "url": "https://cwe.mitre.org/data/definitions/434.html", "label_name": "vulnerable"} {"code": "\tfunction manage() {\n\t global $db;\n\t \n\t expHistory::set('manageable', $this->params);\n//\t $classes = array();\n $dir = BASE.\"framework/modules/ecommerce/billingcalculators\";\n if (is_readable($dir)) {\n $dh = opendir($dir);\n while (($file = readdir($dh)) !== false) {\n if (is_file(\"$dir/$file\") && substr(\"$dir/$file\", -4) == \".php\") {\n include_once(\"$dir/$file\");\n $classname = substr($file, 0, -4);\n $id = $db->selectValue('billingcalculator', 'id', 'calculator_name=\"'.$classname.'\"');\n if (empty($id)) {\n// $calobj = null;\n $calcobj = new $classname();\n if ($calcobj->isSelectable() == true) {\n $obj = new billingcalculator(array(\n 'title'=>$calcobj->name(),\n// 'user_title'=>$calcobj->title,\n 'body'=>$calcobj->description(), \n 'calculator_name'=>$classname,\n 'enabled'=>false));\n $obj->save();\n }\n }\n }\n }\n }\n \n $bcalc = new billingcalculator();\n $calculators = $bcalc->find('all');\n assign_to_template(array(\n 'calculators'=>$calculators\n ));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($elem[2] as $field) {\n echo '\n \n    '.$field[1].' :\n ';\n if ($field[3] === \"masked\") {\n echo '\n
    ';\n } else {\n echo '\n
    ';\n }\n echo '\n \n ';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "vulnerable"} {"code": " public function breadcrumb() {\n global $sectionObj;\n\n expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // Show not only the location of a page in the hierarchy but also the location of a standalone page\n $current = new section($id);\n if ($current->parent == -1) { // standalone page\n $navsections = section::levelTemplate(-1, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n } else {\n $navsections = section::levelTemplate(0, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sections' => $navsections,\n 'current' => $current,\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function getN() {return $this->n;}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tfunction getTextColumns($table) {\n\t\t$sql = \"SHOW COLUMNS FROM \" . $this->prefix.$table . \" WHERE type = 'text' OR type like 'varchar%'\";\n\t\t$res = @mysqli_query($this->connection, $sql);\n\t\tif ($res == null)\n return array();\n\t\t$records = array();\n\t\twhile($row = mysqli_fetch_object($res)) {\n\t\t\t$records[] = $row->Field;\n\t\t}\n\t\t\n\t\treturn $records;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction edit_vendor() {\n\t\t$vendor = new vendor();\n\n\t\tif(isset($this->params['id'])) {\n\t\t\t$vendor = $vendor->find('first', 'id =' .$this->params['id']);\n\t\t\tassign_to_template(array(\n 'vendor'=>$vendor\n ));\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function set_coupon_data($data)\n {\n $this->coupon_data = $data;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " public static function parseAndTrimExport($str, $isHTML = false) { //\ufffdDeath from above\ufffd? \ufffd\n //echo \"1
    \"; eDebug($str); \n\n $str = str_replace(\"\ufffd\", \"’\", $str);\n $str = str_replace(\"\ufffd\", \"‘\", $str);\n $str = str_replace(\"\ufffd\", \"®\", $str);\n $str = str_replace(\"\ufffd\", \"-\", $str);\n $str = str_replace(\"\ufffd\", \"—\", $str);\n $str = str_replace(\"\ufffd\", \"”\", $str);\n $str = str_replace(\"\ufffd\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\t\", \" \", $str);\n $str = str_replace(\",\", \"\\,\", $str);\n $str = str_replace(\"\ufffd\", \"¼\", $str);\n $str = str_replace(\"\ufffd\", \"½\", $str);\n $str = str_replace(\"\ufffd\", \"¾\", $str);\n\n if (!$isHTML) {\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n } else {\n $str = str_replace('\"', '\"\"', $str);\n }\n\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n $str = trim(str_replace(\"\ufffd\", \"™\", $str));\n //echo \"2
    \"; eDebug($str,die);\n return $str;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " recyclebin::sendToRecycleBin($loc, $parent);\r\n //FIXME if we delete the module & sectionref the module completely disappears\r\n// if (class_exists($secref->module)) {\r\n// $modclass = $secref->module;\r\n// //FIXME: more module/controller glue code\r\n// if (expModules::controllerExists($modclass)) {\r\n// $modclass = expModules::getControllerClassName($modclass);\r\n// $mod = new $modclass($loc->src);\r\n// $mod->delete_instance();\r\n// } else {\r\n// $mod = new $modclass();\r\n// $mod->deleteIn($loc);\r\n// }\r\n// }\r\n }\r\n// $db->delete('sectionref', 'section=' . $parent);\r\n $db->delete('section', 'parent=' . $parent);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function remove(History $hist, $transaction = true)\n {\n global $emitter;\n\n try {\n if ($transaction) {\n $this->zdb->connection->beginTransaction();\n }\n\n //remove associated contributions if needeed\n if ($this->getDispatchedAmount() > 0) {\n $c = new Contributions($this->zdb, $this->login);\n $clist = $c->getListFromTransaction($this->_id);\n $cids = array();\n foreach ($clist as $cid) {\n $cids[] = $cid->id;\n }\n $rem = $c->remove($cids, $hist, false);\n }\n\n //remove transaction itself\n $delete = $this->zdb->delete(self::TABLE);\n $delete->where(\n self::PK . ' = ' . $this->_id\n );\n $del = $this->zdb->execute($delete);\n if ($del->count() > 0) {\n $this->dynamicsRemove(true);\n } else {\n Analog::log(\n 'Transaction has not been removed!',\n Analog::WARNING\n );\n return false;\n }\n\n if ($transaction) {\n $this->zdb->connection->commit();\n }\n\n $emitter->emit('transaction.remove', $this);\n return true;\n } catch (Throwable $e) {\n if ($transaction) {\n $this->zdb->connection->rollBack();\n }\n Analog::log(\n 'An error occurred trying to remove transaction #' .\n $this->_id . ' | ' . $e->getMessage(),\n Analog::ERROR\n );\n throw $e;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function getTemplateHierarchyFlat($parent, $depth = 1) {\n global $db;\n\n $arr = array();\n $kids = $db->selectObjects('section_template', 'parent=' . $parent, 'rank');\n//\t\t$kids = expSorter::sort(array('array'=>$kids,'sortby'=>'rank', 'order'=>'ASC'));\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\n $page = $kids[$i];\n $page->depth = $depth;\n $page->first = ($i == 0 ? 1 : 0);\n $page->last = ($i == count($kids) - 1 ? 1 : 0);\n $arr[] = $page;\n $arr = array_merge($arr, self::getTemplateHierarchyFlat($page->id, $depth + 1));\n }\n return $arr;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "function getTypes($subtype=\"both\") {\n\t$types = array(\"users\" => array(),\n\t \"resources\" => array());\n\tif($subtype == \"users\" || $subtype == \"both\") {\n\t\t$query = \"SELECT id, name FROM userprivtype\";\n\t\t$qh = doQuery($query, 365);\n\t\twhile($row = mysql_fetch_assoc($qh)) {\n\t\t\tif($row[\"name\"] == \"block\" || $row[\"name\"] == \"cascade\")\n\t\t\t\tcontinue;\n\t\t\t$types[\"users\"][$row[\"id\"]] = $row[\"name\"];\n\t\t}\n\t}\n\tif($subtype == \"resources\" || $subtype == \"both\") {\n\t\t$query = \"SELECT id, name FROM resourcetype\";\n\t\t$qh = doQuery($query, 366);\n\t\twhile($row = mysql_fetch_assoc($qh)) {\n\t\t\tif($row[\"name\"] == \"block\" || $row[\"name\"] == \"cascade\")\n\t\t\t\tcontinue;\n\t\t\t$types[\"resources\"][$row[\"id\"]] = $row[\"name\"];\n\t\t}\n\t}\n\treturn $types;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " private function runCallback() {\n foreach ($this->records as &$record) {\n if (isset($record->ref_type)) {\n $refType = $record->ref_type;\n if (class_exists($record->ref_type)) {\n $type = new $refType();\n $classinfo = new ReflectionClass($type);\n if ($classinfo->hasMethod('paginationCallback')) {\n $item = new $type($record->original_id);\n $item->paginationCallback($record);\n }\n }\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " static function author() {\n return \"Dave Leffler\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function actionHideWidget() {\n if (isset($_POST['name']) && isset ($_POST['position'])) {\n $name = $_POST['name'];\n $position = $_POST['position'];\n\n $layout = Yii::app()->params->profile->getLayout();\n if (isset ($layout[$position][$name])) {\n\n $layout['hiddenRight'][$name] = $layout[$position][$name];\n unset ($layout[$position][$name]);\n Yii::app()->params->profile->saveLayout($layout);\n }\n\n echo Yii::app()->params->profile->getWidgetMenu();\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\t\tarray_push($privileges, $p);\n\t\t}\n\t}\n\n\treturn array('status' => 'success',\n\t 'privileges' => array_unique($privileges));\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "\t\t\tform_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);\n form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'text-align:right');\n form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'text-align:right');\n form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'text-align:right');\n form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);\n form_end_row();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tpublic function ls($hash, $intersect = null) {\n\t\tif (($dir = $this->dir($hash)) == false || !$dir['read']) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t$list = array();\n\t\t$path = $this->decode($hash);\n\t\t\n\t\t$check = array();\n\t\tif ($intersect) {\n\t\t\t$check = array_flip($intersect);\n\t\t}\n\t\t\n\t\tforeach ($this->getScandir($path) as $stat) {\n\t\t\tif (empty($stat['hidden']) && (!$check || isset($check[$stat['name']])) && $this->mimeAccepted($stat['mime'])) {\n\t\t\t\t$list[$stat['hash']] = $stat['name'];\n\t\t\t}\n\t\t}\n\n\t\treturn $list;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function approve_submit() {\n global $history;\n \n if (empty($this->params['id'])) {\n flash('error', gt('No ID supplied for comment to approve'));\n $lastUrl = expHistory::getLast('editable');\n }\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n $simplenote = new expSimpleNote($this->params['id']);\n //FIXME here is where we might sanitize the note before approving it\n $simplenote->body = $this->params['body'];\n $simplenote->approved = $this->params['approved'];\n $simplenote->save();\n \n $lastUrl = makelink($history->history[$history->history['lasts']['type']][count($history->history[$history->history['lasts']['type']])-1]['params']);\n if (!empty($this->params['tab']))\n {\n $lastUrl .= \"#\".$this->params['tab'];\n }\n redirect_to($lastUrl);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t$context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " protected function unserialize(string $data)\n {\n if (is_numeric($data)) {\n return $data;\n }\n\n $unserialize = $this->options['serialize'][1] ?? \"unserialize\";\n\n return $unserialize($data);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public function approve() {\n expHistory::set('editable', $this->params);\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n if (empty($this->params['id'])) {\n flash('error', gt('No ID supplied for note to approve'));\n $lastUrl = expHistory::getLast('editable');\n }\n \n $simplenote = new expSimpleNote($this->params['id']);\n assign_to_template(array(\n 'simplenote'=>$simplenote,\n 'require_login'=>$require_login,\n 'require_approval'=>$require_approval,\n 'require_notification'=>$require_notification,\n 'notification_email'=>$notification_email,\n 'tab'=>$this->params['tab']\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function inFolder() {\r\n\r\n $uri = explode('/', Site::$url);\r\n\r\n if(count($uri) > 3) {\r\n\r\n return true;\r\n\r\n }else{\r\n\r\n return false;\r\n\r\n }\r\n\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function decorate(&$cache) {\n $decorator = $this->copy();\n // reference is necessary for mocks in PHP 4\n $decorator->cache =& $cache;\n $decorator->type = $cache->type;\n return $decorator;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __construct(\n $name, $doc_url = null, $compress = false\n ) {\n parent::__construct();\n $this->docURL = $doc_url;\n $this->name = $name;\n $this->compress = $compress;\n // initialize sub-printers\n $this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();\n $this->fields[HTMLPurifier_VarParser::BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function canView($section) {\r\n global $db;\r\n\r\n if ($section == null) {\r\n return false;\r\n }\r\n if ($section->public == 0) {\r\n // Not a public section. Check permissions.\r\n return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id));\r\n } else { // Is public. check parents.\r\n if ($section->parent <= 0) {\r\n // Out of parents, and since we are still checking, we haven't hit a private section.\r\n return true;\r\n } else {\r\n $s = $db->selectObject('section', 'id=' . $section->parent);\r\n return self::canView($s);\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function params()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n $values['project_id'] = $project['id'];\n\n if (empty($values['action_name']) || empty($values['event_name'])) {\n $this->create();\n return;\n }\n\n $action = $this->actionManager->getAction($values['action_name']);\n $action_params = $action->getActionRequiredParameters();\n\n if (empty($action_params)) {\n $this->doCreation($project, $values + array('params' => array()));\n }\n\n $projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());\n unset($projects_list[$project['id']]);\n\n $this->response->html($this->template->render('action_creation/params', array(\n 'values' => $values,\n 'action_params' => $action_params,\n 'columns_list' => $this->columnModel->getList($project['id']),\n 'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),\n 'projects_list' => $projects_list,\n 'colors_list' => $this->colorModel->getList(),\n 'categories_list' => $this->categoryModel->getList($project['id']),\n 'links_list' => $this->linkModel->getList(0, false),\n 'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'swimlane_list' => $this->swimlaneModel->getList($project['id']),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function remove()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $tag_id = $this->request->getIntegerParam('tag_id');\n $tag = $this->tagModel->getById($tag_id);\n\n if ($tag['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n if ($this->tagModel->remove($tag_id)) {\n $this->flash->success(t('Tag removed successfully.'));\n } else {\n $this->flash->failure(t('Unable to remove this tag.'));\n }\n\n $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " $this->aliases[$s] = $d->id->toString();\n }\n array_pop($this->context);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function delete() {\n global $db;\n\n if (empty($this->params['id'])) return false;\n $product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);\n $product = new $product_type($this->params['id'], true, false);\n //eDebug($product_type); \n //eDebug($product, true);\n //if (!empty($product->product_type_id)) {\n //$db->delete($product_type, 'id='.$product->product_id);\n //}\n\n $db->delete('option', 'product_id=' . $product->id . \" AND optiongroup_id IN (SELECT id from \" . $db->prefix . \"optiongroup WHERE product_id=\" . $product->id . \")\");\n $db->delete('optiongroup', 'product_id=' . $product->id);\n //die();\n $db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type=\"' . $product_type . '\"');\n\n if ($product->product_type == \"product\") {\n if ($product->hasChildren()) {\n $this->deleteChildren();\n }\n }\n\n $product->delete();\n\n flash('message', gt('Product deleted successfully.'));\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function popBeforeSmtp(\n $host,\n $port = false,\n $timeout = false,\n $username = '',\n $password = '',\n $debug_level = 0\n ) {\n $pop = new POP3;\n return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function updatePassword(Db $zdb, $id_adh, $pass)\n {\n try {\n $cpass = password_hash($pass, PASSWORD_BCRYPT);\n\n $update = $zdb->update(self::TABLE);\n $update->set(\n array('mdp_adh' => $cpass)\n )->where(self::PK . ' = ' . $id_adh);\n $zdb->execute($update);\n Analog::log(\n 'Password for `' . $id_adh . '` has been updated.',\n Analog::DEBUG\n );\n return true;\n } catch (Throwable $e) {\n Analog::log(\n 'An error occurred while updating password for `' . $id_adh .\n '` | ' . $e->getMessage(),\n Analog::ERROR\n );\n throw $e;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function categoryBreadcrumb() {\n// global $db, $router;\n\n //eDebug($this->category);\n\n /*if(isset($router->params['action']))\n {\n $ancestors = $this->category->pathToNode(); \n }else if(isset($router->params['section']))\n {\n $current = $db->selectObject('section',' id= '.$router->params['section']);\n $ancestors[] = $current;\n if( $current->parent != -1 || $current->parent != 0 )\n { \n while ($db->selectObject('section',' id= '.$router->params['section']);)\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n eDebug($sections);\n $ancestors = $this->category->pathToNode(); \n }*/\n\n $ancestors = $this->category->pathToNode();\n // eDebug($ancestors);\n assign_to_template(array(\n 'ancestors' => $ancestors\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_SAVE, 'fas fa-save', null, 'primary', null, 'btn-success xxx text-white mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('tax_rates.php', 'page=' . $_GET['page']), null, null, 'btn-light')];", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function remove() {\r\n global $db;\r\n\r\n $section = $db->selectObject('section', 'id=' . $this->params['id']);\r\n if ($section) {\r\n section::removeLevel($section->id);\r\n $db->decrement('section', 'rank', 1, 'rank > ' . $section->rank . ' AND parent=' . $section->parent);\r\n $section->parent = -1;\r\n $db->updateObject($section, 'section');\r\n expSession::clearAllUsersSessionCache('navigation');\r\n expHistory::back();\r\n } else {\r\n notfoundController::handle_not_authorized();\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testOneTag()\n {\n $this->assertProduces('[b]this is bold[/b]', 'this is bold');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function searchCategory() {\n return gt('Event');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " function getTimeOut()\n {\n return $this->timeout;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function mb_substr_count($haystack, $needle, $enc = null) { return p\\Mbstring::mb_substr_count($haystack, $needle, $enc); }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function update_option_master() { \n global $db;\n\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $opt = new option_master($id);\n $oldtitle = $opt->title;\n \n $opt->update($this->params);\n \n // if the title of the master changed we should update the option groups that are already using it.\n if ($oldtitle != $opt->title) {\n \n }$db->sql('UPDATE '.$db->prefix.'option SET title=\"'.$opt->title.'\" WHERE option_master_id='.$opt->id);\n \n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function getTrustedProxyData()\n {\n return array(\n array(array(), array('127.0.0.1')),\n array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')),\n array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')),\n );\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " protected function execute(InputInterface $input, OutputInterface $output)\n {\n $io = new SymfonyStyle($input, $output);\n\n $io->title('Kimai installation running ...');\n\n /** @var Application $application */\n $application = $this->getApplication();\n /** @var KernelInterface $kernel */\n $kernel = $application->getKernel();\n $environment = $kernel->getEnvironment();\n\n // create the database, in case it is not yet existing\n try {\n $this->createDatabase($io, $input, $output);\n } catch (\\Exception $ex) {\n $io->error('Failed to create database: ' . $ex->getMessage());\n\n return self::ERROR_DATABASE;\n }\n\n // bootstrap database ONLY via doctrine migrations, so all installation will have the correct and same state\n try {\n $this->importMigrations($io, $output);\n } catch (\\Exception $ex) {\n $io->error('Failed to set migration status: ' . $ex->getMessage());\n\n return self::ERROR_MIGRATIONS;\n }\n\n if (!$input->getOption('no-cache')) {\n // flush the cache, just to make sure ... and ignore result\n $this->rebuildCaches($environment, $io, $input, $output);\n }\n\n $io->success(\n sprintf('Congratulations! Successfully installed %s version %s (%s)', Constants::SOFTWARE, Constants::VERSION, Constants::STATUS)\n );\n\n return 0;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": " public function __construct() {\n $this->idDef = new HTMLPurifier_AttrDef_HTML_ID();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " foreach ($nodes as $node) {\r\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n if ($node->active == 1) {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $ar[$node->id] = $text;\r\n foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {\r\n $ar[$id] = $text;\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction delete_vendor() {\n\t\tglobal $db;\n\n if (!empty($this->params['id'])){\n\t\t\t$db->delete('vendor', 'id =' .$this->params['id']);\n\t\t}\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function __construct() {\n $this->_entity_parser = new HTMLPurifier_EntityParser();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function getFilePath($fileName = null)\n {\n if ($fileName === null) {\n $fileName = $this->fileName;\n }\n\n return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-98", "cwe_name": "Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')", "description": "The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in \"require,\" \"include,\" or similar functions.", "url": "https://cwe.mitre.org/data/definitions/98.html", "label_name": "vulnerable"} {"code": " public function destroy($sessionId)\n {\n $this->getCollection()->remove(array(\n $this->options['id_field'] => $sessionId,\n ));\n\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testWithQueryValueHandlesEncoding()\n {\n $uri = new Uri();\n $uri = Uri::withQueryValue($uri, 'E=mc^2', 'ein&stein');\n $this->assertSame('E%3Dmc%5E2=ein%26stein', $uri->getQuery(), 'Decoded key/value get encoded');\n\n $uri = new Uri();\n $uri = Uri::withQueryValue($uri, 'E%3Dmc%5e2', 'ein%26stein');\n $this->assertSame('E%3Dmc%5e2=ein%26stein', $uri->getQuery(), 'Encoded key/value do not get double-encoded');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function delete() {\n\t global $db;\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\t \n\t if (empty($this->params['id'])) {\n\t flash('error', gt('Missing id for the comment you would like to delete'));\n\t expHistory::back();\n\t }\n\t \n\t // delete the comment\n $comment = new expComment($this->params['id']);\n $comment->delete();\n \n // delete the association too\n $db->delete($comment->attachable_table, 'expcomments_id='.$this->params['id']); \n \n // send the user back where they came from.\n expHistory::back();\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction lockTable($table,$lockType=\"WRITE\") {\n $sql = \"LOCK TABLES `\" . $this->prefix . \"$table` $lockType\";\n\n $res = mysqli_query($this->connection, $sql);\n return $res;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function XMLRPCtest($string) {\n\t$string = processInputData($string, ARG_STRING);\n\treturn array('status' => 'success',\n\t 'message' => 'RPC call worked successfully',\n\t 'string' => $string);\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function open($savePath, $sessionName)\n {\n return (bool) $this->handler->open($savePath, $sessionName);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function rules()\n {\n $rules = [];\n $inputs = $this->all();\n\n $validateEmail = false;\n $validateUsername = false;\n\n\n\n if (!isset($inputs['username']) || !isset($inputs['email'])) {\n $validateUsername = true;\n }\n\n if (isset($inputs['email']) && !isset($inputs['username'])) {\n $validateUsername = false;\n $validateEmail = true;\n }\n\n if (isset($inputs['email']) && isset($inputs['username'])) {\n $validateUsername = true;\n $validateEmail = true;\n }\n\n if ($validateEmail) {\n $rules['email'] = 'email|string|min:3|required|string|max:255|unique:users';\n }\n\n if ($validateUsername) {\n $rules['username'] = 'alpha_dash|string|min:1|required|string|max:255|unique:users';\n }\n if (isset($inputs['confirm_password'])) {\n $rules['confirm_password'] = 'required|min:1|same:password';\n }\n\n if (get_option('captcha_disabled', 'users') !== 'y') {\n $rules['captcha'] = 'captcha';\n }\n\n if (isset($inputs['email']) && $inputs['email'] != false && ((get_option('disable_registration_with_temporary_email', 'users') == 'y'))) {\n $rules['email'] = $rules['email'] . '|temporary_email_check';\n }\n\n if (get_option('require_terms', 'users') == 'y') {\n $rules['terms'] = 'terms:terms_user';\n if (isset($inputs['newsletter_subscribe']) and $inputs['newsletter_subscribe']) {\n $rules['terms'] = $rules['terms'] . ', terms_newsletter';\n }\n }\n $rules['password'] = 'required|min:1|max:500';\n\n\n return $rules;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": " public function actionDeleteDropdown() {\n $dropdowns = Dropdowns::model()->findAll('id>=1000');\n\n if (isset($_POST['dropdown'])) {\n if ($_POST['dropdown'] != Actions::COLORS_DROPDOWN_ID) {\n $model = Dropdowns::model()->findByPk($_POST['dropdown']);\n $model->delete();\n $this->redirect('manageDropDowns');\n }\n }\n\n $this->render('deleteDropdowns', array(\n 'dropdowns' => $dropdowns,\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function returnChildrenAsJSON() {\r\n global $db;\r\n\r\n //$nav = section::levelTemplate(intval($_REQUEST['id'], 0));\r\n $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;\r\n $nav = $db->selectObjects('section', 'parent=' . $id, 'rank');\r\n //FIXME $manage_all is moot w/ cascading perms now?\r\n $manage_all = false;\r\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {\r\n $manage_all = true;\r\n }\r\n //FIXME recode to use foreach $key=>$value\r\n $navcount = count($nav);\r\n for ($i = 0; $i < $navcount; $i++) {\r\n if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {\r\n $nav[$i]->manage = 1;\r\n $view = true;\r\n } else {\r\n $nav[$i]->manage = 0;\r\n $view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));\r\n }\r\n $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);\r\n if (!$view) unset($nav[$i]);\r\n }\r\n $nav= array_values($nav);\r\n// $nav[$navcount - 1]->last = true;\r\n if (count($nav)) $nav[count($nav) - 1]->last = true;\r\n// echo expJavascript::ajaxReply(201, '', $nav);\r\n $ar = new expAjaxReply(201, '', $nav);\r\n $ar->send();\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " protected function setUp()\n {\n static::$functions = [];\n static::$fopen = null;\n static::$fread = null;\n parent::setUp();\n $this->security = new ExposedSecurity();\n $this->security->derivationIterations = 1000; // speed up test running\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": "\tpublic function approve_submit() {\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('No ID supplied for comment to approve'));\n\t expHistory::back();\n\t }\n\n /* The global constants can be overriden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n\t $comment = new expComment($this->params['id']);\n\t $comment->body = $this->params['body'];\n\t $comment->approved = $this->params['approved'];\n\t $comment->save();\n\t expHistory::back();\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $cleanedArray[$key] = $this->clean($value);\n }\n\n return $cleanedArray;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\t\t\t} elseif (!is_numeric($item) && ($item != '')) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t} else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " public function update()\n {\n $project = $this->getProject();\n $tag_id = $this->request->getIntegerParam('tag_id');\n $tag = $this->tagModel->getById($tag_id);\n $values = $this->request->getValues();\n list($valid, $errors) = $this->tagValidator->validateModification($values);\n\n if ($tag['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n if ($valid) {\n if ($this->tagModel->update($values['id'], $values['name'])) {\n $this->flash->success(t('Tag updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this tag.'));\n }\n\n $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));\n } else {\n $this->edit($values, $errors);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic function ffmpegToImg($file, $stat) {\n\t\t$name = basename($file);\n\t\t$path = dirname($file);\n\t\t$tmp = $path . DIRECTORY_SEPARATOR . md5($name);\n\t\t$GLOBALS['elFinderTempFiles'][] = $tmp; // regist to remove at the end\n\t\tif (rename($file, $tmp)) {\n\t\t\t// specific start time by file name (xxx^[sec].[extention] - video^3.mp4)\n\t\t\tif (preg_match('/\\^(\\d+(?:\\.\\d+)?)\\.[^.]+$/', $stat['name'], $_m)) {\n\t\t\t\t$ss = $_m[1];\n\t\t\t} else {\n\t\t\t\t$ss = $this->options['tmbVideoConvSec'];\n\t\t\t}\n\t\t\t$cmd = sprintf('ffmpeg -ss 00:00:%.3f -vframes 1 -i %s -f image2 %s', $ss, escapeshellarg($tmp), escapeshellarg($file));\n\t\t\t$r = $this->procExec($cmd);\n\t\t\tunlink($tmp);\n\t\t\treturn ($r === 0);\n\t\t}\n\t\treturn false;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic static function isAnimationGif($path) {\n\t\tlist($width, $height, $type, $attr) = getimagesize($path);\n\t\tswitch ($type) {\n\t\t\tcase IMAGETYPE_GIF:\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t\n\t\t$imgcnt = 0;\n\t\t$fp = fopen($path, 'rb');\n\t\t@fread($fp, 4);\n\t\t$c = @fread($fp,1);\n\t\tif (ord($c) != 0x39) { // GIF89a\n\t\t\treturn false;\n\t\t}\n\t\n\t\twhile (!feof($fp)) {\n\t\t\tdo {\n\t\t\t\t$c = fread($fp, 1);\n\t\t\t} while(ord($c) != 0x21 && !feof($fp));\n\t\n\t\t\tif (feof($fp)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\n\t\t\t$c2 = fread($fp,2);\n\t\t\tif (bin2hex($c2) == \"f904\") {\n\t\t\t\t$imgcnt++;\n\t\t\t}\n\t\n\t\t\tif (feof($fp)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\n\t\tif ($imgcnt > 1) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function actionGetItems(){\n $model = X2Model::model ($this->modelClass);\n if (isset ($model)) {\n list ($accessCond, $params) = $model->getAccessSQLCondition ();\n $tableName = $model->tableName ();\n $sql = \n 'SELECT id, fileName as value\n FROM '.$tableName.' \n WHERE associationType!=\"theme\" and fileName LIKE :qterm AND '.$accessCond.' AND\n (uploadedBy=:username OR private=0 OR private=NULL)\n ORDER BY fileName ASC';\n $command = Yii::app()->db->createCommand($sql);\n $qterm = $_GET['term'].'%';\n $params[':qterm'] = $qterm;\n $params[':username'] = Yii::app()->user->getName ();\n $result = $command->queryAll(true, $params);\n echo CJSON::encode($result);\n }\n Yii::app()->end();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $def = new HTMLPurifier_URIDefinition();\n } else {\n throw new HTMLPurifier_Exception(\"Definition of $type type not supported\");\n }\n $this->definitions[$type] = $def;\n return $def;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic static function login() {\n\t\tuser::login(expString::escape(expString::sanitize($_POST['username'])),expString::escape(expString::sanitize($_POST['password'])));\n\t\tif (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in\n\t\t\tflash('error', gt('Invalid Username / Password'));\n\t\t\tif (expSession::is_set('redirecturl_error')) {\n\t\t\t\t$url = expSession::get('redirecturl_error');\n\t\t\t\texpSession::un_set('redirecturl_error');\n\t\t\t\theader(\"Location: \".$url);\n\t\t\t} else {\n\t\t\t\texpHistory::back();\n\t\t\t}\n\t\t} else { // we're logged in\n\t\t\tglobal $user;\n\n if (expSession::get('customer-login')) expSession::un_set('customer-login');\n\t\t\tif (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));\n if ($user->isAdmin()) {\n expHistory::back();\n } else {\n foreach ($user->groups as $g) {\n if (!empty($g->redirect)) {\n $url = URL_FULL.$g->redirect;\n break;\n }\n }\n if (isset($url)) {\n header(\"Location: \".$url);\n } else {\n expHistory::back();\n }\n }\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));\n\n $this->response->html($this->helper->layout->project('custom_filter/remove', array(\n 'project' => $project,\n 'filter' => $filter,\n 'title' => t('Remove a custom filter')\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "function article_save()\n{\n global $txp_user, $vars, $prefs;\n\n extract($prefs);\n\n $incoming = array_map('assert_string', psa($vars));\n\n $oldArticle = safe_row('Status, url_title, Title, textile_body, textile_excerpt, '.\n 'unix_timestamp(LastMod) as sLastMod, LastModID, '.\n 'unix_timestamp(Posted) as sPosted, '.\n 'unix_timestamp(Expires) as sExpires',\n 'textpattern', 'ID = '.(int) $incoming['ID']);", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " public static function canImportData() {\r\n return true;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function show()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask_converter/show', array(\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " function edit_freeform() {\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\n if ($section->parent == -1) {\n notfoundController::handle_not_found();\n exit;\n } // doesn't work for standalone pages\n if (empty($section->id)) {\n $section->public = 1;\n if (!isset($section->parent)) {\n // This is another precaution. The parent attribute\n // should ALWAYS be set by the caller.\n //FJD - if that's the case, then we should die.\n notfoundController::handle_not_authorized();\n exit;\n //$section->parent = 0;\n }\n }\n assign_to_template(array(\n 'section' => $section,\n 'glyphs' => self::get_glyphs(),\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function isPublic($s) {\r\n if ($s == null) {\r\n return false;\r\n }\r\n while ($s->public && $s->parent > 0) {\r\n $s = new section($s->parent);\r\n }\r\n $lineage = (($s->public) ? 1 : 0);\r\n return $lineage;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function beforeSave() {\n if(strpos($this->tag,self::DELIM) !== false) {\n $this->tag = strtr($this->tag,array(self::DELIM => ''));\n }\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function searchName() { return gt('Webpage'); }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function event()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n $values['project_id'] = $project['id'];\n\n if (empty($values['action_name'])) {\n return $this->create();\n }\n\n return $this->response->html($this->template->render('action_creation/event', array(\n 'values' => $values,\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public function __construct(string $user = null, string $field = 'id') {\n $this->_db = DB::getInstance();\n $this->_sessionName = Config::get('session.session_name');\n $this->_cookieName = Config::get('remember.cookie_name');\n $this->_admSessionName = Config::get('session.admin_name');\n\n if ($user === null) {\n if (Session::exists($this->_sessionName)) {\n $user = Session::get($this->_sessionName);\n if ($this->find($user, $field)) {\n $this->_isLoggedIn = true;\n }\n }\n if (Session::exists($this->_admSessionName)) {\n $user = Session::get($this->_admSessionName);\n if ($user == $this->data()->id && $this->find($user, $field)) {\n $this->_isAdmLoggedIn = true;\n }\n }\n } else {\n $this->find($user, $field);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": " $newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);\n if (!empty($newret)) $ret .= $newret . '
    ';\n if ($iLoc->mod == 'container') {\n $ret .= scan_container($container->internal, $page_id);\n }\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function __construct($apikey){\r\n \r\n $this->apikey = $apikey;\r\n $this->config = $this->getConfig($apikey);\r\n //echo $this->apikey;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask/remove', array(\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function __construct($config) {\n $def = $config->getCSSDefinition();\n $this->info['border-width'] = $def->info['border-width'];\n $this->info['border-style'] = $def->info['border-style'];\n $this->info['border-top-color'] = $def->info['border-top-color'];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tprotected function GetRefs($refList, $type)\n\t{\n\t\tif (!$refList)\n\t\t\treturn;\n\n\t\tif (empty($type))\n\t\t\treturn;\n\n\t\t$args = array();\n\t\t$args[] = '--' . $type;\n\t\t$args[] = '--dereference';\n\t\t$ret = $this->exe->Execute($refList->GetProject()->GetPath(), GIT_SHOW_REF, $args);\n\n\t\t$lines = explode(\"\\n\", $ret);\n\n\t\t$refs = array();\n\t\t$commits = array();\n\n\t\tforeach ($lines as $line) {\n\t\t\tif (preg_match('/^([0-9a-fA-F]{40}) refs\\/' . $type . '\\/([^^]+)(\\^{})?$/', $line, $regs)) {\n\t\t\t\tif (!empty($regs[3]) && ($regs[3] == '^{}')) {\n\t\t\t\t\t$commits[$regs[2]] = $regs[1];\n\t\t\t\t} else {\n\t\t\t\t\t$refs[$regs[2]] = $regs[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn array($refs, $commits);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " function function_exists($name)\n {\n if (isset(\\yiiunit\\framework\\base\\SecurityTest::$functions[$name])) {\n return \\yiiunit\\framework\\base\\SecurityTest::$functions[$name];\n }\n\n return \\function_exists($name);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": " public function buildCurrentUrl() {\n $url = URL_BASE;\n if ($this->url_style == 'sef') {\n $url .= substr(PATH_RELATIVE,0,-1).$this->sefPath;\n } else {\n $url .= urldecode((empty($_SERVER['REQUEST_URI'])) ? $_ENV['REQUEST_URI'] : $_SERVER['REQUEST_URI']);\n }\n return expString::escape(expString::sanitize($url));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction test_anon_comments_require_email() {\n\t\tadd_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' );\n\n\t\t$comment_args = array(\n\t\t\t1,\n\t\t\t'',\n\t\t\t'',\n\t\t\tself::$post->ID,\n\t\t\tarray(\n\t\t\t\t'author' => 'WordPress',\n\t\t\t\t'author_email' => 'noreply at wordpress.org',\n\t\t\t\t'content' => 'Test Anon Comments',\n\t\t\t),\n\t\t);\n\n\t\t$result = $this->myxmlrpcserver->wp_newComment( $comment_args );\n\t\t$this->assertIXRError( $result );\n\t\t$this->assertSame( 403, $result->code );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": " protected function getProjectTag(array $project)\n {\n $tag = $this->tagModel->getById($this->request->getIntegerParam('tag_id'));\n\n if (empty($tag)) {\n throw new PageNotFoundException();\n }\n\n if ($tag['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $tag;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "\t\t$context['clockicons'] = unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " public function removeOverNestedElements()\n {\n $nestLimitVisitor = new \\JBBCode\\visitors\\NestLimitVisitor();\n $this->accept($nestLimitVisitor);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function remove()\n {\n $project = $this->getProject();\n $this->checkCSRFParam();\n $column_id = $this->request->getIntegerParam('column_id');\n\n if ($this->columnModel->remove($column_id)) {\n $this->flash->success(t('Column removed successfully.'));\n } else {\n $this->flash->failure(t('Unable to remove this column.'));\n }\n\n $this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " } elseif (!empty($this->params['src'])) {\n if ($this->params['src'] == $loc->src) {\n $this->config = $config->config;\n break;\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function download_selected($dir)\n{\n require_once(\"_include/fun_archive.php\");\n $items = qxpage_selected_items();\n _download_items($dir, $items);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " public function checkPermissions (&$model, $action=null) {\n return Yii::app()->params->isAdmin || \n (!$model->private || $model->uploadedBy === Yii::app()->user->name) && \n $this->asa ('PermissionsBehavior')->checkPermissions ($model, $action);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function searchName() { return gt('Webpage'); }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function captureAuthorization() {\n //eDebug($this->params,true);\n $order = new order($this->params['id']);\n /*eDebug($this->params); \n //eDebug($order,true);*/\n //eDebug($order,true);\n //$billing = new billing();\n\n //eDebug($billing, true);\n //$billing->calculator = new $calcname($order->billingmethod[0]->billingcalculator_id);\n $calc = $order->billingmethod[0]->billingcalculator->calculator;\n $calc->config = $order->billingmethod[0]->billingcalculator->config;\n\n //$calc = new $calc-\n //eDebug($calc,true);\n if (!method_exists($calc, 'delayed_capture')) {\n flash('error', gt('The Billing Calculator does not support delayed capture'));\n expHistory::back();\n }\n\n $result = $calc->delayed_capture($order->billingmethod[0], $this->params['capture_amt'], $order);\n\n if (empty($result->errorCode)) {\n flash('message', gt('The authorized payment was successfully captured'));\n expHistory::back();\n\n } else {\n flash('error', gt('An error was encountered while capturing the authorized payment.') . '

    ' . $result->message);\n expHistory::back();\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function edit_option_master() {\n expHistory::set('editable', $this->params);\n \n $params = isset($this->params['id']) ? $this->params['id'] : $this->params;\n $record = new option_master($params); \n assign_to_template(array(\n 'record'=>$record\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function toolbar() {\n// global $user;\n\n $menu = array();\n\t\t$dirs = array(\n\t\t\tBASE.'framework/modules/administration/menus',\n\t\t\tBASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'\n\t\t);\n\n\t\tforeach ($dirs as $dir) {\n\t\t if (is_readable($dir)) {\n\t\t\t $dh = opendir($dir);\n\t\t\t while (($file = readdir($dh)) !== false) {\n\t\t\t\t if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {\n\t\t\t\t\t $menu[substr($file,0,-4)] = include($dir.'/'.$file);\n if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\t\t}\n\n // sort the top level menus alphabetically by filename\n\t\tksort($menu);\n\t\t$sorted = array();\n\t\tforeach($menu as $m) $sorted[] = $m;\n\n // slingbar position\n if (isset($_COOKIE['slingbar-top'])){\n $top = $_COOKIE['slingbar-top'];\n } else {\n $top = SLINGBAR_TOP;\n }\n\n\t\tassign_to_template(array(\n 'menu'=>(bs3()) ? $sorted : json_encode($sorted),\n \"top\"=>$top\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public static function format($date, $format='') {\r\n $timezone = Options::v('timezone');\r\n $time = strtotime($date);\r\n (empty($format))? $format = \"j F Y H:i A T\" : $format = $format;\r\n $date = new DateTime($date);\r\n $date->setTimezone(new DateTimeZone($timezone));\r\n $newdate = $date->format($format);\r\n return $newdate;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($value as $val) {\n $this->allowedUrls[$key][] = $val;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __construct(OrderService $orderService)\n {\n $this->orderService = $orderService;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " public function actionDeleteDropdown() {\n $dropdowns = Dropdowns::model()->findAll();\n\n if (isset($_POST['dropdown'])) {\n if ($_POST['dropdown'] != Actions::COLORS_DROPDOWN_ID) {\n $model = Dropdowns::model()->findByPk($_POST['dropdown']);\n $model->delete();\n $this->redirect('manageDropDowns');\n }\n }\n\n $this->render('deleteDropdowns', array(\n 'dropdowns' => $dropdowns,\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public static function html() {\r\n new Xaptcha();\r\n $html = \"
    \r\n
    \r\n \";\r\n if (self::isEnable()) {\r\n return $html;\r\n }else{\r\n return '';\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function captureAuthorization() {\n //eDebug($this->params,true);\n $order = new order($this->params['id']);\n /*eDebug($this->params); \n //eDebug($order,true);*/\n //eDebug($order,true);\n //$billing = new billing();\n\n //eDebug($billing, true);\n //$billing->calculator = new $calcname($order->billingmethod[0]->billingcalculator_id);\n $calc = $order->billingmethod[0]->billingcalculator->calculator;\n $calc->config = $order->billingmethod[0]->billingcalculator->config;\n\n //$calc = new $calc-\n //eDebug($calc,true);\n if (!method_exists($calc, 'delayed_capture')) {\n flash('error', gt('The Billing Calculator does not support delayed capture'));\n expHistory::back();\n }\n\n $result = $calc->delayed_capture($order->billingmethod[0], $this->params['capture_amt'], $order);\n\n if (empty($result->errorCode)) {\n flash('message', gt('The authorized payment was successfully captured'));\n expHistory::back();\n\n } else {\n flash('error', gt('An error was encountered while capturing the authorized payment.') . '

    ' . $result->message);\n expHistory::back();\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " static function author() {\r\n return \"Dave Leffler\";\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function make($config) {\n return clone $this->get($this->getDoctypeFromConfig($config));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic function check(&$params){\n $tags = $this->config['options']['tags']['value'];\n $tags = is_array($tags) ? $tags : Tags::parseTags($tags, true);\n if(!empty($tags) && isset($params['tags'])){ // Check passed params to be sure they're set\n if(!is_array($params['tags'])){\n $params['tags'] = explode(',', $params['tags']);\n }\n $params['tags'] = array_map(function($item){ \n return preg_replace('/^#/','', $item); \n }, $params['tags']);\n\n // must have at least 1 tag in the list:\n if(count(array_intersect($params['tags'], $tags)) > 0){\n return $this->checkConditions($params);\n }else{\n return array(false, Yii::t('studio','No tags on the record matched those in the tag trigger criteria.'));\n }\n }else{ // config is invalid or record has no tags (tags are not optional)\n return array(false, empty($tags) ? Yii::t('studio','No tags in the trigger criteria!') : Yii::t('studio','Tags parameter missing!'));\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " $criteria->addCondition (\n 'user IN (' .\n 'SELECT DISTINCT b.username ' .\n 'FROM x2_group_to_user a JOIN x2_group_to_user b ' .\n 'ON a.groupId=b.groupId ' .\n 'WHERE a.username=:getAccessCriteria_username' .\n ') OR (user = :getAccessCriteria_username)');\n } else { // default history privacy (public or assigned)\n $criteria->addCondition (\"(user=:getAccessCriteria_username OR visibility=1)\");\n }\n }\n\n if ($profile) {\n $criteria->params[':getAccessCriteria_profileUsername'] = $profile->username;\n /* only show events associated with current profile which current user has\n permission to see */\n $criteria->addCondition (\"user=:getAccessCriteria_profileUsername\");\n if (!Yii::app()->params->isAdmin) {\n $criteria->addCondition (\"visibility=1\");\n }\n }\n return $criteria;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function actionView($id){\n\n // add media object to user's recent item list\n User::addRecentItem('m', $id, Yii::app()->user->getId()); \n\n $this->render('view', array(\n 'model' => $this->loadModel($id),\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\tpublic function setLoggerChannel($channel = 'Organizr', $username = null)\n\t{\n\t\tif ($this->hasDB()) {\n\t\t\t$setLogger = false;\n\t\t\tif ($username) {\n\t\t\t\t$username = htmlspecialchars($username);\n\t\t\t}\n\t\t\tif ($this->logger) {\n\t\t\t\tif ($channel) {\n\t\t\t\t\tif (strtolower($this->logger->getChannel()) !== strtolower($channel)) {\n\t\t\t\t\t\t$setLogger = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ($username) {\n\t\t\t\t\tif (strtolower($this->logger->getTraceId()) !== strtolower($channel)) {\n\t\t\t\t\t\t$setLogger = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$setLogger = true;\n\t\t\t}\n\t\t\tif ($setLogger) {\n\t\t\t\t$channel = $channel ?: 'Organizr';\n\t\t\t\treturn $this->setupLogger($channel, $username);\n\t\t\t} else {\n\t\t\t\treturn $this->logger;\n\t\t\t}\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " static function description() {\r\n return \"Manage events and schedules, and optionally publish them.\";\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public static function mb_output_handler($contents, $status)\n {\n return $contents;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function get_info($object_id, $table_name = '')\n {\n $table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));\n\n // Make sure we've got a real id\n if ($object_id < 1) {\n return array();\n }\n\n if (self::is_cached($table_name, $object_id)) {\n return self::get_from_cache($table_name, $object_id);\n }\n\n $sql = \"SELECT * FROM `$table_name` WHERE `id`='$object_id'\";\n $db_results = Dba::read($sql);\n\n if (!$db_results) {\n return array();\n }\n\n $row = Dba::fetch_assoc($db_results);\n\n self::add_to_cache($table_name, $object_id, $row);\n\n return $row;\n } // get_info", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function process_subsections($parent_section, $subtpl) {\r\n global $db, $router;\r\n\r\n $section = new stdClass();\r\n $section->parent = $parent_section->id;\r\n $section->name = $subtpl->name;\r\n $section->sef_name = $router->encode($section->name);\r\n $section->subtheme = $subtpl->subtheme;\r\n $section->active = $subtpl->active;\r\n $section->public = $subtpl->public;\r\n $section->rank = $subtpl->rank;\r\n $section->page_title = $subtpl->page_title;\r\n $section->keywords = $subtpl->keywords;\r\n $section->description = $subtpl->description;\r\n $section->id = $db->insertObject($section, 'section');\r\n self::process_section($section, $subtpl);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function action_edge_mode_enable() {\n w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/activation.php');\n $config_path = w3_get_wp_config_path();\n\n $config_data = @file_get_contents($config_path);\n if ($config_data === false)\n return;\n\n $new_config_data = $this->wp_config_evaluation_mode_remove_from_content($config_data);\n $new_config_data = preg_replace(\n '~<\\?(php)?~',\n \"\\\\0\\r\\n\" . $this->wp_config_evaluation_mode(),\n $new_config_data,\n 1);\n\n if ($new_config_data != $config_data) {\n try {\n w3_wp_write_to_file($config_path, $new_config_data);\n } catch (FilesystemOperationException $ex) {\n throw new FilesystemModifyException(\n $ex->getMessage(), $ex->credentials_form(),\n 'Edit file ' . $config_path .\n ' and add the next lines:', $config_path,\n $this->wp_config_evaluation_mode());\n }\n try {\n $this->_config_admin->set('notes.edge_mode', false);\n $this->_config_admin->save();\n } catch (Exception $ex) {}\n }\n w3_admin_redirect(array('w3tc_note' => 'enabled_edge'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " $retVal = preg_replace_callback ($pattern, $callback, $subject, $limit);\n } else {\n $retVal = preg_replace_callback ($pattern, $callback, $subject);\n }\n if ($throws && $retVal === null) {\n throw new StringUtilException (\n Yii::t('app', 'preg_replace_callback error: '.\n StringUtilException::getErrorMessage (preg_last_error ())), \n StringUtilException::PREG_REPLACE_CALLBACK_ERROR);\n }\n return $retVal;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function show()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask_restriction/show', array(\n 'status_list' => array(\n SubtaskModel::STATUS_TODO => t('Todo'),\n SubtaskModel::STATUS_DONE => t('Done'),\n ),\n 'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()),\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " function insertObject($object, $table) {\n //if ($table==\"text\") eDebug($object,true); \n $sql = \"INSERT INTO `\" . $this->prefix . \"$table` (\";\n $values = \") VALUES (\";\n foreach (get_object_vars($object) as $var => $val) {\n //We do not want to save any fields that start with an '_'\n if ($var{0} != '_') {\n $sql .= \"`$var`,\";\n if ($values != \") VALUES (\") {\n $values .= \",\";\n }\n $values .= \"'\" . $this->escapeString($val) . \"'\";\n }\n }\n $sql = substr($sql, 0, -1) . substr($values, 0) . \")\";\n //if($table=='text')eDebug($sql,true);\n if (@mysqli_query($this->connection, $sql) != false) {\n $id = mysqli_insert_id($this->connection);\n return $id;\n } else\n return 0;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " protected function addOrEnqueueAnAddress($kind, $address, $name)\n {\n $address = trim($address);\n $name = trim(preg_replace('/[\\r\\n]+/', '', $name)); //Strip breaks and trim\n if (($pos = strrpos($address, '@')) === false) {\n // At-sign is misssing.\n $error_message = $this->lang('invalid_address') . \" (addAnAddress $kind): $address\";\n $this->setError($error_message);\n $this->edebug($error_message);\n if ($this->exceptions) {\n throw new phpmailerException($error_message);\n }\n return false;\n }\n $params = array($kind, $address, $name);\n // Enqueue addresses with IDN until we know the PHPMailer::$CharSet.\n if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) {\n if ($kind != 'Reply-To') {\n if (!array_key_exists($address, $this->RecipientsQueue)) {\n $this->RecipientsQueue[$address] = $params;\n return true;\n }\n } else {\n if (!array_key_exists($address, $this->ReplyToQueue)) {\n $this->ReplyToQueue[$address] = $params;\n return true;\n }\n }\n return false;\n }\n // Immediately add standard addresses without IDN.\n return call_user_func_array(array($this, 'addAnAddress'), $params);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static function add()\n {\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function getC3Service()\n {\n include_once $this->targetDirs[1].'/includes/HotPath/C3.php';\n\n return $this->services['Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Fixtures\\\\includes\\\\HotPath\\\\C3'] = new \\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C3();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function mb_strtolower($s, $encoding = null)\n {\n return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " static function isSearchable() { return true; }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function __destruct()\n\t{\n\t\tif (class_exists('ZipArchive')) {\n\t\t\t$this->Zip->close();\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " function __unserialize($data)\n {}", "label": 1, "programming_language": "PHP", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "function barcode_encode_genbarcode($code,$encoding)\n{\n global $genbarcode_loc;\n\n // Clean parameters\n if (preg_match(\"/^ean$/i\", $encoding) && strlen($code)==13) $code=substr($code,0,12);\n if (!$encoding) $encoding=\"ANY\";\n $encoding=preg_replace(\"/[\\\\\\|]/\", \"_\", $encoding);\n $code=preg_replace(\"/[\\\\\\|]/\", \"_\", $code);\n\n $command=escapeshellarg($genbarcode_loc);\n //$paramclear=\" \\\"\".str_replace(\"\\\"\", \"\\\\\\\"\",$code).\"\\\" \\\"\".str_replace(\"\\\"\", \"\\\\\\\"\",strtoupper($encoding)).\"\\\"\";\n $paramclear=\" \".escapeshellarg($code).\" \".escapeshellarg(strtoupper($encoding));\r\n \n $fullcommandclear=$command.\" \".$paramclear.\" 2>&1\";\n //print $fullcommandclear.\"
    \\n\";exit;\n\n dol_syslog(\"Run command \".$fullcommandclear);\n $fp=popen($fullcommandclear, \"r\");\n if ($fp)\n {\n $bars=fgets($fp, 1024);\n $text=fgets($fp, 1024);\n $encoding=fgets($fp, 1024);\n pclose($fp);\n }\n else\n {\n dol_syslog(\"barcode.lib.php::barcode_encode_genbarcode failed to run popen \".$fullcommandclear, LOG_ERR);\n return false;\n }\n //var_dump($bars);\n $ret=array(\n\t\t\"bars\" => trim($bars),\n\t\t\"text\" => trim($text),\n\t\t\"encoding\" => trim($encoding),\n \t\"error\" => \"\"\n );\n //var_dump($ret);\n if (preg_match('/permission denied/i',$ret['bars'])) \n { \n \t$ret['error']=$ret['bars']; $ret['bars']='';\n \treturn $ret;\n }\n if (!$ret['bars']) return false;\n if (!$ret['text']) return false;\n if (!$ret['encoding']) return false;\n return $ret;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " } elseif ($trusted || $check_comments) {\n // always cleanup comments\n $trailing_hyphen = false;\n if ($e) {\n // perform check whether or not there's a trailing hyphen\n if (substr($token->data, -1) == '-') {\n $trailing_hyphen = true;\n }\n }\n $token->data = rtrim($token->data, '-');\n $found_double_hyphen = false;\n while (strpos($token->data, '--') !== false) {\n $found_double_hyphen = true;\n $token->data = str_replace('--', '-', $token->data);\n }\n if ($trusted || !empty($comment_lookup[trim($token->data)]) || ($comment_regexp !== NULL && preg_match($comment_regexp, trim($token->data)))) {\n // OK good\n if ($e) {\n if ($trailing_hyphen) {\n $e->send(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed');\n }\n if ($found_double_hyphen) {\n $e->send(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed');\n }\n }\n } else {\n if ($e) {\n $e->send(E_NOTICE, 'Strategy_RemoveForeignElements: Comment removed');\n }\n continue;\n }\n } else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic static function login() {\n\t\tuser::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));\n\t\tif (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in\n\t\t\tflash('error', gt('Invalid Username / Password'));\n\t\t\tif (expSession::is_set('redirecturl_error')) {\n\t\t\t\t$url = expSession::get('redirecturl_error');\n\t\t\t\texpSession::un_set('redirecturl_error');\n\t\t\t\theader(\"Location: \".$url);\n\t\t\t} else {\n\t\t\t\texpHistory::back();\n\t\t\t}\n\t\t} else { // we're logged in\n\t\t\tglobal $user;\n\n if (expSession::get('customer-login')) expSession::un_set('customer-login');\n\t\t\tif (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));\n if ($user->isAdmin()) {\n expHistory::back();\n } else {\n foreach ($user->groups as $g) {\n if (!empty($g->redirect)) {\n $url = URL_FULL.$g->redirect;\n break;\n }\n }\n if (isset($url)) {\n header(\"Location: \".$url);\n } else {\n expHistory::back();\n }\n }\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function toolbar() {\n// global $user;\n\n $menu = array();\n\t\t$dirs = array(\n\t\t\tBASE.'framework/modules/administration/menus',\n\t\t\tBASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'\n\t\t);\n\n\t\tforeach ($dirs as $dir) {\n\t\t if (is_readable($dir)) {\n\t\t\t $dh = opendir($dir);\n\t\t\t while (($file = readdir($dh)) !== false) {\n\t\t\t\t if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {\n\t\t\t\t\t $menu[substr($file,0,-4)] = include($dir.'/'.$file);\n if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\t\t}\n\n // sort the top level menus alphabetically by filename\n\t\tksort($menu);\n\t\t$sorted = array();\n\t\tforeach($menu as $m) $sorted[] = $m;\n\n // slingbar position\n if (isset($_COOKIE['slingbar-top'])){\n $top = $_COOKIE['slingbar-top'];\n } else {\n $top = SLINGBAR_TOP;\n }\n\n\t\tassign_to_template(array(\n 'menu'=>(bs3()) ? $sorted : json_encode($sorted),\n \"top\"=>$top\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct(App $app)\n {\n $this->Config = $app->Config;\n $this->Request = $app->Request;\n $this->Session = $app->Session;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-307", "cwe_name": "Improper Restriction of Excessive Authentication Attempts", "description": "The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks.", "url": "https://cwe.mitre.org/data/definitions/307.html", "label_name": "vulnerable"} {"code": "\tpublic static function simple($input)\n\t{\n\t\treturn empty($str) ? '' : pts_strings::keep_in_string($input, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_AT | pts_strings::CHAR_COLON);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "\t\t\t\t$item = array();\n\t\t\t\t$item['id'] = $incident->id;\n\t\t\t\t$item['title'] = $incident->incident_title;\n\t\t\t\t$item['link'] = $site_url.'reports/view/'.$incident->id;\n\t\t\t\t$item['description'] = $incident->incident_description;\n\t\t\t\t$item['date'] = $incident->incident_date;\n\t\t\t\t$item['categories'] = $categories;\n\t\t\t\t\n\t\t\t\tif\n\t\t\t\t(\n\t\t\t\t\t$incident->location_id != 0 AND\n\t\t\t\t\t$incident->location->longitude AND\n\t\t\t\t\t$incident->location->latitude\n\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\t$item['point'] = array(\n\t\t\t\t\t\t$incident->location->latitude,\n\t\t\t\t\t $incident->location->longitude\n\t\t\t\t\t);\n\t\t\t\t\t$items[] = $item;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$cache->set($subdomain.'_feed_'.$limit.'_'.$page, $items, array('feed'), 3600); // 1 Hour\n\t\t\t$feed_items = $items;\n\t\t}\n\n\t\t$feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/';\n\n\t\t//header(\"Content-Type: text/xml; charset=utf-8\");\n\t\t$view = new View('feed/'.$feedtype);\n\t\t$view->feed_title = Kohana::config('settings.site_name');\n\t\t$view->site_url = $site_url;\n\t\t$view->georss = 1; // this adds georss namespace in the feed\n\t\t$view->feed_url = $site_url.$feedpath;\n\t\t$view->feed_date = gmdate(\"D, d M Y H:i:s T\", time());\n\t\t$view->feed_description = Kohana::lang('ui_admin.incident_feed').' '.Kohana::config('settings.site_name');\n\t\t$view->items = $feed_items;\n\t\t$view->render(TRUE);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $category = $this->getCategory();\n\n $this->response->html($this->helper->layout->project('category/remove', array(\n 'project' => $project,\n 'category' => $category,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic static function loadFromString($str) {\n\t\t//data scheme \u3088\u308a\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304b\u3089\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067 php://memory \u3092\u4f7f\u3046\n\t\t$fp = fopen(\"php://memory\", \"r+b\");\n\t\tif ($fp === false) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (fwrite($fp, $str) != strlen($str)) {\n\t\t\tfclose($fp);\n\t\t\treturn false;\n\t\t}\n\n\t\tif (fseek($fp, 0) === -1) {\n\t\t\tfclose($fp);\n\t\t\treturn false;\n\t\t}\n\n\t\t$bmp = self::loadFromStream($fp);\n\n\t\tfclose($fp);\n\t\treturn $bmp;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testBugReportsPages () {\n $this->visitPages ($this->getPages ('^bugReports'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " $this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());\n $this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public static function userid($id)\n {\n $usr = Db::result(\n sprintf(\n \"SELECT * FROM `user` WHERE `id` = '%d' LIMIT 1\",\n Typo::int($id)\n )\n );\n\n return $usr[0]->userid;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach ($allgroups as $gid) {\r\n $g = group::getGroupById($gid);\r\n expPermissions::grantGroup($g, 'manage', $sloc);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function withFragment($fragment)\n {\n if (substr($fragment, 0, 1) === '#') {\n $fragment = substr($fragment, 1);\n }\n\n $fragment = $this->filterQueryAndFragment($fragment);\n\n if ($this->fragment === $fragment) {\n return $this;\n }\n\n $new = clone $this;\n $new->fragment = $fragment;\n return $new;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function __construct () {\r\n\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " print_r($error);\n }\n echo '';\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function regdate($id)\n {\n $usr = Db::result(\n sprintf(\n \"SELECT * FROM `user` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1\",\n Typo::int($id),\n Typo::cleanX($id)\n )\n );\n\n return $usr[0]->join_date;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"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": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\t\t$rqv = strip_tags($rqv);\n\t\t\t\t\t}\n\t\t\t\t\t$v = implode(',', $_REQUEST[$var]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// TODO add more validation handling checks... then again, PTS client has its own validation of the env vars\n\t\t\t\t\t$v = strip_tags($_REQUEST[$var]);\n\t\t\t\t}\n\t\t\t\tif(!empty($v) && $v !== 0)\n\t\t\t\t{\n\t\t\t\t\t$posted[$var] = $v;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn $posted;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function page($vars) {\n switch (SMART_URL) {\n case true:\n # code...\n $url = Options::get('siteurl').\"/\".self::slug($vars).GX_URL_PREFIX;\n break;\n \n default:\n # code...\n $url = Options::get('siteurl').\"/index.php?page={$vars}\";\n break;\n\n }\n\n return $url;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function __construct($page, $file = null) {\n\n $this->page = $page;\n $this->file = $file;\n $this->blueprint = $page->blueprint();\n $this->filename = $this->blueprint->files()->sanitize() ? '{safeFilename}' : '{filename}';\n\n if($this->file) {\n $this->replace();\n } else {\n $this->upload(); \n }\n\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-434", "cwe_name": "Unrestricted Upload of File with Dangerous Type", "description": "The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.", "url": "https://cwe.mitre.org/data/definitions/434.html", "label_name": "vulnerable"} {"code": " public function approve_submit() {\n global $history;\n \n if (empty($this->params['id'])) {\n flash('error', gt('No ID supplied for comment to approve'));\n $lastUrl = expHistory::getLast('editable');\n }\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n $simplenote = new expSimpleNote($this->params['id']);\n //FIXME here is where we might sanitize the note before approving it\n $simplenote->body = $this->params['body'];\n $simplenote->approved = $this->params['approved'];\n $simplenote->save();\n \n $lastUrl = makelink($history->history[$history->history['lasts']['type']][count($history->history[$history->history['lasts']['type']])-1]['params']);\n if (!empty($this->params['tab']))\n {\n $lastUrl .= \"#\".$this->params['tab'];\n }\n redirect_to($lastUrl);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function showall() {\n\t expHistory::set('viewable', $this->params);\n\t $hv = new help_version();\n\t //$current_version = $hv->find('first', 'is_current=1');\n\t $ref_version = $hv->find('first', 'version=\\''.$this->help_version.'\\'');\n\n // pagination parameter..hard coded for now.\n\t\t$where = $this->aggregateWhereClause();\n\t $where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id);", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testValidatesUriCanBeParsed()\n {\n new Uri('///');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($day as $extevent) {\r\n $event_cache = new stdClass();\r\n $event_cache->feed = $extgcalurl;\r\n $event_cache->event_id = $extevent->event_id;\r\n $event_cache->title = $extevent->title;\r\n $event_cache->body = $extevent->body;\r\n $event_cache->eventdate = $extevent->eventdate->date;\r\n if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)\r\n $event_cache->dateFinished = $extevent->dateFinished;\r\n if (isset($extevent->eventstart))\r\n $event_cache->eventstart = $extevent->eventstart;\r\n if (isset($extevent->eventend))\r\n $event_cache->eventend = $extevent->eventend;\r\n if (isset($extevent->is_allday))\r\n $event_cache->is_allday = $extevent->is_allday;\r\n $found = false;\r\n if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries\r\n $found = $db->selectObject('event_cache','feed=\"'.$extgcalurl.'\" AND event_id=\"'.$event_cache->event_id.'\" AND eventdate='.$event_cache->eventdate);\r\n if (!$found)\r\n $db->insertObject($event_cache,'event_cache');\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tstatic public function getStatusText($_lng, $_status = 0)\n\t{\n\t\tswitch($_status)\n\t\t{\n\t\t\tcase 0:\n\t\t\t\treturn $_lng['ticket']['open'];\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\treturn $_lng['ticket']['wait_reply'];\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\treturn $_lng['ticket']['replied'];\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn $_lng['ticket']['closed'];\n\t\t\t\tbreak;\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "vulnerable"} {"code": " self::$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);\n return self::$mysqli;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\\Mbstring::mb_strrchr($s, $needle, $part, $enc); }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function stripFolder($req_uri)\n {\n $uri = Site::$url;\n $folder = self::getFolder();\n\n $uri2 = str_replace($folder, '', $req_uri);\n // print_r($uri2);\n return $uri2;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function getSwimlane()\n {\n $swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));\n\n if (empty($swimlane)) {\n throw new PageNotFoundException();\n }\n\n return $swimlane;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic function cmdPostprocess($cmd, &$result, $args, $elfinder) {\n\t\tif ($cmd === 'ls') {\n\t\t\tif (! empty($result['list']) && ! empty($this->replaced['ls'])) {\n\t\t\t\tforeach($result['list'] as $hash => $name) {\n\t\t\t\t\tif ($keys = array_keys($this->replaced['ls'], $name)) {\n\t\t\t\t\t\tif (count($keys) === 1) {\n\t\t\t\t\t\t\t$result['list'][$hash] = $keys[0];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$result['list'][$hash] = $keys;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function getPurchaseOrderByJSON() {\n\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\n\t\techo json_encode($purchase_orders);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function paramRules() {\n\t\treturn array(\n\t\t\t'title' => Yii::t('studio',$this->title),\n\t\t\t'info' => Yii::t('studio',$this->info),\n\t\t\t'modelRequired' => 'Contacts',\n\t\t\t'options' => array(\n\t\t\t\tarray(\n 'name'=>'listId',\n 'label'=>Yii::t('studio', 'List'),\n 'type'=>'link',\n 'linkType'=>'X2List',\n 'linkSource'=>Yii::app()->controller->createUrl(\n\t\t\t\t\t CActiveRecord::model('X2List')->autoCompleteSource, array (\n 'static' => 1\n )\n )\n\t\t\t\t)\n ));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " $f = function (\\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber']) ? $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber'] : ($this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber'] = new \\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber())) && false ?: '_'});", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function getMergeSql()\n {\n switch ($this->driver) {\n case 'mysql':\n return \"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n \"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)\";\n case 'oci':\n // DUAL is Oracle specific dummy table\n return \"MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) \".\n \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n \"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time\";\n case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\\PDO::ATTR_SERVER_VERSION), '10', '>='):\n // MERGE is only available since SQL Server 2008 and must be terminated by semicolon\n // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx\n return \"MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) \".\n \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n \"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time;\";\n case 'sqlite':\n return \"INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)\";\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\t\tdeleteUserGroupMember($userid, $rc['id']);\n\t}\n\tif(count($fails)) {\n\t\t$cnt = 'some';\n\t\t$code = 36;\n\t\tif(count($fails) == count($users)) {\n\t\t\t$cnt = 'any';\n\t\t\t$code = 37;\n\t\t}\n\t\treturn array('status' => 'warning',\n\t\t 'failedusers' => $fails,\n\t\t 'warningcode' => $code,\n\t\t 'warningmsg' => \"failed to remove $cnt users from user group\");\n\t}\n\treturn array('status' => 'success');\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function getMessage($key) {\n if (!$this->_loaded) $this->load();\n if (!isset($this->messages[$key])) return \"[$key]\";\n return $this->messages[$key];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function getProjectTag(array $project)\n {\n $tag = $this->tagModel->getById($this->request->getIntegerParam('tag_id'));\n\n if (empty($tag)) {\n throw new PageNotFoundException();\n }\n\n if ($tag['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $tag;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $action = $this->getAction($project);\n\n $this->response->html($this->helper->layout->project('action/remove', array(\n 'action' => $action,\n 'available_events' => $this->eventManager->getAll(),\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'project' => $project,\n 'title' => t('Remove an action')\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function getSiteInfo()\n {\n // check for a site request param\n if(empty($this->getSite())){\n $this->setName(get_bloginfo('name'));\n $this->setDescription(get_bloginfo('description'));\n $this->setRestApiUrl(get_rest_url());\n $this->setSite(get_bloginfo('url'));\n $this->setLocal(true);\n return;\n }\n // If they forgot to add http(s), add it for them.\n if(strpos($this->getSite(), 'http://') === false && strpos($this->getSite(), 'https://') === false) {\n $this->setSite( 'http://' . $this->getSite());\n }\n // if there is one, check if it exists in wordpress.com, eg \"retirementreflections.com\"\n $site = trailingslashit(sanitize_text_field($this->getSite()));\n\n\n // Let's see if it's self-hosted...\n $data = $this->getSelfHostedSiteInfo($site);\n// if($data === false){\n// // Alright, there was no link to the REST API index. But maybe it's a WordPress.com site...\n// $data = $this->guessSelfHostedSiteInfo($site);\n// }\n if($data === false){\n // Alright, there was no link to the REST API index. But maybe it's a WordPress.com site...\n $data = $this->getWordPressComSiteInfo($site);\n }\n\n return $data;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "\t\t\t$incident_title = strip_tags(html_entity_decode(html_entity_decode($this->data->item_title, ENT_QUOTES)));", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function editTitle() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->title = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n } ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " protected function split($string, $config, $context) {\n // OPTIMIZABLE!\n // do the preg_match, capture all subpatterns for reformulation\n\n // we don't support U+00A1 and up codepoints or\n // escaping because I don't know how to do that with regexps\n // and plus it would complicate optimization efforts (you never\n // see that anyway).\n $pattern = '/(?:(?<=\\s)|\\A)'. // look behind for space or string start\n '((?:--|-?[A-Za-z_])[A-Za-z_\\-0-9]*)'.\n '(?:(?=\\s)|\\z)/'; // look ahead for space or string end\n preg_match_all($pattern, $string, $matches);\n return $matches[1];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function getAction(array $project)\n {\n $action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));\n\n if (empty($action)) {\n throw new PageNotFoundException();\n }\n\n if ($action['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $action;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": "\tprotected function _filePutContents($path, $content) {\n\t\treturn $this->query(sprintf('UPDATE %s SET content=\"%s\", size=%d, mtime=%d WHERE id=%d LIMIT 1', $this->tbf, $this->db->real_escape_string($content), strlen($content), time(), $path));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function getResourceGroups($type=\"\") {\n\t$return = array();\n\t$query = \"SELECT g.id AS id, \"\n\t . \"g.name AS name, \"\n\t . \"t.name AS type, \"\n\t . \"g.ownerusergroupid AS ownerid, \"\n\t . \"CONCAT(u.name, '@', a.name) AS owner \"\n\t . \"FROM resourcegroup g, \"\n\t . \"resourcetype t, \"\n\t . \"usergroup u, \"\n\t . \"affiliation a \"\n\t . \"WHERE g.resourcetypeid = t.id AND \"\n\t . \"g.ownerusergroupid = u.id AND \"\n\t . \"u.affiliationid = a.id \";\n\n\tif(! empty($type))\n\t\t$query .= \"AND t.name = '$type' \";\n\n\t$query .= \"ORDER BY t.name, g.name\";\n\t$qh = doQuery($query, 281);\n\twhile($row = mysql_fetch_assoc($qh)) {\n\t\tif(empty($type))\n\t\t\t$return[$row[\"id\"]][\"name\"] = $row[\"type\"] . \"/\" . $row[\"name\"];\n\t\telse\n\t\t\t$return[$row[\"id\"]][\"name\"] = $row[\"name\"];\n\t\t$return[$row[\"id\"]][\"ownerid\"] = $row[\"ownerid\"];\n\t\t$return[$row[\"id\"]][\"owner\"] = $row[\"owner\"];\n\t}\n\treturn $return;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " protected function deleteFileInStorage(Attachment $attachment)\n {\n $storage = $this->getStorage();\n $dirPath = $this->adjustPathForStorageDisk(dirname($attachment->path));\n\n $storage->delete($this->adjustPathForStorageDisk($attachment->path));\n if (count($storage->allFiles($dirPath)) === 0) {\n $storage->deleteDirectory($dirPath);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " protected function assertCsvUploaded ($csv) {\n $uploadedPath = implode(DIRECTORY_SEPARATOR, array(\n Yii::app()->basePath,\n 'data',\n 'data.csv'\n ));\n $this->assertFileExists ($uploadedPath);\n $this->assertFileEquals ($csv, $uploadedPath);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function testRemoveTags () {\n $contact = $this->contacts ('testAnyone');\n Yii::app()->db->createCommand (\"\n delete from x2_tags where type='Contacts' and itemId=:id\n \")->execute (array (':id' => $contact->id));\n $tags = array ('test', 'test2', 'test3');\n $contact->addTags ($tags);\n $contact->removeTags ($tags);\n $this->assertEquals (array (), $contact->getTags (true));\n\n $tags = array ('test', 'test2', 'test3');\n $contact->addTags ($tags);\n $tags = array ('t,est', 'test2,');\n $contact->removeTags ($tags);\n $this->assertEquals (array ('#test3'), $contact->getTags (true));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function manage()\n {\n expHistory::set('manageable',$this->params);\n $gc = new geoCountry();\n $countries = $gc->find('all');\n\n $gr = new geoRegion();\n $regions = $gr->find('all',null,'rank asc,name asc');\n\n assign_to_template(array(\n 'countries'=>$countries,\n 'regions'=>$regions\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function db_seq_nextval($seqname)\n{\n global $DatabaseType;\n\n if ($DatabaseType == 'mysqli')\n $seq = \"fn_\" . strtolower($seqname) . \"()\";\n\n return $seq;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function testAggregatesHeaders()\n {\n $r = new Request('GET', '', [\n 'ZOO' => 'zoobar',\n 'zoo' => ['foobar', 'zoobar']\n ]);\n $this->assertEquals(['ZOO' => ['zoobar', 'foobar', 'zoobar']], $r->getHeaders());\n $this->assertEquals('zoobar, foobar, zoobar', $r->getHeaderLine('zoo'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tprivate function _firstrevisionsince( $option ) {\n\t\t$this->addTable( 'revision_actor_temp', 'rev' );\n\t\t$this->addSelect(\n\t\t\t[\n\t\t\t\t'rev.revactor_rev',\n\t\t\t\t'rev.revactor_timestamp'\n\t\t\t]\n\t\t);\n\t\t// tell the query optimizer not to look at rows that the following subquery will filter out anyway\n\t\t$this->addWhere(\n\t\t\t[\n\t\t\t\t$this->tableNames['page'] . '.page_id = rev.revactor_page',\n\t\t\t\t'rev.revactor_timestamp >= ' . $this->DB->addQuotes( $option )\n\t\t\t]\n\t\t);\n\t\t$this->addWhere(\n\t\t\t[\n\t\t\t\t$this->tableNames['page'] . '.page_id = rev.revactor_page',\n\t\t\t\t'rev.revactor_timestamp = (SELECT MIN(rev_aux_snc.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_snc WHERE rev_aux_snc.revactor_page=rev.revactor_page AND rev_aux_snc.revactor_timestamp >= ' . $this->convertTimestamp( $option ) . ')'\n\t\t\t]\n\t\t);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "function _makeExtra($value, $title = '') {\n global $THIS_RET;\n\n if ($THIS_RET['WITH_TEACHER_ID'])\n $return .= ''._with.': ' . GetTeacher($THIS_RET['WITH_TEACHER_ID']) . '
    ';\n if ($THIS_RET['NOT_TEACHER_ID'])\n $return .= ''._notWith.': ' . GetTeacher($THIS_RET['NOT_TEACHER_ID']) . '
    ';\n if ($THIS_RET['WITH_PERIOD_ID'])\n $return .= ''._on.': ' . GetPeriod($THIS_RET['WITH_PERIOD_ID']) . '
    ';\n if ($THIS_RET['NOT_PERIOD_ID'])\n $return .= ''._notOn.': ' . GetPeriod($THIS_RET['NOT_PERIOD_ID']) . '
    ';\n if ($THIS_RET['PRIORITY'])\n $return .= ''._priority.': ' . $THIS_RET['PRIORITY'] . '
    ';\n if ($THIS_RET['MARKING_PERIOD_ID'])\n $return .= ''._markingPeriod.': ' . GetMP($THIS_RET['MARKING_PERIOD_ID']) . '
    ';\n\n return $return;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function get($key, $default = null)\n {\n return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function showallSubcategories() {\n// global $db;\n\n expHistory::set('viewable', $this->params);\n// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');\n $catid = expSession::get('catid');\n $parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? $this->params['cat'] : 0);\n $category = new storeCategory($parent);\n $categories = $category->getEcomSubcategories();\n $ancestors = $category->pathToNode();\n assign_to_template(array(\n 'categories' => $categories,\n 'ancestors' => $ancestors,\n 'category' => $category\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function manage()\n {\n expHistory::set('manageable',$this->params);\n $gc = new geoCountry();\n $countries = $gc->find('all');\n\n $gr = new geoRegion();\n $regions = $gr->find('all',null,'rank asc,name asc');\n\n assign_to_template(array(\n 'countries'=>$countries,\n 'regions'=>$regions\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " $values = [READ => __('Read'),\n CREATE => __('Create'),", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " $body = str_replace(array(\"\\n\"), \"
    \", $body);\r\n } else {\r\n // It's going elsewhere (doesn't like quoted-printable)\r\n $body = str_replace(array(\"\\n\"), \" -- \", $body);\r\n }\r\n $title = $items[$i]->title;\r\n\r\n $msg .= \"BEGIN:VEVENT\\n\";\r\n $msg .= $dtstart . $dtend;\r\n $msg .= \"UID:\" . $items[$i]->date_id . \"\\n\";\r\n $msg .= \"DTSTAMP:\" . date(\"Ymd\\THis\", time()) . \"Z\\n\";\r\n if ($title) {\r\n $msg .= \"SUMMARY:$title\\n\";\r\n }\r\n if ($body) {\r\n $msg .= \"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:\" . $body . \"\\n\";\r\n }\r\n //\tif($link_url) { $msg .= \"URL: $link_url\\n\";}\r\n if (!empty($this->config['usecategories'])) {\r\n if (!empty($items[$i]->expCat[0]->title)) {\r\n $msg .= \"CATEGORIES:\".$items[$i]->expCat[0]->title.\"\\n\";\r\n } else {\r\n $msg .= \"CATEGORIES:\".$this->config['uncat'].\"\\n\";\r\n }\r\n }\r\n $msg .= \"END:VEVENT\\n\";\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function get_items( $request ) {\n\n\t\t$sked = get_template_sked( $request['post_id'] );\n\n\t\treturn new WP_REST_Response( $sked, 200 );\n\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function transform($attr, $config, $context) {\n\n if (!isset($attr['href'])) {\n return $attr;\n }\n\n // XXX Kind of inefficient\n $url = $this->parser->parse($attr['href']);\n $scheme = $url->getSchemeObj($config, $context);\n\n if ($scheme->browsable && !$url->isLocal($config, $context)) {\n if (isset($attr['rel'])) {\n $rels = explode(' ', $attr['rel']);\n if (!in_array('nofollow', $rels)) {\n $rels[] = 'nofollow';\n }\n $attr['rel'] = implode(' ', $rels);\n } else {\n $attr['rel'] = 'nofollow';\n }\n }\n\n return $attr;\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " foreach ($usr as $u) {\r\n # code...\r\n $msgs = str_replace('{{userid}}', $u->userid, $msg);\r\n $vars = array(\r\n 'to' => $u->email,\r\n 'to_name' => $u->userid,\r\n 'message' => $msgs,\r\n 'subject' => $subject,\r\n 'msgtype' => $_POST['type']\r\n );\r\n $mailsend = Mail::send($vars);\r\n if ($mailsend !== null) {\r\n $alermailsend[] = $mailsend;\r\n }\r\n sleep(3);\r\n }\r", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function update()\n {\n $project = $this->getProject();\n $tag_id = $this->request->getIntegerParam('tag_id');\n $tag = $this->tagModel->getById($tag_id);\n $values = $this->request->getValues();\n list($valid, $errors) = $this->tagValidator->validateModification($values);\n\n if ($tag['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n if ($valid) {\n if ($this->tagModel->update($values['id'], $values['name'])) {\n $this->flash->success(t('Tag updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this tag.'));\n }\n\n $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));\n } else {\n $this->edit($values, $errors);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " $loc = expCore::makeLocation('navigation', '', $standalone->id);\n if (expPermissions::check('manage', $loc)) return true;\n }\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function loader(){\r\n $theme = Options::v('themes');\r\n define('THEME', $theme);\r\n self::incFunc($theme);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function showall() {\r\n global $user, $sectionObj, $sections;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // all we need to do is determine the current section\r\n $navsections = $sections;\r\n if ($sectionObj->parent == -1) {\r\n $current = $sectionObj;\r\n } else {\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testClearTags () {\n $contact = $this->contacts ('testAnyone');\n Yii::app()->db->createCommand (\"\n delete from x2_tags where type='Contacts' and itemId=:id\n \")->execute (array (':id' => $contact->id));\n $tags = array ('test', 'test2', 'test3');\n $contact->addTags ($tags);\n $contact->clearTags ();\n $this->assertEquals (array (), $contact->getTags (true));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " foreach ($page as $pageperm) {\n if (!empty($pageperm['manage'])) return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $f = function (\\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber']) ? $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber'] : ($this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber'] = new \\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber())) && false ?: '_'});", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " }elseif($p->group == 3){\r\n $grp = AUTHOR;\r\n }elseif($p->group == 4){\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\tpublic function merge($branch, $options = NULL)\n\t\t{\n\t\t\t$this->run('merge', $options, $branch);\n\t\t\treturn $this;\n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " protected function forceChangePassword()\n {\n if (!Yii::$app->user->isMustChangePasswordUrl()) {\n Yii::$app->getResponse()->redirect([Yii::$app->user->mustChangePasswordRoute]);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "\tpublic static function dplParserFunction( &$parser ) {\n\t\tself::setLikeIntersection( false );\n\n\t\t$parser->addTrackingCategory( 'dpl-parserfunc-tracking-category' );\n\n\t\t// callback for the parser function {{#dpl:\t or {{DynamicPageList::\n\t\t$input = \"\";\n\n\t\t$numargs = func_num_args();\n\t\tif ( $numargs < 2 ) {\n\t\t\t$input = \"#dpl: no arguments specified\";\n\t\t\treturn str_replace( '\u00a7', '<', '\u00a7pre>\u00a7nowiki>' . $input . '\u00a7/nowiki>\u00a7/pre>' );\n\t\t}\n\n\t\t// fetch all user-provided arguments (skipping $parser)\n\t\t$arg_list = func_get_args();\n\t\tfor ( $i = 1; $i < $numargs; $i++ ) {\n\t\t\t$p1 = $arg_list[$i];\n\t\t\t$input .= str_replace( \"\\n\", \"\", $p1 ) . \"\\n\";\n\t\t}\n\n\t\t$parse = new \\DPL\\Parse();\n\t\t$dplresult = $parse->parse( $input, $parser, $reset, $eliminate, false );\n\t\treturn [ // parser needs to be coaxed to do further recursive processing\n\t\t\t$parser->getPreprocessor()->preprocessToObj( $dplresult, Parser::PTD_FOR_INCLUSION ),\n\t\t\t'isLocalObj' => true,\n\t\t\t'title' => $parser->getTitle()\n\t\t];\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "\tfunction show_vendor () {\n\t\t$vendor = new vendor();\n\n\t\tif(isset($this->params['id'])) {\n\t\t\t$vendor = $vendor->find('first', 'id =' .$this->params['id']);\n\t\t\t$vendor_title = $vendor->title;\n\t\t\t$state = new geoRegion($vendor->state);\n\t\t\t$vendor->state = $state->name;\n\t\t\t//Removed unnecessary fields\n\t\t\tunset(\n $vendor->title,\n $vendor->table,\n $vendor->tablename,\n $vendor->classname,\n $vendor->identifier\n );\n\n\t\t\tassign_to_template(array(\n 'vendor_title' => $vendor_title,\n 'vendor'=>$vendor\n ));\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\t\t\t\tarray_push($privileges, $p);\n\t\t}\n\t}\n\n\treturn array('status' => 'success',\n\t 'privileges' => array_unique($privileges));\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function read($sessionId)\n {\n $dbData = $this->getCollection()->findOne(array(\n $this->options['id_field'] => $sessionId,\n $this->options['expiry_field'] => array('$gte' => new \\MongoDate()),\n ));\n\n return null === $dbData ? '' : $dbData[$this->options['data_field']]->bin;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testBodyConsistent()\n {\n $r = new Response(200, [], '0');\n $this->assertEquals('0', (string)$r->getBody());\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function addTab($array)\n\t{\n\t\tif (!$array) {\n\t\t\t$this->setAPIResponse('error', 'no data was sent', 422);\n\t\t\treturn null;\n\t\t}\n\t\t$array = $this->checkKeys($this->getTableColumnsFormatted('tabs'), $array);\n\t\t$array['group_id'] = ($array['group_id']) ?? $this->getDefaultGroupId();\n\t\t$array['category_id'] = ($array['category_id']) ?? $this->getDefaultCategoryId();\n\t\t$array['enabled'] = ($array['enabled']) ?? 0;\n\t\t$array['default'] = ($array['default']) ?? 0;\n\t\t$array['type'] = ($array['type']) ?? 1;\n\t\t$array['order'] = ($array['order']) ?? $this->getNextTabOrder() + 1;\n\t\tif (array_key_exists('name', $array)) {\n\t\t\t$array['name'] = htmlspecialchars($array['name']);\n\t\t\tif ($this->isTabNameTaken($array['name'])) {\n\t\t\t\t$this->setAPIResponse('error', 'Tab name: ' . $array['name'] . ' is already taken', 409);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\t$this->setAPIResponse('error', 'Tab name was not supplied', 422);\n\t\t\treturn false;\n\t\t}\n\t\tif (!array_key_exists('url', $array) && !array_key_exists('url_local', $array)) {\n\t\t\t$this->setAPIResponse('error', 'Tab url or url_local was not supplied', 422);\n\t\t\treturn false;\n\t\t}\n\t\tif (!array_key_exists('image', $array)) {\n\t\t\t$this->setAPIResponse('error', 'Tab image was not supplied', 422);\n\t\t\treturn false;\n\t\t}\n\t\t$response = [\n\t\t\tarray(\n\t\t\t\t'function' => 'query',\n\t\t\t\t'query' => array(\n\t\t\t\t\t'INSERT INTO [tabs]',\n\t\t\t\t\t$array\n\t\t\t\t)\n\t\t\t),\n\t\t];\n\t\t$this->setAPIResponse(null, 'Tab added');\n\t\t$this->setLoggerChannel('Tab Management');\n\t\t$this->logger->debug('Added Tab for [' . $array['name'] . ']');\n\t\treturn $this->processQueries($response);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tfunction update_vendor() {\n\t\t$vendor = new vendor();\n\n\t\t$vendor->update($this->params['vendor']);\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " $loc = expCore::makeLocation('navigation', '', $standalone->id);\r\n if (expPermissions::check('manage', $loc)) return true;\r\n }\r\n return false;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function XMLRPCremoveNode($nodeID) {\n\trequire_once(\".ht-inc/privileges.php\");\n\tglobal $user;\n\tif(! is_numeric($nodeID)) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 78,\n\t\t 'errormsg' => 'Invalid nodeid specified');\n\t}\n\tif(! in_array(\"nodeAdmin\", $user['privileges'])) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 70,\n\t\t 'errormsg' => 'User cannot administer nodes');\n\t}\n\tif(! checkUserHasPriv(\"nodeAdmin\", $user['id'], $nodeID)) {\n\t\treturn array('status' => 'error',\n\t\t 'errorcode' => 57,\n\t\t 'errormsg' => 'User cannot edit this node');\n\t}\n\t$nodes = recurseGetChildren($nodeID);\n\tarray_push($nodes, $nodeID);\n\t$deleteNodes = implode(',', $nodes);\n\t$query = \"DELETE FROM privnode \"\n\t . \"WHERE id IN ($deleteNodes)\";\n\tdoQuery($query, 345);\n\treturn array('status' => 'success');\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function getFilePath($fileName = null)\n {\n if ($fileName === null) {\n $fileName = $this->fileName;\n }\n\n return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-829", "cwe_name": "Inclusion of Functionality from Untrusted Control Sphere", "description": "The software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.", "url": "https://cwe.mitre.org/data/definitions/829.html", "label_name": "vulnerable"} {"code": " private static function sign($input, $key, $algo)\n {\n switch ($algo) {\n\n case 'HS256':\n return hash_hmac('sha256', $input, $key, true);\n\n case 'HS384':\n return hash_hmac('sha384', $input, $key, true);\n\n case 'HS512':\n return hash_hmac('sha512', $input, $key, true);\n\n case 'RS256':\n return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA256);\n\n case 'RS384':\n return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA384);\n\n case 'RS512':\n return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA512);\n\n default:\n throw new Exception(\"Unsupported or invalid signing algorithm.\");\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function sendData($data)\n {\n $httpRequest = $this->httpClient->post($this->getEndpoint(), null, http_build_query($data));\n $httpRequest->getCurlOptions()->set(CURLOPT_SSLVERSION, 6); // CURL_SSLVERSION_TLSv1_2 for libcurl < 7.35\n $httpResponse = $httpRequest->send();\n\n return $this->createResponse($httpResponse->getBody());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function get_filedisplay_views() {\n expTemplate::get_filedisplay_views();\n\n $paths = array(\n BASE.'framework/modules/common/views/file/',\n BASE.'themes/'.DISPLAY_THEME.'modules/common/views/file/',\n );\n\n $views = array();\n foreach ($paths as $path) {\n if (is_readable($path)) {\n $dh = opendir($path);\n while (($file = readdir($dh)) !== false) {\n if (is_readable($path.'/'.$file) && substr($file, -4) == '.tpl' && substr($file, -14) != '.bootstrap.tpl' && substr($file, -15) != '.bootstrap3.tpl' && substr($file, -10) != '.newui.tpl') {\n $filename = substr($file, 0, -4);\n $views[$filename] = gt($filename);\n }\n }\n }\n }\n\n return $views;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function rss() {\r\n switch (SMART_URL) {\r\n case true:\r\n # code...\r\n $inFold = (Options::v('permalink_use_index_php') == \"on\")? \"/index.php\":\"\";\r\n $url = Site::$url.$inFold.\"/rss\".GX_URL_PREFIX;\r\n break;\r\n\r\n default:\r\n # code...\r\n $url = Site::$url.\"/index.php?rss\";\r\n break;\r\n\r\n }\r\n\r\n return $url;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function Archive()\n\t{\n\t\t\n\t\t// Update \"main\" ticket\n\t\t$upd_stmt = Database::prepare('\n\t\t\tUPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = \"1\" WHERE `id` = :tid');\n\t\tDatabase::pexecute($upd_stmt, array(\n\t\t\t'tid' => $this->tid\n\t\t));\n\t\t\n\t\t// Update \"answers\" to ticket\n\t\t$upd_stmt = Database::prepare('\n\t\t\tUPDATE `' . TABLE_PANEL_TICKETS . '` SET `archived` = \"1\" WHERE `answerto` = :tid');\n\t\tDatabase::pexecute($upd_stmt, array(\n\t\t\t'tid' => $this->tid\n\t\t));\n\t\treturn true;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": "\t\tform_end_row();\n\t\t$i++;\n\t}\n\n\n\thtml_end_box(false);\n\n/*\n\tprint \"
    \";\n\tif (isset($check) && is_array($check)) {\n\t\tprint_r($check);\n\t}\n\tprint \"
    \";\n*/\n\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " $q = self::query($sql);\n }\n\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testRedirectLinkGeneration () {\n Yii::app()->controller = new MarketingController (\n 'campaign', new MarketingModule ('campaign', null));\n $_SERVER['SERVER_NAME'] = 'localhost';\n $cmb = $this->instantiate();\n $contact = $this->contacts('testUser_unsent');\n $campaign = $this->campaign('redirectLinkGeneration');\n $url = preg_replace ('/^[^\"]*\"([^\"]*)\".*$/', '$1', $campaign->content);\n list($subject,$message,$uniqueId) = $cmb->prepareEmail(\n $this->campaign('redirectLinkGeneration'),\n $contact);\n $this->assertRegExp ('/'.preg_quote (urlencode ($url)).'/', $message);\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function __construct(Database $database, $cookiePrefix = '')\n {\n parent::__construct($database, TBL_SESSIONS, 'ses');\n\n // determine session id\n if (array_key_exists(COOKIE_PREFIX . '_SESSION_ID', $_COOKIE)) {\n $sessionId = $_COOKIE[COOKIE_PREFIX . '_SESSION_ID'];\n } else {\n $sessionId = session_id();\n }\n\n $this->cookieAutoLoginId = $cookiePrefix . '_AUTO_LOGIN_ID';\n\n if (is_int($sessionId)) {\n $this->readDataById($sessionId);\n } else {\n $this->readDataByColumns(array('ses_session_id' => $sessionId));\n\n if ($this->newRecord) {\n // if PHP session id was commited then store them in that field\n $this->setValue('ses_session_id', $sessionId);\n $this->setValue('ses_timestamp', DATETIME_NOW);\n }\n }\n\n // check for a valid auto login\n $this->refreshAutoLogin();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": " public function update()\n {\n try {\n $_recipients = array();\n if ($this->recipients != null) {\n foreach ($this->recipients as $_r) {\n $_recipients[$_r->id] = $_r->sname . ' <' . $_r->email . '>';\n }\n }\n\n $sender = ($this->sender === 0) ?\n new Expression('NULL') : $this->sender;\n $sender_name = ($this->sender_name === null) ?\n new Expression('NULL') : $this->sender_name;\n $sender_address = ($this->sender_address === null) ?\n new Expression('NULL') : $this->sender_address;\n\n $values = array(\n 'mailing_sender' => $sender,\n 'mailing_sender_name' => $sender_name,\n 'mailing_sender_address' => $sender_address,\n 'mailing_subject' => $this->subject,\n 'mailing_body' => $this->message,\n 'mailing_date' => $this->date,\n 'mailing_recipients' => serialize($_recipients),\n 'mailing_sent' => ($this->sent) ?\n true :\n ($this->zdb->isPostgres() ? 'false' : 0)\n );\n\n $update = $this->zdb->update(self::TABLE);\n $update->set($values);\n $update->where(self::PK . ' = ' . $this->mailing->history_id);\n $this->zdb->execute($update);\n return true;\n } catch (Throwable $e) {\n Analog::log(\n 'An error occurend updating Mailing | ' . $e->getMessage(),\n Analog::ERROR\n );\n throw $e;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function execute(&$params){\n $model = new Actions;\n $model->type = 'note';\n $model->complete = 'Yes';\n $model->associationId = $params['model']->id;\n $model->associationType = $params['model']->module;\n $model->actionDescription = $this->parseOption('comment', $params);\n $model->assignedTo = $this->parseOption('assignedTo', $params);\n $model->completedBy = $this->parseOption('assignedTo', $params);\n\n if(empty($model->assignedTo) && $params['model']->hasAttribute('assignedTo')){\n $model->assignedTo = $params['model']->assignedTo;\n $model->completedBy = $params['model']->assignedTo;\n }\n\n if($params['model']->hasAttribute('visibility'))\n $model->visibility = $params['model']->visibility;\n $model->createDate = time();\n $model->completeDate = time();\n\n if($model->save()){\n return array(\n true,\n Yii::t('studio', 'View created action: ').$model->getLink());\n }else{\n return array(false, array_shift($model->getErrors()));\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function updateObject($object, $table, $where=null, $identifier='id', $is_revisioned=false) {\n\n if ($is_revisioned) {\n $object->revision_id++;\n //if ($table==\"text\") eDebug($object);\n $res = $this->insertObject($object, $table);\n //if ($table==\"text\") eDebug($object,true); \n $this->trim_revisions($table, $object->$identifier, WORKFLOW_REVISION_LIMIT);\n return $res;\n }\n $sql = \"UPDATE \" . $this->prefix . \"$table SET \";\n foreach (get_object_vars($object) as $var => $val) {\n //We do not want to save any fields that start with an '_'\n //if($is_revisioned && $var=='revision_id') $val++;\n if ($var{0} != '_') {\n if (is_array($val) || is_object($val)) {\n $val = serialize($val); \n $sql .= \"`$var`='\".$val.\"',\";\n } else {\n $sql .= \"`$var`='\".mysqli_real_escape_string($this->connection,$val).\"',\";\n }\n }\n }\n $sql = substr($sql, 0, -1) . \" WHERE \";\n if ($where != null)\n $sql .= $where;\n else\n $sql .= \"`\" . $identifier . \"`=\" . $object->$identifier;\n //if ($table == 'text') eDebug($sql,true); \n $res = (@mysqli_query($this->connection, $sql) != false);\n return $res;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testDisplayBlocksAcceptTemplateOnlyAsBlocks()\n {\n $template = $this->getMockForAbstractClass('Twig_Template', array(), '', false);\n $template->displayBlock('foo', array(), array('foo' => array(new stdClass(), 'foo')));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " private function _getMetaTags()\n {\n $retval = '';\n $retval .= '';\n $retval .= '';\n $retval .= '';\n return $retval;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function delete() {\n global $db, $history;\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n if (empty($this->params['id'])) {\n flash('error', gt('Missing id for the comment you would like to delete'));\n $lastUrl = expHistory::getLast('editable');\n }\n \n // delete the note\n $simplenote = new expSimpleNote($this->params['id']);\n $rows = $simplenote->delete();\n \n // delete the assocication too\n $db->delete($simplenote->attachable_table, 'expsimplenote_id='.$this->params['id']); \n \n // send the user back where they came from.\n $lastUrl = expHistory::getLast('editable');\n if (!empty($this->params['tab']))\n {\n $lastUrl .= \"#\".$this->params['tab'];\n }\n redirect_to($lastUrl);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function testResolvesUris($base, $rel, $expected)\n {\n $uri = new Uri($base);\n $actual = Uri::resolve($uri, $rel);\n $this->assertSame($expected, (string) $actual);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function autoLogin()\n {\n $oPlugin = OA_Auth::staticGetAuthPlugin();\n\n phpAds_SessionStart();\n\n // No auto-login if auth is external\n if (empty($oPlugin) || (get_class($oPlugin) != 'Plugins_Authentication')) {\n phpAds_SessionDataDestroy();\n return;\n }\n\n $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');\n if (isset($adminAccountId)) {\n // Fetch the user linked to the admin account\n $doUser = OA_Dal::factoryDO('users');\n $doAUA = OA_Dal::factoryDO('account_user_assoc');\n $doAUA->account_id = $adminAccountId;\n $doUser->joinAdd($doAUA);\n $doUser->find();\n if ($doUser->fetch()) {\n phpAds_SessionRegenerateId();\n phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));\n phpAds_SessionDataStore();\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": " public function actionGetItems(){\n $sql = 'SELECT id, name as value FROM x2_products WHERE name LIKE :qterm ORDER BY name ASC';\n $command = Yii::app()->db->createCommand($sql);\n $qterm = $_GET['term'].'%';\n $command->bindParam(\":qterm\", $qterm, PDO::PARAM_STR);\n $result = $command->queryAll();\n echo CJSON::encode($result); exit;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function __construct() {\n $this->pop_conn = 0;\n $this->connected = false;\n $this->error = null;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function setObjectSrc(Response $response)\n {\n if (config('app.allow_content_scripts')) {\n return;\n }\n\n $response->headers->set('Content-Security-Policy', 'object-src \\'self\\'', false);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function captureAuthorization() {\n //eDebug($this->params,true);\n $order = new order($this->params['id']);\n /*eDebug($this->params); \n //eDebug($order,true);*/\n //eDebug($order,true);\n //$billing = new billing();\n\n //eDebug($billing, true);\n //$billing->calculator = new $calcname($order->billingmethod[0]->billingcalculator_id);\n $calc = $order->billingmethod[0]->billingcalculator->calculator;\n $calc->config = $order->billingmethod[0]->billingcalculator->config;\n\n //$calc = new $calc-\n //eDebug($calc,true);\n if (!method_exists($calc, 'delayed_capture')) {\n flash('error', gt('The Billing Calculator does not support delayed capture'));\n expHistory::back();\n }\n\n $result = $calc->delayed_capture($order->billingmethod[0], $this->params['capture_amt'], $order);\n\n if (empty($result->errorCode)) {\n flash('message', gt('The authorized payment was successfully captured'));\n expHistory::back();\n\n } else {\n flash('error', gt('An error was encountered while capturing the authorized payment.') . '

    ' . $result->message);\n expHistory::back();\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public static function BBCode2Html($text) {\n \t$text = trim($text);\n\n $text = self::parseEmoji($text);\n\n // Smileys to find...\n $in = array(\n );\n\n // And replace them by...\n $out = array(\n );\n \t\n \t$in[] = '[/*]';\n \t$in[] = '[*]';\n \t$out[] = '';\n \t$out[] = '
  • ';\n \t \t\n \t$text = str_replace($in, $out, $text);\n\n \t// BBCode to find...\n \t$in = array( \t '/\\[b\\](.*?)\\[\\/b\\]/ms',\n \t\t\t\t\t '/\\[i\\](.*?)\\[\\/i\\]/ms',\n \t\t\t\t\t '/\\[u\\](.*?)\\[\\/u\\]/ms',\n \t\t\t\t\t '/\\[mark\\](.*?)\\[\\/mark\\]/ms',\n \t\t\t\t\t '/\\[s\\](.*?)\\[\\/s\\]/ms',\n \t\t\t\t\t '/\\[list\\=(.*?)\\](.*?)\\[\\/list\\]/ms',\n \t\t\t\t\t '/\\[list\\](.*?)\\[\\/list\\]/ms',\n \t\t\t\t\t '/\\[\\*\\]\\s?(.*?)\\n/ms',\n \t\t\t\t\t '/\\[fs(.*?)\\](.*?)\\[\\/fs(.*?)\\]/ms',\n \t\t\t\t\t '/\\[color\\=(.*?)\\](.*?)\\[\\/color\\]/ms'\n \t);\n\n \t// And replace them by...\n \t$out = array(\t '\\1',\n \t\t\t\t\t '\\1',\n \t\t\t\t\t '\\1',\n \t\t\t\t\t '\\1',\n \t\t\t\t\t '\\1',\n \t\t\t\t\t '
      \\2
    ',\n \t\t\t\t\t '
      \\1
    ',\n \t\t\t\t\t '
  • \\1
  • ',\n \t\t\t\t\t '\\2',\n \t\t\t\t\t '\\2'\n \t);\n\n \t$text = preg_replace($in, $out, $text);\n\n \t// Prepare quote's\n \t$text = str_replace(\"\\r\\n\",\"\\n\",$text);\n\n \t// paragraphs\n \t$text = str_replace(\"\\r\", \"\", $text);\n \t$text = nl2br($text);\n\n \t// clean some tags to remain strict\n \t// not very elegant, but it works. No time to do better ;)\n \tif (!function_exists('removeBr')) {\n \t\tfunction removeBr($s) {\n \t\t\treturn str_replace(\"
    \", \"\", $s[0]);\n \t\t}\n \t}\n\n \t$text = preg_replace_callback('/
    (.*?)<\\/pre>/ms', \"removeBr\", $text);\n    \t$text = preg_replace('/

    (.*?)<\\/pre><\\/p>/ms', \"
    \\\\1
    \", $text);\n\n \t$text = preg_replace_callback('/
      (.*?)<\\/ul>/ms', \"removeBr\", $text);\n \t$text = preg_replace('/

        (.*?)<\\/ul><\\/p>/ms', \"
          \\\\1
        \", $text);\n\n \treturn $text;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " $newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);\n if (!empty($newret)) $ret .= $newret . '
        ';\n if ($iLoc->mod == 'container') {\n $ret .= scan_container($container->internal, $page_id);\n }\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\t\t\tunset($map[$n], $n, $d);\n\t\t\t}\n\t\t\tunset($map);\n\t\t\tif(!self::$client) {\n\t\t\t\tself::$client = false;\n\t\t\t}\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public function testForWritableDir($value)\n {\n if (substr($value, 0, 7) === \"phar://\") {\n return 'Phar protocol not allowed.';\n }\n if (!is_dir($value)) {\n return 'Not a valid directory.';\n }\n if (!is_writeable($value)) {\n return 'Not a writable directory.';\n }\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " public function getFilePath($fileName = null)\n {\n if ($fileName === null) {\n $fileName = $this->fileName;\n }\n\n // Limit paths to those under the assets directory\n $directory = $this->theme->getPath() . '/' . $this->dirName . '/';\n $path = realpath($directory . $fileName);\n if (!starts_with($path, $directory)) {\n return false;\n }\n\n return $path;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-73", "cwe_name": "External Control of File Name or Path", "description": "The software allows user input to control or influence paths or file names that are used in filesystem operations.", "url": "https://cwe.mitre.org/data/definitions/73.html", "label_name": "safe"} {"code": "function phpAds_SessionDataFetch()\n{\n global $session;\n\n // Guard clause: Can't fetch a session without an ID\n if (empty($_COOKIE['sessionID']) || !preg_match('#^[0-9a-f]{32}$#D', $_COOKIE['sessionID'])) {\n return;\n }\n\n $dal = new MAX_Dal_Admin_Session();\n $serialized_session = $dal->getSerializedSession($_COOKIE['sessionID']);\n\n // Return if the session was not found (expired or forged)\n if (!$serialized_session) {\n return;\n }\n\n $loaded_session = unserialize($serialized_session);\n\n // Or if it can't be unserialized and/or is not a session we started\n if (empty($loaded_session['__authentic__'])) {\n return;\n }\n\n $session = $loaded_session;\n\n $dal->refreshSession($_COOKIE['sessionID']);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask/remove', array(\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " function render_menu_tabs() \r\n {\r\n $current_tab = $this->get_current_tab();\r\n\r\n echo '

        ';\r\n foreach ( $this->menu_tabs as $tab_key => $tab_caption ) \r\n {\r\n $active = $current_tab == $tab_key ? 'nav-tab-active' : '';\r\n echo 'menu_page_slug . '&tab=' . $tab_key . '\">' . $tab_caption . '';\t\r\n }\r\n echo '

        ';\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function testFromParts($input)\n {\n $uri = Uri::fromParts(parse_url($input));\n\n $this->assertSame($input, (string) $uri);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function selectArraysBySql($sql) { \n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return array();\n $arrays = array();\n for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)\n $arrays[] = mysqli_fetch_assoc($res);\n return $arrays;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tprotected function _basename($path) {\n\t\t$parts = explode($this->separator, trim($path, $this->separator));\n\t\treturn array_pop($parts);\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function search_by_model() {\n global $db, $user;\n\n $sql = \"select DISTINCT(p.id) as id, p.title, model from \" . $db->prefix . \"product as p WHERE \";\n if (!($user->isAdmin())) $sql .= '(p.active_type=0 OR p.active_type=1) AND ';\n\n //if first character of search is a -, then we do a wild card, else from beginning\n $this->params['query'] = expString::escape($this->params['query']);\n if ($this->params['query'][0] == '-') {\n $sql .= \" p.model LIKE '%\" . $this->params['query'];\n } else {\n $sql .= \" p.model LIKE '\" . $this->params['query'];\n }\n\n $sql .= \"%' AND p.parent_id=0 GROUP BY p.id \";\n $sql .= \"order by p.model ASC LIMIT 30\";\n $res = $db->selectObjectsBySql($sql);\n //eDebug($sql);\n $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function testPhpSession53()\n {\n if (PHP_VERSION_ID >= 50400) {\n $this->markTestSkipped('Test skipped, for PHP 5.3 only.');\n }\n\n $storage = $this->getStorage();\n\n $this->assertFalse(isset($_SESSION));\n $this->assertFalse($storage->getSaveHandler()->isActive());\n\n session_start();\n $this->assertTrue(isset($_SESSION));\n // in PHP 5.3 we cannot reliably tell if a session has started\n $this->assertFalse($storage->getSaveHandler()->isActive());\n // PHP session might have started, but the storage driver has not, so false is correct here\n $this->assertFalse($storage->isStarted());\n\n $key = $storage->getMetadataBag()->getStorageKey();\n $this->assertFalse(isset($_SESSION[$key]));\n $storage->start();\n $this->assertTrue(isset($_SESSION[$key]));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function html_escape($string) {\n\treturn htmlspecialchars($string, ENT_QUOTES, 'UTF-8', true);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function activate_discount(){ \n if (isset($this->params['id'])) {\n $discount = new discounts($this->params['id']);\n $discount->update($this->params);\n //if ($discount->discountulator->hasConfig() && empty($discount->config)) {\n //flash('messages', $discount->discountulator->name().' requires configuration. Please do so now.');\n //redirect_to(array('controller'=>'billing', 'action'=>'configure', 'id'=>$discount->id));\n //}\n }\n \n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function testResource()\n {\n $stream = Psr7\\stream_for('foo');\n $handle = StreamWrapper::getResource($stream);\n $this->assertSame('foo', fread($handle, 3));\n $this->assertSame(3, ftell($handle));\n $this->assertSame(3, fwrite($handle, 'bar'));\n $this->assertSame(0, fseek($handle, 0));\n $this->assertSame('foobar', fread($handle, 6));\n $this->assertSame('', fread($handle, 1));\n $this->assertTrue(feof($handle));\n\n // This fails on HHVM for some reason\n if (!defined('HHVM_VERSION')) {\n $this->assertEquals([\n 'dev' => 0,\n 'ino' => 0,\n 'mode' => 33206,\n 'nlink' => 0,\n 'uid' => 0,\n 'gid' => 0,\n 'rdev' => 0,\n 'size' => 6,\n 'atime' => 0,\n 'mtime' => 0,\n 'ctime' => 0,\n 'blksize' => 0,\n 'blocks' => 0,\n 0 => 0,\n 1 => 0,\n 2 => 33206,\n 3 => 0,\n 4 => 0,\n 5 => 0,\n 6 => 0,\n 7 => 6,\n 8 => 0,\n 9 => 0,\n 10 => 0,\n 11 => 0,\n 12 => 0,\n ], fstat($handle));\n }\n\n $this->assertTrue(fclose($handle));\n $this->assertSame('foobar', (string) $stream);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function canView($section) {\n global $db;\n\n if ($section == null) {\n return false;\n }\n if ($section->public == 0) {\n // Not a public section. Check permissions.\n return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id));\n } else { // Is public. check parents.\n if ($section->parent <= 0) {\n // Out of parents, and since we are still checking, we haven't hit a private section.\n return true;\n } else {\n $s = $db->selectObject('section', 'id=' . $section->parent);\n return self::canView($s);\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $masteroption->delete();\n }\n\n // delete the mastergroup\n $db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);\n $mastergroup->delete();\n\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\tfunction output( $p_format = 'dot', $p_headers = false ) {\n\t\t# Check if it is a recognized format.\n\t\tif( !isset( $this->formats[$p_format] ) ) {\n\t\t\ttrigger_error( ERROR_GENERIC, ERROR );\n\t\t}\n\n\t\t$t_binary = $this->formats[$p_format]['binary'];\n\t\t$t_type = $this->formats[$p_format]['type'];\n\t\t$t_mime = $this->formats[$p_format]['mime'];\n\n\t\t# Send Content-Type header, if requested.\n\t\tif( $p_headers ) {\n\t\t\theader( 'Content-Type: ' . $t_mime );\n\t\t}\n\t\t# Retrieve the source dot document into a buffer\n\t\tob_start();\n\t\t$this->generate();\n\t\t$t_dot_source = ob_get_contents();\n\t\tob_end_clean();\n\n\t\t# Start dot process\n\n\t\t$t_command = $this->graphviz_tool . ' -T' . $p_format;\n\t\t$t_descriptors = array(\n\t\t\t0 => array( 'pipe', 'r', ),\n\t\t\t1 => array( 'pipe', 'w', ),\n\t\t\t2 => array( 'file', 'php://stderr', 'w', ),\n\t\t\t);\n\n\t\t$t_pipes = array();\n\t\t$t_process = proc_open( $t_command, $t_descriptors, $t_pipes );\n\n\t\tif( is_resource( $t_process ) ) {\n\t\t\t# Filter generated output through dot\n\t\t\tfwrite( $t_pipes[0], $t_dot_source );\n\t\t\tfclose( $t_pipes[0] );\n\n\t\t\tif( $p_headers ) {\n\t\t\t\t# Headers were requested, use another output buffer to\n\t\t\t\t# retrieve the size for Content-Length.\n\t\t\t\tob_start();\n\t\t\t\twhile( !feof( $t_pipes[1] ) ) {\n\t\t\t\t\techo fgets( $t_pipes[1], 1024 );\n\t\t\t\t}\n\t\t\t\theader( 'Content-Length: ' . ob_get_length() );\n\t\t\t\tob_end_flush();\n\t\t\t} else {\n\t\t\t\t# No need for headers, send output directly.\n\t\t\t\twhile( !feof( $t_pipes[1] ) ) {\n\t\t\t\t\tprint( fgets( $t_pipes[1], 1024 ) );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfclose( $t_pipes[1] );\n\t\t\tproc_close( $t_process );\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " $q->close();\n }\n\n self::$num_rows = $n;\n\n return $r;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function uploadAvatar(Request $request)\n {\n $user = auth()->user();\n\n if ($user && $request->hasFile('admin_avatar')) {\n $user->clearMediaCollection('admin_avatar');\n\n $user->addMediaFromRequest('admin_avatar')\n ->toMediaCollection('admin_avatar');\n }\n\n if ($user && $request->has('avatar')) {\n $data = json_decode($request->avatar);\n $user->clearMediaCollection('admin_avatar');\n\n $user->addMediaFromBase64($data->data)\n ->usingFileName($data->name)\n ->toMediaCollection('admin_avatar');\n }\n\n return new UserResource($user);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function asText(ElementNode $el)\n {\n if (!$this->hasValidInputs($el)) {\n return $el->getAsBBCode();\n }\n\n $s = \"\";\n foreach ($el->getChildren() as $child)\n $s .= $child->getAsText();\n return $s;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tprivate function _qualitypages( $option ) {\n\t\tif ( function_exists( 'efLoadFlaggedRevs' ) ) {\n\t\t\t//Do not add this again if 'stablepages' has already added it.\n\t\t\tif ( !$this->parametersProcessed['stablepages'] ) {\n\t\t\t\t$this->addJoin(\n\t\t\t\t\t'flaggedpages',\n\t\t\t\t\t[\n\t\t\t\t\t\t\"LEFT JOIN\",\n\t\t\t\t\t\t\"page_id = fp_page_id\"\n\t\t\t\t\t]\n\t\t\t\t);\n\t\t\t}\n\t\t\tswitch ( $option ) {\n\t\t\t\tcase 'only':\n\t\t\t\t\t$this->addWhere( 'fp_quality >= 1' );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'exclude':\n\t\t\t\t\t$this->addWhere( 'fp_quality = 0' );\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " foreach ($allusers as $uid) {\n $u = user::getUserById($uid);\n expPermissions::grant($u, 'manage', $sloc);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function getQuerySelect()\n {\n return \"a.per_tracker_artifact_id AS `\" . $this->name . \"`\";\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function get($extramediatypes = false) {\n\t\ttry {\n\t\t\treturn $this->getConfig($extramediatypes);\n\t\t} catch (\\Exception $exception) {\n\t\t\treturn $this->jsonError($exception);\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function renew2FaSecretAction(Request $request)\n {\n $this->checkCsrfToken($request);\n\n $user = $this->getAdminUser();\n $proxyUser = $this->getAdminUser(true);\n\n $twoFactorService = $this->get('scheb_two_factor.security.google_authenticator');\n $newSecret = $twoFactorService->generateSecret();\n $user->setTwoFactorAuthentication('enabled', true);\n $user->setTwoFactorAuthentication('type', 'google');\n $user->setTwoFactorAuthentication('secret', $newSecret);\n $user->save();\n\n Tool\\Session::useSession(function (AttributeBagInterface $adminSession) {\n Tool\\Session::regenerateId();\n $adminSession->set('2fa_required', true);\n });\n\n $twoFactorService = $this->get('scheb_two_factor.security.google_authenticator');\n $url = $twoFactorService->getQRContent($proxyUser);\n\n $code = new \\Endroid\\QrCode\\QrCode;\n $code->setWriterByName('png');\n $code->setText($url);\n $code->setSize(200);\n\n $qrCodeFile = PIMCORE_PRIVATE_VAR . '/qr-code-' . uniqid() . '.png';\n $code->writeFile($qrCodeFile);\n\n $response = new BinaryFileResponse($qrCodeFile);\n\n return $response;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-307", "cwe_name": "Improper Restriction of Excessive Authentication Attempts", "description": "The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks.", "url": "https://cwe.mitre.org/data/definitions/307.html", "label_name": "vulnerable"} {"code": " public function testNewInstanceWhenAddingHeaderThatWasNotThereBefore()\n {\n $r = new Response(200, ['Foo' => 'Bar']);\n $r2 = $r->withAddedHeader('Baz', 'Bam');\n $this->assertNotSame($r, $r2);\n $this->assertEquals('Bam', $r2->getHeaderLine('Baz'));\n $this->assertEquals('Bar', $r2->getHeaderLine('Foo'));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private static function restoreIniSettings () {\n foreach (self::$_savedIniSettings as $setting => $val) { \n if ($val !== null) { \n ini_set ($setting, $val);\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " private function doCreation(array $project, array $values)\n {\n $values['project_id'] = $project['id'];\n list($valid, ) = $this->actionValidator->validateCreation($values);\n\n if ($valid) {\n if ($this->actionModel->create($values) !== false) {\n $this->flash->success(t('Your automatic action have been created successfully.'));\n } else {\n $this->flash->failure(t('Unable to create your automatic action.'));\n }\n }\n\n $this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": "\tprivate function _maxrevisions( $option ) {\n\t\t$this->addWhere( \"((SELECT count(rev_aux3.revactor_page) FROM {$this->tableNames['revision_actor_temp']} AS rev_aux3 WHERE rev_aux3.revactor_page = {$this->tableNames['page']}.page_id) <= {$option})\" );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public function show() {\n global $user;\n\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n\n // check to see if we should be editing. You either need to be an admin, or viewing own account.\n if ($user->isAdmin() || ($user->id == $id)) {\n $u = new user($id);\n if ($u->isSuperAdmin() && $user->isActingAdmin()) {\n flash('error', gt('You do not have the proper permissions to view this record'));\n expHistory::back();\n }\n parent::show();\n } else {\n flash('error', gt('You do not have the proper permissions to view this record'));\n expHistory::back();\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " public static function isHadSub($parent, $menuid =''){\n $sql = sprintf(\"SELECT * FROM `menus` WHERE `parent` = '%s' %s\", $parent, $where);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " protected function expandCSSEscape($string) {\n // flexibly parse it\n $ret = '';\n for ($i = 0, $c = strlen($string); $i < $c; $i++) {\n if ($string[$i] === '\\\\') {\n $i++;\n if ($i >= $c) {\n $ret .= '\\\\';\n break;\n }\n if (ctype_xdigit($string[$i])) {\n $code = $string[$i];\n for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {\n if (!ctype_xdigit($string[$i])) break;\n $code .= $string[$i];\n }\n // We have to be extremely careful when adding\n // new characters, to make sure we're not breaking\n // the encoding.\n $char = HTMLPurifier_Encoder::unichr(hexdec($code));\n if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;\n $ret .= $char;\n if ($i < $c && trim($string[$i]) !== '') $i--;\n continue;\n }\n if ($string[$i] === \"\\n\") continue;\n }\n $ret .= $string[$i];\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " protected function itemLock($hashes, $autoUnlock = true)\n {\n if (!elFinder::$commonTempPath) {\n return;\n }\n if (!is_array($hashes)) {\n $hashes = array($hashes);\n }\n foreach ($hashes as $hash) {\n $lock = elFinder::$commonTempPath . DIRECTORY_SEPARATOR . $hash . '.lock';\n if ($this->itemLocked($hash)) {\n $cnt = file_get_contents($lock) + 1;\n } else {\n $cnt = 1;\n }\n if (file_put_contents($lock, $cnt, LOCK_EX)) {\n if ($autoUnlock) {\n $this->autoUnlocks[] = $hash;\n }\n }\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " public function hasParameter($name)\n {\n $name = (string) $name;\n $name = $this->normalizeParameterName($name);\n\n return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function get_view_config() {\n global $template;\n\n // set paths we will search in for the view\n $paths = array(\n BASE.'themes/'.DISPLAY_THEME.'/modules/common/views/file/configure',\n BASE.'framework/modules/common/views/file/configure',\n );\n\n foreach ($paths as $path) {\n $view = $path.'/'.$this->params['view'].'.tpl';\n if (is_readable($view)) {\n if (bs(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $view);\n $ar = new expAjaxReply(200, 'ok');\n\t\t $ar->send();\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function manage_versions() {\n\t expHistory::set('manageable', $this->params);\n\n\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');\n\n\t $sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';\n\t $sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';\n\n\t $page = new expPaginator(array(\n 'sql'=>$sql,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Version')=>'version',\n gt('Title')=>'title',\n gt('Current')=>'is_current',\n gt('# of Docs')=>'num_docs'\n ),\n ));\n\n\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page\n ));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " static function displayname() { return gt(\"Navigation\"); }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function editAlt() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->alt = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your alt was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n echo json_encode($file); //FIXME we exit before hitting this\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $swimlane = $this->getSwimlane();\n\n $this->response->html($this->helper->layout->project('swimlane/remove', array(\n 'project' => $project,\n 'swimlane' => $swimlane,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "function PMA_secureSession()\n{\n // prevent session fixation and XSS\n // (better to use session_status() if available)\n if ((PMA_PHP_INT_VERSION >= 50400 && session_status() === PHP_SESSION_ACTIVE)\n || (PMA_PHP_INT_VERSION < 50400 && session_id() !== '')\n ) {\n session_regenerate_id(true);\n }\n $_SESSION[' PMA_token '] = md5(uniqid(rand(), true));\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " function setTimeoutIo($timeout_io)\n {\n $this->timeout_io = $timeout_io;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function formatTemplateArg( $arg, $s, $argNr, $firstCall, $maxLength, Article $article ) {\n\t\t$tableFormat = $this->getParameters()->getParameter( 'tablerow' );\n\t\t// we could try to format fields differently within the first call of a template\n\t\t// currently we do not make such a difference\n\n\t\t// if the result starts with a '-' we add a leading space; thus we avoid a misinterpretation of |- as\n\t\t// a start of a new row (wiki table syntax)\n\t\tif ( array_key_exists( \"$s.$argNr\", $tableFormat ) ) {\n\t\t\t$n = -1;\n\t\t\tif ( $s >= 1 && $argNr == 0 && !$firstCall ) {\n\t\t\t\t$n = strpos( $tableFormat[\"$s.$argNr\"], '|' );\n\t\t\t\tif ( $n === false || !( strpos( substr( $tableFormat[\"$s.$argNr\"], 0, $n ), '{' ) === false ) || !( strpos( substr( $tableFormat[\"$s.$argNr\"], 0, $n ), '[' ) === false ) ) {\n\t\t\t\t\t$n = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$result = str_replace( '%%', $arg, substr( $tableFormat[\"$s.$argNr\"], $n + 1 ) );\n\t\t\t$result = str_replace( '%PAGE%', $article->mTitle->getPrefixedText(), $result );\n\t\t\t$result = str_replace( '%IMAGE%', $this->parseImageUrlWithPath( $arg ), $result ); //@TODO: This just blindly passes the argument through hoping it is an image. --Alexia\n\t\t\t$result = $this->cutAt( $maxLength, $result );\n\t\t\tif ( strlen( $result ) > 0 && $result[0] == '-' ) {\n\t\t\t\treturn ' ' . $result;\n\t\t\t} else {\n\t\t\t\treturn $result;\n\t\t\t}\n\t\t}\n\t\t$result = $this->cutAt( $maxLength, $arg );\n\t\tif ( strlen( $result ) > 0 && $result[0] == '-' ) {\n\t\t\treturn ' ' . $result;\n\t\t} else {\n\t\t\treturn $result;\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public function handleEnd(&$token) {\n // This is the WRONG way of handling the object and param stacks;\n // we should be inserting them directly on the relevant object tokens\n // so that the global stack handling handles it.\n if ($token->name == 'object') {\n array_pop($this->objectStack);\n array_pop($this->paramStack);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function squash($force = false) {\n if ($this->cache !== null && !$force) return $this->cache;\n if ($this->parent) {\n return $this->cache = array_merge($this->parent->squash($force), $this->data);\n } else {\n return $this->cache = $this->data;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic function __construct()\n\t{\n\t\tparent::__construct();\n\t\t\n\t\t// Load profiler\n\t\tif (Kohana::config('config.enable_profiler'))\n\t\t{\n\t\t\t$this->profiler = new Profiler;\n\t\t}\n\t\t\n\t\t$this->auth = Auth::instance();\n\t\t\n\t\t$this->db = Database::instance();\n\n\t\t// Are we logged in? if not, do we have an auto-login cookie?\n\t\tif (! $this->auth->logged_in()) {\n\t\t\t// Try to login with 'remember me' token\n\t\t\tif (! $this->auth->auto_login())\n\t\t\t{\n\t\t\t\t// Login user in via HTTP AUTH\n\t\t\t\t$this->auth->http_auth_login();\n\t\t\t}\n\t\t}\n\n\t\t// Get session information\n\t\t$this->user = Auth::instance()->get_user();\n\n\t\t// Check private deployment access\n\t\t$controller_whitelist = array(\n\t\t\t'login',\n\t\t\t'riverid',\n\t\t\t'api'\n\t\t);\n\n\t\tif (Kohana::config('settings.private_deployment'))\n\t\t{\n\t\t\tif (!$this->auth->logged_in('login') AND ! in_array(Router::$controller, $controller_whitelist))\n\t\t\t{\n\t\t\t\t// Redirect to login form\n\t\t\t\turl::redirect('login');\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Set default content-type header\n\t\theader('Content-type: text/html; charset=UTF-8');\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function validateSignature(array $data, XMLSecurityKey $key)\n {\n assert('array_key_exists(\"Query\", $data)');\n assert('array_key_exists(\"SigAlg\", $data)');\n assert('array_key_exists(\"Signature\", $data)');\n\n $query = $data['Query'];\n $sigAlg = $data['SigAlg'];\n $signature = $data['Signature'];\n\n $signature = base64_decode($signature);\n\n if ($key->type !== XMLSecurityKey::RSA_SHA1) {\n throw new \\Exception('Invalid key type for validating signature on query string.');\n }\n if ($key->type !== $sigAlg) {\n $key = Utils::castKey($key, $sigAlg);\n }\n\n if (!$key->verifySignature($query, $signature)) {\n throw new \\Exception('Unable to validate signature on query string.');\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " protected function getComment()\n {\n $comment = $this->commentModel->getById($this->request->getIntegerParam('comment_id'));\n\n if (empty($comment)) {\n throw new PageNotFoundException();\n }\n\n if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) {\n throw new AccessForbiddenException();\n }\n\n return $comment;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $category = $this->getCategory();\n\n $this->response->html($this->helper->layout->project('category/remove', array(\n 'project' => $project,\n 'category' => $category,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "function wp_validate_redirect($location, $default = '') {\n\t$location = trim( $location );\n\t// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'\n\tif ( substr($location, 0, 2) == '//' )\n\t\t$location = 'http:' . $location;\n\n\t// In php 5 parse_url may fail if the URL query part contains http://, bug #38143\n\t$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;\n\n\t// @-operator is used to prevent possible warnings in PHP < 5.3.3.\n\t$lp = @parse_url($test);\n\n\t// Give up if malformed URL\n\tif ( false === $lp )\n\t\treturn $default;\n\n\t// Allow only http and https schemes. No data:, etc.\n\tif ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )\n\t\treturn $default;\n\n\t// Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.\n\tif ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {\n\t\treturn $default;\n\t}\n\n\t// Reject malformed components parse_url() can return on odd inputs.\n\tforeach ( array( 'user', 'pass', 'host' ) as $component ) {\n\t\tif ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) {\n\t\t\treturn $default;\n\t\t}\n\t}\n\n\t$wpp = parse_url(home_url());\n\n\t/**\n\t * Filters the whitelist of hosts to redirect to.\n\t *\n\t * @since 2.3.0\n\t *\n\t * @param array $hosts An array of allowed hosts.\n\t * @param bool|string $host The parsed host; empty if not isset.\n\t */\n\t$allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '' );\n\n\tif ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )\n\t\t$location = $default;\n\n\treturn $location;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function showByModel() {\n global $order, $template, $db;\n\n expHistory::set('viewable', $this->params);\n $product = new product();\n $model = $product->find(\"first\", 'model=\"' . $this->params['model'] . '\"');\n //eDebug($model);\n $product_type = new $model->product_type($model->id);\n //eDebug($product_type);\n $tpl = $product_type->getForm('show');\n if (!empty($tpl)) $template = new controllertemplate($this, $tpl);\n //eDebug($template);\n $this->grabConfig(); // grab the global config\n assign_to_template(array(\n 'config' => $this->config,\n 'product' => $product_type,\n 'last_category' => $order->lastcat\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public static function insert ($vars) {\n if(is_array($vars)){\n $set = \"\";\n $k = \"\";\n foreach ($vars['key'] as $key => $val) {\n $set .= \"'$val',\";\n $k .= \"`$key`,\";\n }\n \n $set = substr($set, 0,-1);\n $k = substr($k, 0,-1);\n \n $sql = sprintf(\"INSERT INTO `%s` (%s) VALUES (%s) \", $vars['table'], $k, $set) ;\n }else{\n $sql = $vars;\n }\n if(DB_DRIVER == 'mysql') {\n mysql_query('SET CHARACTER SET utf8');\n $q = mysql_query($sql) or die(mysql_error());\n self::$last_id = mysql_insert_id();\n }elseif(DB_DRIVER == 'mysqli'){\n try {\n if(!self::query($sql)){\n printf(\"
        Errormessage: %s
        \\n\", self::$mysqli->error);\n }else{\n self::$last_id = self::$mysqli->insert_id;\n }\n \n } catch (exception $e) {\n echo $e->getMessage();\n }\n \n }\n \n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function __construct()\n {\n self::setActive();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function approve_submit() {\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('No ID supplied for comment to approve'));\n\t expHistory::back();\n\t }\n\n /* The global constants can be overriden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n\t $comment = new expComment($this->params['id']);\n\t $comment->body = $this->params['body'];\n\t $comment->approved = $this->params['approved'];\n\t $comment->save();\n\t expHistory::back();\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function IsSendmail() {\n if (!stristr(ini_get('sendmail_path'), 'sendmail')) {\n $this->Sendmail = '/var/qmail/bin/sendmail';\n }\n $this->Mailer = 'sendmail';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function getMailingDetails($id)\n {\n trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be private with 5.8.', __CLASS__, __METHOD__), E_USER_DEPRECATED);\n\n $details = Shopware()->Modules()->Marketing()->sMailCampaignsGetDetail((int) $id);\n\n foreach ($details['containers'] as $key => $container) {\n if ($container['type'] === 'ctVoucher') {\n if (!empty($container['value'])) {\n $details['voucher'] = $container['value'];\n }\n $details['containers'][$key]['type'] = 'ctText';\n }\n if ($container['type'] === 'ctSuggest') {\n $details['suggest'] = true;\n }\n }\n\n return $details;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function XMLRPCaddResourceGroupPriv($name, $type, $nodeid, $permissions){\n require_once(\".ht-inc/privileges.php\");\n global $user;\n\n if(! checkUserHasPriv(\"resourceGrant\", $user['id'], $nodeid)){\n return array('status' => 'error',\n 'errorcode' => 53,\n 'errormsg' => 'Unable to add resource group to this node');\n }\n\n if($typeid = getResourceTypeID($type)){\n if(!checkForGroupName($name, 'resource', '', $typeid)){\n return array('status' => 'error',\n 'errorcode' => 28,\n 'errormsg' => 'resource group does not exist');\n }\n $perms = explode(':', $permissions);\n updateResourcePrivs(\"$type/$name\", $nodeid, $perms, array());\n return array('status' => 'success');\n } else {\n return array('status' => 'error',\n 'errorcode' => 56,\n 'errormsg' => 'Invalid resource type');\n }\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n\n $this->response->html($this->helper->layout->project('action/remove', array(\n 'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')),\n 'available_events' => $this->eventManager->getAll(),\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'project' => $project,\n 'title' => t('Remove an action')\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tprotected function Start()\n\t{\n\t\t$sCurrentStepClass = $this->sInitialStepClass;\n\t\t$oStep = new $sCurrentStepClass($this, $this->sInitialState);\n\t\t$this->DisplayStep($oStep);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " public static function name($id)\n {\n $id = sprintf('%d', $id);\n if (isset($id)) {\n $cat = Db::result(\"SELECT `name` FROM `cat`\n WHERE `id` = '{$id}' LIMIT 1\");\n //print_r($cat);\n if (isset($cat['error'])) {\n return '';\n } else {\n return $cat[0]->name;\n }\n } else {\n echo 'No ID Selected';\n }\n\n //print_r($cat);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\tpublic function renameRemote($oldName, $newName)\n\t\t{\n\t\t\t$this->run('remote', 'rename', $oldName, $newName);\n\t\t\treturn $this;\n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " public function resetAccessed() {\n $this->accessed = array();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tfunction update_vendor() {\n\t\t$vendor = new vendor();\n\t\t\n\t\t$vendor->update($this->params['vendor']);\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function disconnect()\n {\n $this->sendString('QUIT');\n //The QUIT command may cause the daemon to exit, which will kill our connection\n //So ignore errors here\n try {\n @fclose($this->pop_conn);\n } catch (Exception $e) {\n //Do nothing\n };\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function handle($request, Closure $next)\n {\n view()->share('cspNonce', $this->cspService->getNonce());\n if ($this->cspService->allowedIFrameHostsConfigured()) {\n config()->set('session.same_site', 'none');\n }\n\n $response = $next($request);\n\n $this->cspService->setFrameAncestors($response);\n $this->cspService->setScriptSrc($response);\n $this->cspService->setObjectSrc($response);\n $this->cspService->setBaseUri($response);\n\n return $response;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function selectObjectBySql($sql) {\n //$logFile = \"C:\\\\xampp\\\\htdocs\\\\supserg\\\\tmp\\\\queryLog.txt\";\n //$lfh = fopen($logFile, 'a');\n //fwrite($lfh, $sql . \"\\n\"); \n //fclose($lfh); \n $res = @mysqli_query($this->connection, $this->injectProof($sql));\n if ($res == null)\n return null;\n return mysqli_fetch_object($res);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function desc($vars){\n if(!empty($vars)){\n $desc = substr(strip_tags(htmlspecialchars_decode($vars).\". \".self::$desc),0,150);\n }else{\n $desc = substr(self::$desc,0,150);\n }\n \n return $desc;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static function DragnDropReRank2() {\r\n global $router, $db;\r\n\r\n $id = $router->params['id'];\r\n $page = new section($id);\r\n $old_rank = $page->rank;\r\n $old_parent = $page->parent;\r\n $new_rank = $router->params['position'] + 1; // rank\r\n $new_parent = intval($router->params['parent']);\r\n\r\n $db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole\r\n $db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room\r\n\r\n $params = array();\r\n $params['parent'] = $new_parent;\r\n $params['rank'] = $new_rank;\r\n $page->update($params);\r\n\r\n self::checkForSectionalAdmins($id);\r\n expSession::clearAllUsersSessionCache('navigation');\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function _collapseStack($stack) {\n $result = array();\n $is_folder = false;\n for ($i = 0; isset($stack[$i]); $i++) {\n $is_folder = false;\n // absorb an internally duplicated slash\n if ($stack[$i] == '' && $i && isset($stack[$i+1])) continue;\n if ($stack[$i] == '..') {\n if (!empty($result)) {\n $segment = array_pop($result);\n if ($segment === '' && empty($result)) {\n // error case: attempted to back out too far:\n // restore the leading slash\n $result[] = '';\n } elseif ($segment === '..') {\n $result[] = '..'; // cannot remove .. with ..\n }\n } else {\n // relative path, preserve the double-dots\n $result[] = '..';\n }\n $is_folder = true;\n continue;\n }\n if ($stack[$i] == '.') {\n // silently absorb\n $is_folder = true;\n continue;\n }\n $result[] = $stack[$i];\n }\n if ($is_folder) $result[] = '';\n return $result;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $this->setType('folder');\n }\n\n // do not allow PHP and .htaccess files\n if (preg_match(\"@\\.ph(p[\\d+]?|t|tml|ps)$@i\", $this->getFilename()) || $this->getFilename() == '.htaccess') {\n $this->setFilename($this->getFilename() . '.txt');\n }\n\n if(mb_strlen($this->getFilename()) > 255) {\n throw new \\Exception('Filenames longer than 255 characters are not allowed');\n }\n\n if (Asset\\Service::pathExists($this->getRealFullPath())) {\n $duplicate = Asset::getByPath($this->getRealFullPath());\n if ($duplicate instanceof Asset and $duplicate->getId() != $this->getId()) {\n throw new \\Exception('Duplicate full path [ ' . $this->getRealFullPath() . ' ] - cannot save asset');\n }\n }\n\n $this->validatePathLength();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public function tearDown () {\n // try to replace mocks with original components in case mocks were set during test case\n TestingAuxLib::restoreX2WebUser ();\n TestingAuxLib::restoreX2AuthManager ();\n return parent::tearDown ();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function getQuerySelect()\n {\n $R1 = 'R1_' . $this->field->id;\n $R2 = 'R2_' . $this->field->id;\n $R3 = 'R3_' . $this->field->id;\n return \"$R2.user_id AS `\" . $this->field->name . \"`\";\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function doCreation(array $project, array $values)\n {\n $values['project_id'] = $project['id'];\n list($valid, ) = $this->actionValidator->validateCreation($values);\n\n if ($valid) {\n if ($this->actionModel->create($values) !== false) {\n $this->flash->success(t('Your automatic action have been created successfully.'));\n } else {\n $this->flash->failure(t('Unable to create your automatic action.'));\n }\n }\n\n $this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " } elseif ($key === 'allowedProtocols') {\n $this->setAllowedProtocols($value);\n } elseif ($key === 'logOutputFile' || $key === 'log_output_file') {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-73", "cwe_name": "External Control of File Name or Path", "description": "The software allows user input to control or influence paths or file names that are used in filesystem operations.", "url": "https://cwe.mitre.org/data/definitions/73.html", "label_name": "safe"} {"code": "\tprotected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) {\n\t\tif (($s = @getimagesize($path)) == false || $degree % 360 === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\t$result = false;\n\n\t\t// try lossless rotate\n\t\tif ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) {\n\t\t\t$count = ($degree / 90) % 4;\n\t\t\t$exiftran = array(\n\t\t\t\t1 => '-9',\n\t\t\t\t2 => '-1',\n\t\t\t\t3 => '-2'\n\t\t\t);\n\t\t\t$jpegtran = array(\n\t\t\t\t1 => '90',\n\t\t\t\t2 => '180',\n\t\t\t\t3 => '270'\n\t\t\t);\n\t\t\t$quotedPath = escapeshellarg($path);\n\t\t\t$cmds = array(\n\t\t\t\t'exiftran -i '.$exiftran[$count].' '.$path,\n\t\t\t\t'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath\n\t\t\t);\n\t\t\tforeach($cmds as $cmd) {\n\t\t\t\tif ($this->procExec($cmd) === 0) {\n\t\t\t\t\t$result = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($result) {\n\t\t\t\treturn $path;\n\t\t\t}\n\t\t}\n\n\t\tif (!$jpgQuality) {\n\t\t\t$jpgQuality = $this->options['jpgQuality'];\n\t\t}\n\n\t\tswitch ($this->imgLib) {\n\t\t\tcase 'imagick':\n\t\t\t\ttry {\n\t\t\t\t\t$img = new imagick($path);\n\t\t\t\t} catch (Exception $e) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ($img->getNumberImages() > 1) {\n\t\t\t\t\t$img = $img->coalesceImages();\n\t\t\t\t\tdo {\n\t\t\t\t\t\t$img->rotateImage(new ImagickPixel($bgcolor), $degree);\n\t\t\t\t\t} while ($img->nextImage());\n\t\t\t\t\t$img = $img->optimizeImageLayers();\n\t\t\t\t\t$result = $img->writeImages($path, true);\n\t\t\t\t} else {\n\t\t\t\t\t$img->rotateImage(new ImagickPixel($bgcolor), $degree);\n\t\t\t\t\t$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);\n\t\t\t\t}\n\t\t\t\t$img->clear();\n\t\t\t\treturn $result ? $path : false;\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'gd':\n\t\t\t\t$img = $this->gdImageCreate($path,$s['mime']);\n\n\t\t\t\t$degree = 360 - $degree;\n\t\t\t\tlist($r, $g, $b) = sscanf($bgcolor, \"#%02x%02x%02x\");\n\t\t\t\t$bgcolor = imagecolorallocate($img, $r, $g, $b);\n\t\t\t\t$tmp = imageRotate($img, $degree, (int)$bgcolor);\n\n\t\t\t\t$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);\n\n\t\t\t\timageDestroy($img);\n\t\t\t\timageDestroy($tmp);\n\n\t\t\t\treturn $result ? $path : false;\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn false;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($this->fixesForLevel[$level] as $fix) {\n $ret[$fix] = true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function start()\n {\n if ($this->started) {\n return true;\n }\n\n $this->loadSession();\n if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) {\n // This condition matches only PHP 5.3 + internal save handlers\n $this->saveHandler->setActive(true);\n }\n\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " elseif ($permission == $rolePermission && $rolePermissions[$permission] == 1) {\n $matched = true;\n break;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "function csv_escape_string( $p_string ) {\n\t# Prevent CSV injection by escaping text that could be interpreted as a formula\n\tif( $p_string && strpos( '=-+@', $p_string[0] ) !== false ) {\n\t\t# Prefixing with a tab rather than single quote, as Excel does not show\n\t\t# the tab visually in the cell.\n\t\t$p_string = \"\\t\" . $p_string;\n\t}\n\n\t$t_escaped = str_split( '\"' . csv_get_separator() . csv_get_newline() );\n\t$t_must_escape = false;\n\twhile( ( $t_char = current( $t_escaped ) ) !== false && !$t_must_escape ) {\n\t\t$t_must_escape = strpos( $p_string, $t_char ) !== false;\n\t\tnext( $t_escaped );\n\t}\n\tif( $t_must_escape ) {\n\t\t$p_string = '\"' . str_replace( '\"', '\"\"', $p_string ) . '\"';\n\t}\n\n\treturn $p_string;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": " protected function generateCookieHash($class, $username, $expires, $password)\n {\n return hash_hmac('sha256', $class.self::COOKIE_DELIMITER.$username.self::COOKIE_DELIMITER.$expires.self::COOKIE_DELIMITER.$password, $this->getSecret());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": " $expanded = implode($joiner, $kvp);\n if ($isAssoc) {\n // Don't prepend the value name when using the explode\n // modifier with an associative array.\n $actuallyUseQuery = false;\n }\n } else {\n if ($isAssoc) {\n // When an associative array is encountered and the\n // explode modifier is not set, then the result must be\n // a comma separated list of keys followed by their\n // respective values.\n foreach ($kvp as $k => &$v) {\n $v = $k . ',' . $v;\n }\n }\n $expanded = implode(',', $kvp);\n }\n\n } else {\n if ($value['modifier'] == ':') {\n $variable = substr($variable, 0, $value['position']);\n }\n $expanded = rawurlencode($variable);\n if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {\n $expanded = $this->decodeReserved($expanded);\n }\n }\n\n if ($actuallyUseQuery) {\n if (!$expanded && $joiner != '&') {\n $expanded = $value['value'];\n } else {\n $expanded = $value['value'] . '=' . $expanded;\n }\n }\n\n $replacements[] = $expanded;\n }\n\n $ret = implode($joiner, $replacements);\n if ($ret && $prefix) {\n return $prefix . $ret;\n }\n\n return $ret;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function tmb($hash) {\n\t\t$path = $this->decode($hash);\n\t\t$stat = $this->stat($path);\n\t\t\n\t\tif (isset($stat['tmb'])) {\n\t\t\treturn $stat['tmb'] == \"1\" ? $this->createTmb($path, $stat) : $stat['tmb'];\n\t\t}\n\t\treturn false;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function execute_backup($command) {\n\t$backup_options = get_option('dbmanager_options');\n\tcheck_backup_files();\n\n\tif( realpath( $backup_options['path'] ) === false ) {\n\t\treturn sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) );\n\t} else if( dbmanager_is_valid_path( $backup_options['mysqldumppath'] ) === 0 ) {\n\t\treturn sprintf( __( '%s is not a valid mysqldump path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqldumppath'] ) );\n\t} else if( dbmanager_is_valid_path( $backup_options['mysqlpath'] ) === 0 ) {\n\t\treturn sprintf( __( '%s is not a valid mysql path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqlpath'] ) );\n\t}\n\n\tif(substr(PHP_OS, 0, 3) == 'WIN') {\n\t\t$writable_dir = $backup_options['path'];\n\t\t$tmpnam = $writable_dir.'/wp-dbmanager.bat';\n\t\t$fp = fopen($tmpnam, 'w');\n\t\tfwrite($fp, $command);\n\t\tfclose($fp);\n\t\tsystem($tmpnam.' > NUL', $error);\n\t\tunlink($tmpnam);\n\t} else {\n\t\tpassthru($command, $error);\n\t}\n\treturn $error;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-255", "cwe_name": "Credentials Management Errors", "description": "Weaknesses in this category are related to the management of credentials.", "url": "https://cwe.mitre.org/data/definitions/255.html", "label_name": "vulnerable"} {"code": " public function backup($type='json')\r\n {\r\n global $DB;\r\n global $website;\r\n\r\n $out = array();\r\n\r\n $DB->query('\r\n SELECT * FROM nv_notes \r\n WHERE website = '.protect($website->id),\r\n 'object'\r\n );\r\n $out = $DB->result();\r\n\r\n if($type='json')\r\n $out = json_encode($out);\r\n\r\n return $out;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function is_proper_view_name( $string )\n{\n if(preg_match(\"/[^a-zA-z0-9_\\-\\ ]/\", $string)){\n return false;\n } else {\n return true;\n }\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic function delete() {\n\t global $user;\n\n $count = $this->address->find('count', 'user_id=' . $user->id);\n if($count > 1)\n { \n $address = new address($this->params['id']);\n\t if ($user->isAdmin() || ($user->id == $address->user_id)) {\n if ($address->is_billing)\n {\n $billAddress = $this->address->find('first', 'user_id=' . $user->id . \" AND id != \" . $address->id);\n $billAddress->is_billing = true;\n $billAddress->save();\n }\n if ($address->is_shipping) \n {\n $shipAddress = $this->address->find('first', 'user_id=' . $user->id . \" AND id != \" . $address->id);\n $shipAddress->is_shipping = true;\n $shipAddress->save();\n }\n\t parent::delete();\n\t }\n }\n else\n {\n flash(\"error\", gt(\"You must have at least one address.\"));\n }\n\t expHistory::back();\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tfunction execute( $par ) {\n\t\t$this->setHeaders();\n\t\t$this->outputHeader();\n\n\t\t$pager = new GlobalNewFilesPager();\n\t\t\n\t\t$this->getOutput()->addParserOutputContent( $pager->getFullOutput() );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " $forwardedValues[$k] = substr_replace($v, '0.0.0.0', 0, strrpos($v, ':'));\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " private function defaultParse($bbcode)\n {\n $parser = new JBBCode\\Parser();\n $parser->addCodeDefinitionSet(new JBBCode\\DefaultCodeDefinitionSet());\n $parser->parse($bbcode);\n return $parser->getAsHtml();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $f = function (\\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Fixtures\\\\TestServiceSubscriber']) ? $this->services['Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Fixtures\\\\TestServiceSubscriber'] : ($this->services['Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Fixtures\\\\TestServiceSubscriber'] = new \\Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber())) && false ?: '_'});", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function _testPermissions($dir, $chmod) {\n // early abort, if it is writable, everything is hunky-dory\n if (is_writable($dir)) return true;\n if (!is_dir($dir)) {\n // generally, you'll want to handle this beforehand\n // so a more specific error message can be given\n trigger_error('Directory '.$dir.' does not exist',\n E_USER_WARNING);\n return false;\n }\n if (function_exists('posix_getuid')) {\n // POSIX system, we can give more specific advice\n if (fileowner($dir) === posix_getuid()) {\n // we can chmod it ourselves\n $chmod = $chmod | 0700;\n if (chmod($dir, $chmod)) return true;\n } elseif (filegroup($dir) === posix_getgid()) {\n $chmod = $chmod | 0070;\n } else {\n // PHP's probably running as nobody, so we'll\n // need to give global permissions\n $chmod = $chmod | 0777;\n }\n trigger_error('Directory '.$dir.' not writable, '.\n 'please chmod to ' . decoct($chmod),\n E_USER_WARNING);\n } else {\n // generic error message\n trigger_error('Directory '.$dir.' not writable, '.\n 'please alter file permissions',\n E_USER_WARNING);\n }\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $length = strlen($part);\n if ($part[$length - 1] === '%') {\n // handle percents\n if (!$type) {\n $type = 'percentage';\n } elseif ($type !== 'percentage') {\n return false;\n }\n $num = (float) substr($part, 0, $length - 1);\n if ($num < 0) $num = 0;\n if ($num > 100) $num = 100;\n $new_parts[] = \"$num%\";\n } else {\n // handle integers\n if (!$type) {\n $type = 'integer';\n } elseif ($type !== 'integer') {\n return false;\n }\n $num = (int) $part;\n if ($num < 0) $num = 0;\n if ($num > 255) $num = 255;\n $new_parts[] = (string) $num;\n }\n }\n $new_triad = implode(',', $new_parts);\n $color = \"rgb($new_triad)\";\n } else {\n // hexadecimal handling\n if ($color[0] === '#') {\n $hex = substr($color, 1);\n } else {\n $hex = $color;\n $color = '#' . $color;\n }\n $length = strlen($hex);\n if ($length !== 3 && $length !== 6) return false;\n if (!ctype_xdigit($hex)) return false;\n }\n\n return $color;\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testUserCredentials($email, $password, $server, $port, $security) {\n require_once(\n realpath(Yii::app()->basePath.'/components/phpMailer/PHPMailerAutoload.php'));\n $phpMail = new PHPMailer(true);\n\n $phpMail->isSMTP();\n $phpMail->SMTPAuth = true;\n $phpMail->Username = $email;\n $phpMail->Password = $password;\n $phpMail->Host = $server;\n $phpMail->Port = $port;\n $phpMail->SMTPSecure = $security;\n\n try {\n $validCredentials = $phpMail->SmtpConnect();\n } catch(phpmailerException $error) {\n $validCredentials = false;\n }\n return $validCredentials;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tprotected function imageMagickConvertPrepare($path, $destformat, $jpgQuality, $imageSize = null) {\n\t\tif (is_null($imageSize)) {\n\t\t\t$imageSize = getimagesize($path);\n\t\t}\n\t\tif (!$imageSize) {\n\t\t\treturn array();\n\t\t}\n\t\t$srcType = $this->getExtentionByMime($imageSize['mime'], ':');\n\t\t$ani = false;\n\t\t$cmd = 'identify ' . escapeshellarg($srcType . $path);\n\t\tif ($this->procExec($cmd, $o) === 0) {\n\t\t\t$ani = preg_split('/(?:\\r\\n|\\n|\\r)/', trim($o));\n\t\t\tif (count($ani) < 2) {\n\t\t\t\t$ani = false;\n\t\t\t}\n\t\t}\n\t\t$coalesce = $index = '';\n\t\t$deconstruct = ' +repage';\n\t\tif ($ani) {\n\t\t\tif (is_null($destformat)) {\n\t\t\t\t$coalesce = ' -coalesce -repage 0x0';\n\t\t\t\t$deconstruct = ' +repage -deconstruct -layers optimize';\n\t\t\t} else {\n\t\t\t\t$index = '[0]';\n\t\t\t\tif ($srcType === 'ico:') {\n\t\t\t\t\tforeach($ani as $_i => $_info) {\n\t\t\t\t\t\tif (preg_match('/ (\\d+)x(\\d+) /', $_info, $m)) {\n\t\t\t\t\t\t\tif ($m[1] == $imageSize[0] && $m[2] == $imageSize[1]) {\n\t\t\t\t\t\t\t\t$index = '[' . $_i . ']';\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($imageSize[2] === IMAGETYPE_JPEG || $imageSize[2] === IMAGETYPE_JPEG2000) {\n\t\t\t$jpgQuality = ' -quality ' . $jpgQuality;\n\t\t} else {\n\t\t\t$jpgQuality = '';\n\t\t}\n\t\t$quotedPath = escapeshellarg($srcType . $path . $index);\n\t\t$quotedDstPath = escapeshellarg(($destformat? ($destformat . ':') : $srcType) . $path);\n\t\treturn compact('ani', 'index', 'coalesce', 'deconstruct', 'jpgQuality', 'quotedPath', 'quotedDstPath');\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $return[] = ['struct' => 'struct'];", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function show()\n {\n $task = $this->getTask();\n $subtask = $this->getSubtask();\n\n $this->response->html($this->template->render('subtask_restriction/show', array(\n 'status_list' => array(\n SubtaskModel::STATUS_TODO => t('Todo'),\n SubtaskModel::STATUS_DONE => t('Done'),\n ),\n 'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()),\n 'subtask' => $subtask,\n 'task' => $task,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function getQuerySelect()\n {\n return '';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction update_vendor() {\n\t\t$vendor = new vendor();\n\t\t\n\t\t$vendor->update($this->params['vendor']);\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function getError()\n {\n return $this->error;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function gZip()\n {\n\n #ob_start(ob_gzhandler);\n // ob_start('Site::minifyHTML');\n ob_start();\n ob_implicit_flush(0);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function post($vars) {\r\n switch (SMART_URL) {\r\n case true:\r\n $inFold = (Options::v('permalink_use_index_php') == \"on\")? \"/index.php/\":\"/\";\r\n if (Options::v('multilang_enable') === 'on') {\r\n $lang = Language::isActive();\r\n $lang = !empty($lang)? $lang . '/': '';\r\n $url = Site::$url.$inFold. $lang .self::slug($vars).\"/{$vars}\";\r\n }else{\r\n $url = Site::$url.$inFold.self::slug($vars).\"/{$vars}\";\r\n }\r\n\r\n break;\r\n\r\n default:\r\n if (Options::v('multilang_enable') === 'on') {\r\n $lang = Language::isActive();\r\n $lang = !empty($lang)? '&lang=' . $lang: '';\r\n $url = Site::$url.\"/?post={$vars}{$lang}\";\r\n }else{\r\n $url = Site::$url.\"/?post={$vars}\";\r\n }\r\n break;\r\n\r\n }\r\n\r\n return $url;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function update() {\n global $user;\n\n if (expSession::get('customer-signup')) expSession::set('customer-signup', false);\n if (isset($this->params['address_country_id'])) {\n $this->params['country'] = $this->params['address_country_id'];\n unset($this->params['address_country_id']);\n }\n if (isset($this->params['address_region_id'])) {\n $this->params['state'] = $this->params['address_region_id'];\n unset($this->params['address_region_id']);\n }\n\t\tif ($user->isLoggedIn()) {\n\t\t\t// check to see how many other addresses this user has already.\n\t\t\t$count = $this->address->find('count', 'user_id='.$user->id);\n\t\t\t// if this is first address save for this user we'll make this the default\n\t\t\tif ($count == 0) \n {\n $this->params['is_default'] = 1;\n $this->params['is_billing'] = 1;\n $this->params['is_shipping'] = 1;\n }\n\t\t\t// associate this address with the current user.\n\t\t\t$this->params['user_id'] = $user->id;\n\t\t\t// save the object\n\t\t\t$this->address->update($this->params);\n\t\t}\n else { //if (ecomconfig::getConfig('allow_anonymous_checkout')){\n //user is not logged in, but allow anonymous checkout is enabled so we'll check \n //a few things that we don't check in the parent 'stuff and create a user account.\n $this->params['is_default'] = 1;\n $this->params['is_billing'] = 1;\n $this->params['is_shipping'] = 1; \n $this->address->update($this->params);\n }\n\t\texpHistory::back(); \n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function showall_by_author() {\n\t expHistory::set('viewable', $this->params);\n\n $this->params['author'] = expString::escape($this->params['author']);\n $user = user::getUserByName($this->params['author']);\n\t\t$page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n 'where'=>($this->aggregateWhereClause()?$this->aggregateWhereClause().\" AND \":\"\").\"poster=\".$user->id,\n 'limit'=>isset($this->config['limit']) ? $this->config['limit'] : 10,\n 'order'=>'publish',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));\n\n\t\tassign_to_template(array(\n 'page'=>$page,\n 'moduletitle'=>gt('Blogs by author').' \"'.$this->params['author'].'\"'\n ));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " $db->updateObject($value, 'section');\n }\n $db->updateObject($moveSec, 'section');\n //handle re-ranking of previous parent\n $oldSiblings = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" AND rank>\" . $oldRank . \" ORDER BY rank\");\n $rerank = 1;\n foreach ($oldSiblings as $value) {\n if ($value->id != $moveSec->id) {\n $value->rank = $rerank;\n $db->updateObject($value, 'section');\n $rerank++;\n }\n }\n if ($oldParent != $moveSec->parent) {\n //we need to re-rank the children of the parent that the moving section has just left\n $childOfLastMove = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" ORDER BY rank\");\n for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {\n $childOfLastMove[$i]->rank = $i;\n $db->updateObject($childOfLastMove[$i], 'section');\n }\n }\n }\n }\n self::checkForSectionalAdmins($move);\n expSession::clearAllUsersSessionCache('navigation');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function __search_query($cmd)\n {\n $cmd .= $this->__url . \" -s '\" . $this->__setup['dataset'] . \"'\";\n return $this->__simple_query($cmd);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " public function replace($def, $config) {\n $status = parent::replace($def, $config);\n if (!$status) parent::cleanup($config);\n return $status;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\taddUserGroupMember($esc_user, $rc['id']);\n\t\telse\n\t\t\t$fails[] = $_user;\n\t}\n\tif(count($fails)) {\n\t\t$cnt = 'some';\n\t\t$code = 34;\n\t\tif(count($fails) == count($users)) {\n\t\t\t$cnt = 'all submitted';\n\t\t\t$code = 35;\n\t\t}\n\t\treturn array('status' => 'warning',\n\t\t 'failedusers' => $fails,\n\t\t 'warningcode' => $code,\n\t\t 'warningmsg' => \"failed to add $cnt users to user group\");\n\t}\n\treturn array('status' => 'success');\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public function testVersion()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);\n $this->assertAccessIsGranted($client, '/api/version');\n $result = json_decode($client->getResponse()->getContent(), true);\n\n $this->assertIsArray($result);\n\n $this->assertArrayHasKey('version', $result);\n $this->assertArrayHasKey('versionId', $result);\n $this->assertArrayHasKey('candidate', $result);\n $this->assertArrayHasKey('semver', $result);\n $this->assertArrayHasKey('name', $result);\n $this->assertArrayHasKey('copyright', $result);\n\n $this->assertSame(Constants::VERSION, $result['version']);\n $this->assertSame(Constants::VERSION_ID, $result['versionId']);\n $this->assertEquals(Constants::STATUS, $result['candidate']);\n $this->assertEquals(Constants::VERSION . '-' . Constants::STATUS, $result['semver']);\n $this->assertEquals(Constants::NAME, $result['name']);\n $this->assertEquals(\n 'Kimai - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.',\n $result['copyright']\n );\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": " public static function getDueDate(Db $zdb, $member_id)\n {\n if (!$member_id) {\n return '';\n }\n try {\n $select = $zdb->select(self::TABLE, 'c');\n $select->columns(\n array(\n 'max_date' => new Expression('MAX(date_fin_cotis)')\n )\n )->join(\n array('ct' => PREFIX_DB . ContributionsTypes::TABLE),\n 'c.' . ContributionsTypes::PK . '=ct.' . ContributionsTypes::PK,\n array()\n )->where(\n Adherent::PK . ' = ' . $member_id\n )->where(\n array('cotis_extension' => new Expression('true'))\n );\n\n $results = $zdb->execute($select);\n $result = $results->current();\n $due_date = $result->max_date;\n\n //avoid bad dates in postgres and bad mysql return from zenddb\n if ($due_date == '0001-01-01 BC' || $due_date == '1901-01-01') {\n $due_date = '';\n }\n return $due_date;\n } catch (Throwable $e) {\n Analog::log(\n 'An error occurred trying to retrieve member\\'s due date',\n Analog::ERROR\n );\n throw $e;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function SendHello($hello, $host) {\n fputs($this->smtp_conn, $hello . \" \" . $host . $this->CRLF);\n\n $rply = $this->get_lines();\n $code = substr($rply,0,3);\n\n if($this->do_debug >= 2) {\n $this->edebug(\"SMTP -> FROM SERVER: \" . $rply . $this->CRLF . '
        ');\n }\n\n if($code != 250) {\n $this->error =\n array(\"error\" => $hello . \" not accepted from server\",\n \"smtp_code\" => $code,\n \"smtp_msg\" => substr($rply,4));\n if($this->do_debug >= 1) {\n $this->edebug(\"SMTP -> ERROR: \" . $this->error[\"error\"] . \": \" . $rply . $this->CRLF . '
        ');\n }\n return false;\n }\n\n $this->helo_rply = $rply;\n\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function cleanup($config) {\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic function Delete() {\n\n\t\t// Delete \"main\" ticket\n\t\t$del_stmt = Database::prepare('\n\t\t\tDELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = :tid'\n\t\t);\n\t\tDatabase::pexecute($del_stmt, array('tid' => $this->tid));\n\n\t\t// Delete \"answers\" to ticket\"\n\t\t$del_stmt = Database::prepare('\n\t\t\tDELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = :tid'\n\t\t);\n\t\tDatabase::pexecute($del_stmt, array('tid' => $this->tid));\n\t\treturn true;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "vulnerable"} {"code": " $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\n $ret .= scan_container($cLoc, $page->id);\n $ret .= scan_page($page->id);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function edit_externalalias() {\r\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\r\n if ($section->parent == -1) {\r\n notfoundController::handle_not_found();\r\n exit;\r\n } // doesn't work for standalone pages\r\n if (empty($section->id)) {\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function isValid() {\n if ($this->isValid === null) $this->isValid = $this->validate();\n return $this->isValid;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function reset_stats() {\n// global $db;\n\n // reset the counters\n// $db->sql ('UPDATE '.$db->prefix.'banner SET impressions=0 WHERE 1');\n banner::resetImpressions();\n// $db->sql ('UPDATE '.$db->prefix.'banner SET clicks=0 WHERE 1');\n banner::resetClicks();\n\n // let the user know we did stuff.\n flash('message', gt(\"Banner statistics reset.\"));\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function withParsedBody($data)\n {\n $new = clone $this;\n $new->parsedBody = $data;\n\n return $new;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_SAVE, 'fas fa-save', null, 'primary', null, 'btn-success xxx text-white mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('customer_data_groups.php', 'page=' . $_GET['page']), null, null, 'btn-light')];", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function transform($attr, $config, $context) {\n // Abort early if we're using relaxed definition of name\n if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr;\n if (!isset($attr['name'])) return $attr;\n $id = $this->confiscateAttr($attr, 'name');\n if ( isset($attr['id'])) return $attr;\n $attr['id'] = $id;\n return $attr;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function storeSerializedSession($serialized_session_data, $session_id)\n {\n $doSession = OA_Dal::staticGetDO('session', $session_id);\n if ($doSession) {\n $doSession->sessiondata = $serialized_session_data;\n $doSession->update();\n }\n else {\n $doSession = OA_Dal::factoryDO('session');\n $doSession->sessionid = $session_id;\n $doSession->sessiondata = $serialized_session_data;\n $doSession->insert();\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": "\tstatic public function getInstanceOf($_usernfo, $_tid)\n\t{\n\t\tif (! isset(self::$tickets[$_tid . '-' . $_usernfo['userid']])) {\n\t\t\tself::$tickets[$_tid . '-' . $_usernfo['userid']] = new ticket($_usernfo, $_tid);\n\t\t}\n\t\treturn self::$tickets[$_tid . '-' . $_usernfo['userid']];\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": " function edit() {\n global $user;\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n if (empty($this->params['formtitle'])) \n {\n if (empty($this->params['id']))\n {\n $formtitle = gt(\"Add New Note\");\n }\n else\n {\n $formtitle = gt(\"Edit Note\");\n }\n }\n else\n {\n $formtitle = $this->params['formtitle'];\n }\n \n $id = empty($this->params['id']) ? null : $this->params['id'];\n $simpleNote = new expSimpleNote($id);\n //FIXME here is where we might sanitize the note before displaying/editing it\n\n assign_to_template(array(\n 'simplenote'=>$simpleNote,\n 'user'=>$user,\n 'require_login'=>$require_login,\n 'require_approval'=>$require_approval,\n 'require_notification'=>$require_notification,\n 'notification_email'=>$notification_email,\n 'formtitle'=>$formtitle,\n 'content_type'=>$this->params['content_type'],\n 'content_id'=>$this->params['content_id'],\n 'tab'=>empty($this->params['tab'])?0:$this->params['tab']\n ));\n } ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function expandIdentifiers(&$attr, $attr_types) {\n\n // because foreach will process new elements we add, make sure we\n // skip duplicates\n $processed = array();\n\n foreach ($attr as $def_i => $def) {\n // skip inclusions\n if ($def_i === 0) continue;\n\n if (isset($processed[$def_i])) continue;\n\n // determine whether or not attribute is required\n if ($required = (strpos($def_i, '*') !== false)) {\n // rename the definition\n unset($attr[$def_i]);\n $def_i = trim($def_i, '*');\n $attr[$def_i] = $def;\n }\n\n $processed[$def_i] = true;\n\n // if we've already got a literal object, move on\n if (is_object($def)) {\n // preserve previous required\n $attr[$def_i]->required = ($required || $attr[$def_i]->required);\n continue;\n }\n\n if ($def === false) {\n unset($attr[$def_i]);\n continue;\n }\n\n if ($t = $attr_types->get($def)) {\n $attr[$def_i] = $t;\n $attr[$def_i]->required = $required;\n } else {\n unset($attr[$def_i]);\n }\n }\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " private function advanceIterator()\n {\n // Place a lock on the iterator so that we ensure to not recurse,\n // preventing fatal generator errors.\n if ($this->mutex) {\n return false;\n }\n\n $this->mutex = true;\n\n try {\n $this->iterable->next();\n $this->mutex = false;\n return true;\n } catch (\\Throwable $e) {\n $this->aggregate->reject($e);\n $this->mutex = false;\n return false;\n } catch (\\Exception $e) {\n $this->aggregate->reject($e);\n $this->mutex = false;\n return false;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function params()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n $values['project_id'] = $project['id'];\n\n if (empty($values['action_name']) || empty($values['event_name'])) {\n $this->create();\n return;\n }\n\n $action = $this->actionManager->getAction($values['action_name']);\n $action_params = $action->getActionRequiredParameters();\n\n if (empty($action_params)) {\n $this->doCreation($project, $values + array('params' => array()));\n }\n\n $projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());\n unset($projects_list[$project['id']]);\n\n $this->response->html($this->template->render('action_creation/params', array(\n 'values' => $values,\n 'action_params' => $action_params,\n 'columns_list' => $this->columnModel->getList($project['id']),\n 'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),\n 'projects_list' => $projects_list,\n 'colors_list' => $this->colorModel->getList(),\n 'categories_list' => $this->categoryModel->getList($project['id']),\n 'links_list' => $this->linkModel->getList(0, false),\n 'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'swimlane_list' => $this->swimlaneModel->getList($project['id']),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public static function access ($grp='4') {\r\n if ( isset($_SESSION['gxsess']['val']['group']) ) {\r\n if($_SESSION['gxsess']['val']['group'] <= $grp) {\r\n return true;\r\n }else{\r\n return false;\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function getCookieValue($value)\n {\n if (substr($value, 0, 1) !== '\"' &&\n substr($value, -1, 1) !== '\"' &&\n strpbrk($value, ';,=')\n ) {\n $value = '\"' . $value . '\"';\n }\n\n return $value;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function set($vars) {\r\n self::set_session($vars);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function remove()\n {\n $project = $this->getProject();\n $this->checkCSRFParam();\n $column_id = $this->request->getIntegerParam('column_id');\n\n if ($this->columnModel->remove($column_id)) {\n $this->flash->success(t('Column removed successfully.'));\n } else {\n $this->flash->failure(t('Unable to remove this column.'));\n }\n\n $this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "function db_start()\n{\n global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;\n\n switch ($DatabaseType) {\n case 'mysqli':\n $connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort);\n break;\n }\n\n // Error code for both.\n if ($connection === false) {\n switch ($DatabaseType) {\n case 'mysqli':\n $errormessage = mysqli_error($connection);\n break;\n }\n db_show_error(\"\", \"\" . _couldNotConnectToDatabase . \": $DatabaseServer\", $errormessage);\n }\n return $connection;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function prepare($config, $context) {\n $this->htmlDefinition = $config->getHTMLDefinition();\n // Even though this might fail, some unit tests ignore this and\n // still test checkNeeded, so be careful. Maybe get rid of that\n // dependency.\n $result = $this->checkNeeded($config);\n if ($result !== false) return $result;\n $this->currentNesting =& $context->get('CurrentNesting');\n $this->inputTokens =& $context->get('InputTokens');\n $this->inputIndex =& $context->get('InputIndex');\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function allowedViewProfileField(self $user, $fieldNameIntern)\n {\n return $user->mProfileFieldsData->isVisible($fieldNameIntern, $this->hasRightEditProfile($user));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": " public static function insert($vars) {\n if(is_array($vars)) {\n $ins = array(\n 'table' => 'options',\n 'name' => $vars['name'],\n 'value' => $vars['value']\n );\n $opt = Db::insert($ins);\n }else{\n Control::error('unknown','Format not Found, please in array');\n }\n return $opt;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " private function getCategory()\n {\n $category = $this->categoryModel->getById($this->request->getIntegerParam('category_id'));\n\n if (empty($category)) {\n throw new PageNotFoundException();\n }\n\n return $category;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function testMultipleTags()\n {\n $bbcode = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .\n 'things like [u]that[/u].';\n $bbcodeOutput = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .\n 'things like [u]that[/u].';\n $this->assertBBCodeOutput($bbcode, $bbcodeOutput);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function update_discount() {\n $id = empty($this->params['id']) ? null : $this->params['id'];\n $discount = new discounts($id);\n // find required shipping method if needed\n if ($this->params['required_shipping_calculator_id'] > 0) {\n $this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']];\n } else {\n $this->params['required_shipping_calculator_id'] = 0;\n }\n \n $discount->update($this->params);\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public static function parseAndTrimExport($str, $isHTML = false) { //\ufffdDeath from above\ufffd? \ufffd\n //echo \"1
        \"; eDebug($str); \n\n $str = str_replace(\"\ufffd\", \"’\", $str);\n $str = str_replace(\"\ufffd\", \"‘\", $str);\n $str = str_replace(\"\ufffd\", \"®\", $str);\n $str = str_replace(\"\ufffd\", \"-\", $str);\n $str = str_replace(\"\ufffd\", \"—\", $str);\n $str = str_replace(\"\ufffd\", \"”\", $str);\n $str = str_replace(\"\ufffd\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\t\", \" \", $str);\n $str = str_replace(\",\", \"\\,\", $str);\n $str = str_replace(\"\ufffd\", \"¼\", $str);\n $str = str_replace(\"\ufffd\", \"½\", $str);\n $str = str_replace(\"\ufffd\", \"¾\", $str);\n\n if (!$isHTML) {\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n } else {\n $str = str_replace('\"', '\"\"', $str);\n }\n\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n $str = trim(str_replace(\"\ufffd\", \"™\", $str));\n //echo \"2
        \"; eDebug($str,die);\n return $str;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public static function isExist($token)\n {\n $json = Options::get('tokens');\n $tokens = json_decode($json, true);\n if (!is_array($tokens) || $tokens == '') {\n $tokens = array();\n }\n if (array_key_exists($token, $tokens)) {\n $call = true;\n } else {\n $call = false;\n }\n\n return $call;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $db->insertObject($obj, 'expeAlerts_subscribers');\n }\n \n $count = count($this->params['ealerts']);\n \n if ($count > 0) {\n flash('message', gt(\"Your subscriptions have been updated. You are now subscriber to\").\" \".$count.' '.gt('E-Alerts.'));\n } else {\n flash('error', gt(\"You have been unsubscribed from all E-Alerts.\"));\n }\n \n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "function advancedFilterSearch($queue, $filter)\n{\n\tglobal $database_ged;\n\t$datas = array();\n\n\tif($filter == \"description\"){\n\t\techo json_encode($datas);\n\t\treturn false;\n\t}\n\n\t$gedsql_result1=sqlrequest($database_ged,\"SELECT pkt_type_id,pkt_type_name FROM pkt_type WHERE pkt_type_id!='0' AND pkt_type_id<'100';\");\n\t\n\t\n\twhile($ged_type = mysqli_fetch_assoc($gedsql_result1)){\n\t\t$sql = \"SELECT DISTINCT $filter FROM \".$ged_type[\"pkt_type_name\"].\"_queue_\".$queue;\n\n\t\t$results = sqlrequest($database_ged, $sql);\n\t\twhile($result = mysqli_fetch_array($results)){\n\t\t\tif( !in_array($result[$filter], $datas) && $result[$filter] != \"\" ){\n\t\t\t\tarray_push($datas, $result[$filter]);\n\t\t\t}\n\t\t}\n\t}\n\n\techo json_encode($datas);\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public static function canImportData() {\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function confirm() {\n global $db;\n \n // make sure we have what we need.\n if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));\n if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));\n \n // verify the id/key pair \n $id = $db->selectValue('subscribers','id', 'id='.$this->params['id'].' AND hash=\"'.$this->params['key'].'\"');\n if (empty($id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));\n \n // activate this users pending subscriptions\n $sub = new stdClass();\n $sub->enabled = 1;\n $db->updateObject($sub, 'expeAlerts_subscribers', 'subscribers_id='.$id);\n \n // find the users active subscriptions\n $ealerts = expeAlerts::getBySubscriber($id);\n assign_to_template(array(\n 'ealerts'=>$ealerts\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $sloc = expCore::makeLocation('navigation', null, $section->id);\n // remove any manage permissions for this page and it's children\n // $db->delete('userpermission', \"module='navigationController' AND internal=\".$section->id);\n // $db->delete('grouppermission', \"module='navigationController' AND internal=\".$section->id);\n foreach ($allusers as $uid) {\n $u = user::getUserById($uid);\n expPermissions::grant($u, 'manage', $sloc);\n }\n foreach ($allgroups as $gid) {\n $g = group::getGroupById($gid);\n expPermissions::grantGroup($g, 'manage', $sloc);\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function getTaskLink()\n {\n $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));\n\n if (empty($link)) {\n throw new PageNotFoundException();\n }\n\n return $link;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic function getPurchaseOrderByJSON() {\n\n\t\tif(!empty($this->params['vendor'])) {\n\t\t\t$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);\n\t\t} else {\n\t\t\t$purchase_orders = $this->purchase_order->find('all');\n\t\t}\n\n\t\techo json_encode($purchase_orders);\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public function event()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n $values['project_id'] = $project['id'];\n\n if (empty($values['action_name'])) {\n return $this->create();\n }\n\n return $this->response->html($this->template->render('action_creation/event', array(\n 'values' => $values,\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function activate_discount(){\n if (isset($this->params['id'])) {\n $discount = new discounts($this->params['id']);\n $discount->update($this->params);\n //if ($discount->discountulator->hasConfig() && empty($discount->config)) {\n //flash('messages', $discount->discountulator->name().' requires configuration. Please do so now.');\n //redirect_to(array('controller'=>'billing', 'action'=>'configure', 'id'=>$discount->id));\n //}\n }\n\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function db_seq_nextval($seqname)\n{\n\tglobal $DatabaseType;\n\n\tif ($DatabaseType == 'mysqli')\n\t\t$seq = \"fn_\" . strtolower($seqname) . \"()\";\n\n\treturn $seq;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " $posts_arr = json_decode(json_encode($posts), false);\n // $posts[] = $posts;\n $post_arr[] = $posts_arr;\n $post = $post_arr;\n }\n } else {\n $post = $post;\n }\n } else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function getIso()\n {\n return $this->dateTime->format(\\DateTime::ATOM);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function setup() {\n $this->addDecorator('Cleanup');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function addChannelPageTools($agencyid, $websiteId, $channelid, $channelType)\n{\n if ($channelType == 'publisher') {\n $deleteReturlUrl = MAX::constructUrl(MAX_URL_ADMIN, 'affiliate-channels.php');\n }\n else {\n $deleteReturlUrl = MAX::constructUrl(MAX_URL_ADMIN, 'channel-index.php');\n }\n\n //duplicate\n addPageLinkTool($GLOBALS[\"strDuplicate\"], MAX::constructUrl(MAX_URL_ADMIN, \"channel-modify.php?duplicate=true&agencyid=$agencyid&affiliateid=$websiteId&channelid=$channelid&returnurl=\".urlencode(basename($_SERVER['SCRIPT_NAME']))), \"iconTargetingChannelDuplicate\");\n\n //delete\n $deleteConfirm = phpAds_DelConfirm($GLOBALS['strConfirmDeleteChannel']);\n addPageLinkTool($GLOBALS[\"strDelete\"], MAX::constructUrl(MAX_URL_ADMIN, \"channel-delete.php?token=\" . urlencode(phpAds_SessionGetToken()) . \"&agencyid=$agencyid&affiliateid=$websiteId&channelid=$channelid&returnurl=$deleteReturlUrl\"), \"iconDelete\", null, $deleteConfirm);\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public function theme_switch() {\n if (!expUtil::isReallyWritable(BASE.'framework/conf/config.php')) { // we can't write to the config.php file\n flash('error',gt('The file /framework/conf/config.php is NOT Writeable. You will be unable to change the theme.'));\n }\n \texpSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);\n\t expSession::set('display_theme',$this->params['theme']);\n\t $sv = isset($this->params['sv'])?$this->params['sv']:'';\n\t if (strtolower($sv)=='default') {\n\t $sv = '';\n\t }\n\t expSettings::change('THEME_STYLE_REAL',$sv);\n\t expSession::set('theme_style',$sv);\n\t expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme\n\n // $message = (MINIFY != 1) ? \"Exponent is now minifying Javascript and CSS\" : \"Exponent is no longer minifying Javascript and CSS\" ;\n // flash('message',$message);\n\t $message = gt(\"You have selected the\").\" '\".$this->params['theme'].\"' \".gt(\"theme\");\n\t if ($sv != '') {\n\t\t $message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');\n\t }\n\t flash('message',$message);\n// expSession::un_set('framework');\n expSession::set('force_less_compile', 1);\n// expTheme::removeSmartyCache();\n expSession::clearAllUsersSessionCache();\n \texpHistory::returnTo('manageable');\n }\t", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function flush($config) {\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testQuotesPages () {\n $this->visitPages ($this->getPages ('^quotes'));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "\t\t\tform_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);\n form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'right');\n form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'right');\n form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'right');\n form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);\n form_end_row();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function Login ($username = '', $password = '') {\n if ($this->connected == false) {\n $this->error = 'Not connected to POP3 server';\n\n if ($this->do_debug >= 1) {\n $this->displayErrors();\n }\n }\n\n if (empty($username)) {\n $username = $this->username;\n }\n\n if (empty($password)) {\n $password = $this->password;\n }\n\n $pop_username = \"USER $username\" . $this->CRLF;\n $pop_password = \"PASS $password\" . $this->CRLF;\n\n // Send the Username\n $this->sendString($pop_username);\n $pop3_response = $this->getResponse();\n\n if ($this->checkResponse($pop3_response)) {\n // Send the Password\n $this->sendString($pop_password);\n $pop3_response = $this->getResponse();\n\n if ($this->checkResponse($pop3_response)) {\n return true;\n }\n }\n return false;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tprotected static function localScandir($dir) {\n\t\t// PHP function scandir() is not work well in specific environment. I dont know why.\n\t\t// ref. https://github.com/Studio-42/elFinder/issues/1248\n\t\t$files = array();\n\t\tif ($dh = opendir($dir)) {\n\t\t\twhile (false !== ($file = readdir($dh))) {\n\t\t\t\tif ($file !== '.' && $file !== '..') {\n\t\t\t\t\t$files[] = $file;\n\t\t\t\t}\n\t\t\t}\n\t\t\tclosedir($dh);\n\t\t} else {\n\t\t\tthrow new Exception('Can not open local directory.');\n\t\t}\n\t\treturn $files;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function forceChangePassword()\n {\n if (!Yii::$app->user->isMustChangePasswordUrl()) {\n return Yii::$app->getResponse()->redirect(Url::toRoute(Yii::$app->user->mustChangePasswordRoute));\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " function showallSubcategories() {\n// global $db;\n\n expHistory::set('viewable', $this->params);\n// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');\n $catid = expSession::get('catid');\n $parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? $this->params['cat'] : 0);\n $category = new storeCategory($parent);\n $categories = $category->getEcomSubcategories();\n $ancestors = $category->pathToNode();\n assign_to_template(array(\n 'categories' => $categories,\n 'ancestors' => $ancestors,\n 'category' => $category\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " $date->delete(); // event automatically deleted if all assoc eventdates are deleted\n }\n expHistory::back();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function prepare($config, $context) {\n $this->docURL = $config->get('AutoFormat.PurifierLinkify.DocURL');\n return parent::prepare($config, $context);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function handleRequest() {\n /* Load error handling class */\n $this->loadErrorHandler();\n\n $this->modx->invokeEvent('OnHandleRequest');\n\n /* save page to manager object. allow custom actionVar choice for extending classes. */\n $this->action = isset($_REQUEST[$this->actionVar]) ? (integer)$_REQUEST[$this->actionVar] : $this->defaultAction;\n\n /* invoke OnManagerPageInit event */\n $this->modx->invokeEvent('OnManagerPageInit',array('action' => $this->action));\n $this->prepareResponse();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function getEscapeChar()\n {\n return $this->escapeChar;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": " protected function _mkfile($path, $name)\n {\n $path = $this->_joinPath($path, $name);\n return $this->connect->put($path, '') ? $path : false;\n/*\n if ($this->tmp) {\n $path = $this->_joinPath($path, $name);\n $local = $this->getTempFile();\n $res = touch($local) && $this->connect->put($path, $local, NET_SFTP_LOCAL_FILE);\n unlink($local);\n return $res ? $path : false;\n }\n\n return false;\n */\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public static function isExist($token){\r\n $json = Options::v('tokens');\r\n $tokens = json_decode($json, true);\r\n if(!is_array($tokens) || $tokens == \"\"){\r\n $tokens = array();\r\n }\r\n if(array_key_exists($token, $tokens)){\r\n $call = true;\r\n }else{\r\n $call = false;\r\n }\r\n return $call;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function add($var)\n {\n $route = self::$_route;\n\n self::$_route = array_merge($var, $route);\n // new Router();\n $keys = array_map('strlen', array_keys(self::$_route));\n array_multisort($keys, SORT_DESC, self::$_route);\n // print_r(self::$_route);\n return self::$_route;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function build(ContainerBuilder $container)\n {\n // auto-tag GDPR data providers\n $container\n ->registerForAutoconfiguration(DataProviderInterface::class)\n ->addTag('pimcore.gdpr.data-provider');\n\n $container->addCompilerPass(new SerializerPass());\n $container->addCompilerPass(new GDPRDataProviderPass());\n $container->addCompilerPass(new ImportExportLocatorsPass());\n $container->addCompilerPass(new TranslationServicesPass());\n $container->addCompilerPass(new ContentSecurityPolicyUrlsPass());\n\n /** @var SecurityExtension $extension */\n $extension = $container->getExtension('security');\n $extension->addSecurityListenerFactory(new PreAuthenticatedAdminSessionFactory());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __construct() {\n global $GLOBALS, $data;\n self::$editors =& $GLOBALS;\n self::$data =& $data;\n self::$url = Options::get('siteurl');\n self::$domain = Options::get('sitedomain');\n self::$name = Options::get('sitename');\n self::$key = Options::get('sitekeywords');\n self::$desc = Options::get('sitedesc');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public function verifyDOMDocument($document)\n {\n $signatureNode = $this->locateSignature($document);\n\n /**\n * No signature was added, it should not fail as this is not a requirement on redirect bindings\n */\n if (!$signatureNode) {\n return true;\n }\n\n $this->add509Cert($this->getCertificate()->getPublicKey()->getX509Certificate());\n $this->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);\n $this->addReference($document->documentElement, XMLSecurityDSig::SHA1, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), array('id_name' => 'ID'));\n\n return $this->verify($this->getCertificate()->getPublicKey());\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": "\tpublic function Set($_var = '', $_value = '', $_vartrusted = false, $_valuetrusted = false)\n\t{\n\t\tif ($_var != '' && $_value != '') {\n\t\t\tif (! $_vartrusted) {\n\t\t\t\t$_var = strip_tags($_var);\n\t\t\t}\n\t\t\t\n\t\t\tif (! $_valuetrusted) {\n\t\t\t\t$_value = strip_tags($_value, '
        ');\n\t\t\t}\n\t\t\t\n\t\t\tif (strtolower($_var) == 'message' || strtolower($_var) == 'subject') {\n\t\t\t\t$_value = $this->convertLatin1ToHtml($_value);\n\t\t\t}\n\t\t\t\n\t\t\t$this->t_data[$_var] = $_value;\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": " protected function sendCommand($command, $commandstring, $expect)\n {\n if (!$this->connected()) {\n $this->setError(\"Called $command without being connected\");\n return false;\n }\n $this->client_send($commandstring . self::CRLF);\n\n $this->last_reply = $this->get_lines();\n // Fetch SMTP code and possible error code explanation\n $matches = array();\n if (preg_match(\"/^([0-9]{3})[ -](?:([0-9]\\\\.[0-9]\\\\.[0-9]) )?/\", $this->last_reply, $matches)) {\n $code = $matches[1];\n $code_ex = (count($matches) > 2 ? $matches[2] : null);\n // Cut off error code from each response line\n $detail = preg_replace(\n \"/{$code}[ -]\".($code_ex ? str_replace('.', '\\\\.', $code_ex).' ' : '').\"/m\",\n '',\n $this->last_reply\n );\n } else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " $percent = round($percent, 0);\n } else {\n $percent = round($percent, 2); // school default\n }\n if ($ret == '%')\n return $percent;\n\n if (!$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id])\n $_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] = DBGet(DBQuery('SELECT TITLE,ID,BREAK_OFF FROM report_card_grades WHERE SYEAR=\\'' . $cp[1]['SYEAR'] . '\\' AND SCHOOL_ID=\\'' . $cp[1]['SCHOOL_ID'] . '\\' AND GRADE_SCALE_ID=\\'' . $grade_scale_id . '\\' ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER'));\n\n foreach ($_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] as $grade) {\n if ($does_breakoff == 'Y' ? $percent >= $programconfig[$staff_id][$course_period_id . '-' . $grade['ID']] && is_numeric($programconfig[$staff_id][$course_period_id . '-' . $grade['ID']]) : $percent >= $grade['BREAK_OFF'])\n return $ret == 'ID' ? $grade['ID'] : $grade['TITLE'];\n }\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "function VerifyBlockedSchedule($columns,$course_period_id,$sec,$edit=false)\n{\n if($course_period_id!='new')\n {\n $cp_det_RET= DBGet(DBQuery(\"SELECT * FROM course_periods WHERE course_period_id=$course_period_id\"));\n\n $cp_det_RET=$cp_det_RET[1];\n $teacher=$cp_det_RET['TEACHER_ID'];\n $secteacher=$cp_det_RET['SECONDARY_TEACHER_ID'];\n $all_teacher=$teacher.($secteacher!=''?$secteacher:'');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "\tfunction edit_vendor() {\n\t\t$vendor = new vendor();\n\n\t\tif(isset($this->params['id'])) {\n\t\t\t$vendor = $vendor->find('first', 'id =' .$this->params['id']);\n\t\t\tassign_to_template(array(\n 'vendor'=>$vendor\n ));\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function scan_page($parent_id) {\r\n global $db;\r\n\r\n $sections = $db->selectObjects('section','parent=' . $parent_id);\r\n $ret = '';\r\n foreach ($sections as $page) {\r\n $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\r\n $ret .= scan_container($cLoc, $page->id);\r\n $ret .= scan_page($page->id);\r\n }\r\n return $ret;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic static function login() {\n\t\tuser::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));\n\t\tif (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in\n\t\t\tflash('error', gt('Invalid Username / Password'));\n\t\t\tif (expSession::is_set('redirecturl_error')) {\n\t\t\t\t$url = expSession::get('redirecturl_error');\n\t\t\t\texpSession::un_set('redirecturl_error');\n\t\t\t\theader(\"Location: \".$url);\n\t\t\t} else {\n\t\t\t\texpHistory::back();\n\t\t\t}\n\t\t} else { // we're logged in\n\t\t\tglobal $user;\n\n if (expSession::get('customer-login')) expSession::un_set('customer-login');\n\t\t\tif (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));\n if ($user->isAdmin()) {\n expHistory::back();\n } else {\n foreach ($user->groups as $g) {\n if (!empty($g->redirect)) {\n $url = URL_FULL.$g->redirect;\n break;\n }\n }\n if (isset($url)) {\n header(\"Location: \".$url);\n } else {\n expHistory::back();\n }\n }\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function htmlContextCleaner($input) {\n $bad_chars = array(\"<\", \">\");\n $safe_chars = array(\"<\", \">\");\n $output = str_replace($bad_chars, $safe_chars, $input);\n\n return stripslashes($output);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "\tprotected function _unlink($path) {\n\t\t$ret = unlink($path);\n\t\t$ret && clearstatcache();\n\t\treturn $ret;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function remove_spam()\r\n {\r\n global $DB;\r\n global $website;\r\n\r\n $count = $DB->query_single(\r\n\t 'count(*) as total',\r\n\t 'nv_comments',\r\n\t 'website = '.protect($website->id).' AND status = 3'\r\n );\r\n\r\n $ok = $DB->execute('\r\n\t\t\tDELETE FROM nv_comments\r\n WHERE website = '.protect($website->id).'\r\n AND status = 3\r\n ');\r\n\r\n if($ok)\r\n return $count;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private function scale($r, $scale) {\n if ($scale < 0) {\n // The f sprintf type doesn't support negative numbers, so we\n // need to cludge things manually. First get the string.\n $r = sprintf('%.0f', (float) $r);\n // Due to floating point precision loss, $r will more than likely\n // look something like 4652999999999.9234. We grab one more digit\n // than we need to precise from $r and then use that to round\n // appropriately.\n $precise = (string) round(substr($r, 0, strlen($r) + $scale), -1);\n // Now we return it, truncating the zero that was rounded off.\n return substr($precise, 0, -1) . str_repeat('0', -$scale + 1);\n }\n return sprintf('%.' . $scale . 'f', (float) $r);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $s = trim(substr($s, 4));\n if (!$s) {\n continue;\n }\n $fields = explode(' ', $s);\n if (!empty($fields)) {\n if (!$n) {\n $name = $type;\n $fields = $fields[0];\n } else {\n $name = array_shift($fields);\n if ($name == 'SIZE') {\n $fields = ($fields) ? $fields[0] : 0;\n }\n }\n $this->server_caps[$name] = ($fields ? $fields : true);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function save_change_password() {\n global $user;\n\n $isuser = ($this->params['uid'] == $user->id) ? 1 : 0;\n\n if (!$user->isAdmin() && !$isuser) {\n flash('error', gt('You do not have permissions to change this users password.'));\n expHistory::back();\n }\n\n if (($isuser && empty($this->params['password'])) || (!empty($this->params['password']) && $user->password != user::encryptPassword($this->params['password']))) {\n flash('error', gt('The current password you entered is not correct.'));\n expHistory::returnTo('editable');\n }\n //eDebug($user);\n $u = new user($this->params['uid']);\n\n $ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);\n //eDebug($u, true);\n if (is_string($ret)) {\n flash('error', $ret);\n expHistory::returnTo('editable');\n } else {\n $params = array();\n $params['is_admin'] = !empty($u->is_admin);\n $params['is_acting_admin'] = !empty($u->is_acting_admin);\n $u->update($params);\n }\n\n if (!$isuser) {\n flash('message', gt('The password for') . ' ' . $u->username . ' ' . gt('has been changed.'));\n } else {\n $user->password = $u->password;\n flash('message', gt('Your password has been changed.'));\n }\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function getAmount()\n {\n $amount = $this->getParameter('amount');\n\n if ($amount !== null) {\n // Don't allow integers for currencies that support decimals.\n // This is for legacy reasons - upgrades from v0.9\n if ($this->getCurrencyDecimalPlaces() > 0) {\n if (is_int($amount) || (is_string($amount) && false === strpos((string) $amount, '.'))) {\n throw new InvalidRequestException(\n 'Please specify amount as a string or float, '\n . 'with decimal places (e.g. \\'10.00\\' to represent $10.00).'\n );\n };\n }\n\n $amount = $this->toFloat($amount);\n\n // Check for a negative amount.\n if (!$this->negativeAmountAllowed && $amount < 0) {\n throw new InvalidRequestException('A negative amount is not allowed.');\n }\n\n // Check for a zero amount.\n if (!$this->zeroAmountAllowed && $amount === 0.0) {\n throw new InvalidRequestException('A zero amount is not allowed.');\n }\n\n // Check for rounding that may occur if too many significant decimal digits are supplied.\n $decimal_count = strlen(substr(strrchr(sprintf('%.8g', $amount), '.'), 1));\n if ($decimal_count > $this->getCurrencyDecimalPlaces()) {\n throw new InvalidRequestException('Amount precision is too high for currency.');\n }\n\n return $this->formatCurrency($amount);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function __construct(\n CartService $cartService,\n int $defaultTtl,\n bool $httpCacheEnabled,\n MaintenanceModeResolver $maintenanceModeResolver\n ) {\n $this->cartService = $cartService;\n $this->defaultTtl = $defaultTtl;\n $this->httpCacheEnabled = $httpCacheEnabled;\n $this->maintenanceResolver = $maintenanceModeResolver;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "function XMLRPCremoveResourceGroupPriv($name, $type, $nodeid, $permissions) {\n\treturn _XMLRPCchangeResourceGroupPriv_sub('remove', $name, $type, $nodeid,\n\t $permissions);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public function notify_edge_mode() {\n w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');\n w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin_ui.php');\n $message = sprintf(__('

        You can now keep W3 Total Cache up-to-date without having to worry about new features breaking your website. There will be more releases with bug fixes, security fixes and settings updates.

        \n

        Also, you can now try out our new features as soon as they\\'re ready. %s to enable \"edge mode\" and unlock pre-release features. %s

        ', 'w3-total-cache')\n ,'' . __('Click Here', 'w3-total-cache') . ''\n , w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'edge_mode', '', true,'','w3tc_default_hide_note_custom')\n );\n w3_e_notification_box($message, 'edge-mode');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " protected function getSwimlane(array $project)\n {\n $swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));\n\n if (empty($swimlane)) {\n throw new PageNotFoundException();\n }\n\n if ($swimlane['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $swimlane;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": "\tpublic function manage_versions() {\n\t expHistory::set('manageable', $this->params);\n\n\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');\n\n\t $sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';\n\t $sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';\n\n\t $page = new expPaginator(array(\n 'sql'=>$sql,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Version')=>'version',\n gt('Title')=>'title',\n gt('Current')=>'is_current',\n gt('# of Docs')=>'num_docs'\n ),\n ));\n\n\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page\n ));\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"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 }else{\n $sort = \" ASC\";\n }\n }\n $cat = Db::result(\"SELECT * FROM `cat` {$where} {$order_by} {$sort}\");\n //print_r($cat);\n $drop = \"\";\n\n return $drop;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function update()\n {\n $project = $this->getProject();\n\n $values = $this->request->getValues();\n list($valid, $errors) = $this->swimlaneValidator->validateModification($values);\n\n if ($valid) {\n if ($this->swimlaneModel->update($values['id'], $values)) {\n $this->flash->success(t('Swimlane updated successfully.'));\n return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));\n } else {\n $errors = array('name' => array(t('Another swimlane with the same name exists in the project')));\n }\n }\n\n return $this->edit($values, $errors);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " function __autoload($classname)\n {\n PHPMailerAutoload($classname);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function toolbar() {\n// global $user;\n\n $menu = array();\n\t\t$dirs = array(\n\t\t\tBASE.'framework/modules/administration/menus',\n\t\t\tBASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'\n\t\t);\n\n\t\tforeach ($dirs as $dir) {\n\t\t if (is_readable($dir)) {\n\t\t\t $dh = opendir($dir);\n\t\t\t while (($file = readdir($dh)) !== false) {\n\t\t\t\t if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {\n\t\t\t\t\t $menu[substr($file,0,-4)] = include($dir.'/'.$file);\n if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\t\t}\n\n // sort the top level menus alphabetically by filename\n\t\tksort($menu);\t\t\n\t\t$sorted = array();\n\t\tforeach($menu as $m) $sorted[] = $m;\n \n // slingbar position\n if (isset($_COOKIE['slingbar-top'])){\n $top = $_COOKIE['slingbar-top'];\n } else {\n $top = SLINGBAR_TOP;\n }\n \n\t\tassign_to_template(array(\n 'menu'=>(bs3()) ? $sorted : json_encode($sorted),\n \"top\"=>$top\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function __construct () {\r\n\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function urlProvider()\n {\n return array(\n array('http://till:test@svn.example.org/', $this->getCmd(\" --username 'till' --password 'test' \")),\n array('http://svn.apache.org/', ''),\n array('svn://johndoe@example.org', $this->getCmd(\" --username 'johndoe' --password '' \")),\n );\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "function test($g) {\n $GLOBALS['g'] = $GLOBALS;\n\n array_replace_recursive($GLOBALS, $g);\n\n $GLOBALS['g'] = $GLOBALS;\n array_merge_recursive($GLOBALS, $g);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " public function settings_save() {\n AuthUser::load();\n if (!AuthUser::isLoggedIn()) {\n redirect(get_url('login'));\n } else if (!AuthUser::hasPermission('admin_edit')) {\n Flash::set('error', __('You do not have permission to access the requested page!'));\n redirect(get_url());\n }\n \n if (!isset($_POST['settings'])) {\n Flash::set('error', 'File Manager - ' . __('form was not posted.'));\n redirect(get_url('plugin/file_manager/settings'));\n } else {\n $settings = $_POST['settings'];\n\n if ($settings['umask'] == 0)\n $settings['umask'] = 0;\n elseif (!preg_match('/^0?[0-7]{3}$/', $settings['umask']))\n $settings['umask'] = 0;\n if (strlen($settings['umask']) === 3)\n $settings['umask'] = '0' . $settings['umask'];\n elseif (strlen($settings['umask']) !== 4 && $settings['umask'] != 0)\n $settings['umask'] = 0;\n\n if (!preg_match('/^0?[0-7]{3}$/', $settings['dirmode']))\n $settings['dirmode'] = '0755';\n if (strlen($settings['dirmode']) === 3)\n $settings['dirmode'] = '0' . $settings['dirmode'];\n\n if (!preg_match('/^0?[0-7]{3}$/', $settings['filemode']))\n $settings['filemode'] = '0755';\n if (strlen($settings['filemode']) === 3)\n $settings['filemode'] = '0' . $settings['filemode'];\n }\n\n if (Plugin::setAllSettings($settings, 'file_manager'))\n Flash::setNow('success', 'File Manager - ' . __('plugin settings saved.'));\n else\n Flash::setNow('error', 'File Manager - ' . __('plugin settings not saved!'));\n\n $this->display('file_manager/views/settings', array('settings' => $settings));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " protected function assertNoErrors () {\n\t\t$this->assertElementNotPresent('css=.xdebug-error');\n\t\t$this->assertElementNotPresent('css=#x2-php-error');\n $this->storeEval (\n \"window.document.body.attributes['x2-js-error'] ? 'true' : 'false'\", \n 'hasJsErrorAttr');\n $hasJsErrorAttr = $this->getExpression ('${hasJsErrorAttr}');\n if ($hasJsErrorAttr === 'true') {\n $this->storeAttribute ('dom=document.body@x2-js-error', 'errorMessage');\n $errorMessage = $this->getExpression ('${errorMessage}');\n println ($errorMessage);\n $this->assertTrue (false, $errorMessage);\n } \n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " private function elementInScope($el, $table = false) {\n if(is_array($el)) {\n foreach($el as $element) {\n if($this->elementInScope($element, $table)) {\n return true;\n }\n }\n\n return false;\n }\n\n $leng = count($this->stack);\n\n for($n = 0; $n < $leng; $n++) {\n /* 1. Initialise node to be the current node (the bottommost node of\n the stack). */\n $node = $this->stack[$leng - 1 - $n];\n\n if($node->tagName === $el) {\n /* 2. If node is the target node, terminate in a match state. */\n return true;\n\n } elseif($node->tagName === 'table') {\n /* 3. Otherwise, if node is a table element, terminate in a failure\n state. */\n return false;\n\n } elseif($table === true && in_array($node->tagName, array('caption', 'td',\n 'th', 'button', 'marquee', 'object'))) {\n /* 4. Otherwise, if the algorithm is the \"has an element in scope\"\n variant (rather than the \"has an element in table scope\" variant),\n and node is one of the following, terminate in a failure state. */\n return false;\n\n } elseif($node === $node->ownerDocument->documentElement) {\n /* 5. Otherwise, if node is an html element (root element), terminate\n in a failure state. (This can only happen if the node is the topmost\n node of the stack of open elements, and prevents the next step from\n being invoked if there are no more elements in the stack.) */\n return false;\n }\n\n /* Otherwise, set node to the previous entry in the stack of open\n elements and return to step 2. (This will never fail, since the loop\n will always terminate in the previous step if the top of the stack\n is reached.) */\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $banner->increaseImpressions();\n }\n }\n\n // assign banner to the template and show it!\n assign_to_template(array(\n 'banners'=>$banners\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function getDoNotEmailLinkText(){\n if(!empty($this->doNotEmailLinkText)){\n return $this->doNotEmailLinkText;\n }\n return self::getDoNotEmailLinkDefaultText ();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " protected function defaultExtensions()\n {\n return [\n 'jpg',\n 'jpeg',\n 'bmp',\n 'png',\n 'webp',\n 'gif',\n 'svg',\n 'js',\n 'map',\n 'ico',\n 'css',\n 'less',\n 'scss',\n 'ics',\n 'odt',\n 'doc',\n 'docx',\n 'ppt',\n 'pptx',\n 'pdf',\n 'swf',\n 'txt',\n 'xml',\n 'ods',\n 'xls',\n 'xlsx',\n 'eot',\n 'woff',\n 'woff2',\n 'ttf',\n 'flv',\n 'wmv',\n 'mp3',\n 'ogg',\n 'wav',\n 'avi',\n 'mov',\n 'mp4',\n 'mpeg',\n 'webm',\n 'mkv',\n 'rar',\n 'xml',\n 'zip'\n ];\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function fixName($name) {\n $name = preg_replace('/[^A-Za-z0-9\\.]/','_',$name);\n if ($name[0] == '.') // attempt to upload a dot file\n $name[0] = '_';\n $name = str_replace('_', '..', $name); // attempt to upload with redirection to new folder\n return $name;\n// return preg_replace('/[^A-Za-z0-9\\.]/', '-', $name);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " foreach($course_RET as $period_day)\n {\n $period_days_append_sql .=\"(sp.start_time<='$period_day[END_TIME]' AND '$period_day[START_TIME]'<=sp.end_time AND DAYS LIKE '%$period_day[DAYS]%') OR \";\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " static function isSearchable() {\r\n return true;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " $this->stream = new Stream($streamOrFile);\n } elseif ($streamOrFile instanceof StreamInterface) {\n $this->stream = $streamOrFile;\n } else {\n throw new InvalidArgumentException(\n 'Invalid stream or file provided for UploadedFile'\n );\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function setAuthorizedBackendSession()\n {\n $_SESSION['authorized'] = true;\n $_SESSION['lastSessionId'] = time();\n $_SESSION['tstamp'] = time();\n $_SESSION['expires'] = time() + $this->expireTimeInMinutes * 60;\n $_SESSION['isBackendSession'] = true;\n // Renew the session id to avoid session fixation\n $this->renewSession();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": " public function duplicateTeam(Team $team, Request $request)\n {\n $newTeam = clone $team;\n $newTeam->setName($team->getName() . ' [COPY]');\n\n try {\n $this->repository->saveTeam($newTeam);\n $this->flashSuccess('action.update.success');\n\n return $this->redirectToRoute('admin_team_edit', ['id' => $newTeam->getId()]);\n } catch (\\Exception $ex) {\n $this->flashUpdateException($ex);\n }\n\n return $this->redirectToRoute('admin_team');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public static function parseAndTrimImport($str, $isHTML = false) { //\ufffdDeath from above\ufffd? \ufffd\n //echo \"1
        \"; eDebug($str);\n// global $db;\n\n $str = str_replace(\"\ufffd\", \"’\", $str);\n $str = str_replace(\"\ufffd\", \"‘\", $str);\n $str = str_replace(\"\ufffd\", \"®\", $str);\n $str = str_replace(\"\ufffd\", \"-\", $str);\n $str = str_replace(\"\ufffd\", \"—\", $str);\n $str = str_replace(\"\ufffd\", \"”\", $str);\n $str = str_replace(\"\ufffd\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\,\", \",\", $str);\n $str = str_replace('\"\"', '\"', $str); //do this no matter what...in case someone added a quote in a non HTML field\n if (!$isHTML) {\n //if HTML, then leave the single quotes alone, otheriwse replace w/ special Char\n $str = str_replace('\"', \""\", $str);\n }\n $str = str_replace(\"\ufffd\", \"¼\", $str);\n $str = str_replace(\"\ufffd\", \"½\", $str);\n $str = str_replace(\"\ufffd\", \"¾\", $str);\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n// if (DB_ENGINE=='mysqli') {\n//\t $str = @mysqli_real_escape_string($db->connection,trim(str_replace(\"\ufffd\", \"™\", $str)));\n// } elseif(DB_ENGINE=='mysql') {\n// $str = @mysql_real_escape_string(trim(str_replace(\"\ufffd\", \"™\", $str)),$db->connection);\n// } else {\n//\t $str = trim(str_replace(\"\ufffd\", \"™\", $str));\n// }\n $str = @expString::escape(trim(str_replace(\"\ufffd\", \"™\", $str)));\n //echo \"2
        \"; eDebug($str,die);\n return $str;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "function headerTestController($serverPort) {\n $args = array('Authorization' => 'foo');\n var_dump(request('localhost', $serverPort, \"test_headers.php\",\n [], ['PROXY' => 'foobar'], $args));\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-668", "cwe_name": "Exposure of Resource to Wrong Sphere", "description": "The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.", "url": "https://cwe.mitre.org/data/definitions/668.html", "label_name": "safe"} {"code": " foreach($item->attributes as $name => $value)\n if ($name !== 'id' && $name !== 'listId')\n $copy->$name = $value;\n $lineItems[] = $copy;\n }\n return $lineItems;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " foreach ($week as $dayNum => $day) {\r\n if ($dayNum == $now['mday']) {\r\n $currentweek = $weekNum;\r\n }\r\n if ($dayNum <= $endofmonth) {\r\n// $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $db->countObjects(\"eventdate\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $ed->find(\"count\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function update() {\n parent::update();\n expSession::clearAllUsersSessionCache('navigation');\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $swimlane = $this->getSwimlane();\n\n $this->response->html($this->helper->layout->project('swimlane/remove', array(\n 'project' => $project,\n 'swimlane' => $swimlane,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " $list[] = $this->getClass($obj, 'AttrTransform_');\n }\n return $this->listify($list);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function newpassword() {\n\n if ($token = $this->param('token')) {\n\n $user = $this->app->storage->findOne('cockpit/accounts', ['_reset_token' => $token]);\n\n if (!$user) {\n return false;\n }\n\n $user['md5email'] = md5($user['email']);\n\n return $this->render('cockpit:views/layouts/newpassword.php', compact('user', 'token'));\n }\n\n return false;\n\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function query_single($column, $table, $where = '1=1', $order = '')\r\n\t{\r\n\t $rs = null;\r\n if(!empty($order))\r\n $order = ' ORDER BY '.$order;\r\n\r\n try\r\n {\r\n $stm = $this->db->query('SELECT ' . $column . ' FROM ' . $table . ' WHERE ' . $where . $order . ' LIMIT 1');\r\n $this->queries_count++;\r\n $stm->setFetchMode(PDO::FETCH_NUM);\r\n $rs = $stm->fetchAll();\r\n $stm->closeCursor();\r\n unset($stm);\r\n }\r\n catch(Exception $e)\r\n {\r\n return NULL;\r\n }\r\n\r\n\t\tif(empty($rs)) \treturn NULL;\r\n\t\telse\t\t\treturn $rs[0][0];\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " static function displayname() {\n return gt(\"e-Commerce Category Manager\");\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function dol_print_error($db='',$error='')\n{\n\tglobal $conf,$langs,$argv;\n\tglobal $dolibarr_main_prod;\n\n\t$out = '';\n\t$syslog = '';\n\n\t// Si erreur intervenue avant chargement langue\n\tif (! $langs)\n\t{\n\t\trequire_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php';\n\t\t$langs = new Translate('', $conf);\n\t\t$langs->load(\"main\");\n\t}\n\t$langs->load(\"main\");\n\t$langs->load(\"errors\");\n\n\tif ($_SERVER['DOCUMENT_ROOT']) // Mode web\n\t{\n\t\t$out.=$langs->trans(\"DolibarrHasDetectedError\").\".
        \\n\";\n\t\tif (! empty($conf->global->MAIN_FEATURES_LEVEL))\n\t\t$out.=\"You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.
        \\n\";\n\t\t$out.=$langs->trans(\"InformationToHelpDiagnose\").\":
        \\n\";\n\n\t\t$out.=\"\".$langs->trans(\"Date\").\": \".dol_print_date(time(),'dayhourlog').\"
        \\n\";;\n\t\t$out.=\"\".$langs->trans(\"Dolibarr\").\": \".DOL_VERSION.\"
        \\n\";;\n\t\tif (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.=\"\".$langs->trans(\"LevelOfFeature\").\": \".$conf->global->MAIN_FEATURES_LEVEL.\"
        \\n\";;\n\t\tif (function_exists(\"phpversion\"))\n\t\t{\n\t\t\t$out.=\"\".$langs->trans(\"PHP\").\": \".phpversion().\"
        \\n\";\n\t\t\t//phpinfo(); // This is to show location of php.ini file\n\t\t}\n\t\t$out.=\"\".$langs->trans(\"Server\").\": \".$_SERVER[\"SERVER_SOFTWARE\"].\"
        \\n\";;\n\t\t$out.=\"
        \\n\";\n\t\t$out.=\"\".$langs->trans(\"RequestedUrl\").\": \".$_SERVER[\"REQUEST_URI\"].\"
        \\n\";;\n\t\t$out.=\"\".$langs->trans(\"Referer\").\": \".(isset($_SERVER[\"HTTP_REFERER\"])?$_SERVER[\"HTTP_REFERER\"]:'').\"
        \\n\";;\n\t\t$out.=\"\".$langs->trans(\"MenuManager\").\": \".$conf->top_menu.\"
        \\n\";\n\t\t$out.=\"
        \\n\";\n\t\t$syslog.=\"url=\".$_SERVER[\"REQUEST_URI\"];\n\t\t$syslog.=\", query_string=\".$_SERVER[\"QUERY_STRING\"];\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tpublic function initializeObject() {\n\t\t$this->initializeFormStateFromRequest();\n\t\t$this->initializeCurrentPageFromRequest();\n\n\t\tif (!$this->isFirstRequest()) {\n\t\t\t$this->processSubmittedFormValues();\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function updateObject($object, $table, $where=null, $identifier='id', $is_revisioned=false) {\n\n if ($is_revisioned) {\n $object->revision_id++;\n //if ($table==\"text\") eDebug($object);\n $res = $this->insertObject($object, $table);\n //if ($table==\"text\") eDebug($object,true);\n $this->trim_revisions($table, $object->$identifier, WORKFLOW_REVISION_LIMIT);\n return $res;\n }\n $sql = \"UPDATE \" . $this->prefix . \"$table SET \";\n foreach (get_object_vars($object) as $var => $val) {\n //We do not want to save any fields that start with an '_'\n //if($is_revisioned && $var=='revision_id') $val++;\n if ($var{0} != '_') {\n if (is_array($val) || is_object($val)) {\n $val = serialize($val);\n $sql .= \"`$var`='\".$val.\"',\";\n } else {\n $sql .= \"`$var`='\" . $this->escapeString($val) . \"',\";\n }\n }\n }\n $sql = substr($sql, 0, -1) . \" WHERE \";\n if ($where != null)\n $sql .= $this->injectProof($where);\n else\n $sql .= \"`\" . $identifier . \"`=\" . $object->$identifier;\n //if ($table == 'text') eDebug($sql,true);\n $res = (@mysqli_query($this->connection, $sql) != false);\n return $res;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " private function getTaskLink()\n {\n $link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));\n\n if (empty($link)) {\n throw new PageNotFoundException();\n }\n\n return $link;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " Request::setTrustedHeaderName($key, $name);\n }\n Request::setTrustedProxies(self::$globalState[0]);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " protected function getSwimlane(array $project)\n {\n $swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));\n\n if (empty($swimlane)) {\n throw new PageNotFoundException();\n }\n\n if ($swimlane['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $swimlane;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function getVerp()\n {\n return $this->do_verp;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "\tstatic function convertUTF($string) {\n\t\treturn $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));\n\t} ", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function register_routes() {\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base, array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_items' ),\n\t\t\t\t'permission_callback' => array( $this, 'get_items_permissions_check' ),\n\t\t\t\t'args' => $this->get_collection_params(),\n\t\t\t),\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::CREATABLE,\n\t\t\t\t'callback' => array( $this, 'create_item' ),\n\t\t\t\t'permission_callback' => array( $this, 'create_item_permissions_check' ),\n\t\t\t\t'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),\n\t\t\t),\n\t\t\t'schema' => array( $this, 'get_public_item_schema' ),\n\t\t) );\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\\d]+)', array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_item' ),\n\t\t\t\t'permission_callback' => array( $this, 'get_item_permissions_check' ),\n\t\t\t\t'args' => array(\n\t\t\t\t\t'context' => $this->get_context_param( array( 'default' => 'view' ) ),\n\t\t\t\t),\n\t\t\t),\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::EDITABLE,\n\t\t\t\t'callback' => array( $this, 'update_item' ),\n\t\t\t\t'permission_callback' => array( $this, 'update_item_permissions_check' ),\n\t\t\t\t'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),\n\t\t\t),\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::DELETABLE,\n\t\t\t\t'callback' => array( $this, 'delete_item' ),\n\t\t\t\t'permission_callback' => array( $this, 'delete_item_permissions_check' ),\n\t\t\t\t'args' => array(\n\t\t\t\t\t'force' => array(\n\t\t\t\t\t\t'type' => 'boolean',\n\t\t\t\t\t\t'default' => false,\n\t\t\t\t\t\t'description' => __( 'Required to be true, as terms do not support trashing.' ),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t\t'schema' => array( $this, 'get_public_item_schema' ),\n\t\t) );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " foreach($image->expTag as $tag) {\n if (isset($used_tags[$tag->id])) {\n $used_tags[$tag->id]->count++;\n } else {\n $exptag = new expTag($tag->id);\n $used_tags[$tag->id] = $exptag;\n $used_tags[$tag->id]->count = 1;\n }\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " $module_views[$key]['name'] = gt($value['name']);\n }\n\n // look for a config form for this module's current view \n// $controller->loc->mod = expModules::getControllerClassName($controller->loc->mod);\n //check to see if hcview was passed along, indicating a hard-coded module\n// if (!empty($controller->params['hcview'])) {\n// $viewname = $controller->params['hcview'];\n// } else {\n// $viewname = $db->selectValue('container', 'view', \"internal='\".serialize($controller->loc).\"'\");\n// }\n// $viewconfig = $viewname.'.config';\n// foreach ($modpaths as $path) {\n// if (file_exists($path.'/'.$viewconfig)) {\n// $fileparts = explode('_', $viewname);\n// if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts);\n// $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration');\n// $module_views[$viewname]['file'] =$path.'/'.$viewconfig;\n// }\n// }\n \n // sort the views highest to lowest by filename\n // we are reverse sorting now so our array merge\n // will overwrite property..we will run array_reverse\n // when we're finished to get them back in the right order\n krsort($common_views);\n krsort($module_views);\n\n if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig);\n $views = array_merge($common_views, $module_views);\n $views = array_reverse($views);\n\n return $views;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " protected function listify($array, $polite = false) {\n if (empty($array)) return 'None';\n $ret = '';\n $i = count($array);\n foreach ($array as $value) {\n $i--;\n $ret .= $value;\n if ($i > 0 && !($polite && $i == 1)) $ret .= ', ';\n if ($polite && $i == 1) $ret .= 'and ';\n }\n return $ret;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testExtendingClassesInstantiates()\n {\n // The non-standard port triggers a cascade of private methods which\n // should not use late static binding to access private static members.\n // If they do, this will fatal.\n $this->assertInstanceOf(\n '\\GuzzleHttp\\Tests\\Psr7\\ExtendingClassTest',\n new ExtendingClassTest('http://h:9/')\n );\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function list_process($bp,$display,$bdd){\n\t$sql = \"select name from bp where is_define = 1 and name!='\".$bp.\"' and priority = '\" . $display . \"'\";\n\t$req = $bdd->query($sql);\n\t$process = $req->fetchall();\n\n echo json_encode($process);\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public function testStartedOutside()\n {\n $storage = $this->getStorage();\n\n $this->assertFalse($storage->getSaveHandler()->isActive());\n $this->assertFalse($storage->isStarted());\n\n session_start();\n $this->assertTrue(isset($_SESSION));\n if (PHP_VERSION_ID >= 50400) {\n // this only works in PHP >= 5.4 where session_status is available\n $this->assertTrue($storage->getSaveHandler()->isActive());\n }\n // PHP session might have started, but the storage driver has not, so false is correct here\n $this->assertFalse($storage->isStarted());\n\n $key = $storage->getMetadataBag()->getStorageKey();\n $this->assertFalse(isset($_SESSION[$key]));\n $storage->start();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function mod($var)\n {\n self::load($var);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction test_username_avoids_anon_flow() {\n\t\tadd_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' );\n\n\t\t$comment_args = array(\n\t\t\t1,\n\t\t\t'administrator',\n\t\t\t'administrator',\n\t\t\tself::$post->ID,\n\t\t\tarray(\n\t\t\t\t'author' => 'WordPress',\n\t\t\t\t'author_email' => 'noreply at wordpress.org',\n\t\t\t\t'content' => 'Test Anon Comments',\n\t\t\t),\n\t\t);\n\n\t\t$result = $this->myxmlrpcserver->wp_newComment( $comment_args );\n\t\t$comment = get_comment( $result );\n\t\t$user_id = get_user_by( 'login', 'administrator' )->ID;\n\n\t\t$this->assertSame( $user_id, (int) $comment->user_id );\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": " function reparent_standalone() {\n $standalone = $this->section->find($this->params['page']);\n if ($standalone) {\n $standalone->parent = $this->params['parent'];\n $standalone->update();\n expSession::clearAllUsersSessionCache('navigation');\n expHistory::back();\n } else {\n notfoundController::handle_not_found();\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function _pLookAhead() {\n $this->current($i, $current);\n if ($current instanceof HTMLPurifier_Token_Start) $nesting = 1;\n else $nesting = 0;\n $ok = false;\n while ($this->forwardUntilEndToken($i, $current, $nesting)) {\n $result = $this->_checkNeedsP($current);\n if ($result !== null) {\n $ok = $result;\n break;\n }\n }\n return $ok;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " private function decryptContentEncryptionKey($private_key_or_secret) {\n switch ($this->header['alg']) {\n case 'RSA1_5':\n $rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_PKCS1);\n $this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);\n break;\n case 'RSA-OAEP':\n $rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_OAEP);\n $this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);\n break;\n case 'dir':\n $this->content_encryption_key = $private_key_or_secret;\n break;\n case 'A128KW':\n case 'A256KW':\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A256KW':\n throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');\n default:\n throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');\n }\n if (!$this->content_encryption_key) {\n # NOTE:\n # Not to disclose timing difference between CEK decryption error and others.\n # Mitigating Bleichenbacher Attack on PKCS#1 v1.5\n # ref.) http://inaz2.hatenablog.com/entry/2016/01/26/222303\n $this->generateContentEncryptionKey(null);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " $files[$key]->save();\n }\n \n// eDebug($files,true);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " composerRequireb0c97bd9f2eeb278d17396dd6e6a9a25($fileIdentifier, $file);\n }\n\n return $loader;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function manage() {\n expHistory::set('viewable', $this->params);\n\n $page = new expPaginator(array(\n\t\t\t'model'=>'order_status',\n\t\t\t'where'=>1,\n 'limit'=>10,\n\t\t\t'order'=>'rank',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n //'columns'=>array('Name'=>'title')\n ));\n\n\t\tassign_to_template(array(\n 'page'=>$page\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function searchByModelForm() {\n // get the search terms\n $terms = $this->params['search_string'];\n\n $sql = \"model like '%\" . $terms . \"%'\";\n\n $limit = !empty($this->config['limit']) ? $this->config['limit'] : 10;\n $page = new expPaginator(array(\n 'model' => 'product',\n 'where' => $sql,\n 'limit' => !empty($this->config['pagination_default']) ? $this->config['pagination_default'] : $limit,\n 'order' => 'title',\n 'dir' => 'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'columns' => array(\n gt('Model #') => 'model',\n gt('Product Name') => 'title',\n gt('Price') => 'base_price'\n ),\n ));\n\n assign_to_template(array(\n 'page' => $page,\n 'terms' => $terms\n ));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\tfunction handleFormSubmission(&$request, &$output, &$session) {\n\t\tif ($request->getText('action')) {\n\t\t\thandleRequestActionSubmission('admin', $this, $session);\n\t\t} else if ($request->getText('blockSubmit')) {\n\t\t\t$this->handleBlockFormSubmission($request, $output, $session);\n\t\t} else if ($request->getText('unblockSubmit')) {\n\t\t\t$this->handleUnblockFormSubmission($request, $output, $session);\n\t\t} else if ($request->getText('bypassAddUsername') || $request->getText('bypassRemoveUsername')) { //TODO: refactor to move all the subpages into their own files\n\t\t\t$bypassPage = new RequirementsBypassPage($this);\n\t\t\t$bypassPage->handleFormSubmission();\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " function showByModel() {\n global $order, $template, $db;\n\n expHistory::set('viewable', $this->params);\n $product = new product();\n $model = $product->find(\"first\", 'model=\"' . expString::escape($this->params['model']) . '\"');\n //eDebug($model);\n $product_type = new $model->product_type($model->id);\n //eDebug($product_type);\n $tpl = $product_type->getForm('show');\n if (!empty($tpl)) $template = new controllertemplate($this, $tpl);\n //eDebug($template);\n $this->grabConfig(); // grab the global config\n assign_to_template(array(\n 'config' => $this->config,\n 'product' => $product_type,\n 'last_category' => $order->lastcat\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " protected function getAction(array $project)\n {\n $action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));\n\n if (empty($action)) {\n throw new PageNotFoundException();\n }\n\n if ($action['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $action;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function event()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n $values['project_id'] = $project['id'];\n\n if (empty($values['action_name'])) {\n return $this->create();\n }\n\n return $this->response->html($this->template->render('action_creation/event', array(\n 'values' => $values,\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " static function clear(bool $debugPng = false)\n {\n foreach (self::$_cache as $file) {\n if ($file === self::$broken_image) {\n continue;\n }\n if ($debugPng) {\n print \"[clear unlink $file]\";\n }\n if (file_exists($file)) {\n unlink($file);\n }\n }\n\n foreach (self::$tempImages as $versions) {\n foreach ($versions as $file) {\n if ($file === self::$broken_image) {\n continue;\n }\n if ($debugPng) {\n print \"[unlink temp image $file]\";\n }\n if (file_exists($file)) {\n unlink($file);\n }\n }\n }\n\n self::$_cache = [];\n self::$tempImages = [];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-73", "cwe_name": "External Control of File Name or Path", "description": "The software allows user input to control or influence paths or file names that are used in filesystem operations.", "url": "https://cwe.mitre.org/data/definitions/73.html", "label_name": "safe"} {"code": " public function turn()\n {\n $this->setError('The SMTP TURN command is not implemented');\n $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);\n return false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testMoveToCreatesStreamIfOnlyAFilenameWasProvided()\n {\n $this->cleanup[] = $from = tempnam(sys_get_temp_dir(), 'copy_from');\n $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'copy_to');\n\n copy(__FILE__, $from);\n\n $uploadedFile = new UploadedFile($from, 100, UPLOAD_ERR_OK, basename($from), 'text/plain');\n $uploadedFile->moveTo($to);\n\n $this->assertFileEquals(__FILE__, $to);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tpublic function formatItem( Article $article, $pageText = null ) {\n\t\t$item = $article->mTitle;\n\n\t\tif ( $pageText !== null ) {\n\t\t\t//Include parsed/processed wiki markup content after each item before the closing tag.\n\t\t\t$item .= $pageText;\n\t\t}\n\n\t\t$item = $this->getItemStart() . $item . $this->itemEnd;\n\n\t\t$item = $this->replaceTagParameters( $item, $article );\n\n\t\treturn $item;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public function IsMail() {\n $this->Mailer = 'mail';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function edit_section() {\n global $db, $user;\n\n $parent = new section($this->params['parent']);\n if (empty($parent->id)) $parent->id = 0;\n assign_to_template(array(\n 'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),\n 'parent' => $parent,\n 'isAdministrator' => $user->isAdmin(),\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "function db_start()\n{\n global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;\n\n switch ($DatabaseType) {\n case 'mysqli':\n $connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort);\n break;\n }\n\n // Error code for both.\n if ($connection === false) {\n switch ($DatabaseType) {\n case 'mysqli':\n $errormessage = mysqli_error($connection);\n break;\n }\n db_show_error(\"\", \"\" . _couldNotConnectToDatabase . \": $DatabaseServer\", $errormessage);\n }\n return $connection;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function details($selected_events, $queue)\n{\n\tglobal $database_ged;\n\n\t// get all needed infos into variables\n\t$value_parts = explode(\":\", $selected_events);\n\t$id = $value_parts[0];\n\t$ged_type = $value_parts[1];\n\n\t$sql = \"SELECT * FROM \".$ged_type.\"_queue_\".$queue.\" WHERE id = $id\";\n\t$result = sqlrequest($database_ged, $sql);\n\t$event = mysqli_fetch_assoc($result);\n\n\t// display event's details\n\techo '';\n\t\techo '';\n\t\t\tcreateDetailRow($event, \"equipment\", \"label.host\");\n\t\t\tcreateDetailRow($event, \"host_alias\", \"label.host_alias\");\n\t\t\tcreateDetailRow($event, \"ip_address\", \"label.ip_address\");\n\t\t\tcreateDetailRow($event, \"service\", \"label.service\");\n\t\t\tcreateDetailRow($event, \"state\", \"label.state\");\n\t\t\tcreateDetailRow($event, \"description\", \"label.desc\");\n\t\t\tcreateDetailRow($event, \"occ\", \"label.occurence\");\n\t\t\tcreateDetailRow($event, \"o_sec\", \"label.o_time\");\n\t\t\tcreateDetailRow($event, \"l_sec\", \"label.l_time\");\n\t\t\tcreateDetailRow($event, \"a_sec\", \"label.a_time\");\n\t\t\tcreateDetailRow($event, \"hostgroups\", \"label.hostgroups\");\n\t\t\tcreateDetailRow($event, \"servicegroups\", \"label.servicegroups\");\n\t\t\tcreateDetailRow($event, \"src\", \"label.source\");\n\t\t\tcreateDetailRow($event, \"owner\", \"label.owner\");\n\t\t\tcreateDetailRow($event, \"comments\", \"label.comments\");\n\t\techo '';\n\techo '
        ';\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public static function is_same($p1, $p2)\n {\n if ($p1 == $p2) {\n return true;\n } else {\n return false;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function addTags($tags) {\n $result = false;\n $addedTags = array();\n\n foreach ((array) $tags as $tagName) {\n if (empty($tagName))\n continue;\n if (!$this->hasTag ($tagName)) { // check for duplicate tag\n $tag = new Tags;\n $tag->tag = Tags::normalizeTag ($tagName);\n $tag->itemId = $this->getOwner()->id;\n $tag->type = get_class($this->getOwner());\n $tag->taggedBy = Yii::app()->getSuName();\n $tag->timestamp = time();\n $tag->itemName = $this->getOwner()->name;\n\n if ($tag->save()) {\n $this->_tags[] = $tag->tag; // update tag cache\n $addedTags[] = $tagName;\n $result = true;\n } else {\n throw new CHttpException(\n 422, 'Failed saving tag due to errors: ' . json_encode($tag->errors));\n }\n }\n }\n if ($this->flowTriggersEnabled)\n X2Flow::trigger('RecordTagAddTrigger', array(\n 'model' => $this->getOwner(),\n 'tags' => $addedTags,\n ));\n\n return $result;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function versionReport() {\r\n\r\n $v = self::latestVersion();\r\n\r\n $html = \"\r\n
        \r\n Warning: Your CMS version is different with our latest version ($v).\r\n Please upgrade your system.\r\n
        \r\n \";\r\n\r\n return $html;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function _is_download_allowed( $dir, $items )\n{\n foreach ($items as $file)\n {\n if (!permissions_grant($dir, $file, \"read\"))\n return false;\n\n if (!get_show_item($dir, $file))\n return false;\n }\n\n return true;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "\tfunction edit() {\n\t if (empty($this->params['content_id'])) {\n\t flash('message',gt('An error occurred: No content id set.'));\n expHistory::back(); \n\t } \n /* The global constants can be overridden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n \n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $comment = new expComment($id);\n //FIXME here is where we might sanitize the comment before displaying/editing it\n\t\tassign_to_template(array(\n\t\t 'content_id'=>$this->params['content_id'],\n 'content_type'=>$this->params['content_type'],\n\t\t 'comment'=>$comment\n\t\t));\n\t}\t", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\tforeach($return as $index => $value) {\n\t\t\tif(! is_string($value))\n\t\t\t\t$return[$index] = $defaultvalue;\n\t\t\telseif($addslashes)\n\t\t\t\t$return[$index] = addslashes($value);\n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " foreach ($week as $dayNum => $day) {\r\n if ($dayNum == $now['mday']) {\r\n $currentweek = $weekNum;\r\n }\r\n if ($dayNum <= $endofmonth) {\r\n// $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $db->countObjects(\"eventdate\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $ed->find(\"count\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function reparent_standalone() {\n $standalone = $this->section->find($this->params['page']);\n if ($standalone) {\n $standalone->parent = $this->params['parent'];\n $standalone->update();\n expSession::clearAllUsersSessionCache('navigation');\n expHistory::back();\n } else {\n notfoundController::handle_not_found();\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $body = str_replace(array(\"\\n\"), \"
        \", $body);\r\n } else {\r\n // It's going elsewhere (doesn't like quoted-printable)\r\n $body = str_replace(array(\"\\n\"), \" -- \", $body);\r\n }\r\n $title = $items[$i]->title;\r\n\r\n $msg .= \"BEGIN:VEVENT\\n\";\r\n $msg .= $dtstart . $dtend;\r\n $msg .= \"UID:\" . $items[$i]->date_id . \"\\n\";\r\n $msg .= \"DTSTAMP:\" . date(\"Ymd\\THis\", time()) . \"Z\\n\";\r\n if ($title) {\r\n $msg .= \"SUMMARY:$title\\n\";\r\n }\r\n if ($body) {\r\n $msg .= \"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:\" . $body . \"\\n\";\r\n }\r\n //\tif($link_url) { $msg .= \"URL: $link_url\\n\";}\r\n if (!empty($this->config['usecategories'])) {\r\n if (!empty($items[$i]->expCat[0]->title)) {\r\n $msg .= \"CATEGORIES:\".$items[$i]->expCat[0]->title.\"\\n\";\r\n } else {\r\n $msg .= \"CATEGORIES:\".$this->config['uncat'].\"\\n\";\r\n }\r\n }\r\n $msg .= \"END:VEVENT\\n\";\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function rules()\n {\n\n $ignore = Rule::unique('users')->ignore($this->id ?? 0, 'id');\n\n return [\n 'first_name'=>'max:500',\n 'last_name'=>'max:500',\n 'phone'=>'max:500',\n 'email' => [\n $ignore,\n 'max:500'\n ],\n 'username' => [\n $ignore,\n 'max:500'\n ],\n ];\n\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": " public function enable()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $swimlane_id = $this->request->getIntegerParam('swimlane_id');\n\n if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {\n $this->flash->success(t('Swimlane updated successfully.'));\n } else {\n $this->flash->failure(t('Unable to update this swimlane.'));\n }\n\n $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": "\tpublic function update_groupdiscounts() {\n\t global $db;\n\t \n\t if (empty($this->params['id'])) {\n\t // look for existing discounts for the same group\n\t $existing_id = $db->selectValue('groupdiscounts', 'id', 'group_id='.$this->params['group_id']);\n\t if (!empty($existing_id)) flashAndFlow('error',gt('There is already a discount for that group.'));\n\t }\n\n $gd = new groupdiscounts();\n\t $gd->update($this->params);\n\t expHistory::back();\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " foreach ($nodes as $node) {\r\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n if ($node->active == 1) {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $ar[$node->id] = $text;\r\n foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {\r\n $ar[$id] = $text;\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " function action_default_save_licence_key() {\n $license = W3_Request::get_string('license_key');\n try {\n $old_config = new W3_Config();\n\n $this->_config->set('plugin.license_key', $license);\n $this->_config->save();\n\n w3_instance('W3_Licensing')->possible_state_change($this->_config,\n+ $old_config);\n } catch(Exception $ex){\n echo json_encode(array('result' => 'failed'));\n exit;\n }\n echo json_encode(array('result' => 'success'));\n exit;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " static function isSearchable() { return true; }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function PMA_Process_formset(FormDisplay $form_display)\n{\n if (filter_input(INPUT_GET, 'mode') == 'revert') {\n // revert erroneous fields to their default values\n $form_display->fixErrors();\n PMA_generateHeader303();\n }\n\n if (!$form_display->process(false)) {\n // handle form view and failed POST\n $form_display->display(true, true);\n return;\n }\n\n // check for form errors\n if (!$form_display->hasErrors()) {\n PMA_generateHeader303();\n return;\n }\n\n // form has errors, show warning\n $separator = PMA_URL_getArgSeparator('html');\n $page = filter_input(INPUT_GET, 'page');\n $formset = filter_input(INPUT_GET, 'formset');\n $formset = $formset ? \"{$separator}formset=$formset\" : '';\n $formId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);\n if ($formId === null && $page == 'servers') {\n // we've just added a new server, get its id\n $formId = $form_display->getConfigFile()->getServerCount();\n }\n $formId = $formId ? \"{$separator}id=$formId\" : '';\n ?>\n \n displayErrors() ?>\n \n  \n mode=edit\">\n loc->mod = expModules::getControllerClassName($controller->loc->mod);\n //check to see if hcview was passed along, indicating a hard-coded module\n// if (!empty($controller->params['hcview'])) {\n// $viewname = $controller->params['hcview'];\n// } else {\n// $viewname = $db->selectValue('container', 'view', \"internal='\".serialize($controller->loc).\"'\");\n// }\n// $viewconfig = $viewname.'.config';\n// foreach ($modpaths as $path) {\n// if (file_exists($path.'/'.$viewconfig)) {\n// $fileparts = explode('_', $viewname);\n// if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts);\n// $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration');\n// $module_views[$viewname]['file'] =$path.'/'.$viewconfig;\n// }\n// }\n \n // sort the views highest to lowest by filename\n // we are reverse sorting now so our array merge\n // will overwrite property..we will run array_reverse\n // when we're finished to get them back in the right order\n krsort($common_views);\n krsort($module_views);\n\n if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig);\n $views = array_merge($common_views, $module_views);\n $views = array_reverse($views);\n\n return $views;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " foreach ($events as $event) {\n $extevents[$date][] = $event;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function getJobIdFromWidgetConfiguration()\n {\n $sql = \"SELECT *\n FROM plugin_hudson_widget\n WHERE widget_name = '\" . db_es($this->widget_id) . \"'\n AND owner_id = \" . db_ei($this->owner_id) . \"\n AND owner_type = '\" . db_es($this->owner_type) . \"'\n AND id = \" . db_ei($this->content_id);\n\n $res = db_query($sql);\n if ($res && db_numrows($res)) {\n $data = db_fetch_array($res);\n return $data['job_id'];\n }\n\n return null;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tpublic function delete() {\n\t global $db;\n\n /* The global constants can be overriden by passing appropriate params */\n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];\n// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];\n// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];\n\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('Missing id for the comment you would like to delete'));\n\t expHistory::back();\n\t }\n\n\t // delete the comment\n $comment = new expComment($this->params['id']);\n $comment->delete();\n\n // delete the association too\n $db->delete($comment->attachable_table, 'expcomments_id='.$this->params['id']);\n\n // send the user back where they came from.\n expHistory::back();\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function params()\n {\n $project = $this->getProject();\n $values = $this->request->getValues();\n\n if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {\n $this->create();\n return;\n }\n\n $action = $this->actionManager->getAction($values['action_name']);\n $action_params = $action->getActionRequiredParameters();\n\n if (empty($action_params)) {\n $this->doCreation($project, $values + array('params' => array()));\n }\n\n $projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());\n unset($projects_list[$project['id']]);\n\n $this->response->html($this->template->render('action_creation/params', array(\n 'values' => $values,\n 'action_params' => $action_params,\n 'columns_list' => $this->columnModel->getList($project['id']),\n 'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),\n 'projects_list' => $projects_list,\n 'colors_list' => $this->colorModel->getList(),\n 'categories_list' => $this->categoryModel->getList($project['id']),\n 'links_list' => $this->linkModel->getList(0, false),\n 'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),\n 'project' => $project,\n 'available_actions' => $this->actionManager->getAvailableActions(),\n 'swimlane_list' => $this->swimlaneModel->getList($project['id']),\n 'events' => $this->actionManager->getCompatibleEvents($values['action_name']),\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " } elseif ($var == 'off' || $var == 'false' || $var == '0') {\n $var = false;\n } else {", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function theme_switch() {\n if (!expUtil::isReallyWritable(BASE.'framework/conf/config.php')) { // we can't write to the config.php file\n flash('error',gt('The file /framework/conf/config.php is NOT Writeable. You will be unable to change the theme.'));\n }\n \texpSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);\n\t expSession::set('display_theme',$this->params['theme']);\n\t $sv = isset($this->params['sv'])?$this->params['sv']:'';\n\t if (strtolower($sv)=='default') {\n\t $sv = '';\n\t }\n\t expSettings::change('THEME_STYLE_REAL',$sv);\n\t expSession::set('theme_style',$sv);\n\t expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme\n\n // $message = (MINIFY != 1) ? \"Exponent is now minifying Javascript and CSS\" : \"Exponent is no longer minifying Javascript and CSS\" ;\n // flash('message',$message);\n\t $message = gt(\"You have selected the\").\" '\".$this->params['theme'].\"' \".gt(\"theme\");\n\t if ($sv != '') {\n\t\t $message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');\n\t }\n\t flash('message',$message);\n// expSession::un_set('framework');\n expSession::set('force_less_compile', 1);\n// expTheme::removeSmartyCache();\n expSession::clearAllUsersSessionCache();\n \texpHistory::returnTo('manageable');\n }\t", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function deleteCommentAction(ProjectComment $comment)\n {\n $projectId = $comment->getProject()->getId();\n\n try {\n $this->repository->deleteComment($comment);\n } catch (\\Exception $ex) {\n $this->flashDeleteException($ex);\n }\n\n return $this->redirectToRoute('project_details', ['id' => $projectId]);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public function autocomplete() {\n return;\n global $db;\n\n $model = $this->params['model'];\n $mod = new $model();\n $srchcol = explode(\",\",$this->params['searchoncol']);\n /*for ($i=0; $i=1) $sql .= \" OR \";\n $sql .= $srchcol[$i].' LIKE \\'%'.$this->params['query'].'%\\'';\n }*/\n // $sql .= ' AND parent_id=0';\n //eDebug($sql);\n \n //$res = $mod->find('all',$sql,'id',25);\n $sql = \"select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from \".$db->prefix.\"product as p INNER JOIN \".$db->prefix.\"content_expfiles as cef ON p.id=cef.content_id INNER JOIN \".$db->prefix.\"expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') desc LIMIT 25\";\n //$res = $db->selectObjectsBySql($sql);\n //$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');\n \n $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function hasChildren($i) {\n global $sections;\n\n if (($i + 1) >= count($sections)) return false;\n return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public static function canImportData() {\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\tpublic function transferPage()\n\t\t{\n\t\t\t//FIXME Put Import code in here. \n\t\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function isBlacklisted($ip, $username)\n {\n // first remove old expired rows\n $this->clean();\n // count\n $params = array('conditions' => array(\n 'Bruteforce.ip' => $ip,\n 'Bruteforce.username' => $username),);\n $count = $this->find('count', $params);\n if ($count >= Configure::read('SecureAuth.amount')) {\n return true;\n } else {\n return false;\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " $attvalue = str_replace($quotchar, \"\", $attvalue);\n switch ($attname) {\n case 'background':\n $styledef .= \"background-image: url('$trans_image_path'); \";\n break;\n case 'bgcolor':\n $has_bgc_stl = true;\n $styledef .= \"background-color: $attvalue; \";\n break;\n case 'text':\n $has_txt_stl = true;\n $styledef .= \"color: $attvalue; \";\n break;\n }\n }\n // Outlook defines a white bgcolor and no text color. This can lead to\n // white text on a white bg with certain themes.\n if ($has_bgc_stl && !$has_txt_stl) {\n $styledef .= \"color: $text; \";\n }\n if (strlen($styledef) > 0) {\n $divattary{\"style\"} = \"\\\"$styledef\\\"\";\n }\n }\n return $divattary;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function testWithBody()\n {\n $b = Psr7\\stream_for('0');\n $r = (new Response())->withBody($b);\n $this->assertInstanceOf('Psr\\Http\\Message\\StreamInterface', $r->getBody());\n $this->assertSame('0', (string) $r->getBody());\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n $filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));\n\n $this->response->html($this->helper->layout->project('custom_filter/remove', array(\n 'project' => $project,\n 'filter' => $filter,\n 'title' => t('Remove a custom filter')\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function display_sdm_upload_meta_box($post) { // File Upload metabox\n\t$old_upload = get_post_meta($post->ID, 'sdm_upload', true);\n\t$old_value = isset($old_upload) ? $old_upload : '';\n\n\t_e('Manually enter a valid URL of the file in the text box below, or click \"Select File\" button to upload (or choose) the downloadable file.', 'simple-download-monitor');\n\techo '

        ';\n\n\techo '
        ';\n\techo '';\n\techo '
        ';\n\n\techo '
        ';\n\techo '';\n\n\techo '

        ';\n\t_e('Steps to upload a file or choose one from your media library:', 'simple-download-monitor');\n\techo '
          ';\n\techo '
        1. Hit the \"Select File\" button.
        2. ';\n\techo '
        3. Upload a new file or choose an existing one from your media library.
        4. ';\n\techo '
        5. Click the \"Insert\" button, this will populate the uploaded file\\'s URL in the above text field.
        6. ';\n\techo '
        ';\n\n\twp_nonce_field('sdm_upload_box_nonce', 'sdm_upload_box_nonce_check');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tpublic function getImageSize($path, $mime = '') {\n\t\t$size = false;\n\t\tif ($mime === '' || strtolower(substr($mime, 0, 5)) === 'image') {\n\t\t\tif ($work = $this->getWorkFile($path)) {\n\t\t\t\tif ($size = getimagesize($work)) {\n\t\t\t\t\t$size['dimensions'] = $size[0].'x'.$size[1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tis_file($work) && unlink($work);\n\t\t}\n\t\treturn $size;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function make_fb_cs_vector($size) {\n return str_repeat(\"\\xfe\", $size) . str_repeat(\"\\xfc\", $size);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "safe"} {"code": "function wp_statistics_get_site_title( $url ) {\n\n\t//Get ody Page\n\t$html = wp_statistics_get_html_page( $url );\n\tif ( $html === false ) {\n\t\treturn false;\n\t}\n\n\t//Get Page Title\n\tif ( class_exists( 'DOMDocument' ) ) {\n\t\t$dom = new DOMDocument;\n\t\t@$dom->loadHTML( $html );\n\t\t$title = '';\n\t\tif ( isset( $dom ) and $dom->getElementsByTagName( 'title' )->length > 0 ) {\n\t\t\t$title = $dom->getElementsByTagName( 'title' )->item( '0' )->nodeValue;\n\t\t}\n\t\treturn ( wp_strip_all_tags( $title ) == \"\" ? false : $title );\n\t}\n\n\treturn false;\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function registerBag(SessionBagInterface $bag)\n {\n if ($this->started) {\n throw new \\LogicException('Cannot register a bag when the session is already started.');\n }\n\n $this->bags[$bag->getName()] = $bag;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function actionGetItems(){\n $sql = \n 'SELECT id, name as value \n FROM x2_templates \n WHERE name \n LIKE :qterm \n ORDER BY name ASC';\n\n $command = Yii::app()->db->createCommand($sql);\n $qterm = $_GET['term'].'%';\n $command->bindParam(\":qterm\", $qterm, PDO::PARAM_STR);\n $result = $command->queryAll();\n echo CJSON::encode($result); exit;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " $quotedParts[] = $this->quoteIdentifier(trim($part));\n }\n\n $this->groupBy = implode(\", \", $quotedParts);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function upload() {\n\n // upload the file, but don't save the record yet...\n if ($this->params['resize'] != 'false') {\n $maxwidth = $this->params['max_width'];\n } else {\n $maxwidth = null;\n }\n $file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload\n\n if (is_object($file)) {\n $resized = !empty($file->resized) ? true : false;\n $user = new user($this->params['usrid']);\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($this->params['cat'])) {\n $expcat = new expCat($this->params['cat']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n\n // a echo so YUI Uploader is notified of the function's completion\n if ($resized) {\n echo gt('File resized and then saved');\n } else {\n echo gt('File saved');\n }\n } else {\n echo gt('File was NOT uploaded!');\n// flash('error',gt('File was not uploaded!'));\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " . PMA_Util::getIcon('b_favorite.png')\n . '';\n\n $html .= '`' . $table['db'] . '`.`' . $table['table'] . '`';\n $html .= '';\n }\n }\n } else {\n $html .= '
      • '\n . ($this->_tableType == 'recent'\n ?__('There are no recent tables.')\n :__('There are no favorite tables.'))\n . '
      • ';\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function confirm()\n {\n $project = $this->getProject();\n\n $this->response->html($this->helper->layout->project('column/remove', array(\n 'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),\n 'project' => $project,\n )));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function actionGetItems(){\n // We need to select the id both as 'id' and 'value' in order to correctly populate the association form.\n $sql = 'SELECT id, id as value FROM x2_services WHERE id LIKE :qterm ORDER BY id ASC';\n $command = Yii::app()->db->createCommand($sql);\n $qterm = $_GET['term'].'%';\n $command->bindParam(\":qterm\", $qterm, PDO::PARAM_STR);\n $result = $command->queryAll();\n echo CJSON::encode($result);\n exit;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function current_user_get_bug_filter( $p_project_id = null ) {\n\t$f_filter_string = gpc_get_string( 'filter', '' );\n\t$t_filter = array();\n\n\tif( !is_blank( $f_filter_string ) ) {\n\t\tif( is_numeric( $f_filter_string ) ) {\n\t\t\t$t_token = token_get_value( TOKEN_FILTER );\n\t\t\tif( null != $t_token ) {\n\t\t\t\t$t_filter = json_decode( $t_token, true );\n\t\t\t}\n\t\t} else {\n\t\t\t$t_filter = json_decode( $f_filter_string, true );\n\t\t}\n\t\t$t_filter = filter_ensure_valid_filter( $t_filter );\n\t} else if( !filter_is_cookie_valid() ) {\n\t\t$t_filter = filter_get_default();\n\t} else {\n\t\t$t_user_id = auth_get_current_user_id();\n\t\t$t_filter = user_get_bug_filter( $t_user_id, $p_project_id );\n\t}\n\n\treturn $t_filter;\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " public static function initializeNavigation() {\r\n $sections = section::levelTemplate(0, 0);\r\n return $sections;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tpublic function init() {\r\n\t\tglobal $geo_mashup_options, $pagenow;\r\n\r\n\t\t// Enable this interface when the option is set and we're on a destination page\r\n\t\t$enabled = is_admin() &&\r\n\t\t\t$geo_mashup_options->get( 'overall', 'located_object_name', 'user' ) == 'true' &&\r\n\t\t\tpreg_match( '/(user-edit|profile).php/', $pagenow );\r\n\t\t$enabled = apply_filters( 'geo_mashup_load_user_editor', $enabled );\r\n\r\n\t\t// If enabled, register all the interface elements\r\n\t\tif ( $enabled ) { \r\n\r\n\t\t\t// Form generation\r\n\t\t\tadd_action( 'show_user_profile', array( &$this, 'print_form' ) );\r\n\t\t\tadd_action( 'edit_user_profile', array( &$this, 'print_form' ) );\r\n\t\t\t// MAYBEDO: add location to registration page?\r\n\r\n\t\t\t// Form processing\r\n\t\t\tadd_action( 'personal_options_update', array( &$this, 'save_user'));\r\n\t\t\tadd_action( 'edit_user_profile_update', array( &$this, 'save_user'));\r\n\r\n\t\t\t$this->enqueue_form_client_items();\r\n\t\t}\r\n\t}\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\tfunction edit_vendor() {\n\t\t$vendor = new vendor();\n\n\t\tif(isset($this->params['id'])) {\n\t\t\t$vendor = $vendor->find('first', 'id =' .$this->params['id']);\n\t\t\tassign_to_template(array(\n 'vendor'=>$vendor\n ));\n\t\t}\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tprotected function init() {\n\t\t\n\t\tif (!($this->options['host'] || $this->options['socket'])\n\t\t|| !$this->options['user'] \n\t\t|| !$this->options['pass'] \n\t\t|| !$this->options['db']\n\t\t|| !$this->options['path']\n\t\t|| !$this->options['files_table']) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t\n\t\t$this->db = new mysqli($this->options['host'], $this->options['user'], $this->options['pass'], $this->options['db'], $this->options['port'], $this->options['socket']);\n\t\tif ($this->db->connect_error || mysqli_connect_error()) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t$this->db->set_charset('utf8');\n\n\t\tif ($res = $this->db->query('SHOW TABLES')) {\n\t\t\twhile ($row = $res->fetch_array()) {\n\t\t\t\tif ($row[0] == $this->options['files_table']) {\n\t\t\t\t\t$this->tbf = $this->options['files_table'];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!$this->tbf) {\n\t\t\treturn false;\n\t\t}\n\n\t\t$this->updateCache($this->options['path'], $this->_stat($this->options['path']));\n\n\t\treturn true;\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tprivate function LoadData()\n\t{\n\t\t$this->dataLoaded = true;\n\n\t\t$args = array();\n\t\t$args[] = '-s';\n\t\t$args[] = '-l';\n\t\t$args[] = $this->commitHash;\n\t\t$args[] = '--';\n\t\t$args[] = $this->path;\n\n\t\t$blamelines = explode(\"\\n\", $this->exe->Execute($this->project->GetPath(), GIT_BLAME, $args));\n\n\t\t$lastcommit = '';\n\t\tforeach ($blamelines as $line) {\n\t\t\tif (preg_match('/^([0-9a-fA-F]{40})(\\s+.+)?\\s+([0-9]+)\\)/', $line, $regs)) {\n\t\t\t\tif ($regs[1] != $lastcommit) {\n\t\t\t\t\t$this->blame[(int)($regs[3])] = $regs[1];\n\t\t\t\t\t$lastcommit = $regs[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public function testOnKernelResponseListenerRemovesItself()\n {\n $session = $this->createMock(SessionInterface::class);\n $session->expects($this->any())->method('getName')->willReturn('SESSIONNAME');\n $tokenStorage = $this->createMock(TokenStorageInterface::class);\n $dispatcher = $this->createMock(EventDispatcherInterface::class);\n\n $listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher);\n\n $request = new Request();\n $request->attributes->set('_security_firewall_run', true);\n $request->setSession($session);\n\n $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, new Response());\n\n $dispatcher->expects($this->once())\n ->method('removeListener')\n ->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);\n\n $listener->onKernelResponse($event);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " protected function getSwimlane(array $project)\n {\n $swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));\n\n if (empty($swimlane)) {\n throw new PageNotFoundException();\n }\n\n if ($swimlane['project_id'] != $project['id']) {\n throw new AccessForbiddenException();\n }\n\n return $swimlane;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public static function initializeNavigation() {\n $sections = section::levelTemplate(0, 0);\n return $sections;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private function doCreation(array $project, array $values)\n {\n $values['project_id'] = $project['id'];\n list($valid, ) = $this->actionValidator->validateCreation($values);\n\n if ($valid) {\n if ($this->actionModel->create($values) !== false) {\n $this->flash->success(t('Your automatic action have been created successfully.'));\n } else {\n $this->flash->failure(t('Unable to create your automatic action.'));\n }\n }\n\n $this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "safe"} {"code": " public function save(){\n $login_user = $this->checkLogin();\n $uid = $login_user['uid'] ;\n\n $id = I(\"id/d\");\n $member_group_id = I(\"member_group_id/d\");\n $cat_id = I(\"cat_id/d\");\n\n $teamItemMemberInfo = D(\"TeamItemMember\")->where(\" id = '$id' \")->find();\n $item_id = $teamItemMemberInfo['item_id'] ;\n $team_id = $teamItemMemberInfo['team_id'] ;\n\n\n if(!$this->checkItemManage($uid , $item_id)){\n $this->sendError(10303);\n return ;\n }\n\n $teamInfo = D(\"Team\")->where(\" id = '$team_id' and uid = '$login_user[uid]' \")->find();\n if (!$teamInfo) {\n $this->sendError(10209,\"\u65e0\u6b64\u56e2\u961f\u6216\u8005\u4f60\u65e0\u7ba1\u7406\u6b64\u56e2\u961f\u7684\u6743\u9650\");\n return ;\n } \n\n if(isset($_POST['member_group_id'])){\n $return = D(\"TeamItemMember\")->where(\" id = '$id' \")->save(array(\"member_group_id\"=>$member_group_id));\n }\n if(isset($_POST['cat_id'])){\n $return = D(\"TeamItemMember\")->where(\" id = '$id' \")->save(array(\"cat_id\"=>$cat_id));\n }\n $this->sendResult($return);\n \n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " } elseif (!empty($this->params['src'])) {\r\n if ($this->params['src'] == $loc->src) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function destroy(Appointment $appointment)\n {\n if (!auth()->user()->can(\"appointment-create\")) {\n return response(\"Access denied\", 403);\n }\n\n $deleted = $appointment->delete();\n if ($deleted) {\n return response(\"Success\");\n }\n return response(\"Error\", 503);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": " protected function getSubtask()\n {\n $subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));\n\n if (empty($subtask)) {\n throw new PageNotFoundException();\n }\n\n return $subtask;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " public function getDisplayName ($plural=true, $ofModule=true) {\n return Yii::t('users', '{user}', array(\n '{user}' => Modules::displayName($plural, 'Users'),\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " function RandomCompat_substr($binary_string, $start, $length = null)\n {\n if (!is_string($binary_string)) {\n throw new TypeError(\n 'RandomCompat_substr(): First argument should be a string'\n );\n }\n\n if (!is_int($start)) {\n throw new TypeError(\n 'RandomCompat_substr(): Second argument should be an integer'\n );\n }\n\n if ($length !== null) {\n if (!is_int($length)) {\n throw new TypeError(\n 'RandomCompat_substr(): Third argument should be an integer, or omitted'\n );\n }\n\n return substr($binary_string, $start, $length);\n }\n\n return substr($binary_string, $start);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-335", "cwe_name": "Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)", "description": "The software uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds.", "url": "https://cwe.mitre.org/data/definitions/335.html", "label_name": "safe"} {"code": " public function StartTLS() {\n $this->error = null; # to avoid confusion\n\n if(!$this->connected()) {\n $this->error = array(\"error\" => \"Called StartTLS() without being connected\");\n return false;\n }\n\n fputs($this->smtp_conn,\"STARTTLS\" . $this->CRLF);\n\n $rply = $this->get_lines();\n $code = substr($rply,0,3);\n\n if($this->do_debug >= 2) {\n $this->edebug(\"SMTP -> FROM SERVER:\" . $rply . $this->CRLF . '
        ');\n }\n\n if($code != 220) {\n $this->error =\n array(\"error\" => \"STARTTLS not accepted from server\",\n \"smtp_code\" => $code,\n \"smtp_msg\" => substr($rply,4));\n if($this->do_debug >= 1) {\n $this->edebug(\"SMTP -> ERROR: \" . $this->error[\"error\"] . \": \" . $rply . $this->CRLF . '
        ');\n }\n return false;\n }\n\n // Begin encrypted connection\n if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {\n return false;\n }\n\n return true;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function showallSubcategories() {\n// global $db;\n\n expHistory::set('viewable', $this->params);\n// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');\n $catid = expSession::get('catid');\n $parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? intval($this->params['cat']) : 0);\n $category = new storeCategory($parent);\n $categories = $category->getEcomSubcategories();\n $ancestors = $category->pathToNode();\n assign_to_template(array(\n 'categories' => $categories,\n 'ancestors' => $ancestors,\n 'category' => $category\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " function search_by_model() {\n global $db, $user;\n\n $sql = \"select DISTINCT(p.id) as id, p.title, model from \" . $db->prefix . \"product as p WHERE \";\n if (!($user->isAdmin())) $sql .= '(p.active_type=0 OR p.active_type=1) AND ';\n\n //if first character of search is a -, then we do a wild card, else from beginning\n $this->params['query'] = expString::escape($this->params['query']);\n if ($this->params['query'][0] == '-') {\n $sql .= \" p.model LIKE '%\" . $this->params['query'];\n } else {\n $sql .= \" p.model LIKE '\" . $this->params['query'];\n }\n\n $sql .= \"%' AND p.parent_id=0 GROUP BY p.id \";\n $sql .= \"order by p.model ASC LIMIT 30\";\n $res = $db->selectObjectsBySql($sql);\n //eDebug($sql);\n $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "\tpublic static function startup()\n\t{\n\t\t//Override the default expire time of token\n\t\t\\CsrfMagic\\Csrf::$expires = 259200;\n\t\t\\CsrfMagic\\Csrf::$callback = function ($tokens) {\n\t\t\tthrow new \\App\\Exceptions\\AppException('Invalid request - Response For Illegal Access', 403);\n\t\t};\n\t\t$js = 'vendor/yetiforce/csrf-magic/src/Csrf.min.js';\n\t\tif (!IS_PUBLIC_DIR) {\n\t\t\t$js = 'public_html/' . $js;\n\t\t}\n\t\t\\CsrfMagic\\Csrf::$dirSecret = __DIR__;\n\t\t\\CsrfMagic\\Csrf::$rewriteJs = $js;\n\t\t\\CsrfMagic\\Csrf::$cspToken = \\App\\Session::get('CSP_TOKEN');\n\t\t\\CsrfMagic\\Csrf::$frameBreaker = \\Config\\Security::$csrfFrameBreaker;\n\t\t\\CsrfMagic\\Csrf::$windowVerification = \\Config\\Security::$csrfFrameBreakerWindow;\n\n\t\t/*\n\t\t * if an ajax request initiated, then if php serves content with tags\n\t\t * as a response, then unnecessarily we are injecting csrf magic javascipt\n\t\t * in the response html at and using csrf_ob_handler().\n\t\t * So, to overwride above rewriting we need following config.\n\t\t */\n\t\tif (static::isAjax()) {\n\t\t\t\\CsrfMagic\\Csrf::$frameBreaker = false;\n\t\t\t\\CsrfMagic\\Csrf::$rewriteJs = null;\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "\tfunction insertServiceCategorieInDB(){\n\t\tglobal $pearDB, $centreon;\n\n\t\tif (testServiceCategorieExistence($_POST[\"sc_name\"])){\n $DBRESULT = $pearDB->query(\"INSERT INTO `service_categories` (`sc_name`, `sc_description`, `level`, `icon_id`, `sc_activate` ) \n VALUES ('\".$_POST[\"sc_name\"].\"', '\".$_POST[\"sc_description\"].\"', \".\n (isset($_POST['sc_severity_level']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_level']):\"NULL\").\", \".\n (isset($_POST['sc_severity_icon']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_icon']) : \"NULL\").\", \".\n \"'\".$_POST[\"sc_activate\"][\"sc_activate\"].\"')\");", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " function manage() {\r\n global $db, $router, $user;\r\n\r\n expHistory::set('manageable', $router->params);\r\n assign_to_template(array(\r\n 'canManageStandalones' => self::canManageStandalones(),\r\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\r\n 'user' => $user,\r\n// 'canManagePagesets' => $user->isAdmin(),\r\n// 'templates' => $db->selectObjects('section_template', 'parent=0'),\r\n ));\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function deleteItem(){\n $login_user = $this->checkLogin();\n $this->checkAdmin();\n $item_id = I(\"item_id/d\");\n $return = D(\"Item\")->soft_delete_item($item_id);\n if (!$return) {\n $this->sendError(10101);\n }else{\n $this->sendResult($return);\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " static function displayname() {\r\n return \"Events\";\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $otherPublisherName = MAX_buildName($aOtherPublisher['publisher_id'], $aOtherPublisher['name']);\n if ($aOtherPublisher['publisher_id'] != $affiliateid) {\n $form .= \"\";\n }\n }\n $form .= \"\";\n\n addPageFormTool($GLOBALS['strMoveTo'], 'iconZoneMove', $form);\n }\n\n //delete\n if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)\n || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)\n || OA_Permission::hasPermission(OA_PERM_ZONE_DELETE)) {\n $deleteConfirm = phpAds_DelConfirm($GLOBALS['strConfirmDeleteZone']);\n addPageLinkTool($GLOBALS[\"strDelete\"], MAX::constructUrl(MAX_URL_ADMIN, \"zone-delete.php?token=\" . urlencode(phpAds_SessionGetToken()) . \"&affiliateid=$affiliateid&zoneid=$zoneid&returnurl=affiliate-zones.php\"), \"iconDelete\", null, $deleteConfirm);\n }\n\n //shortcut\n addPageShortcut($GLOBALS['strBackToZones'], MAX::constructUrl(MAX_URL_ADMIN, \"affiliate-zones.php?affiliateid=$affiliateid\"), \"iconBack\");\n $entityString = _getEntityString($aEntities);\n addPageShortcut($GLOBALS['strZoneHistory'], MAX::constructUrl(MAX_URL_ADMIN, \"stats.php?entity=zone&breakdown=history&$entityString\"), 'iconStatistics');\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " protected function assetExtensions()\n {\n return [\n 'jpg',\n 'jpeg',\n 'bmp',\n 'png',\n 'webp',\n 'gif',\n 'ico',\n 'css',\n 'js',\n 'woff',\n 'woff2',\n 'svg',\n 'ttf',\n 'eot',\n 'json',\n 'md',\n 'less',\n 'sass',\n 'scss',\n 'xml'\n ];\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public function getDoctypeFromConfig($config) {\n // recommended test\n $doctype = $config->get('HTML.Doctype');\n if (!empty($doctype)) return $doctype;\n $doctype = $config->get('HTML.CustomDoctype');\n if (!empty($doctype)) return $doctype;\n // backwards-compatibility\n if ($config->get('HTML.XHTML')) {\n $doctype = 'XHTML 1.0';\n } else {\n $doctype = 'HTML 4.01';\n }\n if ($config->get('HTML.Strict')) {\n $doctype .= ' Strict';\n } else {\n $doctype .= ' Transitional';\n }\n return $doctype;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function store(CurrencyFormRequest $request)\n {\n /** @var User $user */\n $user = auth()->user();\n $data = $request->getCurrencyData();\n if (!$this->userRepository->hasRole($user, 'owner')) {\n\n Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');\n Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);\n\n return redirect($this->getPreviousUri('currencies.create.uri'));\n\n }\n\n $data['enabled'] = true;\n try {\n $currency = $this->repository->store($data);\n } catch (FireflyException $e) {\n Log::error($e->getMessage());\n Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);\n $request->session()->flash('error', (string) trans('firefly.could_not_store_currency'));\n $currency = null;\n }\n $redirect = redirect($this->getPreviousUri('currencies.create.uri'));\n\n if (null !== $currency) {\n $request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));\n Log::channel('audit')->info('Created (POST) currency.', $data);\n if (1 === (int) $request->get('create_another')) {\n\n $request->session()->put('currencies.create.fromStore', true);\n\n $redirect = redirect(route('currencies.create'))->withInput();\n\n }\n }\n\n return $redirect;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " static function displayname() {\n return \"Events\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public function actionView($id){\n $model = $this->loadModel($id);\n if (!$this->checkPermissions ($model, 'view')) $this->denied ();\n\n // add media object to user's recent item list\n User::addRecentItem('m', $id, Yii::app()->user->getId()); \n\n $this->render('view', array(\n 'model' => $model,\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public static function hasChildren($i) {\n global $sections;\n\n if (($i + 1) >= count($sections)) return false;\n return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public static function error ($vars=\"\") {\n if( isset($vars) && $vars != \"\" ) {\n include(GX_PATH.'/inc/lib/Control/Error/'.$vars.'.control.php');\n }else{\n include(GX_PATH.'/inc/lib/Control/Error/404.control.php');\n }\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function showModal($params) {\n\n if (!isset($params['argument']) || empty($params['argument'])) {\n return array(\n 'processed' => true,\n 'process_status' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chatcommand', 'Please provide modal URL!')\n );\n }\n\n $paramsURL = explode(' ',$params['argument']);\n $URL = array_shift($paramsURL);\n\n if (is_numeric($URL)) {\n $URL = (erLhcoreClassSystem::$httpsMode == true ? 'https:' : 'http:') . '//' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . erLhcoreClassDesign::baseurldirect('form/formwidget') . '/' . $URL;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-116", "cwe_name": "Improper Encoding or Escaping of Output", "description": "The software prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.", "url": "https://cwe.mitre.org/data/definitions/116.html", "label_name": "vulnerable"} {"code": " public static function addViews($id)\n {\n $botlist = self::botlist();\n $nom = 0;\n foreach ($botlist as $bot) {\n if (preg_match(\"/{$bot}/\", $_SERVER['HTTP_USER_AGENT'])) {\n $nom = 1 + $nom;\n } else {\n $nom = 0;\n }\n }\n if ($nom == 0) {\n # code...\n $sql = \"UPDATE `posts` SET `views` = `views`+1 WHERE `id` = '{$id}' LIMIT 1\";\n $q = Db::query($sql);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction manage_vendors () {\n\t expHistory::set('viewable', $this->params);\n\t\t$vendor = new vendor();\n\t\t\n\t\t$vendors = $vendor->find('all');\n\t\tassign_to_template(array(\n 'vendors'=>$vendors\n ));\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function read($sessionId)\n {\n $dbData = $this->getCollection()->findOne(array(\n $this->options['id_field'] => $sessionId,\n $this->options['expiry_field'] => array('$gte' => $this->createDateTime()),\n ));\n\n if (null === $dbData) {\n return '';\n }\n\n if ($dbData[$this->options['data_field']] instanceof \\MongoDB\\BSON\\Binary) {\n return $dbData[$this->options['data_field']]->getData();\n }\n\n return $dbData[$this->options['data_field']]->bin;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function delete() {\n global $db, $history;\n \n /* The global constants can be overriden by passing appropriate params */ \n //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet\n $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];\n $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];\n $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];\n $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];\n \n if (empty($this->params['id'])) {\n flash('error', gt('Missing id for the comment you would like to delete'));\n $lastUrl = expHistory::getLast('editable');\n }\n \n // delete the note\n $simplenote = new expSimpleNote($this->params['id']);\n $rows = $simplenote->delete();\n \n // delete the assocication too\n $db->delete($simplenote->attachable_table, 'expsimplenote_id='.$this->params['id']); \n \n // send the user back where they came from.\n $lastUrl = expHistory::getLast('editable');\n if (!empty($this->params['tab']))\n {\n $lastUrl .= \"#\".$this->params['tab'];\n }\n redirect_to($lastUrl);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public function testGetEventsPublicProfile(){\n TestingAuxLib::loadX2NonWebUser ();\n TestingAuxLib::suLogin ('testuser');\n\n Yii::app()->settings->historyPrivacy = null;\n $lastEventId=0;\n $lastTimestamp=0;\n $myProfile = Profile::model()->findByAttributes(array('username' => 'testuser2'));\n $events=Events::getEvents(\n $lastEventId,$lastTimestamp,null,$myProfile, false);\n $this->assertEquals (\n array_map (\n function ($event) { return $event->id; }, \n Events::model ()->findAllByAttributes (array (\n 'user' => 'testuser2',\n 'visibility' => 1 \n ))\n ),\n array_map (function ($event) { return $event->id; }, $events['events']));\n\n TestingAuxLib::restoreX2WebUser ();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function process_subsections($parent_section, $subtpl) {\r\n global $db, $router;\r\n\r\n $section = new stdClass();\r\n $section->parent = $parent_section->id;\r\n $section->name = $subtpl->name;\r\n $section->sef_name = $router->encode($section->name);\r\n $section->subtheme = $subtpl->subtheme;\r\n $section->active = $subtpl->active;\r\n $section->public = $subtpl->public;\r\n $section->rank = $subtpl->rank;\r\n $section->page_title = $subtpl->page_title;\r\n $section->keywords = $subtpl->keywords;\r\n $section->description = $subtpl->description;\r\n $section->id = $db->insertObject($section, 'section');\r\n self::process_section($section, $subtpl);\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $list[] = \"$name = \" . $this->getClass($obj, 'AttrDef_') . '';\n }\n return $this->listify($list);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function __invoke(Request $request)\n {\n $this->authorize('manage modules');\n\n $response = ModuleInstaller::upload($request);\n\n return response()->json($response);\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public static function makeConfig ($file) {\n $config = \"getMessage();\n }\n \n return $config;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " private function runCallback() {\n foreach ($this->records as &$record) {\n if (isset($record->ref_type)) {\n $refType = $record->ref_type;\n if (class_exists($record->ref_type)) {\n $type = new $refType();\n $classinfo = new ReflectionClass($type);\n if ($classinfo->hasMethod('paginationCallback')) {\n $item = new $type($record->original_id);\n $item->paginationCallback($record);\n }\n }\n }\n } \n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " function import() {\n $pullable_modules = expModules::listInstalledControllers($this->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));\n\n assign_to_template(array(\n 'modules' => $modules,\n ));\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function getAllowedElements($config) {\n $this->init($config);\n return $this->fake_elements;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tfunction RemoveXSSchars(&$val)\n\t{\n\t\tstatic $patterns = NULL;\n\t\tstatic $replacements = NULL;\n\t\t$val_before = $val;\n\t\t$found = true;\n\n\t\tif ( $patterns == NULL ) {\n\t\t\t$patterns = array();\n\t\t\t$replacements = array();\n\n\t\t\t// remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are\n\t\t\t// allowed this prevents some character re-spacing such as \n\t\t\t// note that you have to handle splits with \\n, \\r, and \\t later since they\n\t\t\t// *are* allowed in some inputs\n\t\t\t$patterns[] = '/([\\x00-\\x08\\x0b-\\x0c\\x0e-\\x19])/';\n\t\t\t$replacements[] = '';\n\n\t\t\t// straight replacements, the user should never need these since they're\n\t\t\t// normal characters this prevents like\n\t\t\t// \n\t\t\t// Calculate the search and replace patterns only once\n\t\t\t$search = 'abcdefghijklmnopqrstuvwxyz';\n\t\t\t$search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\t\t\t$search .= '1234567890!@#$%^&*()';\n\t\t\t$search .= '~`\";:?+/={}[]-_|\\'\\\\';\n\t\t\tfor ($i = 0, $istrlen_search = strlen($search); $i < $istrlen_search; $i++) {\n\t\t\t\t// ;? matches the ;, which is optional\n\t\t\t\t// 0{0,8} matches any padded zeros,\n\t\t\t\t// which are optional and go up to 8 chars\n\t\t\t\t// @ @ search for the hex values\n\t\t\t\t$patterns[] = '/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i';\n\t\t\t\t$replacements[] = $search[$i];\n\t\t\t\t// @ @ 0{0,8} matches '0' zero to eight times\n\t\t\t\t// with a ;\n\t\t\t\t$patterns[] = '/(�{0,8}'.ord($search[$i]).';?)/';\n\t\t\t\t$replacements[] = $search[$i];\n\t\t\t}\n\t\t}\n\t\t$val = preg_replace($patterns, $replacements, $val);\n\t\tif ($val_before == $val) {\n\t\t\t// no replacements were made, so exit the loop\n\t\t\t$found = false;\n\t\t}\n\t\treturn $found;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tpublic function remove_placeholder_escape( $query ) {\n\t\treturn str_replace( $this->placeholder_escape(), '%', $query );\n\t}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " static function author() {\n return \"Dave Leffler\";\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function checkHTTP($link, $get_body = false)\n {\n if (! function_exists('curl_init')) {\n return null;\n }\n $handle = curl_init($link);\n if ($handle === false) {\n return null;\n }\n PMA_Util::configureCurl($handle);\n curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);\n curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);\n curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);\n curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);\n curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);\n curl_setopt($handle, CURLOPT_TIMEOUT, 5);\n curl_setopt($handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);\n if (! defined('TESTSUITE')) {\n session_write_close();\n }\n $data = @curl_exec($handle);\n if (! defined('TESTSUITE')) {\n ini_set('session.use_only_cookies', '0');\n ini_set('session.use_cookies', '0');\n ini_set('session.use_trans_sid', '0');\n ini_set('session.cache_limiter', 'nocache');\n session_start();\n }\n if ($data === false) {\n return null;\n }\n $http_status = curl_getinfo($handle, CURLINFO_HTTP_CODE);\n\n if ($http_status == 200) {\n return $get_body ? $data : true;\n }\n\n if ($http_status == 404) {\n return false;\n }\n return null;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function singleQuoteReplace($param1 = false, $param2 = false, $param3)\n{\n return str_replace(\"'\", \"''\", str_replace(\"\\'\", \"'\", $param3));\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public function nonOkErrorStatus()\n {\n return [\n 'UPLOAD_ERR_INI_SIZE' => [ UPLOAD_ERR_INI_SIZE ],\n 'UPLOAD_ERR_FORM_SIZE' => [ UPLOAD_ERR_FORM_SIZE ],\n 'UPLOAD_ERR_PARTIAL' => [ UPLOAD_ERR_PARTIAL ],\n 'UPLOAD_ERR_NO_FILE' => [ UPLOAD_ERR_NO_FILE ],\n 'UPLOAD_ERR_NO_TMP_DIR' => [ UPLOAD_ERR_NO_TMP_DIR ],\n 'UPLOAD_ERR_CANT_WRITE' => [ UPLOAD_ERR_CANT_WRITE ],\n 'UPLOAD_ERR_EXTENSION' => [ UPLOAD_ERR_EXTENSION ],\n ];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " protected function fixupImportedAttributes($modelName, X2Model &$model) {\n if ($modelName === 'Contacts' || $modelName === 'X2Leads')\n $this->fixupImportedContactName ($model);\n\n if ($modelName === 'Actions' && isset($model->associationType))\n $this->reconstructImportedActionAssoc($model);\n\n // Set visibility to Public by default if unset by import\n if ($model->hasAttribute('visibility') && is_null($model->visibility))\n $model->visibility = 1;\n // If date fields were provided, do not create new values for them\n if (!empty($model->createDate) || !empty($model->lastUpdated) ||\n !empty($model->lastActivity)) {\n $now = time();\n if (empty($model->createDate))\n $model->createDate = $now;\n if (empty($model->lastUpdated))\n $model->lastUpdated = $now;\n if ($model->hasAttribute('lastActivity') && empty($model->lastActivity))\n $model->lastActivity = $now;\n }\n if($_SESSION['leadRouting'] == 1){\n $assignee = $this->getNextAssignee();\n if($assignee == \"Anyone\")\n $assignee = \"\";\n $model->assignedTo = $assignee;\n }\n // Loop through our override and set the manual data\n foreach($_SESSION['override'] as $attr => $val){\n $model->$attr = $val;\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function close()\n {\n $this->setError('');\n $this->server_caps = null;\n $this->helo_rply = null;\n if (is_resource($this->smtp_conn)) {\n // close the connection and cleanup\n fclose($this->smtp_conn);\n $this->smtp_conn = null; //Makes for cleaner serialization\n $this->edebug('Connection: closed', self::DEBUG_CONNECTION);\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " } elseif (!empty($this->params['src'])) {\n if ($this->params['src'] == $loc->src) {\n $this->config = $config->config;\n break;\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function onRefresh()\n {\n $value = post($this->getFieldName());\n $previewHtml = $this->safe\n ? Markdown::parseSafe($value)\n : Markdown::parse($value);\n\n if ($this->shouldCleanHtml()) {\n $previewHtml = Html::clean($previewHtml);\n }\n\n return [\n 'preview' => $previewHtml\n ];\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public static function delete($id)\n {\n return Categories::delete($id);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public function setup($config) {\n $a = $this->addElement(\n 'a', 'Inline', 'Inline', 'Common',\n array(\n // 'accesskey' => 'Character',\n // 'charset' => 'Charset',\n 'href' => 'URI',\n // 'hreflang' => 'LanguageCode',\n 'rel' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'),\n 'rev' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rev'),\n // 'tabindex' => 'Number',\n // 'type' => 'ContentType',\n )\n );\n $a->formatting = true;\n $a->excludes = array('a' => true);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public function testHostIsNormalizedToLowercase()\n {\n $uri = new Uri('//eXaMpLe.CoM');\n\n $this->assertSame('example.com', $uri->getHost());\n $this->assertSame('//example.com', (string) $uri);\n\n $uri = (new Uri())->withHost('eXaMpLe.CoM');\n\n $this->assertSame('example.com', $uri->getHost());\n $this->assertSame('//example.com', (string) $uri);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function draw_cdef_preview($cdef_id) {\n\t?>\n\t\n\t\t\n\t\t\t
        cdef=
        \n\t\t\n\t\n\tcontainer = $container;\n $container->setType('ctBanner');\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public function update() {\n\n //populate the alt tag field if the user didn't\n if (empty($this->params['alt'])) $this->params['alt'] = $this->params['title'];\n \n // call expController update to save the image\n parent::update();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public function remove()\n {\n $this->checkCSRFParam();\n $project = $this->getProject();\n $category = $this->getCategory();\n\n if ($this->categoryModel->remove($category['id'])) {\n $this->flash->success(t('Category removed successfully.'));\n } else {\n $this->flash->failure(t('Unable to remove this category.'));\n }\n\n $this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-639", "cwe_name": "Authorization Bypass Through User-Controlled Key", "description": "The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.", "url": "https://cwe.mitre.org/data/definitions/639.html", "label_name": "vulnerable"} {"code": " public function resetRemoteAuthKey($id)\n {\n if (!$this->request->is('post')) {\n throw new MethodNotAllowedException(__('This endpoint expects POST requests.'));\n }\n $result = $this->Server->resetRemoteAuthkey($id);\n if ($result !== true) {\n if (!$this->_isRest()) {\n $this->Flash->error($result);\n $this->redirect(array('action' => 'index'));\n } else {\n return $this->RestResponse->saveFailResponse('Servers', 'resetRemoteAuthKey', $id, $message, $this->response->type());\n }\n } else {\n $message = __('API key updated.');\n if (!$this->_isRest()) {\n $this->Flash->success($message);\n $this->redirect(array('action' => 'index'));\n } else {\n return $this->RestResponse->saveSuccessResponse('Servers', 'resetRemoteAuthKey', $message, $this->response->type());\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " public function testRaisesExceptionOnInvalidStreamOrFile($streamOrFile)\n {\n $this->setExpectedException('InvalidArgumentException');\n\n new UploadedFile($streamOrFile, 0, UPLOAD_ERR_OK);\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfunction token($str) {\n\t\t$fw=$this->fw;\n\t\t$str=trim(preg_replace('/\\{\\{(.+?)\\}\\}/s',trim('\\1'),\n\t\t\t$fw->compile($str)));\n\t\tif (preg_match('/^(.+)(?split(trim($parts[2],\"\\xC2\\xA0\")) as $func)\n\t\t\t\t$str=((empty($this->filter[$cmd=$func]) &&\n\t\t\t\t\tfunction_exists($cmd)) ||\n\t\t\t\t\tis_string($cmd=$this->filter($func)))?\n\t\t\t\t\t$cmd.'('.$str.')':\n\t\t\t\t\t'Base::instance()->'.\n\t\t\t\t\t\t'call($this->filter(\\''.$func.'\\'),['.$str.'])';\n\t\t}\n\t\treturn $str;\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " $logo = '\";\n } else {\n $logo = '';\n }\n\n return $logo;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function XMLRPCtest($string) {\n\t$string = processInputData($string, ARG_STRING);\n\treturn array('status' => 'success',\n\t 'message' => 'RPC call worked successfully',\n\t 'string' => $string);\n}", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " public function session() {\n // Test if logged in, log in if not, log in.\n try {\n $this->assertElementPresent('css=ul#user-menu');\n } catch (PHPUnit_Framework_AssertionFailedError $e) {\n /* If this isn't the first time we've logged in, we have a problem;\n * the user should have been logged in throughout the life of the\n * test case class. Append t\n */\n if (!$this->firstLogin)\n array_push($this->verificationErrors, $e->toString());\n $this->firstLogin = false;\n $this->login();\n return 0;\n }\n try {\n $this->assertCorrectUser();\n } catch (PHPUnit_Framework_AssertionFailedError $e) {\n // The browser is logged in but not as the correct user.\n $this->logout();\n $this->login();\n $this->firstLogin = false;\n return 0;\n }\n // Indicator of whether the session was already initialized properly\n return 1;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " foreach ($nodes as $node) {\r\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n if ($node->active == 1) {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $ar[$node->id] = $text;\r\n foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {\r\n $ar[$id] = $text;\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\tfunction show_vendor () {\n\t\t$vendor = new vendor();\n\t\t\n\t\tif(isset($this->params['id'])) {\n\t\t\t$vendor = $vendor->find('first', 'id =' .$this->params['id']);\n\t\t\t$vendor_title = $vendor->title;\n\t\t\t$state = new geoRegion($vendor->state);\n\t\t\t$vendor->state = $state->name;\n\t\t\t//Removed unnecessary fields\n\t\t\tunset(\n $vendor->title,\n $vendor->table,\n $vendor->tablename,\n $vendor->classname,\n $vendor->identifier\n );\n\t\t\n\t\t\tassign_to_template(array(\n 'vendor_title' => $vendor_title,\n 'vendor'=>$vendor\n ));\n\t\t}\n\t}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public static function autoload($class) {\n $file = HTMLPurifier_Bootstrap::getPath($class);\n if (!$file) return false;\n // Technically speaking, it should be ok and more efficient to\n // just do 'require', but Antonio Parraga reports that with\n // Zend extensions such as Zend debugger and APC, this invariant\n // may be broken. Since we have efficient alternatives, pay\n // the cost here and avoid the bug.\n require_once HTMLPURIFIER_PREFIX . '/' . $file;\n return true;\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $count += $db->dropTable($basename);\n }\n \n flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');\n expHistory::back();\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " public static function getParent($parent='', $menuid = ''){\n if(isset($menuid)){\n $where = \" AND `menuid` = '{$menuid}'\";\n }else{\n $where = '';\n }\n $sql = sprintf(\"SELECT * FROM `menus` WHERE `parent` = '%s' %s\", $parent, $where);\n $menu = Db::result($sql);\n return $menu;\n }", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function updateBasicSettings(PDFStructure &$structure) {\n\t// set headline\n\tif (isset($_POST['headline'])) {\n\t\t$structure->setTitle(str_replace('<', '', str_replace('>', '', $_POST['headline'])));\n\t}\n\t// set logo\n\tif (isset($_POST['logoFile'])) {\n\t\t$structure->setLogo($_POST['logoFile']);\n\t}\n\t// set folding marks\n\tif (isset($_POST['foldingmarks'])) {\n\t\t$structure->setFoldingMarks($_POST['foldingmarks']);\n\t}\n}", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public static function isPublic($s) {\r\n if ($s == null) {\r\n return false;\r\n }\r\n while ($s->public && $s->parent > 0) {\r\n $s = new section($s->parent);\r\n }\r\n $lineage = (($s->public) ? 1 : 0);\r\n return $lineage;\r\n }\r", "label": 0, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $regx = str_replace('/', '\\/', $k);\n // echo $regx.\"\\n\";\n if (preg_match('/^'.$regx.'$/Usi', $uri, $m)) {\n $result = [$v, $m];\n\n return $result;\n }\n }\n }", "label": 1, "programming_language": "PHP", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "Sa.dy?Sa.dy:0);Ia.insert(Ja)}ta.push(Ia);mxUtils.remove(qa.invert?ia:Ka,Aa)}}}});oa(ra,ra,ka);if(null!=x[ra.id])for(Ga=0;GamxUtils.indexOf(q,ia)};this.executeLayout(function(){ua.execute(A.getDefaultParent());", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "da)b.sidebar.hideTooltip();else{var pa=function(na){Ea&&b.sidebar.currentElt==da&&ma(na,mxEvent.getClientX(la),mxEvent.getClientY(la));Ea=!1;ca.src=\"/images/icon-search.svg\"};b.sidebar.hideTooltip();b.sidebar.currentElt=da;Ea=!0;ca.src=\"/images/aui-wait.gif\";ha.isExt?g(ha,pa,function(){A(mxResources.get(\"cantLoadPrev\"));Ea=!1;ca.src=\"/images/icon-search.svg\"}):ia(ha.url,pa)}}function t(ha,da,ca){if(null!=D){for(var la=D.className.split(\" \"),ia=0;ia=na.getStatus()?la(na.getText(),pa):ia()})):la(b.emptyDiagramXml,pa)},la=function(pa,na){y||b.hideDialog(!0);e(pa,na,ra,da)},ia=function(){A(mxResources.get(\"cannotLoad\"));", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "DriveFile&&c.isEditable()||c.constructor==DropboxFile)};EditorUi.prototype.getServiceName=function(){return\"draw.io\"};EditorUi.prototype.addRemoteServiceSecurityCheck=function(c){c.setRequestHeader(\"Content-Language\",\"da, mi, en, de-DE\")};EditorUi.prototype.loadUrl=function(c,e,g,k,m,q,v,x){EditorUi.logEvent(\"SHOULD NOT BE CALLED: loadUrl\");return this.editor.loadUrl(c,e,g,k,m,q,v,x)};EditorUi.prototype.loadFonts=function(c){EditorUi.logEvent(\"SHOULD NOT BE CALLED: loadFonts\");return this.editor.loadFonts(c)};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " this.complete = function (result) {\n if (resultsBuffer.length) {\n socket.emit('result', resultsBuffer)\n resultsBuffer = []\n }\n\n socket.emit('complete', result || {})\n if (this.config.clearContext) {\n navigateContextTo('about:blank')\n } else {\n self.updater.updateTestStatus('complete')\n }\n if (returnUrl) {\n if (!/^https?:\\/\\//.test(returnUrl)) {\n throw new Error(\n 'Security: Navigation to '.concat(\n returnUrl,\n ' was blocked to prevent malicious exploits.'\n )\n )\n }\n location.href = returnUrl\n }\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": "function(K){var F=x.length;if(1===F%2||F>=f){var H=0,S=0,V,M=0;for(V=K;Vd.length;H||v.push.apply(v,d);d=[];v.push(null);m.push(c);c=null;(H||l)&&this.stopDrawing();l&&2<=F&&this.startDrawing();mxEvent.consume(J)}}),L=new mxCell;L.edge=!0;var C=function(){var J=b.getCurrentCellStyle(L);J=mxUtils.getValue(b.currentVertexStyle,mxConstants.STYLE_STROKECOLOR,mxUtils.getValue(J,mxConstants.STYLE_STROKECOLOR,\"#000\"));\"default\"==", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " _mdBlockQuote(str) {\n return str.replace(/^>\\s(.*)/, (all, quote) => '
        ' + quote + '
        ');\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " Modal.prototype.enforceFocus = function () {\n $(document)\n .off('focusin.bs.modal') // guard against infinite focus loop\n .on('focusin.bs.modal', $.proxy(function (e) {\n if (document !== e.target &&\n this.$element[0] !== e.target &&\n !this.$element.has(e.target).length) {\n this.$element.trigger('focus')\n }\n }, this))\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function _c(a,b,c) {var d={mm:\"munutenn\",MM:\"miz\",dd:\"devezh\"};return a+\" \"+cd(d[c],a)}function ad(a) {switch(bd(a)) {case 1:case 3:case 4:case 5:case 9:return a+\" bloaz\";default:return a+\" vloaz\"}}function bd(a) {return a>9?bd(a%10):a}function cd(a,b) {return 2===b?dd(a):a}function dd(a) {var b={m:\"v\",b:\"v\",d:\"z\"};return void 0===b[a.charAt(0)]?a:b[a.charAt(0)]+a.substring(1)}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function addToolTipToTableCell(value) {\n if (value) {\n return `${value}`\n }\n return ''\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": "function ElementAttributes(source){\n\t\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-436", "cwe_name": "Interpretation Conflict", "description": "Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.", "url": "https://cwe.mitre.org/data/definitions/436.html", "label_name": "vulnerable"} {"code": "var F=this.editorUi,G=F.editor.graph;if(G.isEnabled()&&\"1\"==urlParams.sketch){var N=this.createOption(mxResources.get(\"sketch\"),function(){return Editor.sketchMode},function(J,E){F.setSketchMode(!Editor.sketchMode);null!=E&&mxEvent.isShiftDown(E)||G.updateCellStyles({sketch:J?\"1\":null},G.getVerticesAndEdges())},{install:function(J){this.listener=function(){J(Editor.sketchMode)};F.addListener(\"sketchModeChanged\",this.listener)},destroy:function(){F.removeListener(this.listener)}});B.appendChild(N)}return B};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "Na.prototype.defaultWidth=4;Na.prototype.isOpenEnded=function(){return!0};Na.prototype.getEdgeWidth=function(){return mxUtils.getNumber(this.style,\"width\",this.defaultWidth)+Math.max(0,this.strokewidth-1)};Na.prototype.isArrowRounded=function(){return this.isRounded};mxCellRenderer.registerShape(\"link\",Na);mxUtils.extend(Ca,mxArrowConnector);Ca.prototype.defaultWidth=10;Ca.prototype.defaultArrowWidth=20;Ca.prototype.getStartArrowWidth=function(){return this.getEdgeWidth()+mxUtils.getNumber(this.style,\n\"startWidth\",this.defaultArrowWidth)};Ca.prototype.getEndArrowWidth=function(){return this.getEdgeWidth()+mxUtils.getNumber(this.style,\"endWidth\",this.defaultArrowWidth)};Ca.prototype.getEdgeWidth=function(){return mxUtils.getNumber(this.style,\"width\",this.defaultWidth)+Math.max(0,this.strokewidth-1)};mxCellRenderer.registerShape(\"flexArrow\",Ca);mxUtils.extend(Ra,mxActor);Ra.prototype.size=30;Ra.prototype.isRoundable=function(){return!0};Ra.prototype.redrawPath=function(c,l,x,p,v){l=Math.min(v,parseFloat(mxUtils.getValue(this.style,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " PMA_ajaxShowMessage($('
        ',{'class':'error','html':PMA_messages.strRequestFailed+' ( '+escapeHtml(AJAX.xhr.statusText)+' )'}));\n AJAX.active = false;\n AJAX.xhr = null;\n }\n }\n });", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';function m(a) {throw a;}var q=void 0,u,aa=this;function v(a,b) {var c=a.split(\".\"),d=aa;!(c[0]in d)&&d.execScript&&d.execScript(\"var \"+c[0]);for(var f;c.length&&(f=c.shift());)!c.length&&b!==q?d[f]=b:d=d[f]?d[f]:d[f]={}};var w=\"undefined\"!==typeof Uint8Array&&\"undefined\"!==typeof Uint16Array&&\"undefined\"!==typeof Uint32Array&&\"undefined\"!==typeof DataView;new (w?Uint8Array:Array)(256);var x;for(x=0;256>x;++x)for(var y=x,ba=7,y=y>>>1;y;y>>>=1)--ba;var z=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\"1\"==urlParams.embed&&(d.actions.get(\"save\").funct=function(n){u.isEditing()&&u.stopEditing();var y=\"0\"!=urlParams.pages||null!=d.pages&&1mxUtils.indexOf(d,m)&&null!=urlParams[m]&&(f+=g+m+\"=\"+urlParams[m],g=\"&\")}else f=window.location.search;return f};EditorUi.prototype.getUrl=function(d){d=null!=d?d:window.location.pathname;var f=0mxUtils.indexOf(g,m)&&(d=0==f?d+\"?\":d+\"&\",null!=urlParams[m]&&(d+=m+\"=\"+urlParams[m],f++))}return d};EditorUi.prototype.showLinkDialog=function(d,f,g,m,q){d=new LinkDialog(this,d,f,g,!0,m,q);this.showDialog(d.container,560,130,!0,!0);d.init()};EditorUi.prototype.getServiceCount=function(d){var f=1;null==this.drive&&\"function\"!==typeof window.DriveClient||f++;null==this.dropbox&&\"function\"!==typeof window.DropboxClient||f++;null==this.oneDrive&&\"function\"!==typeof window.OneDriveClient||", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " $scope.removeAllNodes = function(foreignSource) {\n bootbox.confirm('Are you sure you want to remove all the nodes from ' + foreignSource + '?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.removeAllNodesFromRequisition(foreignSource).then(\n function() { // success\n growl.success('All the nodes from ' + foreignSource + ' have been removed, and the requisition has been synchronized.');\n var req = $scope.requisitionsData.getRequisition(foreignSource);\n req.reset();\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " main.subscribeObjects = function (patterns) {\n if (!patterns) return;\n if (typeof patterns === 'object') {\n for (let s = 0; s < patterns.length; s++) {\n main.subscribesObjects[patterns[s]] = main.subscribesObjects[patterns[s]] || 0;\n main.subscribesObjects[patterns[s]]++;\n if (main.subscribesObjects[patterns[s]] === 1) {\n main.socket.emit('subscribeObjects', patterns[s]);\n }\n }\n } else {\n main.subscribesObjects[patterns] = main.subscribesObjects[patterns] || 0;\n main.subscribesObjects[patterns]++;\n if (main.subscribesObjects[patterns] === 1) {\n main.socket.emit('subscribeObjects', patterns);\n }\n }\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "\"bVisible\").length}function aa(a,b){var c=[];h.map(a.aoColumns,function(a,e){a[b]&&c.push(e)});return c}function Ia(a){var b=a.aoColumns,c=a.aoData,d=m.ext.type.detect,e,f,g,j,i,h,l,q,u;e=0;for(f=b.length;e\");\"length\"in i||(i=[i]);for(var c=0;c>1,d[l]=r?v.slice(0,j).join(\" \"):v.slice(0,j),d.insertAdjacentHTML(\"beforeend\",s),d.offsetHeight>t?m=r?j-1:j-2:y=j;d[l]=r?v.slice(0,m).join(\" \"):v.slice(0,m),d.insertAdjacentHTML(\"beforeend\",s);var x=r?\" \".concat(v.slice(m).join(\" \")):v.slice(m),w=document.createTextNode(x),H=document.createElement(\"span\");H.classList.add(a),H.style.display=\"none\",H.appendChild(w),d.insertAdjacentElement(\"beforeend\",H),h.height=g,h.maxHeight=p}}}}}(this,e,t),this})}});", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "h[t.getName()],i=0,j=c.getChildren(),m=j.count(),n=-1,J=-1,r=0,o=d.contains(h.$list);i-1)p[n].firstNotAllowed=1;if(J>-1)p[J].lastNotAllowed=1;return p}function e(b,c){var d=[],k=b.getChildren(),l=k.count(),g,p=0,i=h[c],t=!b.is(h.$inline)||b.is(\"br\");for(t&&d.push(\" \");p", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "D;var E=y(\".odPreview\"),J=y(\"#odFiles\");b=function(N,Q){Q=Q||document;return Q.querySelectorAll(N)}(\".odCatListTitle\");for(D=0;D 7)\n\t\t\t\t\tsize = 7;\n\t\t\t\tif (size < 1)\n\t\t\t\t\tsize = 1;\n\t\t\t}\n\t\t\tif (size < 0) {\n\t\t\t\tsize = 0;\n\t\t\t}\n\t\t\treturn '' + content + '';\n\t\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "aa&&(la=pa[ca],null==la&&(la={},pa[ca]=la),ca=la[aa],null==ca&&(ca=[],la[aa]=ca),ca.push(na))}ia=ia.nextSibling}G(ya,fa,wa)}})}function I(ia){v&&(Aa.scrollTop=0,ea.innerHTML=\"\",Ha.spin(ea),U=!1,V=!0,ha.innerHTML=mxUtils.htmlEntities(mxResources.get(\"recentDiag\")),ba=null,v(ua,function(){z(mxResources.get(\"cannotLoad\"));ua([])},ia?null:n))}function F(ia){if(\"\"==ia)null!=t&&(t.click(),t=null);else{if(null==TemplatesDialog.tagsList[c]){var ra={};for(Ja in ya)for(var aa=ya[Ja],ca=0;ca\")\n\t\t.append(element)\n\t\t.html();\n\ttry {\n\t\treturn element[0].nodeType === NODE_TYPE_TEXT\n\t\t\t? lowercase(elemHtml)\n\t\t\t: elemHtml\n\t\t\t\t\t.match(/^(<[^>]+>)/)[1]\n\t\t\t\t\t.replace(/^<([\\w\\-]+)/, function(match, nodeName) {\n\t\t\t\t\t\treturn \"<\" + lowercase(nodeName);\n\t\t\t\t\t});\n\t} catch (e) {\n\t\treturn lowercase(elemHtml);\n\t}\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\t\t\tunselectAll = function() {\n\t\t\t\tif (selectedFiles.length) {\n\t\t\t\t\tselectLock = false;\n\t\t\t\t\tselectedFiles = [];\n\t\t\t\t\tcwd.find('[id].'+clSelected).trigger(evtUnselect); \n\t\t\t\t\ttrigger();\n\t\t\t\t}\n\t\t\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function remove_cluster(ids) {\n var data = {};\n $.each(ids, function(_, cluster) {\n data[ \"clusterid-\" + cluster] = true;\n });\n $.ajax({\n type: 'POST',\n url: '/manage/removecluster',\n data: data,\n timeout: pcs_timeout,\n success: function () {\n $(\"#dialog_verify_remove_clusters.ui-dialog-content\").each(function(key, item) {$(item).dialog(\"destroy\")});\n Pcs.update();\n },\n error: function (xhr, status, error) {\n alert(\"Unable to remove cluster: \" + res + \" (\"+error+\")\");\n $(\"#dialog_verify_remove_clusters.ui-dialog-content\").each(function(key, item) {$(item).dialog(\"destroy\")});\n }\n });\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " refreshTabs : function(){\n \"use strict\";\n window.console.log('refreshTabs');\n var self = this;\n var pltabs = '';\n for(var i=0; i';\n\n var isplaying = '';\n if(pl.id == this.playingPlaylist){\n isplaying += '▶';\n }\n\n var isunsaved = '';\n if(!pl.saved && pl.reason_open !== 'queue'){\n isunsaved += ' (unsaved)';\n }\n\n // fix for CVE-2015-8310\n var escaped_playlist_name = $(\"
        \").text(pl.name).html();\n pltabs += ''+isplaying+' '+escaped_playlist_name + isunsaved;\n if(pl.closable){\n pltabs += '×';\n }\n pltabs += '';\n }\n pltabs += '
      • +
      • ';\n $(self.cssSelectorPlaylistChooser+' ul').empty()\n $(self.cssSelectorPlaylistChooser+' ul').append(pltabs);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "return true}function g(a){if(!a)return{};for(var a=a.split(/\\s*,\\s*/).sort(),b={};a.length;)b[a.shift()]=J;return b}function h(a){for(var b,c,d,f,e={},l=1,a=t(a);b=a.match(C);){if(c=b[2]){d=m(c,\"styles\");f=m(c,\"attrs\");c=m(c,\"classes\")}else d=f=c=null;e[\"$\"+l++]={elements:b[1],classes:c,styles:d,attributes:f};a=a.slice(b[0].length)}return e}function m(a,b){var c=a.match(O[b]);return c?t(c[1]):null}function j(a){if(!a.styles)a.styles=CKEDITOR.tools.parseCssText(a.attributes.style||\"\",1);if(!a.classes)a.classes=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "(function(d){function e(a){var b=a||window.event,c=[].slice.call(arguments,1),f=0,e=0,g=0,a=d.event.fix(b);a.type=\"mousewheel\";b.wheelDelta&&(f=b.wheelDelta/120);b.detail&&(f=-b.detail/3);g=f;void 0!==b.axis&&b.axis===b.HORIZONTAL_AXIS&&(g=0,e=-1*f);void 0!==b.wheelDeltaY&&(g=b.wheelDeltaY/120);void 0!==b.wheelDeltaX&&(e=-1*b.wheelDeltaX/120);c.unshift(a,f,e,g);return(d.event.dispatch||d.event.handle).apply(this,c)}var c=[\"DOMMouseScroll\",\"mousewheel\"];if(d.event.fixHooks)for(var h=c.length;h;)d.event.fixHooks[c[--h]]=d.event.mouseHooks;d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],e,!1);else this.onmousewheel=e},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a],e,!1);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind(\"mousewheel\",a):this.trigger(\"mousewheel\")},unmousewheel:function(a){return this.unbind(\"mousewheel\",a)}})})(jQuery);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "(function(a){var e={};CKEDITOR.on(\"reset\",function(){e={}});a.equals=function(a){try{return a&&a.$===this.$}catch(c){return false}};a.setCustomData=function(a,c){var d=this.getUniqueId();(e[d]||(e[d]={}))[a]=c;return this};a.getCustomData=function(a){var c=this.$[\"data-cke-expando\"];return(c=c&&e[c])&&a in c?c[a]:null};a.removeCustomData=function(a){var c=this.$[\"data-cke-expando\"],c=c&&e[c],d,g;if(c){d=c[a];g=a in c;delete c[a]}return g?d:null};a.clearCustomData=function(){this.removeAllListeners();", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "(function($,e,t) {\"$:nomunge\";var i=[],n=$.resize=$.extend($.resize,{}),a,r=false,s=\"setTimeout\",u=\"resize\",m=u+\"-special-event\",o=\"pendingDelay\",l=\"activeDelay\",f=\"throttleWindow\";n[o]=200;n[l]=20;n[f]=true;$.event.special[u]={setup:function() {if (!n[f]&&this[s]) {return false}var e=$(this);i.push(this);e.data(m,{w:e.width(),h:e.height()});if (i.length===1) {a=t;h()}},teardown:function() {if (!n[f]&&this[s]) {return false}var e=$(this);for(var t=i.length-1;t>=0;t--) {if (i[t]==this) {i.splice(t,1);break}}e.removeData(m);if (!i.length) {if (r) {cancelAnimationFrame(a)} else {clearTimeout(a)}a=null}},add:function(e) {if (!n[f]&&this[s]) {return false}var i;function a(e,n,a) {var r=$(this),s=r.data(m)||{};s.w=n!==t?n:r.width();s.h=a!==t?a:r.height();i.apply(this,arguments)}if ($.isFunction(e)) {i=e;return a} else {i=e.handler;e.handler=a}}};function h(t) {if (r===true) {r=t||1}for(var s=i.length-1;s>=0;s--) {var l=$(i[s]);if (l[0]==e||l.is(\":visible\")) {var f=l.width(),c=l.height(),d=l.data(m);if (d&&(f!==d.w||c!==d.h)) {l.trigger(u,[d.w=f,d.h=c]);r=t||true}} else {d=l.data(m);d.w=0;d.h=0}}if (a!==null) {if (r&&(t==null||t-r<1e3)) {a=e.requestAnimationFrame(h)} else {a=setTimeout(h,n[o]);r=false}}}if (!e.requestAnimationFrame) {e.requestAnimationFrame=function() {return e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(t,i) {return e.setTimeout(function() {t((new Date).getTime())},n[l])}}()}if (!e.cancelAnimationFrame) {e.cancelAnimationFrame=function() {return e.webkitCancelRequestAnimationFrame||e.mozCancelRequestAnimationFrame||e.oCancelRequestAnimationFrame||e.msCancelRequestAnimationFrame||clearTimeout}()}})(jQuery,this);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "document.createElement(\"span\");z.style[\"float\"]=\"right\";z.style.cursor=\"pointer\";z.style.userSelect=\"none\";z.style.marginTop=\"-4px\";z.appendChild(t);mxUtils.write(z,mxResources.get(\"showStartScreen\"));mxEvent.addListener(z,\"click\",function(D){mxEvent.getSource(D)!=t&&(t.checked=!t.checked)});header=z}var L=localStorage.getItem(Editor.configurationKey);z=[[mxResources.get(\"reset\"),function(D,G){c.confirm(mxResources.get(\"areYouSure\"),function(){try{mxEvent.isShiftDown(D)?(localStorage.removeItem(Editor.settingsKey),\nlocalStorage.removeItem(\".drawio-config\")):(localStorage.removeItem(Editor.configurationKey),c.hideDialog(),c.alert(mxResources.get(\"restartForChangeRequired\")))}catch(P){c.handleError(P)}})},\"Shift+Click to Reset Settings\"]];var C=c.actions.get(\"plugins\");null!=C&&\"1\"==urlParams.sketch&&z.push([mxResources.get(\"plugins\"),C.funct]);EditorUi.isElectronApp||z.push([mxResources.get(\"share\"),function(D,G){if(0' +\n\t\t\t\t\t\tapp.vtranslate('JS_AVAILABLE_FILE_TYPES') +\n\t\t\t\t\t\t': ' +\n\t\t\t\t\t\tallowedTypes.replace(/\\|/g, ', '),\n\t\t\t\t\t'warning'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-434", "cwe_name": "Unrestricted Upload of File with Dangerous Type", "description": "The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.", "url": "https://cwe.mitre.org/data/definitions/434.html", "label_name": "safe"} {"code": " function sendMessage(callback) {\n pool.send(\n {\n data: {},\n message: new MockBuilder(\n {\n from: 'test@valid.sender',\n to: 'test@valid.recipient'\n },\n message\n )\n },\n function (err) {\n expect(err).to.not.exist;\n callback();\n }\n );\n }\n\n let total = 100;\n let returned = 0;\n let cb = function () {\n let sent = 0;\n\n if (++returned === total) {\n expect(pool._connections.length).to.be.above(1);\n pool._connections.forEach(function (conn) {\n expect(conn.messages).to.be.above(1);\n sent += conn.messages;\n });\n\n expect(sent).to.be.equal(total);\n\n pool.close();\n return done();\n }\n };\n for (let i = 0; i < total; i++) {\n sendMessage(cb);\n }\n });", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "\"
        \");return a.join(\"\")})}},checkbox:function(b,a,d){if(!(3>arguments.length)){var e=i.call(this,a,{\"default\":!!a[\"default\"]});a.validate&&(this.validate=a.validate);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,\"span\",null,null,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+\"_checkbox\":CKEDITOR.tools.getNextId()+\"_checkbox\"},true),d=[],h=CKEDITOR.tools.getNextId()+\"_label\",g={\"class\":\"cke_dialog_ui_checkbox_input\",type:\"checkbox\",\"aria-labelledby\":h};p(c);if(a[\"default\"])g.checked=\n\"checked\";if(typeof c.inputStyle!=\"undefined\")c.style=c.inputStyle;e.checkbox=new CKEDITOR.ui.dialog.uiElement(b,c,d,\"input\",null,g);d.push(' \");return d.join(\"\")})}},radio:function(b,a,d){if(!(3>arguments.length)){i.call(this,a);this._[\"default\"]||(this._[\"default\"]=this._.initValue=a.items[0][1]);a.validate&&(this.validate=a.valdiate);var e=[],c=this;CKEDITOR.ui.dialog.labeledElement.call(this,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " ipv6Regex = /^\\s*((([0-9A-Fa-f]{1,4}:) {7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:) {6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3})|:))|(([0-9A-Fa-f]{1,4}:) {5}(((:[0-9A-Fa-f]{1,4}) {1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3})|:))|(([0-9A-Fa-f]{1,4}:) {4}(((:[0-9A-Fa-f]{1,4}) {1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3}))|:))|(([0-9A-Fa-f]{1,4}:) {3}(((:[0-9A-Fa-f]{1,4}) {1,4})|((:[0-9A-Fa-f]{1,4}) {0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3}))|:))|(([0-9A-Fa-f]{1,4}:) {2}(((:[0-9A-Fa-f]{1,4}) {1,5})|((:[0-9A-Fa-f]{1,4}) {0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3}))|:))|(([0-9A-Fa-f]{1,4}:) {1}(((:[0-9A-Fa-f]{1,4}) {1,6})|((:[0-9A-Fa-f]{1,4}) {0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3}))|:))|(:(((:[0-9A-Fa-f]{1,4}) {1,7})|((:[0-9A-Fa-f]{1,4}) {0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)) {3}))|:)))(%.+)?\\s*$/,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "mxDualRuler.prototype.setUnit=function(b){this.vRuler.setUnit(b);this.hRuler.setUnit(b)};mxDualRuler.prototype.setStyle=function(b){this.vRuler.setStyle(b);this.hRuler.setStyle(b)};mxDualRuler.prototype.destroy=function(){this.vRuler.destroy();this.hRuler.destroy();this.ui.refresh=this.editorUiRefresh;mxGuide.prototype.move=this.origGuideMove;mxGuide.prototype.destroy=this.origGuideDestroy;this.ui.getDiagramContainerOffset=this.editorUiGetDiagContOffset};function mxFreehand(b){var e=null!=b.view&&null!=b.view.canvas?b.view.canvas.ownerSVGElement:null;if(null!=b.container&&null!=e){b.addListener(mxEvent.ESCAPE,mxUtils.bind(this,function(){this.stopDrawing()}));var f=mxFreehand.prototype.NORMAL_SMOOTHING,c=null,m=[],n,v=[],d,g=!1,k=!0,l=!0,p=!0,q=!0,x=[],y=!1,A=!0,B=!1,I={size:12,thinning:.5,smoothing:.5,streamline:.5,start:{taper:0,cap:!0},end:{taper:0,cap:!0}},O=!1;this.setClosedPath=function(K){g=K};this.setAutoClose=function(K){k=K};this.setAutoInsert=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "Runner.prototype.grep = function(re, invert){\n debug('grep %s', re);\n this._grep = re;\n this._invert = invert;\n this.total = this.grepTotal(this.suite);\n return this;\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "mxDualRuler.prototype.setUnit=function(b){this.vRuler.setUnit(b);this.hRuler.setUnit(b)};mxDualRuler.prototype.setStyle=function(b){this.vRuler.setStyle(b);this.hRuler.setStyle(b)};mxDualRuler.prototype.destroy=function(){this.vRuler.destroy();this.hRuler.destroy();this.ui.refresh=this.editorUiRefresh;mxGuide.prototype.move=this.origGuideMove;mxGuide.prototype.destroy=this.origGuideDestroy;this.ui.getDiagramContainerOffset=this.editorUiGetDiagContOffset};function mxFreehand(b){var e=null!=b.view&&null!=b.view.canvas?b.view.canvas.ownerSVGElement:null;if(null!=b.container&&null!=e){b.addListener(mxEvent.ESCAPE,mxUtils.bind(this,function(){this.stopDrawing()}));var f=mxFreehand.prototype.NORMAL_SMOOTHING,c=null,m=[],n,v=[],d,g=!1,k=!0,l=!0,p=!0,q=!0,x=[],y=!1,A=!0,B=!1,I={size:12,thinning:.5,smoothing:.5,streamline:.5,start:{taper:0,cap:!0},end:{taper:0,cap:!0}},O=!1;this.setClosedPath=function(J){g=J};this.setAutoClose=function(J){k=J};this.setAutoInsert=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " getCreateHtml: function (address) {\n address = this.getHelper().escapeString(address);\n\n var html = '' +\n '' +\n '' +\n '';\n\n return html;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.user&&this.updateUser(this.emptyFn,this.emptyFn,!0),f(g)):n||401!==g.getStatus()&&400!==g.getStatus()?c(this.parseRequestText(g)):this.authenticate(function(){m(!0)},c,n))}),mxUtils.bind(this,function(g){window.clearTimeout(d);v&&c(g)}))});null==b||6E4>this.tokenExpiresOn-Date.now()?this.authenticate(function(){m(!0)},c):m(!1)};OneDriveClient.prototype.checkToken=function(e,f){null==b||null==this.tokenRefreshThread||6E4>this.tokenExpiresOn-Date.now()?this.authenticate(e,null!=f?f:this.emptyFn):\ne()};OneDriveClient.prototype.getItemRef=function(e){var f=e.split(\"/\");return 1[' + getDateString() + '] [whisper to ' + display + '] ' + escapeXmlTags(result));\n\t\t\t\t\t$('#chatroom').get(0).scrollTop = $('#chatroom').get(0).scrollHeight;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\treturn;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "CKEDITOR.dom.event.prototype={getKey:function(){return this.$.keyCode||this.$.which},getKeystroke:function(){var a=this.getKey();if(this.$.ctrlKey||this.$.metaKey)a=a+CKEDITOR.CTRL;this.$.shiftKey&&(a=a+CKEDITOR.SHIFT);this.$.altKey&&(a=a+CKEDITOR.ALT);return a},preventDefault:function(a){var e=this.$;e.preventDefault?e.preventDefault():e.returnValue=false;a&&this.stopPropagation()},stopPropagation:function(){var a=this.$;a.stopPropagation?a.stopPropagation():a.cancelBubble=true},getTarget:function(){var a=\nthis.$.target||this.$.srcElement;return a?new CKEDITOR.dom.node(a):null},getPhase:function(){return this.$.eventPhase||2},getPageOffset:function(){var a=this.getTarget().getDocument().$;return{x:this.$.pageX||this.$.clientX+(a.documentElement.scrollLeft||a.body.scrollLeft),y:this.$.pageY||this.$.clientY+(a.documentElement.scrollTop||a.body.scrollTop)}}};CKEDITOR.CTRL=1114112;CKEDITOR.SHIFT=2228224;CKEDITOR.ALT=4456448;CKEDITOR.EVENT_PHASE_CAPTURING=1;CKEDITOR.EVENT_PHASE_AT_TARGET=2;", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function isCollapsedOneLiner(node) {\n const before = sourceCode.getTokenBefore(node);\n const last = sourceCode.getLastToken(node);\n const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;\n\n return before.loc.start.line === lastExcludingSemicolon.loc.end.line;\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function(e){var f=e.split(\"/\");return 1
        \");a=this.replaceLinefeeds?a.replace(/\\n/g,\"
        \"):a;var b=null!=this.background&&this.background!=mxConstants.NONE?this.background:null,c=null!=this.border&&this.border!=mxConstants.NONE?this.border:null;if(\"fill\"==this.overflow||\n\"width\"==this.overflow)null!=b&&(this.node.style.backgroundColor=b),null!=c&&(this.node.style.border=\"1px solid \"+c);else{var d=\"\";null!=b&&(d+=\"background-color:\"+mxUtils.htmlEntities(b)+\";\");null!=c&&(d+=\"border:1px solid \"+mxUtils.htmlEntities(c)+\";\");a='
        '+a+\"
        \"}this.node.innerHTML=\na;a=this.node.getElementsByTagName(\"div\");0 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tlist.style.display = '';\n\t\t\t\t\t\tdiv.style.left = '160px';\n\t\t\t\t\t\tlist.innerHTML = '';\n\n\t\t\t\t\t\tcustomCatCount = 0;\n\t\t\t\t\t\tcategories = {'draw.io': docList};\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (var cat in searchImportCats)\n\t\t\t\t\t\t{\t\n\t\t\t\t\t\t\tcategories[cat] = searchImportCats[cat];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tinitUi();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\taddTemplates(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (isSearch)\n\t\t\t{\n\t\t\t\tsearchDocsCallback(searchInput.value, callback2);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trecentDocsCallback(callback2);\n\t\t\t}\n\t\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "Q.marginBottom||0;R.allowGaps=Q.allowGaps||0;R.horizontal=\"1\"==mxUtils.getValue(Q,\"horizontalRack\",\"0\");R.resizeParent=!1;R.fill=!0;return R}return T.apply(this,arguments)};this.updateGlobalUrlVariables()};var B=Graph.prototype.postProcessCellStyle;Graph.prototype.postProcessCellStyle=function(u,E){return Graph.processFontStyle(B.apply(this,arguments))};var I=mxSvgCanvas2D.prototype.updateTextNodes;mxSvgCanvas2D.prototype.updateTextNodes=function(u,E,J,T,N,Q,R,Y,ba,ea,Z){I.apply(this,arguments);Graph.processFontAttributes(Z)};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "m=P.name;v=\"\";O(null,!0)})));k.appendChild(F)})(D[G],G)}100==D.length&&(k.appendChild(A),B=function(){k.scrollTop>=k.scrollHeight-k.offsetHeight&&C()},mxEvent.addListener(k,\"scroll\",B))}),y)});t()};GitHubClient.prototype.logout=function(){this.clearPersistentToken();this.setUser(null);b=null}})();TrelloFile=function(b,e,f){DrawioFile.call(this,b,e);this.meta=f;this.saveNeededCounter=0};mxUtils.extend(TrelloFile,DrawioFile);TrelloFile.prototype.getHash=function(){return\"T\"+encodeURIComponent(this.meta.compoundId)};TrelloFile.prototype.getMode=function(){return App.MODE_TRELLO};TrelloFile.prototype.isAutosave=function(){return!0};TrelloFile.prototype.getTitle=function(){return this.meta.name};TrelloFile.prototype.isRenamable=function(){return!1};TrelloFile.prototype.getSize=function(){return this.meta.bytes};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "_currentRules:function _currentRules() {\n if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n } else {\n return this.conditions[\"INITIAL\"].rules;\n }\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " text: antSword.noxss(conf[_]['type'].toUpperCase()),\n im0: this.manager.list.imgs[0],\n im1: this.manager.list.imgs[0],\n im2: this.manager.list.imgs[0]\n });\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " scope.returnThis = function () {\n return this;\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "function isFormData(obj) {\n return toString.call(obj) === '[object FormData]';\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "previous:function(){return a.call(this,1)},checkForward:function(){return a.call(this,0,1)!==false},checkBackward:function(){return a.call(this,1,1)!==false},lastForward:function(){return e.call(this)},lastBackward:function(){return e.call(this,1)},reset:function(){delete this.current;this._={}}}});var c={block:1,\"list-item\":1,table:1,\"table-row-group\":1,\"table-header-group\":1,\"table-footer-group\":1,\"table-row\":1,\"table-column-group\":1,\"table-column\":1,\"table-cell\":1,\"table-caption\":1},d={absolute:1,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "page.onResourceRequested = function (request, networkRequest) {\n console.log('Request ' + request.url);\n if (request.url.lastIndexOf(body.url, 0) === 0) {\n return;\n }\n\n //potentially dangerous request\n if (request.url.lastIndexOf(\"file:///\", 0) === 0 && !body.allowLocalFilesAccess) {\n networkRequest.abort();\n return;\n }\n\n //to support cdn like format //cdn.jquery...\n if (request.url.lastIndexOf(\"file://\", 0) === 0 && request.url.lastIndexOf(\"file:///\", 0) !== 0) {\n networkRequest.changeUrl(request.url.replace(\"file://\", \"http://\"));\n }\n\n if (body.waitForJS && request.url.lastIndexOf(\"http://intruct-javascript-ending\", 0) === 0) {\n pageJSisDone = true;\n }\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " function getVersionClass(version) {\n if (version) {\n var tmp = version.split ('.');\n if (tmp[0] === '0' && tmp[1] === '0' && tmp[2] === '0') {\n version = 'planned';\n } else if (tmp[0] === '0' && tmp[1] === '0') {\n version = 'alpha';\n } else if (tmp[0] === '0') {\n version = 'beta'\n } else if (version === 'npm error') {\n version = 'error';\n } else {\n version = 'stable';\n }\n }\n return version;\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "function create_group() {\n var num_nodes = 0;\n var node_names = \"\";\n $(\"#resource_list :checked\").parent().parent().each(function (index,element) {\n if (element.getAttribute(\"nodeID\")) {\n num_nodes++;\n node_names += element.getAttribute(\"nodeID\") + \" \"\n }\n });\n\n if (num_nodes == 0) {\n alert(\"You must select at least one resource to add to a group\");\n return;\n }\n\n $(\"#resources_to_add_to_group\").val(node_names);\n $(\"#add_group\").dialog({\n title: 'Create Group',\n modal: true,\n resizable: false,\n buttons: {\n Cancel: function() {\n $(this).dialog(\"close\");\n },\n \"Create Group\": function() {\n var data = $('#add_group > form').serialize();\n var url = get_cluster_remote_url() + \"add_group\";\n ajax_wrapper({\n type: \"POST\",\n url: url,\n data: data,\n success: function() {\n Pcs.update();\n $(\"#add_group\").dialog(\"close\");\n },\n error: function (xhr, status, error) {\n alert(\n \"Error creating group \"\n + ajax_simple_error(xhr, status, error)\n );\n $(\"#add_group\").dialog(\"close\");\n }\n });\n }\n }\n });\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": " value: value.slice(start + 2, idx),\n start: start,\n end: idx + 1,\n replaceInValue: function (value, context) {\n return interpreter.replace(value, context, parseContext);\n },\n };\n\n return parseContext;\n }\n }\n\n return null;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "ba.src=\"/images/icon-search.svg\"};b.sidebar.hideTooltip();b.sidebar.currentElt=ca;Ca=!0;ba.src=\"/images/aui-wait.gif\";fa.isExt?e(fa,oa,function(){A(mxResources.get(\"cantLoadPrev\"));Ca=!1;ba.src=\"/images/icon-search.svg\"}):ia(fa.url,oa)}}function n(fa,ca,ba){if(null!=C){for(var ja=C.className.split(\" \"),ia=0;ia=na.getStatus()?ja(na.getText(),oa):ia()})):ja(b.emptyDiagramXml,oa)},ja=function(oa,na){x||b.hideDialog(!0);f(oa,na,qa,ca)},ia=function(){A(mxResources.get(\"cannotLoad\"));ma()},ma=function(){I=qa;Ba.className=\"geTempDlgCreateBtn\";ca&&(Ka.className=\"geTempDlgOpenBtn\")},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "return this.editor.exportToCanvas(c,e,g,k,m,q,v,x,A,z,L,M,n,y,K,B)};EditorUi.prototype.createImageUrlConverter=function(){EditorUi.logEvent(\"SHOULD NOT BE CALLED: createImageUrlConverter\");return this.editor.createImageUrlConverter()};EditorUi.prototype.convertImages=function(c,e,g,k){EditorUi.logEvent(\"SHOULD NOT BE CALLED: convertImages\");return this.editor.convertImages(c,e,g,k)};EditorUi.prototype.convertImageToDataUri=function(c,e){EditorUi.logEvent(\"SHOULD NOT BE CALLED: convertImageToDataUri\");", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "Manager.prototype.generateId = function () {\n return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString()\n + Math.abs(Math.random() * Math.random() * Date.now() | 0).toString();\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": "once:function(){var b=arguments[1];arguments[1]=function(d){d.removeListener();return b.apply(this,arguments)};return this.on.apply(this,arguments)},capture:function(){CKEDITOR.event.useCapture=1;var b=this.on.apply(this,arguments);CKEDITOR.event.useCapture=0;return b},fire:function(){var b=0,d=function(){b=1},a=0,h=function(){a=1};return function(m,j,i){var n=e(this)[m],m=b,r=a;b=a=0;if(n){var o=n.listeners;if(o.length)for(var o=o.slice(0),u,f=0;f' + self.icon + ' ' + lang.databasic.name + ': ' +\n $node.attr('data-test') + '

        ');\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "for(var I=0;I 1) suites.shift();\n var suite = Suite.create(suites[0], title);\n suites.unshift(suite);\n return suite;\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "function selectedFilesRail(inputFileID) {\n\n var fileobj = [];\n if(inputFileID && inputFileID != '') {\n setFilesRail(document.getElementById(inputFileID).files);\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "Context.prototype.inspect = function(){\n return JSON.stringify(this, function(key, val){\n if ('_runnable' == key) return;\n if ('test' == key) return;\n return val;\n }, 2);\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " copy: function (from, dist, callback) {\n var that = this,\n cmd = '';\n dist = path.resolve(dist);\n fs.lstat(from, function (err, stats) {\n if (err) {\n callback(err);\n } else {\n if (stats.isDirectory()) {\n that.mkdir(dist, function (err) {\n if (err) {\n callback(err);\n } else {\n if (that._win32) {\n cmd = 'echo d|xcopy /s /e /y \"' + path.join(from, '*') + '\" \"' + dist + '\"';\n } else {\n cmd = 'cp -f -R -p ' + path.join(from, '*').replace(/ /g, '\\\\ ') + ' ' + dist.replace(/ /g, '\\\\ ');\n }\n child_process.exec(cmd, function (error, stdout, stderr) {\n callback && callback(error);\n });\n }\n });\n } else if (stats.isFile()) {\n if (that._win32) {\n cmd = 'echo f|xcopy /y \"' + from + '\" \"' + dist + '\"';\n } else {\n cmd = 'cp -f -p ' + from.replace(/ /g, '\\\\ ') + ' ' + dist.replace(/ /g, '\\\\ ');\n }\n child_process.exec(cmd, function (error, stdout, stderr) {\n callback && callback(error);\n });\n } else {\n callback && callback(null);\n }\n }\n });\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "\texpression: function() {\n\t\treturn this.assignment();\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "Client.prototype.openssh_forwardInStreamLocal = function(socketPath, cb) {\n if (!this._sock\n || !this._sock.writable\n || !this._sshstream\n || !this._sshstream.writable)\n throw new Error('Not connected');\n\n var wantReply = (typeof cb === 'function');\n var self = this;\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push(function(had_err) {\n if (had_err) {\n return cb(had_err !== true\n ? had_err\n : new Error('Unable to bind to ' + socketPath));\n }\n self._forwardingUnix[socketPath] = true;\n cb();\n });\n }\n\n return this._sshstream.openssh_streamLocalForward(socketPath, wantReply);\n } else if (wantReply) {\n process.nextTick(function() {\n cb(new Error('strictVendor enabled and server is not OpenSSH or compatible version'));\n });\n }\n\n return true;\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "\t_setOption: function( key, value ) {\n\t\tvar isDraggable, isResizable,\n\t\t\tuiDialog = this.uiDialog;\n\n\t\tif ( key === \"dialogClass\" ) {\n\t\t\tuiDialog\n\t\t\t\t.removeClass( this.options.dialogClass )\n\t\t\t\t.addClass( value );\n\t\t}\n\n\t\tif ( key === \"disabled\" ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._super( key, value );\n\n\t\tif ( key === \"buttons\" ) {\n\t\t\tthis._createButtons();\n\t\t}\n\n\t\tif ( key === \"closeText\" ) {\n\t\t\tthis.uiDialogTitlebarClose.button({\n\t\t\t\t// ensure that we always pass a string\n\t\t\t\tlabel: \"\" + value\n\t\t\t});\n\t\t}\n\n\t\tif ( key === \"draggable\" ) {\n\t\t\tisDraggable = uiDialog.is( \":data(ui-draggable)\" );\n\t\t\tif ( isDraggable && !value ) {\n\t\t\t\tuiDialog.draggable( \"destroy\" );\n\t\t\t}\n\n\t\t\tif ( !isDraggable && value ) {\n\t\t\t\tthis._makeDraggable();\n\t\t\t}\n\t\t}\n\n\t\tif ( key === \"position\" ) {\n\t\t\tthis._position();\n\t\t}\n\n\t\tif ( key === \"resizable\" ) {\n\t\t\t// currently resizable, becoming non-resizable\n\t\t\tisResizable = uiDialog.is( \":data(ui-resizable)\" );\n\t\t\tif ( isResizable && !value ) {\n\t\t\t\tuiDialog.resizable( \"destroy\" );\n\t\t\t}\n\n\t\t\t// currently resizable, changing handles\n\t\t\tif ( isResizable && typeof value === \"string\" ) {\n\t\t\t\tuiDialog.resizable( \"option\", \"handles\", value );\n\t\t\t}\n\n\t\t\t// currently non-resizable, becoming resizable\n\t\t\tif ( !isResizable && value !== false ) {\n\t\t\t\tthis._makeResizable();\n\t\t\t}\n\t\t}\n\n\t\tif ( key === \"title\" ) {\n\t\t\tthis._title( this.uiDialogTitlebar.find( \".ui-dialog-title\" ) );\n\t\t}\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " 'entityType': this.getHelper().escapeString(this.translateEntityType(this.model.get('parentType'))),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " context.teardown = function(fn) {\n suites[0].afterEach(fn);\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function ffprobe(file) {\n return new Promise((resolve, reject) => {\n if (!file)\n throw new Error('no file provided');\n fs_1.stat(file, (err, stats) => {\n if (err)\n return reject(new Error('wrong file provided'));\n child_process_1.exec('ffprobe -v quiet -print_format json -show_format -show_streams ' + file, (error, stdout, stderr) => {\n if (error)\n return reject(error);\n if (!stdout)\n return reject(new Error(\"can't probe file \" + file));\n let ffprobed;\n try {\n ffprobed = JSON.parse(stdout);\n }\n catch (err) {\n return reject(err);\n }\n for (let i = 0; i < ffprobed.streams.length; i++) {\n if (ffprobed.streams[i].codec_type === 'video')\n ffprobed.video = ffprobed.streams[i];\n if (ffprobed.streams[i].codec_type === 'audio' && ffprobed.streams[i].channels)\n ffprobed.audio = ffprobed.streams[i];\n }\n resolve(ffprobed);\n });\n });\n });\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\tthis.closed = function() {\n\t\treturn state == closed;\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " data: function () {\n return _.extend({\n relatedTypeString: this.translateEntityType(this.entityType)\n }, Dep.prototype.data.call(this));\n },\n\n init: function () {\n if (this.getUser().isAdmin()) {\n this.isRemovable = true;\n }\n Dep.prototype.init.call(this);\n },\n\n setup: function () {\n var data = this.model.get('data') || {};\n\n this.entityType = this.model.get('relatedType') || data.entityType || null;\n this.entityId = this.model.get('relatedId') || data.entityId || null;\n this.entityName = this.model.get('relatedName') || data.entityName || null;\n\n this.messageData['relatedEntityType'] = this.translateEntityType(this.entityType);\n this.messageData['relatedEntity'] = '' + this.entityName +'';\n\n this.createMessage();\n },\n });\n});", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function stripHTML(){\n html = html.slice(0, strip) + html.slice(j);\n j = strip;\n strip = false;\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "var T=document.createElement(\"tbody\"),P=(new Date).toDateString();null!=b.currentPage&&null!=b.pages&&(g=mxUtils.indexOf(b.pages,b.currentPage));for(q=e.length-1;0<=q;q--){var Q=function(S){var Y=new Date(S.modifiedDate),ba=null;if(0<=Y.getTime()){var da=function(ja){x.stop();v.innerHTML=\"\";var ea=mxUtils.parseXml(ja),ha=b.editor.extractGraphModel(ea.documentElement,!0);if(null!=ha){var ma=function(Da){null!=Da&&(Da=Aa(Editor.parseDiagramNode(Da)));return Da},Aa=function(Da){var Ca=Da.getAttribute(\"background\");\nif(null==Ca||\"\"==Ca||Ca==mxConstants.NONE)Ca=d.defaultPageBackgroundColor;n.style.backgroundColor=Ca;(new mxCodec(Da.ownerDocument)).decode(Da,d.getModel());d.maxFitScale=1;d.fit(8);d.center();return Da};J.style.display=\"none\";J.innerHTML=\"\";M=ea;u=ja;k=parseSelectFunction=null;l=0;if(\"mxfile\"==ha.nodeName){ea=ha.getElementsByTagName(\"diagram\");k=[];for(ja=0;ja' +\n '
        ' +\n '' +\n '
        ' +\n '
        ' +\n '' +\n '

        ' +\n '
    ';\n\n return html;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " git.commit = function (files, message, newVer, noPrefix, callback) {\n assert.ok(noPrefix, 'No prefix should be true');\n return callback(null);\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "this.customFonts)))}finally{V.getModel().endUpdate()}}}));this.editorUi.showDialog(W.container,380,Editor.enableWebFonts?250:180,!0,!0);W.init()}),z,null,!0)})))}})();function DiagramPage(b,e){this.node=b;null!=e?this.node.setAttribute(\"id\",e):null==this.getId()&&this.node.setAttribute(\"id\",Editor.guid())}DiagramPage.prototype.node=null;DiagramPage.prototype.root=null;DiagramPage.prototype.viewState=null;DiagramPage.prototype.getId=function(){return this.node.getAttribute(\"id\")};DiagramPage.prototype.getName=function(){return this.node.getAttribute(\"name\")};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const isSFTP = (channel.type === 'sftp');\n const type = (isSFTP ? 'session' : channel.type);\n const chanInfo = {\n type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const instance = (\n isSFTP\n ? new SFTP(this, chanInfo, { debug })\n : new Channel(this, chanInfo)\n );\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "mxCellRenderer.prototype.destroy=function(u){E.apply(this,arguments);null!=u.secondLabel&&(u.secondLabel.destroy(),u.secondLabel=null)};mxCellRenderer.prototype.getShapesForState=function(u){return[u.shape,u.text,u.secondLabel,u.control]};var G=mxGraphView.prototype.resetValidationState;mxGraphView.prototype.resetValidationState=function(){G.apply(this,arguments);this.enumerationState=0};var P=mxGraphView.prototype.stateValidated;mxGraphView.prototype.stateValidated=function(u){null!=u.shape&&this.redrawEnumerationState(u);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "function pa(){mxEllipse.call(this)}function ua(){mxEllipse.call(this)}function ya(){mxRhombus.call(this)}function Fa(){mxEllipse.call(this)}function Ma(){mxEllipse.call(this)}function Oa(){mxEllipse.call(this)}function Qa(){mxEllipse.call(this)}function Ta(){mxActor.call(this)}function za(){mxActor.call(this)}function wa(){mxActor.call(this)}function Ea(c,l,x,p){mxShape.call(this);this.bounds=c;this.fill=l;this.stroke=x;this.strokewidth=null!=p?p:1;this.rectStyle=\"square\";this.size=10;this.absoluteCornerSize=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(){k.checked&&(null==g||g.checked)?q.removeAttribute(\"disabled\"):q.setAttribute(\"disabled\",\"disabled\")}));mxUtils.br(d);return{getLink:function(){return k.checked?\"blank\"===q.value?\"_blank\":p:null},getEditInput:function(){return k},getEditSelect:function(){return q}}};EditorUi.prototype.addLinkSection=function(d,g){function k(){var y=document.createElement(\"div\");y.style.width=\"100%\";y.style.height=\"100%\";y.style.boxSizing=\"border-box\";null!=q&&q!=mxConstants.NONE?(y.style.border=\"1px solid black\",\ny.style.backgroundColor=q):(y.style.backgroundPosition=\"center center\",y.style.backgroundRepeat=\"no-repeat\",y.style.backgroundImage=\"url('\"+Dialog.prototype.closeImage+\"')\");x.innerHTML=\"\";x.appendChild(y)}mxUtils.write(d,mxResources.get(\"links\")+\":\");var l=document.createElement(\"select\");l.style.width=\"100px\";l.style.padding=\"0px\";l.style.marginLeft=\"8px\";l.style.marginRight=\"10px\";l.className=\"geBtn\";var p=document.createElement(\"option\");p.setAttribute(\"value\",\"auto\");mxUtils.write(p,mxResources.get(\"automatic\"));", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "b.setSelectionCells([F])}}for(F=0;F');\r\n return;\r\n }\r\n\r\n var pqr = i.value;\r\n if (i.value.length >= 3)\r\n ajax_call('Validator.php?u=' + i.value + 'user', usercheck_callback_noacess, usercheck_error);\r\n}\r", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"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 ' + _.escape($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": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " onData(stream, session, callback) {\n stream.on('data', function () {});\n stream.on('end', callback);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "\"url(\"+mxWindow.prototype.normalizeImage+\")\";aa.style.backgroundPosition=\"top center\";aa.style.backgroundRepeat=\"no-repeat\";aa.setAttribute(\"title\",\"Minimize\");var va=!1,ja=mxUtils.bind(this,function(){N.innerHTML=\"\";if(!va){var da=function(ia,ma,qa){ia=D(\"\",ia.funct,null,ma,ia,qa);ia.style.width=\"40px\";ia.style.opacity=\"0.7\";return ca(ia,null,\"pointer\")},ca=function(ia,ma,qa){null!=ma&&ia.setAttribute(\"title\",ma);ia.style.cursor=null!=qa?qa:\"default\";ia.style.margin=\"2px 0px\";N.appendChild(ia);mxUtils.br(N);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\"unloaded\"==CKEDITOR.status&&function(){CKEDITOR.event.implementOn(CKEDITOR);CKEDITOR.loadFullCore=function(){if(CKEDITOR.status!=\"basic_ready\")CKEDITOR.loadFullCore._load=1;else{delete CKEDITOR.loadFullCore;var a=document.createElement(\"script\");a.type=\"text/javascript\";a.src=CKEDITOR.basePath+\"ckeditor.js\";document.getElementsByTagName(\"head\")[0].appendChild(a)}};CKEDITOR.loadFullCoreTimeout=0;CKEDITOR.add=function(a){(this._.pending||(this._.pending=[])).push(a)};(function(){CKEDITOR.domReady(function(){var a=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"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\tAppConnector.requestForm(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": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "(function(){CKEDITOR.htmlParser.cdata=function(a){this.value=a};CKEDITOR.htmlParser.cdata.prototype=CKEDITOR.tools.extend(new CKEDITOR.htmlParser.node,{type:CKEDITOR.NODE_TEXT,filter:function(){},writeHtml:function(a){a.write(this.value)}})})();\"use strict\";CKEDITOR.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false}};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "[];for(G=0;Gc&&!mxClient.IS_IOS?C.firstChild.nextSibling.setAttribute(\"title\",D.shortcut):l.apply(this,arguments)};var p=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){p.apply(this,arguments);if(null!=this.userElement){var C=this.userElement;C.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+C.style.display;C.className=\"geToolbarButton\";C.innerHTML=\"\";C.style.backgroundImage=\"url(\"+Editor.userImage+\")\";C.style.backgroundPosition=\"center center\";", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "var Lexer = function Lexer(options) {\n\tthis.options = options;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "Cache.prototype.set = function(key, value) {\n this._size >= this._maxSize && this.clear()\n if (!(key in this._values)) this._size++\n\n return (this._values[key] = value)\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": "P)this.editPlantUmlData(E,G,P);else if(P=this.graph.getAttributeForCell(E,\"mermaidData\"),null!=P)this.editMermaidData(E,G,P);else{var J=g.getCellStyle(E);\"1\"==mxUtils.getValue(J,\"metaEdit\",\"0\")?d.showDataDialog(E):k.apply(this,arguments)}}catch(F){d.handleError(F)}};g.getLinkTitle=function(E){return d.getLinkTitle(E)};g.customLinkClicked=function(E){var G=!1;try{d.handleCustomLink(E),G=!0}catch(P){d.handleError(P)}return G};var l=g.parseBackgroundImage;g.parseBackgroundImage=function(E){var G=l.apply(this,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "d};return function(c,d) {return b(c,d,a)}}return function(b,d) {b[a]=d}}function Ma(a) {return D(a.aoData,\"_aData\")}function na(a) {a.aoData.length=0;a.aiDisplayMaster.length=0;a.aiDisplay.length=0;a.aIds={}}function oa(a,b,c) {for(var d=-1,e=0,f=a.length;eb&&a[e]--; -1!=d&&c===k&&a.splice(d,1)}function ea(a,b,c,d) {var e=a.aoData[b],f,g=function(c,d) {for(;c.childNodes.length;)c.removeChild(c.firstChild);c.innerHTML=B(a,b,d,\"display\")};if (\"dom\"===c||(!c||\"auto\"===c)&&\"dom\"===e.src)e._aData=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "TagSearch.prototype.makeKeyDownHandler = function() {\n var me = this;\n var xButton = this._xButton;\n return function(evt) {\n var query = me.getQuery();\n var keyCode = getKeyCode(evt);\n var toolTip = me.getToolTip();\n if (keyCode === 27) {//escape\n me.setQuery('');\n toolTip.show();\n xButton.hide();\n return;\n }\n if (keyCode === 8 || keyCode === 48) {//del or backspace\n if (query.length === 1) {\n toolTip.show();\n xButton.hide();\n }\n } else {\n toolTip.hide();\n xButton.show();\n }\n };\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " __find_array_index(value, array) {\n for (var i in array) {\n if (JSON.stringify(array[i]) === JSON.stringify(value)) { // compare array\n return i;\n }\n }\n return -1;\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $scope.refresh = function() {\n growl.success('Retrieving node ' + _.escape($scope.foreignId) + ' from requisition ' + _.escape($scope.foreignSource) + '...');\n RequisitionsService.getNode($scope.foreignSource, $scope.foreignId).then(\n function(node) { // success\n $scope.node = node;\n },\n $scope.errorHandler\n );\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function disableCurrency(e) {\n var button = $(e.currentTarget);\n var currencyId = parseInt(button.data('id'));\n\n $.post(disableCurrencyUrl, {\n _token: token,\n id: currencyId\n }).done(function (data) {\n // lame but it works\n location.reload();\n }).fail(function () {\n console.error('I failed :(');\n });\n return false;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "EditorUi.prototype.updateTabContainer=function(){null!=this.tabContainer&&(this.tabContainer.style.right=\"70px\",this.diagramContainer.style.bottom=\"1\"==urlParams.sketch?\"0px\":this.tabContainerHeight+\"px\");f.apply(this,arguments)};var g=EditorUi.prototype.updateActionStates;EditorUi.prototype.updateActionStates=function(){g.apply(this,arguments);this.menus.get(\"save\").setEnabled(null!=this.getCurrentFile()||\"1\"==urlParams.embed)};var m=Menus.prototype.addShortcut;Menus.prototype.addShortcut=function(O,\nX){null!=X.shortcut&&900>n&&!mxClient.IS_IOS?O.firstChild.nextSibling.setAttribute(\"title\",X.shortcut):m.apply(this,arguments)};var q=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){q.apply(this,arguments);if(null!=this.userElement){var O=this.userElement;O.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+O.style.display;O.className=\"geToolbarButton\";O.innerHTML=\"\";O.style.backgroundImage=\"url(\"+Editor.userImage+\")\";O.style.backgroundPosition=\"center center\";", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(a,c,b){a=d.preparse(a,c);return d.isValid(a)?(a.M-=100>a.Y?22801:1,b||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};d.transform=function(a,c,b,e){return d.format(d.parse(a,c),b,e)};d.addYears=function(a,c){return d.addMonths(a,12*c)};d.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};d.addDays=function(a,c){var b=new Date(a.getTime());b.setDate(b.getDate()+c);return b};d.addHours=function(a,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "mxDualRuler.prototype.setUnit=function(b){this.vRuler.setUnit(b);this.hRuler.setUnit(b)};mxDualRuler.prototype.setStyle=function(b){this.vRuler.setStyle(b);this.hRuler.setStyle(b)};mxDualRuler.prototype.destroy=function(){this.vRuler.destroy();this.hRuler.destroy();this.ui.refresh=this.editorUiRefresh;mxGuide.prototype.move=this.origGuideMove;mxGuide.prototype.destroy=this.origGuideDestroy;this.ui.getDiagramContainerOffset=this.editorUiGetDiagContOffset};function mxFreehand(b){var f=null!=b.view&&null!=b.view.canvas?b.view.canvas.ownerSVGElement:null;if(null!=b.container&&null!=f){b.addListener(mxEvent.ESCAPE,mxUtils.bind(this,function(){this.stopDrawing()}));var l=mxFreehand.prototype.NORMAL_SMOOTHING,d=null,u=[],t,D=[],c,e=!1,g=!0,k=!0,m=!0,q=!0,v=[],x=!1,A=!0,z=!1,L={size:12,thinning:.5,smoothing:.5,streamline:.5,start:{taper:0,cap:!0},end:{taper:0,cap:!0}},M=!1;this.setClosedPath=function(J){e=J};this.setAutoClose=function(J){g=J};this.setAutoInsert=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "c.getMode())try{this.addRecent({id:c.getHash(),title:c.getTitle(),mode:c.getMode()})}catch(v){}try{mxSettings.setOpenCounter(mxSettings.getOpenCounter()+1),mxSettings.save()}catch(v){}}catch(v){this.fileLoadedError=v;if(null!=c)try{c.close()}catch(x){}if(EditorUi.enableLogging&&!this.isOffline())try{EditorUi.logEvent({category:\"ERROR-LOAD-FILE-\"+(null!=c?c.getHash():\"none\"),action:\"message_\"+v.message,label:\"stack_\"+v.stack})}catch(x){}c=mxUtils.bind(this,function(){null!=urlParams.url&&this.spinner.spin(document.body,\nmxResources.get(\"reconnecting\"))?window.location.search=this.getSearch([\"url\"]):null!=g?this.fileLoaded(g)||m():m()});e?c():this.handleError(v,mxResources.get(\"errorLoadingFile\"),c,!0,null,null,!0)}else m();return k};EditorUi.prototype.getHashValueForPages=function(c,e){var g=0,k=new mxGraphModel,m=new mxCodec;null!=e&&(e.byteCount=0,e.attrCount=0,e.eltCount=0,e.nodeCount=0);for(var q=0;qthis.status)if(\"txt\"==e)g(this.response);else{var A=new FileReader;A.readAsDataURL(this.response);A.onloadend=function(z){var L=new Image;L.onload=\nfunction(){try{var M=L.width,n=L.height;if(0==M&&0==n){var y=A.result,K=y.indexOf(\",\"),B=decodeURIComponent(escape(atob(y.substring(K+1)))),F=mxUtils.parseXml(B).getElementsByTagName(\"svg\");0'),\n\t\t\t\ticon = function(f) {\n\t\t\t\t\tvar mime = f.mime, i, tmb = self.tmb(f);\n\t\t\t\t\ti = '
    ';\n\t\t\t\t\tif (tmb) {\n\t\t\t\t\t\ti = $(i).addClass(tmb.className).css('background-image', \"url('\"+tmb.url+\"')\").get(0).outerHTML;\n\t\t\t\t\t}\n\t\t\t\t\treturn i;\n\t\t\t\t},\n\t\t\t\thashes, l, ctr;\n\t\t\t\n\t\t\tself.draggingUiHelper && self.draggingUiHelper.stop(true, true);\n\t\t\t\n\t\t\tself.trigger('dragstart', {target : element[0], originalEvent : e});\n\t\t\t\n\t\t\thashes = element.hasClass(self.res('class', 'cwdfile')) \n\t\t\t\t? self.selected() \n\t\t\t\t: [self.navId2Hash(element.attr('id'))];\n\t\t\t\n\t\t\thelper.append(icon(files[hashes[0]])).data('files', hashes).data('locked', false).data('droped', false).data('namespace', namespace).data('dropover', 0);\n\n\t\t\tif ((l = hashes.length) > 1) {\n\t\t\t\thelper.append(icon(files[hashes[l-1]]) + ''+l+'');\n\t\t\t}\n\t\t\t\n\t\t\t$(document).on(keydown + ' keyup.' + namespace, function(e) {\n\t\t\t\tvar chk = (e.shiftKey||e.ctrlKey||e.metaKey);\n\t\t\t\tif (ctr !== chk) {\n\t\t\t\t\tctr = chk;\n\t\t\t\t\tif (helper.is(':visible') && helper.data('dropover') && ! helper.data('droped')) {\n\t\t\t\t\t\thelper.toggleClass('elfinder-drag-helper-plus', helper.data('locked')? true : ctr);\n\t\t\t\t\t\tself.trigger(ctr? 'unlockfiles' : 'lockfiles', {files : hashes, helper: helper});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\treturn helper;\n\t\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function ed(a,b,c) {var d=a+\" \";switch(c) {case\"m\":return b?\"jedna minuta\":\"jedne minute\";case\"mm\":return d+=1===a?\"minuta\":2===a||3===a||4===a?\"minute\":\"minuta\";case\"h\":return b?\"jedan sat\":\"jednog sata\";case\"hh\":return d+=1===a?\"sat\":2===a||3===a||4===a?\"sata\":\"sati\";case\"dd\":return d+=1===a?\"dan\":\"dana\";case\"MM\":return d+=1===a?\"mjesec\":2===a||3===a||4===a?\"mjeseca\":\"mjeseci\";case\"yy\":return d+=1===a?\"godina\":2===a||3===a||4===a?\"godine\":\"godina\"}}function fd(a) {return a>1&&5>a&&1!==~~(a/10)}function gd(a,b,c,d) {var e=a+\" \";switch(c) {case\"s\":return b||d?\"p\u00e1r sekund\":\"p\u00e1r sekundami\";case\"m\":return b?\"minuta\":d?\"minutu\":\"minutou\";case\"mm\":return b||d?e+(fd(a)?\"minuty\":\"minut\"):e+\"minutami\";break;case\"h\":return b?\"hodina\":d?\"hodinu\":\"hodinou\";case\"hh\":return b||d?e+(fd(a)?\"hodiny\":\"hodin\"):e+\"hodinami\";break;case\"d\":return b||d?\"den\":\"dnem\";case\"dd\":return b||d?e+(fd(a)?\"dny\":\"dn\u00ed\"):e+\"dny\";break;case\"M\":return b||d?\"m\u011bs\u00edc\":\"m\u011bs\u00edcem\";case\"MM\":return b||d?e+(fd(a)?\"m\u011bs\u00edce\":\"m\u011bs\u00edc\u016f\"):e+\"m\u011bs\u00edci\";break;case\"y\":return b||d?\"rok\":\"rokem\";case\"yy\":return b||d?e+(fd(a)?\"roky\":\"let\"):e+\"lety\"}}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\twp.updates.updatePluginError = function( response ) {\n\t\tvar $card, $message, errorMessage;\n\n\t\tif ( ! wp.updates.isValidResponse( response, 'update' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( wp.updates.maybeHandleCredentialError( response, 'update-plugin' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorMessage = wp.updates.l10n.updateFailed.replace( '%s', response.errorMessage );\n\n\t\tif ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {\n\t\t\t$message = $( 'tr[data-plugin=\"' + response.plugin + '\"]' ).find( '.update-message' );\n\t\t\t$message.removeClass( 'updating-message notice-warning' ).addClass( 'notice-error' ).find( 'p' ).html( errorMessage );\n\t\t} else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {\n\t\t\t$card = $( '.plugin-card-' + response.slug )\n\t\t\t\t.addClass( 'plugin-card-update-failed' )\n\t\t\t\t.append( wp.updates.adminNotice( {\n\t\t\t\t\tclassName: 'update-message notice-error notice-alt is-dismissible',\n\t\t\t\t\tmessage: errorMessage\n\t\t\t\t} ) );\n\n\t\t\t$card.find( '.update-now' )\n\t\t\t\t.attr( 'aria-label', wp.updates.l10n.updateFailedLabel.replace( '%s', response.pluginName ) )\n\t\t\t\t.text( wp.updates.l10n.updateFailedShort ).removeClass( 'updating-message' );\n\n\t\t\t$card.on( 'click', '.notice.is-dismissible .notice-dismiss', function() {\n\n\t\t\t\t// Use same delay as the total duration of the notice fadeTo + slideUp animation.\n\t\t\t\tsetTimeout( function() {\n\t\t\t\t\t$card\n\t\t\t\t\t\t.removeClass( 'plugin-card-update-failed' )\n\t\t\t\t\t\t.find( '.column-name a' ).focus();\n\n\t\t\t\t\t$card.find( '.update-now' )\n\t\t\t\t\t\t.attr( 'aria-label', false )\n\t\t\t\t\t\t.text( wp.updates.l10n.updateNow );\n\t\t\t\t}, 200 );\n\t\t\t} );\n\t\t}\n\n\t\twp.a11y.speak( errorMessage, 'assertive' );\n\n\t\t$document.trigger( 'wp-plugin-update-error', response );\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t_refreshItems: function(event) {\n\n\t\tthis.items = [];\n\t\tthis.containers = [this];\n\n\t\tvar i, j, cur, inst, targetData, _queries, item, queriesLength,\n\t\t\titems = this.items,\n\t\t\tqueries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],\n\t\t\tconnectWith = this._connectWith();\n\n\t\tif(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down\n\t\t\tfor (i = connectWith.length - 1; i >= 0; i--){\n\t\t\t\tcur = $(connectWith[i], this.document[0]);\n\t\t\t\tfor (j = cur.length - 1; j >= 0; j--){\n\t\t\t\t\tinst = $.data(cur[j], this.widgetFullName);\n\t\t\t\t\tif(inst && inst !== this && !inst.options.disabled) {\n\t\t\t\t\t\tqueries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);\n\t\t\t\t\t\tthis.containers.push(inst);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (i = queries.length - 1; i >= 0; i--) {\n\t\t\ttargetData = queries[i][1];\n\t\t\t_queries = queries[i][0];\n\n\t\t\tfor (j=0, queriesLength = _queries.length; j < queriesLength; j++) {\n\t\t\t\titem = $(_queries[j]);\n\n\t\t\t\titem.data(this.widgetName + \"-item\", targetData); // Data for target checking (mouse manager)\n\n\t\t\t\titems.push({\n\t\t\t\t\titem: item,\n\t\t\t\t\tinstance: targetData,\n\t\t\t\t\twidth: 0, height: 0,\n\t\t\t\t\tleft: 0, top: 0\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " getPathInfo(assetPath) {\n return path.parse(assetPath.toLowerCase())\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\"\")},commit:function(a,d){this.getValue()?d.setAttribute(\"border\",this.getValue()):d.removeAttribute(\"border\")}},{id:\"cmbAlign\",type:\"select\",requiredContent:\"table[align]\",\"default\":\"\",label:a.lang.common.align,items:[[a.lang.common.notSet,\"\"],[a.lang.common.alignLeft,\"left\"],[a.lang.common.alignCenter,\"center\"],[a.lang.common.alignRight,\"right\"]],setup:function(a){this.setValue(a.getAttribute(\"align\")||\"\")},commit:function(a,d){this.getValue()?d.setAttribute(\"align\",this.getValue()):d.removeAttribute(\"align\")}}]},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $scope.reset = function() {\n bootbox.confirm('Are you sure you want to reset the foreign source definition to the default ?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.deleteForeignSourceDefinition($scope.foreignSource).then(\n function() { // success\n growl.success('The foreign source definition for ' + _.escape($scope.foreignSource) + 'has been reseted.');\n $scope.initialize();\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $scope.updateUser = function ($event) {\n $event.preventDefault()\n\n var id = $('div[data-user_id]').attr('data-user_id')\n if (_.isUndefined(id)) return\n var data = getFormData()\n\n if (\n data.fullname.toString().length > 25 ||\n data.password.toString().length > 255 ||\n data.cPassword.toString().length > 255 ||\n data.email.toString().length > 255 ||\n !validateEmail(data.email.toString())\n ) {\n helpers.UI.showSnackbar('Form data invalid.', true)\n return false\n }\n\n $http\n .put('/api/v1/users/' + data.username, {\n aId: id,\n aFullname: data.fullname,\n aPass: data.password,\n aPassConfirm: data.cPassword,\n aEmail: data.email,\n\n saveGroups: false\n })\n .success(function () {\n resetForm()\n helpers.UI.showSnackbar({\n text: 'Profile Successfully Saved',\n textColor: '#f8f8f2'\n })\n })\n .error(function (e) {\n $log.log('[trudesk:profile:updateUser] - ' + e.error.message)\n helpers.UI.showSnackbar('Error ' + e.error.message, true)\n })\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "function flexibleAddSighting(clicked, type, attribute_id, event_id, value, page, placement) {\n var $clicked = $(clicked);\n var hoverbroken = false;\n $clicked.off('mouseleave.temp').on('mouseleave.temp', function() {\n hoverbroken = true;\n });\n setTimeout(function() {\n $clicked.off('mouseleave.temp');\n if ($clicked.is(\":hover\") && !hoverbroken) {\n var html = '
    '\n + ''\n + ''\n + '
    ';\n openPopover(clicked, html, true, placement);\n }\n }, 1000);\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "(z=2);return z};var I=mxVertexHandler.prototype.getSelectionBorderBounds;mxVertexHandler.prototype.getSelectionBorderBounds=function(){return I.apply(this,arguments).grow(-this.getSelectionBorderInset())};var V=null,Q=mxVertexHandler.prototype.createCustomHandles;mxVertexHandler.prototype.createCustomHandles=function(){null==V&&(V=mxCellRenderer.defaultShapes.tableLine);var z=Q.apply(this,arguments);if(this.graph.isTable(this.state.cell)){var L=function(Ta,za,wa){for(var Ea=[],Da=0;Da 2 && arguments[2] !== undefined ? arguments[2] : {};\n var tracking = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var internalPath = path;\n options = _objectSpread({\n \"transformRead\": returnWhatWasGiven,\n \"transformKey\": returnWhatWasGiven,\n \"transformWrite\": returnWhatWasGiven\n }, options); // No object data\n\n if (obj === undefined || obj === null) {\n return;\n } // No path string\n\n\n if (!internalPath) {\n return;\n }\n\n internalPath = clean(internalPath); // Path is not a string, throw error\n\n if (typeof internalPath !== \"string\") {\n throw new Error(\"Path argument must be a string\");\n }\n\n if ((0, _typeof2[\"default\"])(obj) !== \"object\") {\n return;\n }\n\n var newObj = decouple(obj, options); // Path has no dot-notation, set key/value\n\n if (isNonCompositePath(internalPath)) {\n var unescapedPath = unEscape(internalPath); // Do not allow prototype pollution\n\n if (unescapedPath === \"__proto__\") return obj;\n\n if (newObj.hasOwnProperty(unescapedPath)) {\n delete newObj[options.transformKey(unescapedPath)];\n return newObj;\n }\n\n tracking.returnOriginal = true;\n return obj;\n }\n\n var pathParts = split(internalPath);\n var pathPart = pathParts.shift();\n var transformedPathPart = options.transformKey(unEscape(pathPart)); // Do not allow prototype pollution\n\n if (transformedPathPart === \"__proto__\") return obj;\n var childPart = newObj[transformedPathPart];\n\n if (!childPart) {\n // No child part available, nothing to unset!\n tracking.returnOriginal = true;\n return obj;\n }\n\n newObj[transformedPathPart] = unSet(childPart, pathParts.join('.'), options, tracking);\n\n if (tracking.returnOriginal) {\n return obj;\n }\n\n return newObj;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "function(){g({message:JSON.parse(n.result).Message})},n.readAsText(L.response))}catch(y){g({})}});L.send(v)}else try{this.doImportVisio(c,e,g,k)}catch(M){g(M)}}else this.spinner.stop(),this.handleError({message:mxResources.get(\"serviceUnavailableOrBlocked\")})});this.doImportVisio||this.loadingExtensions||this.isOffline(!0)?q():(this.loadingExtensions=!0,mxscript(\"js/extensions.min.js\",q))};EditorUi.prototype.importGraphML=function(c,e,g){g=null!=g?g:mxUtils.bind(this,function(m){this.handleError(m)});", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "this.spacing=0}function Ca(){mxArrowConnector.call(this);this.spacing=0}function Ra(){mxActor.call(this)}function ab(){mxRectangleShape.call(this)}function Ka(){mxActor.call(this)}function bb(){mxActor.call(this)}function Pa(){mxActor.call(this)}function Za(){mxActor.call(this)}function z(){mxActor.call(this)}function L(){mxActor.call(this)}function M(){mxActor.call(this)}function T(){mxActor.call(this)}function ca(){mxActor.call(this)}function ia(){mxActor.call(this)}function ma(){mxEllipse.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "c=mb[c];return null!=c?c(this.state):null}}else Graph.createHandle=function(){},Graph.handleFactory={};var rb=new mxPoint(1,0),zb=new mxPoint(1,0),Bb=mxUtils.toRadians(-30);rb=mxUtils.getRotatedPoint(rb,Math.cos(Bb),Math.sin(Bb));var Ab=mxUtils.toRadians(-150);zb=mxUtils.getRotatedPoint(zb,Math.cos(Ab),Math.sin(Ab));mxEdgeStyle.IsometricConnector=function(c,l,x,p,v){var A=c.view;p=null!=p&&0=k.scrollHeight-k.offsetHeight&&C()},mxEvent.addListener(k,\"scroll\",B))}),y)});t()};GitHubClient.prototype.logout=function(){this.clearPersistentToken();this.setUser(null);b=null}})();TrelloFile=function(b,e,f){DrawioFile.call(this,b,e);this.meta=f;this.saveNeededCounter=0};mxUtils.extend(TrelloFile,DrawioFile);TrelloFile.prototype.getHash=function(){return\"T\"+encodeURIComponent(this.meta.compoundId)};TrelloFile.prototype.getMode=function(){return App.MODE_TRELLO};TrelloFile.prototype.isAutosave=function(){return!0};TrelloFile.prototype.getTitle=function(){return this.meta.name};TrelloFile.prototype.isRenamable=function(){return!1};TrelloFile.prototype.getSize=function(){return this.meta.bytes};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " strict: function(obj, name, loc) {\n if (!obj || !(name in obj)) {\n throw new Exception('\"' + name + '\" not defined in ' + obj, {\n loc: loc\n });\n }\n return container.lookupProperty(obj, name);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "function getBlockNodes(nodes) {\n // TODO(perf): update `nodes` instead of creating a new object?\n var node = nodes[0];\n var endNode = nodes[nodes.length - 1];\n var blockNodes;\n\n for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {\n if (blockNodes || nodes[i] !== node) {\n if (!blockNodes) {\n blockNodes = jqLite(slice.call(nodes, 0, i));\n }\n blockNodes.push(node);\n }\n }\n\n return blockNodes || nodes;\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "Suite.prototype.eachTest = function(fn) {\n utils.forEach(this.tests, fn);\n utils.forEach(this.suites, function(suite) {\n suite.eachTest(fn);\n });\n return this;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "b.apply(d)},a||0)},trim:function(){var b=/(?:^[ \\t\\n\\r]+)|(?:[ \\t\\n\\r]+$)/g;return function(a){return a.replace(b,\"\")}}(),ltrim:function(){var b=/^[ \\t\\n\\r]+/g;return function(a){return a.replace(b,\"\")}}(),rtrim:function(){var b=/[ \\t\\n\\r]+$/g;return function(a){return a.replace(b,\"\")}}(),indexOf:function(b,a){if(typeof a==\"function\")for(var d=0,g=b.length;d'):U+('')}U+=\"\";if(b.isEnabled()&&!b.isCellLocked(b.getDefaultParent())){F=this.createStyle(\"stencil(\"+Graph.compress(U)+\")\");U=b.view.scale;X=b.view.translate;F=new mxCell(\"\",new mxGeometry(H/U-X.x,V/U-X.y,J/U,S/U),F);F.vertex=1;b.model.beginUpdate();try{F=b.addCell(F),b.fireEvent(new mxEventObject(\"cellsInserted\",\"cells\",[F])),b.fireEvent(new mxEventObject(\"freehandInserted\",\"cell\",F))}finally{b.model.endUpdate()}B&&\nb.setSelectionCells([F])}}for(F=0;F {\n if (!outputFile || !options || !options.seconds || !options.sampleRate || !options.numOfChannels)\n return reject(new Error('malformed props to createMuteOgg'));\n if (!Number.isInteger(options.seconds) ||\n !Number.isInteger(options.sampleRate) ||\n !Number.isInteger(options.numOfChannels))\n return reject(new Error('malformed numerico options prop for createMuteOgg'));\n const ch = options.numOfChannels === 1 ? 'mono' : 'stereo';\n child_process_1.exec('ffmpeg -f lavfi -i anullsrc=r=' +\n options.sampleRate +\n ':cl=' +\n ch +\n ' -t ' +\n options.seconds +\n ' -c:a libvorbis ' +\n outputFile, (error, stdout, stderr) => {\n if (error)\n return reject(error);\n resolve(true);\n });\n });\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\"geTempDlgCreateBtn geTempDlgBtnDisabled\")}function y(fa,ca){if(null!=I){var ba=function(oa){qa.isExternal?e(qa,function(na){ja(na,oa)},ia):qa.url?mxUtils.get(TEMPLATE_PATH+\"/\"+qa.url,mxUtils.bind(this,function(na){200<=na.getStatus()&&299>=na.getStatus()?ja(na.getText(),oa):ia()})):ja(b.emptyDiagramXml,oa)},ja=function(oa,na){x||b.hideDialog(!0);f(oa,na,qa,ca)},ia=function(){A(mxResources.get(\"cannotLoad\"));ma()},ma=function(){I=qa;Ba.className=\"geTempDlgCreateBtn\";ca&&(Ka.className=\"geTempDlgOpenBtn\")},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " assign: function(id, value) {\n if (!id) return;\n this.current().body.push(id, '=', value, ';');\n return id;\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "c.getMode())try{this.addRecent({id:c.getHash(),title:c.getTitle(),mode:c.getMode()})}catch(v){}try{mxSettings.setOpenCounter(mxSettings.getOpenCounter()+1),mxSettings.save()}catch(v){}}catch(v){this.fileLoadedError=v;if(null!=c)try{c.close()}catch(x){}if(EditorUi.enableLogging&&!this.isOffline())try{EditorUi.logEvent({category:\"ERROR-LOAD-FILE-\"+(null!=c?c.getHash():\"none\"),action:\"message_\"+v.message,label:\"stack_\"+v.stack})}catch(x){}c=mxUtils.bind(this,function(){null!=urlParams.url&&this.spinner.spin(document.body,\nmxResources.get(\"reconnecting\"))?window.location.search=this.getSearch([\"url\"]):null!=g?this.fileLoaded(g)||m():m()});e?c():this.handleError(v,mxResources.get(\"errorLoadingFile\"),c,!0,null,null,!0)}else m();return k};EditorUi.prototype.getHashValueForPages=function(c,e){var g=0,k=new mxGraphModel,m=new mxCodec;null!=e&&(e.byteCount=0,e.attrCount=0,e.eltCount=0,e.nodeCount=0);for(var q=0;q 1) {\n return rimraf(self._path, function (er) {\n if (er) return self.error(er)\n self._old = null\n create(self)\n })\n }\n\n // otherwise, just handle in the app-specific way\n // this creates a fs.WriteStream, or mkdir's, or whatever\n create(self)\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "-1;d=b.parent?b.getIndex():-1}return c>d?1:-1})},param:function(a){a.children=[];a.isEmpty=true;return a},span:function(a){a.attributes[\"class\"]==\"Apple-style-span\"&&delete a.name},html:function(a){delete a.attributes.contenteditable;delete a.attributes[\"class\"]},body:function(a){delete a.attributes.spellcheck;delete a.attributes.contenteditable},style:function(a){var b=a.children[0];if(b&&b.value)b.value=CKEDITOR.tools.trim(b.value);if(!a.attributes.type)a.attributes.type=\"text/css\"},title:function(a){var b=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function makeMap(str) {\n\tvar obj = {},\n\t\titems = str.split(\",\"),\n\t\ti;\n\tfor (i = 0; i < items.length; i++) {\n\t\tobj[items[i]] = true;\n\t}\n\treturn obj;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " address() {\n return this._srv.address();\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " $scope.removeAllNodes = function(foreignSource) {\n bootbox.confirm('Are you sure you want to remove all the nodes from ' + foreignSource + '?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.removeAllNodesFromRequisition(foreignSource).then(\n function() { // success\n growl.success('All the nodes from ' + foreignSource + ' have been removed, and the requisition has been synchronized.');\n var req = $scope.requisitionsData.getRequisition(foreignSource);\n req.reset();\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=\nc.value&&c.value.nodeType==mxConstants.NODETYPE_ELEMENT){var e=d;d=mxUtils.importNode(b.document,c.value,!0);d.appendChild(e);b=e.getAttribute(\"id\");d.setAttribute(\"id\",b);e.removeAttribute(\"id\")}return d};a.beforeDecode=function(b,c,d){var e=c.cloneNode(!0),f=this.getName();c.nodeName!=f?(e=c.getElementsByTagName(f)[0],null!=e&&e.parentNode==c?(mxUtils.removeWhitespace(e,!0),mxUtils.removeWhitespace(e,!1),e.parentNode.removeChild(e)):e=null,d.value=c.cloneNode(!0),c=d.value.getAttribute(\"id\"),null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " get: function () {\n return this._escape_for_html;\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(Ta){var za=Fa[Ta],wa=Taa?b||d?\"minute\":\"minutami\":b||d?\"minut\":\"minutami\";case\"h\":return b?\"ena ura\":\"eno uro\";case\"hh\":return e+=1===a?b?\"ura\":\"uro\":2===a?b||d?\"uri\":\"urama\":5>a?b||d?\"ure\":\"urami\":b||d?\"ur\":\"urami\";case\"d\":return b||d?\"en dan\":\"enim dnem\";case\"dd\":return e+=1===a?b||d?\"dan\":\"dnem\":2===a?b||d?\"dni\":\"dnevoma\":b||d?\"dni\":\"dnevi\";case\"M\":return b||d?\"en mesec\":\"enim mesecem\";case\"MM\":return e+=1===a?b||d?\"mesec\":\"mesecem\":2===a?b||d?\"meseca\":\"mesecema\":5>a?b||d?\"mesece\":\"meseci\":b||d?\"mesecev\":\"meseci\";case\"y\":return b||d?\"eno leto\":\"enim letom\";case\"yy\":return e+=1===a?b||d?\"leto\":\"letom\":2===a?b||d?\"leti\":\"letoma\":5>a?b||d?\"leta\":\"leti\":b||d?\"let\":\"leti\"}}function Nd(a){var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"leS\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"waQ\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"nem\":b+\" pIq\"}function Od(a){var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"Hu\u2019\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"wen\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"ben\":b+\" ret\"}function Pd(a,b,c,d){var e=Qd(a);switch(c){case\"mm\":return e+\" tup\";case\"hh\":return e+\" rep\";case\"dd\":return e+\" jaj\";case\"MM\":return e+\" jar\";case\"yy\":return e+\" DIS\"}}function Qd(a){var b=Math.floor(a%1e3/100),c=Math.floor(a%100/10),d=a%10,e=\"\";return b>0&&(e+=Sg[b]+\"vatlh\"),c>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[c]+\"maH\"),d>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[d]),\"\"===e?\"pagh\":e}function Rd(a,b,c,d){var e={s:[\"viensas secunds\",\"'iensas secunds\"],m:[\"'n m\u00edut\",\"'iens m\u00edut\"],mm:[a+\" m\u00eduts\",\"\"+a+\" m\u00eduts\"],h:[\"'n \u00feora\",\"'iensa \u00feora\"],hh:[a+\" \u00feoras\",\"\"+a+\" \u00feoras\"],d:[\"'n ziua\",\"'iensa ziua\"],dd:[a+\" ziuas\",\"\"+a+\" ziuas\"],M:[\"'n mes\",\"'iens mes\"],MM:[a+\" mesen\",\"\"+a+\" mesen\"],y:[\"'n ar\",\"'iens ar\"],yy:[a+\" ars\",\"\"+a+\" ars\"]};return d?e[c][0]:b?e[c][0]:e[c][1]}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "P)this.editPlantUmlData(D,G,P);else if(P=this.graph.getAttributeForCell(D,\"mermaidData\"),null!=P)this.editMermaidData(D,G,P);else{var K=g.getCellStyle(D);\"1\"==mxUtils.getValue(K,\"metaEdit\",\"0\")?d.showDataDialog(D):k.apply(this,arguments)}}catch(F){d.handleError(F)}};g.getLinkTitle=function(D){return d.getLinkTitle(D)};g.customLinkClicked=function(D){var G=!1;try{d.handleCustomLink(D),G=!0}catch(P){d.handleError(P)}return G};var l=g.parseBackgroundImage;g.parseBackgroundImage=function(D){var G=l.apply(this,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "m=P.name;v=\"\";O(null,!0)})));k.appendChild(F)})(D[G],G)}100==D.length&&(k.appendChild(A),B=function(){k.scrollTop>=k.scrollHeight-k.offsetHeight&&C()},mxEvent.addListener(k,\"scroll\",B))}),y)});t()};GitHubClient.prototype.logout=function(){this.clearPersistentToken();this.setUser(null);b=null}})();TrelloFile=function(b,e,f){DrawioFile.call(this,b,e);this.meta=f;this.saveNeededCounter=0};mxUtils.extend(TrelloFile,DrawioFile);TrelloFile.prototype.getHash=function(){return\"T\"+encodeURIComponent(this.meta.compoundId)};TrelloFile.prototype.getMode=function(){return App.MODE_TRELLO};TrelloFile.prototype.isAutosave=function(){return!0};TrelloFile.prototype.getTitle=function(){return this.meta.name};TrelloFile.prototype.isRenamable=function(){return!1};TrelloFile.prototype.getSize=function(){return this.meta.bytes};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "this.unitListener=function(n,y){g.setUnit(y.getProperty(\"unit\"))};x.addListener(mxEvent.SIZE,f);x.container.addEventListener(\"scroll\",d);x.view.addListener(\"unitChanged\",this.unitListener);b.addListener(\"pageViewChanged\",this.pageListener);b.addListener(\"pageScaleChanged\",this.pageListener);b.addListener(\"pageFormatChanged\",this.pageListener);this.setStyle=function(n){k=n;m.style.background=k.bkgClr;z()};this.origGuideMove=mxGuide.prototype.move;mxGuide.prototype.move=function(n,y,K,B){if(l&&4';L.setAttribute(\"title\",mxResources.get(\"showResolved\"));", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "ca,ca,!1)[0];ia.push(Fa);if(L)T.add(ya,ua[M]);else{var Ma=ya.getIndex(z[M]);T.add(ya,ua[M],Ma+1)}if(this.isTable(ya)){var Oa=this.getCellGeometry(ua[M]),Qa=this.getCellGeometry(ya);null!=Oa&&null!=Qa&&(Qa=Qa.clone(),Qa.height+=Oa.height,T.setGeometry(ya,Qa))}}else ia.push(ua[M])}this.updateCustomLinks(this.createCellMapping(ma,pa),ua,this);this.fireEvent(new mxEventObject(mxEvent.CELLS_ADDED,\"cells\",ua))}finally{T.endUpdate()}return ia};Graph.prototype.insertImage=function(z,L,M){if(null!=z&&null!=\nthis.cellEditor.textarea){for(var T=this.cellEditor.textarea.getElementsByTagName(\"img\"),ca=[],ia=0;iaFa.webUrl.indexOf(\"sharepoint.com/\")){var Ea=Fa.displayName||Fa.name,Da=mxUtils.htmlEntities(Fa.description||Ea);fa&&(Fa.folder=2==fa?{isRoot:!0}:!0);var La=null!=Fa.folder;if(!g||La){var Aa=document.createElement(\"tr\");Aa.className=Ga++%2?\"odOddRow\":\"odEvenRow\";var ta=document.createElement(\"td\");ta.style.width=\"36px\";var ka=document.createElement(\"img\");ka.src=\"/images/\"+(La?\"folder.png\":\"file.png\");ka.className=\"odFileImg\";ta.appendChild(ka);Aa.appendChild(ta);ta=document.createElement(\"td\");\nLa=document.createElement(\"div\");La.className=\"odFileTitle\";La.innerHTML=mxUtils.htmlEntities(Ea);La.setAttribute(\"title\",Da);ta.appendChild(La);Aa.appendChild(ta);Ca.appendChild(Aa);null==za&&(za=Aa,za.className+=\" odRowSelected\",H=Fa,S=N,x||e(H));(function(oa,sa){Aa.addEventListener(\"dblclick\",t);Aa.addEventListener(\"click\",function(){za!=sa&&(za.className=za.className.replace(\"odRowSelected\",\"\"),za=sa,za.className+=\" odRowSelected\",H=oa,S=N,x||e(H))})})(Fa,Aa)}}}0==Ga?(ra=document.createElement(\"div\"),\nra.className=\"odEmptyFolder\",ra.innerHTML=mxUtils.htmlEntities(mxResources.get(\"folderEmpty\",null,\"Folder is empty!\")),va.appendChild(ra)):va.appendChild(Ca);O();V=!1}if(!V){y(\".odCatsList\").style.display=\"block\";y(\".odFilesSec\").style.display=\"block\";null!=E&&(E.innerHTML=\"\",E.style.top=\"50%\");var Z=V=!0,fa=0;W=arguments;var aa=setTimeout(function(){V=Z=!1;P.stop();d(mxResources.get(\"timeout\"))},2E4),va=y(\".odFilesList\");va.innerHTML=\"\";P.spin(va);switch(N){case \"recent\":M=[{name:mxResources.get(\"recent\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "Client.prototype.destroy = function() {\n this._sock && this._sock.destroy();\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "M.scrollCellToVisible(M.getSelectionCell())}}}else{J=function(U){var Q=H[U];null==Q&&(Q=new mxCell(U,new mxGeometry(0,0,80,30),\"whiteSpace=wrap;html=1;\"),Q.vertex=!0,H[U]=Q,y.push(Q));return Q};var H={};y=[];for(F=0;F\");2<=S.length&&(N=J(S[0]),E=J(S[S.length-1]),S=new mxCell(2');if(\"undefined\"==typeof b||\"\"==b)b=\"Unknown error\";$(\".fc_popup\").html(b);b=set_popup_title();$(\".fc_popup\").dialog({modal:!0,show:\"fade\",closeOnEscape:!0,title:b,buttons:[{text:\"Ok\",click:function(){$(\".fc_popup\").dialog(\"destroy\")},\"class\":\"submit\"}]})}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "Suite.prototype.slow = function(ms){\n if (0 === arguments.length) return this._slow;\n if ('string' == typeof ms) ms = milliseconds(ms);\n debug('slow %d', ms);\n this._slow = ms;\n return this;\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "k&&k(q)})):p(\"\")};EditorUi.prototype.updateDiagram=function(d){function g(K){var F=new mxCellOverlay(K.image||p.warningImage,K.tooltip,K.align,K.valign,K.offset);F.addListener(mxEvent.CLICK,function(H,S){l.alert(K.tooltip)});return F}var k=null,l=this;if(null!=d&&0{label}'),i=/\\'/g;CKEDITOR.ui.panel.prototype.addListBlock=function(a,b){return this.addBlock(a,new CKEDITOR.ui.listBlock(this.getHolderElement(),b))};CKEDITOR.ui.listBlock=CKEDITOR.tools.createClass({base:CKEDITOR.ui.panel.block,$:function(a,b){var b=b||{},c=b.attributes||(b.attributes={});(this.multiSelect=!!b.multiSelect)&&(c[\"aria-multiselectable\"]=!0);!c.role&&(c.role=\"listbox\");this.base.apply(this,arguments);this.element.setAttribute(\"role\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function(u){var E=this.graph.getCustomFonts();if(0T.indexOf(\"mxPageSelector\")&&0 current) {\n var message = $.sprintf(PMA_messages['strNewerVersion'], data['version'], data['date']);\n if (Math.floor(latest / 10000) == Math.floor(current / 10000)) {\n /* Security update */\n klass = 'error';\n } else {\n klass = 'notice';\n }\n $('#maincontainer').after('
    ' + message + '
    ');\n }\n if (latest == current) {\n version_information_message = ' (' + PMA_messages['strUpToDate'] + ')';\n }\n $('#li_pma_version').append(version_information_message);\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "[c,l,x])))};mxCellRenderer.registerShape(\"filledEdge\",Da);\"undefined\"!==typeof StyleFormatPanel&&function(){var c=StyleFormatPanel.prototype.getCustomColors;StyleFormatPanel.prototype.getCustomColors=function(){var l=this.editorUi.getSelectionState(),x=c.apply(this,arguments);\"umlFrame\"==l.style.shape&&x.push({title:mxResources.get(\"laneColor\"),key:\"swimlaneFillColor\",defaultValue:\"default\"});return x}}();mxMarker.addMarker(\"dash\",function(c,l,x,p,v,A,B,ha,K,xa){var na=v*(B+K+1),$a=A*(B+K+1);return function(){c.begin();", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " member: function(left, right, computed) {\n if (computed) return this.computedMember(left, right);\n return this.nonComputedMember(left, right);\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "this.ui.handleError({message:mxResources.get(\"fileNotFound\")})})))}else this.ui.spinner.stop(),this.ui.handleError({message:mxResources.get(\"invalidName\")})}}),mxResources.get(\"enterValue\"));this.ui.showDialog(P.container,300,80,!0,!1);P.init()}))),mxUtils.br(k),mxUtils.br(k));for(var G=0;G= 0; i--){\n\t\t\t\tthis.containers[i]._trigger(\"deactivate\", null, this._uiHash(this));\n\t\t\t\tif(this.containers[i].containerCache.over) {\n\t\t\t\t\tthis.containers[i]._trigger(\"out\", null, this._uiHash(this));\n\t\t\t\t\tthis.containers[i].containerCache.over = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif (this.placeholder) {\n\t\t\t//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!\n\t\t\tif(this.placeholder[0].parentNode) {\n\t\t\t\tthis.placeholder[0].parentNode.removeChild(this.placeholder[0]);\n\t\t\t}\n\t\t\tif(this.options.helper !== \"original\" && this.helper && this.helper[0].parentNode) {\n\t\t\t\tthis.helper.remove();\n\t\t\t}\n\n\t\t\t$.extend(this, {\n\t\t\t\thelper: null,\n\t\t\t\tdragging: false,\n\t\t\t\treverting: false,\n\t\t\t\t_noFinalSort: null\n\t\t\t});\n\n\t\t\tif(this.domPosition.prev) {\n\t\t\t\t$(this.domPosition.prev).after(this.currentItem);\n\t\t\t} else {\n\t\t\t\t$(this.domPosition.parent).prepend(this.currentItem);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\n\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "\t\tsize : function(file1, file2) { \n\t\t\tvar size1 = parseInt(file1.size) || 0,\n\t\t\t\tsize2 = parseInt(file2.size) || 0;\n\t\t\t\t\n\t\t\treturn size1 == size2 ? 0 : size1 > size2 ? 1 : -1;\n\t\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "b.$block&&!(a in{li:1,dt:1,dd:1})});this.setRules(\"br\",{breakAfterOpen:1});this.setRules(\"title\",{indent:0,breakAfterOpen:0});this.setRules(\"style\",{indent:0,breakBeforeClose:1});this.setRules(\"pre\",{breakAfterOpen:1,indent:0})},proto:{openTag:function(b){var a=this._.rules[b];this._.afterCloser&&(a&&a.needsSpace&&this._.needsSpace)&&this._.output.push(\"\\n\");this._.indent?this.indentation():a&&a.breakBeforeOpen&&(this.lineBreak(),this.indentation());this._.output.push(\"<\",b);this._.afterCloser=0},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tserialize: function(o) {\n\n\t\tvar items = this._getItemsAsjQuery(o && o.connected),\n\t\t\tstr = [];\n\t\to = o || {};\n\n\t\t$(items).each(function() {\n\t\t\tvar res = ($(o.item || this).attr(o.attribute || \"id\") || \"\").match(o.expression || (/(.+)[\\-=_](.+)/));\n\t\t\tif (res) {\n\t\t\t\tstr.push((o.key || res[1]+\"[]\")+\"=\"+(o.key && o.expression ? res[1] : res[2]));\n\t\t\t}\n\t\t});\n\n\t\tif(!str.length && o.key) {\n\t\t\tstr.push(o.key + \"=\");\n\t\t}\n\n\t\treturn str.join(\"&\");\n\n\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "html:\"\"},{type:\"vbox\",padding:0,children:[{type:\"text\",id:\"txtCaption\",requiredContent:\"caption\",label:a.lang.table.caption,setup:function(a){this.enable();a=a.getElementsByTag(\"caption\");if(0 {\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": 0, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " depthedLookup: function(name) {\n return [this.aliasable('container.lookup'), '(depths, \"', name, '\")'];\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-1321", "cwe_name": "Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')", "description": "The software receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.", "url": "https://cwe.mitre.org/data/definitions/1321.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\tplugin: $( this ).data( 'plugin' ),\n\t\t\t\t\tslug: $( this ).data( 'slug' )\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttarget.postMessage( JSON.stringify( job ), window.location.origin );\n\t\t});\n\n\t} );\n\n\t$( window ).on( 'message', function( e ) {\n\t\tvar event = e.originalEvent,\n\t\t\tmessage,\n\t\t\tloc = document.location,\n\t\t\texpectedOrigin = loc.protocol + '//' + loc.hostname;\n\n\t\tif ( event.origin !== expectedOrigin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tmessage = $.parseJSON( event.data );\n\n\t\tif ( typeof message.action === 'undefined' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch (message.action){\n\t\t\tcase 'decrementUpdateCount' :\n\t\t\t\twp.updates.decrementCount( message.upgradeType );\n\t\t\t\tbreak;\n\t\t\tcase 'updatePlugin' :\n\t\t\t\ttb_remove();\n\n\t\t\t\twp.updates.updateQueue.push( message );\n\t\t\t\twp.updates.queueChecker();\n\t\t\t\tbreak;\n\t\t}\n\n\t} );\n\n\t$( window ).on( 'beforeunload', wp.updates.beforeunload );\n\n})( jQuery, window.wp, window.pagenow, window.ajaxurl );", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "Q.style.overflow=\"hidden\";Q.style.textAlign=\"center\";var R=null;null!=D?(R={data:D,w:F,h:H,title:M},null!=V&&(R.aspect=V),A[D]=J,l.push(R)):null!=S&&(S.aspect=\"fixed\",l.push(S),R=S);mxEvent.addListener(Q,\"keydown\",function(Z){13==Z.keyCode&&null!=O&&(O(),O=null,mxEvent.consume(Z))});W();E.appendChild(Q);mxEvent.addListener(Q,\"mousedown\",function(Z){\"true\"!=Q.getAttribute(\"contentEditable\")&&mxEvent.consume(Z)});T=function(Z){if(mxClient.IS_IOS||mxClient.IS_FF||!(null==document.documentMode||9 i.material-icons');\n }\n\n \tif (inst.text() == 'volume_off'){\n \t\t$.post(this.wwwDir+ 'user/setsettingajax/new_chat_sound/1');\n \t\tconfLH.new_chat_sound_enabled = 1;\n \t\tinst.text('volume_up');\n \t} else {\n \t\t$.post(this.wwwDir+ 'user/setsettingajax/new_chat_sound/0');\n \t\tconfLH.new_chat_sound_enabled = 0;\n \t\tinst.text('volume_off');\n \t}\n \treturn false;\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " qtip: Tine.Tinebase.common.doubleEncode(attr.name),\n leaf: !!attr.account_grants,\n allowDrop: !!attr.account_grants && attr.account_grants.addGrant\n });\n \n // copy 'real' data to container space\n attr.container = Ext.copyTo({}, attr, Tine.Tinebase.Model.Container.getFieldNames());\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\t\t\t\t\t\t\ttitle : $('input:checked', uitype).val(),\n\t\t\t\t\t\t\t\t\t\t\ttext : 'confirmReq',\n\t\t\t\t\t\t\t\t\t\t\taccept : {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel : 'btnApply',\n\t\t\t\t\t\t\t\t\t\t\t\tcallback : function() { \n\t\t\t\t\t\t\t\t\t\t\t\t\tsave();\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tcancel : {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel : 'btnCancel',\n\t\t\t\t\t\t\t\t\t\t\t\tcallback : function() {}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (!((c >= 48 && c <= 57) || (c >= 96 && c <= 105))) {\n\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.filter(':first');\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t!fm.UA.Mobile && inputFirst.focus();\n\t\t\t\t\t\t\tresizable();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\treset.hover(function() { reset.toggleClass('ui-state-hover'); }).click(resetView);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t})", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\"/pid2/mxPidInstruments.js\"];mxStencilRegistry.libraries.pid2misc=[SHAPES_PATH+\"/pid2/mxPidMisc.js\",STENCIL_PATH+\"/pid/misc.xml\"];mxStencilRegistry.libraries.pid2valves=[SHAPES_PATH+\"/pid2/mxPidValves.js\"];mxStencilRegistry.libraries.pidFlowSensors=[STENCIL_PATH+\"/pid/flow_sensors.xml\"];mxMarker.getPackageForType=function(u){var D=null;null!=u&&0' + this.getHelper().escapeString(data.assignedUserName) + '';\n\n if (this.isUserStream) {\n if (this.assignedUserId) {\n if (this.assignedUserId == this.model.get('createdById')) {\n this.messageName += 'Self';\n } else {\n if (this.assignedUserId == this.getUser().id) {\n this.messageName += 'You';\n }\n }\n } else {\n this.messageName += 'Void';\n }\n } else {\n if (this.assignedUserId) {\n if (this.assignedUserId == this.model.get('createdById')) {\n this.messageName += 'Self';\n }\n } else {\n this.messageName += 'Void';\n }\n }\n\n this.createMessage();\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " const target = function(a, b) {\n return a + b;\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "\t\tfilter = function(hashes) {\n\t\t\tvar mixed = false,\n\t\t\t\tcroot = '';\n\t\t\t\n\t\t\tif (fm.searchStatus.state > 1 && fm.searchStatus.target === '') {\n\t\t\t\thashes = $.map(hashes, function(h) {\n\t\t\t\t\treturn fm.isCommandEnabled('download', h)? h : null;\n\t\t\t\t});\n\t\t\t\tcroot = fm.root(hashes[0]);\n\t\t\t\t$.each(hashes, function(i, h) {\n\t\t\t\t\tif (mixed = (croot !== fm.root(h))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tzipOn = (!mixed && fm.command('zipdl') && fm.isCommandEnabled('zipdl', croot));\n\t\t\t} else {\n\t\t\t\tif (!fm.isCommandEnabled('download', hashes[0])) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tzipOn = (fm.command('zipdl') && fm.isCommandEnabled('zipdl', hashes[0]));\n\t\t\t}\n\t\t\t\n\t\t\treturn (!zipOn)?\n\t\t\t\t\t$.map(self.files(hashes), function(f) { return f.mime == 'directory' ? null : f; })\n\t\t\t\t\t: self.files(hashes);\n\t\t};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "for(la=ma=0;la
    < '+mxResources.get(\"back\")+'
    '+", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " value = value.replace(/src=\" *javascript\\:(.*?)\"/gi, function(m, $1) {\n return 'removed=\"\"';\n });", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "TagCreationContainer.prototype._tagInputEnd = function (event, span, textfield) {\n var that = this;\n if (textfield.val() == '' || textfield.val() == '#') { // if no input, get rid of new tag\n that._removeTag (span);\n that._unlockCreateTag(); // we're done with this tag, so a let another get created\n } else { // create new tag\n var value = textfield.val();\n value = value.replace(/#/g, ''); // strip illegal chars\n value = '#' + encodeURIComponent(value); // format into a tag\n\n that._afterCreateNewTag (textfield, value, span);\n\n that._unlockCreateTag(); // we're done with this tag, so a let another get created\n }\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "module.exports = function (options) {\n return new OAuthServer(options);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "function assertNotHasOwnProperty(name, context) {\n if (name === 'hasOwnProperty') {\n throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);\n }\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\thelper : function(e) {\n\t\t\t\t\t\tvar dir = $(e.target).parent();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tdir.children().removeClass('ui-state-hover');\n\t\t\t\t\t\t\n\t\t\t\t\t\treturn $('
    ')\n\t\t\t\t\t\t\t\t.append($('
    ').show().append(dir.clone()));\n\n\t\t\t\t\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "J&&(J=b.shapeForegroundColor);return J};this.createStyle=function(J){var F=\";fillColor=none;\";O&&(F=\";lineShape=1;\");return mxConstants.STYLE_SHAPE+\"=\"+J+F};this.stopDrawing=function(){if(0 Date.parse(jsEOL[key].start) &&\n isEolReleased(key)\n }).map(function (key) {\n return 'node ' + key.slice(1)\n })\n return resolve(queries, context)\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " fn.assign = function(scope, value, locals) {\n return assign(scope, locals, value);\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "passwordComplexity.validate = password => {\n const response = passwordStrength(password, passwordComplexityOptions)\n return !(response.id === 0 || response.id === 1)\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-521", "cwe_name": "Weak Password Requirements", "description": "The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.", "url": "https://cwe.mitre.org/data/definitions/521.html", "label_name": "safe"} {"code": "M.push(E);A.appendChild(E);var D=function(oa){Ba.style.display=\"none\";fa.style.display=\"none\";Z.style.left=\"30px\";u(oa?-1:1);null==W&&(W=La);Z.scrollTop=0;Z.innerHTML=\"\";S.spin(Z);var sa=function(ya,wa,ua){H=0;S.stop();La=ya;ua=ua||{};var xa=0,ha;for(ha in ua)xa+=ua[ha].length;if(wa)Z.innerHTML=wa;else if(0==ya.length&&0==xa)Z.innerHTML=mxUtils.htmlEntities(mxResources.get(\"noDiagrams\",null,\"No Diagrams Found\"));else if(Z.innerHTML=\"\",0= agentKeys.length)\n return;\n if (++agentKeyPos >= agentKeys.length) {\n debug('DEBUG: Agent: No more keys left to try');\n debug('DEBUG: Client: agent auth failed');\n agentKeys = undefined;\n tryNextAuth();\n } else {\n debug('DEBUG: Agent: Trying key #' + (agentKeyPos + 1));\n stream.authPK(self.config.username, agentKeys[agentKeyPos]);\n stream.once('USERAUTH_PK_OK', onUSERAUTH_PK_OK);\n }\n }\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "q))},function(m){m=document.getElementById(\"geStatus\");null!=m&&(m.innerHTML=\"Error loading page. Please try refreshing.\",m.getElementsByTagName(\"a\")[0].onclick=function(){mxLanguage=\"en\";l(mxResources.getDefaultBundle(RESOURCE_BASE,mxLanguage)||mxResources.getSpecialBundle(RESOURCE_BASE,mxLanguage))})})}function d(){try{if(null!=mxSettings.settings){document.body.style.backgroundColor=\"dark\"==uiTheme||mxSettings.settings.darkMode?Editor.darkColor:\"#ffffff\";if(null!=mxSettings.settings.autosaveDelay){var k=\nparseInt(mxSettings.settings.autosaveDelay);!isNaN(k)&&0y.length){H.view.validate();var wa=new mxFastOrganicLayout(H);wa.forceConstant=3*fa;wa.disableEdgeStyle=!1;wa.resetEdges=!1;var Ea=wa.isVertexIgnored;wa.isVertexIgnored=function(Da){return Ea.apply(this,arguments)||0>mxUtils.indexOf(y,Da)};this.executeLayout(function(){wa.execute(H.getDefaultParent());Fa()},!0,u);u=null}}this.hideDialog()}finally{H.model.endUpdate()}null!=u&&u()}}catch(Da){this.handleError(Da)}};EditorUi.prototype.getSearch=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "Project.prototype.resolveMerge = function (file,resolutions) {\n var filePath = fspath.join(this.path,file);\n\n if (/^\\.\\./.test(fspath.relative(this.path,filePath))) {\n throw new Error(\"Invalid file name\")\n }\n\n var self = this;\n if (typeof resolutions === 'string') {\n return util.writeFile(filePath, resolutions).then(function() {\n return self.stageFile(file);\n })\n }\n return fs.readFile(filePath,\"utf8\").then(function(content) {\n var lines = content.split(\"\\n\");\n var result = [];\n var ignoreBlock = false;\n var currentBlock;\n for (var i=1;i<=lines.length;i++) {\n if (resolutions.hasOwnProperty(i)) {\n currentBlock = resolutions[i];\n if (currentBlock.selection === \"A\") {\n ignoreBlock = false;\n } else {\n ignoreBlock = true;\n }\n continue;\n }\n if (currentBlock) {\n if (currentBlock.separator === i) {\n if (currentBlock.selection === \"A\") {\n ignoreBlock = true;\n } else {\n ignoreBlock = false;\n }\n continue;\n } else if (currentBlock.changeEnd === i) {\n currentBlock = null;\n continue;\n } else if (ignoreBlock) {\n continue;\n }\n }\n result.push(lines[i-1]);\n }\n var finalResult = result.join(\"\\n\");\n return util.writeFile(filePath,finalResult).then(function() {\n return self.stageFile(file);\n })\n });\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " .replace(/^function *\\(.*\\) *{/, '')\n .replace(/\\s+\\}$/, '');\n\n var spaces = str.match(/^\\n?( *)/)[1].length\n , tabs = str.match(/^\\n?(\\t*)/)[1].length\n , re = new RegExp('^\\n?' + (tabs ? '\\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm');\n\n str = str.replace(re, '');\n\n return exports.trim(str);\n};\n\n/**\n * Escape regular expression characters in `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nexports.escapeRegexp = function(str) {\n return str.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n};\n\n/**\n * Trim the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nexports.trim = function(str) {\n return str.replace(/^\\s+|\\s+$/g, '');\n};\n\n/**\n * Parse the given `qs`.\n *\n * @param {String} qs\n * @return {Object}\n * @api private\n */\n\nexports.parseQuery = function(qs) {\n return exports.reduce(qs.replace('?', '').split('&'), function(obj, pair) {\n var i = pair.indexOf('=')\n , key = pair.slice(0, i)\n , val = pair.slice(++i);\n\n obj[key] = decodeURIComponent(val);\n return obj;\n }, {});\n};\n\n/**\n * Highlight the given string of `js`.\n *\n * @param {String} js\n * @return {String}\n * @api private\n */\n\nfunction highlight(js) {\n return js\n .replace(//g, '>')\n .replace(/\\/\\/(.*)/gm, '//$1')\n .replace(/('.*?')/gm, '$1')\n .replace(/(\\d+\\.\\d+)/gm, '$1')\n .replace(/(\\d+)/gm, '$1')\n .replace(/\\bnew *(\\w+)/gm, 'new $1')\n .replace(/\\b(function|new|throw|return|var|if|else)\\b/gm, '$1')\n}\n\n/**\n * Highlight the contents of tag `name`.\n *\n * @param {String} name\n * @api private\n */\n\nexports.highlightTags = function(name) {\n var code = document.getElementsByTagName(name);\n for (var i = 0, len = code.length; i < len; ++i) {\n code[i].innerHTML = highlight(code[i].innerHTML);\n }\n};\n\n}); // module: utils.js", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\t\t\tres.writeHead(200, _getServerHeaders({ \"Content-Type\": Array.isArray(mime)?mime[0]:mime, \"Content-Encoding\": \"gzip\" }, stats));\n\t\t\t\trawStream.pipe(zlib.createGzip()).pipe(res)\n\t\t\t\t.on(\"error\", err => _sendError(req, res, 500, `500: Error: ${err}`))\n\t\t\t\t.on(\"end\", _ => res.end());\n\t\t\t} else {\n\t\t\t\tres.writeHead(200, mime ? _getServerHeaders({\"Content-Type\":Array.isArray(mime)?mime[0]:mime}, stats) : _getServerHeaders({}, stats));\n\t\t\t\trawStream.on(\"data\", chunk => res.write(chunk, \"binary\"))\n\t\t\t\t\t.on(\"error\", err => _sendError(req, res, 500, `500: Error: ${err}`))\n\t\t\t\t\t.on(\"end\", _ => res.end());\n\t\t\t}\n\t\t}\n\t});\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "module.exports.skip = function skip() {\n return webpackVersionMajor < 2;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "function(qb,yb){var ub=tb.apply(this,arguments);return null==ub||qb.view.graph.isCustomLink(ub)?null:ub};pa.getLinkTargetForCellState=function(qb,yb){return qb.view.graph.getLinkTargetForCell(qb.cell)};pa.drawCellState=function(qb,yb){for(var ub=qb.view.graph,vb=null!=Ta?Ta.get(qb.cell):ub.isCellSelected(qb.cell),wb=ub.model.getParent(qb.cell);!(ia&&null==Ta||vb)&&null!=wb;)vb=null!=Ta?Ta.get(wb):ub.isCellSelected(wb),wb=ub.model.getParent(wb);(ia&&null==Ta||vb)&&gb.apply(this,arguments)};pa.drawState(this.getView().getState(this.model.root),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function g(D){D.dataTransfer.dropEffect=null!=B?\"move\":\"copy\";D.stopPropagation();D.preventDefault()}function k(D){D.stopPropagation();D.preventDefault();z=!1;I=v(D);if(null!=B)null!=I&&IB?I-1:I,0,l.splice(B,1)[0]),x.insertBefore(x.children[B],x.children[I])):(l.push(l.splice(B,1)[0]),x.appendChild(x.children[B]));else if(0this.status)if(\"txt\"==g)k(this.response);else{var A=new FileReader;A.readAsDataURL(this.response);A.onloadend=function(B){var I=new Image;I.onload=\nfunction(){try{var O=I.width,t=I.height;if(0==O&&0==t){var z=A.result,L=z.indexOf(\",\"),C=decodeURIComponent(escape(atob(z.substring(L+1)))),E=mxUtils.parseXml(C).getElementsByTagName(\"svg\");0= 0;\n }\n\n if (!isValid) {\n context.report({\n node,\n messageId: \"wrongQuotes\",\n data: {\n description: settings.description\n },\n fix(fixer) {\n if (quoteOption === \"backtick\" && astUtils.hasOctalEscapeSequence(rawVal)) {\n\n // An octal escape sequence in a template literal would produce syntax error, even in non-strict mode.\n return null;\n }\n\n return fixer.replaceText(node, settings.convert(node.raw));\n }\n });\n }\n }\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\"nowrap\";J.style.overflow=\"hidden\";J.style.textOverflow=\"ellipsis\";J.setAttribute(\"title\",F.title+\" (\"+F.id+\")\");var R=document.createElement(\"input\");R.setAttribute(\"type\",\"checkbox\");R.checked=b.sidebar.isEntryVisible(F.id);R.defaultChecked=R.checked;J.appendChild(R);mxUtils.write(J,\" \"+F.title);k.appendChild(J);var W=function(O){if(null==O||\"INPUT\"!=mxEvent.getSource(O).nodeName){m.style.textAlign=\"center\";m.style.padding=\"0px\";m.style.color=\"\";m.innerHTML=\"\";if(null!=F.desc){var V=document.createElement(\"pre\");\nV.style.boxSizing=\"border-box\";V.style.fontFamily=\"inherit\";V.style.margin=\"20px\";V.style.right=\"0px\";V.style.textAlign=\"left\";mxUtils.write(V,F.desc);m.appendChild(V)}null!=F.imageCallback?F.imageCallback(m):null!=F.image?m.innerHTML+='':null==F.desc&&(m.style.padding=\"20px\",m.style.color=\"rgb(179, 179, 179)\",mxUtils.write(m,mxResources.get(\"noPreview\")));null!=p&&(p.style.backgroundColor=\"\");p=J;p.style.backgroundColor=Editor.isDarkMode()?\"#000000\":\"#ebf2f9\";null!=\nO&&mxEvent.consume(O)}};mxEvent.addListener(J,\"click\",W);mxEvent.addListener(J,\"dblclick\",function(O){R.checked=!R.checked;mxEvent.consume(O)});v.push(function(){return R.checked?F.id:null});0==B&&0==H&&W()})(G.entries[H])})(A[B])});e=document.createElement(\"div\");e.className=\"geDialogTitle\";mxUtils.write(e,mxResources.get(\"shapes\"));e.style.position=\"absolute\";e.style.top=\"0px\";e.style.left=\"0px\";e.style.lineHeight=\"40px\";e.style.height=\"40px\";e.style.right=\"0px\";var k=document.createElement(\"div\"),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " this.goto_url = function(action, query, lock)\n {\n this.redirect(this.url(action, query), lock);\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "\t_title: function( title ) {\n\t\tif ( !this.options.title ) {\n\t\t\ttitle.html( \" \" );\n\t\t}\n\t\ttitle.text( this.options.title );\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "Graph.prototype.selectUnlockedLayer=function(){if(null==this.defaultParent){var u=this.model.getChildCount(this.model.root),E=0;do var J=this.model.getChildAt(this.model.root,E);while(E++
    ',b);b.setAttribute(\"title\",mxResources.get(\"pages\"));b.style.position=\"absolute\";b.style.marginLeft=\"0px\";b.style.top=\"0px\";b.style.left=\"1px\";var l=b.getElementsByTagName(\"div\")[0];l.style.display=\"inline-block\";l.style.marginTop=\"5px\";l.style.width=\"21px\";l.style.height=\"21px\";mxEvent.addListener(b,\"click\",mxUtils.bind(this,function(d){this.editor.graph.popupMenuHandler.hideMenu();\nvar u=new mxPopupMenu(mxUtils.bind(this,function(c,e){var g=mxUtils.bind(this,function(){for(var v=0;vS)\n // 'auth-agent@openssh.com' (S->C)\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: {}\n };\n }\n bufferParser.clear();\n\n if (channelInfo === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_OPEN (s:${sender}, ${type})`);\n\n const handler = self._handlers.CHANNEL_OPEN;\n if (handler) {\n handler(self, channelInfo);\n } else {\n self.channelOpenFail(\n channelInfo.sender,\n CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED,\n '',\n ''\n );\n }\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function createWebSocketUrl (options, request) {\n const source = new URL(request.url, 'http://127.0.0.1')\n\n const target = new URL(\n options.rewritePrefix || options.prefix || source.pathname,\n options.upstream\n )\n\n target.search = source.search\n\n return target\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\t\tdfrd.abort = function() {\n\t\t\txhr.state() == 'pending' && xhr.abort();\n\t\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "Ua.style.cursor=\"pointer\"):(Ua.setAttribute(\"disabled\",\"disabled\"),Ua.style.cursor=\"default\")},La.addListener(\"stateChanged\",za),I.addListener(\"enabledChanged\",za),za());return Ua}function ea(za,wa,Ea){Ea=document.createElement(\"div\");Ea.className=\"geMenuItem\";Ea.style.display=\"inline-block\";Ea.style.verticalAlign=\"top\";Ea.style.marginRight=\"6px\";Ea.style.padding=\"0 4px 0 4px\";Ea.style.height=\"30px\";Ea.style.position=\"relative\";Ea.style.top=\"0px\";\"1\"==urlParams.sketch&&(Ea.style.boxShadow=\"none\");\nfor(var Da=0;DaS.offsetTop-S.offsetHeight/2?\"70px\":\"10px\");else{for(var za=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "DriveFile&&c.isEditable()||c.constructor==DropboxFile)};EditorUi.prototype.getServiceName=function(){return\"draw.io\"};EditorUi.prototype.addRemoteServiceSecurityCheck=function(c){c.setRequestHeader(\"Content-Language\",\"da, mi, en, de-DE\")};EditorUi.prototype.loadUrl=function(c,e,g,k,m,q,v,x){EditorUi.logEvent(\"SHOULD NOT BE CALLED: loadUrl\");return this.editor.loadUrl(c,e,g,k,m,q,v,x)};EditorUi.prototype.loadFonts=function(c){EditorUi.logEvent(\"SHOULD NOT BE CALLED: loadFonts\");return this.editor.loadFonts(c)};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\tthis._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css(\"position\"), top: this.currentItem.css(\"top\"), left: this.currentItem.css(\"left\") };\n\t\t}\n\n\t\tif (!helper[0].style.width || o.forceHelperSize) {\n\t\t\thelper.width(this.currentItem.width());\n\t\t}\n\t\tif (!helper[0].style.height || o.forceHelperSize) {\n\t\t\thelper.height(this.currentItem.height());\n\t\t}\n\n\t\treturn helper;\n\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "b.type==CKEDITOR.NODE_ELEMENT;){if(e(b))return b;b=b.parent}return null},wrapWith:function(a){this.replaceWith(a);a.add(this);return a},getIndex:function(){return CKEDITOR.tools.indexOf(this.parent.children,this)},getFilterContext:function(a){return a||{}}}})();\"use strict\";CKEDITOR.htmlParser.comment=function(a){this.value=a;this._={isBlockLike:false}};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "ma);H.moveCells(ma,N,W)},!0,u);u=null}else if(\"organic\"==P||\"auto\"==P&&ma.length>y.length){H.view.validate();var wa=new mxFastOrganicLayout(H);wa.forceConstant=3*fa;wa.disableEdgeStyle=!1;wa.resetEdges=!1;var Ea=wa.isVertexIgnored;wa.isVertexIgnored=function(Da){return Ea.apply(this,arguments)||0>mxUtils.indexOf(y,Da)};this.executeLayout(function(){wa.execute(H.getDefaultParent());Fa()},!0,u);u=null}}this.hideDialog()}finally{H.model.endUpdate()}null!=u&&u()}}catch(Da){this.handleError(Da)}};EditorUi.prototype.getSearch=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\twp.updates.installTheme = function( args ) {\n\t\tvar $message = $( '.theme-install[data-slug=\"' + args.slug + '\"]' );\n\n\t\targs = _.extend( {\n\t\t\tsuccess: wp.updates.installThemeSuccess,\n\t\t\terror: wp.updates.installThemeError\n\t\t}, args );\n\n\t\t$message.addClass( 'updating-message' );\n\t\t$message.parents( '.theme' ).addClass( 'focus' );\n\t\tif ( $message.html() !== wp.updates.l10n.installing ) {\n\t\t\t$message.data( 'originaltext', $message.html() );\n\t\t}\n\n\t\t$message.text( wp.updates.l10n.installing );\n\t\twp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );\n\n\t\t// Remove previous error messages, if any.\n\t\t$( '.install-theme-info, [data-slug=\"' + args.slug + '\"]' ).removeClass( 'theme-install-failed' ).find( '.notice.notice-error' ).remove();\n\n\t\treturn wp.updates.ajax( 'install-theme', args );\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "String.prototype.escapeHTML = function(){\n /*\n HTML Escape Before Inserting Untrusted Data into HTML Element Content\n https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention\n _Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into\n _HTML_Element_Content\n */\n var s = this;\n if (!s) {\n return \"\";\n }\n s = s + \"\";\n return s.replace(/[\\&\"<>\\\\]/g, function(s) {\n switch(s) {\n case \"&\": return \"&\";\n case \"\\\\\": return \"\\";\n case \"`\": return '`';\n case \"'\": return ''';\n case '\"': return '"';\n case \"<\": return \"<\";\n case \">\": return \">\";\n default: return s;\n }\n });\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "a.lock();this._.savedSelection=a;return true}return false};CKEDITOR.editor.prototype.unlockSelection=function(a){var b=this._.savedSelection;if(b){b.unlock(a);delete this._.savedSelection;return true}return false};CKEDITOR.editor.prototype.forceNextSelectionCheck=function(){delete this._.selectionPreviousPath};CKEDITOR.dom.document.prototype.getSelection=function(){return new CKEDITOR.dom.selection(this)};CKEDITOR.dom.range.prototype.select=function(){var a=this.root instanceof CKEDITOR.editable?", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " let send = function() {\n if (i++ >= total) {\n return;\n }\n sendMessage(cb);\n setImmediate(send);\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "function print(s) {\n out.value += s + \"\\n\";\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.editorUi.editor.graph,X=U.getSelectionCell();P.call(this,M,X,null,W);this.addMenuItems(M,[\"editTooltip\"],W);U.model.isVertex(X)&&this.addMenuItems(M,[\"editGeometry\"],W);this.addMenuItems(M,[\"-\",\"edit\"],W)})));this.addPopupMenuCellEditItems=function(M,W,U,X){M.addSeparator();this.addSubmenu(\"editCell\",M,X,mxResources.get(\"edit\"))};this.put(\"file\",new Menu(mxUtils.bind(this,function(M,W){var U=C.getCurrentFile();C.menus.addMenuItems(M,[\"new\"],W);C.menus.addSubmenu(\"openFrom\",M,W);isLocalStorage&&", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "d.style.width=\"300px\";d.style.display=\"inline-flex\";d.style.justifyContent=\"center\";d.style.alignItems=\"center\";d.style.position=\"absolute\";var g=document.createElement(\"img\");g.onload=function(){function C(){l.model.setStyle(x,y+m())}l=new Graph(k);l.autoExtend=!1;l.autoScroll=!1;l.setGridEnabled(!1);l.setEnabled(!0);l.setPanning(!1);l.setConnectable(!1);l.getRubberband().setEnabled(!1);l.graphHandler.allowLivePreview=!1;var D=l.createVertexHandler;l.createVertexHandler=function(){var J=D.apply(this,\narguments);J.livePreview=!1;return J};if(null!=f)try{if(\"inset\"==f.substring(0,5)){var G=x.geometry,P=g.width,K=g.height,F=(300-P)/2,H=(300-K)/2,S=f.match(/\\(([^)]+)\\)/)[1].split(/[ ,]+/),V=parseFloat(S[0]),M=parseFloat(S[1]),W=parseFloat(S[2]),U=parseFloat(S[3]);isFinite(V)&&isFinite(M)&&isFinite(W)&&isFinite(U)?(G.x=U/100*P+F,G.y=V/100*K+H,G.width=(100-M)/100*P+F-G.x,G.height=(100-W)/100*K+H-G.y,\"round\"==S[4]?\"50%\"==S[5]?I.setAttribute(\"checked\",\"checked\"):(q=parseInt(S[5]),t.value=q,B.setAttribute(\"checked\",\n\"checked\"),O.style.visibility=\"visible\"):A.setAttribute(\"checked\",\"checked\")):f=null}else f=null}catch(J){}x.style=y+(f?f:m());x.vertex=!0;l.addCell(x,null,null,null,null);l.selectAll();l.addListener(mxEvent.CELLS_MOVED,C);l.addListener(mxEvent.CELLS_RESIZED,C);var X=l.graphHandler.mouseUp,u=l.graphHandler.mouseDown;l.graphHandler.mouseUp=function(){X.apply(this,arguments);k.style.backgroundColor=\"#fff9\"};l.graphHandler.mouseDown=function(){u.apply(this,arguments);k.style.backgroundColor=\"\"};l.dblClick=\nfunction(){};var E=l.getSelectionModel().changeSelection;l.getSelectionModel().changeSelection=function(){E.call(this,[x],[x])}};g.onerror=function(){g.onload=null;g.src=Editor.errorImage};g.setAttribute(\"src\",e);g.style.maxWidth=\"300px\";g.style.maxHeight=\"300px\";d.appendChild(g);v.appendChild(d);var k=document.createElement(\"div\");k.style.width=\"300px\";k.style.height=\"300px\";k.style.overflow=\"hidden\";k.style.backgroundColor=\"#fff9\";v.appendChild(k);var l=null,p=new mxGeometry(100,100,100,100),q=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "p[C]}catch(I){null!=window.console&&console.log(\"Error in vars URL parameter: \"+I)}};Graph.prototype.getExportVariables=function(){return null!=this.globalVars?mxUtils.clone(this.globalVars):{}};var y=Graph.prototype.getGlobalVariable;Graph.prototype.getGlobalVariable=function(p){var C=y.apply(this,arguments);null==C&&null!=this.globalVars&&(C=this.globalVars[p]);return C};Graph.prototype.getDefaultStylesheet=function(){if(null==this.defaultStylesheet){var p=this.themes[\"default-style2\"];this.defaultStylesheet=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "[\"exportPdf\"],y):d.isOffline()||mxClient.IS_IOS&&navigator.standalone||this.addMenuItems(n,[\"exportPdf\"],y);mxClient.IS_IE||\"undefined\"===typeof VsdxExport&&d.isOffline()||this.addMenuItems(n,[\"exportVsdx\"],y);this.addMenuItems(n,[\"-\",\"exportHtml\",\"exportXml\",\"exportUrl\"],y);d.isOffline()||(n.addSeparator(y),this.addMenuItem(n,\"export\",y).firstChild.nextSibling.innerHTML=mxResources.get(\"advanced\")+\"...\")})));this.put(\"importFrom\",new Menu(mxUtils.bind(this,function(n,y){function K(G){G.pickFile(function(N){d.spinner.spin(document.body,\nmxResources.get(\"loading\"))&&G.getFile(N,function(J){var E=\"data:image/\"==J.getData().substring(0,11)?F(J.getTitle()):\"text/xml\";/\\.svg$/i.test(J.getTitle())&&!d.editor.isDataSvg(J.getData())&&(J.setData(Editor.createSvgDataUri(J.getData())),E=\"image/svg+xml\");B(J.getData(),E,J.getTitle())},function(J){d.handleError(J,null!=J?mxResources.get(\"errorLoadingFile\"):null)},G==d.drive)},!0)}var B=mxUtils.bind(this,function(G,N,J){var E=u.view,H=u.getGraphBounds(),S=u.snap(Math.ceil(Math.max(0,H.x/E.scale-", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "WriteStream.prototype.close = function(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on('close', cb);\n }\n\n // If we are not autoClosing, we should call\n // destroy on 'finish'.\n if (!this.autoClose)\n this.on('finish', this.destroy.bind(this));\n\n this.end();\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function openExternal(url)\n{\n\tshell.openExternal(url);\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function f() {\n var f_var = 10;\n function* g() {\n var g_var = 32;\n function h() {\n /* Some text to pad out the function so that it won't be eagerly compiled\n * for being too short. Lorem ipsum dolor sit amet, consectetur adipiscing\n * elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n */\n return f_var + g_var;\n }\n yield h();\n }\n return g().next().value;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "c.pop();)if(k.indexOf(g)==-1)return false}else if(a.attributes[e]!=d[e])return false;for(l in f)if(a.styles[l]!=f[l])return false;return true}function l(a,b){var c,d;if(typeof a==\"string\")c=a;else if(a instanceof CKEDITOR.style)d=a;else{c=a[0];d=a[1]}return[{element:c,left:d,right:function(a,c){c.transform(a,b)}}]}function p(a){return function(b){return y(b,a)}}function k(a){return function(b,c){c[a](b)}}var q=CKEDITOR.dtd,z=CKEDITOR.tools.copy,t=CKEDITOR.tools.trim,J=\"cke-test\",H=[\"\",\"p\",\"br\",\"div\"];", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function(){g.checked&&(null==e||e.checked)?q.removeAttribute(\"disabled\"):q.setAttribute(\"disabled\",\"disabled\")}));mxUtils.br(c);return{getLink:function(){return g.checked?\"blank\"===q.value?\"_blank\":m:null},getEditInput:function(){return g},getEditSelect:function(){return q}}};EditorUi.prototype.addLinkSection=function(c,e){function g(){var x=document.createElement(\"div\");x.style.width=\"100%\";x.style.height=\"100%\";x.style.boxSizing=\"border-box\";null!=q&&q!=mxConstants.NONE?(x.style.border=\"1px solid black\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " $scope.add = function() {\n bootbox.prompt('Please enter the name for the new requisition', function(foreignSource) {\n if (foreignSource) {\n // Validate Requisition\n if (foreignSource.match(/[/\\\\?:&*'\"]/)) {\n bootbox.alert('Cannot add the requisition ' + foreignSource + ' because the following characters are invalid:
    :, /, \\\\, ?, &, *, \\', \"');\n return;\n }\n var r = $scope.requisitionsData.getRequisition(foreignSource);\n if (r) {\n bootbox.alert('Cannot add the requisition ' + foreignSource+ ' because there is already a requisition with that name');\n return;\n }\n // Create Requisition\n RequisitionsService.addRequisition(foreignSource).then(\n function(r) { // success\n growl.success('The requisition ' + r.foreignSource + ' has been created.');\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tgetHasOwnProperty: function(element, property) {\n\t\tvar key = element + \".\" + property;\n\t\tvar own = this.current().own;\n\t\tif (!own.hasOwnProperty(key)) {\n\t\t\town[key] = this.nextId(\n\t\t\t\tfalse,\n\t\t\t\telement + \"&&(\" + this.escape(property) + \" in \" + element + \")\"\n\t\t\t);\n\t\t}\n\t\treturn own[key];\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "setEndAt:function(a,b){switch(b){case CKEDITOR.POSITION_AFTER_START:this.setEnd(a,0);break;case CKEDITOR.POSITION_BEFORE_END:a.type==CKEDITOR.NODE_TEXT?this.setEnd(a,a.getLength()):this.setEnd(a,a.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setEndBefore(a);break;case CKEDITOR.POSITION_AFTER_END:this.setEndAfter(a)}c(this)},fixBlock:function(a,b){var c=this.createBookmark(),d=this.document.createElement(b);this.collapse(a);this.enlarge(CKEDITOR.ENLARGE_BLOCK_CONTENTS);this.extractContents().appendTo(d);\nd.trim();d.appendBogus();this.insertNode(d);this.moveToBookmark(c);return d},splitBlock:function(a){var b=new CKEDITOR.dom.elementPath(this.startContainer,this.root),c=new CKEDITOR.dom.elementPath(this.endContainer,this.root),d=b.block,f=c.block,e=null;if(!b.blockLimit.equals(c.blockLimit))return null;if(a!=\"br\"){if(!d){d=this.fixBlock(true,a);f=(new CKEDITOR.dom.elementPath(this.endContainer,this.root)).block}f||(f=this.fixBlock(false,a))}a=d&&this.checkStartOfBlock();b=f&&this.checkEndOfBlock();", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "CKEDITOR.dtd[c.getName()][\"#\"]}function y(c,k,e){c.fire(\"saveSnapshot\");e.enlarge(CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS);var b=e.extractContents();k.trim(!1,!0);var j=k.createBookmark(),g=new CKEDITOR.dom.elementPath(k.startContainer),h=g.block,g=g.lastElement.getAscendant(\"li\",1)||h,f=new CKEDITOR.dom.elementPath(e.startContainer),a=f.contains(CKEDITOR.dtd.$listItem),f=f.contains(CKEDITOR.dtd.$list);h?(h=h.getBogus())&&h.remove():f&&(h=f.getPrevious(q))&&v(h)&&h.remove();(h=b.getLast())&&(h.type==\nCKEDITOR.NODE_ELEMENT&&h.is(\"br\"))&&h.remove();(h=k.startContainer.getChild(k.startOffset))?b.insertBefore(h):k.startContainer.append(b);if(a&&(b=w(a)))g.contains(a)?(A(b,a.getParent(),a),b.remove()):g.append(b);for(;e.checkStartOfBlock()&&e.checkEndOfBlock();){f=e.startPath();b=f.block;if(!b)break;b.is(\"li\")&&(g=b.getParent(),b.equals(g.getLast(q))&&b.equals(g.getFirst(q))&&(b=g));e.moveToPosition(b,CKEDITOR.POSITION_BEFORE_START);b.remove()}e=e.clone();b=c.editable();e.setEndAt(b,CKEDITOR.POSITION_BEFORE_END);\ne=new CKEDITOR.dom.walker(e);e.evaluator=function(a){return q(a)&&!v(a)};(e=e.next())&&(e.type==CKEDITOR.NODE_ELEMENT&&e.getName()in CKEDITOR.dtd.$list)&&B(e);k.moveToBookmark(j);k.select();c.fire(\"saveSnapshot\")}function w(c){return(c=c.getLast(q))&&c.type==CKEDITOR.NODE_ELEMENT&&c.getName()in r?c:null}var r={ol:1,ul:1},G=CKEDITOR.dom.walker.whitespaces(),D=CKEDITOR.dom.walker.bookmark(),q=function(c){return!(G(c)||D(c))},v=CKEDITOR.dom.walker.bogus();CKEDITOR.plugins.list={listToArray:function(c,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function ed(a,b,c){var d=a+\" \";switch(c){case\"m\":return b?\"jedna minuta\":\"jedne minute\";case\"mm\":return d+=1===a?\"minuta\":2===a||3===a||4===a?\"minute\":\"minuta\";case\"h\":return b?\"jedan sat\":\"jednog sata\";case\"hh\":return d+=1===a?\"sat\":2===a||3===a||4===a?\"sata\":\"sati\";case\"dd\":return d+=1===a?\"dan\":\"dana\";case\"MM\":return d+=1===a?\"mjesec\":2===a||3===a||4===a?\"mjeseca\":\"mjeseci\";case\"yy\":return d+=1===a?\"godina\":2===a||3===a||4===a?\"godine\":\"godina\"}}function fd(a){return a>1&&5>a&&1!==~~(a/10)}function gd(a,b,c,d){var e=a+\" \";switch(c){case\"s\":return b||d?\"p\u00e1r sekund\":\"p\u00e1r sekundami\";case\"m\":return b?\"minuta\":d?\"minutu\":\"minutou\";case\"mm\":return b||d?e+(fd(a)?\"minuty\":\"minut\"):e+\"minutami\";break;case\"h\":return b?\"hodina\":d?\"hodinu\":\"hodinou\";case\"hh\":return b||d?e+(fd(a)?\"hodiny\":\"hodin\"):e+\"hodinami\";break;case\"d\":return b||d?\"den\":\"dnem\";case\"dd\":return b||d?e+(fd(a)?\"dny\":\"dn\u00ed\"):e+\"dny\";break;case\"M\":return b||d?\"m\u011bs\u00edc\":\"m\u011bs\u00edcem\";case\"MM\":return b||d?e+(fd(a)?\"m\u011bs\u00edce\":\"m\u011bs\u00edc\u016f\"):e+\"m\u011bs\u00edci\";break;case\"y\":return b||d?\"rok\":\"rokem\";case\"yy\":return b||d?e+(fd(a)?\"roky\":\"let\"):e+\"lety\"}}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"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 ' + _.escape($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": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "Ua)}La=0};za.positionChanged=function(){};za.reset=function(){La=0};z.push(za)})(ca)}}return null!=z?z.reverse():null};var R=mxVertexHandler.prototype.setHandlesVisible;mxVertexHandler.prototype.setHandlesVisible=function(z){R.apply(this,arguments);if(null!=this.moveHandles)for(var L=0;L 0 && !this.peek('}', ')', ';', ']'))\n body.push(this.expressionStatement());\n if (!this.expect(';')) {\n return { type: AST.Program, body: body};\n }\n }\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "function(n){g.editorUiRefresh.apply(b,arguments);u()};u();var q=document.createElement(\"canvas\");q.width=m.offsetWidth;q.height=m.offsetHeight;m.style.overflow=\"hidden\";q.style.position=\"relative\";m.appendChild(q);var v=q.getContext(\"2d\");this.ui=b;var x=b.editor.graph;this.graph=x;this.container=m;this.canvas=q;var A=function(n,y,K,B,F){n=Math.round(n);y=Math.round(y);K=Math.round(K);B=Math.round(B);v.beginPath();v.moveTo(n+.5,y+.5);v.lineTo(K+.5,B+.5);v.stroke();F&&(l?(v.save(),v.translate(n,y),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "ta.style.width=\"40px\";ta.style.height=\"12px\";ta.style.marginBottom=\"-2px\";ta.style.backgroundImage=\"url(\"+mxWindow.prototype.normalizeImage+\")\";ta.style.backgroundPosition=\"top center\";ta.style.backgroundRepeat=\"no-repeat\";ta.setAttribute(\"title\",\"Minimize\");var Na=!1,Ca=mxUtils.bind(this,function(){S.innerHTML=\"\";if(!Na){var za=function(Ea,La,Ta){Ea=X(\"\",Ea.funct,null,La,Ea,Ta);Ea.style.width=\"40px\";Ea.style.opacity=\"0.7\";return wa(Ea,null,\"pointer\")},wa=function(Ea,La,Ta){null!=La&&Ea.setAttribute(\"title\",\nLa);Ea.style.cursor=null!=Ta?Ta:\"default\";Ea.style.margin=\"2px 0px\";S.appendChild(Ea);mxUtils.br(S);return Ea};wa(U.sidebar.createVertexTemplate(\"text;strokeColor=none;fillColor=none;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;\",60,30,\"Text\",mxResources.get(\"text\"),!0,!1,null,!0,!0),mxResources.get(\"text\")+\" (\"+Editor.ctrlKey+\"+Shift+X)\");wa(U.sidebar.createVertexTemplate(\"shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;fontColor=#000000;darkOpacity=0.05;fillColor=#FFF9B2;strokeColor=none;fillStyle=solid;direction=west;gradientDirection=north;gradientColor=#FFF2A1;shadow=1;size=20;pointerEvents=1;\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "function md(a,b,c) {var d=a+\" \";switch(c) {case\"m\":return b?\"jedna minuta\":\"jedne minute\";case\"mm\":return d+=1===a?\"minuta\":2===a||3===a||4===a?\"minute\":\"minuta\";case\"h\":return b?\"jedan sat\":\"jednog sata\";case\"hh\":return d+=1===a?\"sat\":2===a||3===a||4===a?\"sata\":\"sati\";case\"dd\":return d+=1===a?\"dan\":\"dana\";case\"MM\":return d+=1===a?\"mjesec\":2===a||3===a||4===a?\"mjeseca\":\"mjeseci\";case\"yy\":return d+=1===a?\"godina\":2===a||3===a||4===a?\"godine\":\"godina\"}}function nd(a,b,c,d) {var e=a;switch(c) {case\"s\":return d||b?\"n\u00e9h\u00e1ny m\u00e1sodperc\":\"n\u00e9h\u00e1ny m\u00e1sodperce\";case\"m\":return\"egy\"+(d||b?\" perc\":\" perce\");case\"mm\":return e+(d||b?\" perc\":\" perce\");case\"h\":return\"egy\"+(d||b?\" \u00f3ra\":\" \u00f3r\u00e1ja\");case\"hh\":return e+(d||b?\" \u00f3ra\":\" \u00f3r\u00e1ja\");case\"d\":return\"egy\"+(d||b?\" nap\":\" napja\");case\"dd\":return e+(d||b?\" nap\":\" napja\");case\"M\":return\"egy\"+(d||b?\" h\u00f3nap\":\" h\u00f3napja\");case\"MM\":return e+(d||b?\" h\u00f3nap\":\" h\u00f3napja\");case\"y\":return\"egy\"+(d||b?\" \u00e9v\":\" \u00e9ve\");case\"yy\":return e+(d||b?\" \u00e9v\":\" \u00e9ve\")}return\"\"}function od(a) {return(a?\"\":\"[m\u00falt] \")+\"[\"+ug[this.day()]+\"] LT[-kor]\"}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI)}function U(a) {if (!1!==a.oFeatures.bAutoWidth) {var b=a.aoColumns;Ha(a);for(var c=0,d=b.length;c=0;b--)if(a==s[b].name){s.splice(b,1);return}for(var c=[],d=[],e=l;e!=f&&e.name!=a;){e._.isBlockLike||d.unshift(e);c.push(e);e=e.returnPoint||e.parent}if(e!=f){for(b=0;bN){K=u.substring(N,ba);break}}10==Y&&(\"endobj\"==D?R=null:\"obj\"==D.substring(D.length-3,D.length)||\"xref\"==D||\"trailer\"==D?(R=[],Q[D.split(\" \")[0]]=R):null!=R&&R.push(D),\nD=\"\")}null==K&&(K=Editor.extractGraphModelFromXref(Q));null!=K&&(K=decodeURIComponent(K.replace(/\\\\\\(/g,\"(\").replace(/\\\\\\)/g,\")\")));return K};Editor.extractGraphModelFromXref=function(u){var D=u.trailer,K=null;null!=D&&(D=/.* \\/Info (\\d+) (\\d+) R/g.exec(D.join(\"\\n\")),null!=D&&0 {\n if (er) {\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n if (--writesLeft === 0)\n cb();\n };\n\n // TODO: try to combine chunks to reduce number of requests to the server?\n for (let i = 0; i < data.length; ++i) {\n const chunk = data[i].chunk;\n\n sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);\n this.pos += chunk.length;\n }\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "attributes:a.attributes};a.toolbarRelated=!0;this._={panelDefinition:a,items:{}}},proto:{renderHtml:function(a){var b=[];this.render(a,b);return b.join(\"\")},render:function(a,b){function g(){var c=this.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;a.readOnly&&!this.readOnly&&(c=CKEDITOR.TRISTATE_DISABLED);this.setState(c);this.setValue(\"\");c!=CKEDITOR.TRISTATE_DISABLED&&this.refresh&&this.refresh()}var d=CKEDITOR.env,h=\"cke_\"+this.id,e=CKEDITOR.tools.addFunction(function(b){j&&(a.unlockSelection(1),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " data: {config_calibre_dir: $(\"#config_calibre_dir\").val(), csrf_token: $(\"input[name='csrf_token']\").val()},\n 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 }\n });\n });", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "ta);Z.editorUi.fireEvent(new mxEventObject(\"styleChanged\",\"keys\",sa,\"values\",ya,\"cells\",fa.getSelectionCells()))}finally{fa.getModel().endUpdate()}}function N(Aa,ta,ka){var oa=mxUtils.getOffset(u,!0),sa=mxUtils.getOffset(Aa,!0);ta.style.position=\"absolute\";ta.style.left=sa.x-oa.x+\"px\";ta.style.top=sa.y-oa.y+\"px\";ta.style.width=Aa.offsetWidth+\"px\";ta.style.height=Aa.offsetHeight-(ka?4:0)+\"px\";ta.style.zIndex=5}function Q(Aa,ta,ka){var oa=document.createElement(\"div\");oa.style.width=\"32px\";oa.style.height=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\t\tinvokeValidation: function (field, rules, k, options) {\n\t\t\t//If validation engine already maked the field as error\n\t\t\t// we dont want to proceed\n\t\t\tif (typeof options !== 'undefined') {\n\t\t\t\tif (options.isError === true) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet listOfValidators = Vtiger_Base_Validator_Js.getValidator(field);\n\t\t\tfor (let i in listOfValidators) {\n\t\t\t\tlet validatorList = listOfValidators[i],\n\t\t\t\t\tvalidatorName = validatorList.name,\n\t\t\t\t\tvalidatorInstance = new validatorName(),\n\t\t\t\t\tresult;\n\t\t\t\tvalidatorInstance.setElement(field);\n\t\t\t\tif (validatorList.hasOwnProperty('params')) {\n\t\t\t\t\tresult = validatorInstance.validate(validatorList.params);\n\t\t\t\t} else {\n\t\t\t\t\tresult = validatorInstance.validate();\n\t\t\t\t}\n\t\t\t\tif (!result) {\n\t\t\t\t\treturn validatorInstance.getError();\n\t\t\t\t}\n\t\t\t}\n\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "D=C.createElement(\"output\");C.appendChild(D);C=new mxXmlCanvas2D(D);C.translate(Math.floor((1-z.x)/L),Math.floor((1-z.y)/L));C.scale(1/L);var G=0,P=C.save;C.save=function(){G++;P.apply(this,arguments)};var K=C.restore;C.restore=function(){G--;K.apply(this,arguments)};var F=t.drawShape;t.drawShape=function(H){mxLog.debug(\"entering shape\",H,G);F.apply(this,arguments);mxLog.debug(\"leaving shape\",H,G)};t.drawState(m.getView().getState(m.model.root),C);mxLog.show();mxLog.debug(mxUtils.getXml(D));mxLog.debug(\"stateCounter\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function(){b.hideDialog(!0)});f.className=\"geBtn\";d=null!=d?mxUtils.button(mxResources.get(\"ignore\"),d):null;null!=d&&(d.className=\"geBtn\");b.editor.cancelFirst?(y.appendChild(f),null!=d&&y.appendChild(d),y.appendChild(v),y.appendChild(n)):(y.appendChild(n),y.appendChild(v),null!=d&&y.appendChild(d),y.appendChild(f));k.appendChild(y);k.appendChild(A);this.container=k},FindWindow=function(b,e,f,c,m,n){function v(U,X,u,E){if(\"object\"===typeof X.value&&null!=X.value.attributes){X=X.value.attributes;\nfor(var J=0;JCKEDITOR.env.version&&(a[\"class\"]=\"cke_anchor\"),a=new CKEDITOR.style({element:\"a\",\nattributes:a}),a.type=CKEDITOR.STYLE_INLINE,c.applyStyle(a))}},onHide:function(){delete this._.selectedElement},onShow:function(){var a=c.getSelection(),b=a.getSelectedElement();if(b)CKEDITOR.plugins.link.fakeAnchor?((a=CKEDITOR.plugins.link.tryRestoreFakeAnchor(c,b))&&d.call(this,a),this._.selectedElement=b):b.is(\"a\")&&b.hasAttribute(\"name\")&&d.call(this,b);else if(b=CKEDITOR.plugins.link.getSelectedLink(c))d.call(this,b),a.selectElement(b);this.getContentElement(\"info\",\"txtName\").focus()},contents:[{id:\"info\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "K)));T=!0;for(var N=0;N';\n\n if (name) {\n name = this.getHelper().escapeString(name);\n }\n\n var lineHtml;\n if (id) {\n lineHtml = '
    ' + '' + name + ' » ' + addressHtml + '
    ';\n } else {\n if (name) {\n lineHtml = '' + name + ' » ' + addressHtml + '';\n } else {\n lineHtml = addressHtml;\n }\n }\n if (!id) {\n if (this.getAcl().check('Contact', 'edit')) {\n lineHtml += From.prototype.getCreateHtml.call(this, address);\n }\n }\n lineHtml = '
    ' + lineHtml + '
    ';\n return lineHtml;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " req.on('readable', function() {\n let chunk;\n while ((chunk = req.read()) !== null) {\n body.push(chunk);\n }\n });", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "EditorUi.prototype.createSvgDataUri=function(c){EditorUi.logEvent(\"SHOULD NOT BE CALLED: createSvgDataUri\");return Editor.createSvgDataUri(c)};EditorUi.prototype.embedCssFonts=function(c,e){EditorUi.logEvent(\"SHOULD NOT BE CALLED: embedCssFonts\");return this.editor.embedCssFonts(c,e)};EditorUi.prototype.embedExtFonts=function(c){EditorUi.logEvent(\"SHOULD NOT BE CALLED: embedExtFonts\");return this.editor.embedExtFonts(c)};EditorUi.prototype.exportToCanvas=function(c,e,g,k,m,q,v,x,A,z,L,M,n,y,K,B){EditorUi.logEvent(\"SHOULD NOT BE CALLED: exportToCanvas\");", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tangular.resumeBootstrap = function(extraModules) {\n\t\tforEach(extraModules, function(module) {\n\t\t\tmodules.push(module);\n\t\t});\n\t\treturn doBootstrap();\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "function equals(o1, o2) {\n if (o1 === o2) return true;\n if (o1 === null || o2 === null) return false;\n // eslint-disable-next-line no-self-compare\n if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN\n var t1 = typeof o1, t2 = typeof o2, length, key, keySet;\n if (t1 === t2 && t1 === 'object') {\n if (isArray(o1)) {\n if (!isArray(o2)) return false;\n if ((length = o1.length) === o2.length) {\n for (key = 0; key < length; key++) {\n if (!equals(o1[key], o2[key])) return false;\n }\n return true;\n }\n } else if (isDate(o1)) {\n if (!isDate(o2)) return false;\n return equals(o1.getTime(), o2.getTime());\n } else if (isRegExp(o1)) {\n if (!isRegExp(o2)) return false;\n return o1.toString() === o2.toString();\n } else {\n if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||\n isArray(o2) || isDate(o2) || isRegExp(o2)) return false;\n keySet = createMap();\n for (key in o1) {\n if (key.charAt(0) === '$' || isFunction(o1[key])) continue;\n if (!equals(o1[key], o2[key])) return false;\n keySet[key] = true;\n }\n for (key in o2) {\n if (!(key in keySet) &&\n key.charAt(0) !== '$' &&\n isDefined(o2[key]) &&\n !isFunction(o2[key])) return false;\n }\n return true;\n }\n }\n return false;\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "asn1.fromDer = function(bytes, options) {\n if(options === undefined) {\n options = {\n strict: true,\n parseAllBytes: true,\n decodeBitStrings: true\n };\n }\n if(typeof options === 'boolean') {\n options = {\n strict: options,\n parseAllBytes: true,\n decodeBitStrings: true\n };\n }\n if(!('strict' in options)) {\n options.strict = true;\n }\n if(!('parseAllBytes' in options)) {\n options.parseAllBytes = true;\n }\n if(!('decodeBitStrings' in options)) {\n options.decodeBitStrings = true;\n }\n\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n var byteCount = bytes.length();\n var value = _fromDer(bytes, bytes.length(), 0, options);\n if(options.parseAllBytes && bytes.length() !== 0) {\n var error = new Error('Unparsed DER bytes remain after ASN.1 parsing.');\n error.byteCount = byteCount;\n error.remaining = bytes.length();\n throw error;\n }\n return value;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": "1?0:Ua.y*ia);this.shape.bounds.height=ma.height-(Ta==Ma.length-1?0:(Ua.height+Ua.y)*ia)}this.shape.redraw()}};var Ya=!1;za.setPosition=function(Ua,eb,jb){La=Math.max(Graph.minTableColumnWidth-Ea.width,eb.x-Ua.x-Ea.width);Ya=mxEvent.isShiftDown(jb.getEvent());null==Da||Ya||(La=Math.min(La,Da.width-Graph.minTableColumnWidth))};za.execute=function(Ua){if(0!=La)T.setTableColumnWidth(this.state.cell,La,Ya);else if(!M.blockDelayedSelection){var eb=T.getCellAt(Ua.getGraphX(),Ua.getGraphY())||ma.cell;T.graphHandler.selectCellForEvent(eb,\nUa)}La=0};za.positionChanged=function(){};za.reset=function(){La=0};z.push(za)})(ca)}}return null!=z?z.reverse():null};var R=mxVertexHandler.prototype.setHandlesVisible;mxVertexHandler.prototype.setHandlesVisible=function(z){R.apply(this,arguments);if(null!=this.moveHandles)for(var L=0;L' + rowData.label + '(id:'+ rowId +')');\n tableRows.push('' + rowData.data.filesizeformat() + '');\n }\n \n $('#drivespaceTable tbody').html(tableRows.join(\"\"));\n $('#drivespaceTable').show();\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "ua([])},N?null:n)):J(N)),ba=ha,ea=N}function S(ha){null!=xa&&clearTimeout(xa);13==ha.keyCode?H(Na.value):xa=setTimeout(function(){H(Na.value)},1E3)}var V='
    < '+mxResources.get(\"back\")+'
    '+", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "require.register = function (path, fn) {\n require.modules[path] = fn;\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "InlineLexer.prototype.mangle = function(text) {\n if (!this.options.mangle) return text;\n var out = ''\n , l = text.length\n , i = 0\n , ch;\n\n for (; i < l; i++) {\n ch = text.charCodeAt(i);\n if (Math.random() > 0.5) {\n ch = 'x' + ch.toString(16);\n }\n out += '&#' + ch + ';';\n }\n\n return out;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " select: function (context, versions) {\n return Object.keys(e2c).slice(-versions).map(function (i) {\n return 'chrome ' + e2c[i]\n })\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "this.spacing=0}function Ca(){mxArrowConnector.call(this);this.spacing=0}function Ra(){mxActor.call(this)}function ab(){mxRectangleShape.call(this)}function Ka(){mxActor.call(this)}function bb(){mxActor.call(this)}function Pa(){mxActor.call(this)}function Za(){mxActor.call(this)}function z(){mxActor.call(this)}function L(){mxActor.call(this)}function M(){mxActor.call(this)}function T(){mxActor.call(this)}function ca(){mxActor.call(this)}function ia(){mxActor.call(this)}function ma(){mxEllipse.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "!0);V.init()}))})})}));d.actions.put(\"liveImage\",new Action(\"Live image...\",function(){var n=d.getCurrentFile();null!=n&&d.spinner.spin(document.body,mxResources.get(\"loading\"))&&d.getPublicUrl(d.getCurrentFile(),function(y){d.spinner.stop();null!=y?(y=new EmbedDialog(d,''),d.showDialog(y.container,450,240,!0,!0),y.init()):d.handleError({message:mxResources.get(\"invalidPublicUrl\")})})}));d.actions.put(\"embedImage\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "p[C]}catch(I){null!=window.console&&console.log(\"Error in vars URL parameter: \"+I)}};Graph.prototype.getExportVariables=function(){return null!=this.globalVars?mxUtils.clone(this.globalVars):{}};var y=Graph.prototype.getGlobalVariable;Graph.prototype.getGlobalVariable=function(p){var C=y.apply(this,arguments);null==C&&null!=this.globalVars&&(C=this.globalVars[p]);return C};Graph.prototype.getDefaultStylesheet=function(){if(null==this.defaultStylesheet){var p=this.themes[\"default-style2\"];this.defaultStylesheet=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function makeCheckHook(checkAsync, checkImport) {\n\tif (!checkAsync && !checkImport) return null;\n\treturn (hook, args) => {\n\t\tif (hook === 'function' || hook === 'generator_function' || hook === 'eval' || hook === 'run' ||\n\t\t\t(!checkAsync && (hook === 'async_function' || hook === 'async_generator_function'))) {\n\t\t\tif (hook === 'eval') {\n\t\t\t\tconst script = args[0];\n\t\t\t\targs = [script];\n\t\t\t\tif (typeof(script) !== 'string') return args;\n\t\t\t} else {\n\t\t\t\t// Next line throws on Symbol, this is the same behavior as function constructor calls\n\t\t\t\targs = args.map(arg => `${arg}`);\n\t\t\t}\n\t\t\tconst hasAsync = checkAsync && args.findIndex(arg => /\\basync\\b/.test(arg)) !== -1;\n\t\t\tconst hasImport = checkImport && args.findIndex(arg => /\\bimport\\b/.test(arg)) !== -1;\n\t\t\tif (!hasAsync && !hasImport) return args;\n\t\t\tconst mapped = args.map(arg => {\n\t\t\t\tif (hasAsync) arg = arg.replace(/async/g, 'a\\\\u0073ync');\n\t\t\t\tif (hasImport) arg = arg.replace(/import/g, 'i\\\\u006dport');\n\t\t\t\treturn arg;\n\t\t\t});\n\t\t\ttry {\n\t\t\t\ttryCompile(mapped);\n\t\t\t} catch (u) {\n\t\t\t\t// Some random syntax error or error because of async or import.\n\n\t\t\t\t// First report real syntax errors\n\t\t\t\ttryCompile(args);\n\n\t\t\t\tif (hasAsync && hasImport) {\n\t\t\t\t\tconst mapped2 = args.map(arg => arg.replace(/async/g, 'a\\\\u0073ync'));\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttryCompile(mapped2);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tthrow new VMError('Async not available');\n\t\t\t\t\t}\n\t\t\t\t\tthrow new VMError('Dynamic Import not supported');\n\t\t\t\t}\n\t\t\t\tif (hasAsync) {\n\t\t\t\t\t// Then async error\n\t\t\t\t\tthrow new VMError('Async not available');\n\t\t\t\t}\n\t\t\t\tthrow new VMError('Dynamic Import not supported');\n\t\t\t}\n\t\t\treturn args;\n\t\t}\n\t\tif (checkAsync) throw new VMError('Async not available');\n\t\treturn args;\n\t};\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1321", "cwe_name": "Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')", "description": "The software receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.", "url": "https://cwe.mitre.org/data/definitions/1321.html", "label_name": "safe"} {"code": "TagSearch.prototype.renderResult = function(html) {\n this._contentBox.html(html);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "c.role);c=this.keys;c[40]=\"next\";c[9]=\"next\";c[38]=\"prev\";c[CKEDITOR.SHIFT+9]=\"prev\";c[32]=CKEDITOR.env.ie?\"mouseup\":\"click\";CKEDITOR.env.ie&&(c[13]=\"mouseup\");this._.pendingHtml=[];this._.pendingList=[];this._.items={};this._.groups={}},_:{close:function(){if(this._.started){var a=f.output({items:this._.pendingList.join(\"\")});this._.pendingList=[];this._.pendingHtml.push(a);delete this._.started}},getClick:function(){this._.click||(this._.click=CKEDITOR.tools.addFunction(function(a){var b=this.toggle(a);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "H.x+\" \"+H.y;S=\"\";c=[];for(U=2;Ul;)v.shift()},N=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\"url(\"+mxWindow.prototype.normalizeImage+\")\";aa.style.backgroundPosition=\"top center\";aa.style.backgroundRepeat=\"no-repeat\";aa.setAttribute(\"title\",\"Minimize\");var va=!1,ja=mxUtils.bind(this,function(){N.innerHTML=\"\";if(!va){var da=function(ia,ma,ra){ia=E(\"\",ia.funct,null,ma,ia,ra);ia.style.width=\"40px\";ia.style.opacity=\"0.7\";return ca(ia,null,\"pointer\")},ca=function(ia,ma,ra){null!=ma&&ia.setAttribute(\"title\",ma);ia.style.cursor=null!=ra?ra:\"default\";ia.style.margin=\"2px 0px\";N.appendChild(ia);mxUtils.br(N);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.spacing=0}function Ca(){mxArrowConnector.call(this);this.spacing=0}function Ra(){mxActor.call(this)}function ab(){mxRectangleShape.call(this)}function Ka(){mxActor.call(this)}function bb(){mxActor.call(this)}function Pa(){mxActor.call(this)}function Za(){mxActor.call(this)}function z(){mxActor.call(this)}function L(){mxActor.call(this)}function M(){mxActor.call(this)}function T(){mxActor.call(this)}function ca(){mxActor.call(this)}function ia(){mxActor.call(this)}function ma(){mxEllipse.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "Math.round(Math.max(0,Math.min(Math.min(l.width,l.x+l.width-x.x),Math.min(l.height,x.y-l.y))))})]},note2:function(c){return[fb(c,[\"size\"],function(l){var x=Math.max(0,Math.min(l.width,Math.min(l.height,parseFloat(mxUtils.getValue(this.state.style,\"size\",g.prototype.size)))));return new mxPoint(l.x+l.width-x,l.y+x)},function(l,x){this.state.style.size=Math.round(Math.max(0,Math.min(Math.min(l.width,l.x+l.width-x.x),Math.min(l.height,x.y-l.y))))})]},manualInput:function(c){var l=[fb(c,[\"size\"],function(x){var p=\nMath.max(0,Math.min(x.height,mxUtils.getValue(this.state.style,\"size\",Ra.prototype.size)));return new mxPoint(x.x+x.width/4,x.y+3*p/4)},function(x,p){this.state.style.size=Math.round(Math.max(0,Math.min(x.height,4*(p.y-x.y)/3)))},!1)];mxUtils.getValue(c.style,mxConstants.STYLE_ROUNDED,!1)&&l.push(kb(c));return l},dataStorage:function(c){return[fb(c,[\"size\"],function(l){var x=\"0\"!=mxUtils.getValue(this.state.style,\"fixedSize\",\"0\"),p=parseFloat(mxUtils.getValue(this.state.style,\"size\",x?L.prototype.fixedSize:", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\tcwdDown : function() {\n\t\t\t\t\t\tcwd.scrollTop(cwd.scrollTop() + helper.data('autoScrVal'));\n\t\t\t\t\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "k&&k(q)})):p(\"\")};EditorUi.prototype.updateDiagram=function(d){function g(K){var F=new mxCellOverlay(K.image||p.warningImage,K.tooltip,K.align,K.valign,K.offset);F.addListener(mxEvent.CLICK,function(H,S){l.alert(K.tooltip)});return F}var k=null,l=this;if(null!=d&&0Use refresh to update the deployed statistics');\n requisition.setDeployed(true);\n },\n errorHandler\n );\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "!function(r){Craft.FeedWidget=Garnish.Base.extend({$widget:null,init:function(t,i,e){this.$widget=r(\"#widget\"+t),this.$widget.addClass(\"loading\");var a={url:i,limit:e};Craft.postActionRequest(\"dashboard/get-feed-items\",a,r.proxy(function(t,i){if(this.$widget.removeClass(\"loading\"),\"success\"===i){this.$widget.find(\"table\").attr(\"dir\",t.dir);for(var e=this.$widget.find(\"td\"),a=0;a'+s.title+\" \";s.date&&(n+=''+s.date+\"\"),d.html(n)}}},this))}})}(jQuery);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "o()},usual:function(){s();m();o()},rtl:function(){s();m();o()}},D=function(b){var c=new function(a){var b={};return{getCmdByTab:function(c){for(var e in a)b[a[e]]=e;return b[c]}}}(a.cmd);b.selectPage(c.getCmdByTab(CKEDITOR.config.wsc_cmd));a.sendData(b)},s=function(){a.dialog.hidePage(\"Thesaurus\")},m=function(){a.dialog.hidePage(\"GrammTab\")},o=function(){a.dialog.showPage(\"SpellTab\")},l=function(){a.dialog.getContentElement(a.dialog._.currentTabId,\"bottomGroup\").getElement().show()},r=function(){a.dialog.getContentElement(a.dialog._.currentTabId,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " noteRenderer: function(note) {\n var recordClass = Tine.Tinebase.data.RecordMgr.get(this.record_model),\n app = Tine.Tinebase.appMgr.get(this.app);\n\n note = Ext.util.Format.htmlEncode(note);\n \n if (recordClass) {\n Ext.each(recordClass.getFieldDefinitions(), function(field) {\n if (field.label) {\n note = String(note).replace(field.name, '
    ' + app.i18n._hidden(field.label));\n //map[field.name] = '
    ' + this.app.i18n._hidden(field.label);\n }\n }, this);\n }\n\n return note;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\twp.updates.requestFilesystemCredentials = function( event ) {\n\t\tif ( false === wp.updates.filesystemCredentials.available ) {\n\t\t\t/*\n\t\t\t * After exiting the credentials request modal,\n\t\t\t * return the focus to the element triggering the request.\n\t\t\t */\n\t\t\tif ( event && ! wp.updates.$elToReturnFocusToFromCredentialsModal ) {\n\t\t\t\twp.updates.$elToReturnFocusToFromCredentialsModal = $( event.target );\n\t\t\t}\n\n\t\t\twp.updates.ajaxLocked = true;\n\t\t\twp.updates.requestForCredentialsModalOpen();\n\t\t}\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t\tthis._chunkLoaded = function()\n\t\t{\n\t\t\tif (xhr.readyState !== 4)\n\t\t\t\treturn;\n\n\t\t\tif (xhr.status < 200 || xhr.status >= 400)\n\t\t\t{\n\t\t\t\tthis._chunkError();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte\n\t\t\tthis._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;\n\t\t\tthis._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);\n\t\t\tthis.parseChunk(xhr.responseText);\n\t\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": " function iterateMustacheNode (node) {\n const list = $(node).contents().toArray()\n list.forEach(item => {\n if (item.type === 'text') {\n const rawText = $(item).text()\n if (rawText.indexOf('{{') >= 0 && rawText.indexOf('}}') > 1) {\n $(item).parent().attr('v-pre', true)\n }\n } else {\n iterateMustacheNode(item)\n }\n })\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "CKEDITOR.POSITION_FOLLOWING},getAscendant:function(a,e){var b=this.$,c;if(!e)b=b.parentNode;for(;b;){if(b.nodeName&&(c=b.nodeName.toLowerCase(),typeof a==\"string\"?c==a:c in a))return new CKEDITOR.dom.node(b);try{b=b.parentNode}catch(d){b=null}}return null},hasAscendant:function(a,e){var b=this.$;if(!e)b=b.parentNode;for(;b;){if(b.nodeName&&b.nodeName.toLowerCase()==a)return true;b=b.parentNode}return false},move:function(a,e){a.append(this.remove(),e)},remove:function(a){var e=this.$,b=e.parentNode;", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " var error_original = function(xhr, status, error) {};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": "z();this.redrawHandles()});this.graph.getSelectionModel().addListener(mxEvent.CHANGE,this.changeHandler);this.graph.getModel().addListener(mxEvent.CHANGE,this.changeHandler);var L=this.graph.getLinkForCell(this.state.cell),M=this.graph.getLinksForState(this.state);if(null!=L||null!=M&&0'),Xa.writeln(Editor.mathJaxWebkitCss),Xa.writeln(\"\");mxClient.IS_GC&&(Xa.writeln('\"));null!=p.editor.fontCss&&(Xa.writeln('\"));for(var db=Ha.getCustomFonts(),cb=0;cb'):(Xa.writeln('\"))}};if(\"undefined\"!==typeof MathJax){var jb=Na.renderPage;Na.renderPage=function(Xa,db,cb,fb,eb,lb){var kb=mxClient.NO_FO;mxClient.NO_FO=this.graph.mathEnabled&&!p.editor.useForeignObjectForMath?!0:p.editor.originalNoForeignObject;var gb=jb.apply(this,arguments);mxClient.NO_FO=kb;this.graph.mathEnabled?this.mathEnabled=this.mathEnabled||!0:gb.className=\"geDisableMathJax\";return gb}}Wa=null;bb=P.shapeForegroundColor;$a=P.shapeBackgroundColor;Va=P.enableFlowAnimation;", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "p=0}else d.setStartBefore(f);if(e&&e.type==CKEDITOR.NODE_TEXT)if(l)if(l>=e.getLength())d.setEndAfter(e);else{d.setEndAfter(e);k=0}else d.setEndBefore(e);var d=new CKEDITOR.dom.walker(d),q=CKEDITOR.dom.walker.bookmark();d.evaluator=function(b){return b.type==(a==CKEDITOR.SHRINK_ELEMENT?CKEDITOR.NODE_ELEMENT:CKEDITOR.NODE_TEXT)};var i;d.guard=function(b,d){if(q(b))return true;if(a==CKEDITOR.SHRINK_ELEMENT&&b.type==CKEDITOR.NODE_TEXT||d&&b.equals(i)||c===false&&b.type==CKEDITOR.NODE_ELEMENT&&b.isBlockBoundary()||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "1);break}E.className=ca.join(\" \")}null!=ia?(E=ia,E.className+=\" \"+ra,K=aa,Ba.className=\"geTempDlgCreateBtn\"):(K=E=null,Ba.className=\"geTempDlgCreateBtn geTempDlgBtnDisabled\")}function u(ia,ra){if(null!=K){var aa=function(ta){qa.isExternal?g(qa,function(ka){ca(ka,ta)},na):qa.url?mxUtils.get(TEMPLATE_PATH+\"/\"+qa.url,mxUtils.bind(this,function(ka){200<=ka.getStatus()&&299>=ka.getStatus()?ca(ka.getText(),ta):na()})):ca(b.emptyDiagramXml,ta)},ca=function(ta,ka){y||b.hideDialog(!0);e(ta,ka,qa,ra)},na=function(){z(mxResources.get(\"cannotLoad\"));\nla()},la=function(){K=qa;Ba.className=\"geTempDlgCreateBtn\";ra&&(Ea.className=\"geTempDlgOpenBtn\")},qa=K;K=null;\"boolean\"!==typeof ra&&(ra=qa.isExternal&&p);1==ia?k(qa.url,qa):ra?(Ea.className=\"geTempDlgOpenBtn geTempDlgBtnDisabled geTempDlgBtnBusy\",aa()):(Ba.className=\"geTempDlgCreateBtn geTempDlgBtnDisabled geTempDlgBtnBusy\",ia=null==b.mode||b.mode==App.MODE_GOOGLE||b.mode==App.MODE_BROWSER?mxResources.get(\"diagramName\"):mxResources.get(\"filename\"),ia=new FilenameDialog(b,b.defaultFilename+\".drawio\",\nmxResources.get(\"ok\"),aa,ia,function(ta){var ka=null!=ta&&0]*o:href=['\"](.*?)['\"]/))&&d[1])&&(c.attributes.src=d),c):!1}:h}}},G=function(){this.dataFilter=new CKEDITOR.htmlParser.filter};G.prototype={toHtml:function(a){var a=CKEDITOR.htmlParser.fragment.fromHtml(a),c=new CKEDITOR.htmlParser.basicWriter;a.writeHtml(c,this.dataFilter);return c.getHtml(!0)}};CKEDITOR.cleanWord=function(a,c){CKEDITOR.env.gecko&&(a=a.replace(/(<\\!--\\[if[^<]*?\\])--\\>([\\S\\s]*?)<\\!--(\\[endif\\]--\\>)/gi,\"$1$2$3\"));CKEDITOR.env.webkit&&\n(a=a.replace(/(class=\"MsoListParagraph[^>]+><\\!--\\[if !supportLists\\]--\\>)([^<]+)(<\\!--\\[endif\\]--\\>)/gi,\"$1$2$3\"));var b=new G,f=b.dataFilter;f.addRules(CKEDITOR.plugins.pastefromword.getRules(c,f));c.fire(\"beforeCleanWord\",{filter:f});try{a=b.toHtml(a)}catch(d){alert(c.lang.pastefromword.error)}a=a.replace(/cke:.*?\".*?\"/g,\"\");a=a.replace(/style=\"\"/g,\"\");return a=a.replace(//g,\"\")}})();", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "m=P.name;v=\"\";O(null,!0)})));k.appendChild(F)})(D[G],G)}100==D.length&&(k.appendChild(A),B=function(){k.scrollTop>=k.scrollHeight-k.offsetHeight&&C()},mxEvent.addListener(k,\"scroll\",B))}),y)});t()};GitHubClient.prototype.logout=function(){this.clearPersistentToken();this.setUser(null);b=null}})();TrelloFile=function(b,e,f){DrawioFile.call(this,b,e);this.meta=f;this.saveNeededCounter=0};mxUtils.extend(TrelloFile,DrawioFile);TrelloFile.prototype.getHash=function(){return\"T\"+encodeURIComponent(this.meta.compoundId)};TrelloFile.prototype.getMode=function(){return App.MODE_TRELLO};TrelloFile.prototype.isAutosave=function(){return!0};TrelloFile.prototype.getTitle=function(){return this.meta.name};TrelloFile.prototype.isRenamable=function(){return!1};TrelloFile.prototype.getSize=function(){return this.meta.bytes};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " join: function (segments) {\n return segments.reduce(function (path, part) {\n return (\n path +\n (isQuoted(part) || DIGIT_REGEX.test(part)\n ? '[' + part + ']'\n : (path ? '.' : '') + part)\n )\n }, '')\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "\t\tvar getExtTemplates = function(isSearch)\n\t\t{\n\t\t\tlist.style.display = 'none';\n\t\t\tsearchBox.style.display = 'none';\n\t\t\tdiv.style.left = '30px';\t\t\t\t\n\t\t\t\n\t\t\tsetActiveTab(isSearch? -1 : 1); //deselect all of them if isSearch \n\t\t\t\n\t\t\tif (oldTemplates == null) \n\t\t\t{\n\t\t\t\toldTemplates = templates;\n\t\t\t}\n\t\t\t\n\t\t\tdiv.scrollTop = 0;\n\t\t\tdiv.innerHTML = '';\n\t\t\tspinner.spin(div);\n\n\t\t\tvar callback2 = function(docList, errorMsg, searchImportCats) \n\t\t\t{\n\t\t\t\ti0 = 0;\n\t\t\t\tspinner.stop();\n\t\t\t\ttemplates = docList;\n\t\t\t\tsearchImportCats = searchImportCats || {};\n\t\t\t\tvar importListsCount = 0;\n\t\t\t\t\n\t\t\t\tfor (var cat in searchImportCats)\n\t\t\t\t{\n\t\t\t\t\timportListsCount += searchImportCats[cat].length;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (errorMsg)\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = errorMsg;\n\t\t\t\t}\n\t\t\t\telse if (docList.length == 0 && importListsCount == 0)\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = mxUtils.htmlEntities(mxResources.get('noDiagrams', null, 'No Diagrams Found'));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = '';\n\t\t\t\t\t\n\t\t\t\t\tif (importListsCount > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tlist.style.display = '';\n\t\t\t\t\t\tdiv.style.left = '160px';\n\t\t\t\t\t\tlist.innerHTML = '';\n\n\t\t\t\t\t\tcustomCatCount = 0;\n\t\t\t\t\t\tcategories = {'draw.io': docList};\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (var cat in searchImportCats)\n\t\t\t\t\t\t{\t\n\t\t\t\t\t\t\tcategories[cat] = searchImportCats[cat];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tinitUi();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\taddTemplates(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (isSearch)\n\t\t\t{\n\t\t\t\tsearchDocsCallback(searchInput.value, callback2);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trecentDocsCallback(callback2);\n\t\t\t}\n\t\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "this.getValue()):d.removeAttribute(\"cellSpacing\")}},{type:\"text\",id:\"txtCellPad\",requiredContent:\"table[cellpadding]\",controlStyle:\"width:3em\",label:a.lang.table.cellPad,\"default\":a.filter.check(\"table[cellpadding]\")?1:0,validate:CKEDITOR.dialog.validate.number(a.lang.table.invalidCellPadding),setup:function(a){this.setValue(a.getAttribute(\"cellPadding\")||\"\")},commit:function(a,d){this.getValue()?d.setAttribute(\"cellPadding\",this.getValue()):d.removeAttribute(\"cellPadding\")}}]}]},{type:\"html\",align:\"right\",\nhtml:\"\"},{type:\"vbox\",padding:0,children:[{type:\"text\",id:\"txtCaption\",requiredContent:\"caption\",label:a.lang.table.caption,setup:function(a){this.enable();a=a.getElementsByTag(\"caption\");if(0'],{type:\"text/html\"})});navigator.clipboard.write([d])[\"catch\"](l)};EditorUi.prototype.copyCells=function(d,g){var k=this.editor.graph;if(k.isSelectionEmpty())d.innerHTML=\"\";else{var l=\nmxUtils.sortCells(k.model.getTopmostCells(k.getSelectionCells())),p=mxUtils.getXml(k.encodeCells(l));mxUtils.setTextContent(d,encodeURIComponent(p));g?(k.removeCells(l,!1),k.lastPasteXml=null):(k.lastPasteXml=p,k.pasteCounter=0);d.focus();document.execCommand(\"selectAll\",!1,null)}};EditorUi.prototype.copyXml=function(){var d=null;if(Editor.enableNativeCipboard){var g=this.editor.graph;g.isSelectionEmpty()||(d=mxUtils.sortCells(g.getExportableCells(g.model.getTopmostCells(g.getSelectionCells()))),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "d.addHours=function(a,c){return d.addMinutes(a,60*c)};d.addMinutes=function(a,c){return d.addSeconds(a,60*c)};d.addSeconds=function(a,c){return d.addMilliseconds(a,1E3*c)};d.addMilliseconds=function(a,c){return new Date(a.getTime()+c)};d.subtract=function(a,c){var b=a.getTime()-c.getTime();return{toMilliseconds:function(){return b},toSeconds:function(){return b/1E3},toMinutes:function(){return b/6E4},toHours:function(){return b/36E5},toDays:function(){return b/864E5}}};d.isLeapYear=function(a){return!(a%", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "Q.marginBottom||0;R.allowGaps=Q.allowGaps||0;R.horizontal=\"1\"==mxUtils.getValue(Q,\"horizontalRack\",\"0\");R.resizeParent=!1;R.fill=!0;return R}return T.apply(this,arguments)};this.updateGlobalUrlVariables()};var B=Graph.prototype.postProcessCellStyle;Graph.prototype.postProcessCellStyle=function(u,D){return Graph.processFontStyle(B.apply(this,arguments))};var I=mxSvgCanvas2D.prototype.updateTextNodes;mxSvgCanvas2D.prototype.updateTextNodes=function(u,D,K,T,N,Q,R,Y,ba,ea,Z){I.apply(this,arguments);Graph.processFontAttributes(Z)};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "[];for(G=0;G','',isLocalStorage||mxClient.IS_CHROMEAPP)).container,340,isLocalStorage||mxClient.IS_CHROMEAPP?220:200,\n!0,!0):p(!1,l)};EditorUi.prototype.parseFile=function(d,g,k){k=null!=k?k:d.name;var l=new FileReader;l.onload=mxUtils.bind(this,function(){this.parseFileData(l.result,g,k)});l.readAsText(d)};EditorUi.prototype.parseFileData=function(d,g,k){var l=new XMLHttpRequest;l.open(\"POST\",OPEN_URL);l.setRequestHeader(\"Content-Type\",\"application/x-www-form-urlencoded\");l.onreadystatechange=function(){g(l)};l.send(\"format=xml&filename=\"+encodeURIComponent(k)+\"&data=\"+encodeURIComponent(d));try{EditorUi.logEvent({category:\"GLIFFY-IMPORT-FILE\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " self.update = function() {\n // Prevent focusing on editable when invoke('code') is executed\n if (!context.invoke('editor.hasFocus')) {\n self.hidePopover();\n return;\n }\n\n var rng = context.invoke('editor.createRange');\n var visible = false;\n\n if (rng.isOnData()) {\n var $data = $(rng.sc).closest('data.ext-databasic');\n\n if ($data.length) {\n var pos = dom.posFromPlaceholder($data[0]);\n\n self.$popover.css({\n display: 'block',\n left: pos.left,\n top: pos.top,\n });\n\n // save editor target to let size buttons resize the container\n context.invoke('editor.saveTarget', $data[0]);\n\n visible = true;\n }\n }\n\n // hide if not visible\n if (!visible) {\n self.hidePopover();\n }\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.setEndAt(a,CKEDITOR.POSITION_BEFORE_END);var b=this.extractContents(),c=a.clone(false);b.appendTo(c);c.insertAfter(a);this.moveToPosition(a,CKEDITOR.POSITION_AFTER_END);return c},removeEmptyBlocksAtEnd:function(){function a(d){return function(a){return b(a)||(c(a)||a.type==CKEDITOR.NODE_ELEMENT&&a.isEmptyInlineRemoveable())||d.is(\"table\")&&a.is(\"caption\")?false:true}}var b=CKEDITOR.dom.walker.whitespaces(),c=CKEDITOR.dom.walker.bookmark(false);return function(b){for(var c=this.createBookmark(),\nd=this[b?\"endPath\":\"startPath\"](),e=d.block||d.blockLimit,l;e&&!e.equals(d.root)&&!e.getFirst(a(e));){l=e.getParent();this[b?\"setEndAt\":\"setStartAt\"](e,CKEDITOR.POSITION_AFTER_END);e.remove(1);e=l}this.moveToBookmark(c)}}(),startPath:function(){return new CKEDITOR.dom.elementPath(this.startContainer,this.root)},endPath:function(){return new CKEDITOR.dom.elementPath(this.endContainer,this.root)},checkBoundaryOfElement:function(a,b){var c=b==CKEDITOR.START,d=this.clone();d.collapse(c);d[c?\"setStartAt\":", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "Cache.prototype.get = function(key) {\n return this._values[key]\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": "\"url(\"+Editor.plusImage+\")\",aa.setAttribute(\"title\",mxResources.get(\"insert\")),aa.style.width=\"24px\",va=!0)}));ja();F.addListener(\"darkModeChanged\",ja);F.addListener(\"sketchModeChanged\",ja)}else F.editor.addListener(\"statusChanged\",mxUtils.bind(this,function(){F.setStatusText(F.editor.getStatus())}));if(null!=D){var Ba=function(da){H.popupMenuHandler.hideMenu();mxEvent.isAltDown(da)||mxEvent.isShiftDown(da)?F.actions.get(\"customZoom\").funct():F.actions.get(\"smartFit\").funct()},Da=F.actions.get(\"zoomIn\"),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tthis.exec = function(hashes, type) {\n\t\tvar files = this.files(hashes),\n\t\t\tcnt = files.length,\n\t\t\tmime = type || mimes[0],\n\t\t\tcwd = fm.file(files[0].phash) || null,\n\t\t\terror = ['errArchive', 'errPerm', 'errCreatingTempDir', 'errFtpDownloadFile', 'errFtpUploadFile', 'errFtpMkdir', 'errArchiveExec', 'errExtractExec', 'errRm'],\n\t\t\ti, open;\n\n\t\tdfrd = $.Deferred().fail(function(error) {\n\t\t\terror && fm.error(error);\n\t\t});\n\n\t\tif (!(this.enabled() && cnt && mimes.length && $.inArray(mime, mimes) !== -1)) {\n\t\t\treturn dfrd.reject();\n\t\t}\n\t\t\n\t\tif (!cwd.write) {\n\t\t\treturn dfrd.reject(error);\n\t\t}\n\t\t\n\t\tfor (i = 0; i < cnt; i++) {\n\t\t\tif (!files[i].read) {\n\t\t\t\treturn dfrd.reject(error);\n\t\t\t}\n\t\t}\n\n\t\tself.mime = mime;\n\t\tself.prefix = ((cnt > 1)? 'Archive' : files[0].name) + (fm.option('archivers')['createext']? '.' + fm.option('archivers')['createext'][mime] : '');\n\t\tself.data = {targets : self.hashes(hashes), type : mime};\n\t\t\n\t\tif (fm.cwd().hash !== cwd.hash) {\n\t\t\topen = fm.exec('open', cwd.hash);\n\t\t} else {\n\t\t\topen = null;\n\t\t}\n\t\t\n\t\t$.when(open).done(function() {\n\t\t\tfm.selectfiles({files : hashes});\n\t\t\tdfrd = $.proxy(fm.res('mixin', 'make'), self)();\n\t\t});\n\t\t\n\t\treturn dfrd;\n\t}\n\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "CKEDITOR.dom.nodeList.prototype={count:function(){return this.$.length},getItem:function(a){if(a<0||a>=this.$.length)return null;return(a=this.$[a])?new CKEDITOR.dom.node(a):null}};CKEDITOR.dom.element=function(a,e){typeof a==\"string\"&&(a=(e?e.$:document).createElement(a));CKEDITOR.dom.domObject.call(this,a)};CKEDITOR.dom.element.get=function(a){return(a=typeof a==\"string\"?document.getElementById(a)||document.getElementsByName(a)[0]:a)&&(a.$?a:new CKEDITOR.dom.element(a))};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function _makeGetter(property, next) {\n\tproperty = String(property);\n\n\tif (\n\t\tproperty === '__proto__' ||\n\t\tproperty === 'constructor' ||\n\t\tproperty === 'prototype'\n\t) {\n\t\tthrow new Error('unable to access __proto__, constructor, prototype');\n\t}\n\n\tif (next) {\n\t\treturn function getter(obj) {\n\t\t\ttry {\n\t\t\t\treturn next(obj[property]);\n\t\t\t} catch (ex) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\t} else {\n\t\treturn function getter(obj) {\n\t\t\ttry {\n\t\t\t\treturn obj[property];\n\t\t\t} catch (ex) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\t}\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1321", "cwe_name": "Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')", "description": "The software receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.", "url": "https://cwe.mitre.org/data/definitions/1321.html", "label_name": "safe"} {"code": "function addAdlist() {\n var address = $(\"#new_address\").val();\n var comment = $(\"#new_comment\").val();\n\n utils.disableAll();\n utils.showAlert(\"info\", \"\", \"Adding adlist...\", address);\n\n if (address.length === 0) {\n utils.showAlert(\"warning\", \"\", \"Warning\", \"Please specify an adlist address\");\n return;\n }\n\n $.ajax({\n url: \"scripts/pi-hole/php/groups.php\",\n method: \"post\",\n dataType: \"json\",\n data: {\n action: \"add_adlist\",\n address: address,\n comment: comment,\n token: token\n },\n success: function (response) {\n utils.enableAll();\n if (response.success) {\n utils.showAlert(\"success\", \"fas fa-plus\", \"Successfully added adlist\", address);\n table.ajax.reload(null, false);\n $(\"#new_address\").val(\"\");\n $(\"#new_comment\").val(\"\");\n table.ajax.reload();\n } else {\n utils.showAlert(\"error\", \"\", \"Error while adding new adlist: \", response.message);\n }\n },\n error: function (jqXHR, exception) {\n utils.enableAll();\n utils.showAlert(\"error\", \"\", \"Error while adding new adlist: \", jqXHR.responseText);\n console.log(exception); // eslint-disable-line no-console\n }\n });\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": "d,q,t,D),g&&!k?q.y=A.y:k&&!g&&(q.x=A.x),A.y!=q.y&&null!=this.guideY&&null!=this.guideY.node&&(this.guideY.node.style.visibility=\"hidden\"),A.x!=q.x&&null!=this.guideX&&null!=this.guideX.node&&(this.guideX.node.style.visibility=\"hidden\"),q;F(!0,!0);return b.apply(this,arguments)};var f=mxGuide.prototype.setVisible;mxGuide.prototype.setVisible=function(d){f.call(this,d);var u=this.guidesArrVer,t=this.guidesArrHor;if(null!=u)for(var D=0;D=0&&a.listeners.splice(h,1)}},removeAllListeners:function(){var b=e(this),d;for(d in b)delete b[d]},hasListeners:function(b){return(b=e(this)[b])&&b.listeners.length>0}}}());", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "z();this.redrawHandles()});this.graph.getSelectionModel().addListener(mxEvent.CHANGE,this.changeHandler);this.graph.getModel().addListener(mxEvent.CHANGE,this.changeHandler);var L=this.graph.getLinkForCell(this.state.cell),M=this.graph.getLinksForState(this.state);if(null!=L||null!=M&&0';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse if (entry.desc == null)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tpreview.style.padding = '20px';\n\t\t\t\t\t\t\t\t\t\tpreview.style.color = 'rgb(179, 179, 179)';\n\t\t\t\t\t\t\t\t\t\tmxUtils.write(preview, mxResources.get('noPreview'));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (currentListItem != null)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcurrentListItem.style.backgroundColor = '';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tcurrentListItem = option;\n\t\t\t\t\t\t\t\t\tcurrentListItem.style.backgroundColor = Editor.isDarkMode() ? '#000000' : '#ebf2f9';\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (evt != null)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tmxEvent.consume(evt);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "M.setBackgroundImage=this.editor.graph.setBackgroundImage;M.background=this.editor.graph.background;var K=this.pages[0];this.currentPage==K?M.setBackgroundImage(this.editor.graph.backgroundImage):null!=K.viewState&&null!=K.viewState&&M.setBackgroundImage(K.viewState.backgroundImage);M.getGlobalVariable=function(B){return\"page\"==B?K.getName():\"pagenumber\"==B?1:y.apply(this,arguments)};document.body.appendChild(M.container);M.model.setRoot(K.root)}}v=null!=v?v:this.getXmlFileData(m,q,z,L);A=null!=A?", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\"url(\"+mxWindow.prototype.normalizeImage+\")\";aa.style.backgroundPosition=\"top center\";aa.style.backgroundRepeat=\"no-repeat\";aa.setAttribute(\"title\",\"Minimize\");var ua=!1,la=mxUtils.bind(this,function(){P.innerHTML=\"\";if(!ua){var ca=function(ia,ma,qa){ia=F(\"\",ia.funct,null,ma,ia,qa);ia.style.width=\"40px\";ia.style.opacity=\"0.7\";return ba(ia,null,\"pointer\")},ba=function(ia,ma,qa){null!=ma&&ia.setAttribute(\"title\",ma);ia.style.cursor=null!=qa?qa:\"default\";ia.style.margin=\"2px 0px\";P.appendChild(ia);mxUtils.br(P);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "mxActor);Za.prototype.arrowWidth=.3;Za.prototype.arrowSize=.2;Za.prototype.redrawPath=function(c,l,x,p,v){var A=v*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowWidth\",this.arrowWidth))));l=p*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowSize\",this.arrowSize))));x=(v-A)/2;A=x+A;var B=mxUtils.getValue(this.style,mxConstants.STYLE_ARCSIZE,mxConstants.LINE_ARCSIZE)/2;this.addPoints(c,[new mxPoint(0,x),new mxPoint(p-l,x),new mxPoint(p-l,0),new mxPoint(p,v/2),new mxPoint(p-\nl,v),new mxPoint(p-l,A),new mxPoint(0,A)],this.isRounded,B,!0);c.end()};mxCellRenderer.registerShape(\"singleArrow\",Za);mxUtils.extend(z,mxActor);z.prototype.redrawPath=function(c,l,x,p,v){var A=v*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowWidth\",Za.prototype.arrowWidth))));l=p*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowSize\",Za.prototype.arrowSize))));x=(v-A)/2;A=x+A;var B=mxUtils.getValue(this.style,mxConstants.STYLE_ARCSIZE,mxConstants.LINE_ARCSIZE)/", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\t'select': function(e) {\n\n\t\tif((e.hasAttribute('multiple') === false) && $(e).hasClass('nosearch') === false) {\n\t\t\t$(e).select2({\n\t\t\t\tdropdownAutoWidth : true,\n\t\t\t\t// break a select option item into multi lines\n\t\t\t\ttemplateResult: function(item) {\n\t\t\t\t\tvar selectionText = item.text.split('\\n');\n\t\t\t\t\tvar returnString = $('');\n\t\t\t\t\t$.each(selectionText, function(index, value){\n\t\t\t\t\t\tline = value === undefined ? '' : value;\n\t\t\t\t\t\treturnString.append(line + '
    ');\n\t\t\t\t\t})\n\t\t\t\t\t\t\n\t\t\t\t\treturn returnString;\n\t\t\t\t}\n\t\t\t});\n\t\t\t$(e).on('select2:close', function() {\n\t\t\t\t$(this).focus();\n\t\t\t});\n\t\t\t$(e).on('select2:open', function(e2){\n\n\t\t\t\t$('.dynamic_combo_btn').remove();\n\n\t\t\t\tvar target_id = $(e2.target).attr('id');\n\t\t\t\tvar search_btn = $('#_'+target_id+'_search').clone();\n\t\t\t\tvar add_btn = $('#_'+target_id+'_add').clone();\n\t\t\t\t$(search_btn).addClass('dynamic_combo_btn');\n\t\t\t\t$(add_btn).addClass('dynamic_combo_btn');\n\t\t\t\t$(search_btn).removeAttr('id hidden');\n\t\t\t\t$(add_btn).removeAttr('id hidden');\n\n\t\t\t\t$('.select2-dropdown').append(search_btn);\n\t\t\t\tif($(add_btn) !== 'undefined')\n\t\t\t\t\t$('.select2-dropdown').append(add_btn);\n\t\t\t\t$(search_btn).add(add_btn).click(function(){\n\t\t\t\t\t$('select').select2('close');\n\t\t\t\t});\n\t\t\t\t\n\t\t\t});\n\t\t}\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function(){return this._.select.getElement()},add:function(b,a,d){var e=new CKEDITOR.dom.element(\"option\",this.getDialog().getParentEditor().document),c=this.getInputElement().$;e.$.text=b;e.$.value=void 0===a||null===a?b:a;void 0===d||null===d?CKEDITOR.env.ie?c.add(e.$):c.add(e.$,null):c.add(e.$,d);return this},remove:function(b){this.getInputElement().$.remove(b);return this},clear:function(){for(var b=this.getInputElement().$;0<", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function load_agent_form(resource_id, stonith) {\n var url;\n var form;\n if (stonith) {\n form = $(\"#stonith_agent_form\");\n url = '/managec/' + Pcs.cluster_name + '/fence_device_form';\n } else {\n form = $(\"#resource_agent_form\");\n url = '/managec/' + Pcs.cluster_name + '/resource_form?version=2';\n }\n\n form.empty();\n\n var resource_obj = Pcs.resourcesContainer.get_resource_by_id(resource_id);\n if (!resource_obj || !resource_obj.get('is_primitive'))\n return;\n\n var data = {resource: resource_id};\n\n $.ajax({\n type: 'GET',\n url: url,\n data: data,\n timeout: pcs_timeout,\n success: function (data) {\n Ember.run.next(function(){form.html(data);});\n }\n });\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " function singleRead(psrc, pdst, chunk) {\n src.read(srcHandle,\n readbuf,\n psrc,\n chunk,\n pdst,\n makeCb(psrc, pdst, chunk));\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "Conf.prototype.loadExtras = function (cb) {\n this.setUser(function (er) {\n if (er) return cb(er)\n this.loadUid(function (er) {\n if (er) return cb(er)\n // Without prefix, nothing will ever work\n correctMkdir(this.prefix, cb)\n }.bind(this))\n }.bind(this))\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "vulnerable"} {"code": "this.editor.graph.pageVisible;0==q&&(this.editor.graph.pageVisible=q);var X=this.createDownloadRequest(M,d,l,W,x,p,y,A,B,I,O,P,K);this.editor.graph.pageVisible=U;return X}catch(u){this.handleError(u)}}))}else{var F=null,H=mxUtils.bind(this,function(M){M.length<=MAX_REQUEST_SIZE?this.saveData(z,\"svg\",M,\"image/svg+xml\"):this.handleError({message:mxResources.get(\"drawingTooLarge\")},mxResources.get(\"error\"),mxUtils.bind(this,function(){mxUtils.popup(F)}))});if(\"svg\"==d){var S=this.editor.graph.background;", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxClient.IS_FF||5<=document.documentMode?n.select():document.execCommand(\"selectAll\",!1,null)):K.focus()};EditorUi.prototype.showRemoteExportDialog=function(c,e,g,k,m){var q=document.createElement(\"div\");q.style.whiteSpace=\"nowrap\";var v=document.createElement(\"h3\");mxUtils.write(v,mxResources.get(\"image\"));v.style.cssText=\"width:100%;text-align:center;margin-top:0px;margin-bottom:\"+(m?\"10\":\"4\")+\"px\";q.appendChild(v);if(m){mxUtils.write(q,mxResources.get(\"zoom\")+\":\");var x=document.createElement(\"input\");\nx.setAttribute(\"type\",\"text\");x.style.marginRight=\"16px\";x.style.width=\"60px\";x.style.marginLeft=\"4px\";x.style.marginRight=\"12px\";x.value=this.lastExportZoom||\"100%\";q.appendChild(x);mxUtils.write(q,mxResources.get(\"borderWidth\")+\":\");var A=document.createElement(\"input\");A.setAttribute(\"type\",\"text\");A.style.marginRight=\"16px\";A.style.width=\"60px\";A.style.marginLeft=\"4px\";A.value=this.lastExportBorder||\"0\";q.appendChild(A);mxUtils.br(q)}var z=this.addCheckbox(q,mxResources.get(\"selectionOnly\"),!1,\nthis.editor.graph.isSelectionEmpty()),L=k?null:this.addCheckbox(q,mxResources.get(\"includeCopyOfMyDiagram\"),Editor.defaultIncludeDiagram);v=this.editor.graph;var M=k?null:this.addCheckbox(q,mxResources.get(\"transparentBackground\"),v.background==mxConstants.NONE||null==v.background);null!=M&&(M.style.marginBottom=\"16px\");c=new CustomDialog(this,q,mxUtils.bind(this,function(){var n=parseInt(x.value)/100||1,y=parseInt(A.value)||0;g(!z.checked,null!=L?L.checked:!1,null!=M?M.checked:!1,n,y)}),null,c,e);\nthis.showDialog(c.container,300,(m?25:0)+(k?125:210),!0,!0)};EditorUi.prototype.showExportDialog=function(c,e,g,k,m,q,v,x,A){v=null!=v?v:Editor.defaultIncludeDiagram;var z=document.createElement(\"div\");z.style.whiteSpace=\"nowrap\";var L=this.editor.graph,M=\"jpeg\"==x?220:300,n=document.createElement(\"h3\");mxUtils.write(n,c);n.style.cssText=\"width:100%;text-align:center;margin-top:0px;margin-bottom:10px\";z.appendChild(n);mxUtils.write(z,mxResources.get(\"zoom\")+\":\");var y=document.createElement(\"input\");", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "Runnable.prototype.run = function(fn){\n var self = this\n , ms = this.timeout()\n , start = new Date\n , ctx = this.ctx\n , finished\n , emitted;\n\n if (ctx) ctx.runnable(this);\n\n // timeout\n if (this.async) {\n if (ms) {\n this.timer = setTimeout(function(){\n done(new Error('timeout of ' + ms + 'ms exceeded'));\n self.timedOut = true;\n }, ms);\n }\n }\n\n // called multiple times\n function multiple(err) {\n if (emitted) return;\n emitted = true;\n self.emit('error', err || new Error('done() called multiple times'));\n }\n\n // finished\n function done(err) {\n if (self.timedOut) return;\n if (finished) return multiple(err);\n self.clearTimeout();\n self.duration = new Date - start;\n finished = true;\n fn(err);\n }\n\n // for .resetTimeout()\n this.callback = done;\n\n // async\n if (this.async) {\n try {\n this.fn.call(ctx, function(err){\n if (err instanceof Error || toString.call(err) === \"[object Error]\") return done(err);\n if (null != err) return done(new Error('done() invoked with non-Error: ' + err));\n done();\n });\n } catch (err) {\n done(err);\n }\n return;\n }\n\n if (this.asyncOnly) {\n return done(new Error('--async-only option in use without declaring `done()`'));\n }\n\n // sync\n try {\n if (!this.pending) this.fn.call(ctx);\n this.duration = new Date - start;\n fn();\n } catch (err) {\n fn(err);\n }\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " \"should return true\": function (res) {\n assert.isTrue(res);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "P)this.editPlantUmlData(E,G,P);else if(P=this.graph.getAttributeForCell(E,\"mermaidData\"),null!=P)this.editMermaidData(E,G,P);else{var J=g.getCellStyle(E);\"1\"==mxUtils.getValue(J,\"metaEdit\",\"0\")?d.showDataDialog(E):k.apply(this,arguments)}}catch(F){d.handleError(F)}};g.getLinkTitle=function(E){return d.getLinkTitle(E)};g.customLinkClicked=function(E){var G=!1;try{d.handleCustomLink(E),G=!0}catch(P){d.handleError(P)}return G};var l=g.parseBackgroundImage;g.parseBackgroundImage=function(E){var G=l.apply(this,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\"#fc_showFooter_info\",function(){$(this).toggleClass(\"fc_active\").parent(\"#fc_footer_info\").children(\"ul\").slideToggle(300)});void 0!==typeof window.qtip&&$('[title!=\"\"]').qtip({content:{attr:\"title\"},style:{classes:\"qtip-light qtip-shadow qtip-rounded\"}})});(function(a){a.fn.page_tree=function(b){b=a.extend({beforeSend:function(){},afterSend:function(){}},b);return this.each(function(){var b=a(this);1:, /, \\\\, ?, &, *, \\', \"');\n return;\n }\n var r = $scope.requisitionsData.getRequisition(foreignSource);\n if (r) {\n bootbox.alert('Cannot add the requisition ' + foreignSource+ ' because there is already a requisition with that name');\n return;\n }\n // Create Requisition\n RequisitionsService.addRequisition(foreignSource).then(\n function(r) { // success\n growl.success('The requisition ' + r.foreignSource + ' has been created.');\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " afterrender: function () {\n Ext.get(this.getIframe()).on('load', function () {\n this.iFrameLoaded();\n }.bind(this));\n }.bind(this)", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " onData: function(stream, session, callback) {\n stream.on('data', function() {});\n stream.on('end', callback);\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "NyanCat.prototype.drawScoreboard = function() {\n var stats = this.stats;\n var colors = Base.colors;\n\n function draw(color, n) {\n write(' ');\n write('\\u001b[' + color + 'm' + n + '\\u001b[0m');\n write('\\n');\n }\n\n draw(colors.green, stats.passes);\n draw(colors.fail, stats.failures);\n draw(colors.pending, stats.pending);\n write('\\n');\n\n this.cursorUp(this.numberOfLines);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "N.message)}else null!=this.graph.extFonts&&0c&&!mxClient.IS_IOS?C.firstChild.nextSibling.setAttribute(\"title\",E.shortcut):l.apply(this,arguments)};var p=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){p.apply(this,arguments);if(null!=this.userElement){var C=this.userElement;C.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+C.style.display;C.className=\"geToolbarButton\";C.innerHTML=\"\";C.style.backgroundImage=\"url(\"+Editor.userImage+\")\";C.style.backgroundPosition=\"center center\";", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " destroy() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._protocol.channelClose(this.outgoing.id);\n }\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " var url2FilePath = function(url){\n var subPath = url.substr(\"/tests/frontend\".length);\n if (subPath == \"\"){\n subPath = \"index.html\"\n }\n subPath = subPath.split(\"?\")[0];\n\n var filePath = path.normalize(npm.root + \"/../tests/frontend/\")\n filePath += subPath.replace(\"..\", \"\");\n return filePath;\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "Mocha.prototype.bail = function(bail) {\n if (0 == arguments.length) bail = true;\n this.suite.bail(bail);\n return this;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=\nc.value&&c.value.nodeType==mxConstants.NODETYPE_ELEMENT){var e=d;d=mxUtils.importNode(b.document,c.value,!0);d.appendChild(e);b=e.getAttribute(\"id\");d.setAttribute(\"id\",b);e.removeAttribute(\"id\")}return d};a.beforeDecode=function(b,c,d){var e=c.cloneNode(!0),f=this.getName();c.nodeName!=f?(e=c.getElementsByTagName(f)[0],null!=e&&e.parentNode==c?(mxUtils.removeWhitespace(e,!0),mxUtils.removeWhitespace(e,!1),e.parentNode.removeChild(e)):e=null,d.value=c.cloneNode(!0),c=d.value.getAttribute(\"id\"),null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "Mocha.prototype.globals = function(globals){\n this.options.globals = (this.options.globals || []).concat(globals);\n return this;\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "b,c,d){var e,f,g,j,i,o,l=a.aoColumns;if(b)for(e=b.length-1;0<=e;e--){o=b[e];var q=o.targets!==k?o.targets:o.aTargets;h.isArray(q)||(q=[q]);f=0;for(g=q.length;fq[f])d(l.length+q[f],o);else if(\"string\"===typeof q[f]){j=0;for(i=l.length;ja.Y?22801:1,b||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};d.transform=function(a,c,b,e){return d.format(d.parse(a,c),b,e)};d.addYears=function(a,c){return d.addMonths(a,12*c)};d.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};d.addDays=function(a,c){var b=new Date(a.getTime());b.setDate(b.getDate()+c);return b};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "CKEDITOR.dom.nodeList.prototype={count:function(){return this.$.length},getItem:function(a){if(a<0||a>=this.$.length)return null;return(a=this.$[a])?new CKEDITOR.dom.node(a):null}};CKEDITOR.dom.element=function(a,e){typeof a==\"string\"&&(a=(e?e.$:document).createElement(a));CKEDITOR.dom.domObject.call(this,a)};CKEDITOR.dom.element.get=function(a){return(a=typeof a==\"string\"?document.getElementById(a)||document.getElementsByName(a)[0]:a)&&(a.$?a:new CKEDITOR.dom.element(a))};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.addMenuItems(O,[\"copyAsImage\"],null,ea)};EditorUi.prototype.toggleFormatPanel=function(O){null!=this.formatWindow?this.formatWindow.window.setVisible(null!=O?O:!this.formatWindow.window.isVisible()):b(this)};DiagramFormatPanel.prototype.isMathOptionVisible=function(){return!0};var G=EditorUi.prototype.destroy;EditorUi.prototype.destroy=function(){null!=this.sidebarWindow&&(this.sidebarWindow.window.setVisible(!1),this.sidebarWindow.window.destroy(),this.sidebarWindow=null);null!=this.formatWindow&&", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "l.select();a.fire(\"saveSnapshot\");e=1}else if((j=h.contains([\"td\",\"th\",\"caption\"]))&&l.checkBoundaryOfElement(j,c?CKEDITOR.START:CKEDITOR.END))e=1}return!e});a.blockless&&(CKEDITOR.env.ie&&CKEDITOR.env.needsBrFiller)&&this.attachListener(this,\"keyup\",function(b){if(b.data.getKeystroke()in p&&!this.getFirst(c)){this.appendBogus();b=a.createRange();b.moveToPosition(this,CKEDITOR.POSITION_AFTER_START);b.select()}});this.attachListener(this,\"dblclick\",function(b){if(a.readOnly)return false;b={element:b.data.getTarget()};\na.fire(\"doubleclick\",b)});CKEDITOR.env.ie&&this.attachListener(this,\"click\",b);!CKEDITOR.env.ie&&!CKEDITOR.env.opera&&this.attachListener(this,\"mousedown\",function(b){var c=b.data.getTarget();if(c.is(\"img\",\"hr\",\"input\",\"textarea\",\"select\")){a.getSelection().selectElement(c);c.is(\"input\",\"textarea\",\"select\")&&b.data.preventDefault()}});CKEDITOR.env.gecko&&this.attachListener(this,\"mouseup\",function(b){if(b.data.$.button==2){b=b.data.getTarget();if(!b.getOuterHtml().replace(i,\"\")){var c=a.createRange();", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-697", "cwe_name": "Incorrect Comparison", "description": "The software compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.", "url": "https://cwe.mitre.org/data/definitions/697.html", "label_name": "safe"} {"code": "\t\t\t\t\t\tpattern: RegExp(/((?:^|[^\\\\])(?:\\\\\\\\)*)\\$\\{(?:(?!\\})(?:))*\\}/.source.replace(//g, function () { return FTL_EXPR; })),", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " const res = (result) => {\n let val = '';\n if (!pattern || ((typeof pattern !== 'object') && (typeof pattern !== 'string') && typeof pattern !== 'function')) {\n val = String(pattern);\n } else if (pattern.constructor === JpvObject) {\n val = `operator \"${pattern.type}\": ${JSON.stringify(pattern.value)}`;\n } else {\n JSON.stringify(pattern);\n }\n\n if (typeof pattern === 'function') {\n val = pattern.toString();\n }\n if (!result && options && options.debug) {\n options.logger(`error - the value of: {${options.deepLog.join('.')}: ` +\n `${String(value)}} not matched with: ${val}`);\n }\n return result;\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " text: String.format(i18n._('User: {0}'), Tine.Tinebase.registry.get('currentAccount').accountDisplayName),\n menu: this.getUserActions(),\n menuAlign: 'tr-br',\n iconCls: Tine.Tinebase.registry.get('userAccountChanged') ? 'renderer_accountUserChangedIcon' : 'renderer_accountUserIcon'\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "a.ui.addButton(\"Source\",{label:a.lang.sourcearea.toolbar,command:\"source\",toolbar:\"mode,10\"});a.on(\"mode\",function(){a.getCommand(\"source\").setState(\"source\"==a.mode?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF)})}}});var c=CKEDITOR.tools.createClass({base:CKEDITOR.editable,proto:{setData:function(a){this.setValue(a);this.editor.fire(\"dataReady\")},getData:function(){return this.getValue()},insertHtml:function(){},insertElement:function(){},insertText:function(){},setReadOnly:function(a){this[(a?\"set\":", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\tfunction objectKeys(obj)\n\t\t{\n\t\t\tif (typeof obj !== 'object')\n\t\t\t\treturn [];\n\t\t\tvar keys = [];\n\t\t\tfor (var key in obj)\n\t\t\t\tkeys.push(key);\n\t\t\treturn keys;\n\t\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": "mxResources.get(\"containsValidationErrors\"),mxResources.get(\"ok\"));else if(B&&b.hideDialog(),O=!y.model.contains(A),!B||O||I!=q){I=Graph.compress(I);y.getModel().beginUpdate();try{if(O){var t=b.editor.graph.getFreeInsertPoint();A.geometry.x=t.x;A.geometry.y=t.y;y.addCell(A)}y.setCellStyles(mxConstants.STYLE_SHAPE,\"stencil(\"+I+\")\",[A])}catch(z){throw z;}finally{y.getModel().endUpdate()}O&&(y.setSelectionCell(A),y.scrollCellToVisible(A))}};f=mxUtils.button(mxResources.get(\"preview\"),function(){x(l,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "parseInt(this.div.style.left)+150+\"px\"):(this.div.style.width=\"240px\",this.table.style.width=\"240px\",this.div.style.left=Math.max(0,parseInt(this.div.style.left)-150)+\"px\");this.fit()};mxEvent.addListener(this.formatWindow.window.title,\"dblclick\",mxUtils.bind(this,function(D){mxEvent.getSource(D)==this.formatWindow.window.title&&this.formatWindow.window.toggleMinimized()}))}};var L=EditorUi.prototype.init;EditorUi.prototype.init=function(){function C(da,ca,la){var ia=F.menus.get(da),ma=M.addMenu(mxResources.get(da),\nmxUtils.bind(this,function(){ia.funct.apply(this,arguments)}),V);ma.className=\"1\"==urlParams.sketch?\"geToolbarButton\":\"geMenuItem\";ma.style.display=\"inline-block\";ma.style.boxSizing=\"border-box\";ma.style.top=\"6px\";ma.style.marginRight=\"6px\";ma.style.height=\"30px\";ma.style.paddingTop=\"6px\";ma.style.paddingBottom=\"6px\";ma.style.cursor=\"pointer\";ma.setAttribute(\"title\",mxResources.get(da));F.menus.menuCreated(ia,ma,\"geMenuItem\");null!=la?(ma.style.backgroundImage=\"url(\"+la+\")\",ma.style.backgroundPosition=\n\"center center\",ma.style.backgroundRepeat=\"no-repeat\",ma.style.backgroundSize=\"24px 24px\",ma.style.width=\"34px\",ma.innerHTML=\"\"):ca||(ma.style.backgroundImage=\"url(\"+mxWindow.prototype.normalizeImage+\")\",ma.style.backgroundPosition=\"right 6px center\",ma.style.backgroundRepeat=\"no-repeat\",ma.style.paddingRight=\"22px\");return ma}function D(da,ca,la,ia,ma,qa){var pa=document.createElement(\"a\");pa.className=\"1\"==urlParams.sketch?\"geToolbarButton\":\"geMenuItem\";pa.style.display=\"inline-block\";pa.style.boxSizing=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "B)):N.isSelectionEmpty()&&N.isEnabled()?(B.addSeparator(),this.addMenuItems(B,[\"editData\"],null,G),B.addSeparator(),this.addSubmenu(\"layout\",B),this.addSubmenu(\"insert\",B),this.addMenuItems(B,[\"-\",\"exitGroup\"],null,G)):N.isEnabled()&&this.addMenuItems(B,[\"-\",\"lockUnlock\"],null,G)};var A=Menus.prototype.addPopupMenuEditItems;Menus.prototype.addPopupMenuEditItems=function(B,F,G){A.apply(this,arguments);this.editorUi.editor.graph.isSelectionEmpty()&&this.addMenuItems(B,[\"copyAsImage\"],null,G)};EditorUi.prototype.toggleFormatPanel=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "Ia),!0,null,!0);var Ja=document.createElement(\"div\");Ja.className=\"geTempDlgDialogMask\";M.appendChild(Ja);var Oa=b.sidebar.hideTooltip;b.sidebar.hideTooltip=function(){Ja&&(M.removeChild(Ja),Ja=null,Oa.apply(this,arguments),b.sidebar.hideTooltip=Oa)};mxEvent.addListener(Ja,\"click\",function(){b.sidebar.hideTooltip()})}}var qa=null;if(Da||b.sidebar.currentElt==da)b.sidebar.hideTooltip();else{var pa=function(na){Da&&b.sidebar.currentElt==da&&ma(na,mxEvent.getClientX(la),mxEvent.getClientY(la));Da=!1;\nca.src=\"/images/icon-search.svg\"};b.sidebar.hideTooltip();b.sidebar.currentElt=da;Da=!0;ca.src=\"/images/aui-wait.gif\";ha.isExt?g(ha,pa,function(){A(mxResources.get(\"cantLoadPrev\"));Da=!1;ca.src=\"/images/icon-search.svg\"}):ia(ha.url,pa)}}function t(ha,da,ca){if(null!=E){for(var la=E.className.split(\" \"),ia=0;iab)b=a}return b}function k(e,d){for(var b=p(e),c=b[0].getAscendant(\"table\"),a=r(b,1),b=r(b),a=d?a:b,f=CKEDITOR.tools.buildTableMap(c),c=[],b=[],g=f.length,h=0;h').addClass('link-' + id).attr('data-id', id);\n\n var nameHtml = '
    ' + this.getHelper().escapeString(name) + ' ' + '
    ';\n var removeHtml = '';\n\n $left = $('
    ');\n $left.append(nameHtml);\n $el.append($left);\n\n $right = $('
    ');\n $right.append(removeHtml);\n $el.append($right);\n\n var isPrimary = (id == this.primaryId);\n var iconHtml = '';\n var title = this.translate('Primary');\n var $primary = $('');\n $primary.insertBefore($el.children().first().children().first());\n\n $container.append($el);\n\n this.managePrimaryButton();\n\n return $el;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\"\").test(b)||(b=b+(\" \"+a)));this.$.className=b||a},removeClass:function(a){var b=this.getAttribute(\"class\");if(b){a=RegExp(\"(?:^|\\\\s+)\"+a+\"(?=\\\\s|$)\",\"i\");if(a.test(b))(b=b.replace(a,\"\").replace(/^\\s+/,\"\"))?this.setAttribute(\"class\",b):this.removeAttribute(\"class\")}return this},hasClass:function(a){return RegExp(\"(?:^|\\\\s+)\"+a+\"(?=\\\\s|$)\",\"\").test(this.getAttribute(\"class\"))},append:function(a,b){typeof a==\"string\"&&(a=this.getDocument().createElement(a));b?this.$.insertBefore(a.$,this.$.firstChild):", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $scope.delete = function(foreignSource) {\n bootbox.confirm('Are you sure you want to remove the requisition ' + _.escape(foreignSource) + '?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.deleteRequisition(foreignSource).then(\n function() { // success\n growl.success('The requisition ' + _.escape(foreignSource) + ' has been deleted.');\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "S&&S(M)}}))}catch(L){null!=S&&S(L)}}),N,sa)}catch(Pa){null!=S&&S(Pa)}};Editor.crcTable=[];for(var D=0;256>D;D++)for(var t=D,F=0;8>F;F++)t=1==(t&1)?3988292384^t>>>1:t>>>1,Editor.crcTable[D]=t;Editor.updateCRC=function(u,J,N,W){for(var S=0;S>>8;return u};Editor.crc32=function(u){for(var J=-1,N=0;N>>8^Editor.crcTable[(J^u.charCodeAt(N))&255];return(J^-1)>>>0};Editor.writeGraphModelToPng=function(u,J,N,W,S){function P(sa,Ba){var ta=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "Graph.sanitizeHtml=function(b,e){return DOMPurify.sanitize(b,{ADD_ATTR:[\"target\"],FORBID_TAGS:[\"form\"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|callto|data):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i})};Graph.sanitizeSvg=function(b){return DOMPurify.sanitize(b,{IN_PLACE:!0})};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "G.prototype.g=function() {for(;!this.o;) {var e=J(this,3);e&1&&(this.o=!0);e>>>=1;switch(e) {case 0:var c=this.input,d=this.c,b=this.b,a=this.a,f=c.length,g=q,k=q,m=b.length,p=q;this.d=this.f=0;d+1>=f&&n(Error(\"invalid uncompressed block header: LEN\"));g=c[d++]|c[d++]<<8;d+1>=f&&n(Error(\"invalid uncompressed block header: NLEN\"));k=c[d++]|c[d++]<<8;g===~k&&n(Error(\"invalid uncompressed block header: length verify\"));d+g>c.length&&n(Error(\"input buffer is broken\"));switch(this.k) {case I:for(;a+g>b.length;) {p=\nm-a;g-=p;if (u)b.set(c.subarray(d,d+p),a),a+=p,d+=p;else for(;p--;)b[a++]=c[d++];this.a=a;b=this.e();a=this.a}break;case H:for(;a+g>b.length;)b=this.e({t:2});break;default:n(Error(\"invalid inflate mode\"))}if (u)b.set(c.subarray(d,d+g),a),a+=g,d+=g;else for(;g--;)b[a++]=c[d++];this.c=d;this.a=a;this.b=b;break;case 1:this.l(da,ea);break;case 2:fa(this);break;default:n(Error(\"unknown BTYPE: \"+e))}}return this.q()};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],B=w?new Uint32Array(z):z;function C(a) {var b=a.length,c=0,d=Number.POSITIVE_INFINITY,f,h,k,e,g,l,p,s,r,A;for(s=0;sc&&(c=a[s]),a[s]>=1;A=k<<16|s;for(r=l;rE;E++)switch(!0) {case 143>=E:D.push([E+48,8]);break;case 255>=E:D.push([E-144+400,9]);break;case 279>=E:D.push([E-256+0,7]);break;case 287>=E:D.push([E-280+192,8]);break;default:m(\"invalid literal: \"+E)}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tthis.error = function() {\n\t\tvar arg = arguments[0];\n\t\treturn arguments.length == 1 && typeof(arg) == 'function'\n\t\t\t? self.bind('error', arg)\n\t\t\t: self.trigger('error', {error : arg});\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "mxResources.get(Qa);null==Ma&&(Ma=Qa.substring(0,1).toUpperCase()+Qa.substring(1));Qa=Ma+\" (\"+Ya.length+\")\";var Ta=Ma=mxUtils.htmlEntities(Ma);15 entry.mtime)\n return this[SKIP](entry)\n else if (this[ISREUSABLE](entry, st))\n return this[MAKEFS](null, entry, neverCalled)\n else {\n try {\n if (st.isDirectory()) {\n if (entry.type === 'Directory') {\n if (!this.noChmod && entry.mode && (st.mode & 0o7777) !== entry.mode)\n fs.chmodSync(entry.absolute, entry.mode)\n } else\n fs.rmdirSync(entry.absolute)\n } else\n unlinkFileSync(entry.absolute)\n return this[MAKEFS](null, entry, neverCalled)\n } catch (er) {\n return this[ONERROR](er, entry)\n }\n }\n } catch (er) {\n return this[MAKEFS](null, entry, neverCalled)\n }\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": " changePassword: function(newPassword) {\n var d = $q.defer(),\n loginCookie = readLoginCookie();\n\n $http({\n method: 'POST',\n url: '/SOGo/so/changePassword',\n data: {\n userName: loginCookie[0],\n password: loginCookie[1],\n newPassword: newPassword }\n }).then(d.resolve, function(response) {\n var error,\n data = response.data,\n perr = data.LDAPPasswordPolicyError;\n\n if (!perr) {\n perr = passwordPolicyConfig.PolicyPasswordSystemUnknown;\n error = _(\"Unhandled error response\");\n }\n else if (perr == passwordPolicyConfig.PolicyNoError) {\n error = l(\"Password change failed\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordModNotAllowed) {\n error = l(\"Password change failed - Permission denied\");\n } else if (perr == passwordPolicyConfig.PolicyInsufficientPasswordQuality) {\n error = l(\"Password change failed - Insufficient password quality\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordTooShort) {\n error = l(\"Password change failed - Password is too short\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordTooYoung) {\n error = l(\"Password change failed - Password is too young\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordInHistory) {\n error = l(\"Password change failed - Password is in history\");\n } else {\n error = l(\"Unhandled policy error: %{0}\").formatted(perr);\n perr = passwordPolicyConfig.PolicyPasswordUnknown;\n }\n\n d.reject(error);\n });\n return d.promise;\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "module.exports.commit = function (files, message, newVer, tagName, callback) {\n message = message.replace('%s', newVer).replace('\"', '').replace(\"'\", '');\n files = files.map(function (file) {\n return '\"' + escapeQuotes(file) + '\"';\n }).join(' ');\n var functionSeries = [\n function (done) {\n cp.exec(gitApp + ' add ' + files, gitExtra, done);\n },\n\n function (done) {\n cp.exec([gitApp, 'commit', '-m', '\"' + message + '\"'].join(' '), gitExtra, done);\n },\n\n function (done) {\n cp.exec(\n [\n gitApp, 'tag', '-a', tagName, '-m', '\"' + message + '\"'\n ].join(' '),\n gitExtra, done\n );\n }\n ];\n contra.series(functionSeries, callback);\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " createTreeNode: function(nodeData, target) {\n var nodeName = nodeData.name;\n if(typeof nodeName == 'object') {\n nodeName = nodeName.name;\n }\n \n var newNodeRecord = new Tine.Filemanager.Model.Node(nodeData);\n \n var newNode = new Ext.tree.AsyncTreeNode({\n text: nodeName,\n path: nodeData.path,\n name: nodeData.name,\n nodeRecord: newNodeRecord,\n account_grants: nodeData.account_grants,\n id: nodeData.id\n })\n \n newNode.attributes.nodeRecord.beginEdit();\n newNode.attributes.nodeRecord.set('path', nodeData.path);\n newNode.attributes.nodeRecord.endEdit();\n \n newNode.parentNode = target;\n return newNode;\n \n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "this.customFonts)))}finally{U.getModel().endUpdate()}}}));this.editorUi.showDialog(W.container,380,Editor.enableWebFonts?250:180,!0,!0);W.init()}),y,null,!0)})))}})();function DiagramPage(b,f){this.node=b;null!=f?this.node.setAttribute(\"id\",f):null==this.getId()&&this.node.setAttribute(\"id\",Editor.guid())}DiagramPage.prototype.node=null;DiagramPage.prototype.root=null;DiagramPage.prototype.viewState=null;DiagramPage.prototype.getId=function(){return this.node.getAttribute(\"id\")};DiagramPage.prototype.getName=function(){return this.node.getAttribute(\"name\")};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "S&&S(M)}}))}catch(L){null!=S&&S(L)}}),N,sa)}catch(Pa){null!=S&&S(Pa)}};Editor.crcTable=[];for(var D=0;256>D;D++)for(var t=D,F=0;8>F;F++)t=1==(t&1)?3988292384^t>>>1:t>>>1,Editor.crcTable[D]=t;Editor.updateCRC=function(u,J,N,W){for(var S=0;S>>8;return u};Editor.crc32=function(u){for(var J=-1,N=0;N>>8^Editor.crcTable[(J^u.charCodeAt(N))&255];return(J^-1)>>>0};Editor.writeGraphModelToPng=function(u,J,N,W,S){function P(sa,Ba){var ta=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\"pagecount\"==D?null!=d.pages?d.pages.length:1:O.apply(this,arguments)};var t=g.labelLinkClicked;g.labelLinkClicked=function(D,G,P){var K=G.getAttribute(\"href\");if(null==K||!g.isCustomLink(K)||!mxEvent.isTouchEvent(P)&&mxEvent.isPopupTrigger(P))t.apply(this,arguments);else{if(!g.isEnabled()||null!=D&&g.isCellLocked(D.cell))g.customLinkClicked(K),g.getRubberband().reset();mxEvent.consume(P)}};this.editor.getOrCreateFilename=function(){var D=d.defaultFilename,G=d.getCurrentFile();null!=G&&(D=null!=G.getTitle()?", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " peek: function(i) {\n var num = i || 1;\n return (this.index + num < this.text.length) ? this.text.charAt(this.index + num) : false;\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "2)?O.substring(45,O.lastIndexOf(\"%26ex\")):O.substring(2);this.showError(g,x,mxResources.get(\"openInNewWindow\"),mxUtils.bind(this,function(){this.editor.graph.openLink(\"https://drive.google.com/open?id=\"+O);this.handleError(d,g,k,l,p)}),I,mxResources.get(\"changeUser\"),mxUtils.bind(this,function(){function z(){G.innerHTML=\"\";for(var P=0;P\");K.setAttribute(\"disabled\",\"disabled\");G.appendChild(K)}K=document.createElement(\"option\");mxUtils.write(K,mxResources.get(\"addAccount\"));K.value=L.length;G.appendChild(K)}var L=this.drive.getUsersList(),C=document.createElement(\"div\"),D=document.createElement(\"span\");D.style.marginTop=\"6px\";mxUtils.write(D,mxResources.get(\"changeUser\")+\": \");C.appendChild(D);var G=document.createElement(\"select\");G.style.width=\"200px\";z();mxEvent.addListener(G,\"change\",mxUtils.bind(this,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "!a.is(\"br\")){a=CKEDITOR.env.opera?this.getDocument().createText(\"\"):this.getDocument().createElement(\"br\");CKEDITOR.env.gecko&&a.setAttribute(\"type\",\"_moz\");this.append(a)}}},breakParent:function(a){var b=new CKEDITOR.dom.range(this.getDocument());b.setStartAfter(this);b.setEndAfter(a);a=b.extractContents();b.insertNode(this.remove());a.insertAfterNode(this)},contains:CKEDITOR.env.ie||CKEDITOR.env.webkit?function(a){var b=this.$;return a.type!=CKEDITOR.NODE_ELEMENT?b.contains(a.getParent().$):b!=\na.$&&b.contains(a.$)}:function(a){return!!(this.$.compareDocumentPosition(a.$)&16)},focus:function(){function a(){try{this.$.focus()}catch(b){}}return function(b){b?CKEDITOR.tools.setTimeout(a,100,this):a.call(this)}}(),getHtml:function(){var a=this.$.innerHTML;return CKEDITOR.env.ie?a.replace(/<\\?[^>]*>/g,\"\"):a},getOuterHtml:function(){if(this.$.outerHTML)return this.$.outerHTML.replace(/<\\?[^>]*>/,\"\");var a=this.$.ownerDocument.createElement(\"div\");a.appendChild(this.$.cloneNode(true));return a.innerHTML},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "var pushVal = function pushVal(obj, path, val) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n if (obj === undefined || obj === null || path === undefined) {\n return obj;\n } // Clean the path\n\n\n path = clean(path);\n var pathParts = split(path);\n var part = pathParts.shift();\n if (part === \"__proto__\") return obj;\n\n if (pathParts.length) {\n // Generate the path part in the object if it does not already exist\n obj[part] = decouple(obj[part], options) || {}; // Recurse\n\n pushVal(obj[part], pathParts.join(\".\"), val, options);\n } else if (part) {\n // We have found the target array, push the value\n obj[part] = decouple(obj[part], options) || [];\n\n if (!(obj[part] instanceof Array)) {\n throw \"Cannot push to a path whose leaf node is not an array!\";\n }\n\n obj[part].push(val);\n } else {\n // We have found the target array, push the value\n obj = decouple(obj, options) || [];\n\n if (!(obj instanceof Array)) {\n throw \"Cannot push to a path whose leaf node is not an array!\";\n }\n\n obj.push(val);\n }\n\n return decouple(obj, options);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "[H],\"{1} ago\"));F.setAttribute(\"title\",J.toLocaleDateString()+\" \"+J.toLocaleTimeString())}function k(J){var F=document.createElement(\"img\");F.className=\"geCommentBusyImg\";F.src=IMAGE_PATH+\"/spin.gif\";J.appendChild(F);J.busyImg=F}function l(J){J.style.border=\"1px solid red\";J.removeChild(J.busyImg)}function p(J){J.style.border=\"\";J.removeChild(J.busyImg)}function q(J,F,H,S,V){function M(N,Q,R){var Y=document.createElement(\"li\");Y.className=\"geCommentAction\";var ba=document.createElement(\"a\");ba.className=\n\"geCommentActionLnk\";mxUtils.write(ba,N);Y.appendChild(ba);mxEvent.addListener(ba,\"click\",function(ea){Q(ea,J);ea.preventDefault();mxEvent.consume(ea)});T.appendChild(Y);R&&(Y.style.display=\"none\")}function W(){function N(Y){Q.push(R);if(null!=Y.replies)for(var ba=0;ba ({\n name,\n ...self.imageSizes[name]\n }));\n self.name = 'attachment';\n self.fileGroups = self.options.fileGroups || [\n {\n name: 'images',\n label: 'apostrophe:images',\n extensions: [\n 'gif',\n 'jpg',\n 'png',\n 'svg'\n ],\n extensionMaps: { jpeg: 'jpg' },\n // uploadfs should treat this as an image and create scaled versions\n image: true\n },\n {\n name: 'office',\n label: 'apostrophe:office',\n extensions: [\n 'txt',\n 'rtf',\n 'pdf',\n 'xls',\n 'ppt',\n 'doc',\n 'pptx',\n 'sldx',\n 'ppsx',\n 'potx',\n 'xlsx',\n 'xltx',\n 'csv',\n 'docx',\n 'dotx'\n ],\n extensionMaps: {},\n // uploadfs should just accept this file as-is\n image: false\n }\n ];\n\n // Do NOT add keys here unless they have the value `true`\n self.croppable = {\n gif: true,\n jpg: true,\n png: true\n };\n\n // Do NOT add keys here unless they have the value `true`\n self.sized = {\n gif: true,\n jpg: true,\n png: true\n };\n\n self.sizeAvailableInArchive = self.options.sizeAvailableInArchive || 'one-sixth';\n\n self.rescaleTask = require('./lib/tasks/rescale.js')(self);\n self.addFieldType();\n self.enableBrowserData();\n\n self.db = await self.apos.db.collection('aposAttachments');\n await self.db.createIndex({ docIds: 1 });\n await self.db.createIndex({ archivedDocIds: 1 });\n self.addLegacyMigrations();\n self.addSvgSanitizationMigration();\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "const mergeUrls = base => input => (\n typeof input === 'string' ?\n new URL (input, base).href :\n base\n);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": "F.createStatusContainer();F.statusContainer.style.position=\"relative\";F.statusContainer.style.maxWidth=\"\";F.statusContainer.style.marginTop=\"7px\";F.statusContainer.style.marginLeft=\"6px\";F.statusContainer.style.color=\"gray\";F.statusContainer.style.cursor=\"default\";var W=F.hideCurrentMenu;F.hideCurrentMenu=function(){W.apply(this,arguments);this.editor.graph.popupMenuHandler.hideMenu()};var U=F.descriptorChanged;F.descriptorChanged=function(){U.apply(this,arguments);var da=F.getCurrentFile();if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\"geTempDlgCreateBtn geTempDlgBtnDisabled\")}function y(fa,ca){if(null!=I){var ba=function(oa){qa.isExternal?e(qa,function(na){ja(na,oa)},ia):qa.url?mxUtils.get(TEMPLATE_PATH+\"/\"+qa.url,mxUtils.bind(this,function(na){200<=na.getStatus()&&299>=na.getStatus()?ja(na.getText(),oa):ia()})):ja(b.emptyDiagramXml,oa)},ja=function(oa,na){x||b.hideDialog(!0);f(oa,na,qa,ca)},ia=function(){A(mxResources.get(\"cannotLoad\"));ma()},ma=function(){I=qa;Ba.className=\"geTempDlgCreateBtn\";ca&&(Ka.className=\"geTempDlgOpenBtn\")},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\"#fc_showFooter_info\",function(){$(this).toggleClass(\"fc_active\").parent(\"#fc_footer_info\").children(\"ul\").slideToggle(300)});$('[title!=\"\"]').qtip({content:{attr:\"title\"},style:{classes:\"qtip-light qtip-shadow qtip-rounded\"}})});(function(a){a.fn.page_tree=function(b){b=a.extend({beforeSend:function(){},afterSend:function(){}},b);return this.each(function(){var b=a(this);1=2&&4>=b%10&&(10>b%100||b%100>=20)?c[1]:c[2]}function Jd(a,b,c) {var d={mm:b?\"\u043c\u0438\u043d\u0443\u0442\u0430_\u043c\u0438\u043d\u0443\u0442\u044b_\u043c\u0438\u043d\u0443\u0442\":\"\u043c\u0438\u043d\u0443\u0442\u0443_\u043c\u0438\u043d\u0443\u0442\u044b_\u043c\u0438\u043d\u0443\u0442\",hh:\"\u0447\u0430\u0441_\u0447\u0430\u0441\u0430_\u0447\u0430\u0441\u043e\u0432\",dd:\"\u0434\u0435\u043d\u044c_\u0434\u043d\u044f_\u0434\u043d\u0435\u0439\",MM:\"\u043c\u0435\u0441\u044f\u0446_\u043c\u0435\u0441\u044f\u0446\u0430_\u043c\u0435\u0441\u044f\u0446\u0435\u0432\",yy:\"\u0433\u043e\u0434_\u0433\u043e\u0434\u0430_\u043b\u0435\u0442\"};return\"m\"===c?b?\"\u043c\u0438\u043d\u0443\u0442\u0430\":\"\u043c\u0438\u043d\u0443\u0442\u0443\":a+\" \"+Id(d[c],+a)}function Kd(a) {return a>1&&5>a}function Ld(a,b,c,d) {var e=a+\" \";switch(c) {case\"s\":return b||d?\"p\u00e1r sek\u00fand\":\"p\u00e1r sekundami\";case\"m\":return b?\"min\u00fata\":d?\"min\u00fatu\":\"min\u00fatou\";case\"mm\":return b||d?e+(Kd(a)?\"min\u00faty\":\"min\u00fat\"):e+\"min\u00fatami\";break;case\"h\":return b?\"hodina\":d?\"hodinu\":\"hodinou\";case\"hh\":return b||d?e+(Kd(a)?\"hodiny\":\"hod\u00edn\"):e+\"hodinami\";break;case\"d\":return b||d?\"de\u0148\":\"d\u0148om\";case\"dd\":return b||d?e+(Kd(a)?\"dni\":\"dn\u00ed\"):e+\"d\u0148ami\";break;case\"M\":return b||d?\"mesiac\":\"mesiacom\";case\"MM\":return b||d?e+(Kd(a)?\"mesiace\":\"mesiacov\"):e+\"mesiacmi\";break;case\"y\":return b||d?\"rok\":\"rokom\";case\"yy\":return b||d?e+(Kd(a)?\"roky\":\"rokov\"):e+\"rokmi\"}}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "Runnable.prototype.run = function(fn) {\n var self = this\n , ms = this.timeout()\n , start = new Date\n , ctx = this.ctx\n , finished\n , emitted;\n\n if (ctx) ctx.runnable(this);\n\n // timeout\n if (this.async) {\n if (ms) {\n this.timer = setTimeout(function() {\n done(new Error('timeout of ' + ms + 'ms exceeded'));\n self.timedOut = true;\n }, ms);\n }\n }\n\n // called multiple times\n function multiple(err) {\n if (emitted) return;\n emitted = true;\n self.emit('error', err || new Error('done() called multiple times'));\n }\n\n // finished\n function done(err) {\n if (self.timedOut) return;\n if (finished) return multiple(err);\n self.clearTimeout();\n self.duration = new Date - start;\n finished = true;\n fn(err);\n }\n\n // for .resetTimeout()\n this.callback = done;\n\n // async\n if (this.async) {\n try {\n this.fn.call(ctx, function(err) {\n if (err instanceof Error || toString.call(err) === \"[object Error]\") return done(err);\n if (null != err) return done(new Error('done() invoked with non-Error: ' + err));\n done();\n });\n } catch (err) {\n done(err);\n }\n return;\n }\n\n if (this.asyncOnly) {\n return done(new Error('--async-only option in use without declaring `done()`'));\n }\n\n // sync\n try {\n if (!this.pending) this.fn.call(ctx);\n this.duration = new Date - start;\n fn();\n } catch (err) {\n fn(err);\n }\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " get: function(name, del){\r\n // #ifdef debug\r\n this._trace(\"retrieving function \" + name);\r\n // #endif\r\n if (!_map.hasOwnProperty(name)) {\r\n return;\r\n }\r\n var fn = _map[name];\r\n // #ifdef debug\r\n if (!fn) {\r\n this._trace(name + \" not found\");\r\n }\r\n // #endif\r\n \r\n if (del) {\r\n delete _map[name];\r\n }\r\n return fn;\r\n }\r", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "c.nodeName&&(v=c.hasAttribute(\"max-scale\")?parseFloat(c.getAttribute(\"max-scale\")):1);c=c.nextSibling}}finally{q.endUpdate()}null!=v&&this.chromelessResize&&this.chromelessResize(!0,v)}return g};EditorUi.prototype.getCopyFilename=function(c,e){var g=null!=c&&null!=c.getTitle()?c.getTitle():this.defaultFilename;c=\"\";var k=g.lastIndexOf(\".\");0<=k&&(c=g.substring(k),g=g.substring(0,k));if(e){e=g;var m=new Date;g=m.getFullYear();k=m.getMonth()+1;var q=m.getDate(),v=m.getHours(),x=m.getMinutes();m=m.getSeconds();", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "EditorUi.prototype.updateCssForMarker=function(a,b,f,d,g){a.style.verticalAlign=\"top\";a.style.height=\"21px\";a.style.width=\"21px\";a.innerHTML=\"\";\"flexArrow\"==f?a.className=null!=d&&d!=mxConstants.NONE?\"geSprite geSprite-\"+b+\"blocktrans\":\"geSprite geSprite-noarrow\":(f=this.getImageForMarker(d,g),null!=f?(d=document.createElement(\"img\"),d.style.position=\"absolute\",d.style.marginTop=\"0.5px\",d.setAttribute(\"src\",f),a.className=\"\",\"end\"==b&&mxUtils.setPrefixedStyle(d.style,\"transform\",\"scaleX(-1)\"),Editor.isDarkMode()&&\n(d.style.filter=\"invert(100%)\"),a.appendChild(d)):(a.className=\"geSprite geSprite-noarrow\",a.innerHTML=mxUtils.htmlEntities(mxResources.get(\"none\")),a.style.backgroundImage=\"none\",a.style.verticalAlign=\"top\",a.style.marginTop=\"4px\",a.style.fontSize=\"10px\",a.style.filter=\"none\",a.style.color=this.defaultStrokeColor,a.nextSibling.style.marginTop=\"0px\"))};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "\"80px\";mxUtils.setPrefixedStyle(m.style,\"transform\",\"translate(50%,-50%)\");n.appendChild(m);mxClient.IS_FF||null==navigator.clipboard||\"image/png\"!=x||(A=mxUtils.button(mxResources.get(\"copy\"),function(P){P=b.base64ToBlob(L,\"image/png\");P=new ClipboardItem({\"image/png\":P,\"text/html\":new Blob([''],{type:\"text/html\"})});navigator.clipboard.write([P]).then(mxUtils.bind(this,function(){b.alert(mxResources.get(\"copiedToClipboard\"))}))[\"catch\"](mxUtils.bind(this,function(K){b.handleError(K)}))}),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(e){var f=e.split(\"/\");return 1= _fields.length ? '__parsed_extra' : _fields[j];\n\n\t\t\t\t\tif (_config.transform)\n\t\t\t\t\t\tvalue = _config.transform(value,field);\n\n\t\t\t\t\tvalue = parseDynamic(field, value);\n\n\t\t\t\t\tif (field === '__parsed_extra')\n\t\t\t\t\t{\n\t\t\t\t\t\trow[field] = row[field] || [];\n\t\t\t\t\t\trow[field].push(value);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\trow[field] = value;\n\t\t\t\t}\n\n\n\t\t\t\tif (_config.header)\n\t\t\t\t{\n\t\t\t\t\tif (j > _fields.length)\n\t\t\t\t\t\taddError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);\n\t\t\t\t\telse if (j < _fields.length)\n\t\t\t\t\t\taddError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);\n\t\t\t\t}\n\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\tvar incrementBy = 1;\n\t\t\tif (!_results.data.length || Array.isArray(_results.data[0]))\n\t\t\t{\n\t\t\t\t_results.data = _results.data.map(processRow);\n\t\t\t\tincrementBy = _results.data.length;\n\t\t\t}\n\t\t\telse\n\t\t\t\t_results.data = processRow(_results.data, 0);\n\n\n\t\t\tif (_config.header && _results.meta)\n\t\t\t\t_results.meta.fields = _fields;\n\n\t\t\t_rowCounter += incrementBy;\n\t\t\treturn _results;\n\t\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": "TagSearch.prototype.getToolTip = function() {\n return this._toolTip;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function nodeQuery (context, version) {\n var nodeReleases = jsReleases.filter(function (i) {\n return i.name === 'nodejs'\n })\n var matched = nodeReleases.filter(function (i) {\n return isVersionsMatch(i.version, version)\n })\n if (matched.length === 0) {\n if (context.ignoreUnknownVersions) {\n return []\n } else {\n throw new BrowserslistError('Unknown version ' + version + ' of Node.js')\n }\n }\n return ['node ' + matched[matched.length - 1].version]\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " function removeListeners() {\n sftp.removeListener('ready', onReady);\n sftp.removeListener('error', onError);\n sftp.removeListener('exit', onExit);\n sftp.removeListener('close', onExit);\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "c){return d.addMinutes(a,60*c)};d.addMinutes=function(a,c){return d.addSeconds(a,60*c)};d.addSeconds=function(a,c){return d.addMilliseconds(a,1E3*c)};d.addMilliseconds=function(a,c){return new Date(a.getTime()+c)};d.subtract=function(a,c){var b=a.getTime()-c.getTime();return{toMilliseconds:function(){return b},toSeconds:function(){return b/1E3},toMinutes:function(){return b/6E4},toHours:function(){return b/36E5},toDays:function(){return b/864E5}}};d.isLeapYear=function(a){return!(a%4)&&!!(a%100)||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "function sanitizePath(id, name, callback) {\n if (name[0] === '/') name = name.substring(1);\n\n if (!id) {\n if (typeof callback === 'function') {\n callback('Empty ID');\n }\n return;\n }\n\n if (id) {\n id = id.replace(/\\.\\./g, ''); // do not allow to write in parent directories\n }\n\n if (name.indexOf('..') !== -1) {\n name = path.normalize(name);\n name = name.replace(/\\\\/g, '/');\n }\n if (name[0] === '/') name = name.substring(1); // do not allow absolute paths\n\n return {id: id, name: name};\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "minimumSearchLength:2});$(\".fc_input_fake label\").click(function(){var a=$(this).prop(\"for\");$(\"#\"+a).val(\"\");searchUsers(\"\")});$(\".ajaxForm\").each(function(){dialog_form($(this))});$(\"a.ajaxLink\").click(function(a){a.preventDefault();a=$(this).prop(\"href\");dialog_ajax(\"Saving\",a,getDatesFromQuerystring(document.URL.split(\"?\")[1]))});$(\"#fc_sidebar_footer, #fc_sidebar\").resizable({handles:\"e\",minWidth:100,start:function(b,e){a=parseInt($(window).width(),10)},resize:function(b,e){$(\"#fc_content_container, #fc_content_footer\").css({width:a-", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\tthis._addToParseQueue = function(chunk, callback)\n\t\t{\n\t\t\t// add to queue so that we can indicate\n\t\t\t// completion via callback\n\t\t\t// node will automatically pause the incoming stream\n\t\t\t// when too many items have been added without their\n\t\t\t// callback being invoked\n\t\t\tparseCallbackQueue.push(bindFunction(function() {\n\t\t\t\tthis.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));\n\t\t\t\tif (isFunction(callback)) {\n\t\t\t\t\treturn callback();\n\t\t\t\t}\n\t\t\t}, this));\n\t\t\tif (parseOnWrite) {\n\t\t\t\tparseOnWrite = false;\n\t\t\t\tthis._nextChunk();\n\t\t\t}\n\t\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "safe"} {"code": "mxUtils.bind(this,function(D,G){D=null!=g.backgroundImage?g.backgroundImage.originalSrc:null;if(null!=D){var P=D.indexOf(\",\");if(0 this.disconnect(), config.timeout);\n }\n\n const cookies = this._ws.upgradeReq.headers.cookie;\n if (!cookies) {\n return;\n }\n\n this._listener._connection.states.parse(cookies, (err, state, failed) => {\n\n if (err) {\n this.auth._error = Boom.unauthorized('Invalid nes authentication cookie');\n return;\n }\n\n const auth = state[config.cookie];\n if (auth) {\n this.auth._error = this._setCredentials(auth.credentials, auth.artifacts);\n }\n });\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": " 'sort': this.getSort(),\n 'page': '1'\n };\n var me = this;\n $.ajax({\n dataType: 'json',\n data: data,\n cache: false,\n url: askbot['urls']['tags'],\n success: function(data) {\n if (data['success']) {\n me.renderResult(data['html']);\n me.setIsRunning(false);\n }\n },\n error: function() { me.setIsRunning(false); }\n });\n me.setIsRunning(true);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function getter(obj, path, bindFnToScope) {\n\tif (!path) return obj;\n\tvar keys = path.split(\".\");\n\tvar key;\n\tvar lastInstance = obj;\n\tvar len = keys.length;\n\n\tfor (var i = 0; i < len; i++) {\n\t\tkey = keys[i];\n\t\tif (obj) {\n\t\t\tobj = (lastInstance = obj)[key];\n\t\t}\n\t}\n\tif (!bindFnToScope && isFunction(obj)) {\n\t\treturn bind(lastInstance, obj);\n\t}\n\treturn obj;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " const options = {...(settings || {})}\n /** @type {boolean|undefined} */\n let clean\n\n if (typeof options.sanitize === 'boolean') {\n clean = options.sanitize\n options.sanitize = undefined\n }\n\n if (typeof clean !== 'boolean') {\n clean = true\n }\n\n Object.assign(this, {Compiler: compiler})\n\n /**\n * @type {import('unified').CompilerFunction}\n */\n function compiler(node, file) {\n const hast = toHast(node, {\n allowDangerousHtml: !clean,\n handlers: options.handlers\n })\n // @ts-expect-error: assume root.\n const cleanHast = clean ? sanitize(hast, options.sanitize) : hast\n const result = toHtml(\n // @ts-expect-error: assume root.\n cleanHast,\n Object.assign({}, options, {allowDangerousHtml: !clean})\n )\n\n if (file.extname) {\n file.extname = '.html'\n }\n\n // Add an eof eol.\n return node &&\n node.type &&\n node.type === 'root' &&\n result &&\n /[^\\r\\n]/.test(result.charAt(result.length - 1))\n ? result + '\\n'\n : result\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "isHidden:function(){var a=this.getCommonAncestor();a&&a.type==CKEDITOR.NODE_TEXT&&(a=a.getParent());return!(!a||!a.data(\"cke-hidden-sel\"))},createBookmarks:function(a){a=this.getRanges().createBookmarks(a);this.isFake&&(a.isFake=1);return a},createBookmarks2:function(a){a=this.getRanges().createBookmarks2(a);this.isFake&&(a.isFake=1);return a},selectBookmarks:function(a){for(var b=[],c=0;c 0) {\n a += prefix_length;\n std::string switch_name =\n base::ToLowerASCII(base::StringPiece(a, strcspn(a, \"=\")));\n auto* iter = std::lower_bound(std::begin(kBlacklist), std::end(kBlacklist),\n switch_name);\n if (iter != std::end(kBlacklist) && switch_name == *iter) {\n return true;\n }\n }\n\n return false;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " function getVersionString(version, updatable, news, updatableError) {\n //var span = getVersionSpan(version);\n var color = getVersionClass(version);\n var title = color + '\\n\\r' + (news || '');\n //version = '' +\n version = //'
    ' +\n '
    ' +\n '' +\n '' +\n '
    ' + version + '';\n if (updatable) { //xxx\n version += '';\n }\n version += '
    ';\n return version;\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "d){c=c[d?\"getLast\":\"getFirst\"](function(b){return a.isRelevant(b)&&!b.is(ka)});if(!c)return!1;o(a,c);return d?c.size.top>a.mouse.y:c.size.bottom(a.inInlineMode?b.editable.top+b.editable.height/2:Math.min(b.editable.height,b.pane.height)/2),c=c[f?\"getLast\":\"getFirst\"](function(a){return!(z(a)||A(a))});if(!c)return null;v(a,c)&&(c=a.line.wrap[f?\"getPrevious\":\"getNext\"](function(a){return!(z(a)||A(a))}));if(!m(c)||\np(c)||!G(a,c))return null;o(a,c);return!f&&0<=c.size.top&&0c.size.bottom-e&&d.yb.pane.height-e&&c.size.bottome.size.top-1&&c.y=n.getStatus()?(this.updateDiagram(n.getText()),L()):this.handleError({message:mxResources.get(\"error\")+\" \"+n.getStatus()}))}),mxUtils.bind(this,function(n){this.handleError(n)}))}),L=mxUtils.bind(this,function(){window.clearTimeout(A);A=window.setTimeout(z,x)});this.editor.addListener(\"pageSelected\",mxUtils.bind(this,function(){L();z()}));L();z()}null!=e&&e()});null!=c.url&&0
    < '+mxResources.get(\"back\")+'
    '+", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " function uncaught(err){\n self.uncaught(err);\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "a.remove()},null,null,100);CKEDITOR.env.ie9Compat&&d.on(\"beforeDestroy\",c,null,null,9);CKEDITOR.env.webkit&&d.on(\"setData\",c);d.on(\"contentDomUnload\",function(){d.unlockSelection()});d.on(\"key\",function(a){if(d.mode==\"wysiwyg\"){var b=d.getSelection();if(b.isFake){var c=u[a.data.keyCode];if(c)return c({editor:d,selected:b.getSelectedElement(),selection:b,keyEvent:a})}}})});CKEDITOR.on(\"instanceReady\",function(a){var b=a.editor;if(CKEDITOR.env.webkit){b.on(\"selectionChange\",function(){var a=b.editable(),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "window.ocJSON=function(json){var jsonString=parse(json);return JSON.parse(jsonString);};}(window);+function($){\"use strict\";if($.oc===undefined)", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "a&&a.indent&&(this._.indentation=this._.indentation.substr(this.indentationChars.length));this._.indent?this.indentation():a&&a.breakBeforeClose&&(this.lineBreak(),this.indentation());this._.output.push(\"\");\"pre\"==b&&(this._.inPre=0);a&&a.breakAfterClose&&(this.lineBreak(),this._.needsSpace=a.needsSpace);this._.afterCloser=1},text:function(b){this._.indent&&(this.indentation(),!this._.inPre&&(b=CKEDITOR.tools.ltrim(b)));this._.output.push(b)},comment:function(b){this._.indent&&this.indentation();\nthis._.output.push(\"<\\!--\",b,\"--\\>\")},lineBreak:function(){!this._.inPre&&0CKEDITOR.env.version&&(c.innerHTML=c.innerHTML.replace(/^.*<\\!-- cke-content-start --\\>/,\"\"),setTimeout(function(){var a=new CKEDITOR.dom.range(new CKEDITOR.dom.document(b));a.setStart(new CKEDITOR.dom.node(c),0);d.getSelection().selectRanges([a])},0)));c.contentEditable=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "var jq = function() {\n if (isDefined(jq.name_)) return jq.name_;\n var el;\n var i, ii = ngAttrPrefixes.length, prefix, name;\n for (i = 0; i < ii; ++i) {\n prefix = ngAttrPrefixes[i];\n el = window.document.querySelector('[' + prefix.replace(':', '\\\\:') + 'jq]');\n if (el) {\n name = el.getAttribute(prefix + 'jq');\n break;\n }\n }\n\n return (jq.name_ = name);\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "function(){b.hideDialog(!0)});f.className=\"geBtn\";d=null!=d?mxUtils.button(mxResources.get(\"ignore\"),d):null;null!=d&&(d.className=\"geBtn\");b.editor.cancelFirst?(y.appendChild(f),null!=d&&y.appendChild(d),y.appendChild(v),y.appendChild(n)):(y.appendChild(n),y.appendChild(v),null!=d&&y.appendChild(d),y.appendChild(f));k.appendChild(y);k.appendChild(A);this.container=k},FindWindow=function(b,e,f,c,m,n){function v(U,X,u,E){if(\"object\"===typeof X.value&&null!=X.value.attributes){X=X.value.attributes;\nfor(var J=0;JW?K():U=setTimeout(K,W)}}(function(M,W){m(W)},200),mouseUp:function(M,W){m(W)}};l.addMouseListener(this.mouseListeners);this.shareCursorPositionListener=function(){b.isShareCursorPosition()||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " var normalizeRequestType = function(details) {\n // normalize type, because of issue with Chrome 38+\n var type = details.type;\n if (type !== 'other') {\n return type;\n }\n var url = parseUri(details.url);\n if (url && url.pathname) {\n var pos = url.pathname.lastIndexOf('.');\n if (pos === -1) {\n return type;\n }\n }\n var ext = url.pathname.slice(pos) + '.';\n if ('.eot.ttf.otf.svg.woff.woff2.'.indexOf(ext) !== -1) {\n return 'font';\n }\n // Still need this because often behind-the-scene requests are wrongly\n // categorized as 'other'\n if ('.ico.png.gif.jpg.jpeg.webp.'.indexOf(ext) !== -1) {\n return 'image';\n }\n // https://code.google.com/p/chromium/issues/detail?id=410382\n if (type === 'other') {\n return 'object';\n }\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "vulnerable"} {"code": " exitStatus(chan, status) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 11 + 1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-status', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, status, ++p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-status: ${status})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\t\t\t\t\t\t\tdata : {cmd : 'parents', target : fm.cwd().hash},\n\t\t\t\t\t\t\tpreventFail : true\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.done(function(data) {\n\t\t\t\t\t\t\tset(fm.file(phash) || null);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "b.$.sheet},createElement:function(a,e){var b=new CKEDITOR.dom.element(a,this);if(e){e.attributes&&b.setAttributes(e.attributes);e.styles&&b.setStyles(e.styles)}return b},createText:function(a){return new CKEDITOR.dom.text(a,this)},focus:function(){this.getWindow().focus()},getActive:function(){return new CKEDITOR.dom.element(this.$.activeElement)},getById:function(a){return(a=this.$.getElementById(a))?new CKEDITOR.dom.element(a):null},getByAddress:function(a,e){for(var b=this.$.documentElement,c=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "ma()},ma=function(){K=ra;Aa.className=\"geTempDlgCreateBtn\";da&&(Ha.className=\"geTempDlgOpenBtn\")},ra=K;K=null;\"boolean\"!==typeof da&&(da=ra.isExternal&&p);1==ha?k(ra.url,ra):da?(Ha.className=\"geTempDlgOpenBtn geTempDlgBtnDisabled geTempDlgBtnBusy\",ca()):(Aa.className=\"geTempDlgCreateBtn geTempDlgBtnDisabled geTempDlgBtnBusy\",ha=null==b.mode||b.mode==App.MODE_GOOGLE||b.mode==App.MODE_BROWSER?mxResources.get(\"diagramName\"):mxResources.get(\"filename\"),ha=new FilenameDialog(b,b.defaultFilename+\".drawio\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "ia){ja=fa.getAttribute(\"section\");ba=fa.getAttribute(\"subsection\");if(null==ja&&(ma=ia.indexOf(\"/\"),ja=ia.substring(0,ma),null==ba)){var qa=ia.indexOf(\"/\",ma+1);-1=0;t--){if(i[t]==this){i.splice(t,1);break}}e.removeData(m);if(!i.length){if(r){cancelAnimationFrame(a)}else{clearTimeout(a)}a=null}},add:function(e){if(!n[f]&&this[s]){return false}var i;function a(e,n,a){var r=$(this),s=r.data(m)||{};s.w=n!==t?n:r.width();s.h=a!==t?a:r.height();i.apply(this,arguments)}if($.isFunction(e)){i=e;return a}else{i=e.handler;e.handler=a}}};function h(t){if(r===true){r=t||1}for(var s=i.length-1;s>=0;s--){var l=$(i[s]);if(l[0]==e||l.is(\":visible\")){var f=l.width(),c=l.height(),d=l.data(m);if(d&&(f!==d.w||c!==d.h)){l.trigger(u,[d.w=f,d.h=c]);r=t||true}}else{d=l.data(m);d.w=0;d.h=0}}if(a!==null){if(r&&(t==null||t-r<1e3)){a=e.requestAnimationFrame(h)}else{a=setTimeout(h,n[o]);r=false}}}if(!e.requestAnimationFrame){e.requestAnimationFrame=function(){return e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(t,i){return e.setTimeout(function(){t((new Date).getTime())},n[l])}}()}if(!e.cancelAnimationFrame){e.cancelAnimationFrame=function(){return e.webkitCancelRequestAnimationFrame||e.mozCancelRequestAnimationFrame||e.oCancelRequestAnimationFrame||e.msCancelRequestAnimationFrame||clearTimeout}()}})(jQuery,this);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "return P.apply(this,arguments)};mxGraphView.prototype.createEnumerationValue=function(u){u=decodeURIComponent(mxUtils.getValue(u.style,\"enumerateValue\",\"\"));\"\"==u&&(u=++this.enumerationState);return'
    '+mxUtils.htmlEntities(u)+\"
    \"};mxGraphView.prototype.redrawEnumerationState=function(u){var D=\"1\"==mxUtils.getValue(u.style,\"enumerate\",0);D&&null==u.secondLabel?(u.secondLabel=new mxText(\"\",new mxRectangle,mxConstants.ALIGN_LEFT,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function getObjects(callback) {\n main.socket.emit('getAllObjects', function (err, res) {\n if (err) {\n // following errors are possible\n // permissionError\n // Admin is not enabled in cloud settings!\n window.alert(_(err));\n return;\n }\n\n setTimeout(function () {\n var obj;\n main.objects = res;\n for (var id in main.objects) {\n if (!main.objects.hasOwnProperty(id) || id.slice(0, 7) === '_design') continue;\n\n obj = main.objects[id];\n\n if (obj.type === 'instance') main.instances.push(id);\n if (obj.type === 'enum') tabs.enums.list.push(id);\n if (obj.type === 'user') tabs.users.list.push(id);\n if (obj.type === 'group') tabs.users.groups.push(id);\n if (obj.type === 'adapter') tabs.adapters.list.push(id);\n if (obj.type === 'host') tabs.hosts.addHost(obj);\n\n // convert obj.history into obj.custom\n if (obj.common && obj.common.history) {\n obj.common.custom = JSON.parse(JSON.stringify(obj.common.history));\n delete obj.common.history;\n }\n }\n main.objectsLoaded = true;\n main.initHostsList(true);\n\n initTabs();\n // init dialogs\n for (var dialog in main.dialogs) {\n if (main.dialogs.hasOwnProperty(dialog) && typeof main.dialogs[dialog].prepare === 'function') {\n main.dialogs[dialog].prepare();\n }\n }\n\n // Detect node.js version\n checkNodeJsVersions(tabs.hosts.list);\n\n main.getUser();\n\n if (typeof callback === 'function') callback();\n }, 0);\n });\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " function onSearchKeyUp () {\n var searchTerm = $searchBox.val().toLowerCase()\n $('.all-user-list li').each(function () {\n if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {\n $(this).show()\n } else {\n $(this).hide()\n }\n })\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-662", "cwe_name": "Improper Synchronization", "description": "The software utilizes multiple threads or processes to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.", "url": "https://cwe.mitre.org/data/definitions/662.html", "label_name": "vulnerable"} {"code": "\t\t\tcreateFromRaw = function(raw) {\n\t\t\t\t$.each(raw, function(i, data) {\n\t\t\t\t\tvar node;\n\t\t\t\t\t\n\t\t\t\t\tif (data === '|') {\n\t\t\t\t\t\tmenu.append('
    ');\n\t\t\t\t\t} else if (data.label && typeof data.callback == 'function') {\n\t\t\t\t\t\tnode = item(data.label, data.icon, function() {\n\t\t\t\t\t\t\t!data.remain && close();\n\t\t\t\t\t\t\tdata.callback();\n\t\t\t\t\t\t}, data.options || null);\n\t\t\t\t\t\tmenu.append(node);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function getMethods(a){var b=[],c;for(c in a)try{\"function\"==typeof a[c]&&b.push(c+\": \"+a[c].toString())}catch(e){b.push(c+\": inaccessible\")}return b}function dump(a,b){var c=\"\";b||(b=0);for(var e=\"\",d=0;d \\\"\"+d+'\"\\n';else c=\"===>\"+a+\"<===(\"+typeof a+\")\";return c};(function(a){a.fn.fc_set_tab_list=function(b){var c={toggle_speed:300,fc_list_forms:a(\".fc_list_forms\"),fc_list_add:a(\"#fc_list_add\")};b=a.extend(c,b);return this.each(function(){var c=a(this),d=c.closest(\"ul\").children(\"li\"),f=\"fc_list_\"+c.children(\"input\").val(),g=a(\"#\"+f),h=a(\"#fc_install_new\");b.fc_list_forms.not(\":first\").slideUp(0);0===b.fc_list_add.size()?d.filter(\":first\").addClass(\"fc_active\"):b.fc_list_add.unbind().click(function(){d.removeClass(\"fc_active\");b.fc_list_forms.not(h).slideUp(0);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function toInt(str) {\n\treturn parseInt(str, 10);\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "Runnable.prototype.clearTimeout = function() {\n clearTimeout(this.timer);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "mxCodecRegistry.register(function(){var a=new mxObjectCodec(new mxCell,[\"children\",\"edges\",\"overlays\",\"mxTransient\"],[\"parent\",\"source\",\"target\"]);a.isCellCodec=function(){return!0};a.isNumericAttribute=function(b,c,d){return\"value\"!==c.nodeName&&mxObjectCodec.prototype.isNumericAttribute.apply(this,arguments)};a.isExcluded=function(b,c,d,e){return mxObjectCodec.prototype.isExcluded.apply(this,arguments)||e&&\"value\"==c&&d.nodeType==mxConstants.NODETYPE_ELEMENT};a.afterEncode=function(b,c,d){if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "(i=a.aanFeatures,i[j]||(i[j]=[]),i[j].push(g),e.append(g))}c.replaceWith(e);a.nHolding=null}function fa(a,b) {var c=h(b).children(\"tr\"),d,e,f,g,j,i,o,l,q,u;a.splice(0,a.length);f=0;for(i=c.length;f= 0 && BAD_PROTOCOLS.indexOf(protocol) >= 0) {\n if (protocol === 'data' && ALLOWED_DATA_MIMES.indexOf(str.split(';')[0]) >= 0) {\n return true;\n }\n return false;\n }\n\n return true;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "function next() {\n if (Array.isArray(process._events.exit))\n process._events.exit = process._events.exit[1];\n if (++t === tests.length)\n return;\n\n const v = tests[t];\n v.next = once(next);\n v.msg = msg.bind(null, v.what);\n v.run(v.msg, v.next);\n setup(\n v,\n { username: USER, password: PASSWORD },\n { hostKeys: [HOST_KEY_RSA] }\n );\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " function validateEmail (email) {\n return String(email)\n .toLowerCase()\n .match(\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/\n )\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "Wa,Xa,K,Ga,Ja,Ia,Ha);c.stroke()};Ea.prototype.moveNW=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(0,0):c.moveTo(0,ha)};Ea.prototype.moveNE=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(p,0):c.moveTo(p-ha,0)};Ea.prototype.moveSE=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(p,v):c.moveTo(p,v-ha)};Ea.prototype.moveSW=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(0,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "Graph.sanitizeHtml=function(a,c){return DOMPurify.sanitize(a,{ADD_ATTR:[\"target\"],FORBID_TAGS:[\"form\"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|data):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i})};Graph.sanitizeSvg=function(a){return DOMPurify.sanitize(a,{IN_PLACE:!0})};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "u.appendChild(D));return u}}Graph.fontMapping={\"https://fonts.googleapis.com/css?family=Architects+Daughter\":'@font-face { font-family: \"Architects Daughter\"; src: url('+STYLE_PATH+'/fonts/ArchitectsDaughter-Regular.ttf) format(\"truetype\"); }'};Graph.customFontElements={};Graph.recentCustomFonts={};Graph.isGoogleFontUrl=function(u){return u.substring(0,Editor.GOOGLE_FONTS.length)==Editor.GOOGLE_FONTS};Graph.isCssFontUrl=function(u){return Graph.isGoogleFontUrl(u)};Graph.createFontElement=function(u,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " labels: templateInstance.topTasks.get().map((task) => task._id),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "(function(){function a(){this.rules=[]}function e(b,c,d,e){var h,m;for(h in c){(m=b[h])||(m=b[h]=new a);m.add(c[h],d,e)}}CKEDITOR.htmlParser.filter=CKEDITOR.tools.createClass({$:function(b){this.id=CKEDITOR.tools.getNextNumber();this.elementNameRules=new a;this.attributeNameRules=new a;this.elementsRules={};this.attributesRules={};this.textRules=new a;this.commentRules=new a;this.rootRules=new a;b&&this.addRules(b,10)},proto:{addRules:function(a,c){var d;if(typeof c==\"number\")d=c;else if(c&&\"priority\"in", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "CKEDITOR.removeAnchorCommand=function(){};CKEDITOR.removeAnchorCommand.prototype={exec:function(b){var a=b.getSelection(),d=a.createBookmarks(),c;if(a&&(c=a.getSelectedElement())&&(CKEDITOR.plugins.link.fakeAnchor&&!c.getChildCount()?CKEDITOR.plugins.link.tryRestoreFakeAnchor(b,c):c.is(\"a\")))c.remove(1);else if(c=CKEDITOR.plugins.link.getSelectedLink(b))c.hasAttribute(\"href\")?(c.removeAttributes({name:1,\"data-cke-saved-name\":1}),c.removeClass(\"cke_anchor\")):c.remove(1);a.selectBookmarks(d)},requiredContent:\"a[name]\"};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "NyanCat.prototype.appendRainbow = function(){\n var segment = this.tick ? '_' : '-';\n var rainbowified = this.rainbowify(segment);\n\n for (var index = 0; index < this.numberOfLines; index++) {\n var trajectory = this.trajectories[index];\n if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();\n trajectory.push(rainbowified);\n }\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " escape: function(value) {\n if (isString(value)) return '\\'' + value.replace(this.stringEscapeRegex, this.stringEscapeFn) + '\\'';\n if (isNumber(value)) return value.toString();\n if (value === true) return 'true';\n if (value === false) return 'false';\n if (value === null) return 'null';\n if (typeof value === 'undefined') return 'undefined';\n\n throw $parseMinErr('esc', 'IMPOSSIBLE');\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\t\t\t\trest = function(){\n\t\t\t\t\tif (!overlay.is(':hidden')) {\n\t\t\t\t\t\toverlay.addClass('ui-front')\n\t\t\t\t\t\t\t.elfinderoverlay('hide')\n\t\t\t\t\t\t\t.off('click', cancel);\n\t\t\t\t\t}\n\t\t\t\t\tnode.removeClass('ui-front').css('position', '');\n\t\t\t\t\tif (tarea) {\n\t\t\t\t\t\tnnode.css('max-height', '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpnode.css('width', '')\n\t\t\t\t\t\t\t.parent('td').css('overflow', '');\n\t\t\t\t\t}\n\t\t\t\t}, colwidth,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function fileCompletion (root, req, depth, cb) {\n if (typeof cb !== 'function') {\n cb = depth\n depth = Infinity\n }\n correctMkdir(root, function (er) {\n if (er) return cb(er)\n\n // can be either exactly the req, or a descendent\n var pattern = root + '/{' + req + ',' + req + '/**/*}'\n var opts = { mark: true, dot: true, maxDepth: depth }\n glob(pattern, opts, function (er, files) {\n if (er) return cb(er)\n return cb(null, (files || []).map(function (f) {\n return f.substr(root.length + 1).replace(/^\\/|\\/$/g, '')\n }))\n })\n })\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "vulnerable"} {"code": "insertText:function(a){this.fire(\"insertText\",a)},insertElement:function(a){this.fire(\"insertElement\",a)},focus:function(){this.fire(\"beforeFocus\")},checkDirty:function(){return this.status==\"ready\"&&this._.previousValue!==this.getSnapshot()},resetDirty:function(){this._.previousValue=this.getSnapshot()},updateElement:function(){return r.call(this)},setKeystroke:function(){for(var a=this.keystrokeHandler.keystrokes,b=CKEDITOR.tools.isArray(arguments[0])?arguments[0]:[[].slice.call(arguments,0)],c,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.getTagsForCell(D[Y]),ea=!1;if(0=u.length)){for(var Z=ea=0;Z');\n\n info.message.on('data', function(chunk) {\n chunks.push(chunk);\n });\n\n info.message.on('end', function() {\n let body = Buffer.concat(chunks);\n expect(body.toString()).to.equal(message.replace(/\\r\\n/g, '\\n'));\n done();\n });\n }\n );\n });", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": " setup: function () {\n var data = this.model.get('data');\n\n var field = data.field;\n var value = data.value;\n\n this.style = data.style || 'default';\n\n this.statusText = this.getLanguage().translateOption(value, field, this.model.get('parentType'));\n\n this.messageData['field'] = this.translate(field, 'fields', this.model.get('parentType')).toLowerCase();\n\n this.createMessage();\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tfunction refresh()\n\t{\n\t\tchanged = true;\n\n\t\tif (plugins.length == 0)\n\t\t{\n\t\t\tinner.innerHTML = mxUtils.htmlEntities(mxResources.get('noPlugins'));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tinner.innerHTML = '';\n\t\t\t\n\t\t\tfor (var i = 0; i < plugins.length; i++)\n\t\t\t{\n\t\t\t\tvar span = document.createElement('span');\n\t\t\t\tspan.style.whiteSpace = 'nowrap';\n\n\t\t\t\tvar img = document.createElement('span');\n\t\t\t\timg.className = 'geSprite geSprite-delete';\n\t\t\t\timg.style.position = 'relative';\n\t\t\t\timg.style.cursor = 'pointer';\n\t\t\t\timg.style.top = '5px';\n\t\t\t\timg.style.marginRight = '4px';\n\t\t\t\timg.style.display = 'inline-block';\n\t\t\t\tspan.appendChild(img);\n\t\t\t\t\n\t\t\t\tmxUtils.write(span, plugins[i]);\n\t\t\t\tinner.appendChild(span);\n\t\t\t\t\n\t\t\t\tmxUtils.br(inner);\n\t\t\t\t\n\t\t\t\tmxEvent.addListener(img, 'click', (function(index)\n\t\t\t\t{\n\t\t\t\t\treturn function()\n\t\t\t\t\t{\n\t\t\t\t\t\teditorUi.confirm(mxResources.get('delete') + ' \"' + plugins[index] + '\"?', function()\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (delFn != null) \n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdelFn(plugins[index]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tplugins.splice(index, 1);\n\t\t\t\t\t\t\trefresh();\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t})(i));\n\t\t\t}\n\t\t}\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " onData(stream, session, callback) {\n stream.on('data', function() {});\n stream.on('end', callback);\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "export function writeConfig(output, key, value, recurse) {\n if (!isLegalKey(key)) return;\n\n var k, o;\n if (isObject(value) && !isArray(value)) {\n o = isObject(output[key]) ? output[key] : (output[key] = {});\n for (k in value) {\n if (recurse && (recurse === true || recurse[k])) {\n writeConfig(o, k, value[k]);\n } else if (isLegalKey(k)) {\n o[k] = value[k];\n }\n }\n } else {\n output[key] = value;\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "!0),null!=this.sidebar&&null!=urlParams[\"search-shapes\"]&&null!=this.sidebar.searchShapes&&(this.sidebar.searchShapes(urlParams[\"search-shapes\"]),this.sidebar.showEntries(\"search\"));var F=this;mxWindow.prototype.fit=function(){if(Editor.inlineFullscreen||null==F.embedViewport)mxUtils.fit(this.div);else{var da=parseInt(this.div.offsetLeft),ca=parseInt(this.div.offsetWidth),la=F.embedViewport.x+F.embedViewport.width,ia=parseInt(this.div.offsetTop),ma=parseInt(this.div.offsetHeight),ra=F.embedViewport.y+\nF.embedViewport.height;this.div.style.left=Math.max(F.embedViewport.x,Math.min(da,la-ca))+\"px\";this.div.style.top=Math.max(F.embedViewport.y,Math.min(ia,ra-ma))+\"px\";this.div.style.height=Math.min(F.embedViewport.height,parseInt(this.div.style.height))+\"px\";this.div.style.width=Math.min(F.embedViewport.width,parseInt(this.div.style.width))+\"px\"}};this.keyHandler.bindAction(75,!0,\"toggleShapes\",!0);EditorUi.windowed&&(\"1\"==urlParams.sketch||1E3<=c)&&\"1\"!=urlParams.embedInline&&(b(this,!0),\"1\"==urlParams.sketch?", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "App.Actions.MAIL_ACC.toggle_unlimited_feature = function(evt) {\n var elm = $(evt.target);\n var ref = elm.prev('.vst-input');\n if (!$(ref).data('checked')) {\n App.Actions.MAIL_ACC.enable_unlimited(ref, elm);\n }\n else {\n App.Actions.MAIL_ACC.disable_unlimited(ref, elm);\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "WriteStream.prototype._final = function(cb) {\n if (this.autoClose)\n this.destroy();\n cb();\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "this.ui.handleError({message:mxResources.get(\"fileNotFound\")})})))}else this.ui.spinner.stop(),this.ui.handleError({message:mxResources.get(\"invalidName\")})}}),mxResources.get(\"enterValue\"));this.ui.showDialog(P.container,300,80,!0,!1);P.init()}))),mxUtils.br(k),mxUtils.br(k));for(var G=0;G>>0;this.filename=String.fromCharCode.apply(null,w?a.subarray(b,b+=this.h):a.slice(b,b+=this.h));this.Y=w?a.subarray(b,b+=this.g):a.slice(b,b+=this.g);this.v=w?a.subarray(b,b+this.F):a.slice(b,b+this.F);this.length=b-this.offset};function pa(a,b) {this.input=a;this.offset=b}var qa={O:1,da:8,ea:2048};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " var newFn = function () {\n var self = this\n var len = arguments.length\n if (options.withCallback) {\n var lastType = typeof arguments[len - 1]\n if (lastType === 'function') return fn.apply(self, arguments)\n }\n var args = new Array(len + 1)\n for (var i = 0; i < len; ++i) args[i] = arguments[i]\n var lastIndex = i\n return new Promise(function (resolve, reject) {\n args[lastIndex] = createCallback(resolve, reject, options.multiArgs)\n fn.apply(self, args)\n })\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "inflect.classify = function (table_name) {\n return inflect.camelize(inflect.singularize(util.string.gsub(table_name, /^.*\\./, '')));\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "mxResources.get(\"ok\"),ca,ha,function(pa){var na=null!=pa&&0=na.getStatus()?ja(na.getText(),oa):ia()})):ja(b.emptyDiagramXml,oa)},ja=function(oa,na){x||b.hideDialog(!0);f(oa,na,qa,ca)},ia=function(){A(mxResources.get(\"cannotLoad\"));ma()},ma=function(){I=qa;Ba.className=\"geTempDlgCreateBtn\";ca&&(Ka.className=\"geTempDlgOpenBtn\")},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxDualRuler.prototype.setUnit=function(b){this.vRuler.setUnit(b);this.hRuler.setUnit(b)};mxDualRuler.prototype.setStyle=function(b){this.vRuler.setStyle(b);this.hRuler.setStyle(b)};mxDualRuler.prototype.destroy=function(){this.vRuler.destroy();this.hRuler.destroy();this.ui.refresh=this.editorUiRefresh;mxGuide.prototype.move=this.origGuideMove;mxGuide.prototype.destroy=this.origGuideDestroy;this.ui.getDiagramContainerOffset=this.editorUiGetDiagContOffset};function mxFreehand(b){var e=null!=b.view&&null!=b.view.canvas?b.view.canvas.ownerSVGElement:null;if(null!=b.container&&null!=e){b.addListener(mxEvent.ESCAPE,mxUtils.bind(this,function(){this.stopDrawing()}));var f=mxFreehand.prototype.NORMAL_SMOOTHING,c=null,m=[],n,v=[],d,g=!1,k=!0,l=!0,p=!0,q=!0,x=[],y=!1,A=!0,B=!1,I={size:12,thinning:.5,smoothing:.5,streamline:.5,start:{taper:0,cap:!0},end:{taper:0,cap:!0}},O=!1;this.setClosedPath=function(J){g=J};this.setAutoClose=function(J){k=J};this.setAutoInsert=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "(new mxCodec(u.ownerDocument)).decode(u)}return this.defaultStylesheet};Graph.prototype.isViewer=function(){return urlParams.viewer};var L=Graph.prototype.getSvg;Graph.prototype.getSvg=function(u,E,J,T,N,Q,R,Y,ba,ea,Z,fa,aa,va){var ja=null,Ba=null,Ha=null;fa||null==this.themes||\"darkTheme\"!=this.defaultThemeName||(ja=this.stylesheet,Ba=this.shapeForegroundColor,Ha=this.shapeBackgroundColor,this.shapeForegroundColor=\"darkTheme\"==this.defaultThemeName?\"#000000\":Editor.lightColor,this.shapeBackgroundColor=\n\"darkTheme\"==this.defaultThemeName?\"#ffffff\":Editor.darkColor,this.stylesheet=this.getDefaultStylesheet(),this.refresh());var ra=L.apply(this,arguments),Ca=this.getCustomFonts();if(Z&&0 readFileSync(join(fixturesDir, file));", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function(J){l=J};this.setAutoScroll=function(J){p=J};this.setOpenFill=function(J){q=J};this.setStopClickEnabled=function(J){A=J};this.setSelectInserted=function(J){B=J};this.setSmoothing=function(J){f=J};this.setPerfectFreehandMode=function(J){O=J};this.setBrushSize=function(J){I.size=J};this.getBrushSize=function(){return I.size};var t=function(J){y=J;b.getRubberband().setEnabled(!J);b.graphHandler.setSelectEnabled(!J);b.graphHandler.setMoveEnabled(!J);b.container.style.cursor=J?\"crosshair\":\"\";b.fireEvent(new mxEventObject(\"freehandStateChanged\"))};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "(function(){var a={};CKEDITOR.addTemplate=function(e,b){var c=a[e];if(c)return c;c={name:e,source:b};CKEDITOR.fire(\"template\",c);return a[e]=new CKEDITOR.template(c.source)};CKEDITOR.getTemplate=function(e){return a[e]}})();(function(){var a=[];CKEDITOR.addCss=function(e){a.push(e)};CKEDITOR.getCss=function(){return a.join(\"\\n\")}})();CKEDITOR.on(\"instanceDestroyed\",function(){CKEDITOR.tools.isEmpty(this.instances)&&CKEDITOR.fire(\"reset\")});CKEDITOR.TRISTATE_ON=1;CKEDITOR.TRISTATE_OFF=2;", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function(a,c,b){a=d.preparse(a,c);return d.isValid(a)?(a.M-=100>a.Y?22801:1,b||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};d.transform=function(a,c,b,e){return d.format(d.parse(a,c),b,e)};d.addYears=function(a,c){return d.addMonths(a,12*c)};d.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};d.addDays=function(a,c){var b=new Date(a.getTime());b.setDate(b.getDate()+c);return b};d.addHours=function(a,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "!function(){\"use strict\";var e,n={},r={};function t(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={id:e,loaded:!1,exports:{}};return n[e].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}t.m=n,t.amdO={},e=[],t.O=function(n,r,o,i){if(!r){var u=1/0;for(f=0;f=i)&&Object.keys(t.O).every((function(e){return t.O[e](r[a])}))?r.splice(a--,1):(c=!1,i0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[r,o,i]},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(e){if(\"object\"==typeof window)return window}}(),t.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,\"exports\",{enumerable:!0,set:function(){throw new Error(\"ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: \"+e.id)}}),e},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},t.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},t.p=\"build/\",function(){var e={666:0};t.O.j=function(n){return 0===e[n]};var n=function(n,r){var o,i,u=r[0],c=r[1],a=r[2],f=0;for(o in c)t.o(c,o)&&(t.m[o]=c[o]);if(a)var l=a(t);for(n&&n(r);f0&&h.which!=l.which||a(h.target).is(l.not))return;switch(h.type){case\"mousedown\":return a.extend(l,a(j).offset(),{elem:j,target:h.target,pageX:h.pageX,pageY:h.pageY}),b.add(document,\"mousemove mouseup\",e,l),i(j,!1),d.dragging=null,!1;case!d.dragging&&\"mousemove\":if(g(h.pageX-l.pageX)+g(h.pageY-l.pageY) 1 && typeof color === 'string')\n\t\t\t{\n\t\t\t\tvar clr = (color.charAt(0) == '#') ? color.substring(1).toUpperCase() : color;\n\t\t\t\tvar name = ColorDialog.prototype.colorNames[clr];\n\t\t\t\tbtn.setAttribute('title', (name != null) ? name + ' (' + title + ')' : title);\n\t\t\t}\n\t\t\t\n\t\t\tif (color != null && color != mxConstants.NONE)\n\t\t\t{\n\t\t\t\tcb.setAttribute('checked', 'checked');\n\t\t\t\tcb.defaultChecked = true;\n\t\t\t\tcb.checked = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcb.removeAttribute('checked');\n\t\t\t\tcb.defaultChecked = false;\n\t\t\t\tcb.checked = false;\n\t\t\t}\n\t\n\t\t\tbtn.style.display = (cb.checked || hideCheckbox) ? '' : 'none';\n\n\t\t\tif (callbackFn != null)\n\t\t\t{\n\t\t\t\tcallbackFn(color == 'null' ? null : color);\n\t\t\t}\n\n\t\t\tvalue = color;\n\n\t\t\tif (!disableUpdate)\n\t\t\t{\n\t\t\t\t// Checks if the color value needs to be updated in the model\n\t\t\t\tif (forceUpdate || hideCheckbox || getColorFn() != value)\n\t\t\t\t{\n\t\t\t\t\tsetColorFn(value == 'null' ? null : value, value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tapplying = false;\n\t\t}\n\t};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\tfunction uploadFile(file) {\n\t\t\t\tif (file.size> attachmentMaxSize) {\n\t\t\t\t\tvar message = \"!!Upload should be less than \" + Math.round(attachmentMaxSize/1024/1024) + \" Mb!!\";\n\t\t\t\t\tonedev.server.markdown.updateUploadMessage($input, message);\n\t\t\t\t} else {\n\t\t\t\t\tvar xhr = new XMLHttpRequest();\n\t\t\t\t\tvar val = $input.val();\n\t\t\t\t\tvar i=1;\n\t\t\t\t\tvar message = \"[Uploading file...]\";\n\t\t\t\t\twhile (val.indexOf(message) != -1) {\n\t\t\t\t\t\tmessage = \"[Uploading file\" + (++i) + \"...]\";\n\t\t\t\t\t}\n\n\t\t\t\t\txhr.replaceMessage = message;\n\t\t\t\t\tif ($input.range().length == 0) {\n\t\t\t\t\t\t$input.caret(message);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$input.range(message);\n\t\t\t\t\t\t$input.caret($input.caret()+message.length);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\txhr.onload = function() {\n\t\t\t\t\t\tvar response = xhr.responseText;\n\t\t\t\t\t\tvar index = response.indexOf(\"=M.getStatus())try{this.exportFile(M.getText(),z,q,!0,L,n)}catch(y){this.handleError(y)}else this.handleError({message:mxResources.get(\"errorSavingFile\")})}),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "this.getTagsForCell(D[Y]),ea=!1;if(0=u.length)){for(var Z=ea=0;Za?b||d?\"minute\":\"minutami\":b||d?\"minut\":\"minutami\";case\"h\":return b?\"ena ura\":\"eno uro\";case\"hh\":return e+=1===a?b?\"ura\":\"uro\":2===a?b||d?\"uri\":\"urama\":5>a?b||d?\"ure\":\"urami\":b||d?\"ur\":\"urami\";case\"d\":return b||d?\"en dan\":\"enim dnem\";case\"dd\":return e+=1===a?b||d?\"dan\":\"dnem\":2===a?b||d?\"dni\":\"dnevoma\":b||d?\"dni\":\"dnevi\";case\"M\":return b||d?\"en mesec\":\"enim mesecem\";case\"MM\":return e+=1===a?b||d?\"mesec\":\"mesecem\":2===a?b||d?\"meseca\":\"mesecema\":5>a?b||d?\"mesece\":\"meseci\":b||d?\"mesecev\":\"meseci\";case\"y\":return b||d?\"eno leto\":\"enim letom\";case\"yy\":return e+=1===a?b||d?\"leto\":\"letom\":2===a?b||d?\"leti\":\"letoma\":5>a?b||d?\"leta\":\"leti\":b||d?\"let\":\"leti\"}}function Nd(a) {var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"leS\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"waQ\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"nem\":b+\" pIq\"}function Od(a) {var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"Hu\u2019\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"wen\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"ben\":b+\" ret\"}function Pd(a,b,c,d) {var e=Qd(a);switch(c) {case\"mm\":return e+\" tup\";case\"hh\":return e+\" rep\";case\"dd\":return e+\" jaj\";case\"MM\":return e+\" jar\";case\"yy\":return e+\" DIS\"}}function Qd(a) {var b=Math.floor(a%1e3/100),c=Math.floor(a%100/10),d=a%10,e=\"\";return b>0&&(e+=Sg[b]+\"vatlh\"),c>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[c]+\"maH\"),d>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[d]),\"\"===e?\"pagh\":e}function Rd(a,b,c,d) {var e={s:[\"viensas secunds\",\"'iensas secunds\"],m:[\"'n m\u00edut\",\"'iens m\u00edut\"],mm:[a+\" m\u00eduts\",\"\"+a+\" m\u00eduts\"],h:[\"'n \u00feora\",\"'iensa \u00feora\"],hh:[a+\" \u00feoras\",\"\"+a+\" \u00feoras\"],d:[\"'n ziua\",\"'iensa ziua\"],dd:[a+\" ziuas\",\"\"+a+\" ziuas\"],M:[\"'n mes\",\"'iens mes\"],MM:[a+\" mesen\",\"\"+a+\" mesen\"],y:[\"'n ar\",\"'iens ar\"],yy:[a+\" ars\",\"\"+a+\" ars\"]};return d?e[c][0]:b?e[c][0]:e[c][1]}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "Wa,Xa,K,Ga,Ja,Ia,Ha);c.stroke()};Ea.prototype.moveNW=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(0,0):c.moveTo(0,ha)};Ea.prototype.moveNE=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(p,0):c.moveTo(p-ha,0)};Ea.prototype.moveSE=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(p,v):c.moveTo(p,v-ha)};Ea.prototype.moveSW=function(c,l,x,p,v,A,B,ha,K){\"square\"==B||\"default\"==B&&\"square\"==A||!K?c.moveTo(0,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\tconstructor(options) {\n\n\t\tthis.name = \"default\";\n\t\tthis.optsSettings = options.settings;\n\t\tthis.View = options.view;\n\t\tthis.request = options.request;\n\t\tthis.renditionQueue = options.queue;\n\t\tthis.q = new Queue(this);\n\n\t\tthis.settings = extend(this.settings || {}, {\n\t\t\tinfinite: true,\n\t\t\thidden: false,\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\taxis: undefined,\n\t\t\twritingMode: undefined,\n\t\t\tflow: \"scrolled\",\n\t\t\tignoreClass: \"\",\n\t\t\tfullsize: undefined,\n\t\t\tallowScriptedContent: false\n\t\t});\n\n\t\textend(this.settings, options.settings || {});\n\n\t\tthis.viewSettings = {\n\t\t\tignoreClass: this.settings.ignoreClass,\n\t\t\taxis: this.settings.axis,\n\t\t\tflow: this.settings.flow,\n\t\t\tlayout: this.layout,\n\t\t\tmethod: this.settings.method, // srcdoc, blobUrl, write\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tforceEvenPages: true,\n\t\t\tallowScriptedContent: this.settings.allowScriptedContent\n\t\t};\n\n\t\tthis.rendered = false;\n\n\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " text: Ext.util.Format.htmlEncode(String.format(i18n._('User: {0}'), Tine.Tinebase.registry.get('currentAccount').accountDisplayName)),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tthis.getstate = function(sel) {\n\t\tvar sel = this.files(sel),\n\t\t\tcnt = sel.length,\n\t\t\tchk = (cnt && sel[0].phash && (fm.file(sel[0].phash) || {}).write && ! $.map(sel, function(f) { return f.read ? null : true }).length),\n\t\t\tcwdId;\n\t\t\n\t\tif (chk && fm.searchStatus.state > 1) {\n\t\t\tcwdId = fm.cwd().volumeid;\n\t\t\tchk = (cnt === $.map(sel, function(f) { return f.read && f.hash.indexOf(cwdId) === 0 ? f : null; }).length);\n\t\t}\n\t\t\n\t\treturn chk && !this._disabled && mimes.length && (cnt || (dfrd && dfrd.state() == 'pending')) ? 0 : -1;\n\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "-1;d=b.parent?b.getIndex():-1}return c>d?1:-1})},param:function(a){a.children=[];a.isEmpty=true;return a},span:function(a){a.attributes[\"class\"]==\"Apple-style-span\"&&delete a.name},html:function(a){delete a.attributes.contenteditable;delete a.attributes[\"class\"]},body:function(a){delete a.attributes.spellcheck;delete a.attributes.contenteditable},style:function(a){var b=a.children[0];if(b&&b.value)b.value=CKEDITOR.tools.trim(b.value);if(!a.attributes.type)a.attributes.type=\"text/css\"},title:function(a){var b=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "c,b){var e=function(h,f,l){var p=function(n){n&&(this.res=n)};p.prototype=h;p.prototype.constructor=p;h=new p(l);for(var k in f||{})l=f[k],h[k]=l.slice?l.slice():l;return h},g={res:e(c.res,b.res)};g.formatter=e(c.formatter,b.formatter,g.res);g.parser=e(c.parser,b.parser,g.res);t[a]=g};d.compile=function(a){for(var c=/\\[([^\\[\\]]|\\[[^\\[\\]]*])*]|([A-Za-z])\\2+|\\.{3}|./g,b,e=[a];b=c.exec(a);)e[e.length]=b[0];return e};d.format=function(a,c,b){c=\"string\"===typeof c?d.compile(c):c;a=d.addMinutes(a,b?a.getTimezoneOffset():", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "Suite.prototype.slow = function(ms) {\n if (0 === arguments.length) return this._slow;\n if ('string' == typeof ms) ms = milliseconds(ms);\n debug('slow %d', ms);\n this._slow = ms;\n return this;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tnonComputedMember: function(left, right, context, create) {\n\t\treturn function(scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tif (create && create !== 1) {\n\t\t\t\tif (lhs && lhs[right] == null) {\n\t\t\t\t\tlhs[right] = {};\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar value = undefined;\n\t\t\tif (lhs != null && Object.prototype.hasOwnProperty.call(lhs, right)) {\n\t\t\t\tvalue = lhs[right];\n\t\t\t}\n\n\t\t\tif (context) {\n\t\t\t\treturn { context: lhs, name: right, value: value };\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t};\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " context.suiteSetup = function(fn){\n suites[0].beforeAll(fn);\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "mxTooltipHandler.prototype.show=function(a,b,c){if(!this.destroyed&&null!=a&&0\");this.div.style.visibility=\"\";mxUtils.fit(this.div)}};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tadd_options(id, values) {\n\t\tvar select = this.selects[id];\n\t\tvar selected_value = select.value;\n\t\tselect.innerHTML = \"\"; // ensure uniqueness\n\t\tthis.__add_options_to_select(select, values);\n\t\tselect.value = selected_value;\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxUtils.bind(this,function(){}),null,mxResources.get(\"ok\"),mxUtils.bind(this,function(){this.actions.get(\"import\").funct()}))):this.loadImage(E.target.result,mxUtils.bind(this,function(ba){this.resizeImage(ba,E.target.result,mxUtils.bind(this,function(ea,Z,fa){M(U,mxUtils.bind(this,function(){if(null!=ea&&ea.length {\n if (called)\n return;\n called = true;\n fn(...args);\n };\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "success:function(d,e,f){var l=a(this);a(\".popup\").dialog(\"destroy\").remove();b.children(\"span\").removeClass(\"fc_page_loader\");!0===d.success?(return_success(f.process,d.message),l.slideUp(300,function(){l.remove()})):return_error(f.process,d.message)},error:function(b,c,d){a(\".popup\").dialog(\"destroy\").remove();alert(c+\": \"+d)}})}});b.find(\".fc_page_tree_options_open\").add(\"#fc_add_page button:reset\").on(\"click\",function(b){b.preventDefault();var c=a(this);b=a(\"#fc_add_page\");a(\".page_tree_open_options\").removeClass(\"page_tree_open_options\");", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "ta.style.width=\"40px\";ta.style.height=\"12px\";ta.style.marginBottom=\"-2px\";ta.style.backgroundImage=\"url(\"+mxWindow.prototype.normalizeImage+\")\";ta.style.backgroundPosition=\"top center\";ta.style.backgroundRepeat=\"no-repeat\";ta.setAttribute(\"title\",\"Minimize\");var Na=!1,Ca=mxUtils.bind(this,function(){S.innerHTML=\"\";if(!Na){var za=function(Ea,La,Ta){Ea=X(\"\",Ea.funct,null,La,Ea,Ta);Ea.style.width=\"40px\";Ea.style.opacity=\"0.7\";return wa(Ea,null,\"pointer\")},wa=function(Ea,La,Ta){null!=La&&Ea.setAttribute(\"title\",\nLa);Ea.style.cursor=null!=Ta?Ta:\"default\";Ea.style.margin=\"2px 0px\";S.appendChild(Ea);mxUtils.br(S);return Ea};wa(U.sidebar.createVertexTemplate(\"text;strokeColor=none;fillColor=none;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;\",60,30,\"Text\",mxResources.get(\"text\"),!0,!1,null,!0,!0),mxResources.get(\"text\")+\" (\"+Editor.ctrlKey+\"+Shift+X)\");wa(U.sidebar.createVertexTemplate(\"shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;fontColor=#000000;darkOpacity=0.05;fillColor=#FFF9B2;strokeColor=none;fillStyle=solid;direction=west;gradientDirection=north;gradientColor=#FFF2A1;shadow=1;size=20;pointerEvents=1;\",", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "Ka=U.actions.get(\"zoomOut\"),bb=U.actions.get(\"resetView\");u=U.actions.get(\"fullscreen\");var Pa=U.actions.get(\"undo\"),Za=U.actions.get(\"redo\"),z=X(\"\",Pa.funct,null,mxResources.get(\"undo\")+\" (\"+Pa.shortcut+\")\",Pa,Editor.undoImage),L=X(\"\",Za.funct,null,mxResources.get(\"redo\")+\" (\"+Za.shortcut+\")\",Za,Editor.redoImage),M=X(\"\",u.funct,null,mxResources.get(\"fullscreen\"),u,Editor.fullscreenImage);if(null!=W){J=function(){ma.style.display=null!=U.pages&&(\"0\"!=urlParams.pages||1 '+mxUtils.htmlEntities(mxResources.get(\"loading\"))+\"...
    \";C=b.canReplyToReplies();b.commentsSupported()?b.getComments(function(J){function V(P){if(null!=P){P.sort(function(ia,la){return new Date(ia.modifiedDate)-new Date(la.modifiedDate)});for(var R=0;R limit) {\n\t\t\t\t\tnext = target.slice(limit);\n\t\t\t\t\ttarget = target.slice(0, limit);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttarget.droppable(droppableopts);\n\t\t\t\t\n\t\t\t\tif (next) {\n\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\tupdateDroppable(next);\n\t\t\t\t\t}, 20);\n\t\t\t\t}\n\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\t\t\t\t\tinstanceReady: (evt) => {\n\t\t\t\t\t\t\tevt.editor.on('blur', function () {\n\t\t\t\t\t\t\t\tevt.editor.updateElement();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (this.isModal && this.progressInstance) {\n\t\t\t\t\t\t\t\tthis.progressInstance.progressIndicator({ mode: 'hide' });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function(K){l=K};this.setAutoScroll=function(K){p=K};this.setOpenFill=function(K){q=K};this.setStopClickEnabled=function(K){A=K};this.setSelectInserted=function(K){B=K};this.setSmoothing=function(K){f=K};this.setPerfectFreehandMode=function(K){O=K};this.setBrushSize=function(K){I.size=K};this.getBrushSize=function(){return I.size};var t=function(K){y=K;b.getRubberband().setEnabled(!K);b.graphHandler.setSelectEnabled(!K);b.graphHandler.setMoveEnabled(!K);b.container.style.cursor=K?\"crosshair\":\"\";b.fireEvent(new mxEventObject(\"freehandStateChanged\"))};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "(function(){function a(a){if(!(arguments.length<1)){this.range=a;this.forceBrBreak=0;this.enlargeBr=1;this.enforceRealBlocks=0;this._||(this._={})}}function e(a,b,c){for(a=a.getNextSourceNode(b,null,c);!g(a);)a=a.getNextSourceNode(b,null,c);return a}function b(a){var b=[];a.forEach(function(a){if(a.getAttribute(\"contenteditable\")==\"true\"){b.push(a);return false}},CKEDITOR.NODE_ELEMENT,true);return b}function c(a,d,e,g){a:{g==void 0&&(g=b(e));for(var h;h=g.shift();)if(h.getDtd().p){g={element:h,remaining:g};\nbreak a}g=null}if(!g)return 0;if((h=CKEDITOR.filter.instances[g.element.data(\"cke-filter\")])&&!h.check(d))return c(a,d,e,g.remaining);d=new CKEDITOR.dom.range(g.element);d.selectNodeContents(g.element);d=d.createIterator();d.enlargeBr=a.enlargeBr;d.enforceRealBlocks=a.enforceRealBlocks;d.activeFilter=d.filter=h;a._.nestedEditable={element:g.element,container:e,remaining:g.remaining,iterator:d};return 1}var d=/^[\\r\\n\\t ]+$/,g=CKEDITOR.dom.walker.bookmark(false,true),h=CKEDITOR.dom.walker.whitespaces(true),", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "d.executeLayoutList(K);d.customLayoutConfig=K}catch(B){d.handleError(B),null!=window.console&&console.error(B)}},null,null,null,null,null,!0,null,null,\"https://www.diagrams.net/doc/faq/apply-layouts\");d.showDialog(n.container,620,460,!0,!0);n.init()});k=this.get(\"layout\");var x=k.funct;k.funct=function(n,y){x.apply(this,arguments);n.addItem(mxResources.get(\"orgChart\"),null,function(){function K(){\"undefined\"!==typeof mxOrgChartLayout||d.loadingOrgChart||d.isOffline(!0)?J():d.spinner.spin(document.body,\nmxResources.get(\"loading\"))&&(d.loadingOrgChart=!0,\"1\"==urlParams.dev?mxscript(\"js/orgchart/bridge.min.js\",function(){mxscript(\"js/orgchart/bridge.collections.min.js\",function(){mxscript(\"js/orgchart/OrgChart.Layout.min.js\",function(){mxscript(\"js/orgchart/mxOrgChartLayout.js\",J)})})}):mxscript(\"js/extensions.min.js\",J))}var B=null,F=20,G=20,N=!0,J=function(){d.loadingOrgChart=!1;d.spinner.stop();if(\"undefined\"!==typeof mxOrgChartLayout&&null!=B&&N){var X=d.editor.graph,p=new mxOrgChartLayout(X,B,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\t\"binary!==\": function(left, right, context) {\n\t\treturn function(scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) !==\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "!0,0,mxUtils.bind(this,function(b){this.hsplitPosition=b;this.refresh()})))};EditorUi.prototype.createStatusContainer=function(){var a=document.createElement(\"a\");a.className=\"geItem geStatus\";return a};EditorUi.prototype.setStatusText=function(a){this.statusContainer.innerHTML=a;0==this.statusContainer.getElementsByTagName(\"div\").length&&(this.statusContainer.innerHTML=\"\",a=this.createStatusDiv(a),this.statusContainer.appendChild(a))};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\tupdate = function(dir, preHash) {\n\t\t\t\tvar hash = dir.hash,\n\t\t\t\t\ttgt = $('#'+hash2id(preHash || hash)),\n\t\t\t\t\tnode = create(dir, hash);\n\n\t\t\t\tif (tgt.length > 0) {\n\t\t\t\t\tif (dir.notfound) {\n\t\t\t\t\t\tnode.addClass('ui-state-disabled');\n\t\t\t\t\t}\n\t\t\t\t\ttgt.parent().replaceWith(node);\n\t\t\t\t\tdirs[hash] = dir;\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " strict: function(obj, name, loc) {\n if (!obj || !(name in obj)) {\n throw new Exception('\"' + name + '\" not defined in ' + obj, {\n loc: loc\n });\n }\n return obj[name];\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "Math.round(Math.max(0,Math.min(Math.min(l.width,l.x+l.width-x.x),Math.min(l.height,x.y-l.y))))})]},note2:function(c){return[fb(c,[\"size\"],function(l){var x=Math.max(0,Math.min(l.width,Math.min(l.height,parseFloat(mxUtils.getValue(this.state.style,\"size\",g.prototype.size)))));return new mxPoint(l.x+l.width-x,l.y+x)},function(l,x){this.state.style.size=Math.round(Math.max(0,Math.min(Math.min(l.width,l.x+l.width-x.x),Math.min(l.height,x.y-l.y))))})]},manualInput:function(c){var l=[fb(c,[\"size\"],function(x){var p=\nMath.max(0,Math.min(x.height,mxUtils.getValue(this.state.style,\"size\",Ra.prototype.size)));return new mxPoint(x.x+x.width/4,x.y+3*p/4)},function(x,p){this.state.style.size=Math.round(Math.max(0,Math.min(x.height,4*(p.y-x.y)/3)))},!1)];mxUtils.getValue(c.style,mxConstants.STYLE_ROUNDED,!1)&&l.push(kb(c));return l},dataStorage:function(c){return[fb(c,[\"size\"],function(l){var x=\"0\"!=mxUtils.getValue(this.state.style,\"fixedSize\",\"0\"),p=parseFloat(mxUtils.getValue(this.state.style,\"size\",x?L.prototype.fixedSize:", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "(function(){function w(a){if(!a)throw\"Languages-by-groups list are required for construct selectbox\";var c=[],d=\"\",f;for(f in a)for(var g in a[f]){var h=a[f][g];\"en_US\"==h?d=h:c.push(h)}c.sort();d&&c.unshift(d);return{getCurrentLangGroup:function(c){a:{for(var d in a)for(var f in a[d])if(f.toUpperCase()===c.toUpperCase()){c=d;break a}c=\"\"}return c},setLangList:function(){var c={},d;for(d in a)for(var f in a[d])c[a[d][f]]=f;return c}()}}var e=function(){var a=function(a,b,f){var f=f||{},g=f.expires;", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "elFinder.prototype.commands.mkdir = function() {\n\tvar fm = this.fm,\n\t\tself = this;\n\t\n\tthis.value = '';\n\tthis.disableOnSearch = true;\n\tthis.updateOnSelect = false;\n\tthis.mime = 'directory';\n\tthis.prefix = 'untitled folder';\n\tthis.exec = function(contextSel) {\n\t\tif (! contextSel && ! this.options.intoNewFolderToolbtn) {\n\t\t\tfm.getUI('cwd').trigger('unselectall');\n\t\t}\n\t\tthis.move = fm.selected().length? true : false;\n\t\treturn $.proxy(fm.res('mixin', 'make'), self)();\n\t}\n\t\n\tthis.shortcuts = [{\n\t\tpattern : 'ctrl+shift+n'\n\t}];\n\n\tthis.init = function() {\n\t\tif (this.options.intoNewFolderToolbtn) {\n\t\t\tthis.options.ui = 'mkdirbutton';\n\t\t}\n\t}\n\t\n\tfm.bind('select', function(e) {\n\t\tvar sel = (e.data && e.data.selected)? e.data.selected : [];\n\t\tself.title = sel.length? fm.i18n('cmdmkdirin') : fm.i18n('cmdmkdir');\n\t\tself.update(void(0), self.title);\n\t});\n\t\n\tthis.getstate = function(sel) {\n\t\tvar cwd = fm.cwd(),\n\t\t\tsel = (sel && sel[0] != cwd.hash)? this.files(sel) : [],\n\t\t\tcnt = sel.length;\n\n\t\treturn !this._disabled && cwd.write && (!cnt || $.map(sel, function(f) { return f.phash && f.read && !f.locked ? f : null }).length == cnt)? 0 : -1;\n\t}\n\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "var remove = module.exports.remove = function remove(object, path, value) {\n if (typeof path === \"string\") {\n path = path.split(\".\");\n }\n\n if (!(path instanceof Array) || path.length === 0) {\n return false;\n }\n \n path = path.slice();\n\n var key = path.shift();\n\n if (typeof object !== \"object\" || object === null) {\n return false;\n }\n\n if (path.length === 0) {\n if (!Object.hasOwnProperty.call(object, key)) {\n return false;\n }\n\n delete object[key];\n\n return true;\n } else {\n return remove(object[key], path, value);\n }\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "4)&&!!(a%100)||!(a%400)};d.isSameDay=function(a,c){return a.toDateString()===c.toDateString()};d.locale=function(a,c){c?u(a,{res:v,formatter:w,parser:x},c):\"function\"===typeof a?m=a(d):a&&(q&&!q.date&&console.warn(\"This method of changing the locale is deprecated. See documentation for details.\"),m=a);return m};d.extend=function(a){var c=a.extender||{},b;for(b in c)d[b]||(d[b]=c[b]);(a.formatter||a.parser||a.res)&&u(m,t[m],a)};d.plugin=function(a,c){\"function\"===typeof a?d.extend(r[a(d)]):(r[a]=r[a]||\nc,!c&&r[a]&&(d.extend(r[a]),q&&!q.date&&console.warn(\"This method of applying plugins is deprecated. See documentation for details.\")))};d.locale(m,{});\"object\"===typeof module&&\"object\"===typeof module.exports?module.exports=d:\"function\"===typeof define&&define.amd?define([],function(){return d}):q.date=d})(this);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " this.initVariables = function () {\n if (window.PersonalTheme.staticResources) {\n this.staticResources = window.PersonalTheme.staticResources;\n }\n if (window.PersonalTheme.staticJSResources) {\n this.staticJSResources = window.PersonalTheme.staticJSResources;\n }\n if (window.PersonalTheme.staticCSSResources) {\n this.staticCSSResources = window.PersonalTheme.staticCSSResources;\n }\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tthis.closed = function() {\n\t\treturn state == closed;\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " $scope.refresh = function() {\n growl.success('Retrieving node ' + $scope.foreignId + ' from requisition ' + $scope.foreignSource + '...');\n RequisitionsService.getNode($scope.foreignSource, $scope.foreignId).then(\n function(node) { // success\n $scope.node = node;\n },\n $scope.errorHandler\n );\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t__get_array_from_DOM_row(tr) {\n\t\tvar children = tr.children;\n\t\tvar array = [];\n\t\tfor (var i = 0; i < children.length-1; i++) {\n\t\t\tarray.push(children[i].innerText);\n\t\t}\n\t\treturn array;\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function reloadWithDebugInfo() {\n\twindow.name = \"NG_ENABLE_DEBUG_INFO!\" + window.name;\n\twindow.location.reload();\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "function selectedFilesRail(inputFileID) {\n\n var fileobj = [];\n if(inputFileID && inputFileID != '') {\n setFilesRail(document.getElementById(inputFileID).files);\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "function reqEnv(chan, env) {\n if (chan.outgoing.state !== 'open')\n return true;\n var ret = true;\n var keys = Object.keys(env || {});\n var key;\n var val;\n\n for (var i = 0, len = keys.length; i < len; ++i) {\n key = keys[i];\n val = env[key];\n ret = chan._client._sshstream.env(chan.outgoing.id, key, val, false);\n }\n\n return ret;\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "N);var c=this._.editor;c.focus();setTimeout(function(){c.focusManager.unlock()},0)}delete this._.parentDialog;this.foreach(function(a){a.resetInitValue&&a.resetInitValue()})}},addPage:function(a){if(!a.requiredContent||this._.editor.filter.check(a.requiredContent)){for(var b=[],c=a.label?' title=\"'+CKEDITOR.tools.htmlEncode(a.label)+'\"':\"\",e=CKEDITOR.dialog._.uiElementBuilders.vbox.build(this,{type:\"vbox\",className:\"cke_dialog_page_contents\",children:a.elements,expand:!!a.expand,padding:a.padding,\nstyle:a.style||\"width: 100%;\"},b),d=this._.contents[a.id]={},g=e.getChild(),f=0;e=g.shift();)!e.notAllowed&&(\"hbox\"!=e.type&&\"vbox\"!=e.type)&&f++,d[e.id]=e,\"function\"==typeof e.getChild&&g.push.apply(g,e.getChild());f||(a.hidden=!0);b=CKEDITOR.dom.element.createFromHtml(b.join(\"\"));b.setAttribute(\"role\",\"tabpanel\");e=CKEDITOR.env;d=\"cke_\"+a.id+\"_\"+CKEDITOR.tools.getNextNumber();c=CKEDITOR.dom.element.createFromHtml(['',a.label,\"\"].join(\"\"));b.setAttribute(\"aria-labelledby\",d);this._.tabs[a.id]=[c,b];this._.tabIdList.push(a.id);!a.hidden&&this._.pageCount++;this._.lastTab=c;this.updateStyle();b.setAttribute(\"name\",a.id);b.appendTo(this.parts.contents);c.unselectable();this.parts.tabs.append(c);a.accessKey&&(O(this,this,\"CTRL+\"+a.accessKey,Y,Z),this._.accessKeyMap[\"CTRL+\"+\na.accessKey]=a.id)}},selectPage:function(a){if(this._.currentTabId!=a&&!this._.tabs[a][0].hasClass(\"cke_dialog_tab_disabled\")&&!0!==this.fire(\"selectPage\",{page:a,currentPage:this._.currentTabId})){for(var b in this._.tabs){var c=this._.tabs[b][0],e=this._.tabs[b][1];b!=a&&(c.removeClass(\"cke_dialog_tab_selected\"),e.hide());e.setAttribute(\"aria-hidden\",b!=a)}var d=this._.tabs[a];d[0].addClass(\"cke_dialog_tab_selected\");CKEDITOR.env.ie6Compat||CKEDITOR.env.ie7Compat?(G(d[1]),d[1].show(),setTimeout(function(){G(d[1],", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " signal(chan, signal) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const origSignal = signal;\n\n signal = signal.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const signalLen = signal.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 6 + 1 + 4 + signalLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 6, p += 4);\n packet.utf8Write('signal', p += 4, 6);\n\n packet[p += 6] = 0;\n\n writeUInt32BE(packet, signalLen, ++p);\n packet.utf8Write(signal, p += 4, signalLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, signal: ${signal})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "null!=this.linkHint&&(this.linkHint.style.visibility=\"\")};var Za=mxEdgeHandler.prototype.destroy;mxEdgeHandler.prototype.destroy=function(){Za.apply(this,arguments);null!=this.linkHint&&(this.linkHint.parentNode.removeChild(this.linkHint),this.linkHint=null);null!=this.changeHandler&&(this.graph.getModel().removeListener(this.changeHandler),this.graph.getSelectionModel().removeListener(this.changeHandler),this.changeHandler=null)}}();(function(){function b(c,l,x){mxShape.call(this);this.line=c;this.stroke=l;this.strokewidth=null!=x?x:1;this.updateBoundsFromLine()}function e(){mxSwimlane.call(this)}function k(){mxSwimlane.call(this)}function n(){mxCylinder.call(this)}function D(){mxCylinder.call(this)}function t(){mxActor.call(this)}function F(){mxCylinder.call(this)}function d(){mxCylinder.call(this)}function f(){mxCylinder.call(this)}function g(){mxCylinder.call(this)}function m(){mxShape.call(this)}function q(){mxShape.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\t\t\t\t\tscope.findPirate = function() {\n\t\t\t\t\t\treturn scope.ship.pirate;\n\t\t\t\t\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " \"should remove the property\": function(res) {\n assert.isUndefined(res.a);\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " authPassword(username, password) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n const passLen = Buffer.byteLength(password);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 8, p += 14);\n packet.utf8Write('password', p += 4, 8);\n\n packet[p += 8] = 0;\n\n writeUInt32BE(packet, passLen, ++p);\n packet.utf8Write(password, p += 4, passLen);\n\n this._authsQueue.push('password');\n\n this._debug && this._debug('Outbound: Sending USERAUTH_REQUEST (password)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " user: function (done) {\n UserSchema.getUserByUsername(username, function (err, user) {\n if (err) return done(err)\n if (!user) return done('Invalid User Object')\n\n obj._id = user._id\n\n if (\n !_.isUndefined(obj.password) &&\n !_.isEmpty(obj.password) &&\n !_.isUndefined(obj.passconfirm) &&\n !_.isEmpty(obj.passconfirm)\n ) {\n if (obj.password === obj.passconfirm) {\n if (passwordComplexityEnabled) {\n // check Password Complexity\n const passwordComplexity = require('../../../settings/passwordComplexity')\n if (!passwordComplexity.validate(obj.password)) return done('Password does not meet requirements')\n }\n\n user.password = obj.password\n passwordUpdated = true\n }\n }\n\n if (!_.isUndefined(obj.fullname) && obj.fullname.length > 0) user.fullname = obj.fullname\n if (!_.isUndefined(obj.email) && obj.email.length > 0) user.email = obj.email\n if (!_.isUndefined(obj.title) && obj.title.length > 0) user.title = obj.title\n\n user.save(function (err, nUser) {\n if (err) return done(err)\n\n nUser.populate('role', function (err, populatedUser) {\n if (err) return done(err)\n const resUser = stripUserFields(populatedUser)\n\n return done(null, resUser)\n })\n })\n })\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "mxText.prototype.updateValue=function(){if(mxUtils.isNode(this.value))this.node.innerHTML=\"\",this.node.appendChild(this.value);else{var a=this.value;this.dialect!=mxConstants.DIALECT_STRICTHTML&&(a=mxUtils.htmlEntities(a,!1));a=mxUtils.replaceTrailingNewlines(a,\"

    \");a=this.replaceLinefeeds?a.replace(/\\n/g,\"
    \"):a;var b=null!=this.background&&this.background!=mxConstants.NONE?this.background:null,c=null!=this.border&&this.border!=mxConstants.NONE?this.border:null;if(\"fill\"==this.overflow||\n\"width\"==this.overflow)null!=b&&(this.node.style.backgroundColor=b),null!=c&&(this.node.style.border=\"1px solid \"+c);else{var d=\"\";null!=b&&(d+=\"background-color:\"+mxUtils.htmlEntities(b)+\";\");null!=c&&(d+=\"border:1px solid \"+mxUtils.htmlEntities(c)+\";\");a='
    '+a+\"
    \"}this.node.innerHTML=\na;a=this.node.getElementsByTagName(\"div\");0'\n : '<' + type + '>';\n return tag + content + '\\n';\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "module.exports.assign = function (/* target, ... sources */) {\n let args = Array.from(arguments);\n let target = args.shift() || {};\n\n args.forEach(source => {\n Object.keys(source || {}).forEach(key => {\n if (['tls', 'auth'].includes(key) && source[key] && typeof source[key] === 'object') {\n // tls and auth are special keys that need to be enumerated separately\n // other objects are passed as is\n if (!target[key]) {\n // ensure that target has this key\n target[key] = {};\n }\n Object.keys(source[key]).forEach(subKey => {\n target[key][subKey] = source[key][subKey];\n });\n } else {\n target[key] = source[key];\n }\n });\n });\n return target;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": " fetchVisibleGroups(id) {\n return ajax(`/c/${id}/visible_groups.json`);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "safe"} {"code": "null!=this.linkHint&&(this.linkHint.style.visibility=\"\")};var Za=mxEdgeHandler.prototype.destroy;mxEdgeHandler.prototype.destroy=function(){Za.apply(this,arguments);null!=this.linkHint&&(this.linkHint.parentNode.removeChild(this.linkHint),this.linkHint=null);null!=this.changeHandler&&(this.graph.getModel().removeListener(this.changeHandler),this.graph.getSelectionModel().removeListener(this.changeHandler),this.changeHandler=null)}}();(function(){function b(c,l,x){mxShape.call(this);this.line=c;this.stroke=l;this.strokewidth=null!=x?x:1;this.updateBoundsFromLine()}function e(){mxSwimlane.call(this)}function k(){mxSwimlane.call(this)}function n(){mxCylinder.call(this)}function D(){mxCylinder.call(this)}function t(){mxActor.call(this)}function F(){mxCylinder.call(this)}function d(){mxCylinder.call(this)}function f(){mxCylinder.call(this)}function g(){mxCylinder.call(this)}function m(){mxShape.call(this)}function q(){mxShape.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\"nowrap\";H.style.overflow=\"hidden\";H.style.textOverflow=\"ellipsis\";H.setAttribute(\"title\",F.title+\" (\"+F.id+\")\");var S=document.createElement(\"input\");S.setAttribute(\"type\",\"checkbox\");S.checked=b.sidebar.isEntryVisible(F.id);S.defaultChecked=S.checked;H.appendChild(S);mxUtils.write(H,\" \"+F.title);l.appendChild(H);var V=function(M){if(null==M||\"INPUT\"!=mxEvent.getSource(M).nodeName){p.style.textAlign=\"center\";p.style.padding=\"0px\";p.style.color=\"\";p.innerHTML=\"\";if(null!=F.desc){var W=document.createElement(\"pre\");\nW.style.boxSizing=\"border-box\";W.style.fontFamily=\"inherit\";W.style.margin=\"20px\";W.style.right=\"0px\";W.style.textAlign=\"left\";mxUtils.write(W,F.desc);p.appendChild(W)}null!=F.imageCallback?F.imageCallback(p):null!=F.image?p.innerHTML+='':null==F.desc&&(p.style.padding=\"20px\",p.style.color=\"rgb(179, 179, 179)\",mxUtils.write(p,mxResources.get(\"noPreview\")));null!=q&&(q.style.backgroundColor=\"\");q=H;q.style.backgroundColor=Editor.isDarkMode()?\"#000000\":\"#ebf2f9\";null!=\nM&&mxEvent.consume(M)}};mxEvent.addListener(H,\"click\",V);mxEvent.addListener(H,\"dblclick\",function(M){S.checked=!S.checked;mxEvent.consume(M)});x.push(function(){return S.checked?F.id:null});0==D&&0==K&&V()})(G.entries[K])})(C[D])});g=document.createElement(\"div\");g.className=\"geDialogTitle\";mxUtils.write(g,mxResources.get(\"shapes\"));g.style.position=\"absolute\";g.style.top=\"0px\";g.style.left=\"0px\";g.style.lineHeight=\"40px\";g.style.height=\"40px\";g.style.right=\"0px\";var l=document.createElement(\"div\"),", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " AnsiUp.prototype.transform_to_html = function (fragment) {\n var txt = fragment.text;\n if (txt.length === 0)\n return txt;\n if (this._escape_for_html)\n txt = this.escape_txt_for_html(txt);\n if (!fragment.bold && fragment.fg === null && fragment.bg === null)\n return txt;\n var styles = [];\n var classes = [];\n var fg = fragment.fg;\n var bg = fragment.bg;\n if (fragment.bold)\n styles.push('font-weight:bold');\n if (!this._use_classes) {\n if (fg)\n styles.push(\"color:rgb(\" + fg.rgb.join(',') + \")\");\n if (bg)\n styles.push(\"background-color:rgb(\" + bg.rgb + \")\");\n }\n else {\n if (fg) {\n if (fg.class_name !== 'truecolor') {\n classes.push(fg.class_name + \"-fg\");\n }\n else {\n styles.push(\"color:rgb(\" + fg.rgb.join(',') + \")\");\n }\n }\n if (bg) {\n if (bg.class_name !== 'truecolor') {\n classes.push(bg.class_name + \"-bg\");\n }\n else {\n styles.push(\"background-color:rgb(\" + bg.rgb.join(',') + \")\");\n }\n }\n }\n var class_string = '';\n var style_string = '';\n if (classes.length)\n class_string = \" class=\\\"\" + classes.join(' ') + \"\\\"\";\n if (styles.length)\n style_string = \" style=\\\"\" + styles.join(';') + \"\\\"\";\n return \"\" + txt + \"\";\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxUtils.bind(this,function(){0===C&&(c=U.full_path,m=J.path,v=\"\",O(null,!0))})));k.appendChild(E)})(X[u])}}));G()}else G(),mxUtils.write(k,mxResources.get(\"noFiles\"));100==V.length&&(k.appendChild(A),B=function(){k.scrollTop>=k.scrollHeight-k.offsetHeight&&P()},mxEvent.addListener(k,\"scroll\",B))}),y)}}))});b?this.user?t():this.updateUser(function(){t()},y,!0):this.authenticate(mxUtils.bind(this,function(){this.updateUser(function(){t()},y,!0)}),y)};GitLabClient.prototype.logout=function(){this.ui.editor.loadUrl(this.redirectUri+\n\"?doLogout=1&state=\"+encodeURIComponent(\"cId=\"+this.clientId+\"&domain=\"+window.location.hostname));this.clearPersistentToken();this.setUser(null);b=null;this.setToken(null)}})();DrawioComment=function(b,e,f,c,m,n,v){this.file=b;this.id=e;this.content=f;this.modifiedDate=c;this.createdDate=m;this.isResolved=n;this.user=v;this.replies=[]};DrawioComment.prototype.addReplyDirect=function(b){null!=b&&this.replies.push(b)};DrawioComment.prototype.addReply=function(b,e,f,c,m){e()};DrawioComment.prototype.editComment=function(b,e,f){e()};DrawioComment.prototype.deleteComment=function(b,e){b()};DriveComment=function(b,e,f,c,m,n,v,d){DrawioComment.call(this,b,e,f,c,m,n,v);this.pCommentId=d};mxUtils.extend(DriveComment,DrawioComment);DriveComment.prototype.addReply=function(b,e,f,c,m){b={content:b.content};c?b.verb=\"resolve\":m&&(b.verb=\"reopen\");this.file.ui.drive.executeRequest({url:\"/files/\"+this.file.getId()+\"/comments/\"+this.id+\"/replies\",params:b,method:\"POST\"},mxUtils.bind(this,function(n){e(n.replyId)}),f)};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "\t\t\tscrollToView = function(o) {\n\t\t\t\tvar ftop = o.position().top,\n\t\t\t\t\tfheight = o.outerHeight(true),\n\t\t\t\t\twtop = wrapper.scrollTop(),\n\t\t\t\t\twheight = wrapper.get(0).clientHeight,\n\t\t\t\t\tthheight = tableHeader? tableHeader.outerHeight(true) : 0;\n\n\t\t\t\tif (ftop + thheight + fheight > wtop + wheight) {\n\t\t\t\t\twrapper.scrollTop(parseInt(ftop + thheight + fheight - wheight));\n\t\t\t\t} else if (ftop < wtop) {\n\t\t\t\t\twrapper.scrollTop(ftop);\n\t\t\t\t}\n\t\t\t\tlist && wrapper.scrollLeft(0);\n\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\t\t\t\t\t\t\tsetTimeout(function wait() {\n\t\t\t\t\t\t\t\t\tif (processing > 0) {\n\t\t\t\t\t\t\t\t\t\tsetTimeout(wait, 10);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tnotifyto && clearTimeout(notifyto);\n\t\t\t\t\t\t\t\t\t\tfm.notify({type : 'readdir', cnt : -1});\n\t\t\t\t\t\t\t\t\t\tdfrd.resolve([files, paths, renames, hashes, mkdirs]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}, 10);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "pushState:function pushState(condition) {\n this.begin(condition);\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "function toJson(obj, pretty) {\n\tif (isUndefined(obj)) return undefined;\n\tif (!isNumber(pretty)) {\n\t\tpretty = pretty ? 2 : null;\n\t}\n\treturn JSON.stringify(obj, toJsonReplacer, pretty);\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " toMathML: function (space) {return (space||\"\") + \"&\"+this.data[0]+\";\"}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " menuItemTemplate: function (item) {\n let link = document.createElement(\"a\");\n link.innerText = item.string;\n return link.outerHTML;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "new mxPoint(l,v),new mxPoint(0,v)],this.isRounded,A,!0);c.end()};mxCellRenderer.registerShape(\"corner\",Ka);mxUtils.extend(bb,mxActor);bb.prototype.redrawPath=function(c,l,x,p,v){c.moveTo(0,0);c.lineTo(0,v);c.end();c.moveTo(p,0);c.lineTo(p,v);c.end();c.moveTo(0,v/2);c.lineTo(p,v/2);c.end()};mxCellRenderer.registerShape(\"crossbar\",bb);mxUtils.extend(Pa,mxActor);Pa.prototype.dx=20;Pa.prototype.dy=20;Pa.prototype.redrawPath=function(c,l,x,p,v){l=Math.max(0,Math.min(p,parseFloat(mxUtils.getValue(this.style,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "const meta = async (req, res) => {\n try {\n logger.debug('URL file import handler running', null, req.id)\n const { allowLocalUrls } = req.companion.options\n if (!validateURL(req.body.url, allowLocalUrls)) {\n logger.debug('Invalid request body detected. Exiting url meta handler.', null, req.id)\n return res.status(400).json({ error: 'Invalid request body' })\n }\n\n const urlMeta = await getURLMeta(req.body.url, !allowLocalUrls)\n return res.json(urlMeta)\n } catch (err) {\n logger.error(err, 'controller.url.meta.error', req.id)\n // @todo send more meaningful error message and status code to client if possible\n return res.status(err.status || 500).json({ message: 'failed to fetch URL metadata' })\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "once:function(){var b=arguments[1];arguments[1]=function(d){d.removeListener();return b.apply(this,arguments)};return this.on.apply(this,arguments)},capture:function(){CKEDITOR.event.useCapture=1;var b=this.on.apply(this,arguments);CKEDITOR.event.useCapture=0;return b},fire:function(){var b=0,d=function(){b=1},a=0,h=function(){a=1};return function(m,j,i){var n=e(this)[m],m=b,r=a;b=a=0;if(n){var o=n.listeners;if(o.length)for(var o=o.slice(0),u,f=0;f=f){var H=0,S=0,V,M=0;for(V=J;V new Promise(\n\t(resolve, reject) => {\n\t\tconst git = spawn(\n\t\t\t'git',\n\t\t\tstring.split(' '),\n\t\t);\n\n\t\tconst outputs = { stdout: [], stderr: [] };\n\n\t\tgit.stdout.on(\n\t\t\t'data',\n\t\t\tdata => outputs.stdout.push(data.toString()),\n\t\t);\n\n\t\tgit.stderr.on(\n\t\t\t'data',\n\t\t\tdata => outputs.stderr.push(data.toString()),\n\t\t);\n\n\t\tgit.on('exit', code => {\n\t\t\tswitch (code) {\n\t\t\t\tcase 0:\n\t\t\t\t\tresolve(outputs.stdout.join('').trim());\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treject(outputs.stderr.join('').trim());\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t});\n\t},\n);", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "b.$.sheet},createElement:function(a,e){var b=new CKEDITOR.dom.element(a,this);if(e){e.attributes&&b.setAttributes(e.attributes);e.styles&&b.setStyles(e.styles)}return b},createText:function(a){return new CKEDITOR.dom.text(a,this)},focus:function(){this.getWindow().focus()},getActive:function(){return new CKEDITOR.dom.element(this.$.activeElement)},getById:function(a){return(a=this.$.getElementById(a))?new CKEDITOR.dom.element(a):null},getByAddress:function(a,e){for(var b=this.$.documentElement,c=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "A=!1,C=null,F=function(D,O,Q){if(!A){var R=\"null\"==d?null:d;A=!0;D=/(^#?[a-zA-Z0-9]*$)/.test(D)?D:R;R=null!=D&&D!=mxConstants.NONE?D:R;var P=document.createElement(\"div\");P.style.width=\"36px\";P.style.height=\"12px\";P.style.margin=\"3px\";P.style.border=\"1px solid black\";P.style.backgroundColor=\"default\"==R?n:R;C.innerHTML=\"\";C.appendChild(P);null!=D&&D!=mxConstants.NONE&&1 0 && input[placeholder]) {\n\t\t\t\t\t\tignore.push(placeholder)\n\t\t\t\t\t}\n\t\t\t\t\treturn escFunc? escFunc(input[placeholder]) : self.escape(input[placeholder]);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// get HTML from jQuery object\n\t\t\t\tm = m.get(0).outerHTML;\n\t\t\t}\n\n\t\t\tinput[i] = m;\n\t\t}\n\n\t\treturn $.map(input, function(m, i) { return $.inArray(i, ignore) === -1 ? m : null; }).join('
    ');\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $scope.reset = function() {\n bootbox.confirm('Are you sure you want to reset the foreign source definition to the default ?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.deleteForeignSourceDefinition($scope.foreignSource).then(\n function() { // success\n growl.success('The foreign source definition for ' + $scope.foreignSource + 'has been reseted.');\n $scope.initialize();\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(Ta){var za=Fa[Ta],wa=Tac.length;H||D.push.apply(D,c);c=[];D.push(null);u.push(d);d=null;(H||k)&&this.stopDrawing();k&&2<=E&&this.startDrawing();mxEvent.consume(J)}}),K=new mxCell;K.edge=!0;var B=function(){var J=b.getCurrentCellStyle(K);J=mxUtils.getValue(b.currentVertexStyle,mxConstants.STYLE_STROKECOLOR,mxUtils.getValue(J,mxConstants.STYLE_STROKECOLOR,\"#000\"));\"default\"==", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "module.exports = function (options) {\n return new OAuthServer(options);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "function Markdown(runner) {\n Base.call(this, runner);\n\n var self = this\n , stats = this.stats\n , level = 0\n , buf = '';\n\n function title(str) {\n return Array(level).join('#') + ' ' + str;\n }\n\n function indent() {\n return Array(level).join(' ');\n }\n\n function mapTOC(suite, obj) {\n var ret = obj;\n obj = obj[suite.title] = obj[suite.title] || { suite: suite };\n suite.suites.forEach(function(suite) {\n mapTOC(suite, obj);\n });\n return ret;\n }\n\n function stringifyTOC(obj, level) {\n ++level;\n var buf = '';\n var link;\n for (var key in obj) {\n if ('suite' == key) continue;\n if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\\n';\n if (key) buf += Array(level).join(' ') + link;\n buf += stringifyTOC(obj[key], level);\n }\n --level;\n return buf;\n }\n\n function generateTOC(suite) {\n var obj = mapTOC(suite, {});\n return stringifyTOC(obj, 0);\n }\n\n generateTOC(runner.suite);\n\n runner.on('suite', function(suite) {\n ++level;\n var slug = utils.slug(suite.fullTitle());\n buf += '' + '\\n';\n buf += title(suite.title) + '\\n';\n });\n\n runner.on('suite end', function(suite) {\n --level;\n });\n\n runner.on('pass', function(test) {\n var code = utils.clean(test.fn.toString());\n buf += test.title + '.\\n';\n buf += '\\n```js\\n';\n buf += code + '\\n';\n buf += '```\\n\\n';\n });\n\n runner.on('end', function() {\n process.stdout.write('# TOC\\n');\n process.stdout.write(generateTOC(runner.suite));\n process.stdout.write(buf);\n });\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function(){return mxClient.IS_CHROMEAPP||this.useCanvasForExport};Editor.prototype.getMaxCanvasScale=function(p,C,I){var T=mxClient.IS_FF?8192:16384;return Math.min(I,Math.min(T/p,T/C))};Editor.prototype.exportToCanvas=function(p,C,I,T,P,O,R,Y,da,ha,Z,ea,aa,ua,la,Aa,Fa,xa){try{O=null!=O?O:!0;R=null!=R?R:!0;ea=null!=ea?ea:this.graph;aa=null!=aa?aa:0;var Da=da?null:ea.background;Da==mxConstants.NONE&&(Da=null);null==Da&&(Da=T);null==Da&&0==da&&(Da=Aa?this.graph.defaultPageBackgroundColor:\"#ffffff\");", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "setTimeout(function(){Fa.style.display=\"none\"},4E3)}function B(){null!=X&&(X.style.fontWeight=\"normal\",X.style.textDecoration=\"none\",u=X,X=null)}function I(ha,da,ca,la,ia,ma,qa){if(-1=Ia.getStatus()&&(qa=Ia.getText());Ka(qa)}))):Ka(qa)}function ma(na,Ka,Ia){if(null!=na&&mxUtils.isAncestorNode(document.body,da)&&(na=mxUtils.parseXml(na),na=Editor.extractGraphModel(na.documentElement,!0),null!=na)){\"mxfile\"==", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " path: 'http://localhost:' + (port + 1000) + '/message.html'\n }\n }\n };\n shared.resolveContent(mail.data, 'html', function (err) {\n expect(err).to.exist;\n done();\n });\n });", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "[];Editor.doMathJaxRender=function(R){window.setTimeout(function(){\"hidden\"!=R.style.visibility&&MathJax.Hub.Queue([\"Typeset\",MathJax.Hub,R])},0)};var J=null!=urlParams[\"math-font\"]?decodeURIComponent(urlParams[\"math-font\"]):\"TeX\";E=null!=E?E:{\"HTML-CSS\":{availableFonts:[J],imageFont:null},SVG:{font:J,useFontCache:!1},tex2jax:{ignoreClass:\"mxCellEditor\"},asciimath2jax:{ignoreClass:\"mxCellEditor\"}};window.MathJax={skipStartupTypeset:!0,showMathMenu:!1,messageStyle:\"none\",AuthorInit:function(){MathJax.Hub.Config(E);", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "elFinder.prototype.commands.cut = function() {\n\t\n\tthis.shortcuts = [{\n\t\tpattern : 'ctrl+x shift+insert'\n\t}];\n\t\n\tthis.getstate = function(sel) {\n\t\tvar sel = this.files(sel),\n\t\t\tcnt = sel.length;\n\t\t\n\t\treturn !this._disabled && cnt && $.map(sel, function(f) { return f.phash && f.read && !f.locked ? f : null }).length == cnt ? 0 : -1;\n\t}\n\t\n\tthis.exec = function(hashes) {\n\t\tvar fm = this.fm,\n\t\t\tdfrd = $.Deferred()\n\t\t\t\t.fail(function(error) {\n\t\t\t\t\tfm.error(error);\n\t\t\t\t});\n\n\t\t$.each(this.files(hashes), function(i, file) {\n\t\t\tif (!(file.read && file.phash) ) {\n\t\t\t\treturn !dfrd.reject(['errCopy', file.name, 'errPerm']);\n\t\t\t}\n\t\t\tif (file.locked) {\n\t\t\t\treturn !dfrd.reject(['errLocked', file.name]);\n\t\t\t}\n\t\t});\n\t\t\n\t\treturn dfrd.state() == 'rejected' ? dfrd : dfrd.resolve(fm.clipboard(this.hashes(hashes), true));\n\t}\n\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "Cache.prototype.clear = function () {\n this._size = 0\n this._values = Object.create(null)\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "if(p||q){var M=[],W=null,U=null,X=null,u=function(oa){V.setAttribute(\"disabled\",\"disabled\");for(var sa=0;sa=B)break;D[K.id]={replAllMrk:I,replAllPos:B};l.isCellEditable(K)&&(l.model.setValue(K,H(T,A,L.value,B-A.length,l.getCurrentCellStyle(K))),u++)}U!=b.currentPage&&b.editor.graph.model.execute(new SelectPage(b,U));mxUtils.write(F,mxResources.get(\"matchesRepl\",[u]))}catch(Q){b.handleError(Q)}finally{l.getModel().endUpdate(),b.editor.graph.setSelectionCells(X),b.editor.graph.rendering=!0}I++}});M.setAttribute(\"title\",mxResources.get(\"replaceAll\"));M.style.float=\"none\";M.style.width=\"120px\";", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "var b=CKEDITOR.tools.getNextId();this._.groups[a]=b;this._.pendingHtml.push(h.output({id:b,label:a}))},commit:function(){this._.close();this.element.appendHtml(this._.pendingHtml.join(\"\"));delete this._.size;this._.pendingHtml=[]},toggle:function(a){var b=this.isMarked(a);b?this.unmark(a):this.mark(a);return!b},hideGroup:function(a){var b=(a=this.element.getDocument().getById(this._.groups[a]))&&a.getNext();a&&(a.setStyle(\"display\",\"none\"),b&&\"ul\"==b.getName()&&b.setStyle(\"display\",\"none\"))},hideItem:function(a){this.element.getDocument().getById(this._.items[a]).setStyle(\"display\",\n\"none\")},showAll:function(){var a=this._.items,b=this._.groups,c=this.element.getDocument(),d;for(d in a)c.getById(a[d]).setStyle(\"display\",\"\");for(var e in b)a=c.getById(b[e]),d=a.getNext(),a.setStyle(\"display\",\"\"),d&&\"ul\"==d.getName()&&d.setStyle(\"display\",\"\")},mark:function(a){this.multiSelect||this.unmarkAll();var a=this._.items[a],b=this.element.getDocument().getById(a);b.addClass(\"cke_selected\");this.element.getDocument().getById(a+\"_option\").setAttribute(\"aria-selected\",!0);this.onMark&&this.onMark(b)},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " nextId: function(skip, init) {\n var id = 'v' + (this.state.nextId++);\n if (!skip) {\n this.current().vars.push(id + (init ? '=' + init : ''));\n }\n return id;\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "[];for(G=0;Gn&&!mxClient.IS_IOS?O.firstChild.nextSibling.setAttribute(\"title\",X.shortcut):m.apply(this,arguments)};var q=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){q.apply(this,arguments);if(null!=this.userElement){var O=this.userElement;O.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+O.style.display;O.className=\"geToolbarButton\";O.innerHTML=\"\";O.style.backgroundImage=\"url(\"+Editor.userImage+\")\";O.style.backgroundPosition=\"center center\";\nO.style.backgroundRepeat=\"no-repeat\";O.style.backgroundSize=\"24px 24px\";O.style.height=\"24px\";O.style.width=\"24px\";O.style.cssFloat=\"right\";O.setAttribute(\"title\",mxResources.get(\"changeUser\"));if(\"none\"!=O.style.display){O.style.display=\"inline-block\";var X=this.getCurrentFile();if(null!=X&&X.isRealtimeEnabled()&&X.isRealtimeSupported()){var ea=document.createElement(\"img\");ea.setAttribute(\"border\",\"0\");ea.style.position=\"absolute\";ea.style.left=\"18px\";ea.style.top=\"2px\";ea.style.width=\"12px\";ea.style.height=\n\"12px\";var ka=X.getRealtimeError();X=X.getRealtimeState();var ja=mxResources.get(\"realtimeCollaboration\");1==X?(ea.src=Editor.syncImage,ja+=\" (\"+mxResources.get(\"online\")+\")\"):(ea.src=Editor.syncProblemImage,ja=null!=ka&&null!=ka.message?ja+(\" (\"+ka.message+\")\"):ja+(\" (\"+mxResources.get(\"disconnected\")+\")\"));ea.setAttribute(\"title\",ja);O.style.paddingRight=\"4px\";O.appendChild(ea)}}}};var y=App.prototype.updateButtonContainer;App.prototype.updateButtonContainer=function(){y.apply(this,arguments);if(null!=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "EditorUi.prototype.updateTabContainer=function(){null!=this.tabContainer&&(this.tabContainer.style.right=\"70px\",this.diagramContainer.style.bottom=\"1\"==urlParams.sketch?\"0px\":this.tabContainerHeight+\"px\");e.apply(this,arguments)};var g=EditorUi.prototype.updateActionStates;EditorUi.prototype.updateActionStates=function(){g.apply(this,arguments);this.menus.get(\"save\").setEnabled(null!=this.getCurrentFile()||\"1\"==urlParams.embed)};var k=Menus.prototype.addShortcut;Menus.prototype.addShortcut=function(A,\nB){null!=B.shortcut&&900>d&&!mxClient.IS_IOS?A.firstChild.nextSibling.setAttribute(\"title\",B.shortcut):k.apply(this,arguments)};var m=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){m.apply(this,arguments);if(null!=this.userElement){var A=this.userElement;A.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+A.style.display;A.className=\"geToolbarButton\";A.innerHTML=\"\";A.style.backgroundImage=\"url(\"+Editor.userImage+\")\";A.style.backgroundPosition=\"center center\";", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "this.engineLoaded&&\"undefined\"!==typeof window.scayt&&this.getScayt(a)},isScaytEnabled:function(a){return(a=this.getScayt(a))?!1===a.disabled:!1},getUiTabs:function(a){var c=[],b=a.config.scayt_uiTabs||\"1,1,1\",b=b.split(\",\");b[3]=\"1\";for(var d=0;4>d;d++)c[d]=\"undefined\"!=typeof window.scayt&&\"undefined\"!=typeof window.scayt.uiTags?parseInt(b[d],10)&&window.scayt.uiTags[d]:parseInt(b[d],10);\"object\"==typeof a.plugins.wsc?c.push(1):c.push(0);return c},loadEngine:function(a){if(CKEDITOR.env.gecko&&10900>", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function init(_settings, _runtime) {\n settings = _settings;\n runtime = _runtime;\n projectsDir = fspath.join(settings.userDir,\"projects\");\n authCache.init();\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "U;return L.apply(this,arguments)};v.hoverIcons.getStateAt=function(H,S,U){return d(H.cell)?null:this.graph.view.getState(this.graph.getCellAt(S,U))};var M=x.duplicateCells;x.duplicateCells=function(H,S){H=null!=H?H:this.getSelectionCells();for(var U=H.slice(0),Q=0;Q0&&h.which!=l.which||a(h.target).is(l.not))return;switch(h.type) {case\"mousedown\":return a.extend(l,a(j).offset(),{elem:j,target:h.target,pageX:h.pageX,pageY:h.pageY}),b.add(document,\"mousemove mouseup\",e,l),i(j,!1),d.dragging=null,!1;case!d.dragging&&\"mousemove\":if (g(h.pageX-l.pageX)+g(h.pageY-l.pageY)\"']/gm, function (str) {\n if (str === \"&\")\n return \"&\";\n if (str === \"<\")\n return \"<\";\n if (str === \">\")\n return \">\";\n if (str === \"\\\"\")\n return \""\";\n if (str === \"'\")\n return \"'\";\n });\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\"Uploader\").cancelFileUpload(e,!0,!1)})},uploadifyClearQueue:function(){a(this).each(function(){document.getElementById(a(this).attr(\"id\")+\"Uploader\").clearFileUploadQueue(!1)})}})}(jQuery); \r", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "module.exports = function(options) {\n return new OAuthServer(options);\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "function u(a){return a.type==CKEDITOR.NODE_ELEMENT&&(a.name==\"br\"||q.$block[a.name])}function f(a,b,c){var d=a.name;if(q.$empty[d]||!a.children.length)if(d==\"hr\"&&b==\"br\")a.replaceWith(o());else{a.parent&&c.push({check:\"it\",el:a.parent});a.remove()}else if(q.$block[d]||d==\"tr\")if(b==\"br\"){if(a.previous&&!u(a.previous)){b=o();b.insertBefore(a)}if(a.next&&!u(a.next)){b=o();b.insertAfter(a)}a.replaceWithChildren()}else{var d=a.children,f;b:{f=q[b];for(var e=0,l=d.length,k;e0;){k=d[--l];if(e&&(k.type==CKEDITOR.NODE_TEXT||k.type==CKEDITOR.NODE_ELEMENT&&q.$inline[k.name])){if(!g){g=new CKEDITOR.htmlParser.element(b);g.insertAfter(a);c.push({check:\"parent-down\",el:g})}g.add(k,0)}else{g=null;k.insertAfter(a);f.type!=CKEDITOR.NODE_DOCUMENT_FRAGMENT&&(k.type==\nCKEDITOR.NODE_ELEMENT&&!q[f.name][k.name])&&c.push({check:\"el-up\",el:k})}}a.remove()}}else if(d==\"style\")a.remove();else{a.parent&&c.push({check:\"it\",el:a.parent});a.replaceWithChildren()}}function s(a,b,c){var d,f;for(d=0;darguments.length)return this._.children.concat();a.splice||(a=[a]);return 2>a.length?this._.children[a[0]]:this._.children[a[0]]&&this._.children[a[0]].getChild?this._.children[a[0]].getChild(a.slice(1,a.length)):null}},!0);CKEDITOR.ui.dialog.vbox.prototype=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "S&&S(M)}}))}catch(L){null!=S&&S(L)}}),N,sa)}catch(Pa){null!=S&&S(Pa)}};Editor.crcTable=[];for(var D=0;256>D;D++)for(var t=D,F=0;8>F;F++)t=1==(t&1)?3988292384^t>>>1:t>>>1,Editor.crcTable[D]=t;Editor.updateCRC=function(u,J,N,W){for(var S=0;S>>8;return u};Editor.crc32=function(u){for(var J=-1,N=0;N>>8^Editor.crcTable[(J^u.charCodeAt(N))&255];return(J^-1)>>>0};Editor.writeGraphModelToPng=function(u,J,N,W,S){function P(sa,Ba){var ta=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " onUpdate: function(username, accessToken) {\n testtoken = accessToken;\n }.bind(this)", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "Tine.Addressbook.ContactGridPanel.displayNameRenderer = function(data) {\n var i18n = Tine.Tinebase.appMgr.get('Addressbook').i18n;\n return data ? data : ('
    ' + i18n._('No name') + '
    ');\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function usercheck_init_staff(i) {\r\n\r\n var obj = document.getElementById('ajax_output_st');\r\n obj.innerHTML = '';\r\n document.getElementById('usr_err_check').value = '0';\r\n if (i.value.length < 1)\r\n return;\r\n\r\n var err = new Array();\r\n if (i.value.match(/[^A-Za-z0-9_]/))\r\n err[err.length] = 'Username can only contain letters, numbers and underscores';\r\n if (i.value.length < 3)\r\n err[err.length] = 'Username Too Short';\r\n if (err != '') {\r\n obj.style.color = '#ff0000';\r\n obj.innerHTML = err.join('
    ');\r\n return;\r\n }\r\n\r\n ajax_call('Validator.php?u=' + i.value + 'stud', usercheck_callback_staff);\r\n}\r", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "b=CKEDITOR.tools.indexOf(e,a),c=a.next;e.splice(b+1,0,this);this.next=a.next;this.previous=a;a.next=this;c&&(c.previous=this);this.parent=a.parent},insertBefore:function(a){var e=a.parent.children,b=CKEDITOR.tools.indexOf(e,a);e.splice(b,0,this);this.next=a;(this.previous=a.previous)&&(a.previous.next=this);a.previous=this;this.parent=a.parent},getAscendant:function(a){var e=typeof a==\"function\"?a:typeof a==\"string\"?function(b){return b.name==a}:function(b){return b.name in a},b=this.parent;for(;b&&\nb.type==CKEDITOR.NODE_ELEMENT;){if(e(b))return b;b=b.parent}return null},wrapWith:function(a){this.replaceWith(a);a.add(this);return a},getIndex:function(){return CKEDITOR.tools.indexOf(this.parent.children,this)},getFilterContext:function(a){return a||{}}}})();\"use strict\";CKEDITOR.htmlParser.comment=function(a){this.value=a;this._={isBlockLike:false}};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " set: function(k, v) {\n for (const path of FORBIDDEN_KEY_PATHS) {\n if (k.startsWith(`${path}.`)) {\n return this\n }\n }\n\n v = coerce(k, v, this._schema, this)\n const path = k.split('.')\n const childKey = path.pop()\n const parentKey = path.join('.')\n const parent = walk(this._instance, parentKey, true)\n parent[childKey] = v\n return this\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-1321", "cwe_name": "Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')", "description": "The software receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.", "url": "https://cwe.mitre.org/data/definitions/1321.html", "label_name": "vulnerable"} {"code": " ref() {\n this._srv.ref();\n return this;\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "this.spacing=0}function Ca(){mxArrowConnector.call(this);this.spacing=0}function Ra(){mxActor.call(this)}function ab(){mxRectangleShape.call(this)}function Ka(){mxActor.call(this)}function bb(){mxActor.call(this)}function Pa(){mxActor.call(this)}function Za(){mxActor.call(this)}function z(){mxActor.call(this)}function L(){mxActor.call(this)}function M(){mxActor.call(this)}function T(){mxActor.call(this)}function ca(){mxActor.call(this)}function ia(){mxActor.call(this)}function ma(){mxEllipse.call(this)}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function onAuthDecide(ctx, allowed, methodsLeft, isPartial) {\n if (authCtx === ctx && !self.authenticated) {\n if (allowed) {\n stream.removeListener('USERAUTH_REQUEST', onUSERAUTH_REQUEST);\n authCtx = undefined;\n self.authenticated = true;\n stream.authSuccess();\n pendingAuths = [];\n self.emit('ready');\n } else {\n stream.authFailure(methodsLeft, isPartial);\n if (pendingAuths.length) {\n authCtx = pendingAuths.pop();\n if (listenerCount(self, 'authentication'))\n self.emit('authentication', authCtx);\n else\n authCtx.reject();\n }\n }\n }\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "showAll:function(){this._.list.showAll()},add:function(a,b,d){this._.items[a]=d||a;this._.list.add(a,b,d)},startGroup:function(a){this._.list.startGroup(a)},commit:function(){this._.committed||(this._.list.commit(),this._.committed=1,CKEDITOR.ui.fire(\"ready\",this));this._.committed=1},setState:function(a){if(this._.state!=a){var b=this.document.getById(\"cke_\"+this.id);b.setState(a,\"cke_combo\");a==CKEDITOR.TRISTATE_DISABLED?b.setAttribute(\"aria-disabled\",!0):b.removeAttribute(\"aria-disabled\");this._.state=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "module.exports = function newline(state, silent) {\n var pmax, max, pos = state.pos;\n\n if (state.src.charCodeAt(pos) !== 0x0A/* \\n */) { return false; }\n\n pmax = state.pending.length - 1;\n max = state.posMax;\n\n // ' \\n' -> hardbreak\n // Lookup in pending chars is bad practice! Don't copy to other rules!\n // Pending string is stored in concat mode, indexed lookups will cause\n // convertion to flat mode.\n if (!silent) {\n if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {\n if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {\n state.pending = state.pending.replace(/ +$/, '');\n state.push('hardbreak', 'br', 0);\n } else {\n state.pending = state.pending.slice(0, -1);\n state.push('softbreak', 'br', 0);\n }\n\n } else {\n state.push('softbreak', 'br', 0);\n }\n }\n\n pos++;\n\n // skip heading spaces for next line\n while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }\n\n state.pos = pos;\n return true;\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "!function(e){e.languages.sass=e.languages.extend(\"css\",{comment:{pattern:/^([ \\t]*)\\/[\\/*].*(?:(?:\\r?\\n|\\r)\\1[ \\t]+.+)*/m,lookbehind:!0}}),e.languages.insertBefore(\"sass\",\"atrule\",{\"atrule-line\":{pattern:/^(?:[ \\t]*)[@+=].+/m,inside:{atrule:/(?:@[\\w-]+|[+=])/m}}}),delete e.languages.sass.atrule;var t=/\\$[-\\w]+|#\\{\\$[-\\w]+\\}/,a=[/[+*\\/%]|[=!]=|<=?|>=?|\\b(?:and|or|not)\\b/,{pattern:/(\\s+)-(?=\\s)/,lookbehind:!0}];e.languages.insertBefore(\"sass\",\"property\",{\"variable-line\":{pattern:/^[ \\t]*\\$.+/m,inside:{punctuation:/:/,variable:t,operator:a}},\"property-line\":{pattern:/^[ \\t]*(?:[^:\\s]+ *:.*|:[^:\\s]+.*)/m,inside:{property:[/[^:\\s]+(?=\\s*:)/,{pattern:/(:)[^:\\s]+/,lookbehind:!0}],punctuation:/:/,variable:t,operator:a,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,e.languages.insertBefore(\"sass\",\"punctuation\",{selector:{pattern:/([ \\t]*)\\S(?:,[^,\\r\\n]+|[^,\\r\\n]*)(?:,[^,\\r\\n]+)*(?:,(?:\\r?\\n|\\r)\\1[ \\t]+\\S(?:,[^,\\r\\n]+|[^,\\r\\n]*)(?:,[^,\\r\\n]+)*)*/,lookbehind:!0}})}(Prism);", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "function sanitizeShellString(str) {\n const s = str || '';\n let result = '';\n for (i = 0; i <= 2000; i++) {\n if (!(s[i] === undefined ||\n s[i] === '>' ||\n s[i] === '<' ||\n s[i] === '*' ||\n s[i] === '?' ||\n s[i] === '[' ||\n s[i] === ']' ||\n s[i] === '|' ||\n s[i] === '\u02da' ||\n s[i] === '$' ||\n s[i] === ';' ||\n s[i] === '&' ||\n s[i] === '(' ||\n s[i] === ')' ||\n s[i] === ']' ||\n s[i] === '#' ||\n s[i] === '\\\\' ||\n s[i] === '\\t' ||\n s[i] === '\\n' ||\n s[i] === '\"')) {\n result = result + s[i];\n }\n }\n return result;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\t\t\tslug: $( event.target ).data( 'slug' )\n\t\t} );\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t\"binary+\": function(left, right, context) {\n\t\treturn function(scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tvar rhs = right(scope, locals, assign, inputs);\n\t\t\tvar arg = plusFn(lhs, rhs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "var M=mxText.prototype.redraw;mxText.prototype.redraw=function(){M.apply(this,arguments);null!=this.node&&\"DIV\"==this.node.nodeName&&Graph.processFontAttributes(this.node)};Graph.prototype.createTagsDialog=function(p,C,I){function T(){for(var la=R.getSelectionCells(),Aa=[],Fa=0;Fa')\r\n var csvString = Papa.unparse(csvScope, {})\r\n var csvData = new Blob([csvString], {\r\n type: 'text/csv;charset=utf-8;'\r\n });\r\n if (navigator.msSaveBlob) {\r\n navigator.msSaveBlob(csvData, filename);\r\n } else {\r\n var csvURL = window.URL.createObjectURL(csvData);\r\n var dlLink = document.createElement('a');\r\n dlLink.href = csvURL;\r\n dlLink.setAttribute('download', filename)\r\n document.body.appendChild(dlLink)\r\n dlLink.click();\r\n document.body.removeChild(dlLink)\r\n }\r\n $(\"#exportButton\").html(exportHTML)\r\n}\r", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-1236", "cwe_name": "Improper Neutralization of Formula Elements in a CSV File", "description": "The software saves user-provided information into a Comma-Separated Value (CSV) file, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as a command when the file is opened by spreadsheet software.", "url": "https://cwe.mitre.org/data/definitions/1236.html", "label_name": "vulnerable"} {"code": "g&&g(q)})):m(\"\")};EditorUi.prototype.updateDiagram=function(c){function e(J){var E=new mxCellOverlay(J.image||m.warningImage,J.tooltip,J.align,J.valign,J.offset);E.addListener(mxEvent.CLICK,function(H,S){k.alert(J.tooltip)});return E}var g=null,k=this;if(null!=c&&0=u.length)){for(var Z=ea=0;Za.lang?-1:1});e=f.getById(\"scayt_lcol_\"+b);d=f.getById(\"scayt_rcol_\"+b);for(c=0;c {\n // fileList += `
  • ${file.name}
  • `;\n fileList += `
  • ${file.name}
  • `;\n\n fileCounter++;\n });\n console.log(fileobj);\n\n fileListElement.innerHTML = fileList;\n\n if(fileCounter > 0) {\n $(\"#nofiles\").hide();\n } else {\n $(\"#nofiles\").show();\n }\n fileobj = [];\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " refreshTabs : function(){\n \"use strict\";\n window.console.log('refreshTabs');\n var self = this;\n var pltabs = '';\n for(var i=0; i';\n\n var isplaying = '';\n if(pl.id == this.playingPlaylist){\n isplaying += '▶';\n }\n\n var isunsaved = '';\n if(!pl.saved && pl.reason_open !== 'queue'){\n isunsaved += ' (unsaved)';\n }\n\n // fix for CVE-2015-8310\n var escaped_playlist_name = $(\"
    \").text(pl.name).html();\n pltabs += ''+isplaying+' '+escaped_playlist_name + isunsaved;\n if(pl.closable){\n pltabs += '×';\n }\n pltabs += '';\n }\n pltabs += '
  • +
  • ';\n $(self.cssSelectorPlaylistChooser+' ul').empty()\n $(self.cssSelectorPlaylistChooser+' ul').append(pltabs);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tfunction cellClicked(cell)\n\t{\n\t\t// Forces focusout in IE\n\t\tif (!ui.editor.isChromelessView())\n\t\t{\n\t\t\tgraph.container.focus();\n\t\t}\n\n\t\t// Gets the selection cell\n\t\tif (cell == null)\n\t\t{\n\t\t\thighlight.highlight(null);\n\t\t\tdiv.innerHTML = '

    ' + mxResources.get('nothingIsSelected') + '

    ';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar attrs = (cell.value != null) ? cell.value.attributes : null;\n\n\t\t\tif (ui.editor.isChromelessView())\n\t\t\t{\n\t\t\t\thighlight.highlight(graph.view.getState(cell));\n\t\t\t}\n\t\n\t\t\tif (attrs != null)\n\t\t\t{\n\t\t\t\tvar label = graph.sanitizeHtml(graph.getLabel(cell));\n\t\t\t\t\n\t\t\t\tif (label != null && label.length > 0)\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = '

    ' + label + '

    ';\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = '';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (var i = 0; i < attrs.length; i++)\n\t\t\t\t{\n\t\t\t\t\tif (mxUtils.indexOf(ignored, attrs[i].nodeName) < 0 &&\n\t\t\t\t\t\tattrs[i].nodeValue.length > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t// TODO: Add click handler on h2 to output data\n\t\t\t\t\t\tvar h2 = document.createElement('h2');\n\t\t\t\t\t\tmxUtils.write(h2, attrs[i].nodeName);\n\t\t\t\t\t\tdiv.appendChild(h2);\n\t\t\t\t\t\tvar p = document.createElement('p');\n\t\t\t\t\t\tmxUtils.write(p, attrs[i].nodeValue);\n\t\t\t\t\t\tdiv.appendChild(p);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar label = graph.convertValueToString(cell);\n\t\t\t\t\n\t\t\t\tif (label != '')\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = '

    ' + graph.sanitizeHtml(label) + '

    ';\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdiv.innerHTML = '

    No data

    ';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!ui.editor.isChromelessView())\n\t\t\t{\n\t\t\t\tvar button = document.createElement('button');\n\t\t\t\tbutton.setAttribute('title', 'Click or Shift+Click to write data for all selected cells to the browser console');\n\t\t\t\tbutton.style['float'] = 'none';\n\t\t\t\tmxUtils.write(button, 'Write to Console');\n\n\t\t\t\tmxEvent.addListener(button, 'click', function(evt)\n\t\t\t\t{\n\t\t\t\t\textractData(evt);\n\t\t\t\t});\n\n\t\t\t\tdiv.appendChild(button);\n\t\t\t}\n\t\t}\n\t};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "u,D.value=T,D.scale=K,D.redraw())}};var J=mxGraphView.prototype.validateBackgroundPage;mxGraphView.prototype.validateBackgroundPage=function(){J.apply(this,arguments);if(mxClient.IS_GC&&null!=this.getDrawPane()){var u=this.getDrawPane().parentNode;!this.graph.mathEnabled||mxClient.NO_FO||null!=this.webKitForceRepaintNode&&null!=this.webKitForceRepaintNode.parentNode||\"svg\"!=this.graph.container.firstChild.nodeName?null==this.webKitForceRepaintNode||this.graph.mathEnabled&&(\"svg\"==this.graph.container.firstChild.nodeName||\nthis.graph.container.firstChild==this.webKitForceRepaintNode)||(null!=this.webKitForceRepaintNode.parentNode&&this.webKitForceRepaintNode.parentNode.removeChild(this.webKitForceRepaintNode),this.webKitForceRepaintNode=null):(this.webKitForceRepaintNode=document.createElement(\"div\"),this.webKitForceRepaintNode.style.cssText=\"position:absolute;\",u.ownerSVGElement.parentNode.insertBefore(this.webKitForceRepaintNode,u.ownerSVGElement))}};var F=Graph.prototype.refresh;Graph.prototype.refresh=function(){F.apply(this,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "if(d.data(\"cke-saved-name\"))return d}}};CKEDITOR.unlinkCommand=function(){};CKEDITOR.unlinkCommand.prototype={exec:function(b){var a=new CKEDITOR.style({element:\"a\",type:CKEDITOR.STYLE_INLINE,alwaysRemoveElement:1});b.removeStyle(a)},refresh:function(b,a){var d=a.lastElement&&a.lastElement.getAscendant(\"a\",!0);d&&\"a\"==d.getName()&&d.getAttribute(\"href\")&&d.getChildCount()?this.setState(CKEDITOR.TRISTATE_OFF):this.setState(CKEDITOR.TRISTATE_DISABLED)},contextSensitive:1,startDisabled:1,requiredContent:\"a[href]\"};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t'open reload load' : function() { \n\t\t\tthis._disabled = !(this.alwaysEnabled || this.fm.isCommandEnabled(this.name));\n\t\t\tthis.update(void(0), this.value)\n\t\t\tthis.change(); \n\t\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "isEnabled:function(){return!this._.disabled},eventProcessors:CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onClick:function(b,a){this.on(\"click\",function(){a.apply(this,arguments)})}},!0),accessKeyUp:function(){this.click()},accessKeyDown:function(){this.focus()},keyboardFocusable:!0},!0);CKEDITOR.ui.dialog.textInput.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function(){return CKEDITOR.document.getById(this._.inputId)},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "H.x+\" \"+H.y;S=\"\";d=[];for(V=2;Vf;)x.shift()},P=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "mxResources.get(\"containsValidationErrors\"),mxResources.get(\"ok\"));else if(z&&b.hideDialog(),M=!x.model.contains(A),!z||M||L!=q){L=Graph.compress(L);x.getModel().beginUpdate();try{if(M){var n=b.editor.graph.getFreeInsertPoint();A.geometry.x=n.x;A.geometry.y=n.y;x.addCell(A)}x.setCellStyles(mxConstants.STYLE_SHAPE,\"stencil(\"+L+\")\",[A])}catch(y){throw y;}finally{x.getModel().endUpdate()}M&&(x.setSelectionCell(A),x.scrollCellToVisible(A))}};l=mxUtils.button(mxResources.get(\"preview\"),function(){v(k,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " function onSuccess(info) {\n sshstream.removeListener('CHANNEL_OPEN_FAILURE:' + localChan, onFailure);\n sshstream.removeListener('CHANNEL_CLOSE:' + localChan, onFailure);\n\n var chaninfo = {\n type: type,\n incoming: {\n id: localChan,\n window: initWindow,\n packetSize: maxPacket,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n cb(undefined, new Channel(chaninfo, self));\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "\"<\")},htmlEncodeAttr:function(b){return b.replace(/\"/g,\""\").replace(//g,\">\")},htmlDecodeAttr:function(b){return b.replace(/"/g,'\"').replace(/</g,\"<\").replace(/>/g,\">\")},getNextNumber:function(){var b=0;return function(){return++b}}(),getNextId:function(){return\"cke_\"+this.getNextNumber()},override:function(b,a){var d=a(b);d.prototype=b.prototype;return d},setTimeout:function(b,a,d,g,e){e||(e=window);d||(d=e);return e.setTimeout(function(){g?b.apply(d,[].concat(g)):", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "rcube_webmail.prototype.managesieve_setget = function()\n{\n var id = this.filtersets_list.get_single_selection(),\n script = this.env.filtersets[id];\n\n this.goto_url('plugin.managesieve-action', {_act: 'setget', _set: script}, false, true);\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t\t\t\trest = function() {\n\t\t\t\t\tif (!overlay.is(':hidden')) {\n\t\t\t\t\t\toverlay.addClass('ui-front')\n\t\t\t\t\t\t\t.elfinderoverlay('hide')\n\t\t\t\t\t\t\t.off('click', cancel);\n\t\t\t\t\t}\n\t\t\t\t\tnode.removeClass('ui-front').css('position', '');\n\t\t\t\t\tif (tarea) {\n\t\t\t\t\t\tnnode.css('max-height', '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpnode.css('width', '')\n\t\t\t\t\t\t\t.parent('td').css('overflow', '');\n\t\t\t\t\t}\n\t\t\t\t}, colwidth,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " $scope.reset = function() {\n bootbox.confirm('Are you sure you want to reset the foreign source definition to the default ?', function(ok) {\n if (ok) {\n RequisitionsService.startTiming();\n RequisitionsService.deleteForeignSourceDefinition($scope.foreignSource).then(\n function() { // success\n growl.success('The foreign source definition for ' + _.escape($scope.foreignSource) + 'has been reseted.');\n $scope.initialize();\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "function once(fn) {\n let called = false;\n return (...args) => {\n if (called)\n return;\n called = true;\n fn(...args);\n };\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "(function(){if(window.CKEDITOR&&window.CKEDITOR.dom)return;window.CKEDITOR||(window.CKEDITOR=function(){var a={timestamp:\"E0LB\",version:\"4.3.2\",revision:\"ba625e6\",rnd:Math.floor(900*Math.random())+100,_:{pending:[]},status:\"unloaded\",basePath:function(){var b=window.CKEDITOR_BASEPATH||\"\";if(!b)for(var d=document.getElementsByTagName(\"script\"),a=0;aW?K():U=setTimeout(K,W)}}(function(M,W){m(W)},200),mouseUp:function(M,W){m(W)}};l.addMouseListener(this.mouseListeners);this.shareCursorPositionListener=function(){b.isShareCursorPosition()||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "Ka);null==D&&(L(da),t(Pa,\"geTempDlgDiagramTileActive\",ha[ra]));Ra=document.createElement(\"div\");Ra.className=\"geTempDlgDiagramTileImg geTempDlgDiagramTileImgLoading\";var Qa=document.createElement(\"img\");Qa.style.display=\"none\";(function(Ma,Ta,Ua){Qa.onload=function(){Ta.className=\"geTempDlgDiagramTileImg\";Ma.style.display=\"\"};Qa.onerror=function(){this.src!=Ua?this.src=Ua:Ta.className=\"geTempDlgDiagramTileImg geTempDlgDiagramTileImgError\"}})(Qa,Ra,Ia?Ia.replace(\".drawio.xml\",\"\").replace(\".drawio\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "getCommand:function(a){return this.commands[a]},getData:function(a){!a&&this.fire(\"beforeGetData\");var b=this._.data;if(typeof b!=\"string\")b=(b=this.element)&&this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE?b.is(\"textarea\")?b.getValue():b.getHtml():\"\";b={dataValue:b};!a&&this.fire(\"getData\",b);return b.dataValue},getSnapshot:function(){var a=this.fire(\"getSnapshot\");if(typeof a!=\"string\"){var b=this.element;b&&this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE&&(a=b.is(\"textarea\")?b.getValue():b.getHtml())}return a},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tset_statustext: function(_value) {\n\t\t// Tooltip should not be shown in mobile view\n\t\tif (egwIsMobile()) return;\n\t\t// Don't execute the code below, if no tooltip will be attached/detached\n\t\tif (_value == \"\" && !this._tooltipElem)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.statustext = _value;\n\n\t\t//Get the domnode the tooltip should be attached to\n\t\tvar elem = jQuery(this.getTooltipElement());\n\n\t\tif (elem)\n\t\t{\n\t\t\t//If a tooltip is already attached to the element, remove it first\n\t\t\tif (this._tooltipElem)\n\t\t\t{\n\t\t\t\tthis.egw().tooltipUnbind(this._tooltipElem);\n\t\t\t\tthis._tooltipElem = null;\n\t\t\t}\n\n\t\t\tif (_value && _value != '')\n\t\t\t{\n\t\t\t\tthis.egw().tooltipBind(elem, _value, this.options.statustext_html);\n\t\t\t\tthis._tooltipElem = elem;\n\t\t\t}\n\t\t}\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "'\" for=\"'+c.inputId+'\"'+(a.labelStyle?' style=\"'+a.labelStyle+'\"':\"\")+\">\"+CKEDITOR.tools.htmlEncode(a.label)+\"\"},{type:\"html\",html:'\"+e.call(this,b,a)+\"\"}]},CKEDITOR.dialog._.uiElementBuilders.hbox.build(b,d,f));return f.join(\"\")})}},textInput:function(b,a,d){if(!(3>arguments.length)){i.call(this,a);var e=this._.inputId=CKEDITOR.tools.getNextId()+\"_textInput\",c={\"class\":\"cke_dialog_ui_input_\"+", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " success:function(data){\n if (data === 'failure') return;\n lastEventId=data[0];\n if(data[1]){\n var text=data[1];\n if($(\"#activity-feed .items .empty\").html()){\n $(\"#activity-feed .items\").html(\n \"
    \");\n }\n if($(\"#new-events\").is(\":hidden\")){\n $(\"#new-events\").show();\n }\n $.each($(\".list-view\"), function(){\n if(typeof $.fn.yiiListView.settings[\"'\"+$(this).attr(\"id\")+\"'\"] ===\n \"undefined\")\n $(this).yiiListView();\n });\n that.DEBUG && console.log ('hiding ' + text);\n $newElem = $(text).hide().prependTo(\"#new-events\");\n that.makePostExpandable ($newElem.find ('.event-text-box').children ('.event-text'));\n $newElem.fadeIn(1000);\n }\n if(data[2]){\n var comments=data[2];\n $.each(comments,function(key,value){\n $(\"#\"+key+\"-comment-count\").html(\"\"+value+\"\");\n });\n if(data[3]>lastEventId)\n lastEventId=data[3];\n if(data[4]>lastTimestamp)\n lastTimestamp=data[4];\n }\n var t=setTimeout(function(){updateFeed();},5000);\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "function isNumber(value) {return typeof value === 'number';}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "TagSearch.prototype.decorate = function(element) {\n this._element = element;\n this._contentBox = $('#ContentLeft');\n this._xButton = $('input[name=reset_query]');\n element.keyup(this.makeKeyUpHandler());\n element.keydown(this.makeKeyDownHandler());\n\n var me = this;\n this._xButton.click(function(){ me.reset() });\n\n var toolTip = new InputToolTip();\n toolTip.setPromptText(askbot['data']['tagSearchPromptText']);\n toolTip.setClickHandler(function() {\n element.focus();\n });\n element.after(toolTip.getElement());\n //below is called after getElement, b/c element must be defined\n if (this.getQuery() !== '') {\n toolTip.hide();//hide if search query is not empty\n }\n this._toolTip = toolTip;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "var P=new Spinner({left:\"50%\",lines:12,length:8,width:3,radius:5,rotate:0,color:\"#000\",speed:1,trail:60,shadow:!1,hwaccel:!1,className:\"spinner\",zIndex:2E9}),J=new Editor,F=null,H=null,S=null,V=!1,M=[],W=null,U=null;this.getSelectedItem=function(){null!=H&&n(H);return H};if(null==y(\"#mxODPickerCss\")){var X=document.head||document.getElementsByTagName(\"head\")[0],u=document.createElement(\"style\");X.appendChild(u);u.type=\"text/css\";u.id=\"mxODPickerCss\";u.appendChild(document.createTextNode(G))}b.innerHTML=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "this.user&&this.updateUser(this.emptyFn,this.emptyFn,!0),f(g)):n||401!==g.getStatus()&&400!==g.getStatus()?c(this.parseRequestText(g)):this.authenticate(function(){m(!0)},c,n))}),mxUtils.bind(this,function(g){window.clearTimeout(d);v&&c(g)}))});null==b||6E4>this.tokenExpiresOn-Date.now()?this.authenticate(function(){m(!0)},c):m(!1)};OneDriveClient.prototype.checkToken=function(e,f){null==b||null==this.tokenRefreshThread||6E4>this.tokenExpiresOn-Date.now()?this.authenticate(e,null!=f?f:this.emptyFn):\ne()};OneDriveClient.prototype.getItemRef=function(e){var f=e.split(\"/\");return 1'+name+'');\n\t\t\t\t});\n\t\t\t\treturn dirs.join(''+fm.option('separator')+'');\n\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "function pa(){mxEllipse.call(this)}function ua(){mxEllipse.call(this)}function ya(){mxRhombus.call(this)}function Fa(){mxEllipse.call(this)}function Ma(){mxEllipse.call(this)}function Oa(){mxEllipse.call(this)}function Qa(){mxEllipse.call(this)}function Ta(){mxActor.call(this)}function za(){mxActor.call(this)}function wa(){mxActor.call(this)}function Ea(c,l,x,p){mxShape.call(this);this.bounds=c;this.fill=l;this.stroke=x;this.strokewidth=null!=p?p:1;this.rectStyle=\"square\";this.size=10;this.absoluteCornerSize=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " function test_behavior_with_bad_packet(test_case_name, bad_packet, expectError, done) {\n redirectToFile(\n \"MessageBuilder_\" + test_case_name + \".log\",\n () => {\n const messageBuilder = new MessageBuilder();\n\n let full_message_body_event_received = false;\n let on_message__received = false;\n\n messageBuilder\n .on(\"message\", (message) => {\n on_message__received = true;\n })\n .on(\"full_message_body\", (full_message_body) => {\n full_message_body_event_received = true;\n })\n .on(\"invalid_message\", (err) => {\n expectError.should.eql(false);\n on_message__received.should.equal(false);\n full_message_body_event_received.should.equal(true);\n done();\n })\n .on(\"error\", (err) => {\n err.should.be.instanceOf(Error);\n expectError.should.eql(true);\n done();\n });\n\n messageBuilder.feed(bad_packet); // OpenSecureChannel message\n },\n function () {}\n );\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " 'readYAML': function(test) {\n test.expect(5);\n var obj;\n obj = grunt.file.readYAML('test/fixtures/utf8.yaml');\n test.deepEqual(obj, this.object, 'file should be safely read as utf8 by default and parsed correctly.');\n\n obj = grunt.file.readYAML('test/fixtures/utf8.yaml', null, {unsafeLoad: true});\n test.deepEqual(obj, this.object, 'file should be unsafely read as utf8 by default and parsed correctly.');\n\n obj = grunt.file.readYAML('test/fixtures/iso-8859-1.yaml', {encoding: 'iso-8859-1'});\n test.deepEqual(obj, this.object, 'file should be read using the specified encoding.');\n\n test.throws(function() {\n obj = grunt.file.readYAML('test/fixtures/error.yaml');\n }, function(err) {\n return err.message.indexOf('undefined') === -1;\n }, 'error thrown should not contain undefined.');\n\n grunt.file.defaultEncoding = 'iso-8859-1';\n obj = grunt.file.readYAML('test/fixtures/iso-8859-1.yaml');\n test.deepEqual(obj, this.object, 'changing the default encoding should work.');\n test.done();\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-1188", "cwe_name": "Insecure Default Initialization of Resource", "description": "The software initializes or sets a resource with a default that is intended to be changed by the administrator, but the default is not secure.", "url": "https://cwe.mitre.org/data/definitions/1188.html", "label_name": "safe"} {"code": "function deleteClient() {\n var tr = $(this).closest(\"tr\");\n var id = tr.attr(\"data-id\");\n var ip = tr.find(\"#ip_\" + id).text();\n var name = utils.escapeHtml(tr.find(\"#name_\" + id).text());\n\n if (name.length > 0) {\n ip += \" (\" + name + \")\";\n }\n\n utils.disableAll();\n utils.showAlert(\"info\", \"\", \"Deleting client...\", ip);\n $.ajax({\n url: \"scripts/pi-hole/php/groups.php\",\n method: \"post\",\n dataType: \"json\",\n data: { action: \"delete_client\", id: id, token: token },\n success: function (response) {\n utils.enableAll();\n if (response.success) {\n utils.showAlert(\"success\", \"far fa-trash-alt\", \"Successfully deleted client \", ip);\n table.row(tr).remove().draw(false).ajax.reload(null, false);\n reloadClientSuggestions();\n } else {\n utils.showAlert(\"error\", \"\", \"Error while deleting client with ID \" + id, response.message);\n }\n },\n error: function (jqXHR, exception) {\n utils.enableAll();\n utils.showAlert(\"error\", \"\", \"Error while deleting client with ID \" + id, jqXHR.responseText);\n console.log(exception); // eslint-disable-line no-console\n }\n });\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "safe"} {"code": " delObject: function ($tree, id, callback) {\n const leaf = $tree ? $tree.selectId('getTreeInfo', id) : null;\n if (main.objects[id]) {\n if (leaf && leaf.children) {\n // ask if only object must be deleted or just this one\n main.confirmMessage(_('Do you want to delete just one object or all children of %s too?', id), null, 'help_outline', [_('_All'), _('Only one'), _('Cancel')], function (result) {\n // If all\n if (result === 0) {\n main._delObjects(id, true, callback);\n } else\n // if only one object\n if (result === 1) {\n main._delObjects(id, false, callback);\n } // else do nothing\n });\n } else {\n main.confirmMessage(_('Are you sure to delete %s?', id), null, 'help_outline', function (result) {\n // If all\n if (result) main._delObjects(id, true, callback);\n });\n }\n } else if (leaf && leaf.children) {\n main.confirmMessage(_('Are you sure to delete all children of %s?', id), null, 'help_outline', function (result) {\n // If all\n if (result) main._delObjects(id, true, callback);\n });\n } else {\n main.showMessage(_('Object \"%s\" does not exists. Update the page.', id), _('Error'), 'help_outline', function (result) {\n // If all\n if (result) main._delObjects(id, true, callback);\n });\n }\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "function(a){b.lock(a.data&&a.data.dontUpdate)});a.on(\"unlockSnapshot\",b.unlock,b)}});CKEDITOR.plugins.undo={};var f=CKEDITOR.plugins.undo.Image=function(a,c){this.editor=a;a.fire(\"beforeUndoImage\");var d=a.getSnapshot();CKEDITOR.env.ie&&d&&(d=d.replace(/\\s+data-cke-expando=\".*?\"/g,\"\"));this.contents=d;c||(this.bookmarks=(d=d&&a.getSelection())&&d.createBookmarks2(!0));a.fire(\"afterUndoImage\")},h=/\\b(?:href|src|name)=\"[^\"]*?\"/gi;f.prototype={equalsContent:function(a){var c=this.contents,a=a.contents;", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.moveChildren(a);this.getParent()&&this.$.parentNode.replaceChild(a.$,this.$);a.$[\"data-cke-expando\"]=this.$[\"data-cke-expando\"];this.$=a.$}},getChild:function(){function a(b,c){var d=b.childNodes;if(c>=0&&c0&&c;)c=a(c,b.shift());else c=a(c,b);return c?new CKEDITOR.dom.node(c):null}}(),getChildCount:function(){return this.$.childNodes.length},disableContextMenu:function(){this.on(\"contextmenu\",function(a){a.data.getTarget().hasClass(\"cke_enable_context_menu\")||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function isJSXLiteral(node) {\n return node.parent.type === \"JSXAttribute\" || node.parent.type === \"JSXElement\" || node.parent.type === \"JSXFragment\";\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "[\"javascript:\",t(f)]}a[\"data-cke-saved-href\"]=e.join(\"\")}if(c.target)if(c.target.type==\"popup\"){for(var e=[\"window.open(this.href, '\",c.target.name||\"\",\"', '\"],j=[\"resizable\",\"status\",\"location\",\"toolbar\",\"menubar\",\"fullscreen\",\"scrollbars\",\"dependent\"],i=j.length,f=function(a){c.target[a]&&j.push(a+\"=\"+c.target[a])},h=0;h= 0; i--) {\n var d = diff[i];\n for (var j = 0; j < d.oldlength; j++) {\n if (str[d.start-1+j] !== d.oldlines[j]) {\n return false;\n }\n }\n Array.prototype.splice.apply(str,[d.start-1,+d.oldlength].concat(d.newlines));\n }\n\n if (remEOFNL) {\n while (!str[str.length-1]) {\n str.pop();\n }\n } else if (addEOFNL) {\n str.push('');\n }\n return str.join('\\n');\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "label:c.lang.link.anchor.title,accessKey:\"I\",elements:[{type:\"text\",id:\"txtName\",label:c.lang.link.anchor.name,required:!0,validate:function(){return!this.getValue()?(alert(c.lang.link.anchor.errorName),!1):!0}}]}]}});", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " delete_row(row_id) {\n var tr = document.getElementById(row_id);\n var array = this.__get_array_from_DOM_row(tr);\n var data_index = this.__find_array_index(array, this.data);\n tr.outerHTML = \"\";\n this.data.splice(data_index, 1);\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function testImage() {\n return testContainer.firstChild;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "App.Actions.DB.update_dns_record_hint = function(elm, hint) {\n // clean hint\n if (hint.trim() == '') {\n $(elm).parent().find('.hint').html('');\n }\n\n // set domain name without rec in case of @ entries\n if (hint == '@') {\n hint = '';\n }\n\n // dont show pregix if domain name = rec value\n if (hint == GLOBAL.DNS_REC_PREFIX + '.') {\n hint = '';\n }\n\n // add dot at the end if needed\n if (hint != '' && hint.slice(-1) != '.') {\n hint += '.';\n }\n\n $(elm).parent().find('.hint').text(hint + GLOBAL.DNS_REC_PREFIX);\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "u[E]}catch(J){null!=window.console&&console.log(\"Error in vars URL parameter: \"+J)}};Graph.prototype.getExportVariables=function(){return null!=this.globalVars?mxUtils.clone(this.globalVars):{}};var z=Graph.prototype.getGlobalVariable;Graph.prototype.getGlobalVariable=function(u){var E=z.apply(this,arguments);null==E&&null!=this.globalVars&&(E=this.globalVars[u]);return E};Graph.prototype.getDefaultStylesheet=function(){if(null==this.defaultStylesheet){var u=this.themes[\"default-style2\"];this.defaultStylesheet=\n(new mxCodec(u.ownerDocument)).decode(u)}return this.defaultStylesheet};Graph.prototype.isViewer=function(){return urlParams.viewer};var L=Graph.prototype.getSvg;Graph.prototype.getSvg=function(u,E,J,T,N,Q,R,Y,ba,ea,Z,fa,aa,va){var ja=null,Ba=null,Ha=null;fa||null==this.themes||\"darkTheme\"!=this.defaultThemeName||(ja=this.stylesheet,Ba=this.shapeForegroundColor,Ha=this.shapeBackgroundColor,this.shapeForegroundColor=\"darkTheme\"==this.defaultThemeName?\"#000000\":Editor.lightColor,this.shapeBackgroundColor=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function ElementAttributes(){\n\tthis.attributeNames = {}\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-436", "cwe_name": "Interpretation Conflict", "description": "Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.", "url": "https://cwe.mitre.org/data/definitions/436.html", "label_name": "safe"} {"code": "CKEDITOR.dom.element.setMarker=function(a,e,b,c){var d=e.getCustomData(\"list_marker_id\")||e.setCustomData(\"list_marker_id\",CKEDITOR.tools.getNextNumber()).getCustomData(\"list_marker_id\"),g=e.getCustomData(\"list_marker_names\")||e.setCustomData(\"list_marker_names\",{}).getCustomData(\"list_marker_names\");a[d]=e;g[b]=1;return e.setCustomData(b,c)};CKEDITOR.dom.element.clearAllMarkers=function(a){for(var e in a)CKEDITOR.dom.element.clearMarkers(a,a[e],1)};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function U(a,b) {for(var c=a.f,d=a.d,f=a.input,h=a.c,k=f.length,e=b[0],g=b[1],l,p;d=k);)c|=f[h++]<>>16;a.f=c>>p;a.d=d-p;a.c=h;return l&65535}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " mouseProto._touchMove = function (event) {\n\n\t// Ignore event if not handled\n\tif (!touchHandled) {\n\t return;\n\t}\n\n\t// Ignore if it's a \"false\" move (position not changed)\n\tvar x = event.originalEvent.changedTouches[0].screenX.toFixed(0);\n\tvar y = event.originalEvent.changedTouches[0].screenY.toFixed(0);\n\t// Ignore if it's a \"false\" move (position not changed)\n\tif (Math.abs(posX - x) <= 2 && Math.abs(posY - y) <= 2) {\n\t\treturn;\n\t}\n\n\t// Interaction was not a click\n\tthis._touchMoved = true;\n\n\t// Simulate the mousemove event\n\tsimulateMouseEvent(event, 'mousemove');\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " function copy(target, current) {\n lazy.forOwn(current, function (value, key) {\n if (key === '__proto__') {\n return;\n }\n\n var val = target[key];\n // add the missing property, or allow a null property to be updated\n if (val == null) {\n target[key] = value;\n } else if (lazy.isObject(val) && lazy.isObject(value)) {\n defaultsDeep(val, value);\n }\n });\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "null!=na){ca=ha.getAttribute(\"section\");aa=ha.getAttribute(\"subsection\");if(null==ca&&(la=na.indexOf(\"/\"),ca=na.substring(0,la),null==aa)){var oa=na.indexOf(\"/\",la+1);-1'\n html += '
    '\n html += '

    ' + message.body + '

    '\n html += '
    '\n html += '
    '\n } else {\n html += '
    '\n html +=\n '
    '\n html += '

    ' + message.body + '

    '\n html += '
    '\n html += '
    '\n }\n\n return html\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-662", "cwe_name": "Improper Synchronization", "description": "The software utilizes multiple threads or processes to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.", "url": "https://cwe.mitre.org/data/definitions/662.html", "label_name": "safe"} {"code": "process.removeListener = function(e, fn) {\n if ('uncaughtException' == e) {\n global.onerror = function() {};\n var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn);\n if (i != -1) { uncaughtExceptionHandlers.splice(i, 1); }\n }\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "NewListFromSelection.prototype.convertToAddToList = function (listId, dialogState) {\n var that = this;\n var addToList = this.massActionsManager.massActionObjects['MassAddToList'];\n var newListName = this.dialogElem$.find ('.new-list-name');\n var listName = $(newListName).val ();\n addToList.addListOption (listId, listName);\n addToList.setListId (listId);\n addToList.progressBar = this.progressBar;\n addToList.recordCount = this.recordCount;\n dialogState.superExecuteParams.listId = listId;\n dialogState.superExecuteParams.massAction = addToList.massActionName;\n\n return addToList;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "1)},setStartBefore:function(a){this.setStart(a.getParent(),a.getIndex())},setEndAfter:function(a){this.setEnd(a.getParent(),a.getIndex()+1)},setEndBefore:function(a){this.setEnd(a.getParent(),a.getIndex())},setStartAt:function(a,b){switch(b){case CKEDITOR.POSITION_AFTER_START:this.setStart(a,0);break;case CKEDITOR.POSITION_BEFORE_END:a.type==CKEDITOR.NODE_TEXT?this.setStart(a,a.getLength()):this.setStart(a,a.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setStartBefore(a);break;case CKEDITOR.POSITION_AFTER_END:this.setStartAfter(a)}c(this)},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "insertText:function(a){this.fire(\"insertText\",a)},insertElement:function(a){this.fire(\"insertElement\",a)},focus:function(){this.fire(\"beforeFocus\")},checkDirty:function(){return this.status==\"ready\"&&this._.previousValue!==this.getSnapshot()},resetDirty:function(){this._.previousValue=this.getSnapshot()},updateElement:function(){return r.call(this)},setKeystroke:function(){for(var a=this.keystrokeHandler.keystrokes,b=CKEDITOR.tools.isArray(arguments[0])?arguments[0]:[[].slice.call(arguments,0)],c,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "module.exports = function(grunt) {\n // Project configuration.\n grunt.initConfig({\n eslint: {\n all: ['index.js', 'lib/**/*.js', 'test/**/*.js', 'examples/**/*.js', 'Gruntfile.js']\n },\n\n mochaTest: {\n all: {\n options: {\n reporter: 'spec'\n },\n src: ['test/**/*-test.js']\n }\n }\n });\n\n // Load the plugin(s)\n grunt.loadNpmTasks('grunt-eslint');\n grunt.loadNpmTasks('grunt-mocha-test');\n\n // Tasks\n grunt.registerTask('default', ['eslint', 'mochaTest']);\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "\"{\").replace(/\\]/g,\"}\")}}();CKEDITOR.plugins.add(\"dialogui\",{onLoad:function(){var i=function(b){this._||(this._={});this._[\"default\"]=this._.initValue=b[\"default\"]||\"\";this._.required=b.required||!1;for(var a=[this._],d=1;dn&&!mxClient.IS_IOS?O.firstChild.nextSibling.setAttribute(\"title\",X.shortcut):m.apply(this,arguments)};var q=App.prototype.updateUserElement;App.prototype.updateUserElement=function(){q.apply(this,arguments);if(null!=this.userElement){var O=this.userElement;O.style.cssText=\"position:relative;margin-right:4px;cursor:pointer;display:\"+O.style.display;O.className=\"geToolbarButton\";O.innerHTML=\"\";O.style.backgroundImage=\"url(\"+Editor.userImage+\")\";O.style.backgroundPosition=\"center center\";", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "var sanitizeInput = function (username) {\n return username\n .replace(/\\*/g, '\\\\2a')\n .replace(/\\(/g, '\\\\28')\n .replace(/\\)/g, '\\\\29')\n .replace(/\\\\/g, '\\\\5c')\n .replace(/\\0/g, '\\\\00')\n .replace(/\\//g, '\\\\2f');\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-90", "cwe_name": "Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection')", "description": "The software constructs all or part of an LDAP query using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended LDAP query when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/90.html", "label_name": "safe"} {"code": "function(c,l,x){c=[];var p=x*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowWidth\",this.arrowWidth)))),v=l*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowSize\",this.arrowSize))));p=(x-p)/2;c.push(new mxConnectionConstraint(new mxPoint(0,.5),!1));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,0,p));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,.5*(l-v),p));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,l-v,0));c.push(new mxConnectionConstraint(new mxPoint(1,\n.5),!1));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,l-v,x));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,.5*(l-v),x-p));c.push(new mxConnectionConstraint(new mxPoint(0,0),!1,null,0,x-p));return c};z.prototype.getConstraints=function(c,l,x){c=[];var p=x*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowWidth\",Za.prototype.arrowWidth)))),v=l*Math.max(0,Math.min(1,parseFloat(mxUtils.getValue(this.style,\"arrowSize\",Za.prototype.arrowSize))));p=(x-p)/2;c.push(new mxConnectionConstraint(new mxPoint(0,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(J){var F=x.length;if(1===F%2||F>=f){var H=0,S=0,V,M=0;for(V=J;VW?J():U=setTimeout(J,W)}}(function(M,W){m(W)},200),mouseUp:function(M,W){m(W)}};l.addMouseListener(this.mouseListeners);this.shareCursorPositionListener=function(){b.isShareCursorPosition()||", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "function sanitizeShellString(str, strict = false) {\n const s = str || '';\n let result = '';\n for (let i = 0; i <= 2000; i++) {\n if (!(s[i] === undefined ||\n s[i] === '>' ||\n s[i] === '<' ||\n s[i] === '*' ||\n s[i] === '?' ||\n s[i] === '[' ||\n s[i] === ']' ||\n s[i] === '|' ||\n s[i] === '\u02da' ||\n s[i] === '$' ||\n s[i] === ';' ||\n s[i] === '&' ||\n s[i] === '(' ||\n s[i] === ')' ||\n s[i] === ']' ||\n s[i] === '#' ||\n s[i] === '\\\\' ||\n s[i] === '\\t' ||\n s[i] === '\\n' ||\n s[i] === '\\'' ||\n s[i] === '`' ||\n s[i] === '\"' ||\n s[i].length > 1 ||\n (strict && s[i] === '@') ||\n (strict && s[i] === ' ') ||\n (strict && s[i] == '{') ||\n (strict && s[i] == ')'))) {\n result = result + s[i];\n }\n }\n return result;\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "CKEDITOR.dialog.add(\"link\",function(n){var p,q;function r(a){return a.replace(/'/g,\"\\\\$&\")}function t(a){var g,c=p,d,e;g=[q,\"(\"];for(var b=0;b {};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " depthedLookup: function(name) {\n return [\n this.aliasable('container.lookup'),\n '(depths, ',\n JSON.stringify(name),\n ')'\n ];\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "function pa(){mxEllipse.call(this)}function ua(){mxEllipse.call(this)}function ya(){mxRhombus.call(this)}function Fa(){mxEllipse.call(this)}function Ma(){mxEllipse.call(this)}function Oa(){mxEllipse.call(this)}function Qa(){mxEllipse.call(this)}function Ta(){mxActor.call(this)}function za(){mxActor.call(this)}function wa(){mxActor.call(this)}function Ea(c,l,x,p){mxShape.call(this);this.bounds=c;this.fill=l;this.stroke=x;this.strokewidth=null!=p?p:1;this.rectStyle=\"square\";this.size=10;this.absoluteCornerSize=\n!0;this.indent=2;this.rectOutline=\"single\"}function Da(){mxConnector.call(this)}function La(c,l,x,p,v,A,B,ha,K,xa){B+=K;var na=p.clone();p.x-=v*(2*B+K);p.y-=A*(2*B+K);v*=B+K;A*=B+K;return function(){c.ellipse(na.x-v-B,na.y-A-B,2*B,2*B);xa?c.fillAndStroke():c.stroke()}}mxUtils.extend(b,mxShape);b.prototype.updateBoundsFromLine=function(){var c=null;if(null!=this.line)for(var l=0;l {\n const r = ModuleFindPath(request, paths.concat(eslintRulesPath), isMain);\n if (!r) {\n if (hacks.includes(request))\n return path.join(__dirname, '.eslint-plugins', request);\n }\n return r;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " settings: function (done) {\n const SettingUtil = require('../../../settings/settingsUtil')\n SettingUtil.getSettings(function (err, content) {\n if (err) return done(err)\n\n const settings = content.data.settings\n passwordComplexityEnabled = settings.accountsPasswordComplexity.value\n\n return done()\n })\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " pathParams: match.slice(1),\n req,\n res\n });\n }\n catch (e) {\n log.error(`Custom handler ${note.noteId} failed with ${e.message}`);\n\n res.status(500).send(e.message);\n }\n }\n else if (attr.name === 'customResourceProvider') {\n fileUploadService.downloadNoteFile(attr.noteId, res);\n }\n else {\n throw new Error(\"Unrecognized attribute name \" + attr.name);\n }\n\n return; // only first handler is executed\n }\n\n const message = `No handler matched for custom ${path} request.`;\n\n log.info(message);\n res.status(404).send(message);\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function(){try{var O=I.width,t=I.height;if(0==O&&0==t){var z=A.result,L=z.indexOf(\",\"),C=decodeURIComponent(escape(atob(z.substring(L+1)))),D=mxUtils.parseXml(C).getElementsByTagName(\"svg\");0 {\n const {headers: {location}} = Response.message (response);\n const original = Response.request (response);\n const oldUrl = Request.url (original);\n const newUrl = mergeUrls (oldUrl) (location);\n return (Request (Request.options (original))\n (newUrl)\n (Request.body (original)));\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": "\"240px\",this.div.style.left=Math.max(0,parseInt(this.div.style.left)-150)+\"px\");this.fit()};mxEvent.addListener(this.formatWindow.window.title,\"dblclick\",mxUtils.bind(this,function(B){mxEvent.getSource(B)==this.formatWindow.window.title&&this.formatWindow.window.toggleMinimized()}))}};var C=EditorUi.prototype.init;EditorUi.prototype.init=function(){function A(aa,ca,na){var la=F.menus.get(aa),oa=O.addMenu(mxResources.get(aa),mxUtils.bind(this,function(){la.funct.apply(this,arguments)}),W);oa.className=\n\"1\"==urlParams.sketch?\"geToolbarButton\":\"geMenuItem\";oa.style.display=\"inline-block\";oa.style.boxSizing=\"border-box\";oa.style.top=\"6px\";oa.style.marginRight=\"6px\";oa.style.height=\"30px\";oa.style.paddingTop=\"6px\";oa.style.paddingBottom=\"6px\";oa.style.cursor=\"pointer\";oa.setAttribute(\"title\",mxResources.get(aa));F.menus.menuCreated(la,oa,\"geMenuItem\");null!=na?(oa.style.backgroundImage=\"url(\"+na+\")\",oa.style.backgroundPosition=\"center center\",oa.style.backgroundRepeat=\"no-repeat\",oa.style.backgroundSize=\n\"24px 24px\",oa.style.width=\"34px\",oa.innerHTML=\"\"):ca||(oa.style.backgroundImage=\"url(\"+mxWindow.prototype.normalizeImage+\")\",oa.style.backgroundPosition=\"right 6px center\",oa.style.backgroundRepeat=\"no-repeat\",oa.style.paddingRight=\"22px\");return oa}function B(aa,ca,na,la,oa,ra){var ia=document.createElement(\"a\");ia.className=\"1\"==urlParams.sketch?\"geToolbarButton\":\"geMenuItem\";ia.style.display=\"inline-block\";ia.style.boxSizing=\"border-box\";ia.style.height=\"30px\";ia.style.padding=\"6px\";ia.style.position=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " exitSignal(chan, name, coreDumped, msg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n const nameLen = Buffer.byteLength(name);\n const msgLen = (msg ? Buffer.byteLength(msg) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-signal', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n packet[p += nameLen] = (coreDumped ? 1 : 0);\n\n writeUInt32BE(packet, msgLen, ++p);\n\n p += 4;\n if (msgLen) {\n packet.utf8Write(msg, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " config: Object.assign(Object.create(null), configObj),\n env: envObj || process.env,\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": "function convertTimezoneToLocal(date, timezone, reverse) {\n reverse = reverse ? -1 : 1;\n var dateTimezoneOffset = date.getTimezoneOffset();\n var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n return addDateMinutes(date, reverse * (timezoneOffset - dateTimezoneOffset));\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\taddValue:function(qName, value, offset) {\n\t\tif(!tagNamePattern.test(qName)){\n\t\t\tthrow new Error('invalid attribute:'+qName)\n\t\t}\n\t\tthis.attributeNames[qName] = this.length;\n\t\tthis[this.length++] = {qName:qName,value:value,offset:offset}\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-436", "cwe_name": "Interpretation Conflict", "description": "Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.", "url": "https://cwe.mitre.org/data/definitions/436.html", "label_name": "safe"} {"code": "\trender(markupLanguage, markup, theme, options) {\n\t\treturn this.renderer(markupLanguage).render(markup, theme, options);\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " getItemHtml: function (value) {\n value = value.toString();\n var valueSanitized = this.escapeValue(value);\n var translatedValue = this.escapeValue(this.translatedOptions[value] || value);\n\n var html = '' +\n '
    ' +\n '
    ' +\n '' +\n '
    ' +\n '
    ' +\n '' +\n '

    ' +\n '
    ';\n\n return html;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.$.appendChild(a.$);return a},appendHtml:function(a){if(this.$.childNodes.length){var b=new CKEDITOR.dom.element(\"div\",this.getDocument());b.setHtml(a);b.moveChildren(this)}else this.setHtml(a)},appendText:function(a){this.$.text!=void 0?this.$.text=this.$.text+a:this.append(new CKEDITOR.dom.text(a))},appendBogus:function(a){if(a||CKEDITOR.env.needsBrFiller||CKEDITOR.env.opera){for(a=this.getLast();a&&a.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.rtrim(a.getText());)a=a.getPrevious();if(!a||!a.is||", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "!a.equals(h))&&(a.type!=CKEDITOR.NODE_ELEMENT||!b||!a.equals(c.root))}}if(a&&!this._.guardRTL){var i=d.type==CKEDITOR.NODE_ELEMENT?d:d.getParent(),w=d.type==CKEDITOR.NODE_ELEMENT?n?d.getChild(n-1):null:d.getPrevious();this._.guardRTL=function(a,b){return(!b||!i.equals(a))&&(!w||!a.equals(w))&&(a.type!=CKEDITOR.NODE_ELEMENT||!b||!a.equals(c.root))}}var m=a?this._.guardRTL:this._.guardLTR;g=k?function(a,b){return m(a,b)===false?false:k(a,b)}:m;if(this.current)f=this.current[j](false,q,g);else{if(a)f.type==", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " $scope.add = function() {\n bootbox.prompt('Please enter the name for the new requisition', function(foreignSource) {\n if (foreignSource) {\n // Validate Requisition\n if (foreignSource.match(/[/\\\\?:&*'\"]/)) {\n bootbox.alert('Cannot add the requisition ' + _.escape(foreignSource) + ' because the following characters are invalid:
    :, /, \\\\, ?, &, *, \\', \"');\n return;\n }\n var r = $scope.requisitionsData.getRequisition(foreignSource);\n if (r) {\n bootbox.alert('Cannot add the requisition ' + _.escape(foreignSource) + ' because there is already a requisition with that name');\n return;\n }\n // Create Requisition\n RequisitionsService.addRequisition(foreignSource).then(\n function(r) { // success\n growl.success('The requisition ' + _.escape(r.foreignSource) + ' has been created.');\n },\n $scope.errorHandler\n );\n }\n });\n };", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.editor.embedExtFonts(mxUtils.bind(this,function(g){try{null!=g&&this.editor.addFontCss(c,g),e(c)}catch(k){e(c)}}))}catch(g){e(c)}}))};EditorUi.prototype.exportImage=function(c,e,g,k,m,q,v,x,A,z,L,M,n){A=null!=A?A:\"png\";if(this.spinner.spin(document.body,mxResources.get(\"exporting\"))){var y=this.editor.graph.isSelectionEmpty();g=null!=g?g:y;null==this.thumbImageCache&&(this.thumbImageCache={});try{this.editor.exportToCanvas(mxUtils.bind(this,function(K){this.spinner.stop();try{this.saveCanvas(K,\nm?this.getFileData(!0,null,null,null,g,x):null,A,null==this.pages||0==this.pages.length,L)}catch(B){this.handleError(B)}}),null,this.thumbImageCache,null,mxUtils.bind(this,function(K){this.spinner.stop();this.handleError(K)}),null,g,c||1,e,k,null,null,q,v,z,M,n)}catch(K){this.spinner.stop(),this.handleError(K)}}};EditorUi.prototype.isCorsEnabledForUrl=function(c){return this.editor.isCorsEnabledForUrl(c)};EditorUi.prototype.importXml=function(c,e,g,k,m,q,v){e=null!=e?e:0;g=null!=g?g:0;var x=[];try{var A=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "return this.collapsed||a.type!=CKEDITOR.NODE_ELEMENT?a:a.getChild(this.endOffset-1)||a},getNextEditableNode:b(),getPreviousEditableNode:b(1),scrollIntoView:function(){var a=new CKEDITOR.dom.element.createFromHtml(\" \",this.document),b,c,d,f=this.clone();f.optimize();if(d=f.startContainer.type==CKEDITOR.NODE_TEXT){c=f.startContainer.getText();b=f.startContainer.split(f.startOffset);a.insertAfter(f.startContainer)}else f.insertNode(a);a.scrollIntoView();if(d){f.startContainer.setText(c);\nb.remove()}a.remove()}}})();CKEDITOR.POSITION_AFTER_START=1;CKEDITOR.POSITION_BEFORE_END=2;CKEDITOR.POSITION_BEFORE_START=3;CKEDITOR.POSITION_AFTER_END=4;CKEDITOR.ENLARGE_ELEMENT=1;CKEDITOR.ENLARGE_BLOCK_CONTENTS=2;CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS=3;CKEDITOR.ENLARGE_INLINE=4;CKEDITOR.START=1;CKEDITOR.END=2;CKEDITOR.SHRINK_ELEMENT=1;CKEDITOR.SHRINK_TEXT=2;\"use strict\";", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\twp.updates.credentialError = function( response, action ) {\n\n\t\t// Restore callbacks.\n\t\tresponse = wp.updates._addCallbacks( response, action );\n\n\t\twp.updates.queue.push( {\n\t\t\taction: action,\n\n\t\t\t/*\n\t\t\t * Not cool that we're depending on response for this data.\n\t\t\t * This would feel more whole in a view all tied together.\n\t\t\t */\n\t\t\tdata: response\n\t\t} );\n\n\t\twp.updates.filesystemCredentials.available = false;\n\t\twp.updates.showErrorInCredentialsForm( response.errorMessage );\n\t\twp.updates.requestFilesystemCredentials();\n\t};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "(a.message.id||(a.message.id=f),h=a.message);a=window.JSON.stringify(h,b);g.postMessage(a,\"*\")}},hash:{create:function(){},parse:function(){}},cookie:{set:a,get:function(a){return(a=document.cookie.match(RegExp(\"(?:^|; )\"+a.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g,\"\\\\$1\")+\"=([^;]*)\")))?decodeURIComponent(a[1]):void 0},remove:function(c){a(c,\"\",{expires:-1})}}}}(),a=a||{};a.TextAreaNumber=null;a.load=!0;a.cmd={SpellTab:\"spell\",Thesaurus:\"thes\",GrammTab:\"grammar\"};a.dialog=null;a.optionNode=null;a.selectNode=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function(){return null!=q?q.readyState:3};this.getLastError=function(){return S};this.mouseListeners={startX:0,startY:0,scrollLeft:0,scrollTop:0,mouseDown:function(M,W){},mouseMove:function(M,W){var U,X=-1;return function(){clearTimeout(U);var u=this,E=arguments,J=function(){U=null;X=Date.now();M.apply(u,E)};Date.now()-X>W?J():U=setTimeout(J,W)}}(function(M,W){m(W)},200),mouseUp:function(M,W){m(W)}};l.addMouseListener(this.mouseListeners);this.shareCursorPositionListener=function(){b.isShareCursorPosition()||", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function usercheck_init_noacess(i) {\r\n var obj = document.getElementById('ajax_output');\r\n obj.innerHTML = '';\r\n\r\n if (i.value.length < 1)\r\n return;\r\n\r\n var err = new Array();\r\n if (i.value.match(/[^A-Za-z0-9_]/))\r\n err[err.length] = 'Username can only contain letters, numbers and underscores';\r\n if (i.value.length < 3)\r\n err[err.length] = 'Username Too Short';\r\n if (err != '') {\r\n obj.style.color = '#ff0000';\r\n obj.innerHTML = err.join('
    ');\r\n return;\r\n }\r\n\r\n var pqr = i.value;\r\n if (i.value.length >= 3)\r\n ajax_call('Validator.php?u=' + i.value + 'user', usercheck_callback_noacess, usercheck_error);\r\n}\r", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "ca.src=\"/images/icon-search.svg\"};b.sidebar.hideTooltip();b.sidebar.currentElt=da;Da=!0;ca.src=\"/images/aui-wait.gif\";ha.isExt?g(ha,pa,function(){A(mxResources.get(\"cantLoadPrev\"));Da=!1;ca.src=\"/images/icon-search.svg\"}):ia(ha.url,pa)}}function t(ha,da,ca){if(null!=E){for(var la=E.className.split(\" \"),ia=0;ia=na.getStatus()?la(na.getText(),pa):ia()})):la(b.emptyDiagramXml,pa)},la=function(pa,na){y||b.hideDialog(!0);e(pa,na,qa,da)},ia=function(){A(mxResources.get(\"cannotLoad\"));ma()},ma=function(){J=qa;za.className=\"geTempDlgCreateBtn\";da&&(Ga.className=\"geTempDlgOpenBtn\")},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "a.$.nextSibling);return a},insertBefore:function(a){a.$.parentNode.insertBefore(this.$,a.$);return a},insertBeforeMe:function(a){this.$.parentNode.insertBefore(a.$,this.$);return a},getAddress:function(a){for(var e=[],b=this.getDocument().$.documentElement,c=this.$;c&&c!=b;){var d=c.parentNode;d&&e.unshift(this.getIndex.call({$:c},a));c=d}return e},getDocument:function(){return new CKEDITOR.dom.document(this.$.ownerDocument||this.$.parentNode.ownerDocument)},getIndex:function(a){var e=this.$,b=-1,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "document.execCommand(\"selectAll\",!1,null),null!=b.pages&&1
    ',CKEDITOR.document);CKEDITOR.document.getBody().append(a);return function(c,b,f){a.setStyle(c,b);for(var c={},b=f.length,d=0;d 0) {\n\t\t\t\t\t$(this).draggable('option', { refreshPositions : true });\n\t\t\t\t\thelper.data('refreshPositions', -1);\n\t\t\t\t} else {\n\t\t\t\t\t$(this).draggable('option', { refreshPositions : false });\n\t\t\t\t\thelper.data('refreshPositions', null);\n\t\t\t\t}\n\t\t\t}\n\t\t},", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " get() {\n return this.handle === null;\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function(z){var L=null;null!=z&&0
    \");return b.join(\"\")})}},textarea:function(b,a,d){if(!(3>arguments.length)){i.call(this,a);var e=this,c=this._.inputId=CKEDITOR.tools.getNextId()+\"_textarea\",f={};a.validate&&(this.validate=a.validate);\nf.rows=a.rows||5;f.cols=a.cols||20;f[\"class\"]=\"cke_dialog_ui_input_textarea \"+(a[\"class\"]||\"\");\"undefined\"!=typeof a.inputStyle&&(f.style=a.inputStyle);a.dir&&(f.dir=a.dir);CKEDITOR.ui.dialog.labeledElement.call(this,b,a,d,function(){f[\"aria-labelledby\"]=this._.labelId;this._.required&&(f[\"aria-required\"]=this._.required);var a=['
    \");return a.join(\"\")})}},checkbox:function(b,a,d){if(!(3>arguments.length)){var e=i.call(this,a,{\"default\":!!a[\"default\"]});a.validate&&(this.validate=a.validate);CKEDITOR.ui.dialog.uiElement.call(this,b,a,d,\"span\",null,null,function(){var c=CKEDITOR.tools.extend({},a,{id:a.id?a.id+\"_checkbox\":CKEDITOR.tools.getNextId()+\"_checkbox\"},true),d=[],h=CKEDITOR.tools.getNextId()+\"_label\",g={\"class\":\"cke_dialog_ui_checkbox_input\",type:\"checkbox\",\"aria-labelledby\":h};p(c);if(a[\"default\"])g.checked=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "this.graph.getTooltip(c,d,e,f);this.show(k,e,f);this.state=c;this.node=d;this.stateSource=g}}),this.delay)}};mxTooltipHandler.prototype.hide=function(){this.resetTimer();this.hideTooltip()};mxTooltipHandler.prototype.hideTooltip=function(){null!=this.div&&(this.div.style.visibility=\"hidden\",this.div.innerHTML=\"\")};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "once:function(){var b=arguments[1];arguments[1]=function(d){d.removeListener();return b.apply(this,arguments)};return this.on.apply(this,arguments)},capture:function(){CKEDITOR.event.useCapture=1;var b=this.on.apply(this,arguments);CKEDITOR.event.useCapture=0;return b},fire:function(){var b=0,d=function(){b=1},a=0,h=function(){a=1};return function(m,j,i){var n=e(this)[m],m=b,r=a;b=a=0;if(n){var o=n.listeners;if(o.length)for(var o=o.slice(0),u,f=0;f {\n process.nextTick(() => {\n\n const result = [];\n\n const workload = [];\n if (containerArray.length && containerArray[0].trim() === '*') {\n containerArray = [];\n dockerContainers().then(allContainers => {\n for (let container of allContainers) {\n containerArray.push(container.id);\n }\n dockerContainerStats(containerArray.join(',')).then(result => {\n if (callback) { callback(result); }\n resolve(result);\n });\n });\n } else {\n for (let containerID of containerArray) {\n workload.push(dockerContainerStatsSingle(containerID.trim()));\n }\n if (workload.length) {\n Promise.all(\n workload\n ).then(data => {\n if (callback) { callback(data); }\n resolve(data);\n });\n } else {\n if (callback) { callback(result); }\n resolve(result);\n }\n }\n });\n });\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "\tasync testing() {\n\t\tconst markdownUtils = require('lib/markdownUtils');\n\t\tconst ClipperServer = require('lib/ClipperServer');\n\t\tconst server = new ClipperServer();\n\t\tconst HtmlToMd = require('lib/HtmlToMd');\n\t\tconst service = new HtmlToMd();\n\t\tconst html = await shim.fsDriver().readFile('/mnt/d/test.html');\n\t\tlet markdown = service.parse(html, { baseUrl: 'https://duckduckgo.com/' });\n\t\tconsole.info(markdown);\n\t\tconsole.info('--------------------------------------------------');\n\n\t\tconst imageUrls = markdownUtils.extractImageUrls(markdown);\n\t\tlet result = await server.downloadImages_(imageUrls);\n\t\tresult = await server.createResourcesFromPaths_(result);\n\t\tconsole.info(result);\n\t\tmarkdown = server.replaceImageUrlsByResources_(markdown, result);\n\t\tconsole.info('--------------------------------------------------');\n\t\tconsole.info(markdown);\n\t\tconsole.info('--------------------------------------------------');\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "N.message)}else null!=this.graph.extFonts&&0 0) {\r\n toolbarContent.appendChild(toolbarArrow);\r\n }\r\n }\r\n }\r", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\"/\";void 0==window.scayt?(CKEDITOR._djScaytConfig={baseUrl:b,addOnLoad:[function(){CKEDITOR.fireOnce(\"scaytReady\")}],isDebug:!1},CKEDITOR.document.getHead().append(CKEDITOR.document.createElement(\"script\",{attributes:{type:\"text/javascript\",async:\"true\",src:c}}))):CKEDITOR.fireOnce(\"scaytReady\");return null},parseUrl:function(a){var c;return a.match&&(c=a.match(/(.*)[\\/\\\\](.*?\\.\\w+)$/))?{path:c[1],file:c[2]}:a}};var d=CKEDITOR.plugins.scayt,p=function(a,c,b,d,e,f,h){a.addCommand(d,e);a.addMenuItem(d,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\t\t\tselectAll = function() {\n\t\t\t\tvar phash = fm.cwd().hash;\n\n\t\t\t\tselectCheckbox && selectAllCheckbox.find('input').prop('checked', true);\n\t\t\t\tfm.lazy(function() {\n\t\t\t\t\tcwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect);\n\t\t\t\t\tselectedFiles = (incHashes || cwdHashes).concat();\n\t\t\t\t\ttrigger();\n\t\t\t\t\tselectCheckbox && selectAllCheckbox.data('pending', false);\n\t\t\t\t\tcwd.addClass('elfinder-cwd-allselected');\n\t\t\t\t});\n\t\t\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tfatalError:function(error) {\n\t\tthrow new ParseError(error, this.locator);\n\t}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-436", "cwe_name": "Interpretation Conflict", "description": "Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.", "url": "https://cwe.mitre.org/data/definitions/436.html", "label_name": "safe"} {"code": "mxClient.IS_IOS?(M.style.padding=\"0px 10px 20px 10px\",M.style.top=\"6px\"):mxClient.IS_FF&&(n.style.paddingTop=\"0px\",n.style.marginTop=\"-2px\");if(null!=A)for(m=0;mf.length?\"preview\":\"openInNewWindow\"),function(){var v=5E5>f.length?k.value:f;if(null!=u)u(v);else if(g)try{var x=b.openLink(v);null!=x&&(null==l||0]+?>.*?<\\/[^>]+?>/g, '') //Closed Tags\n .replace(/<[^>]+?\\/\\s*>/g, '') //Self-Closing Tags\n .replace(/<[^>]+?>/g, ''); //Unclosed Tags\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": "function generateUID() {\n var bytes = randomBytes(UID_LENGTH);\n var result = '';\n for(var i=0; i\"==this.textarea.innerHTML?(this.textarea.innerHTML=this.getEmptyLabelText(),this.clearOnChange=0 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tlist.style.display = '';\n\t\t\t\t\t\tdiv.style.left = '160px';\n\t\t\t\t\t\tlist.innerHTML = '';\n\n\t\t\t\t\t\tcustomCatCount = 0;\n\t\t\t\t\t\tcategories = {'draw.io': docList};\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (var cat in searchImportCats)\n\t\t\t\t\t\t{\t\n\t\t\t\t\t\t\tcategories[cat] = searchImportCats[cat];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tinitUi();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\taddTemplates(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "document.createElement(\"tr\");ja.className=\"gePropHeader\";var Ba=document.createElement(\"th\");Ba.className=\"gePropHeaderCell\";var Ha=document.createElement(\"img\");Ha.src=Sidebar.prototype.expandedImage;Ha.style.verticalAlign=\"middle\";Ba.appendChild(Ha);mxUtils.write(Ba,mxResources.get(\"property\"));ja.style.cursor=\"pointer\";var ra=function(){var Aa=va.querySelectorAll(\".gePropNonHeaderRow\");if(Z.editorUi.propertiesCollapsed){Ha.src=Sidebar.prototype.collapsedImage;var ta=\"none\";for(var ka=u.childNodes.length-\n1;0<=ka;ka--)try{var oa=u.childNodes[ka],sa=oa.nodeName.toUpperCase();\"INPUT\"!=sa&&\"SELECT\"!=sa||u.removeChild(oa)}catch(ya){}}else Ha.src=Sidebar.prototype.expandedImage,ta=\"\";for(ka=0;ka 1) {\n this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));\n } else if (leaks.length) {\n this.fail(test, new Error('global leak detected: ' + leaks[0]));\n }\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\tisInWindow : function(elem, nochkHide) {\n\t\tif (! nochkHide && elem.is(':hidden')) {\n\t\t\treturn false;\n\t\t}\n\t\tvar rect = elem[0].getBoundingClientRect();\n\t\treturn document.elementFromPoint(rect.left, rect.top)? true : false;\n\t},", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "S&&S(M)}}))}catch(L){null!=S&&S(L)}}),N,sa)}catch(Pa){null!=S&&S(Pa)}};Editor.crcTable=[];for(var D=0;256>D;D++)for(var t=D,F=0;8>F;F++)t=1==(t&1)?3988292384^t>>>1:t>>>1,Editor.crcTable[D]=t;Editor.updateCRC=function(u,J,N,W){for(var S=0;S>>8;return u};Editor.crc32=function(u){for(var J=-1,N=0;N>>8^Editor.crcTable[(J^u.charCodeAt(N))&255];return(J^-1)>>>0};Editor.writeGraphModelToPng=function(u,J,N,W,S){function P(sa,Ba){var ta=\nva;va+=Ba;return sa.substring(ta,va)}function Z(sa){sa=P(sa,4);return sa.charCodeAt(3)+(sa.charCodeAt(2)<<8)+(sa.charCodeAt(1)<<16)+(sa.charCodeAt(0)<<24)}function oa(sa){return String.fromCharCode(sa>>24&255,sa>>16&255,sa>>8&255,sa&255)}u=u.substring(u.indexOf(\",\")+1);u=window.atob?atob(u):Base64.decode(u,!0);var va=0;if(P(u,8)!=String.fromCharCode(137)+\"PNG\"+String.fromCharCode(13,10,26,10))null!=S&&S();else if(P(u,4),\"IHDR\"!=P(u,4))null!=S&&S();else{P(u,17);S=u.substring(0,va);do{var Aa=Z(u);if(\"IDAT\"==", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "b instanceof String||b instanceof Number||b instanceof Boolean||b instanceof Date||b instanceof RegExp)return b;a=new b.constructor;for(d in b)a[d]=CKEDITOR.tools.clone(b[d]);return a},capitalize:function(b,a){return b.charAt(0).toUpperCase()+(a?b.slice(1):b.slice(1).toLowerCase())},extend:function(b){var a=arguments.length,d,g;if(typeof(d=arguments[a-1])==\"boolean\")a--;else if(typeof(d=arguments[a-2])==\"boolean\"){g=arguments[a-1];a=a-2}for(var e=1;ee};EditorUi.prototype.resizeImage=function(c,e,g,k,m,q,v){m=null!=m?m:this.maxImageSize;var x=Math.max(1,c.width),A=Math.max(1,c.height);if(k&&this.isResampleImageSize(null!=v?v:e.length,q))try{var z=Math.max(x/m,A/m);if(1A
    ').css({\n position: 'absolute',\n left: -1000,\n top: -1000,\n display: 'block',\n padding: 0,\n margin: 0,\n 'font-family': 'monospace'\n }).appendTo($('body'));\n\n var charWidth = div.width();\n var charHeight = div.height();\n\n div.remove();\n\n // compensate for internal horizontal padding\n var cssWidth = width * charWidth + 20;\n // Add an extra line for the status bar and divider\n var cssHeight = (height * charHeight) + charHeight + 2;\n\n log.debug(\"desired console size in characters, width: \", width, \" height: \", height);\n log.debug(\"console size in pixels, width: \", cssWidth, \" height: \", cssHeight);\n log.debug(\"character size in pixels, width: \", charWidth, \" height: \", charHeight);\n\n element.css({\n width: cssWidth,\n height: cssHeight,\n 'min-width': cssWidth,\n 'min-height': cssHeight\n });\n\n var authHeader = Core.getBasicAuthHeader(userDetails.username, userDetails.password);\n\n gogo.Terminal(element.get(0), width, height, authHeader);\n\n scope.$on(\"$destroy\", function(e) {\n document.onkeypress = null;\n document.onkeydown = null;\n });\n\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "0;ethis.state.width?10:0)+2+\"px\",this.moveHandle.style.top=this.state.y+this.state.height+(40>this.state.height?10:0)+2+\"px\")};var J=mxVertexHandler.prototype.setHandlesVisible;mxVertexHandler.prototype.setHandlesVisible=function(H){J.apply(this,", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "document.documentElement.clientWidth||document.body.clientWidth;1E3<=X&&null!=this.sidebarWindow&&\"1\"!=urlParams.sketch&&this.sidebarWindow.window.setVisible(!0);null!=this.formatWindow&&(1E3<=X||\"1\"==urlParams.sketch)&&this.formatWindow.window.setVisible(!0)}else null!=this.sidebarWindow&&this.sidebarWindow.window.setVisible(!1),null!=this.formatWindow&&this.formatWindow.window.setVisible(!1)};EditorUi.prototype.chromelessWindowResize=function(){};var da=DiagramFormatPanel.prototype.addView;DiagramFormatPanel.prototype.addView=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "ImageProto.stream = function(type, writer) {\n\n\tvar self = this;\n\n\t!self.builder.length && self.minify();\n\n\tif (!type || !SUPPORTEDIMAGES[type])\n\t\ttype = self.outputType;\n\n\tF.stats.performance.open++;\n\tvar cmd = spawn(CMD_CONVERT[self.cmdarg], self.arg(self.filename ? wrap(self.filename) : '-', (type ? type + ':' : '') + '-'), SPAWN_OPT);\n\tif (self.currentStream) {\n\t\tif (self.currentStream instanceof Buffer)\n\t\t\tcmd.stdin.end(self.currentStream);\n\t\telse\n\t\t\tself.currentStream.pipe(cmd.stdin);\n\t}\n\n\twriter && writer(cmd.stdin);\n\tvar middleware = middlewares[type];\n\treturn middleware ? cmd.stdout.pipe(middleware()) : cmd.stdout;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function onFinish() {\n this.eof();\n if (this.server || !this.allowHalfOpen)\n this.close();\n this.writable = false;\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function(I){mxEvent.isConsumed(I)||((mxEvent.isControlDown(I)||mxClient.IS_MAC&&mxEvent.isMetaDown(I))&&13==I.keyCode?(D.click(),mxEvent.consume(I)):27==I.keyCode&&(n.click(),mxEvent.consume(I)))}));D.focus();D.className=\"geCommentEditBtn gePrimaryBtn\";Y.appendChild(D);F.insertBefore(Y,O);V.style.display=\"none\";O.style.display=\"none\";U.focus()}function e(H,F){F.innerHTML=\"\";H=new Date(H.modifiedDate);var J=b.timeSince(H);null==J&&(J=mxResources.get(\"lessThanAMinute\"));mxUtils.write(F,mxResources.get(\"timeAgo\",\n[J],\"{1} ago\"));F.setAttribute(\"title\",H.toLocaleDateString()+\" \"+H.toLocaleTimeString())}function g(H){var F=document.createElement(\"img\");F.className=\"geCommentBusyImg\";F.src=IMAGE_PATH+\"/spin.gif\";H.appendChild(F);H.busyImg=F}function k(H){H.style.border=\"1px solid red\";H.removeChild(H.busyImg)}function m(H){H.style.border=\"\";H.removeChild(H.busyImg)}function p(H,F,J,R,W){function O(Q,P,T){var X=document.createElement(\"li\");X.className=\"geCommentAction\";var ba=document.createElement(\"a\");ba.className=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " remove(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (this._channels[id]) {\n delete this._channels[id];\n if (this._count)\n --this._count;\n }\n }", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " text: Ext.util.Format.htmlEncode(record.get('name')),\n qtip: Ext.util.Format.htmlEncode(record.get('host')),\n leaf: false,\n cls: 'felamimail-node-account',\n delimiter: record.get('delimiter'),\n ns_personal: record.get('ns_personal'),\n account_id: record.data.id,\n listeners: {\n scope: this,\n load: function(node) {\n var account = this.accountStore.getById(node.id);\n this.updateAccountStatus(account);\n }\n }\n });", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " function next(suite) {\n self.suite = suite;\n\n if (!suite) {\n self.suite = orig;\n return fn();\n }\n\n self.hook(name, function(err){\n if (err) {\n var errSuite = self.suite;\n self.suite = orig;\n return fn(err, errSuite);\n }\n\n next(suites.pop());\n });\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "a in j&&(this.write(\"]\"),this.getRule(a,\"breakAfterOpen\")&&this.lineBreak(1))},attribute:function(a,b){\"option\"==a&&(\"string\"==typeof b&&(b=b.replace(/&/g,\"&\")),this.write(\"=\",b))},closeTag:function(a){a in j&&(this.getRule(a,\"breakBeforeClose\")&&this.lineBreak(1),\"*\"!=a&&this.write(\"[/\",a,\"]\"),this.getRule(a,\"breakAfterClose\")&&this.lineBreak(1))},text:function(a){this.write(a)},comment:function(){},lineBreak:function(){!this._.hasLineBreak&&this._.output.length&&(this.write(\"\\n\"),this._.hasLineBreak=", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "E=J}return E};Graph.prototype.getCellsById=function(u){var E=[];if(null!=u)for(var J=0;J '+mxUtils.htmlEntities(mxResources.get(\"loading\"))+\"...
    \";y=b.canReplyToReplies();b.commentsSupported()?b.getComments(function(H){function R(W){if(null!=W){W.sort(function(V,U){return new Date(V.modifiedDate)-\nnew Date(U.modifiedDate)});for(var J=0;JW?K():U=setTimeout(K,W)}}(function(M,W){m(W)},200),mouseUp:function(M,W){m(W)}};l.addMouseListener(this.mouseListeners);this.shareCursorPositionListener=function(){b.isShareCursorPosition()||\nc(\"cursor\",{hide:!0})};b.addListener(\"shareCursorPositionChanged\",this.shareCursorPositionListener);this.selectionChangeListener=function(M,W){M=function(u){return null!=u?u.id:null};var U=null!=b.currentPage?b.currentPage.getId():null,X=W.getProperty(\"added\");W=W.getProperty(\"removed\");c(\"selectionChange\",{pageId:U,removed:X?X.map(M):[],added:W?W.map(M):[]})};l.getSelectionModel().addListener(mxEvent.CHANGE,this.selectionChangeListener);this.cursorHandler=mxUtils.bind(this,function(){for(var M in y)n(y[M])});", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function assignableAST(ast) {\n if (ast.body.length === 1 && isAssignable(ast.body[0].expression)) {\n return {type: AST.AssignmentExpression, left: ast.body[0].expression, right: {type: AST.NGValueParameter}, operator: '='};\n }\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tthis.init = function() {\n\t\tvar o = this.options, \n\t\t\twin = this.window,\n\t\t\tpreview = this.preview,\n\t\t\ti, p;\n\t\t\n\t\twidth = o.width > 0 ? parseInt(o.width) : 450;\t\n\t\theight = o.height > 0 ? parseInt(o.height) : 300;\n\n\t\tfm.one('load', function() {\n\t\t\tparent = fm.getUI();\n\t\t\tcwd = fm.getUI('cwd');\n\n\t\t\twin.appendTo('body');\n\t\t\t\n\t\t\t// close window on escape\n\t\t\t$(document).keydown(function(e) {\n\t\t\t\te.keyCode == 27 && self.opened() && win.trigger('close')\n\t\t\t})\n\t\t\t\n\t\t\tif ($.fn.resizable && !fm.UA.Touch) {\n\t\t\t\twin.resizable({ \n\t\t\t\t\thandles : 'se', \n\t\t\t\t\tminWidth : 350, \n\t\t\t\t\tminHeight : 120, \n\t\t\t\t\tresize : function() { \n\t\t\t\t\t\t// use another event to avoid recursion in fullscreen mode\n\t\t\t\t\t\t// may be there is clever solution, but i cant find it :(\n\t\t\t\t\t\tpreview.trigger('changesize'); \n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\t\n\t\t\tself.change(function() {\n\t\t\t\tif (self.opened()) {\n\t\t\t\t\tself.value ? preview.trigger($.Event('update', {file : self.value})) : win.trigger('close');\n\t\t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\t$.each(fm.commands.quicklook.plugins || [], function(i, plugin) {\n\t\t\t\tif (typeof(plugin) == 'function') {\n\t\t\t\t\tnew plugin(self)\n\t\t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\tpreview.bind('update', function() {\n\t\t\t\tself.info.show();\n\t\t\t});\n\t\t});\n\t\t\n\t}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "function Md(a,b,c,d){var e=a+\" \";switch(c){case\"s\":return b||d?\"nekaj sekund\":\"nekaj sekundami\";case\"m\":return b?\"ena minuta\":\"eno minuto\";case\"mm\":return e+=1===a?b?\"minuta\":\"minuto\":2===a?b||d?\"minuti\":\"minutama\":5>a?b||d?\"minute\":\"minutami\":b||d?\"minut\":\"minutami\";case\"h\":return b?\"ena ura\":\"eno uro\";case\"hh\":return e+=1===a?b?\"ura\":\"uro\":2===a?b||d?\"uri\":\"urama\":5>a?b||d?\"ure\":\"urami\":b||d?\"ur\":\"urami\";case\"d\":return b||d?\"en dan\":\"enim dnem\";case\"dd\":return e+=1===a?b||d?\"dan\":\"dnem\":2===a?b||d?\"dni\":\"dnevoma\":b||d?\"dni\":\"dnevi\";case\"M\":return b||d?\"en mesec\":\"enim mesecem\";case\"MM\":return e+=1===a?b||d?\"mesec\":\"mesecem\":2===a?b||d?\"meseca\":\"mesecema\":5>a?b||d?\"mesece\":\"meseci\":b||d?\"mesecev\":\"meseci\";case\"y\":return b||d?\"eno leto\":\"enim letom\";case\"yy\":return e+=1===a?b||d?\"leto\":\"letom\":2===a?b||d?\"leti\":\"letoma\":5>a?b||d?\"leta\":\"leti\":b||d?\"let\":\"leti\"}}function Nd(a){var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"leS\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"waQ\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"nem\":b+\" pIq\"}function Od(a){var b=a;return b=-1!==a.indexOf(\"jaj\")?b.slice(0,-3)+\"Hu\u2019\":-1!==a.indexOf(\"jar\")?b.slice(0,-3)+\"wen\":-1!==a.indexOf(\"DIS\")?b.slice(0,-3)+\"ben\":b+\" ret\"}function Pd(a,b,c,d){var e=Qd(a);switch(c){case\"mm\":return e+\" tup\";case\"hh\":return e+\" rep\";case\"dd\":return e+\" jaj\";case\"MM\":return e+\" jar\";case\"yy\":return e+\" DIS\"}}function Qd(a){var b=Math.floor(a%1e3/100),c=Math.floor(a%100/10),d=a%10,e=\"\";return b>0&&(e+=Sg[b]+\"vatlh\"),c>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[c]+\"maH\"),d>0&&(e+=(\"\"!==e?\" \":\"\")+Sg[d]),\"\"===e?\"pagh\":e}function Rd(a,b,c,d){var e={s:[\"viensas secunds\",\"'iensas secunds\"],m:[\"'n m\u00edut\",\"'iens m\u00edut\"],mm:[a+\" m\u00eduts\",\"\"+a+\" m\u00eduts\"],h:[\"'n \u00feora\",\"'iensa \u00feora\"],hh:[a+\" \u00feoras\",\"\"+a+\" \u00feoras\"],d:[\"'n ziua\",\"'iensa ziua\"],dd:[a+\" ziuas\",\"\"+a+\" ziuas\"],M:[\"'n mes\",\"'iens mes\"],MM:[a+\" mesen\",\"\"+a+\" mesen\"],y:[\"'n ar\",\"'iens ar\"],yy:[a+\" ars\",\"\"+a+\" ars\"]};return d?e[c][0]:b?e[c][0]:e[c][1]}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "WriteStream.prototype._write = function(data, encoding, cb) {\n if (!Buffer.isBuffer(data)) {\n const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);\n return this.emit('error', err);\n }\n\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._write(data, encoding, cb);\n });\n }\n\n this.sftp.write(this.handle,\n data,\n 0,\n data.length,\n this.pos,\n (er, bytes) => {\n if (er) {\n if (this.autoClose)\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n cb();\n });\n\n this.pos += data.length;\n};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function noop() {}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function(J){l=J};this.setAutoScroll=function(J){p=J};this.setOpenFill=function(J){q=J};this.setStopClickEnabled=function(J){A=J};this.setSelectInserted=function(J){B=J};this.setSmoothing=function(J){f=J};this.setPerfectFreehandMode=function(J){O=J};this.setBrushSize=function(J){I.size=J};this.getBrushSize=function(){return I.size};var t=function(J){y=J;b.getRubberband().setEnabled(!J);b.graphHandler.setSelectEnabled(!J);b.graphHandler.setMoveEnabled(!J);b.container.style.cursor=J?\"crosshair\":\"\";b.fireEvent(new mxEventObject(\"freehandStateChanged\"))};", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " getItemName: function($row) {\n return $row.attr(this.settings.nameAttribute);\n },", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function setPopoverHtmlContent($enteredElement, content) {\n content =\n content ||\n $enteredElement.attr(\"data-html-popover\") ||\n $enteredElement.attr(\"data-html-tooltip\");\n\n replaceHtmlContent($enteredElement, content);\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function colorLines(name, str) {\n return str.split('\\n').map(function(str){\n return color(name, str);\n }).join('\\n');\n}", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " \"value\": function(c) { assert.equal(c.value, 'bar') },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "this.startDrawing=function(){t(!0)};this.isDrawing=function(){return y};var z=mxUtils.bind(this,function(J){if(c){var F=d.length,H=A&&0d.length;H||v.push.apply(v,d);d=[];v.push(null);m.push(c);c=null;(H||l)&&this.stopDrawing();l&&2<=F&&this.startDrawing();mxEvent.consume(J)}}),L=new mxCell;L.edge=!0;var C=function(){var J=b.getCurrentCellStyle(L);J=mxUtils.getValue(b.currentVertexStyle,mxConstants.STYLE_STROKECOLOR,mxUtils.getValue(J,mxConstants.STYLE_STROKECOLOR,\"#000\"));\"default\"==", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "H&&!V)if(\"sharepoint\"==S)z(\"site\",null,H.id,H.displayName);else if(\"site\"==S)z(\"subsite\",null,H.id,H.name);else{var N=H.folder;H=H.remoteItem?H.remoteItem:H;var Q=(H.parentReference?H.parentReference.driveId:null)||S,R=H.id;N?z(Q,R,null,H.name):B()}}function z(N,Q,R,Y,ba){function ea(qa){P.stop();var Ca=document.createElement(\"table\");Ca.className=\"odFileListGrid\";for(var Aa=null,Ha=0,Na=0;null!=qa&&NaGa.webUrl.indexOf(\"sharepoint.com/\")){var Fa=Ga.displayName||Ga.name,Ea=mxUtils.htmlEntities(Ga.description||Fa);fa&&(Ga.folder=2==fa?{isRoot:!0}:!0);var La=null!=Ga.folder;if(!g||La){var za=document.createElement(\"tr\");za.className=Ha++%2?\"odOddRow\":\"odEvenRow\";var ta=document.createElement(\"td\");ta.style.width=\"36px\";var ka=document.createElement(\"img\");ka.src=\"/images/\"+(La?\"folder.png\":\"file.png\");ka.className=\"odFileImg\";ta.appendChild(ka);za.appendChild(ta);ta=document.createElement(\"td\");\nLa=document.createElement(\"div\");La.className=\"odFileTitle\";La.innerHTML=mxUtils.htmlEntities(Fa);La.setAttribute(\"title\",Ea);ta.appendChild(La);za.appendChild(ta);Ca.appendChild(za);null==Aa&&(Aa=za,Aa.className+=\" odRowSelected\",H=Ga,S=N,x||e(H));(function(oa,sa){za.addEventListener(\"dblclick\",t);za.addEventListener(\"click\",function(){Aa!=sa&&(Aa.className=Aa.className.replace(\"odRowSelected\",\"\"),Aa=sa,Aa.className+=\" odRowSelected\",H=oa,S=N,x||e(H))})})(Ga,za)}}}0==Ha?(qa=document.createElement(\"div\"),\nqa.className=\"odEmptyFolder\",qa.innerHTML=mxUtils.htmlEntities(mxResources.get(\"folderEmpty\",null,\"Folder is empty!\")),va.appendChild(qa)):va.appendChild(Ca);O();V=!1}if(!V){y(\".odCatsList\").style.display=\"block\";y(\".odFilesSec\").style.display=\"block\";null!=D&&(D.innerHTML=\"\",D.style.top=\"50%\");var Z=V=!0,fa=0;W=arguments;var aa=setTimeout(function(){V=Z=!1;P.stop();d(mxResources.get(\"timeout\"))},2E4),va=y(\".odFilesList\");va.innerHTML=\"\";P.spin(va);switch(N){case \"recent\":M=[{name:mxResources.get(\"recent\",", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " var doSynchronize = function(requisition, rescanExisting) {\n RequisitionsService.startTiming();\n RequisitionsService.synchronizeRequisition(requisition.foreignSource, rescanExisting).then(\n function() { // success\n growl.success('The import operation has been started for ' + requisition.foreignSource + ' (rescanExisting? ' + rescanExisting + ')
    Use refresh to update the deployed statistics');\n requisition.setDeployed(true);\n },\n errorHandler\n );\n };", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " qtip: Ext.util.Format.htmlEncode(attr.name.name)\n });\n }\n\n // copy 'real' data to a node record NOTE: not a full record as we have no record reader here\n var nodeData = Ext.copyTo({}, attr, Tine.Filemanager.Model.Node.getFieldNames());\n attr.nodeRecord = new Tine.Filemanager.Model.Node(nodeData);\n },", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "null);B.apply(this,arguments)};var I=EditorUi.prototype.setGraphEnabled;EditorUi.prototype.setGraphEnabled=function(C){I.apply(this,arguments);if(C){var E=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;1E3<=E&&null!=this.sidebarWindow&&\"1\"!=urlParams.sketch&&this.sidebarWindow.window.setVisible(!0);null!=this.formatWindow&&(1E3<=E||\"1\"==urlParams.sketch)&&this.formatWindow.window.setVisible(!0)}else null!=this.sidebarWindow&&this.sidebarWindow.window.setVisible(!1),\nnull!=this.formatWindow&&this.formatWindow.window.setVisible(!1)};EditorUi.prototype.chromelessWindowResize=function(){};var O=DiagramFormatPanel.prototype.addView;DiagramFormatPanel.prototype.addView=function(C){C=O.apply(this,arguments);var E=this.editorUi,G=E.editor.graph;if(G.isEnabled()&&\"1\"==urlParams.sketch){var P=this.createOption(mxResources.get(\"sketch\"),function(){return Editor.sketchMode},function(J,F){E.setSketchMode(!Editor.sketchMode);null!=F&&mxEvent.isShiftDown(F)||G.updateCellStyles({sketch:J?", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "(function(){var b=new mxObjectCodec(new ChangeGridColor,[\"ui\"]);b.beforeDecode=function(e,f,c){c.ui=e.ui;return f};mxCodecRegistry.register(b)})();(function(){EditorUi.VERSION=\"18.0.6\";EditorUi.compactUi=\"atlas\"!=uiTheme;Editor.isDarkMode()&&(mxGraphView.prototype.gridColor=mxGraphView.prototype.defaultDarkGridColor);EditorUi.enableLogging=\"1\"!=urlParams.stealth&&\"1\"!=urlParams.lockdown&&(/.*\\.draw\\.io$/.test(window.location.hostname)||/.*\\.diagrams\\.net$/.test(window.location.hostname))&&\"support.draw.io\"!=window.location.hostname;EditorUi.drawHost=window.DRAWIO_BASE_URL;EditorUi.lightboxHost=window.DRAWIO_LIGHTBOX_URL;EditorUi.lastErrorMessage=", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": "ka.size,ua,sa)):\"readOnly\"==wa?(sa=document.createElement(\"input\"),sa.setAttribute(\"readonly\",\"\"),sa.value=ta,sa.style.width=\"96px\",sa.style.borderWidth=\"0px\",xa.appendChild(sa)):(xa.innerHTML=mxUtils.htmlEntities(decodeURIComponent(ta)),mxEvent.addListener(xa,\"click\",mxUtils.bind(Z,function(){function da(){var la=ca.value;la=0==la.length&&\"string\"!=wa?0:la;ka.allowAuto&&(null!=la.trim&&\"auto\"==la.trim().toLowerCase()?(la=\"auto\",wa=\"string\"):(la=parseFloat(la),la=isNaN(la)?0:la));null!=ka.min&&la<\nka.min?la=ka.min:null!=ka.max&&la>ka.max&&(la=ka.max);la=encodeURIComponent((\"int\"==wa?parseInt(la):la)+\"\");T(Aa,la,ka)}var ca=document.createElement(\"input\");N(xa,ca,!0);ca.value=decodeURIComponent(ta);ca.className=\"gePropEditor\";\"int\"!=wa&&\"float\"!=wa||ka.allowAuto||(ca.type=\"number\",ca.step=\"int\"==wa?\"1\":\"any\",null!=ka.min&&(ca.min=parseFloat(ka.min)),null!=ka.max&&(ca.max=parseFloat(ka.max)));u.appendChild(ca);mxEvent.addListener(ca,\"keypress\",function(la){13==la.keyCode&&da()});ca.focus();mxEvent.addListener(ca,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "return P.apply(this,arguments)};mxGraphView.prototype.createEnumerationValue=function(u){u=decodeURIComponent(mxUtils.getValue(u.style,\"enumerateValue\",\"\"));\"\"==u&&(u=++this.enumerationState);return'
    '+mxUtils.htmlEntities(u)+\"
    \"};mxGraphView.prototype.redrawEnumerationState=function(u){var E=\"1\"==mxUtils.getValue(u.style,\"enumerate\",0);E&&null==u.secondLabel?(u.secondLabel=new mxText(\"\",new mxRectangle,mxConstants.ALIGN_LEFT,", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " fetch: function () {\n var data = Dep.prototype.fetch.call(this);\n data.translatedOptions = {};\n (data[this.name] || []).forEach(function (value) {\n data.translatedOptions[value] = this.$el.find('input[data-name=\"translatedValue\"][data-value=\"'+value+'\"]').val() || value;\n }, this);\n\n return data;\n }", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "mxTooltipHandler.prototype.reset=function(a,b,c){if(!this.ignoreTouchEvents||mxEvent.isMouseEvent(a.getEvent()))if(this.resetTimer(),c=null!=c?c:this.getStateForEvent(a),b&&this.isEnabled()&&null!=c&&(null==this.div||\"hidden\"==this.div.style.visibility)){var d=a.getSource(),e=a.getX(),f=a.getY(),g=a.isSource(c.shape)||a.isSource(c.text);this.thread=window.setTimeout(mxUtils.bind(this,function(){if(!this.graph.isEditing()&&!this.graph.popupMenuHandler.isMenuShowing()&&!this.graph.isMouseDown){var k=\nthis.graph.getTooltip(c,d,e,f);this.show(k,e,f);this.state=c;this.node=d;this.stateSource=g}}),this.delay)}};mxTooltipHandler.prototype.hide=function(){this.resetTimer();this.hideTooltip()};mxTooltipHandler.prototype.hideTooltip=function(){null!=this.div&&(this.div.style.visibility=\"hidden\",this.div.innerHTML=\"\")};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "e.$.scrollLeft;c=c-e.$.scrollTop;e=e.getParent()}e=j;j=(n=j.$.offsetParent)?new CKEDITOR.dom.element(n):null}}if(a){j=this.getWindow();e=a.getWindow();if(!j.equals(e)&&j.$.frameElement){a=(new CKEDITOR.dom.element(j.$.frameElement)).getDocumentPosition(a);b=b+a.x;c=c+a.y}}if(!document.documentElement.getBoundingClientRect&&CKEDITOR.env.gecko&&!i){b=b+(this.$.clientLeft?1:0);c=c+(this.$.clientTop?1:0)}return{x:b,y:c}},scrollIntoView:function(a){var b=this.getParent();if(b){do{(b.$.clientWidth&&b.$.clientWidth<\nb.$.scrollWidth||b.$.clientHeight&&b.$.clientHeight 0) {\n item = ajax_queue.shift();\n ajax_wrapper(item);\n }\n });\n }\n }\n else {\n error_original(xhr, status, error);\n }\n }\n // Do not run complete function if login dialog is open.\n // Once user is logged in again, the original complete function will be run\n // in repeated ajax call run by login dialog on success.\n options_new.complete = function(xhr, status) {\n if (xhr.status == 401) {\n return;\n }\n else {\n complete_original(xhr, status);\n }\n }\n\n // run ajax request or put it into a queue\n if (login_dialog_opened) {\n ajax_queue.push(options);\n }\n else {\n $.ajax(options_new);\n }\n}", "label": 1, "programming_language": "JavaScript", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "safe"} {"code": "module.exports.tile = function (inPath, outPath, pattern, options) {\n options = options || {};\n var tileSize = options.tileSize || 256;\n var tmpDir = options.tmpDir || process.env.TMPDIR || '/tmp';\n var tempDir = tmpDir + '/image-tiler_' + process.pid;\n var zoom = 0;\n var zoomToDisplay = 0;\n var quality = options.quality || 100;\n if (!options.invertZoom) {\n var size = sizeOf(inPath);\n var halvingsWidth = Math.ceil(Math.log2(Math.ceil(size.width / tileSize)));\n var halvingsheight = Math.ceil(Math.log2(Math.ceil(size.height / tileSize)));\n zoomToDisplay = Math.max(halvingsWidth, halvingsheight);\n }\n return mkdirp(tempDir)\n .then(()=>tileRec(inPath, outPath, zoom, tileSize, tempDir, pattern, zoomToDisplay, options.invertZoom, quality))\n .then(()=>rimraf(tempDir));\n};", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "Ua)}La=0};za.positionChanged=function(){};za.reset=function(){La=0};z.push(za)})(ca)}}return null!=z?z.reverse():null};var R=mxVertexHandler.prototype.setHandlesVisible;mxVertexHandler.prototype.setHandlesVisible=function(z){R.apply(this,arguments);if(null!=this.moveHandles)for(var L=0;L Bob: Authentication Request\\nBob --\\x3e Alice: Authentication Response\\n\\nAlice -> Bob: Another authentication Request\\nAlice <-- Bob: Another authentication Response\\n@enduml\"==", "label": 0, "programming_language": "JavaScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int masq_inet_event(struct notifier_block *this,\n\t\t\t unsigned long event,\n\t\t\t void *ptr)\n{\n\tstruct in_device *idev = ((struct in_ifaddr *)ptr)->ifa_dev;\n\tstruct netdev_notifier_info info;\n\n\t/* The masq_dev_notifier will catch the case of the device going\n\t * down. So if the inetdev is dead and being destroyed we have\n\t * no work to do. Otherwise this is an individual address removal\n\t * and we have to perform the flush.\n\t */\n\tif (idev->dead)\n\t\treturn NOTIFY_DONE;\n\n\tnetdev_notifier_info_init(&info, idev->dev);\n\treturn masq_device_event(this, event, &info);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static int read_private_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tconst sc_acl_entry_t *e;\n\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I0012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\te = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\tif (e == NULL || e->method == SC_AC_NEVER)\n\t\treturn 10;\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_private_key(p, keysize, rsa);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int n_tty_ioctl(struct tty_struct *tty, struct file *file,\n\t\t unsigned int cmd, unsigned long arg)\n{\n\tstruct n_tty_data *ldata = tty->disc_data;\n\tint retval;\n\n\tswitch (cmd) {\n\tcase TIOCOUTQ:\n\t\treturn put_user(tty_chars_in_buffer(tty), (int __user *) arg);\n\tcase TIOCINQ:\n\t\tdown_write(&tty->termios_rwsem);\n\t\tif (L_ICANON(tty) && !L_EXTPROC(tty))\n\t\t\tretval = inq_canon(ldata);\n\t\telse\n\t\t\tretval = read_cnt(ldata);\n\t\tup_write(&tty->termios_rwsem);\n\t\treturn put_user(retval, (unsigned int __user *) arg);\n\tdefault:\n\t\treturn n_tty_ioctl_helper(tty, file, cmd, arg);\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-704", "cwe_name": "Incorrect Type Conversion or Cast", "description": "The software does not correctly convert an object, resource, or structure from one type to a different type.", "url": "https://cwe.mitre.org/data/definitions/704.html", "label_name": "safe"} {"code": "static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t ignored, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_ctx *ctx = ask->private;\n\tunsigned bs = crypto_ablkcipher_blocksize(crypto_ablkcipher_reqtfm(\n\t\t&ctx->req));\n\tstruct skcipher_sg_list *sgl;\n\tstruct scatterlist *sg;\n\tunsigned long iovlen;\n\tstruct iovec *iov;\n\tint err = -EAGAIN;\n\tint used;\n\tlong copied = 0;\n\n\tlock_sock(sk);\n\tmsg->msg_namelen = 0;\n\tfor (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0;\n\t iovlen--, iov++) {\n\t\tunsigned long seglen = iov->iov_len;\n\t\tchar __user *from = iov->iov_base;\n\n\t\twhile (seglen) {\n\t\t\tsgl = list_first_entry(&ctx->tsgl,\n\t\t\t\t\t struct skcipher_sg_list, list);\n\t\t\tsg = sgl->sg;\n\n\t\t\twhile (!sg->length)\n\t\t\t\tsg++;\n\n\t\t\tused = ctx->used;\n\t\t\tif (!used) {\n\t\t\t\terr = skcipher_wait_for_data(sk, flags);\n\t\t\t\tif (err)\n\t\t\t\t\tgoto unlock;\n\t\t\t}\n\n\t\t\tused = min_t(unsigned long, used, seglen);\n\n\t\t\tused = af_alg_make_sg(&ctx->rsgl, from, used, 1);\n\t\t\terr = used;\n\t\t\tif (err < 0)\n\t\t\t\tgoto unlock;\n\n\t\t\tif (ctx->more || used < ctx->used)\n\t\t\t\tused -= used % bs;\n\n\t\t\terr = -EINVAL;\n\t\t\tif (!used)\n\t\t\t\tgoto free;\n\n\t\t\tablkcipher_request_set_crypt(&ctx->req, sg,\n\t\t\t\t\t\t ctx->rsgl.sg, used,\n\t\t\t\t\t\t ctx->iv);\n\n\t\t\terr = af_alg_wait_for_completion(\n\t\t\t\tctx->enc ?\n\t\t\t\t\tcrypto_ablkcipher_encrypt(&ctx->req) :\n\t\t\t\t\tcrypto_ablkcipher_decrypt(&ctx->req),\n\t\t\t\t&ctx->completion);\n\nfree:\n\t\t\taf_alg_free_sg(&ctx->rsgl);\n\n\t\t\tif (err)\n\t\t\t\tgoto unlock;\n\n\t\t\tcopied += used;\n\t\t\tfrom += used;\n\t\t\tseglen -= used;\n\t\t\tskcipher_pull_sgl(sk, used);\n\t\t}\n\t}\n\n\terr = 0;\n\nunlock:\n\tskcipher_wmem_wakeup(sk);\n\trelease_sock(sk);\n\n\treturn copied ?: err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "horizontalDifference16(unsigned short *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From14)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n/* assumption is unsigned pixel values */\n#undef CLAMP\n#define CLAMP(v) From14[(v) >> 2]\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\twp += 3;\n\t\tip += 3;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\twp += 4;\n\t\tip += 4;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1;\n\t }\n\t} else {\n\t ip += n - 1;\t/* point to last one */\n\t wp += n - 1;\t/* point to last one */\n\t n -= stride;\n\t while (n > 0) {\n\t\tREPEAT(stride, wp[0] = CLAMP(ip[0]);\n\t\t\t\twp[stride] -= wp[0];\n\t\t\t\twp[stride] &= mask;\n\t\t\t\twp--; ip--)\n\t\tn -= stride;\n\t }\n\t REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--)\n\t}\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void vapic_exit(struct kvm_vcpu *vcpu)\n{\n\tstruct kvm_lapic *apic = vcpu->arch.apic;\n\tint idx;\n\n\tif (!apic || !apic->vapic_addr)\n\t\treturn;\n\n\tidx = srcu_read_lock(&vcpu->kvm->srcu);\n\tkvm_release_page_dirty(apic->vapic_page);\n\tmark_page_dirty(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);\n\tsrcu_read_unlock(&vcpu->kvm->srcu, idx);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int filter_frame(AVFilterLink *inlink, AVFrame *frame)\n{\n AVFilterContext *ctx = inlink->dst;\n const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);\n uint32_t plane_checksum[4] = {0}, checksum = 0;\n int i, plane, vsub = desc->log2_chroma_h;\n\n for (plane = 0; plane < 4 && frame->data[plane]; plane++) {\n int64_t linesize = av_image_get_linesize(frame->format, frame->width, plane);\n uint8_t *data = frame->data[plane];\n int h = plane == 1 || plane == 2 ? FF_CEIL_RSHIFT(inlink->h, vsub) : inlink->h;\n\n if (linesize < 0)\n return linesize;\n\n for (i = 0; i < h; i++) {\n plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize);\n checksum = av_adler32_update(checksum, data, linesize);\n data += frame->linesize[plane];\n }\n }\n\n av_log(ctx, AV_LOG_INFO,\n \"n:%\"PRId64\" pts:%s pts_time:%s pos:%\"PRId64\" \"\n \"fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c \"\n \"checksum:%08X plane_checksum:[%08X\",\n inlink->frame_count,\n av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base), av_frame_get_pkt_pos(frame),\n desc->name,\n frame->sample_aspect_ratio.num, frame->sample_aspect_ratio.den,\n frame->width, frame->height,\n !frame->interlaced_frame ? 'P' : /* Progressive */\n frame->top_field_first ? 'T' : 'B', /* Top / Bottom */\n frame->key_frame,\n av_get_picture_type_char(frame->pict_type),\n checksum, plane_checksum[0]);\n\n for (plane = 1; plane < 4 && frame->data[plane]; plane++)\n av_log(ctx, AV_LOG_INFO, \" %08X\", plane_checksum[plane]);\n av_log(ctx, AV_LOG_INFO, \"]\\n\");\n\n return ff_filter_frame(inlink->dst->outputs[0], frame);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *\n decorator_list, expr_ty returns, int lineno, int col_offset, int\n end_lineno, int end_col_offset, PyArena *arena)\n{\n stmt_ty p;\n if (!name) {\n PyErr_SetString(PyExc_ValueError,\n \"field name is required for FunctionDef\");\n return NULL;\n }\n if (!args) {\n PyErr_SetString(PyExc_ValueError,\n \"field args is required for FunctionDef\");\n return NULL;\n }\n p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));\n if (!p)\n return NULL;\n p->kind = FunctionDef_kind;\n p->v.FunctionDef.name = name;\n p->v.FunctionDef.args = args;\n p->v.FunctionDef.body = body;\n p->v.FunctionDef.decorator_list = decorator_list;\n p->v.FunctionDef.returns = returns;\n p->lineno = lineno;\n p->col_offset = col_offset;\n p->end_lineno = end_lineno;\n p->end_col_offset = end_col_offset;\n return p;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int set_evtchn_to_irq(evtchn_port_t evtchn, unsigned int irq)\n{\n\tunsigned row;\n\tunsigned col;\n\n\tif (evtchn >= xen_evtchn_max_channels())\n\t\treturn -EINVAL;\n\n\trow = EVTCHN_ROW(evtchn);\n\tcol = EVTCHN_COL(evtchn);\n\n\tif (evtchn_to_irq[row] == NULL) {\n\t\t/* Unallocated irq entries return -1 anyway */\n\t\tif (irq == -1)\n\t\t\treturn 0;\n\n\t\tevtchn_to_irq[row] = (int *)get_zeroed_page(GFP_KERNEL);\n\t\tif (evtchn_to_irq[row] == NULL)\n\t\t\treturn -ENOMEM;\n\n\t\tclear_evtchn_to_irq_row(row);\n\t}\n\n\tevtchn_to_irq[row][col] = irq;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;\n\tint len;\n\n\tif (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) {\n\t\trfcomm_dlc_accept(d);\n\t\tmsg->msg_namelen = 0;\n\t\treturn 0;\n\t}\n\n\tlen = bt_sock_stream_recvmsg(iocb, sock, msg, size, flags);\n\n\tlock_sock(sk);\n\tif (!(flags & MSG_PEEK) && len > 0)\n\t\tatomic_sub(len, &sk->sk_rmem_alloc);\n\n\tif (atomic_read(&sk->sk_rmem_alloc) <= (sk->sk_rcvbuf >> 2))\n\t\trfcomm_dlc_unthrottle(rfcomm_pi(sk)->dlc);\n\trelease_sock(sk);\n\n\treturn len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static void free_huge_page(struct page *page)\n{\n\t/*\n\t * Can't pass hstate in here because it is called from the\n\t * compound page destructor.\n\t */\n\tstruct hstate *h = page_hstate(page);\n\tint nid = page_to_nid(page);\n\tstruct address_space *mapping;\n\n\tmapping = (struct address_space *) page_private(page);\n\tset_page_private(page, 0);\n\tpage->mapping = NULL;\n\tBUG_ON(page_count(page));\n\tBUG_ON(page_mapcount(page));\n\tINIT_LIST_HEAD(&page->lru);\n\n\tspin_lock(&hugetlb_lock);\n\tif (h->surplus_huge_pages_node[nid] && huge_page_order(h) < MAX_ORDER) {\n\t\tupdate_and_free_page(h, page);\n\t\th->surplus_huge_pages--;\n\t\th->surplus_huge_pages_node[nid]--;\n\t} else {\n\t\tenqueue_huge_page(h, page);\n\t}\n\tspin_unlock(&hugetlb_lock);\n\tif (mapping)\n\t\thugetlb_put_quota(mapping, 1);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "iakerb_gss_unwrap(OM_uint32 *minor_status, gss_ctx_id_t context_handle,\n gss_buffer_t input_message_buffer,\n gss_buffer_t output_message_buffer, int *conf_state,\n gss_qop_t *qop_state)\n{\n iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle;\n\n if (ctx->gssc == GSS_C_NO_CONTEXT)\n return GSS_S_NO_CONTEXT;\n\n return krb5_gss_unwrap(minor_status, ctx->gssc, input_message_buffer,\n output_message_buffer, conf_state, qop_state);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-18", "cwe_name": "DEPRECATED: Source Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/18.html", "label_name": "safe"} {"code": "file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,\n size_t nbytes)\n{\n\tunion {\n\t\tint32_t l;\n\t\tchar c[sizeof (int32_t)];\n\t} u;\n\tint clazz;\n\tint swap;\n\tstruct stat st;\n\toff_t fsize;\n\tint flags = 0;\n\tElf32_Ehdr elf32hdr;\n\tElf64_Ehdr elf64hdr;\n\tuint16_t type, phnum, shnum, notecount;\n\n\tif (ms->flags & (MAGIC_MIME|MAGIC_APPLE))\n\t\treturn 0;\n\t/*\n\t * ELF executables have multiple section headers in arbitrary\n\t * file locations and thus file(1) cannot determine it from easily.\n\t * Instead we traverse thru all section headers until a symbol table\n\t * one is found or else the binary is stripped.\n\t * Return immediately if it's not ELF (so we avoid pipe2file unless needed).\n\t */\n\tif (buf[EI_MAG0] != ELFMAG0\n\t || (buf[EI_MAG1] != ELFMAG1 && buf[EI_MAG1] != OLFMAG1)\n\t || buf[EI_MAG2] != ELFMAG2 || buf[EI_MAG3] != ELFMAG3)\n\t\treturn 0;\n\n\t/*\n\t * If we cannot seek, it must be a pipe, socket or fifo.\n\t */\n\tif((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))\n\t\tfd = file_pipe2file(ms, fd, buf, nbytes);\n\n\tif (fstat(fd, &st) == -1) {\n \t\tfile_badread(ms);\n\t\treturn -1;\n\t}\n\tif (S_ISREG(st.st_mode) || st.st_size != 0)\n\t\tfsize = st.st_size;\n\telse\n\t\tfsize = SIZE_UNKNOWN;\n\n\tclazz = buf[EI_CLASS];\n\n\tswitch (clazz) {\n\tcase ELFCLASS32:\n#undef elf_getu\n#define elf_getu(a, b)\telf_getu32(a, b)\n#undef elfhdr\n#define elfhdr elf32hdr\n#include \"elfclass.h\"\n\tcase ELFCLASS64:\n#undef elf_getu\n#define elf_getu(a, b)\telf_getu64(a, b)\n#undef elfhdr\n#define elfhdr elf64hdr\n#include \"elfclass.h\"\n\tdefault:\n\t if (file_printf(ms, \", unknown class %d\", clazz) == -1)\n\t\t return -1;\n\t break;\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static int get_task_ioprio(struct task_struct *p)\n{\n\tint ret;\n\n\tret = security_task_getioprio(p);\n\tif (ret)\n\t\tgoto out;\n\tret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);\n\ttask_lock(p);\n\tif (p->io_context)\n\t\tret = p->io_context->ioprio;\n\ttask_unlock(p);\nout:\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static inline void x86_assign_hw_event(struct perf_event *event,\n\t\t\t\tstruct cpu_hw_events *cpuc, int i)\n{\n\tstruct hw_perf_event *hwc = &event->hw;\n\n\thwc->idx = cpuc->assign[i];\n\thwc->last_cpu = smp_processor_id();\n\thwc->last_tag = ++cpuc->tags[i];\n\n\tif (hwc->idx == X86_PMC_IDX_FIXED_BTS) {\n\t\thwc->config_base = 0;\n\t\thwc->event_base\t= 0;\n\t} else if (hwc->idx >= X86_PMC_IDX_FIXED) {\n\t\thwc->config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL;\n\t\thwc->event_base = MSR_ARCH_PERFMON_FIXED_CTR0;\n\t} else {\n\t\thwc->config_base = x86_pmu_config_addr(hwc->idx);\n\t\thwc->event_base = x86_pmu_event_addr(hwc->idx);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)\n{\n\tstruct ipcm_cookie ipc;\n\tstruct rtable *rt = skb_rtable(skb);\n\tstruct net *net = dev_net(rt->dst.dev);\n\tstruct sock *sk;\n\tstruct inet_sock *inet;\n\t__be32 daddr;\n\n\tif (ip_options_echo(&icmp_param->replyopts, skb))\n\t\treturn;\n\n\tsk = icmp_xmit_lock(net);\n\tif (sk == NULL)\n\t\treturn;\n\tinet = inet_sk(sk);\n\n\ticmp_param->data.icmph.checksum = 0;\n\n\tinet->tos = ip_hdr(skb)->tos;\n\tdaddr = ipc.addr = rt->rt_src;\n\tipc.opt = NULL;\n\tipc.tx_flags = 0;\n\tif (icmp_param->replyopts.optlen) {\n\t\tipc.opt = &icmp_param->replyopts;\n\t\tif (ipc.opt->srr)\n\t\t\tdaddr = icmp_param->replyopts.faddr;\n\t}\n\t{\n\t\tstruct flowi4 fl4 = {\n\t\t\t.daddr = daddr,\n\t\t\t.saddr = rt->rt_spec_dst,\n\t\t\t.flowi4_tos = RT_TOS(ip_hdr(skb)->tos),\n\t\t\t.flowi4_proto = IPPROTO_ICMP,\n\t\t};\n\t\tsecurity_skb_classify_flow(skb, flowi4_to_flowi(&fl4));\n\t\trt = ip_route_output_key(net, &fl4);\n\t\tif (IS_ERR(rt))\n\t\t\tgoto out_unlock;\n\t}\n\tif (icmpv4_xrlim_allow(net, rt, icmp_param->data.icmph.type,\n\t\t\t icmp_param->data.icmph.code))\n\t\ticmp_push_reply(icmp_param, &ipc, &rt);\n\tip_rt_put(rt);\nout_unlock:\n\ticmp_xmit_unlock(sk);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "void inet6_destroy_sock(struct sock *sk)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct ipv6_txoptions *opt;\n\n\t/* Release rx options */\n\n\tskb = xchg(&np->pktoptions, NULL);\n\tif (skb)\n\t\tkfree_skb(skb);\n\n\tskb = xchg(&np->rxpmtu, NULL);\n\tif (skb)\n\t\tkfree_skb(skb);\n\n\t/* Free flowlabels */\n\tfl6_free_socklist(sk);\n\n\t/* Free tx options */\n\n\topt = xchg(&np->opt, NULL);\n\tif (opt)\n\t\tsock_kfree_s(sk, opt, opt->tot_len);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "int build_segment_manager(struct f2fs_sb_info *sbi)\n{\n\tstruct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);\n\tstruct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);\n\tstruct f2fs_sm_info *sm_info;\n\tint err;\n\n\tsm_info = kzalloc(sizeof(struct f2fs_sm_info), GFP_KERNEL);\n\tif (!sm_info)\n\t\treturn -ENOMEM;\n\n\t/* init sm info */\n\tsbi->sm_info = sm_info;\n\tsm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr);\n\tsm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr);\n\tsm_info->segment_count = le32_to_cpu(raw_super->segment_count);\n\tsm_info->reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count);\n\tsm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count);\n\tsm_info->main_segments = le32_to_cpu(raw_super->segment_count_main);\n\tsm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);\n\tsm_info->rec_prefree_segments = sm_info->main_segments *\n\t\t\t\t\tDEF_RECLAIM_PREFREE_SEGMENTS / 100;\n\tif (sm_info->rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS)\n\t\tsm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS;\n\n\tif (!test_opt(sbi, LFS))\n\t\tsm_info->ipu_policy = 1 << F2FS_IPU_FSYNC;\n\tsm_info->min_ipu_util = DEF_MIN_IPU_UTIL;\n\tsm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;\n\tsm_info->min_hot_blocks = DEF_MIN_HOT_BLOCKS;\n\n\tsm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;\n\n\tINIT_LIST_HEAD(&sm_info->sit_entry_set);\n\n\tif (!f2fs_readonly(sbi->sb)) {\n\t\terr = create_flush_cmd_control(sbi);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\terr = create_discard_cmd_control(sbi);\n\tif (err)\n\t\treturn err;\n\n\terr = build_sit_info(sbi);\n\tif (err)\n\t\treturn err;\n\terr = build_free_segmap(sbi);\n\tif (err)\n\t\treturn err;\n\terr = build_curseg(sbi);\n\tif (err)\n\t\treturn err;\n\n\t/* reinit free segmap based on SIT */\n\tbuild_sit_entries(sbi);\n\n\tinit_free_segmap(sbi);\n\terr = build_dirty_segmap(sbi);\n\tif (err)\n\t\treturn err;\n\n\tinit_min_max_mtime(sbi);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "process_bitmap_updates(STREAM s)\n{\n\tuint16 num_updates;\n\tuint16 left, top, right, bottom, width, height;\n\tuint16 cx, cy, bpp, Bpp, compress, bufsize, size;\n\tuint8 *data, *bmpdata;\n\tint i;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\n\tin_uint16_le(s, num_updates);\n\n\tfor (i = 0; i < num_updates; i++)\n\t{\n\t\tin_uint16_le(s, left);\n\t\tin_uint16_le(s, top);\n\t\tin_uint16_le(s, right);\n\t\tin_uint16_le(s, bottom);\n\t\tin_uint16_le(s, width);\n\t\tin_uint16_le(s, height);\n\t\tin_uint16_le(s, bpp);\n\t\tBpp = (bpp + 7) / 8;\n\t\tin_uint16_le(s, compress);\n\t\tin_uint16_le(s, bufsize);\n\n\t\tcx = right - left + 1;\n\t\tcy = bottom - top + 1;\n\n\t\tlogger(Graphics, Debug,\n\t\t \"process_bitmap_updates(), [%d,%d,%d,%d], [%d,%d], bpp=%d, compression=%d\",\n\t\t left, top, right, bottom, width, height, Bpp, compress);\n\n\t\tif (!compress)\n\t\t{\n\t\t\tint y;\n\t\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tin_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],\n\t\t\t\t\t width * Bpp);\n\t\t\t}\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t\txfree(bmpdata);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\tif (compress & 0x400)\n\t\t{\n\t\t\tsize = bufsize;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_uint8s(s, 2);\t/* pad */\n\t\t\tin_uint16_le(s, size);\n\t\t\tin_uint8s(s, 4);\t/* line_size, final_size */\n\t\t}\n\t\tin_uint8p(s, data, size);\n\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\tif (bitmap_decompress(bmpdata, width, height, data, size, Bpp))\n\t\t{\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t \"process_bitmap_updates(), failed to decompress bitmap\");\n\t\t}\n\n\t\txfree(bmpdata);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC)\n{\n\tzend_object_value new_obj_val;\n\tzend_object *old_object;\n\tzend_object *new_object;\n\tzend_object_handle handle = Z_OBJ_HANDLE_P(zobject);\n\tspl_filesystem_object *intern;\n\tspl_filesystem_object *source;\n\tint index, skip_dots;\n\n\told_object = zend_objects_get_address(zobject TSRMLS_CC);\n\tsource = (spl_filesystem_object*)old_object;\n\n\tnew_obj_val = spl_filesystem_object_new_ex(old_object->ce, &intern TSRMLS_CC);\n\tnew_object = &intern->std;\n\n\tintern->flags = source->flags;\n\n\tswitch (source->type) {\n\tcase SPL_FS_INFO:\n\t\tintern->_path_len = source->_path_len;\n\t\tintern->_path = estrndup(source->_path, source->_path_len);\n\t\tintern->file_name_len = source->file_name_len;\n\t\tintern->file_name = estrndup(source->file_name, intern->file_name_len);\n\t\tbreak;\n\tcase SPL_FS_DIR:\n\t\tspl_filesystem_dir_open(intern, source->_path TSRMLS_CC);\n\t\t/* read until we hit the position in which we were before */\n\t\tskip_dots = SPL_HAS_FLAG(source->flags, SPL_FILE_DIR_SKIPDOTS);\n\t\tfor(index = 0; index < source->u.dir.index; ++index) {\n\t\t\tdo {\n\t\t\t\tspl_filesystem_dir_read(intern TSRMLS_CC);\n\t\t\t} while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));\n\t\t}\n\t\tintern->u.dir.index = index;\n\t\tbreak;\n\tcase SPL_FS_FILE:\n\t\tphp_error_docref(NULL TSRMLS_CC, E_ERROR, \"An object of class %s cannot be cloned\", old_object->ce->name);\n\t\tbreak;\n\t}\n\t\n\tintern->file_class = source->file_class;\n\tintern->info_class = source->info_class;\n\tintern->oth = source->oth;\n\tintern->oth_handler = source->oth_handler;\n\n\tzend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC);\n\n\tif (intern->oth_handler && intern->oth_handler->clone) {\n\t\tintern->oth_handler->clone(source, intern TSRMLS_CC);\n\t}\n\n\treturn new_obj_val;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static int vmci_transport_dgram_dequeue(struct kiocb *kiocb,\n\t\t\t\t\tstruct vsock_sock *vsk,\n\t\t\t\t\tstruct msghdr *msg, size_t len,\n\t\t\t\t\tint flags)\n{\n\tint err;\n\tint noblock;\n\tstruct vmci_datagram *dg;\n\tsize_t payload_len;\n\tstruct sk_buff *skb;\n\n\tnoblock = flags & MSG_DONTWAIT;\n\n\tif (flags & MSG_OOB || flags & MSG_ERRQUEUE)\n\t\treturn -EOPNOTSUPP;\n\n\tmsg->msg_namelen = 0;\n\n\t/* Retrieve the head sk_buff from the socket's receive queue. */\n\terr = 0;\n\tskb = skb_recv_datagram(&vsk->sk, flags, noblock, &err);\n\tif (err)\n\t\treturn err;\n\n\tif (!skb)\n\t\treturn -EAGAIN;\n\n\tdg = (struct vmci_datagram *)skb->data;\n\tif (!dg)\n\t\t/* err is 0, meaning we read zero bytes. */\n\t\tgoto out;\n\n\tpayload_len = dg->payload_size;\n\t/* Ensure the sk_buff matches the payload size claimed in the packet. */\n\tif (payload_len != skb->len - sizeof(*dg)) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tif (payload_len > len) {\n\t\tpayload_len = len;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\t/* Place the datagram payload in the user's iovec. */\n\terr = skb_copy_datagram_iovec(skb, sizeof(*dg), msg->msg_iov,\n\t\tpayload_len);\n\tif (err)\n\t\tgoto out;\n\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_vm *vm_addr;\n\n\t\t/* Provide the address of the sender. */\n\t\tvm_addr = (struct sockaddr_vm *)msg->msg_name;\n\t\tvsock_addr_init(vm_addr, dg->src.context, dg->src.resource);\n\t\tmsg->msg_namelen = sizeof(*vm_addr);\n\t}\n\terr = payload_len;\n\nout:\n\tskb_free_datagram(&vsk->sk, skb);\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,\n\t\t\t unsigned int keylen)\n{\n\treturn -ENOSYS;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "openscript(\n char_u\t*name,\n int\t\tdirectly)\t/* when TRUE execute directly */\n{\n if (curscript + 1 == NSCRIPT)\n {\n\temsg(_(e_nesting));\n\treturn;\n }\n\n // Disallow sourcing a file in the sandbox, the commands would be executed\n // later, possibly outside of the sandbox.\n if (check_secure())\n\treturn;\n\n#ifdef FEAT_EVAL\n if (ignore_script)\n\t/* Not reading from script, also don't open one. Warning message? */\n\treturn;\n#endif\n\n if (scriptin[curscript] != NULL)\t/* already reading script */\n\t++curscript;\n\t\t\t\t/* use NameBuff for expanded name */\n expand_env(name, NameBuff, MAXPATHL);\n if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL)\n {\n\tsemsg(_(e_notopen), name);\n\tif (curscript)\n\t --curscript;\n\treturn;\n }\n if (save_typebuf() == FAIL)\n\treturn;\n\n /*\n * Execute the commands from the file right now when using \":source!\"\n * after \":global\" or \":argdo\" or in a loop. Also when another command\n * follows. This means the display won't be updated. Don't do this\n * always, \"make test\" would fail.\n */\n if (directly)\n {\n\toparg_T\toa;\n\tint\toldcurscript;\n\tint\tsave_State = State;\n\tint\tsave_restart_edit = restart_edit;\n\tint\tsave_insertmode = p_im;\n\tint\tsave_finish_op = finish_op;\n\tint\tsave_msg_scroll = msg_scroll;\n\n\tState = NORMAL;\n\tmsg_scroll = FALSE;\t/* no msg scrolling in Normal mode */\n\trestart_edit = 0;\t/* don't go to Insert mode */\n\tp_im = FALSE;\t\t/* don't use 'insertmode' */\n\tclear_oparg(&oa);\n\tfinish_op = FALSE;\n\n\toldcurscript = curscript;\n\tdo\n\t{\n\t update_topline_cursor();\t// update cursor position and topline\n\t normal_cmd(&oa, FALSE);\t// execute one command\n\t vpeekc();\t\t\t// check for end of file\n\t}\n\twhile (scriptin[oldcurscript] != NULL);\n\n\tState = save_State;\n\tmsg_scroll = save_msg_scroll;\n\trestart_edit = save_restart_edit;\n\tp_im = save_insertmode;\n\tfinish_op = save_finish_op;\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "static bool vtable_is_addr_vtable_start_msvc(RVTableContext *context, ut64 curAddress) {\n\tRAnalRef *xref;\n\tRListIter *xrefIter;\n\n\tif (!curAddress || curAddress == UT64_MAX) {\n\t\treturn false;\n\t}\n\tif (curAddress && !vtable_is_value_in_text_section (context, curAddress, NULL)) {\n\t\treturn false;\n\t}\n\t// total xref's to curAddress\n\tRList *xrefs = r_anal_xrefs_get (context->anal, curAddress);\n\tif (r_list_empty (xrefs)) {\n\t\tr_list_free (xrefs);\n\t\treturn false;\n\t}\n\tr_list_foreach (xrefs, xrefIter, xref) {\n\t\t// section in which currenct xref lies\n\t\tif (vtable_addr_in_text_section (context, xref->addr)) {\n\t\t\tut8 buf[VTABLE_BUFF_SIZE];\n\t\t\tcontext->anal->iob.read_at (context->anal->iob.io, xref->addr, buf, sizeof(buf));\n\n\t\t\tRAnalOp analop = {0};\n\t\t\tr_anal_op (context->anal, &analop, xref->addr, buf, sizeof(buf), R_ANAL_OP_MASK_BASIC);\n\n\t\t\tif (analop.type == R_ANAL_OP_TYPE_MOV\n\t\t\t\t|| analop.type == R_ANAL_OP_TYPE_LEA) {\n\t\t\t\tr_list_free (xrefs);\n\t\t\t\tr_anal_op_fini (&analop);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tr_anal_op_fini (&analop);\n\t\t}\n\t}\n\tr_list_free (xrefs);\n\treturn false;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-824", "cwe_name": "Access of Uninitialized Pointer", "description": "The program accesses or uses a pointer that has not been initialized.", "url": "https://cwe.mitre.org/data/definitions/824.html", "label_name": "vulnerable"} {"code": "static int _snd_timer_stop(struct snd_timer_instance * timeri,\n\t\t\t int keep_flag, int event)\n{\n\tstruct snd_timer *timer;\n\tunsigned long flags;\n\n\tif (snd_BUG_ON(!timeri))\n\t\treturn -ENXIO;\n\n\tif (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {\n\t\tif (!keep_flag) {\n\t\t\tspin_lock_irqsave(&slave_active_lock, flags);\n\t\t\ttimeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;\n\t\t\tlist_del_init(&timeri->ack_list);\n\t\t\tlist_del_init(&timeri->active_list);\n\t\t\tspin_unlock_irqrestore(&slave_active_lock, flags);\n\t\t}\n\t\tgoto __end;\n\t}\n\ttimer = timeri->timer;\n\tif (!timer)\n\t\treturn -EINVAL;\n\tspin_lock_irqsave(&timer->lock, flags);\n\tlist_del_init(&timeri->ack_list);\n\tlist_del_init(&timeri->active_list);\n\tif ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&\n\t !(--timer->running)) {\n\t\ttimer->hw.stop(timer);\n\t\tif (timer->flags & SNDRV_TIMER_FLG_RESCHED) {\n\t\t\ttimer->flags &= ~SNDRV_TIMER_FLG_RESCHED;\n\t\t\tsnd_timer_reschedule(timer, 0);\n\t\t\tif (timer->flags & SNDRV_TIMER_FLG_CHANGE) {\n\t\t\t\ttimer->flags &= ~SNDRV_TIMER_FLG_CHANGE;\n\t\t\t\ttimer->hw.start(timer);\n\t\t\t}\n\t\t}\n\t}\n\tif (!keep_flag)\n\t\ttimeri->flags &=\n\t\t\t~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);\n\tspin_unlock_irqrestore(&timer->lock, flags);\n __end:\n\tif (event != SNDRV_TIMER_EVENT_RESOLUTION)\n\t\tsnd_timer_notify1(timeri, event);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "spnego_gss_export_sec_context(\n\t\t\t OM_uint32\t *minor_status,\n\t\t\t gss_ctx_id_t *context_handle,\n\t\t\t gss_buffer_t interprocess_token)\n{\n\tOM_uint32 ret;\n\tspnego_gss_ctx_id_t sc = *(spnego_gss_ctx_id_t *)context_handle;\n\n\t/* We don't currently support exporting partially established\n\t * contexts. */\n\tif (!sc->opened)\n\t\treturn GSS_S_UNAVAILABLE;\n\n\tret = gss_export_sec_context(minor_status,\n\t\t\t\t &sc->ctx_handle,\n\t\t\t\t interprocess_token);\n\tif (sc->ctx_handle == GSS_C_NO_CONTEXT) {\n\t\trelease_spnego_ctx(&sc);\n\t\t*context_handle = GSS_C_NO_CONTEXT;\n\t}\n\treturn (ret);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "safe"} {"code": "sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const int32_t * const buffer [], void *client_data)\n{\tSF_PRIVATE *psf = (SF_PRIVATE*) client_data ;\n\tFLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;\n\n\tpflac->frame = frame ;\n\tpflac->bufferpos = 0 ;\n\n\tpflac->bufferbackup = SF_FALSE ;\n\tpflac->wbuffer = buffer ;\n\n\tflac_buffer_copy (psf) ;\n\n\treturn FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE ;\n} /* sf_flac_write_callback */", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "PGTYPESinterval_from_asc(char *str, char **endptr)\n{\n\tinterval *result = NULL;\n\tfsec_t\t\tfsec;\n\tstruct tm\ttt,\n\t\t\t *tm = &tt;\n\tint\t\t\tdtype;\n\tint\t\t\tnf;\n\tchar\t *field[MAXDATEFIELDS];\n\tint\t\t\tftype[MAXDATEFIELDS];\n\tchar\t\tlowstr[MAXDATELEN + MAXDATEFIELDS];\n\tchar\t *realptr;\n\tchar\t **ptr = (endptr != NULL) ? endptr : &realptr;\n\n\ttm->tm_year = 0;\n\ttm->tm_mon = 0;\n\ttm->tm_mday = 0;\n\ttm->tm_hour = 0;\n\ttm->tm_min = 0;\n\ttm->tm_sec = 0;\n\tfsec = 0;\n\n\tif (strlen(str) > MAXDATELEN)\n\t{\n\t\terrno = PGTYPES_INTVL_BAD_INTERVAL;\n\t\treturn NULL;\n\t}\n\n\tif (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||\n\t\t(DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0 &&\n\t\t DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0))\n\t{\n\t\terrno = PGTYPES_INTVL_BAD_INTERVAL;\n\t\treturn NULL;\n\t}\n\n\tresult = (interval *) pgtypes_alloc(sizeof(interval));\n\tif (!result)\n\t\treturn NULL;\n\n\tif (dtype != DTK_DELTA)\n\t{\n\t\terrno = PGTYPES_INTVL_BAD_INTERVAL;\n\t\tfree(result);\n\t\treturn NULL;\n\t}\n\n\tif (tm2interval(tm, fsec, result) != 0)\n\t{\n\t\terrno = PGTYPES_INTVL_BAD_INTERVAL;\n\t\tfree(result);\n\t\treturn NULL;\n\t}\n\n\terrno = 0;\n\treturn result;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "struct task_struct * __cpuinit fork_idle(int cpu)\n{\n\tstruct task_struct *task;\n\tstruct pt_regs regs;\n\n\ttask = copy_process(CLONE_VM, 0, idle_regs(®s), 0, NULL,\n\t\t\t &init_struct_pid, 0);\n\tif (!IS_ERR(task)) {\n\t\tinit_idle_pids(task->pids);\n\t\tinit_idle(task, cpu);\n\t}\n\n\treturn task;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "char *path_name(struct strbuf *path, const char *name)\n{\n\tstruct strbuf ret = STRBUF_INIT;\n\tif (path)\n\t\tstrbuf_addbuf(&ret, path);\n\tstrbuf_addstr(&ret, name);\n\treturn strbuf_detach(&ret, NULL);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "SPL_METHOD(SplFileObject, rewind)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tspl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);\n} /* }}} */", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb)\n{\n int i, j, v;\n\n if (get_bits1(gb)) {\n if (get_bits_left(gb) < 64*8)\n return AVERROR_INVALIDDATA;\n /* intra_quantiser_matrix */\n for (i = 0; i < 64; i++) {\n v = get_bits(gb, 8);\n j = s->idsp.idct_permutation[ff_zigzag_direct[i]];\n s->intra_matrix[j] = v;\n s->chroma_intra_matrix[j] = v;\n }\n }\n\n if (get_bits1(gb)) {\n if (get_bits_left(gb) < 64*8)\n return AVERROR_INVALIDDATA;\n /* non_intra_quantiser_matrix */\n for (i = 0; i < 64; i++) {\n get_bits(gb, 8);\n }\n }\n\n if (get_bits1(gb)) {\n if (get_bits_left(gb) < 64*8)\n return AVERROR_INVALIDDATA;\n /* chroma_intra_quantiser_matrix */\n for (i = 0; i < 64; i++) {\n v = get_bits(gb, 8);\n j = s->idsp.idct_permutation[ff_zigzag_direct[i]];\n s->chroma_intra_matrix[j] = v;\n }\n }\n\n if (get_bits1(gb)) {\n if (get_bits_left(gb) < 64*8)\n return AVERROR_INVALIDDATA;\n /* chroma_non_intra_quantiser_matrix */\n for (i = 0; i < 64; i++) {\n get_bits(gb, 8);\n }\n }\n\n next_start_code_studio(gb);\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "IW_IMPL(unsigned int) iw_get_ui16be(const iw_byte *b)\n{\n\treturn (b[0]<<8) | b[1];\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-682", "cwe_name": "Incorrect Calculation", "description": "The software performs a calculation that generates incorrect or unintended results that are later used in security-critical decisions or resource management.", "url": "https://cwe.mitre.org/data/definitions/682.html", "label_name": "vulnerable"} {"code": "static void clear_evtchn_to_irq_row(unsigned row)\n{\n\tunsigned col;\n\n\tfor (col = 0; col < EVTCHN_PER_ROW; col++)\n\t\tWRITE_ONCE(evtchn_to_irq[row][col], -1);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "ip_printts(netdissect_options *ndo,\n register const u_char *cp, u_int length)\n{\n\tregister u_int ptr;\n\tregister u_int len;\n\tint hoplen;\n\tconst char *type;\n\n\tif (length < 4) {\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\t\treturn;\n\t}\n\tND_PRINT((ndo, \" TS{\"));\n\thoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;\n\tif ((length - 4) & (hoplen-1))\n\t\tND_PRINT((ndo, \"[bad length %u]\", length));\n\tptr = cp[2] - 1;\n\tlen = 0;\n\tif (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)\n\t\tND_PRINT((ndo, \"[bad ptr %u]\", cp[2]));\n\tswitch (cp[3]&0xF) {\n\tcase IPOPT_TS_TSONLY:\n\t\tND_PRINT((ndo, \"TSONLY\"));\n\t\tbreak;\n\tcase IPOPT_TS_TSANDADDR:\n\t\tND_PRINT((ndo, \"TS+ADDR\"));\n\t\tbreak;\n\t/*\n\t * prespecified should really be 3, but some ones might send 2\n\t * instead, and the IPOPT_TS_PRESPEC constant can apparently\n\t * have both values, so we have to hard-code it here.\n\t */\n\n\tcase 2:\n\t\tND_PRINT((ndo, \"PRESPEC2.0\"));\n\t\tbreak;\n\tcase 3:\t\t\t/* IPOPT_TS_PRESPEC */\n\t\tND_PRINT((ndo, \"PRESPEC\"));\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \"[bad ts type %d]\", cp[3]&0xF));\n\t\tgoto done;\n\t}\n\n\ttype = \" \";\n\tfor (len = 4; len < length; len += hoplen) {\n\t\tif (ptr == len)\n\t\t\ttype = \" ^ \";\n\t\tND_PRINT((ndo, \"%s%d@%s\", type, EXTRACT_32BITS(&cp[len+hoplen-4]),\n\t\t hoplen!=8 ? \"\" : ipaddr_string(ndo, &cp[len])));\n\t\ttype = \" \";\n\t}\n\ndone:\n\tND_PRINT((ndo, \"%s\", ptr == len ? \" ^ \" : \"\"));\n\n\tif (cp[3]>>4)\n\t\tND_PRINT((ndo, \" [%d hops not recorded]} \", cp[3]>>4));\n\telse\n\t\tND_PRINT((ndo, \"}\"));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "string_object_to_c_ast(const char *s, PyObject *filename, int start,\n PyCompilerFlags *flags, int feature_version,\n PyArena *arena)\n{\n mod_ty mod;\n PyCompilerFlags localflags;\n perrdetail err;\n int iflags = PARSER_FLAGS(flags);\n\n node *n = Ta3Parser_ParseStringObject(s, filename,\n &_Ta3Parser_Grammar, start, &err,\n &iflags);\n if (flags == NULL) {\n localflags.cf_flags = 0;\n flags = &localflags;\n }\n if (n) {\n flags->cf_flags |= iflags & PyCF_MASK;\n mod = Ta3AST_FromNodeObject(n, flags, filename, feature_version, arena);\n Ta3Node_Free(n);\n }\n else {\n err_input(&err);\n mod = NULL;\n }\n err_free(&err);\n return mod;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int mesg_make_query (u_char *qname, uint16_t qtype, uint16_t qclass,\n\t\t uint32_t id, int rd, u_char *buf, int buflen) {\n\tchar *fn = \"mesg_make_query()\";\n\tu_char *ucp;\n\tint i, written_len;\n\tMesg_Hdr *hdr;\n\n\tif (T.debug > 4)\n\t\tsyslog (LOG_DEBUG, \"%s: (qtype: %s, id: %d): start\", fn,\n\t\t\tstring_rtype (qtype), id);\n\n\thdr = (Mesg_Hdr *) buf;\n\n\t/* write header */\n\thdr->id = id;\n\thdr->opcode = OP_QUERY;\n\thdr->rcode = RC_OK;\n\thdr->rd = rd;\n\thdr->qr = hdr->aa = hdr->tc = hdr->ra = hdr->zero = 0;\n\thdr->qdcnt = ntohs (1);\n\thdr->ancnt = hdr->nscnt = hdr->arcnt = ntohs (0);\n\n\twritten_len = sizeof (Mesg_Hdr);\n\tucp = (u_char *) (hdr + 1);\n\n\t/* write qname */\n\tif (T.debug > 4)\n\t\tsyslog (LOG_DEBUG, \"%s: qname offset = %zd\", fn, ucp - buf);\n\n\ti = dname_copy (qname, ucp, buflen - written_len);\n\tif (i < 0)\n\t\treturn -1;\n\n\twritten_len += i;\n\tucp += i;\n\n\t/* write qtype / qclass */\n\tif (T.debug > 4)\n\t\tsyslog (LOG_DEBUG, \"%s: qtype/qclass offset = %zd\",\n\t\t\tfn, ucp - buf);\n\n\twritten_len += sizeof (uint16_t) * 2;\n\tif (written_len > buflen)\n\t\treturn -1;\n\n\tPUTSHORT (qtype, ucp);\n\tPUTSHORT (qclass, ucp);\n\n\treturn written_len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": "static void perf_event_comm_output(struct perf_event *event,\n\t\t\t\t struct perf_comm_event *comm_event)\n{\n\tstruct perf_output_handle handle;\n\tstruct perf_sample_data sample;\n\tint size = comm_event->event_id.header.size;\n\tint ret;\n\n\tperf_event_header__init_id(&comm_event->event_id.header, &sample, event);\n\tret = perf_output_begin(&handle, event,\n\t\t\t\tcomm_event->event_id.header.size, 0);\n\n\tif (ret)\n\t\tgoto out;\n\n\tcomm_event->event_id.pid = perf_event_pid(event, comm_event->task);\n\tcomm_event->event_id.tid = perf_event_tid(event, comm_event->task);\n\n\tperf_output_put(&handle, comm_event->event_id);\n\t__output_copy(&handle, comm_event->comm,\n\t\t\t\t comm_event->comm_size);\n\n\tperf_event__output_id_sample(event, &handle, &sample);\n\n\tperf_output_end(&handle);\nout:\n\tcomm_event->event_id.header.size = size;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, const u_char **endp)\n{\n int result;\n u_char c;\n int saw_digit;\n int neg;\n int too_large;\n\n if (len == 0)\n goto trunc;\n ND_TCHECK(*bp);\n too_large = 0;\n neg = 0;\n if (*bp == '-') {\n neg = 1;\n bp++;\n len--;\n }\n result = 0;\n saw_digit = 0;\n\n for (;;) {\n if (len == 0)\n goto trunc;\n ND_TCHECK(*bp);\n c = *bp;\n if (!(c >= '0' && c <= '9')) {\n if (!saw_digit)\n goto invalid;\n break;\n }\n c -= '0';\n if (result > (INT_MAX / 10)) {\n /* This will overflow an int when we multiply it by 10. */\n too_large = 1;\n } else {\n result *= 10;\n if (result == INT_MAX && c > (INT_MAX % 10)) {\n /* This will overflow an int when we add c */\n too_large = 1;\n } else\n result += c;\n }\n bp++;\n len--;\n saw_digit = 1;\n }\n if (!saw_digit)\n goto invalid;\n\n /*\n * OK, the next thing should be \\r\\n.\n */\n if (len == 0)\n goto trunc;\n ND_TCHECK(*bp);\n if (*bp != '\\r')\n goto invalid;\n bp++;\n len--;\n if (len == 0)\n goto trunc;\n ND_TCHECK(*bp);\n if (*bp != '\\n')\n goto invalid;\n bp++;\n len--;\n *endp = bp;\n if (neg) {\n /* -1 means \"null\", anything else is invalid */\n if (too_large || result != 1)\n return (-4);\n result = -1;\n }\n return (too_large ? -3 : result);\n\ntrunc:\n return (-2);\n\ninvalid:\n return (-5);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": "getprivs_ret * get_privs_2_svc(krb5_ui_4 *arg, struct svc_req *rqstp)\n{\n static getprivs_ret ret;\n gss_buffer_desc client_name, service_name;\n OM_uint32 minor_stat;\n kadm5_server_handle_t handle;\n const char *errmsg = NULL;\n\n xdr_free(xdr_getprivs_ret, &ret);\n\n if ((ret.code = new_server_handle(*arg, rqstp, &handle)))\n goto exit_func;\n\n if ((ret.code = check_handle((void *)handle)))\n goto exit_func;\n\n ret.api_version = handle->api_version;\n\n if (setup_gss_names(rqstp, &client_name, &service_name) < 0) {\n ret.code = KADM5_FAILURE;\n goto exit_func;\n }\n\n ret.code = kadm5_get_privs((void *)handle, &ret.privs);\n if( ret.code != 0 )\n errmsg = krb5_get_error_message(handle->context, ret.code);\n\n log_done(\"kadm5_get_privs\", client_name.value, errmsg,\n &client_name, &service_name, rqstp);\n\n if (errmsg != NULL)\n krb5_free_error_message(handle->context, errmsg);\n\n gss_release_buffer(&minor_stat, &client_name);\n gss_release_buffer(&minor_stat, &service_name);\nexit_func:\n free_server_handle(handle);\n return &ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-772", "cwe_name": "Missing Release of Resource after Effective Lifetime", "description": "The software does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.", "url": "https://cwe.mitre.org/data/definitions/772.html", "label_name": "vulnerable"} {"code": "sysObjectID_handler(snmp_varbind_t *varbind, uint32_t *oid)\n{\n OID(sysObjectID_oid, 1, 3, 6, 1, 4, 1, 54352);\n snmp_api_set_oid(varbind, oid, sysObjectID_oid);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int fsmMkfile(rpmfi fi, const char *dest, rpmfiles files,\n\t\t rpmpsm psm, int nodigest, int *setmeta,\n\t\t int * firsthardlink)\n{\n int rc = 0;\n int numHardlinks = rpmfiFNlink(fi);\n\n if (numHardlinks > 1) {\n\t/* Create first hardlinked file empty */\n\tif (*firsthardlink < 0) {\n\t *firsthardlink = rpmfiFX(fi);\n\t rc = expandRegular(fi, dest, psm, nodigest, 1);\n\t} else {\n\t /* Create hard links for others */\n\t char *fn = rpmfilesFN(files, *firsthardlink);\n\t rc = link(fn, dest);\n\t if (rc < 0) {\n\t\trc = RPMERR_LINK_FAILED;\n\t }\n\t free(fn);\n\t}\n }\n /* Write normal files or fill the last hardlinked (already\n existing) file with content */\n if (numHardlinks<=1) {\n\tif (!rc)\n\t rc = expandRegular(fi, dest, psm, nodigest, 0);\n } else if (rpmfiArchiveHasContent(fi)) {\n\tif (!rc)\n\t rc = expandRegular(fi, dest, psm, nodigest, 0);\n\t*firsthardlink = -1;\n } else {\n\t*setmeta = 0;\n }\n\n return rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create)\n{\n\tstruct inet_peer __rcu **stack[PEER_MAXDEPTH], ***stackptr;\n\tstruct inet_peer_base *base = family_to_base(daddr->family);\n\tstruct inet_peer *p;\n\tunsigned int sequence;\n\tint invalidated, gccnt = 0;\n\n\t/* Attempt a lockless lookup first.\n\t * Because of a concurrent writer, we might not find an existing entry.\n\t */\n\trcu_read_lock();\n\tsequence = read_seqbegin(&base->lock);\n\tp = lookup_rcu(daddr, base);\n\tinvalidated = read_seqretry(&base->lock, sequence);\n\trcu_read_unlock();\n\n\tif (p)\n\t\treturn p;\n\n\t/* If no writer did a change during our lookup, we can return early. */\n\tif (!create && !invalidated)\n\t\treturn NULL;\n\n\t/* retry an exact lookup, taking the lock before.\n\t * At least, nodes should be hot in our cache.\n\t */\n\twrite_seqlock_bh(&base->lock);\nrelookup:\n\tp = lookup(daddr, stack, base);\n\tif (p != peer_avl_empty) {\n\t\tatomic_inc(&p->refcnt);\n\t\twrite_sequnlock_bh(&base->lock);\n\t\treturn p;\n\t}\n\tif (!gccnt) {\n\t\tgccnt = inet_peer_gc(base, stack, stackptr);\n\t\tif (gccnt && create)\n\t\t\tgoto relookup;\n\t}\n\tp = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL;\n\tif (p) {\n\t\tp->daddr = *daddr;\n\t\tatomic_set(&p->refcnt, 1);\n\t\tatomic_set(&p->rid, 0);\n\t\tatomic_set(&p->ip_id_count, secure_ip_id(daddr->addr.a4));\n\t\tp->tcp_ts_stamp = 0;\n\t\tp->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;\n\t\tp->rate_tokens = 0;\n\t\tp->rate_last = 0;\n\t\tp->pmtu_expires = 0;\n\t\tp->pmtu_orig = 0;\n\t\tmemset(&p->redirect_learned, 0, sizeof(p->redirect_learned));\n\n\n\t\t/* Link the node. */\n\t\tlink_to_pool(p, base);\n\t\tbase->total++;\n\t}\n\twrite_sequnlock_bh(&base->lock);\n\n\treturn p;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_hash rhash;\n\tstruct shash_alg *salg = __crypto_shash_alg(alg);\n\n\tsnprintf(rhash.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"shash\");\n\trhash.blocksize = alg->cra_blocksize;\n\trhash.digestsize = salg->digestsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_HASH,\n\t\t sizeof(struct crypto_report_hash), &rhash))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "pim_print(netdissect_options *ndo,\n register const u_char *bp, register u_int len, const u_char *bp2)\n{\n\tregister const struct pim *pim = (const struct pim *)bp;\n\n#ifdef notyet\t\t\t/* currently we see only version and type */\n\tND_TCHECK(pim->pim_rsv);\n#endif\n\n\tND_TCHECK(pim->pim_typever);\n\tswitch (PIM_VER(pim->pim_typever)) {\n\tcase 2:\n\t\tif (!ndo->ndo_vflag) {\n\t\t\tND_PRINT((ndo, \"PIMv%u, %s, length %u\",\n\t\t\t PIM_VER(pim->pim_typever),\n\t\t\t tok2str(pimv2_type_values,\"Unknown Type\",PIM_TYPE(pim->pim_typever)),\n\t\t\t len));\n\t\t\treturn;\n\t\t} else {\n\t\t\tND_PRINT((ndo, \"PIMv%u, length %u\\n\\t%s\",\n\t\t\t PIM_VER(pim->pim_typever),\n\t\t\t len,\n\t\t\t tok2str(pimv2_type_values,\"Unknown Type\",PIM_TYPE(pim->pim_typever))));\n\t\t\tpimv2_print(ndo, bp, len, bp2);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tND_PRINT((ndo, \"PIMv%u, length %u\",\n\t\t PIM_VER(pim->pim_typever),\n\t\t len));\n\t\tbreak;\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"[|pim]\"));\n\treturn;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "get_visual_text(\n cmdarg_T\t*cap,\n char_u\t**pp,\t // return: start of selected text\n int\t\t*lenp)\t // return: length of selected text\n{\n if (VIsual_mode != 'V')\n\tunadjust_for_sel();\n if (VIsual.lnum != curwin->w_cursor.lnum)\n {\n\tif (cap != NULL)\n\t clearopbeep(cap->oap);\n\treturn FAIL;\n }\n if (VIsual_mode == 'V')\n {\n\t*pp = ml_get_curline();\n\t*lenp = (int)STRLEN(*pp);\n }\n else\n {\n\tif (LT_POS(curwin->w_cursor, VIsual))\n\t{\n\t *pp = ml_get_pos(&curwin->w_cursor);\n\t *lenp = VIsual.col - curwin->w_cursor.col + 1;\n\t}\n\telse\n\t{\n\t *pp = ml_get_pos(&VIsual);\n\t *lenp = curwin->w_cursor.col - VIsual.col + 1;\n\t}\n\tif (**pp == NUL)\n\t *lenp = 0;\n\tif (has_mbyte && *lenp > 0)\n\t // Correct the length to include all bytes of the last character.\n\t *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;\n }\n reset_VIsual_and_resel();\n return OK;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-126", "cwe_name": "Buffer Over-read", "description": "The software reads from a buffer using buffer access mechanisms such as indexes or pointers that reference memory locations after the targeted buffer.", "url": "https://cwe.mitre.org/data/definitions/126.html", "label_name": "vulnerable"} {"code": "SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,\n\t\tstruct rusage32 __user *, ur)\n{\n\tstruct rusage r;\n\tlong ret, err;\n\tmm_segment_t old_fs;\n\n\tif (!ur)\n\t\treturn sys_wait4(pid, ustatus, options, NULL);\n\n\told_fs = get_fs();\n\t\t\n\tset_fs (KERNEL_DS);\n\tret = sys_wait4(pid, ustatus, options, (struct rusage __user *) &r);\n\tset_fs (old_fs);\n\n\tif (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))\n\t\treturn -EFAULT;\n\n\terr = 0;\n\terr |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);\n\terr |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);\n\terr |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);\n\terr |= __put_user(r.ru_stime.tv_usec, &ur->ru_stime.tv_usec);\n\terr |= __put_user(r.ru_maxrss, &ur->ru_maxrss);\n\terr |= __put_user(r.ru_ixrss, &ur->ru_ixrss);\n\terr |= __put_user(r.ru_idrss, &ur->ru_idrss);\n\terr |= __put_user(r.ru_isrss, &ur->ru_isrss);\n\terr |= __put_user(r.ru_minflt, &ur->ru_minflt);\n\terr |= __put_user(r.ru_majflt, &ur->ru_majflt);\n\terr |= __put_user(r.ru_nswap, &ur->ru_nswap);\n\terr |= __put_user(r.ru_inblock, &ur->ru_inblock);\n\terr |= __put_user(r.ru_oublock, &ur->ru_oublock);\n\terr |= __put_user(r.ru_msgsnd, &ur->ru_msgsnd);\n\terr |= __put_user(r.ru_msgrcv, &ur->ru_msgrcv);\n\terr |= __put_user(r.ru_nsignals, &ur->ru_nsignals);\n\terr |= __put_user(r.ru_nvcsw, &ur->ru_nvcsw);\n\terr |= __put_user(r.ru_nivcsw, &ur->ru_nivcsw);\n\n\treturn err ? err : ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other)\n{\n\tint connected;\n\n\tconnected = unix_dgram_peer_wake_connect(sk, other);\n\n\tif (unix_recvq_full(other))\n\t\treturn 1;\n\n\tif (connected)\n\t\tunix_dgram_peer_wake_disconnect(sk, other);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "check_lnums(int do_curwin)\n{\n win_T\t*wp;\n tabpage_T\t*tp;\n\n FOR_ALL_TAB_WINDOWS(tp, wp)\n\tif ((do_curwin || wp != curwin) && wp->w_buffer == curbuf)\n\t{\n\t // save the original cursor position and topline\n\t wp->w_save_cursor.w_cursor_save = wp->w_cursor;\n\t wp->w_save_cursor.w_topline_save = wp->w_topline;\n\n\t if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t\twp->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t if (wp->w_topline > curbuf->b_ml.ml_line_count)\n\t\twp->w_topline = curbuf->b_ml.ml_line_count;\n\n\t // save the corrected cursor position and topline\n\t wp->w_save_cursor.w_cursor_corr = wp->w_cursor;\n\t wp->w_save_cursor.w_topline_corr = wp->w_topline;\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-122", "cwe_name": "Heap-based Buffer Overflow", "description": "A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().", "url": "https://cwe.mitre.org/data/definitions/122.html", "label_name": "vulnerable"} {"code": "void l2tp_packet_print(const struct l2tp_packet_t *pack,\n\t\t void (*print)(const char *fmt, ...))\n{\n\tconst struct l2tp_attr_t *attr;\n\tconst struct l2tp_dict_value_t *val;\n\n\tif (pack->hdr.ver == 2) {\n\t\tprint(\"[L2TP tid=%u sid=%u\", ntohs(pack->hdr.tid), ntohs(pack->hdr.sid));\n\t\tlog_ppp_debug(\" Ns=%u Nr=%u\", ntohs(pack->hdr.Ns), ntohs(pack->hdr.Nr));\n\t} else {\n\t\tprint(\"[L2TP cid=%u\", pack->hdr.cid);\n\t\tlog_ppp_debug(\" Ns=%u Nr=%u\", ntohs(pack->hdr.Ns), ntohs(pack->hdr.Nr));\n\t}\n\n\tlist_for_each_entry(attr, &pack->attrs, entry) {\n\t\tprint(\" <%s\", attr->attr->name);\n\t\tval = l2tp_dict_find_value(attr->attr, attr->val);\n\t\tif (val)\n\t\t\tprint(\" %s\", val->name);\n\t\telse if (attr->H)\n\t\t\tprint(\" (hidden, %hu bytes)\", attr->length);\n\t\telse {\n\t\t\tswitch (attr->attr->type) {\n\t\t\t\tcase ATTR_TYPE_INT16:\n\t\t\t\t\tprint(\" %i\", attr->val.int16);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ATTR_TYPE_INT32:\n\t\t\t\t\tprint(\" %i\", attr->val.int32);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ATTR_TYPE_STRING:\n\t\t\t\t\tprint(\" %s\", attr->val.string);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tprint(\">\");\n\t}\n\n\tprint(\"]\\n\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "void ZydisFormatterBufferInitTokenized(ZydisFormatterBuffer* buffer,\n ZydisFormatterToken** first_token, void* user_buffer, ZyanUSize length)\n{\n ZYAN_ASSERT(buffer);\n ZYAN_ASSERT(first_token);\n ZYAN_ASSERT(user_buffer);\n ZYAN_ASSERT(length);\n\n *first_token = user_buffer;\n (*first_token)->type = ZYDIS_TOKEN_INVALID;\n (*first_token)->next = 0;\n\n user_buffer = (ZyanU8*)user_buffer + sizeof(ZydisFormatterToken);\n length -= sizeof(ZydisFormatterToken);\n\n buffer->is_token_list = ZYAN_TRUE;\n buffer->capacity = length;\n buffer->string.flags = ZYAN_STRING_HAS_FIXED_CAPACITY;\n buffer->string.vector.allocator = ZYAN_NULL;\n buffer->string.vector.element_size = sizeof(char);\n buffer->string.vector.size = 1;\n buffer->string.vector.capacity = length;\n buffer->string.vector.data = user_buffer;\n *(char*)user_buffer = '\\0';\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-457", "cwe_name": "Use of Uninitialized Variable", "description": "The code uses a variable that has not been initialized, leading to unpredictable or unintended results.", "url": "https://cwe.mitre.org/data/definitions/457.html", "label_name": "vulnerable"} {"code": "static int jpc_siz_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate,\n jas_stream_t *in)\n{\n\tjpc_siz_t *siz = &ms->parms.siz;\n\tunsigned int i;\n\tuint_fast8_t tmp;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tif (jpc_getuint16(in, &siz->caps) ||\n\t jpc_getuint32(in, &siz->width) ||\n\t jpc_getuint32(in, &siz->height) ||\n\t jpc_getuint32(in, &siz->xoff) ||\n\t jpc_getuint32(in, &siz->yoff) ||\n\t jpc_getuint32(in, &siz->tilewidth) ||\n\t jpc_getuint32(in, &siz->tileheight) ||\n\t jpc_getuint32(in, &siz->tilexoff) ||\n\t jpc_getuint32(in, &siz->tileyoff) ||\n\t jpc_getuint16(in, &siz->numcomps)) {\n\t\treturn -1;\n\t}\n\tif (!siz->width || !siz->height || !siz->tilewidth ||\n\t !siz->tileheight || !siz->numcomps || siz->numcomps > 16384) {\n\t\treturn -1;\n\t}\n\tif (siz->tilexoff >= siz->width || siz->tileyoff >= siz->height) {\n\t\tjas_eprintf(\"all tiles are outside the image area\\n\");\n\t\treturn -1;\n\t}\n\tif (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {\n\t\treturn -1;\n\t}\n\tfor (i = 0; i < siz->numcomps; ++i) {\n\t\tif (jpc_getuint8(in, &tmp) ||\n\t\t jpc_getuint8(in, &siz->comps[i].hsamp) ||\n\t\t jpc_getuint8(in, &siz->comps[i].vsamp)) {\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tif (siz->comps[i].hsamp == 0 || siz->comps[i].hsamp > 255) {\n\t\t\tjas_eprintf(\"invalid XRsiz value %d\\n\", siz->comps[i].hsamp);\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tif (siz->comps[i].vsamp == 0 || siz->comps[i].vsamp > 255) {\n\t\t\tjas_eprintf(\"invalid YRsiz value %d\\n\", siz->comps[i].vsamp);\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tsiz->comps[i].sgnd = (tmp >> 7) & 1;\n\t\tsiz->comps[i].prec = (tmp & 0x7f) + 1;\n\t}\n\tif (jas_stream_eof(in)) {\n\t\tjas_free(siz->comps);\n\t\treturn -1;\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)\n{\n\tsize_t i, j;\n\tcdf_secid_t maxsector = (cdf_secid_t)((sat->sat_len * size)\n\t / sizeof(maxsector));\n\n\tDPRINTF((\"Chain:\"));\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tDPRINTF((\" %d\", sid));\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Counting chain loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\treturn (size_t)-1;\n\t\t}\n\t\tif (sid >= maxsector) {\n\t\t\tDPRINTF((\"Sector %d >= %d\\n\", sid, maxsector));\n\t\t\terrno = EFTYPE;\n\t\t\treturn (size_t)-1;\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);\n\t}\n\tif (i == 0) {\n\t\tDPRINTF((\" none, sid: %d\\n\", sid));\n\t\treturn (size_t)-1;\n\n\t}\n\tDPRINTF((\"\\n\"));\n\treturn i;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "RList *r_bin_ne_get_segments(r_bin_ne_obj_t *bin) {\n\tint i;\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_list_newf (free);\n\tfor (i = 0; i < bin->ne_header->SegCount; i++) {\n\t\tRBinSection *bs = R_NEW0 (RBinSection);\n\t\tif (!bs) {\n\t\t\treturn segments;\n\t\t}\n\t\tNE_image_segment_entry *se = &bin->segment_entries[i];\n\t\tbs->size = se->length;\n\t\tbs->vsize = se->minAllocSz ? se->minAllocSz : 64000;\n\t\tbs->bits = R_SYS_BITS_16;\n\t\tbs->is_data = se->flags & IS_DATA;\n\t\tbs->perm = __translate_perms (se->flags);\n\t\tbs->paddr = (ut64)se->offset * bin->alignment;\n\t\tbs->name = r_str_newf (\"%s.%\" PFMT64d, se->flags & IS_MOVEABLE ? \"MOVEABLE\" : \"FIXED\", bs->paddr);\n\t\tbs->is_segment = true;\n\t\tr_list_append (segments, bs);\n\t}\n\tbin->segments = segments;\n\treturn segments;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "int dns_packet_is_reply_for(DnsPacket *p, const DnsResourceKey *key) {\n int r;\n\n assert(p);\n assert(key);\n\n /* Checks if the specified packet is a reply for the specified\n * key and the specified key is the only one in the question\n * section. */\n\n if (DNS_PACKET_QR(p) != 1)\n return 0;\n\n /* Let's unpack the packet, if that hasn't happened yet. */\n r = dns_packet_extract(p);\n if (r < 0)\n return r;\n\n if (!p->question)\n return 0;\n\n if (p->question->n_keys != 1)\n return 0;\n\n return dns_resource_key_equal(p->question->keys[0], key);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "destroyPresentationContextList(LST_HEAD ** lst)\n{\n DUL_PRESENTATIONCONTEXT *pc;\n DUL_TRANSFERSYNTAX *ts;\n\n if ((lst == NULL) || (*lst == NULL))\n return;\n while ((pc = (DUL_PRESENTATIONCONTEXT*) LST_Dequeue(lst)) != NULL) {\n if (pc->proposedTransferSyntax != NULL) {\n while ((ts = (DUL_TRANSFERSYNTAX*) LST_Dequeue(&pc->proposedTransferSyntax)) != NULL) {\n free(ts);\n }\n LST_Destroy(&pc->proposedTransferSyntax);\n }\n free(pc);\n }\n LST_Destroy(lst);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-401", "cwe_name": "Missing Release of Memory after Effective Lifetime", "description": "The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.", "url": "https://cwe.mitre.org/data/definitions/401.html", "label_name": "vulnerable"} {"code": "static void controloptions (lua_State *L, int opt, const char **fmt,\n Header *h) {\n switch (opt) {\n case ' ': return; /* ignore white spaces */\n case '>': h->endian = BIG; return;\n case '<': h->endian = LITTLE; return;\n case '!': {\n int a = getnum(fmt, MAXALIGN);\n if (!isp2(a))\n luaL_error(L, \"alignment %d is not a power of 2\", a);\n h->align = a;\n return;\n }\n default: {\n const char *msg = lua_pushfstring(L, \"invalid format option '%c'\", opt);\n luaL_argerror(L, 1, msg);\n }\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void test_creat(const char *path)\n{\n\tif (creat(path, 0755) >= 0) {\n\t\tfprintf(stderr, \"leak at creat of %s\\n\", path);\n\t\texit(1);\n\t}\n\tif (errno != ENOENT && errno != ENOSYS) {\n\t\tfprintf(stderr, \"leak at creat of %s: errno was %s\\n\", path, strerror(errno));\n\t\texit(1);\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "PUBLIC bool updateFields(cchar *tableName, MprJson *params)\n{\n EdiRec *rec;\n cchar *key;\n\n key = mprLookupJson(params, \"id\");\n if ((rec = ediSetFields(ediReadRec(getDatabase(), tableName, key), params)) == 0) {\n return 0;\n }\n return updateRec(rec);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "smb_flush_file(struct smb_request *sr, struct smb_ofile *ofile)\n{\n\tsr->user_cr = smb_ofile_getcred(ofile);\n\n\tif ((ofile->f_node->flags & NODE_FLAGS_WRITE_THROUGH) == 0)\n\t\t(void) smb_fsop_commit(sr, sr->user_cr, ofile->f_node);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static void queue_delete(struct snd_seq_queue *q)\n{\n\t/* stop and release the timer */\n\tmutex_lock(&q->timer_mutex);\n\tsnd_seq_timer_stop(q->timer);\n\tsnd_seq_timer_close(q);\n\tmutex_unlock(&q->timer_mutex);\n\t/* wait until access free */\n\tsnd_use_lock_sync(&q->use_lock);\n\t/* release resources... */\n\tsnd_seq_prioq_delete(&q->tickq);\n\tsnd_seq_prioq_delete(&q->timeq);\n\tsnd_seq_timer_delete(&q->timer);\n\n\tkfree(q);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static void bt_for_each(struct blk_mq_hw_ctx *hctx,\n\t\tstruct blk_mq_bitmap_tags *bt, unsigned int off,\n\t\tbusy_iter_fn *fn, void *data, bool reserved)\n{\n\tstruct request *rq;\n\tint bit, i;\n\n\tfor (i = 0; i < bt->map_nr; i++) {\n\t\tstruct blk_align_bitmap *bm = &bt->map[i];\n\n\t\tfor (bit = find_first_bit(&bm->word, bm->depth);\n\t\t bit < bm->depth;\n\t\t bit = find_next_bit(&bm->word, bm->depth, bit + 1)) {\n\t\t\trq = hctx->tags->rqs[off + bit];\n\t\t\tif (rq->q == hctx->queue)\n\t\t\t\tfn(hctx, rq, data, reserved);\n\t\t}\n\n\t\toff += (1 << bt->bits_per_word);\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static inline int restore_fpu_checking(struct task_struct *tsk)\n{\n\t/* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception\n\t is pending. Clear the x87 state here by setting it to fixed\n\t values. \"m\" is a random variable that should be in L1 */\n\tif (unlikely(static_cpu_has(X86_FEATURE_FXSAVE_LEAK))) {\n\t\tasm volatile(\n\t\t\t\"fnclex\\n\\t\"\n\t\t\t\"emms\\n\\t\"\n\t\t\t\"fildl %P[addr]\"\t/* set F?P to defined value */\n\t\t\t: : [addr] \"m\" (tsk->thread.fpu.has_fpu));\n\t}\n\n\treturn fpu_restore_checking(&tsk->thread.fpu);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static gboolean irssi_ssl_verify(SSL *ssl, SSL_CTX *ctx, const char* hostname, X509 *cert)\n{\n\tif (SSL_get_verify_result(ssl) != X509_V_OK) {\n\t\tunsigned char md[EVP_MAX_MD_SIZE];\n\t\tunsigned int n;\n\t\tchar *str;\n\n\t\tg_warning(\"Could not verify SSL servers certificate:\");\n\t\tif ((str = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) == NULL)\n\t\t\tg_warning(\" Could not get subject-name from peer certificate\");\n\t\telse {\n\t\t\tg_warning(\" Subject : %s\", str);\n\t\t\tfree(str);\n\t\t}\n\t\tif ((str = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0)) == NULL)\n\t\t\tg_warning(\" Could not get issuer-name from peer certificate\");\n\t\telse {\n\t\t\tg_warning(\" Issuer : %s\", str);\n\t\t\tfree(str);\n\t\t}\n\t\tif (! X509_digest(cert, EVP_md5(), md, &n))\n\t\t\tg_warning(\" Could not get fingerprint from peer certificate\");\n\t\telse {\n\t\t\tchar hex[] = \"0123456789ABCDEF\";\n\t\t\tchar fp[EVP_MAX_MD_SIZE*3];\n\t\t\tif (n < sizeof(fp)) {\n\t\t\t\tunsigned int i;\n\t\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\t\tfp[i*3+0] = hex[(md[i] >> 4) & 0xF];\n\t\t\t\t\tfp[i*3+1] = hex[(md[i] >> 0) & 0xF];\n\t\t\t\t\tfp[i*3+2] = i == n - 1 ? '\\0' : ':';\n\t\t\t\t}\n\t\t\t\tg_warning(\" MD5 Fingerprint : %s\", fp);\n\t\t\t}\n\t\t}\n\t\treturn FALSE;\n\t} else if (! irssi_ssl_verify_hostname(cert, hostname)){\n\t\treturn FALSE;\n\t}\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *m, size_t total_len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint error = 0;\n\n\tif (sk->sk_state & PPPOX_BOUND) {\n\t\terror = -EIO;\n\t\tgoto end;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\tflags & MSG_DONTWAIT, &error);\n\tif (error < 0)\n\t\tgoto end;\n\n\tm->msg_namelen = 0;\n\n\tif (skb) {\n\t\ttotal_len = min_t(size_t, total_len, skb->len);\n\t\terror = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len);\n\t\tif (error == 0) {\n\t\t\tconsume_skb(skb);\n\t\t\treturn total_len;\n\t\t}\n\t}\n\n\tkfree_skb(skb);\nend:\n\treturn error;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "void CLASS foveon_load_camf()\n{\n unsigned type, wide, high, i, j, row, col, diff;\n ushort huff[1024], vpred[2][2] = {{512,512},{512,512}}, hpred[2];\n\n fseek (ifp, meta_offset, SEEK_SET);\n type = get4(); get4(); get4();\n wide = get4();\n high = get4();\n#ifdef LIBRAW_LIBRARY_BUILD\n if(wide>32767 || high > 32767 || wide*high > 20000000)\n throw LIBRAW_EXCEPTION_IO_CORRUPT;\n#endif\n if (type == 2) {\n fread (meta_data, 1, meta_length, ifp);\n for (i=0; i < meta_length; i++) {\n high = (high * 1597 + 51749) % 244944;\n wide = high * (INT64) 301593171 >> 24;\n meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17;\n }\n } else if (type == 4) {\n free (meta_data);\n meta_data = (char *) malloc (meta_length = wide*high*3/2);\n merror (meta_data, \"foveon_load_camf()\");\n foveon_huff (huff);\n get4();\n getbits(-1);\n for (j=row=0; row < high; row++) {\n for (col=0; col < wide; col++) {\n\tdiff = ljpeg_diff(huff);\n\tif (col < 2) hpred[col] = vpred[row & 1][col] += diff;\n\telse hpred[col & 1] += diff;\n\tif (col & 1) {\n\t meta_data[j++] = hpred[0] >> 4;\n\t meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8;\n\t meta_data[j++] = hpred[1];\n }\n }\n }\n } else\n fprintf (stderr,_(\"%s has unknown CAMF type %d.\\n\"), ifname, type);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,\n\tstruct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint copied;\n\tint err = 0;\n\n\tlock_sock(sk);\n\t/*\n\t * \tThis works for seqpacket too. The receiver has ordered the\n\t *\tqueue for us! We do one quick check first though\n\t */\n\tif (sk->sk_type == SOCK_SEQPACKET && sk->sk_state != TCP_ESTABLISHED) {\n\t\terr = -ENOTCONN;\n\t\tgoto out;\n\t}\n\n\t/* Now we can treat all alike */\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\tflags & MSG_DONTWAIT, &err);\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tif (!ax25_sk(sk)->pidincl)\n\t\tskb_pull(skb, 1);\t\t/* Remove PID */\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\tskb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tif (msg->msg_namelen != 0) {\n\t\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\t\tax25_digi digi;\n\t\tax25_address src;\n\t\tconst unsigned char *mac = skb_mac_header(skb);\n\n\t\tmemset(sax, 0, sizeof(struct full_sockaddr_ax25));\n\t\tax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL,\n\t\t\t\t&digi, NULL, NULL);\n\t\tsax->sax25_family = AF_AX25;\n\t\t/* We set this correctly, even though we may not let the\n\t\t application know the digi calls further down (because it\n\t\t did NOT ask to know them). This could get political... **/\n\t\tsax->sax25_ndigis = digi.ndigi;\n\t\tsax->sax25_call = src;\n\n\t\tif (sax->sax25_ndigis != 0) {\n\t\t\tint ct;\n\t\t\tstruct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)sax;\n\n\t\t\tfor (ct = 0; ct < digi.ndigi; ct++)\n\t\t\t\tfsa->fsa_digipeater[ct] = digi.calls[ct];\n\t\t}\n\t\tmsg->msg_namelen = sizeof(struct full_sockaddr_ax25);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\terr = copied;\n\nout:\n\trelease_sock(sk);\n\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int check_submodule_url(const char *url)\n{\n\tconst char *curl_url;\n\n\tif (looks_like_command_line_option(url))\n\t\treturn -1;\n\n\tif (submodule_url_is_relative(url)) {\n\t\t/*\n\t\t * This could be appended to an http URL and url-decoded;\n\t\t * check for malicious characters.\n\t\t */\n\t\tchar *decoded = url_decode(url);\n\t\tint has_nl = !!strchr(decoded, '\\n');\n\t\tfree(decoded);\n\t\tif (has_nl)\n\t\t\treturn -1;\n\t}\n\n\telse if (url_to_curl_url(url, &curl_url)) {\n\t\tstruct credential c = CREDENTIAL_INIT;\n\t\tint ret = credential_from_url_gently(&c, curl_url, 1);\n\t\tcredential_clear(&c);\n\t\treturn ret;\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-522", "cwe_name": "Insufficiently Protected Credentials", "description": "The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.", "url": "https://cwe.mitre.org/data/definitions/522.html", "label_name": "vulnerable"} {"code": "qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t const char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_err(\"[%s]:[%s:%d]:%d: %pV\", dev_name(&qedi->pdev->dev),\n\t\t func, line, qedi->host_no, &vaf);\n\telse\n\t\tpr_err(\"[0000:00:00.0]:[%s:%d]: %pV\", func, line, &vaf);\n\n\tva_end(va);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "header_read (SF_PRIVATE *psf, void *ptr, int bytes)\n{\tint count = 0 ;\n\n\tif (psf->header.indx + bytes >= psf->header.len && psf_bump_header_allocation (psf, bytes))\n\t\treturn count ;\n\n\tif (psf->header.indx + bytes > psf->header.end)\n\t{\tcount = psf_fread (psf->header.ptr + psf->header.end, 1, bytes - (psf->header.end - psf->header.indx), psf) ;\n\t\tif (count != bytes - (int) (psf->header.end - psf->header.indx))\n\t\t{\tpsf_log_printf (psf, \"Error : psf_fread returned short count.\\n\") ;\n\t\t\treturn count ;\n\t\t\t} ;\n\t\tpsf->header.end += count ;\n\t\t} ;\n\n\tmemcpy (ptr, psf->header.ptr + psf->header.indx, bytes) ;\n\tpsf->header.indx += bytes ;\n\n\treturn bytes ;\n} /* header_read */", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int bad_format_imginfo(char *fmt){\n return bad_format_check(\"^\" SAFE_STRING \"%s\" SAFE_STRING \"%lu\" SAFE_STRING \"%lu\" SAFE_STRING \"$\",fmt);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": "__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,\n\t\t\t\t __be16 sport, __be16 dport)\n{\n\tu32 secret[MD5_MESSAGE_BYTES / 4];\n\tu32 hash[MD5_DIGEST_WORDS];\n\tu32 i;\n\n\tmemcpy(hash, saddr, 16);\n\tfor (i = 0; i < 4; i++)\n\t\tsecret[i] = net_secret[i] + daddr[i];\n\tsecret[4] = net_secret[4] +\n\t\t(((__force u16)sport << 16) + (__force u16)dport);\n\tfor (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)\n\t\tsecret[i] = net_secret[i];\n\n\tmd5_transform(hash, secret);\n\n\treturn seq_scale(hash[0]);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static void utee_param_to_param(struct tee_ta_param *p, struct utee_params *up)\n{\n\tsize_t n;\n\tuint32_t types = up->types;\n\n\tp->types = types;\n\tfor (n = 0; n < TEE_NUM_PARAMS; n++) {\n\t\tuintptr_t a = up->vals[n * 2];\n\t\tsize_t b = up->vals[n * 2 + 1];\n\n\t\tswitch (TEE_PARAM_TYPE_GET(types, n)) {\n\t\tcase TEE_PARAM_TYPE_MEMREF_INPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_OUTPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_INOUT:\n\t\t\tp->u[n].mem.mobj = &mobj_virt;\n\t\t\tp->u[n].mem.offs = a;\n\t\t\tp->u[n].mem.size = b;\n\t\t\tbreak;\n\t\tcase TEE_PARAM_TYPE_VALUE_INPUT:\n\t\tcase TEE_PARAM_TYPE_VALUE_INOUT:\n\t\t\tp->u[n].val.a = a;\n\t\t\tp->u[n].val.b = b;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmemset(&p->u[n], 0, sizeof(p->u[n]));\n\t\t\tbreak;\n\t\t}\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int mount_entry_on_relative_rootfs(struct mntent *mntent,\n\t\t\t\t\t const char *rootfs)\n{\n\tchar path[MAXPATHLEN];\n\tint ret;\n\n\t/* relative to root mount point */\n\tret = snprintf(path, sizeof(path), \"%s/%s\", rootfs, mntent->mnt_dir);\n\tif (ret >= sizeof(path)) {\n\t\tERROR(\"path name too long\");\n\t\treturn -1;\n\t}\n\n\treturn mount_entry_on_generic(mntent, path, rootfs);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,\n\t\t\t\tsize_t msg_len)\n{\n\tstruct sock *sk = asoc->base.sk;\n\tint err = 0;\n\tlong current_timeo = *timeo_p;\n\tDEFINE_WAIT(wait);\n\n\tpr_debug(\"%s: asoc:%p, timeo:%ld, msg_len:%zu\\n\", __func__, asoc,\n\t\t *timeo_p, msg_len);\n\n\t/* Increment the association's refcnt. */\n\tsctp_association_hold(asoc);\n\n\t/* Wait on the association specific sndbuf space. */\n\tfor (;;) {\n\t\tprepare_to_wait_exclusive(&asoc->wait, &wait,\n\t\t\t\t\t TASK_INTERRUPTIBLE);\n\t\tif (!*timeo_p)\n\t\t\tgoto do_nonblock;\n\t\tif (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||\n\t\t asoc->base.dead)\n\t\t\tgoto do_error;\n\t\tif (signal_pending(current))\n\t\t\tgoto do_interrupted;\n\t\tif (msg_len <= sctp_wspace(asoc))\n\t\t\tbreak;\n\n\t\t/* Let another process have a go. Since we are going\n\t\t * to sleep anyway.\n\t\t */\n\t\trelease_sock(sk);\n\t\tcurrent_timeo = schedule_timeout(current_timeo);\n\t\tif (sk != asoc->base.sk)\n\t\t\tgoto do_error;\n\t\tlock_sock(sk);\n\n\t\t*timeo_p = current_timeo;\n\t}\n\nout:\n\tfinish_wait(&asoc->wait, &wait);\n\n\t/* Release the association's refcnt. */\n\tsctp_association_put(asoc);\n\n\treturn err;\n\ndo_error:\n\terr = -EPIPE;\n\tgoto out;\n\ndo_interrupted:\n\terr = sock_intr_errno(*timeo_p);\n\tgoto out;\n\ndo_nonblock:\n\terr = -EAGAIN;\n\tgoto out;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static void enable_nmi_window(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\n\tif ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK))\n\t == HF_NMI_MASK)\n\t\treturn; /* IRET will cause a vm exit */\n\n\t/*\n\t * Something prevents NMI from been injected. Single step over possible\n\t * problem (IRET or exception injection or interrupt shadow)\n\t */\n\tsvm->nmi_singlestep = true;\n\tsvm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);\n\tupdate_db_bp_intercept(vcpu);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "static int read_public_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I1012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = MIN(file->size, sizeof buf);\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_public_key(p, keysize, rsa);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "SPL_METHOD(SplFileInfo, getFilename)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tint path_len;\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tspl_filesystem_object_get_path(intern, &path_len TSRMLS_CC);\n\t\n\tif (path_len && path_len < intern->file_name_len) {\n\t\tRETURN_STRINGL(intern->file_name + path_len + 1, intern->file_name_len - (path_len + 1), 1);\n\t} else {\n\t\tRETURN_STRINGL(intern->file_name, intern->file_name_len, 1);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus EvalQuantized(TfLiteContext* context, TfLiteNode* node,\n OpData* data, const RuntimeShape& lhs_shape,\n const TfLiteTensor* lhs,\n const RuntimeShape& rhs_shape,\n const TfLiteTensor* rhs, TfLiteTensor* output) {\n if (lhs->type == kTfLiteFloat32) {\n TfLiteTensor* input_quantized = GetTemporary(context, node, /*index=*/2);\n TfLiteTensor* scaling_factors = GetTemporary(context, node, /*index=*/3);\n TfLiteTensor* accum_scratch = GetTemporary(context, node, /*index=*/4);\n TfLiteTensor* input_offsets = GetTemporary(context, node, /*index=*/5);\n TfLiteTensor* row_sums = GetTemporary(context, node, /*index=*/6);\n return EvalHybrid(\n context, node, data, lhs_shape, lhs, rhs_shape, rhs, input_quantized,\n scaling_factors, accum_scratch, row_sums, input_offsets, output);\n } else if (lhs->type == kTfLiteInt8) {\n return EvalInt8(context, data, lhs_shape, lhs, rhs_shape, rhs,\n GetTensorShape(output), output);\n } else {\n TF_LITE_KERNEL_LOG(\n context, \"Currently only hybrid and int8 quantization is supported.\\n\");\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "cpStripToTile(uint8* out, uint8* in,\n uint32 rows, uint32 cols, int outskew, int64 inskew)\n{\n\twhile (rows-- > 0) {\n\t\tuint32 j = cols;\n\t\twhile (j-- > 0)\n\t\t\t*out++ = *in++;\n\t\tout += outskew;\n\t\tin += inskew;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateIntArray(const int *numbers,int count)\t\t{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,\n\t\t\t struct flowi *fl,\n\t\t\t struct request_sock *req,\n\t\t\t struct tcp_fastopen_cookie *foc,\n\t\t\t bool attach_req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct flowi6 *fl6 = &fl->u.ip6;\n\tstruct sk_buff *skb;\n\tint err = -ENOMEM;\n\n\t/* First, grab a route. */\n\tif (!dst && (dst = inet6_csk_route_req(sk, fl6, req,\n\t\t\t\t\t IPPROTO_TCP)) == NULL)\n\t\tgoto done;\n\n\tskb = tcp_make_synack(sk, dst, req, foc, attach_req);\n\n\tif (skb) {\n\t\t__tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr,\n\t\t\t\t &ireq->ir_v6_rmt_addr);\n\n\t\tfl6->daddr = ireq->ir_v6_rmt_addr;\n\t\tif (np->repflow && ireq->pktopts)\n\t\t\tfl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts));\n\n\t\terr = ip6_xmit(sk, skb, fl6, np->opt, np->tclass);\n\t\terr = net_xmit_eval(err);\n\t}\n\ndone:\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)\n{\n\twhile (elements-- > 0) {\n\t\tzval key, *data, d, *old_data;\n\t\tzend_ulong idx;\n\n\t\tZVAL_UNDEF(&key);\n\n\t\tif (!php_var_unserialize_internal(&key, p, max, NULL, classes)) {\n\t\t\tzval_dtor(&key);\n\t\t\treturn 0;\n\t\t}\n\n\t\tdata = NULL;\n\t\tZVAL_UNDEF(&d);\n\n\t\tif (!objprops) {\n\t\t\tif (Z_TYPE(key) == IS_LONG) {\n\t\t\t\tidx = Z_LVAL(key);\nnumeric_key:\n\t\t\t\tif (UNEXPECTED((old_data = zend_hash_index_find(ht, idx)) != NULL)) {\n\t\t\t\t\t//??? update hash\n\t\t\t\t\tvar_push_dtor(var_hash, old_data);\n\t\t\t\t\tdata = zend_hash_index_update(ht, idx, &d);\n\t\t\t\t} else {\n\t\t\t\t\tdata = zend_hash_index_add_new(ht, idx, &d);\n\t\t\t\t}\n\t\t\t} else if (Z_TYPE(key) == IS_STRING) {\n\t\t\t\tif (UNEXPECTED(ZEND_HANDLE_NUMERIC(Z_STR(key), idx))) {\n\t\t\t\t\tgoto numeric_key;\n\t\t\t\t}\n\t\t\t\tif (UNEXPECTED((old_data = zend_hash_find(ht, Z_STR(key))) != NULL)) {\n\t\t\t\t\t//??? update hash\n\t\t\t\t\tvar_push_dtor(var_hash, old_data);\n\t\t\t\t\tdata = zend_hash_update(ht, Z_STR(key), &d);\n\t\t\t\t} else {\n\t\t\t\t\tdata = zend_hash_add_new(ht, Z_STR(key), &d);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tzval_dtor(&key);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t} else {\n\t\t\tif (EXPECTED(Z_TYPE(key) == IS_STRING)) {\nstring_key:\n\t\t\t\tif ((old_data = zend_hash_find(ht, Z_STR(key))) != NULL) {\n\t\t\t\t\tif (Z_TYPE_P(old_data) == IS_INDIRECT) {\n\t\t\t\t\t\told_data = Z_INDIRECT_P(old_data);\n\t\t\t\t\t}\n\t\t\t\t\tvar_push_dtor(var_hash, old_data);\n\t\t\t\t\tdata = zend_hash_update_ind(ht, Z_STR(key), &d);\n\t\t\t\t} else {\n\t\t\t\t\tdata = zend_hash_add_new(ht, Z_STR(key), &d);\n\t\t\t\t}\n\t\t\t} else if (Z_TYPE(key) == IS_LONG) {\n\t\t\t\t/* object properties should include no integers */\n\t\t\t\tconvert_to_string(&key);\n\t\t\t\tgoto string_key;\n\t\t\t} else {\n\t\t\t\tzval_dtor(&key);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tif (!php_var_unserialize_internal(data, p, max, var_hash, classes)) {\n\t\t\tzval_dtor(&key);\n\t\t\treturn 0;\n\t\t}\n\n\t\tvar_push_dtor(var_hash, data);\n\t\tzval_dtor(&key);\n\n\t\tif (elements && *(*p-1) != ';' && *(*p-1) != '}') {\n\t\t\t(*p)--;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr,\n\t\tunsigned long end, int write, struct page **pages, int *nr)\n{\n\tstruct page *head, *page;\n\tint refs;\n\n\tif (!pud_access_permitted(orig, write))\n\t\treturn 0;\n\n\tif (pud_devmap(orig))\n\t\treturn __gup_device_huge_pud(orig, pudp, addr, end, pages, nr);\n\n\trefs = 0;\n\tpage = pud_page(orig) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);\n\tdo {\n\t\tpages[*nr] = page;\n\t\t(*nr)++;\n\t\tpage++;\n\t\trefs++;\n\t} while (addr += PAGE_SIZE, addr != end);\n\n\thead = compound_head(pud_page(orig));\n\tif (!page_cache_add_speculative(head, refs)) {\n\t\t*nr -= refs;\n\t\treturn 0;\n\t}\n\n\tif (unlikely(pud_val(orig) != pud_val(*pudp))) {\n\t\t*nr -= refs;\n\t\twhile (refs--)\n\t\t\tput_page(head);\n\t\treturn 0;\n\t}\n\n\tSetPageReferenced(head);\n\treturn 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int jas_iccputsint(jas_stream_t *out, int n, longlong val)\n{\n\tulonglong tmp;\n\ttmp = (val < 0) ? (abort(), 0) : val;\n\treturn jas_iccputuint(out, n, tmp);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static void clear_evtchn_to_irq_row(unsigned row)\n{\n\tunsigned col;\n\n\tfor (col = 0; col < EVTCHN_PER_ROW; col++)\n\t\tevtchn_to_irq[row][col] = -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "cdf_read_short_sector_chain(const cdf_header_t *h,\n const cdf_sat_t *ssat, const cdf_stream_t *sst,\n cdf_secid_t sid, size_t len, cdf_stream_t *scn)\n{\n\tsize_t ss = CDF_SEC_SIZE(h), i, j;\n\tscn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));\n\tscn->sst_dirlen = len;\n\n\tif (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)\n\t\treturn -1;\n\n\tscn->sst_tab = calloc(scn->sst_len, ss);\n\tif (scn->sst_tab == NULL)\n\t\treturn -1;\n\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read short sector chain loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (i >= scn->sst_len) {\n\t\t\tDPRINTF((\"Out of bounds reading short sector chain \"\n\t\t\t \"%\" SIZE_T_FORMAT \"u > %\" SIZE_T_FORMAT \"u\\n\",\n\t\t\t i, scn->sst_len));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,\n\t\t sid) != (ssize_t)ss) {\n\t\t\tDPRINTF((\"Reading short sector chain %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);\n\t}\n\treturn 0;\nout:\n\tfree(scn->sst_tab);\n\treturn -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void perf_event_reset(struct perf_event *event)\n{\n\t(void)perf_event_read(event);\n\tlocal64_set(&event->count, 0);\n\tperf_event_update_userpage(event);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "static UINT parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)\n{\n\tchar* path = NULL;\n\tint status;\n\tUINT32 PathLength;\n\tStream_Seek(irp->input, 28);\n\t/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */\n\t/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */\n\tStream_Read_UINT32(irp->input, PathLength);\n\tstatus = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)Stream_Pointer(irp->input), PathLength / 2,\n\t &path, 0, NULL, NULL);\n\n\tif (status < 1)\n\t\tif (!(path = (char*)calloc(1, 1)))\n\t\t{\n\t\t\tWLog_ERR(TAG, \"calloc failed!\");\n\t\t\treturn CHANNEL_RC_NO_MEMORY;\n\t\t}\n\n\tparallel->id = irp->devman->id_sequence++;\n\tparallel->file = open(parallel->path, O_RDWR);\n\n\tif (parallel->file < 0)\n\t{\n\t\tirp->IoStatus = STATUS_ACCESS_DENIED;\n\t\tparallel->id = 0;\n\t}\n\telse\n\t{\n\t\t/* all read and write operations should be non-blocking */\n\t\tif (fcntl(parallel->file, F_SETFL, O_NONBLOCK) == -1)\n\t\t{\n\t\t}\n\t}\n\n\tStream_Write_UINT32(irp->output, parallel->id);\n\tStream_Write_UINT8(irp->output, 0);\n\tfree(path);\n\treturn irp->Complete(irp);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int dbd_db_login(SV* dbh, imp_dbh_t* imp_dbh, char* dbname, char* user,\n\t\t char* password) {\n#ifdef dTHR\n dTHR;\n#endif\n dTHX; \n D_imp_xxh(dbh);\n\n if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)\n PerlIO_printf(DBIc_LOGPIO(imp_xxh),\n\t\t \"imp_dbh->connect: dsn = %s, uid = %s, pwd = %s\\n\",\n\t\t dbname ? dbname : \"NULL\",\n\t\t user ? user : \"NULL\",\n\t\t password ? password : \"NULL\");\n\n imp_dbh->stats.auto_reconnects_ok= 0;\n imp_dbh->stats.auto_reconnects_failed= 0;\n imp_dbh->bind_type_guessing= FALSE;\n imp_dbh->bind_comment_placeholders= FALSE;\n imp_dbh->has_transactions= TRUE;\n /* Safer we flip this to TRUE perl side if we detect a mod_perl env. */\n imp_dbh->auto_reconnect = FALSE;\n\n /* HELMUT */\n#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION\n imp_dbh->enable_utf8 = FALSE; /* initialize mysql_enable_utf8 */\n#endif\n\n if (!my_login(aTHX_ dbh, imp_dbh))\n {\n do_error(dbh, mysql_errno(imp_dbh->pmysql),\n mysql_error(imp_dbh->pmysql) ,mysql_sqlstate(imp_dbh->pmysql));\n return FALSE;\n }\n\n /*\n * Tell DBI, that dbh->disconnect should be called for this handle\n */\n DBIc_ACTIVE_on(imp_dbh);\n\n /* Tell DBI, that dbh->destroy should be called for this handle */\n DBIc_on(imp_dbh, DBIcf_IMPSET);\n\n return TRUE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static void disk_seqf_stop(struct seq_file *seqf, void *v)\n{\n\tstruct class_dev_iter *iter = seqf->private;\n\n\t/* stop is called even after start failed :-( */\n\tif (iter) {\n\t\tclass_dev_iter_exit(iter);\n\t\tkfree(iter);\n\t\tseqf->private = NULL;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)\n{\n\treturn F2FS_M_SB(page->mapping);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,\n\t\t\t size_t sec_attr_len)\n{\n\tu8 *tmp;\n\tif (!sc_file_valid(file)) {\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\t}\n\n\tif (sec_attr == NULL) {\n\t\tif (file->sec_attr != NULL)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn 0;\n\t }\n\ttmp = (u8 *) realloc(file->sec_attr, sec_attr_len);\n\tif (!tmp) {\n\t\tif (file->sec_attr)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\tfile->sec_attr = tmp;\n\tmemcpy(file->sec_attr, sec_attr, sec_attr_len);\n\tfile->sec_attr_len = sec_attr_len;\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static inline int init_new_context(struct task_struct *tsk,\n\t\t\t\t struct mm_struct *mm)\n{\n\tcpumask_clear(&mm->context.cpu_attach_mask);\n\tatomic_set(&mm->context.attach_count, 0);\n\tmm->context.flush_mm = 0;\n\tmm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;\n\tmm->context.asce_bits |= _ASCE_TYPE_REGION3;\n#ifdef CONFIG_PGSTE\n\tmm->context.alloc_pgste = page_table_allocate_pgste;\n\tmm->context.has_pgste = 0;\n\tmm->context.use_skey = 0;\n#endif\n\tmm->context.asce_limit = STACK_TOP_MAX;\n\tcrst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int check_swap_activate(struct file *swap_file, unsigned int max)\n{\n\tstruct address_space *mapping = swap_file->f_mapping;\n\tstruct inode *inode = mapping->host;\n\tunsigned blocks_per_page;\n\tunsigned long page_no;\n\tunsigned blkbits;\n\tsector_t probe_block;\n\tsector_t last_block;\n\tsector_t lowest_block = -1;\n\tsector_t highest_block = 0;\n\n\tblkbits = inode->i_blkbits;\n\tblocks_per_page = PAGE_SIZE >> blkbits;\n\n\t/*\n\t * Map all the blocks into the extent list. This code doesn't try\n\t * to be very smart.\n\t */\n\tprobe_block = 0;\n\tpage_no = 0;\n\tlast_block = i_size_read(inode) >> blkbits;\n\twhile ((probe_block + blocks_per_page) <= last_block && page_no < max) {\n\t\tunsigned block_in_page;\n\t\tsector_t first_block;\n\n\t\tcond_resched();\n\n\t\tfirst_block = bmap(inode, probe_block);\n\t\tif (first_block == 0)\n\t\t\tgoto bad_bmap;\n\n\t\t/*\n\t\t * It must be PAGE_SIZE aligned on-disk\n\t\t */\n\t\tif (first_block & (blocks_per_page - 1)) {\n\t\t\tprobe_block++;\n\t\t\tgoto reprobe;\n\t\t}\n\n\t\tfor (block_in_page = 1; block_in_page < blocks_per_page;\n\t\t\t\t\tblock_in_page++) {\n\t\t\tsector_t block;\n\n\t\t\tblock = bmap(inode, probe_block + block_in_page);\n\t\t\tif (block == 0)\n\t\t\t\tgoto bad_bmap;\n\t\t\tif (block != first_block + block_in_page) {\n\t\t\t\t/* Discontiguity */\n\t\t\t\tprobe_block++;\n\t\t\t\tgoto reprobe;\n\t\t\t}\n\t\t}\n\n\t\tfirst_block >>= (PAGE_SHIFT - blkbits);\n\t\tif (page_no) {\t/* exclude the header page */\n\t\t\tif (first_block < lowest_block)\n\t\t\t\tlowest_block = first_block;\n\t\t\tif (first_block > highest_block)\n\t\t\t\thighest_block = first_block;\n\t\t}\n\n\t\tpage_no++;\n\t\tprobe_block += blocks_per_page;\nreprobe:\n\t\tcontinue;\n\t}\n\treturn 0;\n\nbad_bmap:\n\tpr_err(\"swapon: swapfile has holes\\n\");\n\treturn -EINVAL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)\n{\n\tstruct sockaddr_rc sa;\n\tstruct sock *sk = sock->sk;\n\tint len, err = 0;\n\n\tif (!addr || addr->sa_family != AF_BLUETOOTH)\n\t\treturn -EINVAL;\n\n\tmemset(&sa, 0, sizeof(sa));\n\tlen = min_t(unsigned int, sizeof(sa), addr_len);\n\tmemcpy(&sa, addr, len);\n\n\tBT_DBG(\"sk %p %pMR\", sk, &sa.rc_bdaddr);\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state != BT_OPEN) {\n\t\terr = -EBADFD;\n\t\tgoto done;\n\t}\n\n\tif (sk->sk_type != SOCK_STREAM) {\n\t\terr = -EINVAL;\n\t\tgoto done;\n\t}\n\n\twrite_lock(&rfcomm_sk_list.lock);\n\n\tif (sa.rc_channel &&\n\t __rfcomm_get_listen_sock_by_addr(sa.rc_channel, &sa.rc_bdaddr)) {\n\t\terr = -EADDRINUSE;\n\t} else {\n\t\t/* Save source address */\n\t\tbacpy(&rfcomm_pi(sk)->src, &sa.rc_bdaddr);\n\t\trfcomm_pi(sk)->channel = sa.rc_channel;\n\t\tsk->sk_state = BT_BOUND;\n\t}\n\n\twrite_unlock(&rfcomm_sk_list.lock);\n\ndone:\n\trelease_sock(sk);\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "mark_op_resolved (FlatpakTransactionOperation *op,\n const char *commit,\n GFile *sideload_path,\n GBytes *metadata,\n GBytes *old_metadata)\n{\n g_debug (\"marking op %s:%s resolved to %s\", kind_to_str (op->kind), flatpak_decomposed_get_ref (op->ref), commit ? commit : \"-\");\n\n g_assert (op != NULL);\n\n g_assert (commit != NULL);\n\n op->resolved = TRUE;\n\n if (op->resolved_commit != commit)\n {\n g_free (op->resolved_commit); /* This is already set if we retry resolving to get a token, so free first */\n op->resolved_commit = g_strdup (commit);\n }\n\n if (sideload_path)\n op->resolved_sideload_path = g_object_ref (sideload_path);\n\n if (metadata)\n {\n g_autoptr(GKeyFile) metakey = g_key_file_new ();\n if (g_key_file_load_from_bytes (metakey, metadata, G_KEY_FILE_NONE, NULL))\n {\n op->resolved_metadata = g_bytes_ref (metadata);\n op->resolved_metakey = g_steal_pointer (&metakey);\n }\n else\n g_message (\"Warning: Failed to parse metadata for %s\\n\", flatpak_decomposed_get_ref (op->ref));\n }\n if (old_metadata)\n {\n g_autoptr(GKeyFile) metakey = g_key_file_new ();\n if (g_key_file_load_from_bytes (metakey, old_metadata, G_KEY_FILE_NONE, NULL))\n {\n op->resolved_old_metadata = g_bytes_ref (old_metadata);\n op->resolved_old_metakey = g_steal_pointer (&metakey);\n }\n else\n g_message (\"Warning: Failed to parse old metadata for %s\\n\", flatpak_decomposed_get_ref (op->ref));\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "vulnerable"} {"code": "static int put_chars(u32 vtermno, const char *buf, int count)\n{\n\tstruct port *port;\n\tstruct scatterlist sg[1];\n\tvoid *data;\n\tint ret;\n\n\tif (unlikely(early_put_chars))\n\t\treturn early_put_chars(vtermno, buf, count);\n\n\tport = find_port_by_vtermno(vtermno);\n\tif (!port)\n\t\treturn -EPIPE;\n\n\tdata = kmemdup(buf, count, GFP_ATOMIC);\n\tif (!data)\n\t\treturn -ENOMEM;\n\n\tsg_init_one(sg, data, count);\n\tret = __send_to_port(port, sg, 1, count, data, false);\n\tkfree(data);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static void print_buttons(HttpRequest req, HttpResponse res, Service_T s) {\n if (is_readonly(req)) {\n // A read-only REMOTE_USER does not get access to these buttons\n return;\n }\n StringBuffer_append(res->outputbuffer, \"\");\n /* Start program */\n if (s->start)\n StringBuffer_append(res->outputbuffer,\n \"\", s->name);\n /* Stop program */\n if (s->stop)\n StringBuffer_append(res->outputbuffer,\n \"\", s->name);\n /* Restart program */\n if ((s->start && s->stop) || s->restart)\n StringBuffer_append(res->outputbuffer,\n \"\", s->name);\n /* (un)monitor */\n StringBuffer_append(res->outputbuffer,\n \"
    \"\n \"\"\n \"
    \"\n \"\"\n \"
    \"\n \"\"\n \"
    \"\n \"\"\n \"
    \",\n s->name,\n s->monitor ? \"unmonitor\" : \"monitor\",\n s->monitor ? \"Disable monitoring\" : \"Enable monitoring\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "static int proc_dmesg_restrict(struct ctl_table *table, int write,\n\t\t\t\tvoid __user *buffer, size_t *lenp, loff_t *ppos)\n{\n\tif (write && !capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\treturn proc_dointvec_minmax(table, write, buffer, lenp, ppos);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "pci_get_vdev_info(int slot)\n{\n\tstruct businfo *bi;\n\tstruct slotinfo *si;\n\tstruct pci_vdev *dev = NULL;\n\n\tbi = pci_businfo[0];\n\tassert(bi != NULL);\n\n\tsi = &bi->slotinfo[slot];\n\tif (si != NULL)\n\t\tdev = si->si_funcs[0].fi_devi;\n\telse\n\t\tfprintf(stderr, \"slot=%d is empty!\\n\", slot);\n\n\treturn dev;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,\n\t\t\t\tvoid __user *buffer, size_t *lenp,\n\t\t\t\tloff_t *ppos)\n{\n\tint ret = proc_dointvec(table, write, buffer, lenp, ppos);\n\n\tif (ret || !write)\n\t\treturn ret;\n\n\tif (sysctl_perf_cpu_time_max_percent == 100 ||\n\t sysctl_perf_cpu_time_max_percent == 0) {\n\t\tprintk(KERN_WARNING\n\t\t \"perf: Dynamic interrupt throttling disabled, can hang your system!\\n\");\n\t\tWRITE_ONCE(perf_sample_allowed_ns, 0);\n\t} else {\n\t\tupdate_perf_cpu_limits();\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,\n\t\tstruct nfsd3_setaclargs *argp,\n\t\tstruct nfsd3_attrstat *resp)\n{\n\tstruct inode *inode;\n\tsvc_fh *fh;\n\t__be32 nfserr = 0;\n\tint error;\n\n\tfh = fh_copy(&resp->fh, &argp->fh);\n\tnfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);\n\tif (nfserr)\n\t\tgoto out;\n\n\tinode = d_inode(fh->fh_dentry);\n\tif (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {\n\t\terror = -EOPNOTSUPP;\n\t\tgoto out_errno;\n\t}\n\n\terror = fh_want_write(fh);\n\tif (error)\n\t\tgoto out_errno;\n\n\terror = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);\n\tif (error)\n\t\tgoto out_drop_write;\n\terror = inode->i_op->set_acl(inode, argp->acl_default,\n\t\t\t\t ACL_TYPE_DEFAULT);\n\nout_drop_write:\n\tfh_drop_write(fh);\nout_errno:\n\tnfserr = nfserrno(error);\nout:\n\t/* argp->acl_{access,default} may have been allocated in\n\t nfs3svc_decode_setaclargs. */\n\tposix_acl_release(argp->acl_access);\n\tposix_acl_release(argp->acl_default);\n\tRETURN_STATUS(nfserr);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "vulnerable"} {"code": "void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) {\n int i;\n int nextra = ci->u.l.nextraargs;\n if (wanted < 0) {\n wanted = nextra; /* get all extra arguments available */\n checkstackp(L, nextra, where); /* ensure stack space */\n L->top = where + nextra; /* next instruction will need top */\n }\n for (i = 0; i < wanted && i < nextra; i++)\n setobjs2s(L, where + i, ci->func - nextra + i);\n for (; i < wanted; i++) /* complete required results with nil */\n setnilvalue(s2v(where + i));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int klsi_105_get_line_state(struct usb_serial_port *port,\n\t\t\t\t unsigned long *line_state_p)\n{\n\tint rc;\n\tu8 *status_buf;\n\t__u16 status;\n\n\tdev_info(&port->serial->dev->dev, \"sending SIO Poll request\\n\");\n\n\tstatus_buf = kmalloc(KLSI_STATUSBUF_LEN, GFP_KERNEL);\n\tif (!status_buf)\n\t\treturn -ENOMEM;\n\n\tstatus_buf[0] = 0xff;\n\tstatus_buf[1] = 0xff;\n\trc = usb_control_msg(port->serial->dev,\n\t\t\t usb_rcvctrlpipe(port->serial->dev, 0),\n\t\t\t KL5KUSB105A_SIO_POLL,\n\t\t\t USB_TYPE_VENDOR | USB_DIR_IN,\n\t\t\t 0, /* value */\n\t\t\t 0, /* index */\n\t\t\t status_buf, KLSI_STATUSBUF_LEN,\n\t\t\t 10000\n\t\t\t );\n\tif (rc < 0)\n\t\tdev_err(&port->dev, \"Reading line status failed (error = %d)\\n\",\n\t\t\trc);\n\telse {\n\t\tstatus = get_unaligned_le16(status_buf);\n\n\t\tdev_info(&port->serial->dev->dev, \"read status %x %x\\n\",\n\t\t\t status_buf[0], status_buf[1]);\n\n\t\t*line_state_p = klsi_105_status2linestate(status);\n\t}\n\n\tkfree(status_buf);\n\treturn rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-532", "cwe_name": "Insertion of Sensitive Information into Log File", "description": "Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.", "url": "https://cwe.mitre.org/data/definitions/532.html", "label_name": "vulnerable"} {"code": "show_tree(tree_t *t, /* I - Parent node */\n int indent) /* I - Indentation */\n{\n while (t)\n {\n if (t->markup == MARKUP_NONE)\n printf(\"%*s\\\"%s\\\"\\n\", indent, \"\", t->data);\n else\n printf(\"%*s%s\\n\", indent, \"\", _htmlMarkups[t->markup]);\n\n if (t->child)\n show_tree(t->child, indent + 2);\n\n t = t->next;\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "int sas_ex_revalidate_domain(struct domain_device *port_dev)\n{\n\tint res;\n\tstruct domain_device *dev = NULL;\n\n\tres = sas_find_bcast_dev(port_dev, &dev);\n\twhile (res == 0 && dev) {\n\t\tstruct expander_device *ex = &dev->ex_dev;\n\t\tint i = 0, phy_id;\n\n\t\tdo {\n\t\t\tphy_id = -1;\n\t\t\tres = sas_find_bcast_phy(dev, &phy_id, i, true);\n\t\t\tif (phy_id == -1)\n\t\t\t\tbreak;\n\t\t\tres = sas_rediscover(dev, phy_id);\n\t\t\ti = phy_id + 1;\n\t\t} while (i < ex->num_phys);\n\n\t\tdev = NULL;\n\t\tres = sas_find_bcast_dev(port_dev, &dev);\n\t}\n\treturn res;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)\n{\n\tstruct dentry *parent;\n\tstruct inode *p_inode;\n\tint ret = 0;\n\n\tif (!dentry)\n\t\tdentry = path->dentry;\n\n\tif (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))\n\t\treturn 0;\n\n\tparent = dget_parent(dentry);\n\tp_inode = parent->d_inode;\n\n\tif (unlikely(!fsnotify_inode_watches_children(p_inode)))\n\t\t__fsnotify_update_child_dentry_flags(p_inode);\n\telse if (p_inode->i_fsnotify_mask & mask) {\n\t\t/* we are notifying a parent so come up with the new mask which\n\t\t * specifies these are events which came from a child. */\n\t\tmask |= FS_EVENT_ON_CHILD;\n\n\t\tif (path)\n\t\t\tret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,\n\t\t\t\t dentry->d_name.name, 0);\n\t\telse\n\t\t\tret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,\n\t\t\t\t dentry->d_name.name, 0);\n\t}\n\n\tdput(parent);\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)\n{\n\tregister u_int length = h->len;\n\tregister u_int caplen = h->caplen;\n\n\tif (caplen < CHDLC_HDRLEN) {\n\t\tND_PRINT((ndo, \"[|chdlc]\"));\n\t\treturn (caplen);\n\t}\n return (chdlc_print(ndo, p,length));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function *func_ptr, int pass_num_args, zval *return_value, zval *arg2 TSRMLS_DC) /* {{{ */\n{\n\tzend_fcall_info fci;\n\tzend_fcall_info_cache fcic;\n\tzval z_fname;\n\tzval * zresource_ptr = &intern->u.file.zresource, *retval;\n\tint result;\n\tint num_args = pass_num_args + (arg2 ? 2 : 1);\n\n\tzval ***params = (zval***)safe_emalloc(num_args, sizeof(zval**), 0);\n\n\tparams[0] = &zresource_ptr;\n\n\tif (arg2) {\n\t\tparams[1] = &arg2;\n\t}\n\n\tzend_get_parameters_array_ex(pass_num_args, params+(arg2 ? 2 : 1));\n\n\tZVAL_STRING(&z_fname, func_ptr->common.function_name, 0);\n\n\tfci.size = sizeof(fci);\n\tfci.function_table = EG(function_table);\n\tfci.object_ptr = NULL;\n\tfci.function_name = &z_fname;\n\tfci.retval_ptr_ptr = &retval;\n\tfci.param_count = num_args;\n\tfci.params = params;\n\tfci.no_separation = 1;\n\tfci.symbol_table = NULL;\n\n\tfcic.initialized = 1;\n\tfcic.function_handler = func_ptr;\n\tfcic.calling_scope = NULL;\n\tfcic.called_scope = NULL;\n\tfcic.object_ptr = NULL;\n\n\tresult = zend_call_function(&fci, &fcic TSRMLS_CC);\n\n\tif (result == FAILURE) {\n\t\tRETVAL_FALSE;\n\t} else {\n\t\tZVAL_ZVAL(return_value, retval, 1, 1);\n\t}\n\n\tefree(params);\n\treturn result;\n} /* }}} */", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "lldp_mgmt_addr_tlv_print(netdissect_options *ndo,\n const u_char *pptr, u_int len)\n{\n uint8_t mgmt_addr_len, intf_num_subtype, oid_len;\n const u_char *tptr;\n u_int tlen;\n char *mgmt_addr;\n\n tlen = len;\n tptr = pptr;\n\n if (tlen < 1) {\n return 0;\n }\n mgmt_addr_len = *tptr++;\n tlen--;\n\n if (tlen < mgmt_addr_len) {\n return 0;\n }\n\n mgmt_addr = lldp_network_addr_print(ndo, tptr, mgmt_addr_len);\n if (mgmt_addr == NULL) {\n return 0;\n }\n ND_PRINT((ndo, \"\\n\\t Management Address length %u, %s\",\n mgmt_addr_len, mgmt_addr));\n tptr += mgmt_addr_len;\n tlen -= mgmt_addr_len;\n\n if (tlen < LLDP_INTF_NUM_LEN) {\n return 0;\n }\n\n intf_num_subtype = *tptr;\n ND_PRINT((ndo, \"\\n\\t %s Interface Numbering (%u): %u\",\n tok2str(lldp_intf_numb_subtype_values, \"Unknown\", intf_num_subtype),\n intf_num_subtype,\n EXTRACT_32BITS(tptr + 1)));\n\n tptr += LLDP_INTF_NUM_LEN;\n tlen -= LLDP_INTF_NUM_LEN;\n\n /*\n * The OID is optional.\n */\n if (tlen) {\n oid_len = *tptr;\n\n if (tlen < 1U + oid_len) {\n return 0;\n }\n if (oid_len) {\n ND_PRINT((ndo, \"\\n\\t OID length %u\", oid_len));\n safeputs(ndo, tptr + 1, oid_len);\n }\n }\n\n return 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static int read_probe(const AVProbeData *p)\n{\n int cnt = 0;\n\n for (int i = 0; i < p->buf_size; i++)\n cnt += !!isansicode(p->buf[i]);\n\n return (cnt * 100LL / p->buf_size) * (cnt > 400) *\n !!av_match_ext(p->filename, tty_extensions);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch,\n\t\t\t\t struct srpt_recv_ioctx *recv_ioctx,\n\t\t\t\t struct srpt_send_ioctx *send_ioctx)\n{\n\tstruct srp_tsk_mgmt *srp_tsk;\n\tstruct se_cmd *cmd;\n\tstruct se_session *sess = ch->sess;\n\tuint64_t unpacked_lun;\n\tint tcm_tmr;\n\tint rc;\n\n\tBUG_ON(!send_ioctx);\n\n\tsrp_tsk = recv_ioctx->ioctx.buf;\n\tcmd = &send_ioctx->cmd;\n\n\tpr_debug(\"recv tsk_mgmt fn %d for task_tag %lld and cmd tag %lld\"\n\t\t \" cm_id %p sess %p\\n\", srp_tsk->tsk_mgmt_func,\n\t\t srp_tsk->task_tag, srp_tsk->tag, ch->cm_id, ch->sess);\n\n\tsrpt_set_cmd_state(send_ioctx, SRPT_STATE_MGMT);\n\tsend_ioctx->cmd.tag = srp_tsk->tag;\n\ttcm_tmr = srp_tmr_to_tcm(srp_tsk->tsk_mgmt_func);\n\tunpacked_lun = srpt_unpack_lun((uint8_t *)&srp_tsk->lun,\n\t\t\t\t sizeof(srp_tsk->lun));\n\trc = target_submit_tmr(&send_ioctx->cmd, sess, NULL, unpacked_lun,\n\t\t\t\tsrp_tsk, tcm_tmr, GFP_KERNEL, srp_tsk->task_tag,\n\t\t\t\tTARGET_SCF_ACK_KREF);\n\tif (rc != 0) {\n\t\tsend_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED;\n\t\tgoto fail;\n\t}\n\treturn;\nfail:\n\ttransport_send_check_condition_and_sense(cmd, 0, 0); // XXX:\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "header_seek (SF_PRIVATE *psf, sf_count_t position, int whence)\n{\n\tswitch (whence)\n\t{\tcase SEEK_SET :\n\t\t\tif (psf->header.indx + position >= psf->header.len)\n\t\t\t\tpsf_bump_header_allocation (psf, position) ;\n\t\t\tif (position > psf->header.len)\n\t\t\t{\t/* Too much header to cache so just seek instead. */\n\t\t\t\tpsf_fseek (psf, position, whence) ;\n\t\t\t\treturn ;\n\t\t\t\t} ;\n\t\t\tif (position > psf->header.end)\n\t\t\t\tpsf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - psf->header.end, psf) ;\n\t\t\tpsf->header.indx = position ;\n\t\t\tbreak ;\n\n\t\tcase SEEK_CUR :\n\t\t\tif (psf->header.indx + position >= psf->header.len)\n\t\t\t\tpsf_bump_header_allocation (psf, position) ;\n\n\t\t\tif (psf->header.indx + position < 0)\n\t\t\t\tbreak ;\n\n\t\t\tif (psf->header.indx >= psf->header.len)\n\t\t\t{\tpsf_fseek (psf, position, whence) ;\n\t\t\t\treturn ;\n\t\t\t\t} ;\n\n\t\t\tif (psf->header.indx + position <= psf->header.end)\n\t\t\t{\tpsf->header.indx += position ;\n\t\t\t\tbreak ;\n\t\t\t\t} ;\n\n\t\t\tif (psf->header.indx + position > psf->header.len)\n\t\t\t{\t/* Need to jump this without caching it. */\n\t\t\t\tpsf->header.indx = psf->header.end ;\n\t\t\t\tpsf_fseek (psf, position, SEEK_CUR) ;\n\t\t\t\tbreak ;\n\t\t\t\t} ;\n\n\t\t\tpsf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - (psf->header.end - psf->header.indx), psf) ;\n\t\t\tpsf->header.indx = psf->header.end ;\n\t\t\tbreak ;\n\n\t\tcase SEEK_END :\n\t\tdefault :\n\t\t\tpsf_log_printf (psf, \"Bad whence param in header_seek().\\n\") ;\n\t\t\tbreak ;\n\t\t} ;\n\n\treturn ;\n} /* header_seek */", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr,\n\t\tunsigned long end, int write, struct page **pages, int *nr)\n{\n\tstruct page *head, *page;\n\tint refs;\n\n\tif (!pud_access_permitted(orig, write))\n\t\treturn 0;\n\n\tif (pud_devmap(orig))\n\t\treturn __gup_device_huge_pud(orig, pudp, addr, end, pages, nr);\n\n\trefs = 0;\n\tpage = pud_page(orig) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);\n\tdo {\n\t\tpages[*nr] = page;\n\t\t(*nr)++;\n\t\tpage++;\n\t\trefs++;\n\t} while (addr += PAGE_SIZE, addr != end);\n\n\thead = try_get_compound_head(pud_page(orig), refs);\n\tif (!head) {\n\t\t*nr -= refs;\n\t\treturn 0;\n\t}\n\n\tif (unlikely(pud_val(orig) != pud_val(*pudp))) {\n\t\t*nr -= refs;\n\t\twhile (refs--)\n\t\t\tput_page(head);\n\t\treturn 0;\n\t}\n\n\tSetPageReferenced(head);\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "error_t ftpClientParsePwdReply(FtpClientContext *context, char_t *path,\n size_t maxLen)\n{\n size_t length;\n char_t *p;\n\n //Search for the last double quote\n p = strrchr(context->buffer, '\\\"');\n //Failed to parse the response?\n if(p == NULL)\n return ERROR_INVALID_SYNTAX;\n\n //Split the string\n *p = '\\0';\n\n //Search for the first double quote\n p = strchr(context->buffer, '\\\"');\n //Failed to parse the response?\n if(p == NULL)\n return ERROR_INVALID_SYNTAX;\n\n //Retrieve the length of the working directory\n length = osStrlen(p + 1);\n //Limit the number of characters to copy\n length = MIN(length, maxLen);\n\n //Copy the string\n osStrncpy(path, p + 1, length);\n //Properly terminate the string with a NULL character\n path[length] = '\\0';\n\n //Successful processing\n return NO_ERROR;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,\n\t\tunsigned long, nbytes, int __user *, start, void __user *, arg)\n{\n\tunsigned long w;\n\tstruct percpu_struct *cpu;\n\n\tswitch (op) {\n\tcase GSI_IEEE_FP_CONTROL:\n\t\t/* Return current software fp control & status bits. */\n\t\t/* Note that DU doesn't verify available space here. */\n\n \t\tw = current_thread_info()->ieee_state & IEEE_SW_MASK;\n \t\tw = swcr_update_status(w, rdfpcr());\n\t\tif (put_user(w, (unsigned long __user *) buffer))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tcase GSI_IEEE_STATE_AT_SIGNAL:\n\t\t/*\n\t\t * Not sure anybody will ever use this weird stuff. These\n\t\t * ops can be used (under OSF/1) to set the fpcr that should\n\t\t * be used when a signal handler starts executing.\n\t\t */\n\t\tbreak;\n\n \tcase GSI_UACPROC:\n\t\tif (nbytes < sizeof(unsigned int))\n\t\t\treturn -EINVAL;\n \t\tw = (current_thread_info()->flags >> UAC_SHIFT) & UAC_BITMASK;\n \t\tif (put_user(w, (unsigned int __user *)buffer))\n \t\t\treturn -EFAULT;\n \t\treturn 1;\n\n\tcase GSI_PROC_TYPE:\n\t\tif (nbytes < sizeof(unsigned long))\n\t\t\treturn -EINVAL;\n\t\tcpu = (struct percpu_struct*)\n\t\t ((char*)hwrpb + hwrpb->processor_offset);\n\t\tw = cpu->type;\n\t\tif (put_user(w, (unsigned long __user*)buffer))\n\t\t\treturn -EFAULT;\n\t\treturn 1;\n\n\tcase GSI_GET_HWRPB:\n\t\tif (nbytes > sizeof(*hwrpb))\n\t\t\treturn -EINVAL;\n\t\tif (copy_to_user(buffer, hwrpb, nbytes) != 0)\n\t\t\treturn -EFAULT;\n\t\treturn 1;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn -EOPNOTSUPP;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "PHP_FUNCTION( locale_get_region )\n{\n\tget_icu_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)\n{\n\tint rc;\n\tunsigned char key2[8];\n\tstruct crypto_skcipher *tfm_des;\n\tstruct scatterlist sgin, sgout;\n\tstruct skcipher_request *req;\n\n\tstr_to_key(key, key2);\n\n\ttfm_des = crypto_alloc_skcipher(\"ecb(des)\", 0, CRYPTO_ALG_ASYNC);\n\tif (IS_ERR(tfm_des)) {\n\t\trc = PTR_ERR(tfm_des);\n\t\tcifs_dbg(VFS, \"could not allocate des crypto API\\n\");\n\t\tgoto smbhash_err;\n\t}\n\n\treq = skcipher_request_alloc(tfm_des, GFP_KERNEL);\n\tif (!req) {\n\t\trc = -ENOMEM;\n\t\tcifs_dbg(VFS, \"could not allocate des crypto API\\n\");\n\t\tgoto smbhash_free_skcipher;\n\t}\n\n\tcrypto_skcipher_setkey(tfm_des, key2, 8);\n\n\tsg_init_one(&sgin, in, 8);\n\tsg_init_one(&sgout, out, 8);\n\n\tskcipher_request_set_callback(req, 0, NULL, NULL);\n\tskcipher_request_set_crypt(req, &sgin, &sgout, 8, NULL);\n\n\trc = crypto_skcipher_encrypt(req);\n\tif (rc)\n\t\tcifs_dbg(VFS, \"could not encrypt crypt key rc: %d\\n\", rc);\n\n\tskcipher_request_free(req);\n\nsmbhash_free_skcipher:\n\tcrypto_free_skcipher(tfm_des);\nsmbhash_err:\n\treturn rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "void perf_event_disable(struct perf_event *event)\n{\n\tstruct perf_event_context *ctx;\n\n\tctx = perf_event_ctx_lock(event);\n\t_perf_event_disable(event);\n\tperf_event_ctx_unlock(event, ctx);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static ram_addr_t find_ram_offset(struct uc_struct *uc, ram_addr_t size)\n{\n RAMBlock *block, *next_block;\n ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX;\n\n assert(size != 0); /* it would hand out same offset multiple times */\n\n if (QLIST_EMPTY(&uc->ram_list.blocks)) {\n return 0;\n }\n\n RAMBLOCK_FOREACH(block) {\n ram_addr_t candidate, next = RAM_ADDR_MAX;\n\n /* Align blocks to start on a 'long' in the bitmap\n * which makes the bitmap sync'ing take the fast path.\n */\n candidate = block->offset + block->max_length;\n candidate = ROUND_UP(candidate, BITS_PER_LONG << TARGET_PAGE_BITS);\n\n /* Search for the closest following block\n * and find the gap.\n */\n RAMBLOCK_FOREACH(next_block) {\n if (next_block->offset >= candidate) {\n next = MIN(next, next_block->offset);\n }\n }\n\n /* If it fits remember our place and remember the size\n * of gap, but keep going so that we might find a smaller\n * gap to fill so avoiding fragmentation.\n */\n if (next - candidate >= size && next - candidate < mingap) {\n offset = candidate;\n mingap = next - candidate;\n }\n }\n\n if (offset == RAM_ADDR_MAX) {\n fprintf(stderr, \"Failed to find gap of requested size: %\" PRIu64 \"\\n\",\n (uint64_t)size);\n abort();\n }\n\n return offset;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static void rds_tcp_kill_sock(struct net *net)\n{\n\tstruct rds_tcp_connection *tc, *_tc;\n\tLIST_HEAD(tmp_list);\n\tstruct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);\n\tstruct socket *lsock = rtn->rds_tcp_listen_sock;\n\n\trtn->rds_tcp_listen_sock = NULL;\n\trds_tcp_listen_stop(lsock, &rtn->rds_tcp_accept_w);\n\tspin_lock_irq(&rds_tcp_conn_lock);\n\tlist_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {\n\t\tstruct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net);\n\n\t\tif (net != c_net || !tc->t_sock)\n\t\t\tcontinue;\n\t\tif (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn)) {\n\t\t\tlist_move_tail(&tc->t_tcp_node, &tmp_list);\n\t\t} else {\n\t\t\tlist_del(&tc->t_tcp_node);\n\t\t\ttc->t_tcp_node_detached = true;\n\t\t}\n\t}\n\tspin_unlock_irq(&rds_tcp_conn_lock);\n\tlist_for_each_entry_safe(tc, _tc, &tmp_list, t_tcp_node)\n\t\trds_conn_destroy(tc->t_cpath->cp_conn);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo,\n size_t offset)\n{\n\tsize_t position;\n\tWINPR_UNUSED(context);\n\tposition = Stream_GetPosition(s);\n\tStream_SetPosition(s, offset);\n\tStream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */\n\n\tif (orderInfo->controlFlags & ORDER_TYPE_CHANGE)\n\t\tStream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */\n\n\tupdate_write_field_flags(s, orderInfo->fieldFlags, orderInfo->controlFlags,\n\t get_primary_drawing_order_field_bytes(orderInfo->orderType, NULL));\n\tupdate_write_bounds(s, orderInfo);\n\tStream_SetPosition(s, position);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk)\n{\n\tstruct sk_buff *frag;\n\n\tif (!skb->data_len)\n\t\tgoto done;\n\n\t/* Don't forget the fragments. */\n\tfor (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next)\n\t\tsctp_skb_set_owner_r_frag(frag, sk);\n\ndone:\n\tsctp_skb_set_owner_r(skb, sk);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "path_in(PG_FUNCTION_ARGS)\n{\n\tchar\t *str = PG_GETARG_CSTRING(0);\n\tPATH\t *path;\n\tint\t\t\tisopen;\n\tchar\t *s;\n\tint\t\t\tnpts;\n\tint\t\t\tsize;\n\tint\t\t\tdepth = 0;\n\n\tif ((npts = pair_count(str, ',')) <= 0)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t errmsg(\"invalid input syntax for type path: \\\"%s\\\"\", str)));\n\n\ts = str;\n\twhile (isspace((unsigned char) *s))\n\t\ts++;\n\n\t/* skip single leading paren */\n\tif ((*s == LDELIM) && (strrchr(s, LDELIM) == s))\n\t{\n\t\ts++;\n\t\tdepth++;\n\t}\n\n\tsize = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts;\n\tpath = (PATH *) palloc(size);\n\n\tSET_VARSIZE(path, size);\n\tpath->npts = npts;\n\n\tif ((!path_decode(TRUE, npts, s, &isopen, &s, &(path->p[0])))\n\t&& (!((depth == 0) && (*s == '\\0'))) && !((depth >= 1) && (*s == RDELIM)))\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t errmsg(\"invalid input syntax for type path: \\\"%s\\\"\", str)));\n\n\tpath->closed = (!isopen);\n\t/* prevent instability in unused pad bytes */\n\tpath->dummy = 0;\n\n\tPG_RETURN_PATH_P(path);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];\n\tjpc_fix_t *buf = joinbuf;\n\tjpc_fix_t *srcptr;\n\tjpc_fix_t *dstptr;\n\tregister jpc_fix_t *srcptr2;\n\tregister jpc_fix_t *dstptr2;\n\tregister int n;\n\tregister int i;\n\tint hstartcol;\n\n\t/* Allocate memory for the join buffer from the heap. */\n\tif (bufsize > QMFB_JOINBUFSIZE) {\n\t\tif (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE, sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\thstartcol = (numrows + 1 - parity) >> 1;\n\n\t/* Save the samples from the lowpass channel. */\n\tn = hstartcol;\n\tsrcptr = &a[0];\n\tdstptr = buf;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tsrcptr += stride;\n\t\tdstptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\t/* Copy the samples from the highpass channel into place. */\n\tsrcptr = &a[hstartcol * stride];\n\tdstptr = &a[(1 - parity) * stride];\n\tn = numrows - hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += stride;\n\t}\n\t/* Copy the samples from the lowpass channel into place. */\n\tsrcptr = buf;\n\tdstptr = &a[parity * stride];\n\tn = hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\n\t/* If the join buffer was allocated on the heap, free this memory. */\n\tif (buf != joinbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "SPL_METHOD(SplFileObject, valid)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {\n\t\tRETURN_BOOL(intern->u.file.current_line || intern->u.file.current_zval);\n\t} else {\n\t\tRETVAL_BOOL(!php_stream_eof(intern->u.file.stream));\n\t}\n} /* }}} */", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static void mark_object(struct object *obj, struct strbuf *path,\n\t\t\tconst char *name, void *data)\n{\n\tupdate_progress(data);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "process_bitmap_updates(STREAM s)\n{\n\tuint16 num_updates;\n\tuint16 left, top, right, bottom, width, height;\n\tuint16 cx, cy, bpp, Bpp, compress, bufsize, size;\n\tuint8 *data, *bmpdata;\n\tint i;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\n\tin_uint16_le(s, num_updates);\n\n\tfor (i = 0; i < num_updates; i++)\n\t{\n\t\tin_uint16_le(s, left);\n\t\tin_uint16_le(s, top);\n\t\tin_uint16_le(s, right);\n\t\tin_uint16_le(s, bottom);\n\t\tin_uint16_le(s, width);\n\t\tin_uint16_le(s, height);\n\t\tin_uint16_le(s, bpp);\n\t\tBpp = (bpp + 7) / 8;\n\t\tin_uint16_le(s, compress);\n\t\tin_uint16_le(s, bufsize);\n\n\t\tcx = right - left + 1;\n\t\tcy = bottom - top + 1;\n\n\t\tlogger(Graphics, Debug,\n\t\t \"process_bitmap_updates(), [%d,%d,%d,%d], [%d,%d], bpp=%d, compression=%d\",\n\t\t left, top, right, bottom, width, height, Bpp, compress);\n\n\t\tif (!compress)\n\t\t{\n\t\t\tint y;\n\t\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tin_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],\n\t\t\t\t\t width * Bpp);\n\t\t\t}\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t\txfree(bmpdata);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\tif (compress & 0x400)\n\t\t{\n\t\t\tsize = bufsize;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_uint8s(s, 2);\t/* pad */\n\t\t\tin_uint16_le(s, size);\n\t\t\tin_uint8s(s, 4);\t/* line_size, final_size */\n\t\t}\n\t\tin_uint8p(s, data, size);\n\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\tif (bitmap_decompress(bmpdata, width, height, data, size, Bpp))\n\t\t{\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t \"process_bitmap_updates(), failed to decompress bitmap\");\n\t\t}\n\n\t\txfree(bmpdata);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static int __init ip6_tunnel_init(void)\n{\n\tint err;\n\n\tif (xfrm6_tunnel_register(&ip4ip6_handler, AF_INET)) {\n\t\tprintk(KERN_ERR \"ip6_tunnel init: can't register ip4ip6\\n\");\n\t\terr = -EAGAIN;\n\t\tgoto out;\n\t}\n\n\tif (xfrm6_tunnel_register(&ip6ip6_handler, AF_INET6)) {\n\t\tprintk(KERN_ERR \"ip6_tunnel init: can't register ip6ip6\\n\");\n\t\terr = -EAGAIN;\n\t\tgoto unreg_ip4ip6;\n\t}\n\n\terr = register_pernet_device(&ip6_tnl_net_ops);\n\tif (err < 0)\n\t\tgoto err_pernet;\n\treturn 0;\nerr_pernet:\n\txfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6);\nunreg_ip4ip6:\n\txfrm6_tunnel_deregister(&ip4ip6_handler, AF_INET);\nout:\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb,\n\t\t\t\t struct udphdr *uh)\n{\n\tstruct udp_offload_priv *uo_priv;\n\tstruct sk_buff *p, **pp = NULL;\n\tstruct udphdr *uh2;\n\tunsigned int off = skb_gro_offset(skb);\n\tint flush = 1;\n\n\tif (NAPI_GRO_CB(skb)->encap_mark ||\n\t (skb->ip_summed != CHECKSUM_PARTIAL &&\n\t NAPI_GRO_CB(skb)->csum_cnt == 0 &&\n\t !NAPI_GRO_CB(skb)->csum_valid))\n\t\tgoto out;\n\n\t/* mark that this skb passed once through the tunnel gro layer */\n\tNAPI_GRO_CB(skb)->encap_mark = 1;\n\n\trcu_read_lock();\n\tuo_priv = rcu_dereference(udp_offload_base);\n\tfor (; uo_priv != NULL; uo_priv = rcu_dereference(uo_priv->next)) {\n\t\tif (net_eq(read_pnet(&uo_priv->net), dev_net(skb->dev)) &&\n\t\t uo_priv->offload->port == uh->dest &&\n\t\t uo_priv->offload->callbacks.gro_receive)\n\t\t\tgoto unflush;\n\t}\n\tgoto out_unlock;\n\nunflush:\n\tflush = 0;\n\n\tfor (p = *head; p; p = p->next) {\n\t\tif (!NAPI_GRO_CB(p)->same_flow)\n\t\t\tcontinue;\n\n\t\tuh2 = (struct udphdr *)(p->data + off);\n\n\t\t/* Match ports and either checksums are either both zero\n\t\t * or nonzero.\n\t\t */\n\t\tif ((*(u32 *)&uh->source != *(u32 *)&uh2->source) ||\n\t\t (!uh->check ^ !uh2->check)) {\n\t\t\tNAPI_GRO_CB(p)->same_flow = 0;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tskb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */\n\tskb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));\n\tNAPI_GRO_CB(skb)->proto = uo_priv->offload->ipproto;\n\tpp = uo_priv->offload->callbacks.gro_receive(head, skb,\n\t\t\t\t\t\t uo_priv->offload);\n\nout_unlock:\n\trcu_read_unlock();\nout:\n\tNAPI_GRO_CB(skb)->flush |= flush;\n\treturn pp;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "void sas_deform_port(struct asd_sas_phy *phy, int gone)\n{\n\tstruct sas_ha_struct *sas_ha = phy->ha;\n\tstruct asd_sas_port *port = phy->port;\n\tstruct sas_internal *si =\n\t\tto_sas_internal(sas_ha->core.shost->transportt);\n\tstruct domain_device *dev;\n\tunsigned long flags;\n\n\tif (!port)\n\t\treturn;\t\t /* done by a phy event */\n\n\tdev = port->port_dev;\n\tif (dev)\n\t\tdev->pathways--;\n\n\tif (port->num_phys == 1) {\n\t\tsas_unregister_domain_devices(port, gone);\n\t\tsas_destruct_devices(port);\n\t\tsas_port_delete(port->port);\n\t\tport->port = NULL;\n\t} else {\n\t\tsas_port_delete_phy(port->port, phy->phy);\n\t\tsas_device_set_phy(dev, port->port);\n\t}\n\n\tif (si->dft->lldd_port_deformed)\n\t\tsi->dft->lldd_port_deformed(phy);\n\n\tspin_lock_irqsave(&sas_ha->phy_port_lock, flags);\n\tspin_lock(&port->phy_list_lock);\n\n\tlist_del_init(&phy->port_phy_el);\n\tsas_phy_set_target(phy, NULL);\n\tphy->port = NULL;\n\tport->num_phys--;\n\tport->phy_mask &= ~(1U << phy->id);\n\n\tif (port->num_phys == 0) {\n\t\tINIT_LIST_HEAD(&port->phy_list);\n\t\tmemset(port->sas_addr, 0, SAS_ADDR_SIZE);\n\t\tmemset(port->attached_sas_addr, 0, SAS_ADDR_SIZE);\n\t\tport->class = 0;\n\t\tport->iproto = 0;\n\t\tport->tproto = 0;\n\t\tport->oob_mode = 0;\n\t\tport->phy_mask = 0;\n\t}\n\tspin_unlock(&port->phy_list_lock);\n\tspin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);\n\n\treturn;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "create_vterm(term_T *term, int rows, int cols)\n{\n VTerm\t *vterm;\n VTermScreen\t *screen;\n VTermState\t *state;\n VTermValue\t value;\n\n vterm = vterm_new_with_allocator(rows, cols, &vterm_allocator, NULL);\n term->tl_vterm = vterm;\n if (vterm == NULL)\n\treturn FAIL;\n\n // Allocate screen and state here, so we can bail out if that fails.\n state = vterm_obtain_state(vterm);\n screen = vterm_obtain_screen(vterm);\n if (state == NULL || screen == NULL)\n {\n\tvterm_free(vterm);\n\treturn FAIL;\n }\n\n vterm_screen_set_callbacks(screen, &screen_callbacks, term);\n /* TODO: depends on 'encoding'. */\n vterm_set_utf8(vterm, 1);\n\n init_default_colors(term);\n\n vterm_state_set_default_colors(\n\t state,\n\t &term->tl_default_color.fg,\n\t &term->tl_default_color.bg);\n\n if (t_colors >= 16)\n\tvterm_state_set_bold_highbright(vterm_obtain_state(vterm), 1);\n\n /* Required to initialize most things. */\n vterm_screen_reset(screen, 1 /* hard */);\n\n /* Allow using alternate screen. */\n vterm_screen_enable_altscreen(screen, 1);\n\n /* For unix do not use a blinking cursor. In an xterm this causes the\n * cursor to blink if it's blinking in the xterm.\n * For Windows we respect the system wide setting. */\n#ifdef WIN3264\n if (GetCaretBlinkTime() == INFINITE)\n\tvalue.boolean = 0;\n else\n\tvalue.boolean = 1;\n#else\n value.boolean = 0;\n#endif\n vterm_state_set_termprop(state, VTERM_PROP_CURSORBLINK, &value);\n vterm_state_set_unrecognised_fallbacks(state, &parser_fallbacks, term);\n\n return OK;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "snmp_api_set_time_ticks(snmp_varbind_t *varbind, uint32_t *oid, uint32_t integer)\n{\n\n snmp_api_replace_oid(varbind, oid);\n varbind->value_type = SNMP_DATA_TYPE_TIME_TICKS;\n varbind->value.integer = integer;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static char *get_pid_environ_val(pid_t pid,char *val){\n int temp_size = 500;\n char *temp = malloc(temp_size);\n \n int i=0;\n int foundit=0;\n FILE *fp;\n\n sprintf(temp,\"/proc/%d/environ\",pid);\n\n fp=fopen(temp,\"r\");\n if(fp==NULL)\n return NULL;\n\n \n for(;;){\n \n if (i >= temp_size) {\n temp_size *= 2;\n temp = realloc(temp, temp_size);\n }\n \n temp[i]=fgetc(fp); \n\n if(foundit==1 && (temp[i]==0 || temp[i]=='\\0' || temp[i]==EOF)){\n char *ret;\n temp[i]=0;\n ret=malloc(strlen(temp)+10);\n sprintf(ret,\"%s\",temp);\n fclose(fp);\n return ret;\n }\n\n switch(temp[i]){\n case EOF:\n fclose(fp);\n return NULL;\n case '=':\n temp[i]=0;\n if(!strcmp(temp,val)){\n\tfoundit=1;\n }\n i=0;\n break;\n case '\\0':\n i=0;\n break;\n default:\n i++;\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "unsigned long lh_char_hash(const void *k)\n{\n\tstatic volatile int random_seed = -1;\n\n\tif (random_seed == -1) {\n\t\tint seed;\n\t\t/* we can't use -1 as it is the unitialized sentinel */\n\t\twhile ((seed = json_c_get_random_seed()) == -1);\n#if defined __GNUC__\n\t\t__sync_val_compare_and_swap(&random_seed, -1, seed);\n#elif defined _MSC_VER\n\t\tInterlockedCompareExchange(&random_seed, seed, -1);\n#else\n#warning \"racy random seed initializtion if used by multiple threads\"\n\t\trandom_seed = seed; /* potentially racy */\n#endif\n\t}\n\n\treturn hashlittle((const char*)k, strlen((const char*)k), random_seed); \n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "static int do_siocgstampns(struct net *net, struct socket *sock,\n\t\t\t unsigned int cmd, void __user *up)\n{\n\tmm_segment_t old_fs = get_fs();\n\tstruct timespec kts;\n\tint err;\n\n\tset_fs(KERNEL_DS);\n\terr = sock_do_ioctl(net, sock, cmd, (unsigned long)&kts);\n\tset_fs(old_fs);\n\tif (!err)\n\t\terr = compat_put_timespec(up, &kts);\n\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "read_subpkt(cdk_stream_t inp, cdk_subpkt_t * r_ctx, size_t * r_nbytes)\n{\n\tbyte c, c1;\n\tsize_t size, nread, n;\n\tcdk_subpkt_t node;\n\tcdk_error_t rc;\n\n\tif (!inp || !r_nbytes)\n\t\treturn CDK_Inv_Value;\n\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\"read_subpkt:\\n\");\n\n\tn = 0;\n\t*r_nbytes = 0;\n\tc = cdk_stream_getc(inp);\n\tn++;\n\tif (c == 255) {\n\t\tsize = read_32(inp);\n\t\tn += 4;\n\t} else if (c >= 192 && c < 255) {\n\t\tc1 = cdk_stream_getc(inp);\n\t\tn++;\n\t\tif (c1 == 0)\n\t\t\treturn 0;\n\t\tsize = ((c - 192) << 8) + c1 + 192;\n\t} else if (c < 192)\n\t\tsize = c;\n\telse\n\t\treturn CDK_Inv_Packet;\n\n\tnode = cdk_subpkt_new(size);\n\tif (!node)\n\t\treturn CDK_Out_Of_Core;\n\tnode->size = size;\n\tnode->type = cdk_stream_getc(inp);\n\tif (DEBUG_PKT)\n\t\t_gnutls_write_log(\" %d octets %d type\\n\", node->size,\n\t\t\t\t node->type);\n\tn++;\n\tnode->size--;\n\trc = stream_read(inp, node->d, node->size, &nread);\n\tn += nread;\n\tif (rc) {\n\t\tcdk_subpkt_free(node);\n\t\treturn rc;\n\t}\n\t*r_nbytes = n;\n\tif (!*r_ctx)\n\t\t*r_ctx = node;\n\telse\n\t\tcdk_subpkt_add(*r_ctx, node);\n\treturn rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "void native_tss_update_io_bitmap(void)\n{\n\tstruct tss_struct *tss = this_cpu_ptr(&cpu_tss_rw);\n\tstruct thread_struct *t = ¤t->thread;\n\tu16 *base = &tss->x86_tss.io_bitmap_base;\n\n\tif (!test_thread_flag(TIF_IO_BITMAP)) {\n\t\tnative_tss_invalidate_io_bitmap();\n\t\treturn;\n\t}\n\n\tif (IS_ENABLED(CONFIG_X86_IOPL_IOPERM) && t->iopl_emul == 3) {\n\t\t*base = IO_BITMAP_OFFSET_VALID_ALL;\n\t} else {\n\t\tstruct io_bitmap *iobm = t->io_bitmap;\n\n\t\t/*\n\t\t * Only copy bitmap data when the sequence number differs. The\n\t\t * update time is accounted to the incoming task.\n\t\t */\n\t\tif (tss->io_bitmap.prev_sequence != iobm->sequence)\n\t\t\ttss_copy_io_bitmap(tss, iobm);\n\n\t\t/* Enable the bitmap */\n\t\t*base = IO_BITMAP_OFFSET_VALID_MAP;\n\t}\n\n\t/*\n\t * Make sure that the TSS limit is covering the IO bitmap. It might have\n\t * been cut down by a VMEXIT to 0x67 which would cause a subsequent I/O\n\t * access from user space to trigger a #GP because tbe bitmap is outside\n\t * the TSS limit.\n\t */\n\trefresh_tss_limit();\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "safe"} {"code": "int check_name(char *name, int size)\n{\n\tchar *start = name;\n\n\tif(name[0] == '.') {\n\t\tif(name[1] == '.')\n\t\t\tname++;\n\t\tif(name[1] == '/' || name[1] == '\\0')\n\t\t\treturn FALSE;\n\t}\n\n\twhile(name[0] != '/' && name[0] != '\\0')\n\t\tname ++;\n\n\tif(name[0] == '/')\n\t\treturn FALSE;\n\n\tif((name - start) != size)\n\t\treturn FALSE;\n\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "static int may_create_in_sticky(struct dentry * const dir,\n\t\t\t\tstruct inode * const inode)\n{\n\tif ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) ||\n\t (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||\n\t likely(!(dir->d_inode->i_mode & S_ISVTX)) ||\n\t uid_eq(inode->i_uid, dir->d_inode->i_uid) ||\n\t uid_eq(current_fsuid(), inode->i_uid))\n\t\treturn 0;\n\n\tif (likely(dir->d_inode->i_mode & 0002) ||\n\t (dir->d_inode->i_mode & 0020 &&\n\t ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||\n\t (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {\n\t\tconst char *operation = S_ISFIFO(inode->i_mode) ?\n\t\t\t\t\t\"sticky_create_fifo\" :\n\t\t\t\t\t\"sticky_create_regular\";\n\t\taudit_log_path_denied(AUDIT_ANOM_CREAT, operation);\n\t\treturn -EACCES;\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int read_public_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I1012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_public_key(p, keysize, rsa);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "path_in(PG_FUNCTION_ARGS)\n{\n\tchar\t *str = PG_GETARG_CSTRING(0);\n\tPATH\t *path;\n\tint\t\t\tisopen;\n\tchar\t *s;\n\tint\t\t\tnpts;\n\tint\t\t\tsize;\n\tint\t\t\tbase_size;\n\tint\t\t\tdepth = 0;\n\n\tif ((npts = pair_count(str, ',')) <= 0)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t errmsg(\"invalid input syntax for type path: \\\"%s\\\"\", str)));\n\n\ts = str;\n\twhile (isspace((unsigned char) *s))\n\t\ts++;\n\n\t/* skip single leading paren */\n\tif ((*s == LDELIM) && (strrchr(s, LDELIM) == s))\n\t{\n\t\ts++;\n\t\tdepth++;\n\t}\n\n\tbase_size = sizeof(path->p[0]) * npts;\n\tsize = offsetof(PATH, p[0]) + base_size;\n\n\t/* Check for integer overflow */\n\tif (base_size / npts != sizeof(path->p[0]) || size <= base_size)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),\n\t\t\t\t errmsg(\"too many points requested\")));\n\n\tpath = (PATH *) palloc(size);\n\n\tSET_VARSIZE(path, size);\n\tpath->npts = npts;\n\n\tif ((!path_decode(TRUE, npts, s, &isopen, &s, &(path->p[0])))\n\t&& (!((depth == 0) && (*s == '\\0'))) && !((depth >= 1) && (*s == RDELIM)))\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t errmsg(\"invalid input syntax for type path: \\\"%s\\\"\", str)));\n\n\tpath->closed = (!isopen);\n\t/* prevent instability in unused pad bytes */\n\tpath->dummy = 0;\n\n\tPG_RETURN_PATH_P(path);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,\n const char **elem_rtrn, const char **field_rtrn,\n ExprDef **index_rtrn)\n{\n switch (expr->expr.op) {\n case EXPR_IDENT:\n *elem_rtrn = NULL;\n *field_rtrn = xkb_atom_text(ctx, expr->ident.ident);\n *index_rtrn = NULL;\n return (*field_rtrn != NULL);\n case EXPR_FIELD_REF:\n *elem_rtrn = xkb_atom_text(ctx, expr->field_ref.element);\n *field_rtrn = xkb_atom_text(ctx, expr->field_ref.field);\n *index_rtrn = NULL;\n return true;\n case EXPR_ARRAY_REF:\n *elem_rtrn = xkb_atom_text(ctx, expr->array_ref.element);\n *field_rtrn = xkb_atom_text(ctx, expr->array_ref.field);\n *index_rtrn = expr->array_ref.entry;\n return true;\n default:\n break;\n }\n log_wsgo(ctx, \"Unexpected operator %d in ResolveLhs\\n\", expr->expr.op);\n return false;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "int hns_ppe_get_sset_count(int stringset)\n{\n\tif (stringset == ETH_SS_STATS)\n\t\treturn ETH_PPE_STATIC_NUM;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "new_identifier(const char *n, struct compiling *c)\n{\n PyObject *id = PyUnicode_DecodeUTF8(n, strlen(n), NULL);\n if (!id)\n return NULL;\n /* PyUnicode_DecodeUTF8 should always return a ready string. */\n assert(PyUnicode_IS_READY(id));\n /* Check whether there are non-ASCII characters in the\n identifier; if so, normalize to NFKC. */\n if (!PyUnicode_IS_ASCII(id)) {\n PyObject *id2;\n if (!c->c_normalize && !init_normalization(c)) {\n Py_DECREF(id);\n return NULL;\n }\n PyTuple_SET_ITEM(c->c_normalize_args, 1, id);\n id2 = PyObject_Call(c->c_normalize, c->c_normalize_args, NULL);\n Py_DECREF(id);\n if (!id2)\n return NULL;\n id = id2;\n }\n PyUnicode_InternInPlace(&id);\n if (PyArena_AddPyObject(c->c_arena, id) < 0) {\n Py_DECREF(id);\n return NULL;\n }\n return id;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "write_stacktrace(const char *file_name, const char *str)\n{\n\tint fd;\n\tvoid *buffer[100];\n\tint nptrs;\n\tint i;\n\tchar **strs;\n\n\tnptrs = backtrace(buffer, 100);\n\tif (file_name) {\n\t\tfd = open(file_name, O_WRONLY | O_APPEND | O_CREAT, 0644);\n\t\tif (str)\n\t\t\tdprintf(fd, \"%s\\n\", str);\n\t\tbacktrace_symbols_fd(buffer, nptrs, fd);\n\t\tif (write(fd, \"\\n\", 1) != 1) {\n\t\t\t/* We don't care, but this stops a warning on Ubuntu */\n\t\t}\n\t\tclose(fd);\n\t} else {\n\t\tif (str)\n\t\t\tlog_message(LOG_INFO, \"%s\", str);\n\t\tstrs = backtrace_symbols(buffer, nptrs);\n\t\tif (strs == NULL) {\n\t\t\tlog_message(LOG_INFO, \"Unable to get stack backtrace\");\n\t\t\treturn;\n\t\t}\n\n\t\t/* We don't need the call to this function, or the first two entries on the stack */\n\t\tfor (i = 1; i < nptrs - 2; i++)\n\t\t\tlog_message(LOG_INFO, \" %s\", strs[i]);\n\t\tfree(strs);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "process_plane(uint8 * in, int width, int height, uint8 * out, int size)\n{\n\tUNUSED(size);\n\tint indexw;\n\tint indexh;\n\tint code;\n\tint collen;\n\tint replen;\n\tint color;\n\tint x;\n\tint revcode;\n\tuint8 * last_line;\n\tuint8 * this_line;\n\tuint8 * org_in;\n\tuint8 * org_out;\n\n\torg_in = in;\n\torg_out = out;\n\tlast_line = 0;\n\tindexh = 0;\n\twhile (indexh < height)\n\t{\n\t\tout = (org_out + width * height * 4) - ((indexh + 1) * width * 4);\n\t\tcolor = 0;\n\t\tthis_line = out;\n\t\tindexw = 0;\n\t\tif (last_line == 0)\n\t\t{\n\t\t\twhile (indexw < width)\n\t\t\t{\n\t\t\t\tcode = CVAL(in);\n\t\t\t\treplen = code & 0xf;\n\t\t\t\tcollen = (code >> 4) & 0xf;\n\t\t\t\trevcode = (replen << 4) | collen;\n\t\t\t\tif ((revcode <= 47) && (revcode >= 16))\n\t\t\t\t{\n\t\t\t\t\treplen = revcode;\n\t\t\t\t\tcollen = 0;\n\t\t\t\t}\n\t\t\t\twhile (collen > 0)\n\t\t\t\t{\n\t\t\t\t\tcolor = CVAL(in);\n\t\t\t\t\t*out = color;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\tcollen--;\n\t\t\t\t}\n\t\t\t\twhile (replen > 0)\n\t\t\t\t{\n\t\t\t\t\t*out = color;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\treplen--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\twhile (indexw < width)\n\t\t\t{\n\t\t\t\tcode = CVAL(in);\n\t\t\t\treplen = code & 0xf;\n\t\t\t\tcollen = (code >> 4) & 0xf;\n\t\t\t\trevcode = (replen << 4) | collen;\n\t\t\t\tif ((revcode <= 47) && (revcode >= 16))\n\t\t\t\t{\n\t\t\t\t\treplen = revcode;\n\t\t\t\t\tcollen = 0;\n\t\t\t\t}\n\t\t\t\twhile (collen > 0)\n\t\t\t\t{\n\t\t\t\t\tx = CVAL(in);\n\t\t\t\t\tif (x & 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tx = x >> 1;\n\t\t\t\t\t\tx = x + 1;\n\t\t\t\t\t\tcolor = -x;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tx = x >> 1;\n\t\t\t\t\t\tcolor = x;\n\t\t\t\t\t}\n\t\t\t\t\tx = last_line[indexw * 4] + color;\n\t\t\t\t\t*out = x;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\tcollen--;\n\t\t\t\t}\n\t\t\t\twhile (replen > 0)\n\t\t\t\t{\n\t\t\t\t\tx = last_line[indexw * 4] + color;\n\t\t\t\t\t*out = x;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\treplen--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tindexh++;\n\t\tlast_line = this_line;\n\t}\n\treturn (int) (in - org_in);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int jpc_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_ppm_t *ppm = &ms->parms.ppm;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tppm->data = 0;\n\n\tif (ms->len < 1) {\n\t\tgoto error;\n\t}\n\tif (jpc_getuint8(in, &ppm->ind)) {\n\t\tgoto error;\n\t}\n\n\tppm->len = ms->len - 1;\n\tif (ppm->len > 0) {\n\t\tif (!(ppm->data = jas_malloc(ppm->len))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (JAS_CAST(jas_uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {\n\t\t\tgoto error;\n\t\t}\n\t} else {\n\t\tppm->data = 0;\n\t}\n\treturn 0;\n\nerror:\n\tjpc_ppm_destroyparms(ms);\n\treturn -1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,\n\tstruct user_namespace *user_ns)\n{\n\tmm->mmap = NULL;\n\tmm->mm_rb = RB_ROOT;\n\tmm->vmacache_seqnum = 0;\n\tatomic_set(&mm->mm_users, 1);\n\tatomic_set(&mm->mm_count, 1);\n\tinit_rwsem(&mm->mmap_sem);\n\tINIT_LIST_HEAD(&mm->mmlist);\n\tmm->core_state = NULL;\n\tatomic_long_set(&mm->nr_ptes, 0);\n\tmm_nr_pmds_init(mm);\n\tmm->map_count = 0;\n\tmm->locked_vm = 0;\n\tmm->pinned_vm = 0;\n\tmemset(&mm->rss_stat, 0, sizeof(mm->rss_stat));\n\tspin_lock_init(&mm->page_table_lock);\n\tmm_init_cpumask(mm);\n\tmm_init_aio(mm);\n\tmm_init_owner(mm, p);\n\tRCU_INIT_POINTER(mm->exe_file, NULL);\n\tmmu_notifier_mm_init(mm);\n\tinit_tlb_flush_pending(mm);\n#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS\n\tmm->pmd_huge_pte = NULL;\n#endif\n\n\tif (current->mm) {\n\t\tmm->flags = current->mm->flags & MMF_INIT_MASK;\n\t\tmm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK;\n\t} else {\n\t\tmm->flags = default_dump_filter;\n\t\tmm->def_flags = 0;\n\t}\n\n\tif (mm_alloc_pgd(mm))\n\t\tgoto fail_nopgd;\n\n\tif (init_new_context(p, mm))\n\t\tgoto fail_nocontext;\n\n\tmm->user_ns = get_user_ns(user_ns);\n\treturn mm;\n\nfail_nocontext:\n\tmm_free_pgd(mm);\nfail_nopgd:\n\tfree_mm(mm);\n\treturn NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)\n{\n\tstruct pipe_buffer *bufs;\n\tunsigned int head, tail, mask, n;\n\n\t/*\n\t * We can shrink the pipe, if arg is greater than the ring occupancy.\n\t * Since we don't expect a lot of shrink+grow operations, just free and\n\t * allocate again like we would do for growing. If the pipe currently\n\t * contains more buffers than arg, then return busy.\n\t */\n\tmask = pipe->ring_size - 1;\n\thead = pipe->head;\n\ttail = pipe->tail;\n\tn = pipe_occupancy(pipe->head, pipe->tail);\n\tif (nr_slots < n)\n\t\treturn -EBUSY;\n\n\tbufs = kcalloc(nr_slots, sizeof(*bufs),\n\t\t GFP_KERNEL_ACCOUNT | __GFP_NOWARN);\n\tif (unlikely(!bufs))\n\t\treturn -ENOMEM;\n\n\t/*\n\t * The pipe array wraps around, so just start the new one at zero\n\t * and adjust the indices.\n\t */\n\tif (n > 0) {\n\t\tunsigned int h = head & mask;\n\t\tunsigned int t = tail & mask;\n\t\tif (h > t) {\n\t\t\tmemcpy(bufs, pipe->bufs + t,\n\t\t\t n * sizeof(struct pipe_buffer));\n\t\t} else {\n\t\t\tunsigned int tsize = pipe->ring_size - t;\n\t\t\tif (h > 0)\n\t\t\t\tmemcpy(bufs + tsize, pipe->bufs,\n\t\t\t\t h * sizeof(struct pipe_buffer));\n\t\t\tmemcpy(bufs, pipe->bufs + t,\n\t\t\t tsize * sizeof(struct pipe_buffer));\n\t\t}\n\t}\n\n\thead = n;\n\ttail = 0;\n\n\tkfree(pipe->bufs);\n\tpipe->bufs = bufs;\n\tpipe->ring_size = nr_slots;\n\tif (pipe->max_usage > nr_slots)\n\t\tpipe->max_usage = nr_slots;\n\tpipe->tail = tail;\n\tpipe->head = head;\n\n\t/* This might have made more room for writers */\n\twake_up_interruptible(&pipe->wr_wait);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "goto_tabpage_tp(\n tabpage_T\t*tp,\n int\t\ttrigger_enter_autocmds,\n int\t\ttrigger_leave_autocmds)\n{\n CHECK_CMDWIN;\n\n // Don't repeat a message in another tab page.\n set_keep_msg(NULL, 0);\n\n if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,\n\t\t\t\t\ttrigger_leave_autocmds) == OK)\n {\n\tif (valid_tabpage(tp))\n\t enter_tabpage(tp, curbuf, trigger_enter_autocmds,\n\t\t trigger_leave_autocmds);\n\telse\n\t enter_tabpage(curtab, curbuf, trigger_enter_autocmds,\n\t\t trigger_leave_autocmds);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "crm_recv_remote_raw(void *session, gboolean encrypted, size_t max_recv, size_t *recv_len, int *disconnected)\n{\n char *reply = NULL;\n if (recv_len) {\n *recv_len = 0;\n }\n\n if (disconnected) {\n *disconnected = 0;\n }\n\n if (encrypted) {\n#ifdef HAVE_GNUTLS_GNUTLS_H\n reply = crm_recv_tls(session, max_recv, recv_len, disconnected);\n#else\n CRM_ASSERT(encrypted == FALSE);\n#endif\n } else {\n reply = crm_recv_plaintext(GPOINTER_TO_INT(session), max_recv, recv_len, disconnected);\n }\n if (reply == NULL || strlen(reply) == 0) {\n crm_trace(\"Empty reply\");\n }\n\n return reply;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static mif_hdr_t *mif_hdr_get(jas_stream_t *in)\n{\n\tjas_uchar magicbuf[MIF_MAGICLEN];\n\tchar buf[4096];\n\tmif_hdr_t *hdr;\n\tbool done;\n\tjas_tvparser_t *tvp;\n\tint id;\n\n\thdr = 0;\n\ttvp = 0;\n\n\tif (jas_stream_read(in, magicbuf, MIF_MAGICLEN) != MIF_MAGICLEN) {\n\t\tgoto error;\n\t}\n\tif (magicbuf[0] != (MIF_MAGIC >> 24) || magicbuf[1] != ((MIF_MAGIC >> 16) &\n\t 0xff) || magicbuf[2] != ((MIF_MAGIC >> 8) & 0xff) || magicbuf[3] !=\n\t (MIF_MAGIC & 0xff)) {\n\t\tjas_eprintf(\"error: bad signature\\n\");\n\t\tgoto error;\n\t}\n\n\tif (!(hdr = mif_hdr_create(0))) {\n\t\tgoto error;\n\t}\n\n\tdone = false;\n\tdo {\n\t\tif (!mif_getline(in, buf, sizeof(buf))) {\n\t\t\tjas_eprintf(\"mif_getline failed\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tif (buf[0] == '\\0') {\n\t\t\tcontinue;\n\t\t}\n\t\tJAS_DBGLOG(10, (\"header line: len=%d; %s\\n\", strlen(buf), buf));\n\t\tif (!(tvp = jas_tvparser_create(buf))) {\n\t\t\tjas_eprintf(\"jas_tvparser_create failed\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tif (jas_tvparser_next(tvp)) {\n\t\t\tjas_eprintf(\"cannot get record type\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tid = jas_taginfo_nonull(jas_taginfos_lookup(mif_tags2,\n\t\t jas_tvparser_gettag(tvp)))->id;\n\t\tjas_tvparser_destroy(tvp);\n\t\ttvp = 0;\n\t\tswitch (id) {\n\t\tcase MIF_CMPT:\n\t\t\tif (mif_process_cmpt(hdr, buf)) {\n\t\t\t\tjas_eprintf(\"cannot get component information\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase MIF_END:\n\t\t\tdone = 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tjas_eprintf(\"invalid header information: %s\\n\", buf);\n\t\t\tgoto error;\n\t\t\tbreak;\n\t\t}\n\t} while (!done);\n\n\treturn hdr;\n\nerror:\n\tif (hdr) {\n\t\tmif_hdr_destroy(hdr);\n\t}\n\tif (tvp) {\n\t\tjas_tvparser_destroy(tvp);\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "gstd_accept(int fd, char **display_creds, char **export_name, char **mech)\n{\n\tgss_name_t\t client;\n\tgss_OID\t\t mech_oid;\n\tstruct gstd_tok *tok;\n\tgss_ctx_id_t\t ctx = GSS_C_NO_CONTEXT;\n\tgss_buffer_desc\t in, out;\n\tOM_uint32\t maj, min;\n\tint\t\t ret;\n\n\t*display_creds = NULL;\n\t*export_name = NULL;\n\tout.length = 0;\n\tin.length = 0;\n\tread_packet(fd, &in, 60000, 1);\nagain:\n\twhile ((ret = read_packet(fd, &in, 60000, 0)) == -2)\n\t\t;\n\n\tif (ret < 1)\n\t\treturn NULL;\n\n\tmaj = gss_accept_sec_context(&min, &ctx, GSS_C_NO_CREDENTIAL,\n\t &in, GSS_C_NO_CHANNEL_BINDINGS, &client, &mech_oid, &out, NULL,\n\t NULL, NULL);\n\n\tgss_release_buffer(&min, &in);\n\n\tif (out.length && write_packet(fd, &out)) {\n\t\tgss_release_buffer(&min, &out);\n\t\treturn NULL;\n\t}\n\tgss_release_buffer(&min, &out);\n\n\tGSTD_GSS_ERROR(maj, min, NULL, \"gss_accept_sec_context\");\n\n\tif (maj & GSS_S_CONTINUE_NEEDED)\n\t\tgoto again;\n\n\t*display_creds = gstd_get_display_name(client);\n\t*export_name = gstd_get_export_name(client);\n\t*mech = gstd_get_mech(mech_oid);\n\n\tgss_release_name(&min, &client);\n\tSETUP_GSTD_TOK(tok, ctx, fd, \"gstd_accept\");\n\treturn tok;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "static inline bool key_is_negative(const struct key *key)\n{\n\treturn key_read_state(key) < 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int check_stack_boundary(struct bpf_verifier_env *env, int regno,\n\t\t\t\tint access_size, bool zero_size_allowed,\n\t\t\t\tstruct bpf_call_arg_meta *meta)\n{\n\tstruct bpf_verifier_state *state = env->cur_state;\n\tstruct bpf_reg_state *regs = state->regs;\n\tint off, i, slot, spi;\n\n\tif (regs[regno].type != PTR_TO_STACK) {\n\t\t/* Allow zero-byte read from NULL, regardless of pointer type */\n\t\tif (zero_size_allowed && access_size == 0 &&\n\t\t register_is_null(regs[regno]))\n\t\t\treturn 0;\n\n\t\tverbose(env, \"R%d type=%s expected=%s\\n\", regno,\n\t\t\treg_type_str[regs[regno].type],\n\t\t\treg_type_str[PTR_TO_STACK]);\n\t\treturn -EACCES;\n\t}\n\n\t/* Only allow fixed-offset stack reads */\n\tif (!tnum_is_const(regs[regno].var_off)) {\n\t\tchar tn_buf[48];\n\n\t\ttnum_strn(tn_buf, sizeof(tn_buf), regs[regno].var_off);\n\t\tverbose(env, \"invalid variable stack read R%d var_off=%s\\n\",\n\t\t\tregno, tn_buf);\n\t\treturn -EACCES;\n\t}\n\toff = regs[regno].off + regs[regno].var_off.value;\n\tif (off >= 0 || off < -MAX_BPF_STACK || off + access_size > 0 ||\n\t access_size < 0 || (access_size == 0 && !zero_size_allowed)) {\n\t\tverbose(env, \"invalid stack type R%d off=%d access_size=%d\\n\",\n\t\t\tregno, off, access_size);\n\t\treturn -EACCES;\n\t}\n\n\tif (env->prog->aux->stack_depth < -off)\n\t\tenv->prog->aux->stack_depth = -off;\n\n\tif (meta && meta->raw_mode) {\n\t\tmeta->access_size = access_size;\n\t\tmeta->regno = regno;\n\t\treturn 0;\n\t}\n\n\tfor (i = 0; i < access_size; i++) {\n\t\tslot = -(off + i) - 1;\n\t\tspi = slot / BPF_REG_SIZE;\n\t\tif (state->allocated_stack <= slot ||\n\t\t state->stack[spi].slot_type[slot % BPF_REG_SIZE] !=\n\t\t\tSTACK_MISC) {\n\t\t\tverbose(env, \"invalid indirect read from stack off %d+%d size %d\\n\",\n\t\t\t\toff, i, access_size);\n\t\t\treturn -EACCES;\n\t\t}\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int _yr_re_is_word_char(\n uint8_t* input,\n int character_size)\n{\n int result = ((isalnum(*input) || (*input) == '_'));\n\n if (character_size == 2)\n result = result && (*(input + 1) == 0);\n\n return result;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "choose_filters(struct archive_read *a)\n{\n\tint number_bidders, i, bid, best_bid, n;\n\tstruct archive_read_filter_bidder *bidder, *best_bidder;\n\tstruct archive_read_filter *filter;\n\tssize_t avail;\n\tint r;\n\n\tfor (n = 0; n < 25; ++n) {\n\t\tnumber_bidders = sizeof(a->bidders) / sizeof(a->bidders[0]);\n\n\t\tbest_bid = 0;\n\t\tbest_bidder = NULL;\n\n\t\tbidder = a->bidders;\n\t\tfor (i = 0; i < number_bidders; i++, bidder++) {\n\t\t\tif (bidder->bid != NULL) {\n\t\t\t\tbid = (bidder->bid)(bidder, a->filter);\n\t\t\t\tif (bid > best_bid) {\n\t\t\t\t\tbest_bid = bid;\n\t\t\t\t\tbest_bidder = bidder;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* If no bidder, we're done. */\n\t\tif (best_bidder == NULL) {\n\t\t\t/* Verify the filter by asking it for some data. */\n\t\t\t__archive_read_filter_ahead(a->filter, 1, &avail);\n\t\t\tif (avail < 0) {\n\t\t\t\t__archive_read_close_filters(a);\n\t\t\t\t__archive_read_free_filters(a);\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->archive.compression_name = a->filter->name;\n\t\t\ta->archive.compression_code = a->filter->code;\n\t\t\treturn (ARCHIVE_OK);\n\t\t}\n\n\t\tfilter\n\t\t = (struct archive_read_filter *)calloc(1, sizeof(*filter));\n\t\tif (filter == NULL)\n\t\t\treturn (ARCHIVE_FATAL);\n\t\tfilter->bidder = best_bidder;\n\t\tfilter->archive = a;\n\t\tfilter->upstream = a->filter;\n\t\ta->filter = filter;\n\t\tr = (best_bidder->init)(a->filter);\n\t\tif (r != ARCHIVE_OK) {\n\t\t\t__archive_read_close_filters(a);\n\t\t\t__archive_read_free_filters(a);\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t}\n\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,\n\t \"Input requires too many filters for decoding\");\n\treturn (ARCHIVE_FATAL);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "void * gdImageWBMPPtr (gdImagePtr im, int *size, int fg)\n{\n\tvoid *rv;\n\tgdIOCtx *out = gdNewDynamicCtx(2048, NULL);\n\tgdImageWBMPCtx(im, fg, out);\n\trv = gdDPExtractData(out, size);\n\tout->gd_free(out);\n\n\treturn rv;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int ntlm_read_message_fields(wStream* s, NTLM_MESSAGE_FIELDS* fields)\n{\n\tif (Stream_GetRemainingLength(s) < 8)\n\t\treturn -1;\n\n\tStream_Read_UINT16(s, fields->Len); /* Len (2 bytes) */\n\tStream_Read_UINT16(s, fields->MaxLen); /* MaxLen (2 bytes) */\n\tStream_Read_UINT32(s, fields->BufferOffset); /* BufferOffset (4 bytes) */\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "void prefetch_table(const void *tab, size_t len)\n{\n const volatile byte *vtab = tab;\n size_t i;\n\n for (i = 0; i < len; i += 8 * 32)\n {\n (void)vtab[i + 0 * 32];\n (void)vtab[i + 1 * 32];\n (void)vtab[i + 2 * 32];\n (void)vtab[i + 3 * 32];\n (void)vtab[i + 4 * 32];\n (void)vtab[i + 5 * 32];\n (void)vtab[i + 6 * 32];\n (void)vtab[i + 7 * 32];\n }\n\n (void)vtab[len - 1];\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-668", "cwe_name": "Exposure of Resource to Wrong Sphere", "description": "The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.", "url": "https://cwe.mitre.org/data/definitions/668.html", "label_name": "vulnerable"} {"code": "int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)\n{\n\tstruct nfs_server *server = NFS_SERVER(state->inode);\n\tstruct nfs4_closedata *calldata;\n\tstruct nfs4_state_owner *sp = state->owner;\n\tstruct rpc_task *task;\n\tstruct rpc_message msg = {\n\t\t.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE],\n\t\t.rpc_cred = state->owner->so_cred,\n\t};\n\tstruct rpc_task_setup task_setup_data = {\n\t\t.rpc_client = server->client,\n\t\t.rpc_message = &msg,\n\t\t.callback_ops = &nfs4_close_ops,\n\t\t.workqueue = nfsiod_workqueue,\n\t\t.flags = RPC_TASK_ASYNC,\n\t};\n\tint status = -ENOMEM;\n\n\tcalldata = kmalloc(sizeof(*calldata), GFP_KERNEL);\n\tif (calldata == NULL)\n\t\tgoto out;\n\tcalldata->inode = state->inode;\n\tcalldata->state = state;\n\tcalldata->arg.fh = NFS_FH(state->inode);\n\tcalldata->arg.stateid = &state->open_stateid;\n\t/* Serialization for the sequence id */\n\tcalldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid);\n\tif (calldata->arg.seqid == NULL)\n\t\tgoto out_free_calldata;\n\tcalldata->arg.fmode = 0;\n\tcalldata->arg.bitmask = server->attr_bitmask;\n\tcalldata->res.fattr = &calldata->fattr;\n\tcalldata->res.seqid = calldata->arg.seqid;\n\tcalldata->res.server = server;\n\tcalldata->path.mnt = mntget(path->mnt);\n\tcalldata->path.dentry = dget(path->dentry);\n\n\tmsg.rpc_argp = &calldata->arg,\n\tmsg.rpc_resp = &calldata->res,\n\ttask_setup_data.callback_data = calldata;\n\ttask = rpc_run_task(&task_setup_data);\n\tif (IS_ERR(task))\n\t\treturn PTR_ERR(task);\n\tstatus = 0;\n\tif (wait)\n\t\tstatus = rpc_wait_for_completion_task(task);\n\trpc_put_task(task);\n\treturn status;\nout_free_calldata:\n\tkfree(calldata);\nout:\n\tnfs4_put_open_state(state);\n\tnfs4_put_state_owner(sp);\n\treturn status;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "static int apparmor_setprocattr(struct task_struct *task, char *name,\n\t\t\t\tvoid *value, size_t size)\n{\n\tstruct common_audit_data sa;\n\tstruct apparmor_audit_data aad = {0,};\n\tchar *command, *largs = NULL, *args = value;\n\tsize_t arg_size;\n\tint error;\n\n\tif (size == 0)\n\t\treturn -EINVAL;\n\t/* task can only write its own attributes */\n\tif (current != task)\n\t\treturn -EACCES;\n\n\t/* AppArmor requires that the buffer must be null terminated atm */\n\tif (args[size - 1] != '\\0') {\n\t\t/* null terminate */\n\t\tlargs = args = kmalloc(size + 1, GFP_KERNEL);\n\t\tif (!args)\n\t\t\treturn -ENOMEM;\n\t\tmemcpy(args, value, size);\n\t\targs[size] = '\\0';\n\t}\n\n\terror = -EINVAL;\n\targs = strim(args);\n\tcommand = strsep(&args, \" \");\n\tif (!args)\n\t\tgoto out;\n\targs = skip_spaces(args);\n\tif (!*args)\n\t\tgoto out;\n\n\targ_size = size - (args - (char *) value);\n\tif (strcmp(name, \"current\") == 0) {\n\t\tif (strcmp(command, \"changehat\") == 0) {\n\t\t\terror = aa_setprocattr_changehat(args, arg_size,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\t} else if (strcmp(command, \"permhat\") == 0) {\n\t\t\terror = aa_setprocattr_changehat(args, arg_size,\n\t\t\t\t\t\t\t AA_DO_TEST);\n\t\t} else if (strcmp(command, \"changeprofile\") == 0) {\n\t\t\terror = aa_setprocattr_changeprofile(args, !AA_ONEXEC,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\t} else if (strcmp(command, \"permprofile\") == 0) {\n\t\t\terror = aa_setprocattr_changeprofile(args, !AA_ONEXEC,\n\t\t\t\t\t\t\t AA_DO_TEST);\n\t\t} else\n\t\t\tgoto fail;\n\t} else if (strcmp(name, \"exec\") == 0) {\n\t\tif (strcmp(command, \"exec\") == 0)\n\t\t\terror = aa_setprocattr_changeprofile(args, AA_ONEXEC,\n\t\t\t\t\t\t\t !AA_DO_TEST);\n\t\telse\n\t\t\tgoto fail;\n\t} else\n\t\t/* only support the \"current\" and \"exec\" process attributes */\n\t\tgoto fail;\n\n\tif (!error)\n\t\terror = size;\nout:\n\tkfree(largs);\n\treturn error;\n\nfail:\n\tsa.type = LSM_AUDIT_DATA_NONE;\n\tsa.aad = &aad;\n\taad.profile = aa_current_profile();\n\taad.op = OP_SETPROCATTR;\n\taad.info = name;\n\taad.error = error = -EINVAL;\n\taa_audit_msg(AUDIT_APPARMOR_DENIED, &sa, NULL);\n\tgoto out;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int iwch_l2t_send(struct t3cdev *tdev, struct sk_buff *skb, struct l2t_entry *l2e)\n{\n\tint\terror = 0;\n\tstruct cxio_rdev *rdev;\n\n\trdev = (struct cxio_rdev *)tdev->ulp;\n\tif (cxio_fatal_error(rdev)) {\n\t\tkfree_skb(skb);\n\t\treturn -EIO;\n\t}\n\terror = l2t_send(tdev, skb, l2e);\n\tif (error < 0)\n\t\tkfree_skb(skb);\n\treturn error < 0 ? error : 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static bool cgm_bind_dir(const char *root, const char *dirname)\n{\n\tnih_local char *cgpath = NULL;\n\n\t/* /sys should have been mounted by now */\n\tcgpath = NIH_MUST( nih_strdup(NULL, root) );\n\tNIH_MUST( nih_strcat(&cgpath, NULL, \"/sys/fs/cgroup\") );\n\n\tif (!dir_exists(cgpath)) {\n\t\tERROR(\"%s does not exist\", cgpath);\n\t\treturn false;\n\t}\n\n\t/* mount a tmpfs there so we can create subdirs */\n\tif (mount(\"cgroup\", cgpath, \"tmpfs\", 0, \"size=10000,mode=755\")) {\n\t\tSYSERROR(\"Failed to mount tmpfs at %s\", cgpath);\n\t\treturn false;\n\t}\n\tNIH_MUST( nih_strcat(&cgpath, NULL, \"/cgmanager\") );\n\n\tif (mkdir(cgpath, 0755) < 0) {\n\t\tSYSERROR(\"Failed to create %s\", cgpath);\n\t\treturn false;\n\t}\n\n\tif (mount(dirname, cgpath, \"none\", MS_BIND, 0)) {\n\t\tSYSERROR(\"Failed to bind mount %s to %s\", dirname, cgpath);\n\t\treturn false;\n\t}\n\n\treturn true;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "static void mutex_lock_double(struct mutex *a, struct mutex *b)\n{\n\tif (b < a)\n\t\tswap(a, b);\n\n\tmutex_lock(a);\n\tmutex_lock_nested(b, SINGLE_DEPTH_NESTING);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateFloatArray( double *numbers, int count )\n{\n\tint i;\n\tcJSON *n = 0, *p = 0, *a = cJSON_CreateArray();\n\tfor ( i = 0; a && i < count; ++i ) {\n\t\tn = cJSON_CreateFloat( numbers[i] );\n\t\tif ( ! i )\n\t\t\ta->child = n;\n\t\telse\n\t\t\tsuffix_object( p, n );\n\t\tp = n;\n\t}\n\treturn a;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,\n\t\t struct cfg80211_ap_settings *params)\n{\n\tstruct ieee_types_header *rate_ie;\n\tint var_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);\n\tconst u8 *var_pos = params->beacon.head + var_offset;\n\tint len = params->beacon.head_len - var_offset;\n\tu8 rate_len = 0;\n\n\trate_ie = (void *)cfg80211_find_ie(WLAN_EID_SUPP_RATES, var_pos, len);\n\tif (rate_ie) {\n\t\tif (rate_ie->len > MWIFIEX_SUPPORTED_RATES)\n\t\t\treturn;\n\t\tmemcpy(bss_cfg->rates, rate_ie + 1, rate_ie->len);\n\t\trate_len = rate_ie->len;\n\t}\n\n\trate_ie = (void *)cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES,\n\t\t\t\t\t params->beacon.tail,\n\t\t\t\t\t params->beacon.tail_len);\n\tif (rate_ie) {\n\t\tif (rate_ie->len > MWIFIEX_SUPPORTED_RATES - rate_len)\n\t\t\treturn;\n\t\tmemcpy(bss_cfg->rates + rate_len, rate_ie + 1, rate_ie->len);\n\t}\n\n\treturn;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "ast2obj_withitem(void* _o)\n{\n withitem_ty o = (withitem_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n result = PyType_GenericNew(withitem_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_expr(o->context_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->optional_vars);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static void bt_tags_for_each(struct blk_mq_tags *tags,\n\t\tstruct blk_mq_bitmap_tags *bt, unsigned int off,\n\t\tbusy_tag_iter_fn *fn, void *data, bool reserved)\n{\n\tstruct request *rq;\n\tint bit, i;\n\n\tif (!tags->rqs)\n\t\treturn;\n\tfor (i = 0; i < bt->map_nr; i++) {\n\t\tstruct blk_align_bitmap *bm = &bt->map[i];\n\n\t\tfor (bit = find_first_bit(&bm->word, bm->depth);\n\t\t bit < bm->depth;\n\t\t bit = find_next_bit(&bm->word, bm->depth, bit + 1)) {\n\t\t\trq = blk_mq_tag_to_rq(tags, off + bit);\n\t\t\tfn(rq, data, reserved);\n\t\t}\n\n\t\toff += (1 << bt->bits_per_word);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "int rds_rdma_extra_size(struct rds_rdma_args *args)\n{\n\tstruct rds_iovec vec;\n\tstruct rds_iovec __user *local_vec;\n\tint tot_pages = 0;\n\tunsigned int nr_pages;\n\tunsigned int i;\n\n\tlocal_vec = (struct rds_iovec __user *)(unsigned long) args->local_vec_addr;\n\n\tif (args->nr_local == 0)\n\t\treturn -EINVAL;\n\n\t/* figure out the number of pages in the vector */\n\tfor (i = 0; i < args->nr_local; i++) {\n\t\tif (copy_from_user(&vec, &local_vec[i],\n\t\t\t\t sizeof(struct rds_iovec)))\n\t\t\treturn -EFAULT;\n\n\t\tnr_pages = rds_pages_in_vec(&vec);\n\t\tif (nr_pages == 0)\n\t\t\treturn -EINVAL;\n\n\t\ttot_pages += nr_pages;\n\n\t\t/*\n\t\t * nr_pages for one entry is limited to (UINT_MAX>>PAGE_SHIFT)+1,\n\t\t * so tot_pages cannot overflow without first going negative.\n\t\t */\n\t\tif (tot_pages < 0)\n\t\t\treturn -EINVAL;\n\t}\n\n\treturn tot_pages * sizeof(struct scatterlist);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_blkcipher rblkcipher;\n\n\tsnprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"givcipher\");\n\tsnprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, \"%s\",\n\t\t alg->cra_ablkcipher.geniv ?: \"\");\n\n\trblkcipher.blocksize = alg->cra_blocksize;\n\trblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;\n\trblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize;\n\trblkcipher.ivsize = alg->cra_ablkcipher.ivsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER,\n\t\t sizeof(struct crypto_report_blkcipher), &rblkcipher))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "kdc_process_s4u_x509_user(krb5_context context,\n krb5_kdc_req *request,\n krb5_pa_data *pa_data,\n krb5_keyblock *tgs_subkey,\n krb5_keyblock *tgs_session,\n krb5_pa_s4u_x509_user **s4u_x509_user,\n const char **status)\n{\n krb5_error_code code;\n krb5_data req_data;\n\n req_data.length = pa_data->length;\n req_data.data = (char *)pa_data->contents;\n\n code = decode_krb5_pa_s4u_x509_user(&req_data, s4u_x509_user);\n if (code)\n return code;\n\n code = verify_s4u_x509_user_checksum(context,\n tgs_subkey ? tgs_subkey :\n tgs_session,\n &req_data,\n request->nonce, *s4u_x509_user);\n\n if (code) {\n *status = \"INVALID_S4U2SELF_CHECKSUM\";\n krb5_free_pa_s4u_x509_user(context, *s4u_x509_user);\n *s4u_x509_user = NULL;\n return code;\n }\n\n if (krb5_princ_size(context, (*s4u_x509_user)->user_id.user) == 0 ||\n (*s4u_x509_user)->user_id.subject_cert.length != 0) {\n *status = \"INVALID_S4U2SELF_REQUEST\";\n krb5_free_pa_s4u_x509_user(context, *s4u_x509_user);\n *s4u_x509_user = NULL;\n return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN;\n }\n\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)\n{\n\tu32 hash[MD5_DIGEST_WORDS];\n\n\thash[0] = (__force u32)saddr;\n\thash[1] = (__force u32)daddr;\n\thash[2] = (__force u32)dport ^ net_secret[14];\n\thash[3] = net_secret[15];\n\n\tmd5_transform(hash, net_secret);\n\n\treturn hash[0];\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "reference_queue_proccess_all (void)\n{\n\tMonoReferenceQueue **iter;\n\tMonoReferenceQueue *queue = ref_queues;\n\tfor (; queue; queue = queue->next)\n\t\treference_queue_proccess (queue);\n\nrestart:\n\tEnterCriticalSection (&reference_queue_mutex);\n\tfor (iter = &ref_queues; *iter;) {\n\t\tqueue = *iter;\n\t\tif (!queue->should_be_deleted) {\n\t\t\titer = &queue->next;\n\t\t\tcontinue;\n\t\t}\n\t\tif (queue->queue) {\n\t\t\tLeaveCriticalSection (&reference_queue_mutex);\n\t\t\treference_queue_proccess (queue);\n\t\t\tgoto restart;\n\t\t}\n\t\t*iter = queue->next;\n\t\tg_free (queue);\n\t}\n\tLeaveCriticalSection (&reference_queue_mutex);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,\n bool *set_rtrn)\n{\n bool ok = false;\n const char *ident;\n\n switch (expr->expr.op) {\n case EXPR_VALUE:\n if (expr->expr.value_type != EXPR_TYPE_BOOLEAN) {\n log_err(ctx,\n \"Found constant of type %s where boolean was expected\\n\",\n expr_value_type_to_string(expr->expr.value_type));\n return false;\n }\n *set_rtrn = expr->boolean.set;\n return true;\n\n case EXPR_IDENT:\n ident = xkb_atom_text(ctx, expr->ident.ident);\n if (ident) {\n if (istreq(ident, \"true\") ||\n istreq(ident, \"yes\") ||\n istreq(ident, \"on\")) {\n *set_rtrn = true;\n return true;\n }\n else if (istreq(ident, \"false\") ||\n istreq(ident, \"no\") ||\n istreq(ident, \"off\")) {\n *set_rtrn = false;\n return true;\n }\n }\n log_err(ctx, \"Identifier \\\"%s\\\" of type boolean is unknown\\n\", ident);\n return false;\n\n case EXPR_FIELD_REF:\n log_err(ctx, \"Default \\\"%s.%s\\\" of type boolean is unknown\\n\",\n xkb_atom_text(ctx, expr->field_ref.element),\n xkb_atom_text(ctx, expr->field_ref.field));\n return false;\n\n case EXPR_INVERT:\n case EXPR_NOT:\n ok = ExprResolveBoolean(ctx, expr, set_rtrn);\n if (ok)\n *set_rtrn = !*set_rtrn;\n return ok;\n case EXPR_ADD:\n case EXPR_SUBTRACT:\n case EXPR_MULTIPLY:\n case EXPR_DIVIDE:\n case EXPR_ASSIGN:\n case EXPR_NEGATE:\n case EXPR_UNARY_PLUS:\n log_err(ctx, \"%s of boolean values not permitted\\n\",\n expr_op_type_to_string(expr->expr.op));\n break;\n\n default:\n log_wsgo(ctx, \"Unknown operator %d in ResolveBoolean\\n\",\n expr->expr.op);\n break;\n }\n\n return false;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,\n\t\t\t\t struct request_sock *req,\n\t\t\t\t struct dst_entry *dst)\n{\n\tstruct inet_request_sock *ireq;\n\tstruct inet_sock *newinet;\n\tstruct sock *newsk;\n\n\tif (sk_acceptq_is_full(sk))\n\t\tgoto exit_overflow;\n\n\tif (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)\n\t\tgoto exit;\n\n\tnewsk = dccp_create_openreq_child(sk, req, skb);\n\tif (newsk == NULL)\n\t\tgoto exit_nonewsk;\n\n\tsk_setup_caps(newsk, dst);\n\n\tnewinet\t\t = inet_sk(newsk);\n\tireq\t\t = inet_rsk(req);\n\tnewinet->inet_daddr\t= ireq->rmt_addr;\n\tnewinet->inet_rcv_saddr = ireq->loc_addr;\n\tnewinet->inet_saddr\t= ireq->loc_addr;\n\tnewinet->inet_opt\t= ireq->opt;\n\tireq->opt\t = NULL;\n\tnewinet->mc_index = inet_iif(skb);\n\tnewinet->mc_ttl\t = ip_hdr(skb)->ttl;\n\tnewinet->inet_id = jiffies;\n\n\tdccp_sync_mss(newsk, dst_mtu(dst));\n\n\tif (__inet_inherit_port(sk, newsk) < 0) {\n\t\tsock_put(newsk);\n\t\tgoto exit;\n\t}\n\t__inet_hash_nolisten(newsk, NULL);\n\n\treturn newsk;\n\nexit_overflow:\n\tNET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);\nexit_nonewsk:\n\tdst_release(dst);\nexit:\n\tNET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);\n\treturn NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si)\n{\n\ts32 pps_id;\n\n\t/*s->current_picture.reference= h->nal_ref_idc != 0;*/\n\tgf_bs_read_ue_log(bs, \"first_mb_in_slice\");\n\tsi->slice_type = gf_bs_read_ue_log(bs, \"slice_type\");\n\tif (si->slice_type > 9) return -1;\n\n\tpps_id = gf_bs_read_ue_log(bs, \"pps_id\");\n\tif (pps_id > 255)\n\t\treturn -1;\n\tsi->pps = &avc->pps[pps_id];\n\tsi->pps->id = pps_id;\n\tif (!si->pps->slice_group_count)\n\t\treturn -2;\n\tsi->sps = &avc->sps[si->pps->sps_id + GF_SVC_SSPS_ID_SHIFT];\n\tif (!si->sps->log2_max_frame_num)\n\t\treturn -2;\n\n\tsi->frame_num = gf_bs_read_int_log(bs, si->sps->log2_max_frame_num, \"frame_num\");\n\n\tsi->field_pic_flag = 0;\n\tif (si->sps->frame_mbs_only_flag) {\n\t\t/*s->picture_structure= PICT_FRAME;*/\n\t}\n\telse {\n\t\tsi->field_pic_flag = gf_bs_read_int_log(bs, 1, \"field_pic_flag\");\n\t\tif (si->field_pic_flag) si->bottom_field_flag = gf_bs_read_int_log(bs, 1, \"bottom_field_flag\");\n\t}\n\tif (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE || si->NalHeader.idr_pic_flag)\n\t\tsi->idr_pic_id = gf_bs_read_ue_log(bs, \"idr_pic_id\");\n\n\tif (si->sps->poc_type == 0) {\n\t\tsi->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, \"poc_lsb\");\n\t\tif (si->pps->pic_order_present && !si->field_pic_flag) {\n\t\t\tsi->delta_poc_bottom = gf_bs_read_se_log(bs, \"delta_poc_bottom\");\n\t\t}\n\t}\n\telse if ((si->sps->poc_type == 1) && !si->sps->delta_pic_order_always_zero_flag) {\n\t\tsi->delta_poc[0] = gf_bs_read_se_log(bs, \"delta_poc0\");\n\t\tif ((si->pps->pic_order_present == 1) && !si->field_pic_flag)\n\t\t\tsi->delta_poc[1] = gf_bs_read_se_log(bs, \"delta_poc1\");\n\t}\n\tif (si->pps->redundant_pic_cnt_present) {\n\t\tsi->redundant_pic_cnt = gf_bs_read_ue_log(bs, \"redundant_pic_cnt\");\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "SPL_METHOD(SplFileObject, fread)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tlong length = 0;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &length) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (length <= 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Length parameter must be greater than 0\");\n\t\tRETURN_FALSE;\n\t}\n\tif (length > INT_MAX) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Length parameter must be no more than %d\", INT_MAX);\n\t\tRETURN_FALSE;\n\t}\n\n\tZ_STRVAL_P(return_value) = emalloc(length + 1);\n\tZ_STRLEN_P(return_value) = php_stream_read(intern->u.file.stream, Z_STRVAL_P(return_value), length);\n\n\t/* needed because recv/read/gzread doesnt put a null at the end*/\n\tZ_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;\n\tZ_TYPE_P(return_value) = IS_STRING;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "__u32 secure_ipv6_id(const __be32 daddr[4])\n{\n\tconst struct keydata *keyptr;\n\t__u32 hash[4];\n\n\tkeyptr = get_keyptr();\n\n\thash[0] = (__force __u32)daddr[0];\n\thash[1] = (__force __u32)daddr[1];\n\thash[2] = (__force __u32)daddr[2];\n\thash[3] = (__force __u32)daddr[3];\n\n\treturn half_md4_transform(hash, keyptr->secret);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "DECLAREreadFunc(readContigTilesIntoBuffer)\n{\n\tint status = 1;\n\ttsize_t tilesize = TIFFTileSize(in);\n\ttdata_t tilebuf;\n\tuint32 imagew = TIFFScanlineSize(in);\n\tuint32 tilew = TIFFTileRowSize(in);\n\tint iskew = imagew - tilew;\n\tuint8* bufp = (uint8*) buf;\n\tuint32 tw, tl;\n\tuint32 row;\n\n\t(void) spp;\n\ttilebuf = _TIFFmalloc(tilesize);\n\tif (tilebuf == 0)\n\t\treturn 0;\n\t_TIFFmemset(tilebuf, 0, tilesize);\n\t(void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);\n\t(void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);\n \n\tfor (row = 0; row < imagelength; row += tl) {\n\t\tuint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;\n\t\tuint32 colb = 0;\n\t\tuint32 col;\n\n\t\tfor (col = 0; col < imagewidth; col += tw) {\n\t\t\tif (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0\n\t\t\t && !ignore) {\n\t\t\t\tTIFFError(TIFFFileName(in),\n\t\t\t\t \"Error, can't read tile at %lu %lu\",\n\t\t\t\t (unsigned long) col,\n\t\t\t\t (unsigned long) row);\n\t\t\t\tstatus = 0;\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t\tif (colb + tilew > imagew) {\n\t\t\t\tuint32 width = imagew - colb;\n\t\t\t\tuint32 oskew = tilew - width;\n\t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, width,\n\t\t\t\t oskew + iskew, oskew );\n\t\t\t} else\n\t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, tilew,\n\t\t\t\t iskew, 0);\n\t\t\tcolb += tilew;\n\t\t}\n\t\tbufp += imagew * nrow;\n\t}\ndone:\n\t_TIFFfree(tilebuf);\n\treturn status;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static void iwjpeg_scan_exif_ifd(struct iwjpegrcontext *rctx,\n\tstruct iw_exif_state *e, iw_uint32 ifd)\n{\n\tunsigned int tag_count;\n\tunsigned int i;\n\tunsigned int tag_pos;\n\tunsigned int tag_id;\n\tunsigned int v;\n\tdouble v_dbl;\n\n\tif(ifd<8 || e->d_len<18 || ifd>e->d_len-18) return;\n\n\ttag_count = get_exif_ui16(e, ifd);\n\tif(tag_count>1000) return; // Sanity check.\n\n\tfor(i=0;i e->d_len) return; // Avoid overruns.\n\t\ttag_id = get_exif_ui16(e, tag_pos);\n\n\t\tswitch(tag_id) {\n\t\tcase 274: // 274 = Orientation\n\t\t\tif(get_exif_tag_int_value(e,tag_pos,&v)) {\n\t\t\t\trctx->exif_orientation = v;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 296: // 296 = ResolutionUnit\n\t\t\tif(get_exif_tag_int_value(e,tag_pos,&v)) {\n\t\t\t\trctx->exif_density_unit = v;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 282: // 282 = XResolution\n\t\t\tif(get_exif_tag_dbl_value(e,tag_pos,&v_dbl)) {\n\t\t\t\trctx->exif_density_x = v_dbl;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 283: // 283 = YResolution\n\t\t\tif(get_exif_tag_dbl_value(e,tag_pos,&v_dbl)) {\n\t\t\t\trctx->exif_density_y = v_dbl;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void mspack_fmap_free(void *mem)\n{\n if(mem) {\n free(mem);\n mem = NULL;\n }\n return;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int generic_permission(struct inode *inode, int mask)\n{\n\tint ret;\n\n\t/*\n\t * Do the basic permission checks.\n\t */\n\tret = acl_permission_check(inode, mask);\n\tif (ret != -EACCES)\n\t\treturn ret;\n\n\tif (S_ISDIR(inode->i_mode)) {\n\t\t/* DACs are overridable for directories */\n\t\tif (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))\n\t\t\treturn 0;\n\t\tif (!(mask & MAY_WRITE))\n\t\t\tif (capable_wrt_inode_uidgid(inode,\n\t\t\t\t\t\t CAP_DAC_READ_SEARCH))\n\t\t\t\treturn 0;\n\t\treturn -EACCES;\n\t}\n\t/*\n\t * Read/write DACs are always overridable.\n\t * Executable DACs are overridable when there is\n\t * at least one exec bit set.\n\t */\n\tif (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))\n\t\tif (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))\n\t\t\treturn 0;\n\n\t/*\n\t * Searching includes executable on directories, else just read.\n\t */\n\tmask &= MAY_READ | MAY_WRITE | MAY_EXEC;\n\tif (mask == MAY_READ)\n\t\tif (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))\n\t\t\treturn 0;\n\n\treturn -EACCES;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_blkcipher rblkcipher;\n\n\tsnprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"blkcipher\");\n\tsnprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, \"%s\",\n\t\t alg->cra_blkcipher.geniv ?: \"\");\n\n\trblkcipher.blocksize = alg->cra_blocksize;\n\trblkcipher.min_keysize = alg->cra_blkcipher.min_keysize;\n\trblkcipher.max_keysize = alg->cra_blkcipher.max_keysize;\n\trblkcipher.ivsize = alg->cra_blkcipher.ivsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER,\n\t\t sizeof(struct crypto_report_blkcipher), &rblkcipher))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "static void print_value(int output, int num, const char *devname,\n\t\t\tconst char *value, const char *name, size_t valsz)\n{\n\tif (output & OUTPUT_VALUE_ONLY) {\n\t\tfputs(value, stdout);\n\t\tfputc('\\n', stdout);\n\n\t} else if (output & OUTPUT_UDEV_LIST) {\n\t\tprint_udev_format(name, value);\n\n\t} else if (output & OUTPUT_EXPORT_LIST) {\n\t\tif (num == 1 && devname)\n\t\t\tprintf(\"DEVNAME=%s\\n\", devname);\n\t\tfputs(name, stdout);\n\t\tfputs(\"=\", stdout);\n\t\tsafe_print(value, valsz, NULL);\n\t\tfputs(\"\\n\", stdout);\n\n\t} else {\n\t\tif (num == 1 && devname)\n\t\t\tprintf(\"%s:\", devname);\n\t\tfputs(\" \", stdout);\n\t\tfputs(name, stdout);\n\t\tfputs(\"=\\\"\", stdout);\n\t\tsafe_print(value, valsz, \"\\\"\");\n\t\tfputs(\"\\\"\", stdout);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "const char * util_acl_to_str(const sc_acl_entry_t *e)\n{\n\tstatic char line[80], buf[20];\n\tunsigned int acl;\n\n\tif (e == NULL)\n\t\treturn \"N/A\";\n\tline[0] = 0;\n\twhile (e != NULL) {\n\t\tacl = e->method;\n\n\t\tswitch (acl) {\n\t\tcase SC_AC_UNKNOWN:\n\t\t\treturn \"N/A\";\n\t\tcase SC_AC_NEVER:\n\t\t\treturn \"NEVR\";\n\t\tcase SC_AC_NONE:\n\t\t\treturn \"NONE\";\n\t\tcase SC_AC_CHV:\n\t\t\tstrcpy(buf, \"CHV\");\n\t\t\tif (e->key_ref != SC_AC_KEY_REF_NONE)\n\t\t\t\tsprintf(buf + 3, \"%d\", e->key_ref);\n\t\t\tbreak;\n\t\tcase SC_AC_TERM:\n\t\t\tstrcpy(buf, \"TERM\");\n\t\t\tbreak;\n\t\tcase SC_AC_PRO:\n\t\t\tstrcpy(buf, \"PROT\");\n\t\t\tbreak;\n\t\tcase SC_AC_AUT:\n\t\t\tstrcpy(buf, \"AUTH\");\n\t\t\tif (e->key_ref != SC_AC_KEY_REF_NONE)\n\t\t\t\tsprintf(buf + 4, \"%d\", e->key_ref);\n\t\t\tbreak;\n\t\tcase SC_AC_SEN:\n\t\t\tstrcpy(buf, \"Sec.Env. \");\n\t\t\tif (e->key_ref != SC_AC_KEY_REF_NONE)\n\t\t\t\tsprintf(buf + 3, \"#%d\", e->key_ref);\n\t\t\tbreak;\n\t\tcase SC_AC_SCB:\n\t\t\tstrcpy(buf, \"Sec.ControlByte \");\n\t\t\tif (e->key_ref != SC_AC_KEY_REF_NONE)\n\t\t\t\tsprintf(buf + 3, \"Ox%X\", e->key_ref);\n\t\t\tbreak;\n\t\tcase SC_AC_IDA:\n\t\t\tstrcpy(buf, \"PKCS#15 AuthID \");\n\t\t\tif (e->key_ref != SC_AC_KEY_REF_NONE)\n\t\t\t\tsprintf(buf + 3, \"#%d\", e->key_ref);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstrcpy(buf, \"????\");\n\t\t\tbreak;\n\t\t}\n\t\tstrcat(line, buf);\n\t\tstrcat(line, \" \");\n\t\te = e->next;\n\t}\n\tline[strlen(line)-1] = 0; /* get rid of trailing space */\n\treturn line;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *m, size_t len, int flags)\n\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint ret;\n\tint copylen;\n\n\tret = -EOPNOTSUPP;\n\tif (m->msg_flags&MSG_OOB)\n\t\tgoto read_error;\n\n\tm->msg_namelen = 0;\n\n\tskb = skb_recv_datagram(sk, flags, 0 , &ret);\n\tif (!skb)\n\t\tgoto read_error;\n\tcopylen = skb->len;\n\tif (len < copylen) {\n\t\tm->msg_flags |= MSG_TRUNC;\n\t\tcopylen = len;\n\t}\n\n\tret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);\n\tif (ret)\n\t\tgoto out_free;\n\n\tret = (flags & MSG_TRUNC) ? skb->len : copylen;\nout_free:\n\tskb_free_datagram(sk, skb);\n\tcaif_check_flow_release(sk);\n\treturn ret;\n\nread_error:\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "parsegid(const char *s, gid_t *gid)\n{\n\tstruct group *gr;\n\tconst char *errstr;\n\n\tif ((gr = getgrnam(s)) != NULL) {\n\t\t*gid = gr->gr_gid;\n\t\treturn 0;\n\t}\n\t#if !defined(__linux__) && !defined(__NetBSD__)\n\t*gid = strtonum(s, 0, GID_MAX, &errstr);\n\t#else\n\tsscanf(s, \"%d\", gid);\n\t#endif\n\tif (errstr)\n\t\treturn -1;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-908", "cwe_name": "Use of Uninitialized Resource", "description": "The software uses or accesses a resource that has not been initialized.", "url": "https://cwe.mitre.org/data/definitions/908.html", "label_name": "vulnerable"} {"code": "static int dccp_error(struct net *net, struct nf_conn *tmpl,\n\t\t struct sk_buff *skb, unsigned int dataoff,\n\t\t enum ip_conntrack_info *ctinfo,\n\t\t u_int8_t pf, unsigned int hooknum)\n{\n\tstruct dccp_hdr _dh, *dh;\n\tunsigned int dccp_len = skb->len - dataoff;\n\tunsigned int cscov;\n\tconst char *msg;\n\n\tdh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);\n\tif (dh == NULL) {\n\t\tmsg = \"nf_ct_dccp: short packet \";\n\t\tgoto out_invalid;\n\t}\n\n\tif (dh->dccph_doff * 4 < sizeof(struct dccp_hdr) ||\n\t dh->dccph_doff * 4 > dccp_len) {\n\t\tmsg = \"nf_ct_dccp: truncated/malformed packet \";\n\t\tgoto out_invalid;\n\t}\n\n\tcscov = dccp_len;\n\tif (dh->dccph_cscov) {\n\t\tcscov = (dh->dccph_cscov - 1) * 4;\n\t\tif (cscov > dccp_len) {\n\t\t\tmsg = \"nf_ct_dccp: bad checksum coverage \";\n\t\t\tgoto out_invalid;\n\t\t}\n\t}\n\n\tif (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&\n\t nf_checksum_partial(skb, hooknum, dataoff, cscov, IPPROTO_DCCP,\n\t\t\t\tpf)) {\n\t\tmsg = \"nf_ct_dccp: bad checksum \";\n\t\tgoto out_invalid;\n\t}\n\n\tif (dh->dccph_type >= DCCP_PKT_INVALID) {\n\t\tmsg = \"nf_ct_dccp: reserved packet type \";\n\t\tgoto out_invalid;\n\t}\n\n\treturn NF_ACCEPT;\n\nout_invalid:\n\tif (LOG_INVALID(net, IPPROTO_DCCP))\n\t\tnf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, \"%s\", msg);\n\treturn -NF_ACCEPT;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "char *cJSON_PrintUnformatted( cJSON *item )\n{\n\treturn print_value( item, 0, 0 );\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)\n{\n\tstruct dwc3_gadget_ep_cmd_params params;\n\tstruct dwc3_request\t\t*req;\n\tint\t\t\t\tstarting;\n\tint\t\t\t\tret;\n\tu32\t\t\t\tcmd;\n\n\tif (!dwc3_calc_trbs_left(dep))\n\t\treturn 0;\n\n\tstarting = !(dep->flags & DWC3_EP_BUSY);\n\n\tdwc3_prepare_trbs(dep);\n\treq = next_request(&dep->started_list);\n\tif (!req) {\n\t\tdep->flags |= DWC3_EP_PENDING_REQUEST;\n\t\treturn 0;\n\t}\n\n\tmemset(¶ms, 0, sizeof(params));\n\n\tif (starting) {\n\t\tparams.param0 = upper_32_bits(req->trb_dma);\n\t\tparams.param1 = lower_32_bits(req->trb_dma);\n\t\tcmd = DWC3_DEPCMD_STARTTRANSFER;\n\n\t\tif (usb_endpoint_xfer_isoc(dep->endpoint.desc))\n\t\t\tcmd |= DWC3_DEPCMD_PARAM(dep->frame_number);\n\t} else {\n\t\tcmd = DWC3_DEPCMD_UPDATETRANSFER |\n\t\t\tDWC3_DEPCMD_PARAM(dep->resource_index);\n\t}\n\n\tret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);\n\tif (ret < 0) {\n\t\t/*\n\t\t * FIXME we need to iterate over the list of requests\n\t\t * here and stop, unmap, free and del each of the linked\n\t\t * requests instead of what we do now.\n\t\t */\n\t\tif (req->trb)\n\t\t\tmemset(req->trb, 0, sizeof(struct dwc3_trb));\n\t\tdep->queued_requests--;\n\t\tdwc3_gadget_del_and_unmap_request(dep, req, ret);\n\t\treturn ret;\n\t}\n\n\tdep->flags |= DWC3_EP_BUSY;\n\n\tif (starting) {\n\t\tdep->resource_index = dwc3_gadget_ep_get_transfer_index(dep);\n\t\tWARN_ON_ONCE(!dep->resource_index);\n\t}\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-667", "cwe_name": "Improper Locking", "description": "The software does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors.", "url": "https://cwe.mitre.org/data/definitions/667.html", "label_name": "safe"} {"code": "parse_memory(VALUE klass, VALUE data)\n{\n xmlParserCtxtPtr ctxt;\n\n if (NIL_P(data)) {\n rb_raise(rb_eArgError, \"data cannot be nil\");\n }\n if (!(int)RSTRING_LEN(data)) {\n rb_raise(rb_eRuntimeError, \"data cannot be empty\");\n }\n\n ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(data),\n (int)RSTRING_LEN(data));\n if (ctxt->sax) {\n xmlFree(ctxt->sax);\n ctxt->sax = NULL;\n }\n\n return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-241", "cwe_name": "Improper Handling of Unexpected Data Type", "description": "The software does not handle or incorrectly handles when a particular element is not the expected type, e.g. it expects a digit (0-9) but is provided with a letter (A-Z).", "url": "https://cwe.mitre.org/data/definitions/241.html", "label_name": "vulnerable"} {"code": "struct vfsmount *collect_mounts(struct path *path)\n{\n\tstruct mount *tree;\n\tnamespace_lock();\n\tif (!check_mnt(real_mount(path->mnt)))\n\t\ttree = ERR_PTR(-EINVAL);\n\telse\n\t\ttree = copy_tree(real_mount(path->mnt), path->dentry,\n\t\t\t\t CL_COPY_ALL | CL_PRIVATE);\n\tnamespace_unlock();\n\tif (IS_ERR(tree))\n\t\treturn ERR_CAST(tree);\n\treturn &tree->mnt;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "int read_header_tga(gdIOCtx *ctx, oTga *tga)\n{\n\n\tunsigned char header[18];\n\n\tif (gdGetBuf(header, sizeof(header), ctx) < 18) {\n\t\tgd_error(\"fail to read header\");\n\t\treturn -1;\n\t}\n\n\ttga->identsize = header[0];\n\ttga->colormaptype = header[1];\n\ttga->imagetype = header[2];\n\ttga->colormapstart = header[3] + (header[4] << 8);\n\ttga->colormaplength = header[5] + (header[6] << 8);\n\ttga->colormapbits = header[7];\n\ttga->xstart = header[8] + (header[9] << 8);\n\ttga->ystart = header[10] + (header[11] << 8);\n\ttga->width = header[12] + (header[13] << 8);\n\ttga->height = header[14] + (header[15] << 8);\n\ttga->bits = header[16];\n\ttga->alphabits = header[17] & 0x0f;\n\ttga->fliph = (header[17] & 0x10) ? 1 : 0;\n\ttga->flipv = (header[17] & 0x20) ? 0 : 1;\n\n#if DEBUG\n\tprintf(\"format bps: %i\\n\", tga->bits);\n\tprintf(\"flip h/v: %i / %i\\n\", tga->fliph, tga->flipv);\n\tprintf(\"alpha: %i\\n\", tga->alphabits);\n\tprintf(\"wxh: %i %i\\n\", tga->width, tga->height);\n#endif\n\n\tswitch(tga->bits) {\n\tcase 8:\n\tcase 16:\n\tcase 24:\n\tcase 32:\n\t\tbreak;\n\tdefault:\n\t\tgd_error(\"bps %i not supported\", tga->bits);\n\t\treturn -1;\n\t\tbreak;\n\t}\n\n\ttga->ident = NULL;\n\n\tif (tga->identsize > 0) {\n\t\ttga->ident = (char *) gdMalloc(tga->identsize * sizeof(char));\n\t\tif(tga->ident == NULL) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tgdGetBuf(tga->ident, tga->identsize, ctx);\n\t}\n\n\treturn 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int ip_options_get_from_user(struct net *net, struct ip_options **optp,\n\t\t\t unsigned char __user *data, int optlen)\n{\n\tstruct ip_options *opt = ip_options_get_alloc(optlen);\n\n\tif (!opt)\n\t\treturn -ENOMEM;\n\tif (optlen && copy_from_user(opt->__data, data, optlen)) {\n\t\tkfree(opt);\n\t\treturn -EFAULT;\n\t}\n\treturn ip_options_get_finish(net, optp, opt, optlen);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static noinline int btrfs_mksubvol(struct path *parent,\n\t\t\t\t char *name, int namelen,\n\t\t\t\t struct btrfs_root *snap_src,\n\t\t\t\t u64 *async_transid, bool readonly,\n\t\t\t\t struct btrfs_qgroup_inherit **inherit)\n{\n\tstruct inode *dir = parent->dentry->d_inode;\n\tstruct dentry *dentry;\n\tint error;\n\n\tmutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);\n\n\tdentry = lookup_one_len(name, parent->dentry, namelen);\n\terror = PTR_ERR(dentry);\n\tif (IS_ERR(dentry))\n\t\tgoto out_unlock;\n\n\terror = -EEXIST;\n\tif (dentry->d_inode)\n\t\tgoto out_dput;\n\n\terror = btrfs_may_create(dir, dentry);\n\tif (error)\n\t\tgoto out_dput;\n\n\t/*\n\t * even if this name doesn't exist, we may get hash collisions.\n\t * check for them now when we can safely fail\n\t */\n\terror = btrfs_check_dir_item_collision(BTRFS_I(dir)->root,\n\t\t\t\t\t dir->i_ino, name,\n\t\t\t\t\t namelen);\n\tif (error)\n\t\tgoto out_dput;\n\n\tdown_read(&BTRFS_I(dir)->root->fs_info->subvol_sem);\n\n\tif (btrfs_root_refs(&BTRFS_I(dir)->root->root_item) == 0)\n\t\tgoto out_up_read;\n\n\tif (snap_src) {\n\t\terror = create_snapshot(snap_src, dentry, name, namelen,\n\t\t\t\t\tasync_transid, readonly, inherit);\n\t} else {\n\t\terror = create_subvol(BTRFS_I(dir)->root, dentry,\n\t\t\t\t name, namelen, async_transid, inherit);\n\t}\n\tif (!error)\n\t\tfsnotify_mkdir(dir, dentry);\nout_up_read:\n\tup_read(&BTRFS_I(dir)->root->fs_info->subvol_sem);\nout_dput:\n\tdput(dentry);\nout_unlock:\n\tmutex_unlock(&dir->i_mutex);\n\treturn error;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "spnego_gss_set_sec_context_option(\n\t\tOM_uint32 *minor_status,\n\t\tgss_ctx_id_t *context_handle,\n\t\tconst gss_OID desired_object,\n\t\tconst gss_buffer_t value)\n{\n\tOM_uint32 ret;\n\tspnego_gss_ctx_id_t sc = (spnego_gss_ctx_id_t)*context_handle;\n\n\t/* There are no SPNEGO-specific OIDs for this function, and we cannot\n\t * construct an empty SPNEGO context with it. */\n\tif (sc == NULL || sc->ctx_handle == GSS_C_NO_CONTEXT)\n\t\treturn (GSS_S_UNAVAILABLE);\n\n\tret = gss_set_sec_context_option(minor_status,\n\t\t\t &sc->ctx_handle,\n\t\t\t desired_object,\n\t\t\t value);\n\treturn (ret);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "safe"} {"code": "test_save_copy (const char *origname)\n{\n char buf[TESTBUFSIZE];\n int ret;\n\n snprintf_func (buf, TESTBUFSIZE, \"cp -f %s %s\", origname, TEST_COPY_FILE);\n\n if ((ret = system (buf)) != 0)\n {\n return XD3_INTERNAL;\n }\n\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_rpsi(\n\t\t\t\t\t pjmedia_rtcp_session *session, \n\t\t\t\t\t void *buf,\n\t\t\t\t\t pj_size_t *length,\n\t\t\t\t\t const pjmedia_rtcp_fb_rpsi *rpsi)\n{\n pjmedia_rtcp_common *hdr;\n pj_uint8_t *p;\n unsigned bitlen, padlen, len;\n\n PJ_ASSERT_RETURN(session && buf && length && rpsi, PJ_EINVAL);\n\n bitlen = (unsigned)rpsi->rpsi_bit_len + 16;\n padlen = (32 - (bitlen % 32)) % 32;\n len = (3 + (bitlen+padlen)/32) * 4;\n if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n /* Build RTCP-FB RPSI header */\n hdr = (pjmedia_rtcp_common*)buf;\n pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));\n hdr->pt = RTCP_PSFB;\n hdr->count = 3; /* FMT = 3 */\n hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));\n\n /* Build RTCP-FB RPSI FCI */\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n /* PB (number of padding bits) */\n *p++ = (pj_uint8_t)padlen;\n /* Payload type */\n *p++ = rpsi->pt & 0x7F;\n /* RPSI bit string */\n pj_memcpy(p, rpsi->rpsi.ptr, rpsi->rpsi_bit_len/8);\n p += rpsi->rpsi_bit_len/8;\n if (rpsi->rpsi_bit_len % 8) {\n\t*p++ = *(rpsi->rpsi.ptr + rpsi->rpsi_bit_len/8);\n }\n /* Zero padding */\n if (padlen >= 8)\n\tpj_bzero(p, padlen/8);\n\n /* Finally */\n *length = len;\n\n return PJ_SUCCESS;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int atusb_read_reg(struct atusb *atusb, uint8_t reg)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tint ret;\n\tuint8_t *buffer;\n\tuint8_t value;\n\n\tbuffer = kmalloc(1, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\tdev_dbg(&usb_dev->dev, \"atusb: reg = 0x%x\\n\", reg);\n\tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n\t\t\t\tATUSB_REG_READ, ATUSB_REQ_FROM_DEV,\n\t\t\t\t0, reg, buffer, 1, 1000);\n\n\tif (ret >= 0) {\n\t\tvalue = buffer[0];\n\t\tkfree(buffer);\n\t\treturn value;\n\t} else {\n\t\tkfree(buffer);\n\t\treturn ret;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "PUBLIC cchar *mprGetJson(MprJson *obj, cchar *key)\n{\n MprJson *result;\n\n if (key && !strpbrk(key, \".[]*\")) {\n return mprLookupJson(obj, key);\n }\n if ((result = mprQueryJson(obj, key, 0, 0)) != 0) {\n if (result->length == 1 && result->children->type & MPR_JSON_VALUE) {\n return result->children->value;\n } else if (result->length > 1) {\n return mprJsonToString(result, 0);\n }\n }\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "SPL_METHOD(DirectoryIterator, getFilename)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tRETURN_STRING(intern->u.dir.entry.d_name, 1);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static int amd_gpio_remove(struct platform_device *pdev)\n{\n\tstruct amd_gpio *gpio_dev;\n\n\tgpio_dev = platform_get_drvdata(pdev);\n\n\tgpiochip_remove(&gpio_dev->gc);\n\tpinctrl_unregister(gpio_dev->pctrl);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "ex_function(exarg_T *eap)\n{\n (void)define_function(eap, NULL);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int snd_compress_check_input(struct snd_compr_params *params)\n{\n\t/* first let's check the buffer parameter's */\n\tif (params->buffer.fragment_size == 0 ||\n\t params->buffer.fragments > INT_MAX / params->buffer.fragment_size)\n\t\treturn -EINVAL;\n\n\t/* now codec parameters */\n\tif (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX)\n\t\treturn -EINVAL;\n\n\tif (params->codec.ch_in == 0 || params->codec.ch_out == 0)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static int read_private_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tconst sc_acl_entry_t *e;\n\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I0012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\te = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\tif (e == NULL || e->method == SC_AC_NEVER)\n\t\treturn 10;\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_private_key(p, keysize, rsa);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void handle_PORT(ctrl_t *ctrl, char *str)\n{\n\tint a, b, c, d, e, f;\n\tchar addr[INET_ADDRSTRLEN];\n\tstruct sockaddr_in sin;\n\n\tif (ctrl->data_sd > 0) {\n\t\tuev_io_stop(&ctrl->data_watcher);\n\t\tclose(ctrl->data_sd);\n\t\tctrl->data_sd = -1;\n\t}\n\n\t/* Convert PORT command's argument to IP address + port */\n\tsscanf(str, \"%d,%d,%d,%d,%d,%d\", &a, &b, &c, &d, &e, &f);\n\tsprintf(addr, \"%d.%d.%d.%d\", a, b, c, d);\n\n\t/* Check IPv4 address using inet_aton(), throw away converted result */\n\tif (!inet_aton(addr, &(sin.sin_addr))) {\n\t\tERR(0, \"Invalid address '%s' given to PORT command\", addr);\n\t\tsend_msg(ctrl->sd, \"500 Illegal PORT command.\\r\\n\");\n\t\treturn;\n\t}\n\n\tstrlcpy(ctrl->data_address, addr, sizeof(ctrl->data_address));\n\tctrl->data_port = e * 256 + f;\n\n\tDBG(\"Client PORT command accepted for %s:%d\", ctrl->data_address, ctrl->data_port);\n\tsend_msg(ctrl->sd, \"200 PORT command successful.\\r\\n\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void rdp_read_flow_control_pdu(wStream* s, UINT16* type)\n{\n\t/*\n\t * Read flow control PDU - documented in FlowPDU section in T.128\n\t * http://www.itu.int/rec/T-REC-T.128-199802-S/en\n\t * The specification for the PDU has pad8bits listed BEFORE pduTypeFlow.\n\t * However, so far pad8bits has always been observed to arrive AFTER pduTypeFlow.\n\t * Switched the order of these two fields to match this observation.\n\t */\n\tUINT8 pduType;\n\tStream_Read_UINT8(s, pduType); /* pduTypeFlow */\n\t*type = pduType;\n\tStream_Seek_UINT8(s); /* pad8bits */\n\tStream_Seek_UINT8(s); /* flowIdentifier */\n\tStream_Seek_UINT8(s); /* flowNumber */\n\tStream_Seek_UINT16(s); /* pduSource */\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,\n UINT16* flags)\n{\n\tBYTE bitsPerPixelId;\n\tBITMAP_DATA_EX* bitmapData;\n\n\tif (!Stream_EnsureRemainingCapacity(\n\t s, update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, flags)))\n\t\treturn FALSE;\n\n\tbitmapData = &cache_bitmap_v3->bitmapData;\n\tbitsPerPixelId = BPP_CBR23[cache_bitmap_v3->bpp];\n\t*flags = (cache_bitmap_v3->cacheId & 0x00000003) |\n\t ((cache_bitmap_v3->flags << 7) & 0x0000FF80) | ((bitsPerPixelId << 3) & 0x00000078);\n\tStream_Write_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */\n\tStream_Write_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */\n\tStream_Write_UINT8(s, bitmapData->bpp);\n\tStream_Write_UINT8(s, 0); /* reserved1 (1 byte) */\n\tStream_Write_UINT8(s, 0); /* reserved2 (1 byte) */\n\tStream_Write_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */\n\tStream_Write_UINT16(s, bitmapData->width); /* width (2 bytes) */\n\tStream_Write_UINT16(s, bitmapData->height); /* height (2 bytes) */\n\tStream_Write_UINT32(s, bitmapData->length); /* length (4 bytes) */\n\tStream_Write(s, bitmapData->data, bitmapData->length);\n\treturn TRUE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "service_info *FindServiceControlURLPath(\n\tservice_table *table, const char *controlURLPath)\n{\n\tservice_info *finger = NULL;\n\turi_type parsed_url;\n\turi_type parsed_url_in;\n\n\tif (table && parse_uri(controlURLPath,\n\t\t\t strlen(controlURLPath),\n\t\t\t &parsed_url_in) == HTTP_SUCCESS) {\n\t\tfinger = table->serviceList;\n\t\twhile (finger) {\n\t\t\tif (finger->controlURL) {\n\t\t\t\tif (parse_uri(finger->controlURL,\n\t\t\t\t\t strlen(finger->controlURL),\n\t\t\t\t\t &parsed_url) == HTTP_SUCCESS) {\n\t\t\t\t\tif (!token_cmp(&parsed_url.pathquery,\n\t\t\t\t\t\t &parsed_url_in.pathquery)) {\n\t\t\t\t\t\treturn finger;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinger = finger->next;\n\t\t}\n\t}\n\n\treturn NULL;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "DefragTimeoutTest(void)\n{\n int i;\n int ret = 0;\n\n /* Setup a small numberr of trackers. */\n if (ConfSet(\"defrag.trackers\", \"16\") != 1) {\n printf(\"ConfSet failed: \");\n goto end;\n }\n\n DefragInit();\n\n /* Load in 16 packets. */\n for (i = 0; i < 16; i++) {\n Packet *p = BuildTestPacket(i, 0, 1, 'A' + i, 16);\n if (p == NULL)\n goto end;\n\n Packet *tp = Defrag(NULL, NULL, p, NULL);\n\n SCFree(p);\n\n if (tp != NULL) {\n SCFree(tp);\n goto end;\n }\n }\n\n /* Build a new packet but push the timestamp out by our timeout.\n * This should force our previous fragments to be timed out. */\n Packet *p = BuildTestPacket(99, 0, 1, 'A' + i, 16);\n if (p == NULL)\n goto end;\n\n p->ts.tv_sec += (defrag_context->timeout + 1);\n Packet *tp = Defrag(NULL, NULL, p, NULL);\n\n if (tp != NULL) {\n SCFree(tp);\n goto end;\n }\n\n DefragTracker *tracker = DefragLookupTrackerFromHash(p);\n if (tracker == NULL)\n goto end;\n\n if (tracker->id != 99)\n goto end;\n\n SCFree(p);\n\n ret = 1;\nend:\n DefragDestroy();\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "vulnerable"} {"code": "static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,\n\t\tstruct snd_compr_params *params)\n{\n\tunsigned int buffer_size;\n\tvoid *buffer;\n\n\tif (params->buffer.fragment_size == 0 ||\n\t params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size)\n\t\treturn -EINVAL;\n\n\tbuffer_size = params->buffer.fragment_size * params->buffer.fragments;\n\tif (stream->ops->copy) {\n\t\tbuffer = NULL;\n\t\t/* if copy is defined the driver will be required to copy\n\t\t * the data from core\n\t\t */\n\t} else {\n\t\tbuffer = kmalloc(buffer_size, GFP_KERNEL);\n\t\tif (!buffer)\n\t\t\treturn -ENOMEM;\n\t}\n\tstream->runtime->fragment_size = params->buffer.fragment_size;\n\tstream->runtime->fragments = params->buffer.fragments;\n\tstream->runtime->buffer = buffer;\n\tstream->runtime->buffer_size = buffer_size;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,\n\t\t\t\t\t unsigned long addr,\n\t\t\t\t\t unsigned long length)\n{\n\tunsigned long result = 0;\n\n\tswitch (ioapic->ioregsel) {\n\tcase IOAPIC_REG_VERSION:\n\t\tresult = ((((IOAPIC_NUM_PINS - 1) & 0xff) << 16)\n\t\t\t | (IOAPIC_VERSION_ID & 0xff));\n\t\tbreak;\n\n\tcase IOAPIC_REG_APIC_ID:\n\tcase IOAPIC_REG_ARB_ID:\n\t\tresult = ((ioapic->id & 0xf) << 24);\n\t\tbreak;\n\n\tdefault:\n\t\t{\n\t\t\tu32 redir_index = (ioapic->ioregsel - 0x10) >> 1;\n\t\t\tu64 redir_content;\n\n\t\t\tASSERT(redir_index < IOAPIC_NUM_PINS);\n\n\t\t\tredir_content = ioapic->redirtbl[redir_index].bits;\n\t\t\tresult = (ioapic->ioregsel & 0x1) ?\n\t\t\t (redir_content >> 32) & 0xffffffff :\n\t\t\t redir_content & 0xffffffff;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn result;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int setup_ttydir_console(const struct lxc_rootfs *rootfs,\n\t\t\t const struct lxc_console *console,\n\t\t\t char *ttydir)\n{\n\tchar path[MAXPATHLEN], lxcpath[MAXPATHLEN];\n\tint ret;\n\n\t/* create rootfs/dev/ directory */\n\tret = snprintf(path, sizeof(path), \"%s/dev/%s\", rootfs->mount,\n\t\t ttydir);\n\tif (ret >= sizeof(path))\n\t\treturn -1;\n\tret = mkdir(path, 0755);\n\tif (ret && errno != EEXIST) {\n\t\tSYSERROR(\"failed with errno %d to create %s\", errno, path);\n\t\treturn -1;\n\t}\n\tINFO(\"created %s\", path);\n\n\tret = snprintf(lxcpath, sizeof(lxcpath), \"%s/dev/%s/console\",\n\t\t rootfs->mount, ttydir);\n\tif (ret >= sizeof(lxcpath)) {\n\t\tERROR(\"console path too long\");\n\t\treturn -1;\n\t}\n\n\tsnprintf(path, sizeof(path), \"%s/dev/console\", rootfs->mount);\n\tret = unlink(path);\n\tif (ret && errno != ENOENT) {\n\t\tSYSERROR(\"error unlinking %s\", path);\n\t\treturn -1;\n\t}\n\n\tret = creat(lxcpath, 0660);\n\tif (ret==-1 && errno != EEXIST) {\n\t\tSYSERROR(\"error %d creating %s\", errno, lxcpath);\n\t\treturn -1;\n\t}\n\tif (ret >= 0)\n\t\tclose(ret);\n\n\tif (console->master < 0) {\n\t\tINFO(\"no console\");\n\t\treturn 0;\n\t}\n\n\tif (mount(console->name, lxcpath, \"none\", MS_BIND, 0)) {\n\t\tERROR(\"failed to mount '%s' on '%s'\", console->name, lxcpath);\n\t\treturn -1;\n\t}\n\n\t/* create symlink from rootfs/dev/console to 'lxc/console' */\n\tret = snprintf(lxcpath, sizeof(lxcpath), \"%s/console\", ttydir);\n\tif (ret >= sizeof(lxcpath)) {\n\t\tERROR(\"lxc/console path too long\");\n\t\treturn -1;\n\t}\n\tret = symlink(lxcpath, path);\n\tif (ret) {\n\t\tSYSERROR(\"failed to create symlink for console\");\n\t\treturn -1;\n\t}\n\n\tINFO(\"console has been setup on %s\", lxcpath);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "krb5_gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,\n const gss_ctx_id_t context_handle,\n const gss_OID desired_object,\n gss_buffer_set_t *data_set)\n{\n krb5_gss_ctx_id_rec *ctx;\n size_t i;\n\n if (minor_status == NULL)\n return GSS_S_CALL_INACCESSIBLE_WRITE;\n\n *minor_status = 0;\n\n if (desired_object == GSS_C_NO_OID)\n return GSS_S_CALL_INACCESSIBLE_READ;\n\n if (data_set == NULL)\n return GSS_S_CALL_INACCESSIBLE_WRITE;\n\n *data_set = GSS_C_NO_BUFFER_SET;\n\n ctx = (krb5_gss_ctx_id_rec *) context_handle;\n\n if (!ctx->established)\n return GSS_S_NO_CONTEXT;\n\n for (i = 0; i < sizeof(krb5_gss_inquire_sec_context_by_oid_ops)/\n sizeof(krb5_gss_inquire_sec_context_by_oid_ops[0]); i++) {\n if (g_OID_prefix_equal(desired_object, &krb5_gss_inquire_sec_context_by_oid_ops[i].oid)) {\n return (*krb5_gss_inquire_sec_context_by_oid_ops[i].func)(minor_status,\n context_handle,\n desired_object,\n data_set);\n }\n }\n\n *minor_status = EINVAL;\n\n return GSS_S_UNAVAILABLE;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static int read_private_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tconst sc_acl_entry_t *e;\n\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I0012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\te = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\tif (e == NULL || e->method == SC_AC_NEVER)\n\t\treturn 10;\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_private_key(p, keysize, rsa);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx)\n{\n\tu32 exit_intr_info;\n\n\tif (!(vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY\n\t || vmx->exit_reason == EXIT_REASON_EXCEPTION_NMI))\n\t\treturn;\n\n\tvmx->exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);\n\texit_intr_info = vmx->exit_intr_info;\n\n\t/* Handle machine checks before interrupts are enabled */\n\tif (is_machine_check(exit_intr_info))\n\t\tkvm_machine_check();\n\n\t/* We need to handle NMIs before interrupts are enabled */\n\tif ((exit_intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR &&\n\t (exit_intr_info & INTR_INFO_VALID_MASK)) {\n\t\tkvm_before_handle_nmi(&vmx->vcpu);\n\t\tasm(\"int $2\");\n\t\tkvm_after_handle_nmi(&vmx->vcpu);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-388", "cwe_name": "7PK - Errors", "description": "This category represents one of the phyla in the Seven Pernicious Kingdoms vulnerability classification. It includes weaknesses that occur when an application does not properly handle errors that occur during processing. According to the authors of the Seven Pernicious Kingdoms, \"Errors and error handling represent a class of API. Errors related to error handling are so common that they deserve a special kingdom of their own. As with 'API Abuse,' there are two ways to introduce an error-related security vulnerability: the most common one is handling errors poorly (or not at all). The second is producing errors that either give out too much information (to possible attackers) or are difficult to handle.\"", "url": "https://cwe.mitre.org/data/definitions/388.html", "label_name": "vulnerable"} {"code": "static void mutex_lock_double(struct mutex *a, struct mutex *b)\n{\n\tif (b < a)\n\t\tswap(a, b);\n\n\tmutex_lock(a);\n\tmutex_lock_nested(b, SINGLE_DEPTH_NESTING);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "inline static jas_int_asr(int x, int n)\n{\n\tassert(n >= 0);\n\treturn x >> n;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int snd_timer_user_release(struct inode *inode, struct file *file)\n{\n\tstruct snd_timer_user *tu;\n\n\tif (file->private_data) {\n\t\ttu = file->private_data;\n\t\tfile->private_data = NULL;\n\t\tmutex_lock(&tu->ioctl_lock);\n\t\tif (tu->timeri)\n\t\t\tsnd_timer_close(tu->timeri);\n\t\tmutex_unlock(&tu->ioctl_lock);\n\t\tkfree(tu->queue);\n\t\tkfree(tu->tqueue);\n\t\tkfree(tu);\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "lldpd_alloc_mgmt(int family, void *addrptr, size_t addrsize, u_int32_t iface)\n{\n\tstruct lldpd_mgmt *mgmt;\n\n\tlog_debug(\"alloc\", \"allocate a new management address (family: %d)\", family);\n\n\tif (family <= LLDPD_AF_UNSPEC || family >= LLDPD_AF_LAST) {\n\t\terrno = EAFNOSUPPORT;\n\t\treturn NULL;\n\t}\n\tif (addrsize > LLDPD_MGMT_MAXADDRSIZE) {\n\t\terrno = EOVERFLOW;\n\t\treturn NULL;\n\t}\n\tmgmt = calloc(1, sizeof(struct lldpd_mgmt));\n\tif (mgmt == NULL) {\n\t\terrno = ENOMEM;\n\t\treturn NULL;\n\t}\n\tmgmt->m_family = family;\n\tassert(addrsize <= LLDPD_MGMT_MAXADDRSIZE);\n\tmemcpy(&mgmt->m_addr, addrptr, addrsize);\n\tmgmt->m_addrsize = addrsize;\n\tmgmt->m_iface = iface;\n\treturn mgmt;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "juniper_pppoe_atm_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n struct juniper_l2info_t l2info;\n\tuint16_t extracted_ethertype;\n\n l2info.pictype = DLT_JUNIPER_PPPOE_ATM;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n\n ND_TCHECK2(p[0], 2);\n extracted_ethertype = EXTRACT_16BITS(p);\n /* this DLT contains nothing but raw PPPoE frames,\n * prepended with a type field*/\n if (ethertype_print(ndo, extracted_ethertype,\n p+ETHERTYPE_LEN,\n l2info.length-ETHERTYPE_LEN,\n l2info.caplen-ETHERTYPE_LEN,\n NULL, NULL) == 0)\n /* ether_type not known, probably it wasn't one */\n ND_PRINT((ndo, \"unknown ethertype 0x%04x\", extracted_ethertype));\n\n return l2info.header_len;\n\ntrunc:\n\tND_PRINT((ndo, \"[|juniper_pppoe_atm]\"));\n\treturn l2info.header_len;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static inline int mount_entry_on_generic(struct mntent *mntent,\n const char* path)\n{\n\tunsigned long mntflags;\n\tchar *mntdata;\n\tint ret;\n\tbool optional = hasmntopt(mntent, \"optional\") != NULL;\n\n\tret = mount_entry_create_dir_file(mntent, path);\n\n\tif (ret < 0)\n\t\treturn optional ? 0 : -1;\n\n\tcull_mntent_opt(mntent);\n\n\tif (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {\n\t\tfree(mntdata);\n\t\treturn -1;\n\t}\n\n\tret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type,\n\t\t\t mntflags, mntdata, optional);\n\n\tfree(mntdata);\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "static ssize_t aio_setup_single_vector(struct kiocb *kiocb)\n{\n\tkiocb->ki_iovec = &kiocb->ki_inline_vec;\n\tkiocb->ki_iovec->iov_base = kiocb->ki_buf;\n\tkiocb->ki_iovec->iov_len = kiocb->ki_left;\n\tkiocb->ki_nr_segs = 1;\n\tkiocb->ki_cur_seg = 0;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t ignored, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_ctx *ctx = ask->private;\n\tunsigned bs = crypto_ablkcipher_blocksize(crypto_ablkcipher_reqtfm(\n\t\t&ctx->req));\n\tstruct skcipher_sg_list *sgl;\n\tstruct scatterlist *sg;\n\tunsigned long iovlen;\n\tstruct iovec *iov;\n\tint err = -EAGAIN;\n\tint used;\n\tlong copied = 0;\n\n\tlock_sock(sk);\n\tmsg->msg_namelen = 0;\n\tfor (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0;\n\t iovlen--, iov++) {\n\t\tunsigned long seglen = iov->iov_len;\n\t\tchar __user *from = iov->iov_base;\n\n\t\twhile (seglen) {\n\t\t\tsgl = list_first_entry(&ctx->tsgl,\n\t\t\t\t\t struct skcipher_sg_list, list);\n\t\t\tsg = sgl->sg;\n\n\t\t\twhile (!sg->length)\n\t\t\t\tsg++;\n\n\t\t\tused = ctx->used;\n\t\t\tif (!used) {\n\t\t\t\terr = skcipher_wait_for_data(sk, flags);\n\t\t\t\tif (err)\n\t\t\t\t\tgoto unlock;\n\t\t\t}\n\n\t\t\tused = min_t(unsigned long, used, seglen);\n\n\t\t\tused = af_alg_make_sg(&ctx->rsgl, from, used, 1);\n\t\t\terr = used;\n\t\t\tif (err < 0)\n\t\t\t\tgoto unlock;\n\n\t\t\tif (ctx->more || used < ctx->used)\n\t\t\t\tused -= used % bs;\n\n\t\t\terr = -EINVAL;\n\t\t\tif (!used)\n\t\t\t\tgoto free;\n\n\t\t\tablkcipher_request_set_crypt(&ctx->req, sg,\n\t\t\t\t\t\t ctx->rsgl.sg, used,\n\t\t\t\t\t\t ctx->iv);\n\n\t\t\terr = af_alg_wait_for_completion(\n\t\t\t\tctx->enc ?\n\t\t\t\t\tcrypto_ablkcipher_encrypt(&ctx->req) :\n\t\t\t\t\tcrypto_ablkcipher_decrypt(&ctx->req),\n\t\t\t\t&ctx->completion);\n\nfree:\n\t\t\taf_alg_free_sg(&ctx->rsgl);\n\n\t\t\tif (err)\n\t\t\t\tgoto unlock;\n\n\t\t\tcopied += used;\n\t\t\tfrom += used;\n\t\t\tseglen -= used;\n\t\t\tskcipher_pull_sgl(sk, used);\n\t\t}\n\t}\n\n\terr = 0;\n\nunlock:\n\tskcipher_wmem_wakeup(sk);\n\trelease_sock(sk);\n\n\treturn copied ?: err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "juniper_ggsn_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n struct juniper_l2info_t l2info;\n struct juniper_ggsn_header {\n uint8_t svc_id;\n uint8_t flags_len;\n uint8_t proto;\n uint8_t flags;\n uint8_t vlan_id[2];\n uint8_t res[2];\n };\n const struct juniper_ggsn_header *gh;\n\n l2info.pictype = DLT_JUNIPER_GGSN;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n gh = (struct juniper_ggsn_header *)&l2info.cookie;\n\n ND_TCHECK(*gh);\n if (ndo->ndo_eflag) {\n ND_PRINT((ndo, \"proto %s (%u), vlan %u: \",\n tok2str(juniper_protocol_values,\"Unknown\",gh->proto),\n gh->proto,\n EXTRACT_16BITS(&gh->vlan_id[0])));\n }\n\n switch (gh->proto) {\n case JUNIPER_PROTO_IPV4:\n ip_print(ndo, p, l2info.length);\n break;\n case JUNIPER_PROTO_IPV6:\n ip6_print(ndo, p, l2info.length);\n break;\n default:\n if (!ndo->ndo_eflag)\n ND_PRINT((ndo, \"unknown GGSN proto (%u)\", gh->proto));\n }\n\n return l2info.header_len;\n\ntrunc:\n\tND_PRINT((ndo, \"[|juniper_services]\"));\n\treturn l2info.header_len;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len)\n{\n\tstruct sock_iocb *siocb = kiocb_to_siocb(kiocb);\n\tstruct sock *sk = sock->sk;\n\tstruct netlink_sock *nlk = nlk_sk(sk);\n\tstruct sockaddr_nl *addr = msg->msg_name;\n\tu32 dst_pid;\n\tu32 dst_group;\n\tstruct sk_buff *skb;\n\tint err;\n\tstruct scm_cookie scm;\n\n\tif (msg->msg_flags&MSG_OOB)\n\t\treturn -EOPNOTSUPP;\n\n\tif (NULL == siocb->scm)\n\t\tsiocb->scm = &scm;\n\n\terr = scm_send(sock, msg, siocb->scm, true);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (msg->msg_namelen) {\n\t\terr = -EINVAL;\n\t\tif (addr->nl_family != AF_NETLINK)\n\t\t\tgoto out;\n\t\tdst_pid = addr->nl_pid;\n\t\tdst_group = ffs(addr->nl_groups);\n\t\terr = -EPERM;\n\t\tif (dst_group && !netlink_capable(sock, NL_NONROOT_SEND))\n\t\t\tgoto out;\n\t} else {\n\t\tdst_pid = nlk->dst_pid;\n\t\tdst_group = nlk->dst_group;\n\t}\n\n\tif (!nlk->pid) {\n\t\terr = netlink_autobind(sock);\n\t\tif (err)\n\t\t\tgoto out;\n\t}\n\n\terr = -EMSGSIZE;\n\tif (len > sk->sk_sndbuf - 32)\n\t\tgoto out;\n\terr = -ENOBUFS;\n\tskb = alloc_skb(len, GFP_KERNEL);\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tNETLINK_CB(skb).pid\t= nlk->pid;\n\tNETLINK_CB(skb).dst_group = dst_group;\n\tmemcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred));\n\n\terr = -EFAULT;\n\tif (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {\n\t\tkfree_skb(skb);\n\t\tgoto out;\n\t}\n\n\terr = security_netlink_send(sk, skb);\n\tif (err) {\n\t\tkfree_skb(skb);\n\t\tgoto out;\n\t}\n\n\tif (dst_group) {\n\t\tatomic_inc(&skb->users);\n\t\tnetlink_broadcast(sk, skb, dst_pid, dst_group, GFP_KERNEL);\n\t}\n\terr = netlink_unicast(sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT);\n\nout:\n\tscm_destroy(siocb->scm);\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": "static BOOL nsc_decode(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tUINT16 rw;\n\tBYTE shift;\n\tBYTE* bmpdata;\n\tsize_t pos = 0;\n\n\tif (!context)\n\t\treturn FALSE;\n\n\trw = ROUND_UP_TO(context->width, 8);\n\tshift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */\n\tbmpdata = context->BitmapData;\n\n\tif (!bmpdata)\n\t\treturn FALSE;\n\n\tfor (y = 0; y < context->height; y++)\n\t{\n\t\tconst BYTE* yplane;\n\t\tconst BYTE* coplane;\n\t\tconst BYTE* cgplane;\n\t\tconst BYTE* aplane = context->priv->PlaneBuffers[3] + y * context->width; /* A */\n\n\t\tif (context->ChromaSubsamplingLevel)\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * rw; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>\n\t\t\t 1); /* Co, supersampled */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>\n\t\t\t 1); /* Cg, supersampled */\n\t\t}\n\t\telse\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * context->width; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + y * context->width; /* Co */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */\n\t\t}\n\n\t\tfor (x = 0; x < context->width; x++)\n\t\t{\n\t\t\tINT16 y_val = (INT16) * yplane;\n\t\t\tINT16 co_val = (INT16)(INT8)(*coplane << shift);\n\t\t\tINT16 cg_val = (INT16)(INT8)(*cgplane << shift);\n\t\t\tINT16 r_val = y_val + co_val - cg_val;\n\t\t\tINT16 g_val = y_val + cg_val;\n\t\t\tINT16 b_val = y_val - co_val - cg_val;\n\n\t\t\tif (pos + 4 > context->BitmapDataLength)\n\t\t\t\treturn FALSE;\n\n\t\t\tpos += 4;\n\t\t\t*bmpdata++ = MINMAX(b_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(g_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(r_val, 0, 0xFF);\n\t\t\t*bmpdata++ = *aplane;\n\t\t\typlane++;\n\t\t\tcoplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\tcgplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\taplane++;\n\t\t}\n\t}\n\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)\n{\n\tgfn_t gfn, end_gfn;\n\tpfn_t pfn;\n\tint r = 0;\n\tstruct iommu_domain *domain = kvm->arch.iommu_domain;\n\tint flags;\n\n\t/* check if iommu exists and in use */\n\tif (!domain)\n\t\treturn 0;\n\n\tgfn = slot->base_gfn;\n\tend_gfn = gfn + slot->npages;\n\n\tflags = IOMMU_READ;\n\tif (!(slot->flags & KVM_MEM_READONLY))\n\t\tflags |= IOMMU_WRITE;\n\tif (!kvm->arch.iommu_noncoherent)\n\t\tflags |= IOMMU_CACHE;\n\n\n\twhile (gfn < end_gfn) {\n\t\tunsigned long page_size;\n\n\t\t/* Check if already mapped */\n\t\tif (iommu_iova_to_phys(domain, gfn_to_gpa(gfn))) {\n\t\t\tgfn += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* Get the page size we could use to map */\n\t\tpage_size = kvm_host_page_size(kvm, gfn);\n\n\t\t/* Make sure the page_size does not exceed the memslot */\n\t\twhile ((gfn + (page_size >> PAGE_SHIFT)) > end_gfn)\n\t\t\tpage_size >>= 1;\n\n\t\t/* Make sure gfn is aligned to the page size we want to map */\n\t\twhile ((gfn << PAGE_SHIFT) & (page_size - 1))\n\t\t\tpage_size >>= 1;\n\n\t\t/* Make sure hva is aligned to the page size we want to map */\n\t\twhile (__gfn_to_hva_memslot(slot, gfn) & (page_size - 1))\n\t\t\tpage_size >>= 1;\n\n\t\t/*\n\t\t * Pin all pages we are about to map in memory. This is\n\t\t * important because we unmap and unpin in 4kb steps later.\n\t\t */\n\t\tpfn = kvm_pin_pages(slot, gfn, page_size);\n\t\tif (is_error_noslot_pfn(pfn)) {\n\t\t\tgfn += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* Map into IO address space */\n\t\tr = iommu_map(domain, gfn_to_gpa(gfn), pfn_to_hpa(pfn),\n\t\t\t page_size, flags);\n\t\tif (r) {\n\t\t\tprintk(KERN_ERR \"kvm_iommu_map_address:\"\n\t\t\t \"iommu failed to map pfn=%llx\\n\", pfn);\n\t\t\tkvm_unpin_pages(kvm, pfn, page_size);\n\t\t\tgoto unmap_pages;\n\t\t}\n\n\t\tgfn += page_size >> PAGE_SHIFT;\n\n\n\t}\n\n\treturn 0;\n\nunmap_pages:\n\tkvm_iommu_put_pages(kvm, slot->base_gfn, gfn - slot->base_gfn);\n\treturn r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static unsigned long mb2_cache_count(struct shrinker *shrink,\n\t\t\t\t struct shrink_control *sc)\n{\n\tstruct mb2_cache *cache = container_of(shrink, struct mb2_cache,\n\t\t\t\t\t c_shrink);\n\n\treturn cache->c_entry_count;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "safe"} {"code": "static int udp_push_pending_frames(struct sock *sk)\n{\n\tstruct udp_sock *up = udp_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct flowi4 *fl4 = &inet->cork.fl.u.ip4;\n\tstruct sk_buff *skb;\n\tint err = 0;\n\n\tskb = ip_finish_skb(sk, fl4);\n\tif (!skb)\n\t\tgoto out;\n\n\terr = udp_send_skb(skb, fl4);\n\nout:\n\tup->len = 0;\n\tup->pending = 0;\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "static unsigned int get_exif_ui32(struct iw_exif_state *e, unsigned int pos)\n{\n\tif(e->d_len<4 || pos>e->d_len-4) return 0;\n\treturn iw_get_ui32_e(&e->d[pos], e->endian);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static pyc_object *get_set_object(RBuffer *buffer) {\n\tbool error = false;\n\tut32 n = get_ut32 (buffer, &error);\n\tif (n > ST32_MAX) {\n\t\teprintf (\"bad marshal data (set size out of range)\\n\");\n\t\treturn NULL;\n\t}\n\tif (error) {\n\t\treturn NULL;\n\t}\n\tpyc_object *ret = get_array_object_generic (buffer, n);\n\tif (ret) {\n\t\tret->type = TYPE_SET;\n\t}\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "ppp_unregister_channel(struct ppp_channel *chan)\n{\n\tstruct channel *pch = chan->ppp;\n\tstruct ppp_net *pn;\n\n\tif (!pch)\n\t\treturn;\t\t/* should never happen */\n\n\tchan->ppp = NULL;\n\n\t/*\n\t * This ensures that we have returned from any calls into the\n\t * the channel's start_xmit or ioctl routine before we proceed.\n\t */\n\tdown_write(&pch->chan_sem);\n\tspin_lock_bh(&pch->downl);\n\tpch->chan = NULL;\n\tspin_unlock_bh(&pch->downl);\n\tup_write(&pch->chan_sem);\n\tppp_disconnect_channel(pch);\n\n\tpn = ppp_pernet(pch->chan_net);\n\tspin_lock_bh(&pn->all_channels_lock);\n\tlist_del(&pch->list);\n\tspin_unlock_bh(&pn->all_channels_lock);\n\tput_net(pch->chan_net);\n\tpch->chan_net = NULL;\n\n\tpch->file.dead = 1;\n\twake_up_interruptible(&pch->file.rwait);\n\tif (atomic_dec_and_test(&pch->file.refcnt))\n\t\tppp_destroy_channel(pch);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "NOEXPORT int ssl_tlsext_ticket_key_cb(SSL *ssl, unsigned char *key_name,\n unsigned char *iv, EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc) {\n CLI *c;\n const EVP_CIPHER *cipher;\n int iv_len;\n\n (void)key_name; /* squash the unused parameter warning */\n s_log(LOG_DEBUG, \"Session ticket processing callback\");\n\n c=SSL_get_ex_data(ssl, index_ssl_cli);\n if(!HMAC_Init_ex(hctx, (const unsigned char *)(c->opt->ticket_mac->key_val),\n c->opt->ticket_mac->key_len, EVP_sha256(), NULL)) {\n s_log(LOG_ERR, \"HMAC_Init_ex failed\");\n return -1;\n }\n if(c->opt->ticket_key->key_len == 16)\n cipher = EVP_aes_128_cbc();\n else /* c->opt->ticket_key->key_len == 32 */\n cipher = EVP_aes_256_cbc();\n if(enc) { /* create new session */\n /* EVP_CIPHER_iv_length() returns 16 for either cipher EVP_aes_128_cbc() or EVP_aes_256_cbc() */\n iv_len = EVP_CIPHER_iv_length(cipher);\n if(RAND_bytes(iv, iv_len) <= 0) { /* RAND_bytes error */\n s_log(LOG_ERR, \"RAND_bytes failed\");\n return -1;\n }\n if(!EVP_EncryptInit_ex(ctx, cipher, NULL,\n (const unsigned char *)(c->opt->ticket_key->key_val), iv)) {\n s_log(LOG_ERR, \"EVP_EncryptInit_ex failed\");\n return -1;\n }\n } else /* retrieve session */\n if(!EVP_DecryptInit_ex(ctx, cipher, NULL,\n (const unsigned char *)(c->opt->ticket_key->key_val), iv)) {\n s_log(LOG_ERR, \"EVP_DecryptInit_ex failed\");\n return -1;\n }\n /* By default, in TLSv1.2 and below, a new session ticket */\n /* is not issued on a successful resumption. */\n /* In TLSv1.3 the default behaviour is to always issue a new ticket on resumption. */\n /* This behaviour can NOT be changed if this ticket key callback is in use! */\n if(strcmp(SSL_get_version(c->ssl), \"TLSv1.3\"))\n return 1; /* new session ticket is not issued */\n else\n return 2; /* session ticket should be replaced */\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "static int override_release(char __user *release, int len)\n{\n\tint ret = 0;\n\tchar buf[65];\n\n\tif (current->personality & UNAME26) {\n\t\tchar *rest = UTS_RELEASE;\n\t\tint ndots = 0;\n\t\tunsigned v;\n\n\t\twhile (*rest) {\n\t\t\tif (*rest == '.' && ++ndots >= 3)\n\t\t\t\tbreak;\n\t\t\tif (!isdigit(*rest) && *rest != '.')\n\t\t\t\tbreak;\n\t\t\trest++;\n\t\t}\n\t\tv = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;\n\t\tsnprintf(buf, len, \"2.6.%u%s\", v, rest);\n\t\tret = copy_to_user(release, buf, len);\n\t}\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-16", "cwe_name": "Configuration", "description": "Weaknesses in this category are typically introduced during the configuration of the software.", "url": "https://cwe.mitre.org/data/definitions/16.html", "label_name": "vulnerable"} {"code": "int wait_for_key_construction(struct key *key, bool intr)\n{\n\tint ret;\n\n\tret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT,\n\t\t\t intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);\n\tif (ret)\n\t\treturn -ERESTARTSYS;\n\tret = key_read_state(key);\n\tif (ret < 0)\n\t\treturn ret;\n\treturn key_validate(key);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int sh_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {\n\tut8 op_MSB,op_LSB;\n\tint ret;\n\tif (!data || len < 2) {\n\t\treturn 0;\n\t}\n\tmemset (op, '\\0', sizeof (RAnalOp));\n\top->addr = addr;\n\top->type = R_ANAL_OP_TYPE_UNK;\n\top->jump = op->fail = -1;\n\top->ptr = op->val = -1;\n\n\top->size = 2;\n\n\top_MSB = anal->big_endian? data[0]: data[1];\n\top_LSB = anal->big_endian? data[1]: data[0];\n\tret = first_nibble_decode[(op_MSB>>4) & 0x0F](anal, op, (ut16)(op_MSB<<8 | op_LSB));\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int socket_create(uint16_t port)\n{\n\tint sfd = -1;\n\tint yes = 1;\n#ifdef WIN32\n\tWSADATA wsa_data;\n\tif (!wsa_init) {\n\t\tif (WSAStartup(MAKEWORD(2,2), &wsa_data) != ERROR_SUCCESS) {\n\t\t\tfprintf(stderr, \"WSAStartup failed!\\n\");\n\t\t\tExitProcess(-1);\n\t\t}\n\t\twsa_init = 1;\n\t}\n#endif\n\tstruct sockaddr_in saddr;\n\n\tif (0 > (sfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))) {\n\t\tperror(\"socket()\");\n\t\treturn -1;\n\t}\n\n\tif (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void*)&yes, sizeof(int)) == -1) {\n\t\tperror(\"setsockopt()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n\tmemset((void *) &saddr, 0, sizeof(saddr));\n\tsaddr.sin_family = AF_INET;\n\tsaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n\tsaddr.sin_port = htons(port);\n\n\tif (0 > bind(sfd, (struct sockaddr *) &saddr, sizeof(saddr))) {\n\t\tperror(\"bind()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n\tif (listen(sfd, 1) == -1) {\n\t\tperror(\"listen()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n\treturn sfd;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "static int cac_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* serial)\n{\n\tcac_private_data_t * priv = CAC_DATA(card);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);\n if (card->serialnr.len) {\n *serial = card->serialnr;\n SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n }\n\tif (priv->cac_id_len) {\n\t\tserial->len = MIN(priv->cac_id_len, SC_MAX_SERIALNR);\n\t\tmemcpy(serial->value, priv->cac_id, priv->cac_id_len);\n\t\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n\t}\n\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int spk_ttyio_ldisc_open(struct tty_struct *tty)\n{\n\tstruct spk_ldisc_data *ldisc_data;\n\n\tif (!tty->ops->write)\n\t\treturn -EOPNOTSUPP;\n\tspeakup_tty = tty;\n\n\tldisc_data = kmalloc(sizeof(*ldisc_data), GFP_KERNEL);\n\tif (!ldisc_data)\n\t\treturn -ENOMEM;\n\n\tinit_completion(&ldisc_data->completion);\n\tldisc_data->buf_free = true;\n\tspeakup_tty->disc_data = ldisc_data;\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "vulnerable"} {"code": "snmp_ber_decode_string_len_buffer(unsigned char *buf, uint32_t *buff_len, const char **str, uint32_t *length)\n{\n uint8_t type, i, length_bytes;\n\n buf = snmp_ber_decode_type(buf, buff_len, &type);\n\n if(buf == NULL || type != BER_DATA_TYPE_OCTET_STRING) {\n /*\n * Sanity check\n * Invalid type in buffer\n */\n return NULL;\n }\n\n if((*buf & 0x80) == 0) {\n *length = (uint32_t)*buf++;\n (*buff_len)--;\n } else {\n\n length_bytes = (uint8_t)(*buf++ & 0x7F);\n (*buff_len)--;\n if(length_bytes > 4) {\n /*\n * Sanity check\n * It will not fit in the uint32_t\n */\n return NULL;\n }\n\n *length = (uint32_t)*buf++;\n (*buff_len)--;\n for(i = 1; i < length_bytes; ++i) {\n *length <<= 8;\n *length |= *buf++;\n (*buff_len)--;\n }\n }\n\n *str = (const char *)buf;\n *buff_len -= *length;\n\n return buf + *length;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sco_pinfo *pi = sco_pi(sk);\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state == BT_CONNECT2 &&\n\t test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {\n\t\tsco_conn_defer_accept(pi->conn->hcon, pi->setting);\n\t\tsk->sk_state = BT_CONFIG;\n\t\tmsg->msg_namelen = 0;\n\n\t\trelease_sock(sk);\n\t\treturn 0;\n\t}\n\n\trelease_sock(sk);\n\n\treturn bt_sock_recvmsg(iocb, sock, msg, len, flags);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int filter_frame(AVFilterLink *inlink, AVFrame *in)\n{\n GradFunContext *s = inlink->dst->priv;\n AVFilterLink *outlink = inlink->dst->outputs[0];\n AVFrame *out;\n int p, direct;\n\n if (av_frame_is_writable(in)) {\n direct = 1;\n out = in;\n } else {\n direct = 0;\n out = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n if (!out) {\n av_frame_free(&in);\n return AVERROR(ENOMEM);\n }\n av_frame_copy_props(out, in);\n }\n\n for (p = 0; p < 4 && in->data[p] && in->linesize[p]; p++) {\n int w = inlink->w;\n int h = inlink->h;\n int r = s->radius;\n if (p) {\n w = s->chroma_w;\n h = s->chroma_h;\n r = s->chroma_r;\n }\n\n if (FFMIN(w, h) > 2 * r)\n filter(s, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r);\n else if (out->data[p] != in->data[p])\n av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h);\n }\n\n if (!direct)\n av_frame_free(&in);\n\n return ff_filter_frame(outlink, out);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int mif_validate(jas_stream_t *in)\n{\n\tjas_uchar buf[MIF_MAGICLEN];\n\tuint_fast32_t magic;\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= MIF_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, MIF_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Was enough data read? */\n\tif (n < MIF_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\t/* Compute the signature value. */\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Ensure that the signature is correct for this format. */\n\tif (magic != MIF_MAGIC) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "process_plane(uint8 * in, int width, int height, uint8 * out, int size)\n{\n\tUNUSED(size);\n\tint indexw;\n\tint indexh;\n\tint code;\n\tint collen;\n\tint replen;\n\tint color;\n\tint x;\n\tint revcode;\n\tuint8 * last_line;\n\tuint8 * this_line;\n\tuint8 * org_in;\n\tuint8 * org_out;\n\n\torg_in = in;\n\torg_out = out;\n\tlast_line = 0;\n\tindexh = 0;\n\twhile (indexh < height)\n\t{\n\t\tout = (org_out + width * height * 4) - ((indexh + 1) * width * 4);\n\t\tcolor = 0;\n\t\tthis_line = out;\n\t\tindexw = 0;\n\t\tif (last_line == 0)\n\t\t{\n\t\t\twhile (indexw < width)\n\t\t\t{\n\t\t\t\tcode = CVAL(in);\n\t\t\t\treplen = code & 0xf;\n\t\t\t\tcollen = (code >> 4) & 0xf;\n\t\t\t\trevcode = (replen << 4) | collen;\n\t\t\t\tif ((revcode <= 47) && (revcode >= 16))\n\t\t\t\t{\n\t\t\t\t\treplen = revcode;\n\t\t\t\t\tcollen = 0;\n\t\t\t\t}\n\t\t\t\twhile (collen > 0)\n\t\t\t\t{\n\t\t\t\t\tcolor = CVAL(in);\n\t\t\t\t\t*out = color;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\tcollen--;\n\t\t\t\t}\n\t\t\t\twhile (replen > 0)\n\t\t\t\t{\n\t\t\t\t\t*out = color;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\treplen--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\twhile (indexw < width)\n\t\t\t{\n\t\t\t\tcode = CVAL(in);\n\t\t\t\treplen = code & 0xf;\n\t\t\t\tcollen = (code >> 4) & 0xf;\n\t\t\t\trevcode = (replen << 4) | collen;\n\t\t\t\tif ((revcode <= 47) && (revcode >= 16))\n\t\t\t\t{\n\t\t\t\t\treplen = revcode;\n\t\t\t\t\tcollen = 0;\n\t\t\t\t}\n\t\t\t\twhile (collen > 0)\n\t\t\t\t{\n\t\t\t\t\tx = CVAL(in);\n\t\t\t\t\tif (x & 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tx = x >> 1;\n\t\t\t\t\t\tx = x + 1;\n\t\t\t\t\t\tcolor = -x;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tx = x >> 1;\n\t\t\t\t\t\tcolor = x;\n\t\t\t\t\t}\n\t\t\t\t\tx = last_line[indexw * 4] + color;\n\t\t\t\t\t*out = x;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\tcollen--;\n\t\t\t\t}\n\t\t\t\twhile (replen > 0)\n\t\t\t\t{\n\t\t\t\t\tx = last_line[indexw * 4] + color;\n\t\t\t\t\t*out = x;\n\t\t\t\t\tout += 4;\n\t\t\t\t\tindexw++;\n\t\t\t\t\treplen--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tindexh++;\n\t\tlast_line = this_line;\n\t}\n\treturn (int) (in - org_in);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)\n{\n\tint ret = pci_read_config_word(dev, offset, value);\n\tconst struct pci_cmd_info *cmd = data;\n\n\t*value &= PCI_COMMAND_GUEST;\n\t*value |= cmd->val & ~PCI_COMMAND_GUEST;\n\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct in6_addr *final_p, final;\n\tstruct flowi6 fl6;\n\tint err = -1;\n\tstruct dst_entry *dst;\n\n\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\tfl6.saddr = ireq->ir_v6_loc_addr;\n\tfl6.flowlabel = 0;\n\tfl6.flowi6_oif = ireq->ir_iif;\n\tfl6.fl6_dport = ireq->ir_rmt_port;\n\tfl6.fl6_sport = htons(ireq->ir_num);\n\tsecurity_req_classify_flow(req, flowi6_to_flowi(&fl6));\n\n\n\tfinal_p = fl6_update_dst(&fl6, np->opt, &final);\n\n\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tdst = NULL;\n\t\tgoto done;\n\t}\n\n\tskb = dccp_make_response(sk, dst, req);\n\tif (skb != NULL) {\n\t\tstruct dccp_hdr *dh = dccp_hdr(skb);\n\n\t\tdh->dccph_checksum = dccp_v6_csum_finish(skb,\n\t\t\t\t\t\t\t &ireq->ir_v6_loc_addr,\n\t\t\t\t\t\t\t &ireq->ir_v6_rmt_addr);\n\t\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\t\terr = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);\n\t\terr = net_xmit_eval(err);\n\t}\n\ndone:\n\tdst_release(dst);\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "void handle_debug_usb_rx(const void *msg, size_t len)\n{\n if (msg_tiny_flag) {\n uint8_t buf[64];\n memcpy(buf, msg, sizeof(buf));\n\n uint16_t msgId = buf[4] | ((uint16_t)buf[3]) << 8;\n uint32_t msgSize = buf[8] |\n ((uint32_t)buf[7]) << 8 |\n ((uint32_t)buf[6]) << 16 |\n ((uint32_t)buf[5]) << 24;\n\n if (msgSize > 64 - 9) {\n (*msg_failure)(FailureType_Failure_UnexpectedMessage, \"Malformed tiny packet\");\n return;\n }\n\n // Determine callback handler and message map type.\n const MessagesMap_t *entry = message_map_entry(DEBUG_MSG, msgId, IN_MSG);\n if (!entry) {\n (*msg_failure)(FailureType_Failure_UnexpectedMessage, \"Unknown message\");\n return;\n }\n\n tiny_dispatch(entry, buf + 9, msgSize);\n } else {\n usb_rx_helper(msg, len, DEBUG_MSG);\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)\n{\n\tgdIOCtx *out = gdNewFileCtx(outFile);\n\tif (out == NULL) {\n\t\treturn;\n\t}\n\t_gdImageWebpCtx(im, out, -1);\n\tout->gd_free(out);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "static void addParamsFromBuf(HttpConn *conn, cchar *buf, ssize len)\n{\n MprJson *params, *prior;\n char *newValue, *decoded, *keyword, *value, *tok;\n\n assert(conn);\n params = httpGetParams(conn);\n decoded = mprAlloc(len + 1);\n decoded[len] = '\\0';\n memcpy(decoded, buf, len);\n\n keyword = stok(decoded, \"&\", &tok);\n while (keyword != 0) {\n if ((value = strchr(keyword, '=')) != 0) {\n *value++ = '\\0';\n value = mprUriDecode(value);\n } else {\n value = MPR->emptyString;\n }\n keyword = mprUriDecode(keyword);\n if (*keyword) {\n /*\n Append to existing keywords\n */\n prior = mprReadJsonObj(params, keyword);\n#if ME_EJS_PRODUCT\n /*\n Just for ejscript, we allow embedded \".[]\" in the keys\n */\n if (prior && prior->type == MPR_JSON_VALUE) {\n if (*value) {\n newValue = sjoin(prior->value, \" \", value, NULL);\n mprSetJson(params, keyword, newValue);\n }\n } else {\n mprSetJson(params, keyword, value);\n }\n#else\n if (prior && prior->type == MPR_JSON_VALUE) {\n if (*value) {\n newValue = sjoin(prior->value, \" \", value, NULL);\n mprWriteJson(params, keyword, newValue);\n }\n } else {\n mprWriteJson(params, keyword, value);\n }\n#endif\n }\n keyword = stok(0, \"&\", &tok);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "ast_for_arg(struct compiling *c, const node *n)\n{\n identifier name;\n expr_ty annotation = NULL;\n node *ch;\n arg_ty ret;\n\n assert(TYPE(n) == tfpdef || TYPE(n) == vfpdef);\n ch = CHILD(n, 0);\n name = NEW_IDENTIFIER(ch);\n if (!name)\n return NULL;\n if (forbidden_name(c, name, ch, 0))\n return NULL;\n\n if (NCH(n) == 3 && TYPE(CHILD(n, 1)) == COLON) {\n annotation = ast_for_expr(c, CHILD(n, 2));\n if (!annotation)\n return NULL;\n }\n\n ret = arg(name, annotation, LINENO(n), n->n_col_offset,\n n->n_end_lineno, n->n_end_col_offset, c->c_arena);\n if (!ret)\n return NULL;\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "header_put_marker (SF_PRIVATE *psf, int x)\n{\tif (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)\n\t{\tpsf->header [psf->headindex++] = (x >> 24) ;\n\t\tpsf->header [psf->headindex++] = (x >> 16) ;\n\t\tpsf->header [psf->headindex++] = (x >> 8) ;\n\t\tpsf->header [psf->headindex++] = x ;\n\t\t} ;\n} /* header_put_marker */", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,\n\tstruct cftype *cft, struct eventfd_ctx *eventfd)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);\n\tstruct mem_cgroup_thresholds *thresholds;\n\tstruct mem_cgroup_threshold_ary *new;\n\tint type = MEMFILE_TYPE(cft->private);\n\tu64 usage;\n\tint i, j, size;\n\n\tmutex_lock(&memcg->thresholds_lock);\n\tif (type == _MEM)\n\t\tthresholds = &memcg->thresholds;\n\telse if (type == _MEMSWAP)\n\t\tthresholds = &memcg->memsw_thresholds;\n\telse\n\t\tBUG();\n\n\t/*\n\t * Something went wrong if we trying to unregister a threshold\n\t * if we don't have thresholds\n\t */\n\tBUG_ON(!thresholds);\n\n\tusage = mem_cgroup_usage(memcg, type == _MEMSWAP);\n\n\t/* Check if a threshold crossed before removing */\n\t__mem_cgroup_threshold(memcg, type == _MEMSWAP);\n\n\t/* Calculate new number of threshold */\n\tsize = 0;\n\tfor (i = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd != eventfd)\n\t\t\tsize++;\n\t}\n\n\tnew = thresholds->spare;\n\n\t/* Set thresholds array to NULL if we don't have thresholds */\n\tif (!size) {\n\t\tkfree(new);\n\t\tnew = NULL;\n\t\tgoto swap_buffers;\n\t}\n\n\tnew->size = size;\n\n\t/* Copy thresholds and find current threshold */\n\tnew->current_threshold = -1;\n\tfor (i = 0, j = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd == eventfd)\n\t\t\tcontinue;\n\n\t\tnew->entries[j] = thresholds->primary->entries[i];\n\t\tif (new->entries[j].threshold < usage) {\n\t\t\t/*\n\t\t\t * new->current_threshold will not be used\n\t\t\t * until rcu_assign_pointer(), so it's safe to increment\n\t\t\t * it here.\n\t\t\t */\n\t\t\t++new->current_threshold;\n\t\t}\n\t\tj++;\n\t}\n\nswap_buffers:\n\t/* Swap primary and spare array */\n\tthresholds->spare = thresholds->primary;\n\trcu_assign_pointer(thresholds->primary, new);\n\n\t/* To be sure that nobody uses thresholds */\n\tsynchronize_rcu();\n\n\tmutex_unlock(&memcg->thresholds_lock);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "unix_client_connect(hsm_com_client_hdl_t *hdl)\r\n{\r\n\tint\t\t\t\t\tfd, len;\r\n\tstruct sockaddr_un\tunix_addr;\r\n\thsm_com_errno_t\t\tres = HSM_COM_OK;\r\n\r\n\tif ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) \r\n\t{\r\n\t\treturn HSM_COM_ERROR;\r\n\t}\r\n\r\n\tmemset(&unix_addr,0,sizeof(unix_addr));\r\n\r\n\tunix_addr.sun_family = AF_UNIX;\r\n\t\r\n\tif(strlen(hdl->c_path) >= sizeof(unix_addr.sun_path))\r\n\t{\r\n\t\tres = HSM_COM_PATH_ERR;\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\tsnprintf(unix_addr.sun_path, sizeof(unix_addr.sun_path), \"%s\", hdl->c_path);\r\n\r\n\tlen = SUN_LEN(&unix_addr);\r\n\r\n\tunlink(unix_addr.sun_path);\r\n\r\n\tif(bind(fd, (struct sockaddr *)&unix_addr, len) < 0)\r\n\t{\r\n\t\tres = HSM_COM_BIND_ERR;\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\tif(chmod(unix_addr.sun_path, S_IRWXU) < 0)\r\n\t{\r\n\t\tres = HSM_COM_CHMOD_ERR;\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\tmemset(&unix_addr,0,sizeof(unix_addr));\r\n\r\n\tunix_addr.sun_family = AF_UNIX;\r\n\tstrncpy(unix_addr.sun_path, hdl->s_path, sizeof(unix_addr.sun_path));\r\n\tunix_addr.sun_path[sizeof(unix_addr.sun_path)-1] = 0;\r\n\r\n\tlen = SUN_LEN(&unix_addr);\r\n\r\n\tif (connect(fd, (struct sockaddr *) &unix_addr, len) < 0) \r\n\t{\r\n\t\tres = HSM_COM_CONX_ERR;\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\thdl->client_fd = fd;\r\n\thdl->client_state = HSM_COM_C_STATE_CT;\r\n\r\n\t// Send connection data packet\r\n\tif(unix_sck_send_conn(hdl, 2) != HSM_COM_OK)\r\n\t{\r\n\t\thdl->client_state = HSM_COM_C_STATE_IN;\r\n\t\tres = HSM_COM_SEND_ERR;\r\n\t}\r\n\r\n\treturn res;\r\n\r\ncleanup:\r\n\tclose(fd);\r\n\treturn res;\r\n\r\n}\r", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "get_html_data (MAPI_Attr *a)\n{\n VarLenData **body = XCALLOC(VarLenData*, a->num_values + 1);\n\n int j;\n for (j = 0; j < a->num_values; j++)\n {\n\tbody[j] = XMALLOC(VarLenData, 1);\n\tbody[j]->len = a->values[j].len;\n\tbody[j]->data = CHECKED_XCALLOC(unsigned char, a->values[j].len);\n\tmemmove (body[j]->data, a->values[j].data.buf, body[j]->len);\n }\n return body;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s)\n{\n\tUINT32 i;\n\tBITMAP_UPDATE* bitmapUpdate = calloc(1, sizeof(BITMAP_UPDATE));\n\n\tif (!bitmapUpdate)\n\t\tgoto fail;\n\n\tif (Stream_GetRemainingLength(s) < 2)\n\t\tgoto fail;\n\n\tStream_Read_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */\n\tWLog_Print(update->log, WLOG_TRACE, \"BitmapUpdate: %\"PRIu32\"\", bitmapUpdate->number);\n\n\tif (bitmapUpdate->number > bitmapUpdate->count)\n\t{\n\t\tUINT16 count;\n\t\tBITMAP_DATA* newdata;\n\t\tcount = bitmapUpdate->number * 2;\n\t\tnewdata = (BITMAP_DATA*) realloc(bitmapUpdate->rectangles,\n\t\t sizeof(BITMAP_DATA) * count);\n\n\t\tif (!newdata)\n\t\t\tgoto fail;\n\n\t\tbitmapUpdate->rectangles = newdata;\n\t\tZeroMemory(&bitmapUpdate->rectangles[bitmapUpdate->count],\n\t\t sizeof(BITMAP_DATA) * (count - bitmapUpdate->count));\n\t\tbitmapUpdate->count = count;\n\t}\n\n\t/* rectangles */\n\tfor (i = 0; i < bitmapUpdate->number; i++)\n\t{\n\t\tif (!update_read_bitmap_data(update, s, &bitmapUpdate->rectangles[i]))\n\t\t\tgoto fail;\n\t}\n\n\treturn bitmapUpdate;\nfail:\n\tfree_bitmap_update(update->context, bitmapUpdate);\n\treturn NULL;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset) {\n\tbloc = *offset;\n\twhile (node && node->symbol == INTERNAL_NODE) {\n\t\tif (get_bit(fin)) {\n\t\t\tnode = node->right;\n\t\t} else {\n\t\t\tnode = node->left;\n\t\t}\n\t}\n\tif (!node) {\n\t\t*ch = 0;\n\t\treturn;\n//\t\tCom_Error(ERR_DROP, \"Illegal tree!\");\n\t}\n\t*ch = node->symbol;\n\t*offset = bloc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "u_undo_end(\n int\t\tdid_undo,\t// just did an undo\n int\t\tabsolute)\t// used \":undo N\"\n{\n char\t*msgstr;\n u_header_T\t*uhp;\n char_u\tmsgbuf[80];\n\n#ifdef FEAT_FOLDING\n if ((fdo_flags & FDO_UNDO) && KeyTyped)\n\tfoldOpenCursor();\n#endif\n\n if (global_busy\t // no messages now, wait until global is finished\n\t || !messaging()) // 'lazyredraw' set, don't do messages now\n\treturn;\n\n if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t--u_newcount;\n\n u_oldcount -= u_newcount;\n if (u_oldcount == -1)\n\tmsgstr = N_(\"more line\");\n else if (u_oldcount < 0)\n\tmsgstr = N_(\"more lines\");\n else if (u_oldcount == 1)\n\tmsgstr = N_(\"line less\");\n else if (u_oldcount > 1)\n\tmsgstr = N_(\"fewer lines\");\n else\n {\n\tu_oldcount = u_newcount;\n\tif (u_newcount == 1)\n\t msgstr = N_(\"change\");\n\telse\n\t msgstr = N_(\"changes\");\n }\n\n if (curbuf->b_u_curhead != NULL)\n {\n\t// For \":undo N\" we prefer a \"after #N\" message.\n\tif (absolute && curbuf->b_u_curhead->uh_next.ptr != NULL)\n\t{\n\t uhp = curbuf->b_u_curhead->uh_next.ptr;\n\t did_undo = FALSE;\n\t}\n\telse if (did_undo)\n\t uhp = curbuf->b_u_curhead;\n\telse\n\t uhp = curbuf->b_u_curhead->uh_next.ptr;\n }\n else\n\tuhp = curbuf->b_u_newhead;\n\n if (uhp == NULL)\n\t*msgbuf = NUL;\n else\n\tadd_time(msgbuf, sizeof(msgbuf), uhp->uh_time);\n\n#ifdef FEAT_CONCEAL\n {\n\twin_T\t*wp;\n\n\tFOR_ALL_WINDOWS(wp)\n\t{\n\t if (wp->w_buffer == curbuf && wp->w_p_cole > 0)\n\t\tredraw_win_later(wp, NOT_VALID);\n\t}\n }\n#endif\n if (VIsual_active)\n\tcheck_pos(curbuf, &VIsual);\n\n smsg_attr_keep(0, _(\"%ld %s; %s #%ld %s\"),\n\t u_oldcount < 0 ? -u_oldcount : u_oldcount,\n\t _(msgstr),\n\t did_undo ? _(\"before\") : _(\"after\"),\n\t uhp == NULL ? 0L : uhp->uh_seq,\n\t msgbuf);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *offset, int check_empty TSRMLS_DC) /* {{{ */\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);\n\tlong index;\n\tzval *rv, *value = NULL, **tmp;\n\n\tif (check_inherited && intern->fptr_offset_has) {\n\t\tzval *offset_tmp = offset;\n\t\tSEPARATE_ARG_IF_REF(offset_tmp);\n\t\tzend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_has, \"offsetExists\", &rv, offset_tmp);\n\t\tzval_ptr_dtor(&offset_tmp);\n\n\t\tif (rv && zend_is_true(rv)) {\n\t\t\tzval_ptr_dtor(&rv);\n\t\t\tif (check_empty != 1) {\n\t\t\t\treturn 1;\n\t\t\t} else if (intern->fptr_offset_get) {\n\t\t\t\tvalue = spl_array_read_dimension_ex(1, object, offset, BP_VAR_R TSRMLS_CC);\n\t\t\t}\n\t\t} else {\n\t\t\tif (rv) {\n\t\t\t\tzval_ptr_dtor(&rv);\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif (!value) {\n\t\tHashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);\n\n\t\tswitch(Z_TYPE_P(offset)) {\n\t\t\tcase IS_STRING:\n\t\t\t\tif (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) {\n\t\t\t\t\tif (check_empty == 2) {\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase IS_DOUBLE:\n\t\t\tcase IS_RESOURCE:\n\t\t\tcase IS_BOOL:\n\t\t\tcase IS_LONG:\n\t\t\t\tif (offset->type == IS_DOUBLE) {\n\t\t\t\t\tindex = (long)Z_DVAL_P(offset);\n\t\t\t\t} else {\n\t\t\t\t\tindex = Z_LVAL_P(offset);\n\t\t\t\t}\n\t\t\t\tif (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {\n\t\t\t\t\tif (check_empty == 2) {\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tzend_error(E_WARNING, \"Illegal offset type\");\n\t\t\t\treturn 0;\n\t\t}\n\n\t\tif (check_empty && check_inherited && intern->fptr_offset_get) {\n\t\t\tvalue = spl_array_read_dimension_ex(1, object, offset, BP_VAR_R TSRMLS_CC);\n\t\t} else {\n\t\t\tvalue = *tmp;\n\t\t}\n\t}\n\n\treturn check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;\n} /* }}} */", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "int CLASS parse_jpeg(int offset)\n{\n int len, save, hlen, mark;\n fseek(ifp, offset, SEEK_SET);\n if (fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8)\n return 0;\n\n while (fgetc(ifp) == 0xff && (mark = fgetc(ifp)) != 0xda)\n {\n order = 0x4d4d;\n len = get2() - 2;\n save = ftell(ifp);\n if (mark == 0xc0 || mark == 0xc3 || mark == 0xc9)\n {\n fgetc(ifp);\n raw_height = get2();\n raw_width = get2();\n }\n order = get2();\n hlen = get4();\n if (get4() == 0x48454150\n#ifdef LIBRAW_LIBRARY_BUILD\n\t&& (save+hlen) >= 0 && (save+hlen)<=ifp->size()\n#endif\n\t) /* \"HEAP\" */\n {\n#ifdef LIBRAW_LIBRARY_BUILD\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_FixedLens;\n imgdata.lens.makernotes.LensMount = LIBRAW_MOUNT_FixedLens;\n#endif\n parse_ciff(save + hlen, len - hlen, 0);\n }\n if (parse_tiff(save + 6))\n apply_tiff();\n fseek(ifp, save + len, SEEK_SET);\n }\n return 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static bool cgm_bind_dir(const char *root, const char *dirname)\n{\n\tnih_local char *cgpath = NULL;\n\n\t/* /sys should have been mounted by now */\n\tcgpath = NIH_MUST( nih_strdup(NULL, root) );\n\tNIH_MUST( nih_strcat(&cgpath, NULL, \"/sys/fs/cgroup\") );\n\n\tif (!dir_exists(cgpath)) {\n\t\tERROR(\"%s does not exist\", cgpath);\n\t\treturn false;\n\t}\n\n\t/* mount a tmpfs there so we can create subdirs */\n\tif (safe_mount(\"cgroup\", cgpath, \"tmpfs\", 0, \"size=10000,mode=755\", root)) {\n\t\tSYSERROR(\"Failed to mount tmpfs at %s\", cgpath);\n\t\treturn false;\n\t}\n\tNIH_MUST( nih_strcat(&cgpath, NULL, \"/cgmanager\") );\n\n\tif (mkdir(cgpath, 0755) < 0) {\n\t\tSYSERROR(\"Failed to create %s\", cgpath);\n\t\treturn false;\n\t}\n\n\tif (safe_mount(dirname, cgpath, \"none\", MS_BIND, 0, root)) {\n\t\tSYSERROR(\"Failed to bind mount %s to %s\", dirname, cgpath);\n\t\treturn false;\n\t}\n\n\treturn true;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "arg(identifier arg, expr_ty annotation, int lineno, int col_offset, int\n end_lineno, int end_col_offset, PyArena *arena)\n{\n arg_ty p;\n if (!arg) {\n PyErr_SetString(PyExc_ValueError,\n \"field arg is required for arg\");\n return NULL;\n }\n p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));\n if (!p)\n return NULL;\n p->arg = arg;\n p->annotation = annotation;\n p->lineno = lineno;\n p->col_offset = col_offset;\n p->end_lineno = end_lineno;\n p->end_col_offset = end_col_offset;\n return p;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,\n\t\t\t\t\t struct userfaultfd_wait_queue *ewq)\n{\n\tif (WARN_ON_ONCE(current->flags & PF_EXITING))\n\t\tgoto out;\n\n\tewq->ctx = ctx;\n\tinit_waitqueue_entry(&ewq->wq, current);\n\n\tspin_lock(&ctx->event_wqh.lock);\n\t/*\n\t * After the __add_wait_queue the uwq is visible to userland\n\t * through poll/read().\n\t */\n\t__add_wait_queue(&ctx->event_wqh, &ewq->wq);\n\tfor (;;) {\n\t\tset_current_state(TASK_KILLABLE);\n\t\tif (ewq->msg.event == 0)\n\t\t\tbreak;\n\t\tif (ACCESS_ONCE(ctx->released) ||\n\t\t fatal_signal_pending(current)) {\n\t\t\t/*\n\t\t\t * &ewq->wq may be queued in fork_event, but\n\t\t\t * __remove_wait_queue ignores the head\n\t\t\t * parameter. It would be a problem if it\n\t\t\t * didn't.\n\t\t\t */\n\t\t\t__remove_wait_queue(&ctx->event_wqh, &ewq->wq);\n\t\t\tif (ewq->msg.event == UFFD_EVENT_FORK) {\n\t\t\t\tstruct userfaultfd_ctx *new;\n\n\t\t\t\tnew = (struct userfaultfd_ctx *)\n\t\t\t\t\t(unsigned long)\n\t\t\t\t\tewq->msg.arg.reserved.reserved1;\n\n\t\t\t\tuserfaultfd_ctx_put(new);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tspin_unlock(&ctx->event_wqh.lock);\n\n\t\twake_up_poll(&ctx->fd_wqh, POLLIN);\n\t\tschedule();\n\n\t\tspin_lock(&ctx->event_wqh.lock);\n\t}\n\t__set_current_state(TASK_RUNNING);\n\tspin_unlock(&ctx->event_wqh.lock);\n\n\t/*\n\t * ctx may go away after this if the userfault pseudo fd is\n\t * already released.\n\t */\nout:\n\tuserfaultfd_ctx_put(ctx);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags)\n{\n uint32_t *input_u32;\n uint8_t *input_u8, *output_u8;\n size_t length;\n int rc;\n\n if (!input)\n {\n if (output)\n\t*output = 0;\n return IDN2_OK;\n }\n\n input_u32 = (uint32_t *) malloc ((inlen + 1) * sizeof(uint32_t));\n if (!input_u32)\n return IDN2_MALLOC;\n\n u32_cpy (input_u32, input, inlen);\n input_u32[inlen] = 0;\n\n input_u8 = u32_to_u8 (input_u32, inlen + 1, NULL, &length);\n free (input_u32);\n if (!input_u8)\n {\n if (errno == ENOMEM)\n\treturn IDN2_MALLOC;\n return IDN2_ENCODING_ERROR;\n }\n\n rc = idn2_lookup_u8 (input_u8, &output_u8, flags);\n free (input_u8);\n\n if (rc == IDN2_OK)\n {\n /* wow, this is ugly, but libidn manpage states:\n * char * out output zero terminated string that must have room for at\n * least 63 characters plus the terminating zero.\n */\n if (output)\n\tstrcpy (output, (const char *) output_u8);\n\n free(output_u8);\n }\n\n return rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "term_and_job_init(\n\tterm_T\t *term,\n\ttypval_T *argvar,\n\tchar\t **argv,\n\tjobopt_T *opt,\n\tjobopt_T *orig_opt UNUSED)\n{\n if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL)\n\treturn FAIL;\n\n#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)\n if (opt->jo_set2 & JO2_ANSI_COLORS)\n\tset_vterm_palette(term->tl_vterm, opt->jo_ansi_colors);\n else\n\tinit_vterm_ansi_colors(term->tl_vterm);\n#endif\n\n /* This may change a string in \"argvar\". */\n term->tl_job = job_start(argvar, argv, opt, TRUE);\n if (term->tl_job != NULL)\n\t++term->tl_job->jv_refcount;\n\n return term->tl_job != NULL\n\t&& term->tl_job->jv_channel != NULL\n\t&& term->tl_job->jv_status != JOB_FAILED ? OK : FAIL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "ossl_cipher_initialize(VALUE self, VALUE str)\n{\n EVP_CIPHER_CTX *ctx;\n const EVP_CIPHER *cipher;\n char *name;\n\n name = StringValueCStr(str);\n GetCipherInit(self, ctx);\n if (ctx) {\n\tossl_raise(rb_eRuntimeError, \"Cipher already inititalized!\");\n }\n AllocCipher(self, ctx);\n if (!(cipher = EVP_get_cipherbyname(name))) {\n\tossl_raise(rb_eRuntimeError, \"unsupported cipher algorithm (%\"PRIsVALUE\")\", str);\n }\n if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)\n\tossl_raise(eCipherError, NULL);\n\n return self;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-326", "cwe_name": "Inadequate Encryption Strength", "description": "The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.", "url": "https://cwe.mitre.org/data/definitions/326.html", "label_name": "safe"} {"code": "flac_read_loop (SF_PRIVATE *psf, unsigned len)\n{\tFLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;\n\n\tpflac->pos = 0 ;\n\tpflac->len = len ;\n\tpflac->remain = len ;\n\n\t/* First copy data that has already been decoded and buffered. */\n\tif (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize)\n\t\tflac_buffer_copy (psf) ;\n\n\t/* Decode some more. */\n\twhile (pflac->pos < pflac->len)\n\t{\tif (FLAC__stream_decoder_process_single (pflac->fsd) == 0)\n\t\t\tbreak ;\n\t\tif (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM)\n\t\t\tbreak ;\n\t\t} ;\n\n\tpflac->ptr = NULL ;\n\n\treturn pflac->pos ;\n} /* flac_read_loop */", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "int read_file(struct sc_card *card, char *str_path, unsigned char **data, size_t *data_len)\n{\n\tstruct sc_path path;\n\tstruct sc_file *file;\n\tunsigned char *p;\n\tint ok = 0;\n\tint r;\n\tsize_t len;\n\n\tsc_format_path(str_path, &path);\n\tif (SC_SUCCESS != sc_select_file(card, &path, &file)) {\n\t\tgoto err;\n\t}\n\n\tlen = file ? file->size : 4096;\n\tp = realloc(*data, len);\n\tif (!p) {\n\t\tgoto err;\n\t}\n\t*data = p;\n\t*data_len = len;\n\n\tr = sc_read_binary(card, 0, p, len, 0);\n\tif (r < 0)\n\t\tgoto err;\n\n\t*data_len = r;\n\tok = 1;\n\nerr:\n\tsc_file_free(file);\n\n\treturn ok;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "_client_protocol_timeout (GsmXSMPClient *client)\n{\n g_debug (\"GsmXSMPClient: client_protocol_timeout for client '%s' in ICE status %d\",\n client->priv->description,\n IceConnectionStatus (client->priv->ice_connection));\n\n gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FAILED);\n gsm_client_disconnected (GSM_CLIENT (client));\n\n return FALSE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": "static int hi3660_stub_clk_probe(struct platform_device *pdev)\n{\n\tstruct device *dev = &pdev->dev;\n\tstruct resource *res;\n\tunsigned int i;\n\tint ret;\n\n\t/* Use mailbox client without blocking */\n\tstub_clk_chan.cl.dev = dev;\n\tstub_clk_chan.cl.tx_done = NULL;\n\tstub_clk_chan.cl.tx_block = false;\n\tstub_clk_chan.cl.knows_txdone = false;\n\n\t/* Allocate mailbox channel */\n\tstub_clk_chan.mbox = mbox_request_channel(&stub_clk_chan.cl, 0);\n\tif (IS_ERR(stub_clk_chan.mbox))\n\t\treturn PTR_ERR(stub_clk_chan.mbox);\n\n\tres = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n\tif (!res)\n\t\treturn -EINVAL;\n\tfreq_reg = devm_ioremap(dev, res->start, resource_size(res));\n\tif (!freq_reg)\n\t\treturn -ENOMEM;\n\n\tfreq_reg += HI3660_STUB_CLOCK_DATA;\n\n\tfor (i = 0; i < HI3660_CLK_STUB_NUM; i++) {\n\t\tret = devm_clk_hw_register(&pdev->dev, &hi3660_stub_clks[i].hw);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn devm_of_clk_add_hw_provider(&pdev->dev, hi3660_stub_clk_hw_get,\n\t\t\t\t\t hi3660_stub_clks);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "void __init(RBuffer *buf, r_bin_ne_obj_t *bin) {\n\tbin->header_offset = r_buf_read_le16_at (buf, 0x3c);\n\tbin->ne_header = R_NEW0 (NE_image_header);\n\tif (!bin->ne_header) {\n\t\treturn;\n\t}\n\tbin->buf = buf;\n\t// XXX this is endian unsafe\n\tr_buf_read_at (buf, bin->header_offset, (ut8 *)bin->ne_header, sizeof (NE_image_header));\n\tif (bin->ne_header->FileAlnSzShftCnt > 8) {\n\t\tbin->ne_header->FileAlnSzShftCnt = 8;\n\t}\n\tif (bin->ne_header->ModRefs * sizeof (ut16) >= r_buf_size (bin->buf)) {\n\t\tbin->ne_header->ModRefs = r_buf_size (bin->buf) / sizeof (ut16);\n\t}\n\tbin->alignment = 1 << bin->ne_header->FileAlnSzShftCnt;\n\tif (!bin->alignment) {\n\t\tbin->alignment = 1 << 9;\n\t}\n\tbin->os = __get_target_os (bin);\n\n\tut16 offset = bin->ne_header->SegTableOffset + bin->header_offset;\n\tsize_t size = bin->ne_header->SegCount * sizeof (NE_image_segment_entry);\n\tif (offset >= r_buf_size (bin->buf)) {\n\t\treturn;\n\t}\n\tsize_t remaining = r_buf_size (bin->buf) - offset;\n\tsize = R_MIN (remaining, size);\n\tbin->segment_entries = calloc (1, size);\n\tif (size >= remaining) {\n\t\tbin->ne_header->SegCount = size / sizeof (NE_image_segment_entry);\n\t}\n\tif (!bin->segment_entries) {\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, offset, (ut8 *)bin->segment_entries, size);\n\tbin->entry_table = calloc (1, bin->ne_header->EntryTableLength);\n\tr_buf_read_at (buf, (ut64)bin->header_offset + bin->ne_header->EntryTableOffset, bin->entry_table, bin->ne_header->EntryTableLength);\n\tbin->imports = r_bin_ne_get_imports (bin);\n\t__ne_get_resources (bin);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "safe"} {"code": "int ras_validate(jas_stream_t *in)\n{\n\tjas_uchar buf[RAS_MAGICLEN];\n\tint i;\n\tint n;\n\tuint_fast32_t magic;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= RAS_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, RAS_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Did we read enough data? */\n\tif (n < RAS_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Is the signature correct for the Sun Rasterfile format? */\n\tif (magic != RAS_MAGIC) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "acc_ctx_hints(OM_uint32 *minor_status,\n\t gss_ctx_id_t *ctx,\n\t spnego_gss_cred_id_t spcred,\n\t gss_buffer_t *mechListMIC,\n\t OM_uint32 *negState,\n\t send_token_flag *return_token)\n{\n\tOM_uint32 tmpmin, ret;\n\tgss_OID_set supported_mechSet;\n\tspnego_gss_ctx_id_t sc = NULL;\n\n\t*mechListMIC = GSS_C_NO_BUFFER;\n\tsupported_mechSet = GSS_C_NO_OID_SET;\n\t*return_token = NO_TOKEN_SEND;\n\t*negState = REJECT;\n\t*minor_status = 0;\n\n\t/* A hint request must be the first token received. */\n\tif (*ctx != GSS_C_NO_CONTEXT)\n\t return GSS_S_DEFECTIVE_TOKEN;\n\n\tret = get_negotiable_mechs(minor_status, spcred, GSS_C_ACCEPT,\n\t\t\t\t &supported_mechSet);\n\tif (ret != GSS_S_COMPLETE)\n\t\tgoto cleanup;\n\n\tret = make_NegHints(minor_status, mechListMIC);\n\tif (ret != GSS_S_COMPLETE)\n\t\tgoto cleanup;\n\n\tsc = create_spnego_ctx();\n\tif (sc == NULL) {\n\t\tret = GSS_S_FAILURE;\n\t\tgoto cleanup;\n\t}\n\tif (put_mech_set(supported_mechSet, &sc->DER_mechTypes) < 0) {\n\t\tret = GSS_S_FAILURE;\n\t\tgoto cleanup;\n\t}\n\tsc->internal_mech = GSS_C_NO_OID;\n\n\t*negState = ACCEPT_INCOMPLETE;\n\t*return_token = INIT_TOKEN_SEND;\n\tsc->firstpass = 1;\n\t*ctx = (gss_ctx_id_t)sc;\n\tsc = NULL;\n\tret = GSS_S_COMPLETE;\n\ncleanup:\n\trelease_spnego_ctx(&sc);\n\tgss_release_oid_set(&tmpmin, &supported_mechSet);\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "vulnerable"} {"code": "static int filter_frame(AVFilterLink *inlink, AVFrame *in)\n{\n DelogoContext *s = inlink->dst->priv;\n AVFilterLink *outlink = inlink->dst->outputs[0];\n const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);\n AVFrame *out;\n int hsub0 = desc->log2_chroma_w;\n int vsub0 = desc->log2_chroma_h;\n int direct = 0;\n int plane;\n AVRational sar;\n\n if (av_frame_is_writable(in)) {\n direct = 1;\n out = in;\n } else {\n out = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n if (!out) {\n av_frame_free(&in);\n return AVERROR(ENOMEM);\n }\n\n av_frame_copy_props(out, in);\n }\n\n sar = in->sample_aspect_ratio;\n /* Assume square pixels if SAR is unknown */\n if (!sar.num)\n sar.num = sar.den = 1;\n\n for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) {\n int hsub = plane == 1 || plane == 2 ? hsub0 : 0;\n int vsub = plane == 1 || plane == 2 ? vsub0 : 0;\n\n apply_delogo(out->data[plane], out->linesize[plane],\n in ->data[plane], in ->linesize[plane],\n FF_CEIL_RSHIFT(inlink->w, hsub),\n FF_CEIL_RSHIFT(inlink->h, vsub),\n sar, s->x>>hsub, s->y>>vsub,\n /* Up and left borders were rounded down, inject lost bits\n * into width and height to avoid error accumulation */\n FF_CEIL_RSHIFT(s->w + (s->x & ((1<h + (s->y & ((1<band>>FFMIN(hsub, vsub),\n s->show, direct);\n }\n\n if (!direct)\n av_frame_free(&in);\n\n return ff_filter_frame(outlink, out);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_kpp rkpp;\n\n\tstrncpy(rkpp.type, \"kpp\", sizeof(rkpp.type));\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_KPP,\n\t\t sizeof(struct crypto_report_kpp), &rkpp))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "iakerb_gss_wrap_iov_length(OM_uint32 *minor_status,\n gss_ctx_id_t context_handle, int conf_req_flag,\n gss_qop_t qop_req, int *conf_state,\n gss_iov_buffer_desc *iov, int iov_count)\n{\n iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle;\n\n if (ctx->gssc == GSS_C_NO_CONTEXT)\n return GSS_S_NO_CONTEXT;\n\n return krb5_gss_wrap_iov_length(minor_status, ctx->gssc, conf_req_flag,\n qop_req, conf_state, iov, iov_count);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-18", "cwe_name": "DEPRECATED: Source Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/18.html", "label_name": "safe"} {"code": "void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)\n{\n\tstruct kvm_pit *pit = vcpu->kvm->arch.vpit;\n\tstruct hrtimer *timer;\n\n\tif (!kvm_vcpu_is_bsp(vcpu) || !pit)\n\t\treturn;\n\n\ttimer = &pit->pit_state.timer;\n\tmutex_lock(&pit->pit_state.lock);\n\tif (hrtimer_cancel(timer))\n\t\thrtimer_start_expires(timer, HRTIMER_MODE_ABS);\n\tmutex_unlock(&pit->pit_state.lock);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "bool inode_capable(const struct inode *inode, int cap)\n{\n\tstruct user_namespace *ns = current_user_ns();\n\n\treturn ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "snmp_ber_encode_null(unsigned char *out, uint32_t *out_len, uint8_t type)\n{\n (*out_len)++;\n *out-- = 0x00;\n out = snmp_ber_encode_type(out, out_len, type);\n\n return out;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)\n{\n\tstruct snd_ctl_elem_id id;\n\tunsigned int idx;\n\tunsigned int count;\n\tint err = -EINVAL;\n\n\tif (! kcontrol)\n\t\treturn err;\n\tif (snd_BUG_ON(!card || !kcontrol->info))\n\t\tgoto error;\n\tid = kcontrol->id;\n\tdown_write(&card->controls_rwsem);\n\tif (snd_ctl_find_id(card, &id)) {\n\t\tup_write(&card->controls_rwsem);\n\t\tdev_err(card->dev, \"control %i:%i:%i:%s:%i is already present\\n\",\n\t\t\t\t\tid.iface,\n\t\t\t\t\tid.device,\n\t\t\t\t\tid.subdevice,\n\t\t\t\t\tid.name,\n\t\t\t\t\tid.index);\n\t\terr = -EBUSY;\n\t\tgoto error;\n\t}\n\tif (snd_ctl_find_hole(card, kcontrol->count) < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\terr = -ENOMEM;\n\t\tgoto error;\n\t}\n\tlist_add_tail(&kcontrol->list, &card->controls);\n\tcard->controls_count += kcontrol->count;\n\tkcontrol->id.numid = card->last_numid + 1;\n\tcard->last_numid += kcontrol->count;\n\tcount = kcontrol->count;\n\tup_write(&card->controls_rwsem);\n\tfor (idx = 0; idx < count; idx++, id.index++, id.numid++)\n\t\tsnd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);\n\treturn 0;\n\n error:\n\tsnd_ctl_free_one(kcontrol);\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "BGD_DECLARE(void *) gdImageGifPtr(gdImagePtr im, int *size)\n{\n\tvoid *rv;\n\tgdIOCtx *out = gdNewDynamicCtx(2048, NULL);\n\tif (out == NULL) return NULL;\n\tgdImageGifCtx(im, out);\n\trv = gdDPExtractData(out, size);\n\tout->gd_free(out);\n\treturn rv;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "mcs_parse_domain_params(STREAM s)\n{\n\tint length;\n\n\tber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);\n\tin_uint8s(s, length);\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "int firstBitSet(int x)\n{\n int position=0;\n while (x!=0)\n {\n x>>=1;\n ++position;\n }\n return position;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "parse_user_name(char *user_input, char **ret_username)\n{\n\tregister char *ptr;\n\tregister int index = 0;\n\tchar username[PAM_MAX_RESP_SIZE];\n\n\t/* Set the default value for *ret_username */\n\t*ret_username = NULL;\n\n\t/*\n\t * Set the initial value for username - this is a buffer holds\n\t * the user name.\n\t */\n\tbzero((void *)username, PAM_MAX_RESP_SIZE);\n\n\t/*\n\t * The user_input is guaranteed to be terminated by a null character.\n\t */\n\tptr = user_input;\n\n\t/* Skip all the leading whitespaces if there are any. */\n\twhile ((*ptr == ' ') || (*ptr == '\\t'))\n\t\tptr++;\n\n\tif (*ptr == '\\0') {\n\t\t/*\n\t\t * We should never get here since the user_input we got\n\t\t * in pam_get_user() is not all whitespaces nor just \"\\0\".\n\t\t */\n\t\treturn (PAM_BUF_ERR);\n\t}\n\n\t/*\n\t * username will be the first string we get from user_input\n\t * - we skip leading whitespaces and ignore trailing whitespaces\n\t */\n\twhile (*ptr != '\\0') {\n\t\tif ((*ptr == ' ') || (*ptr == '\\t'))\n\t\t\tbreak;\n\t\telse {\n\t\t\tusername[index] = *ptr;\n\t\t\tindex++;\n\t\t\tptr++;\n\t\t}\n\t}\n\n\t/* ret_username will be freed in pam_get_user(). */\n\tif ((*ret_username = malloc(index + 1)) == NULL)\n\t\treturn (PAM_BUF_ERR);\n\t(void) strcpy(*ret_username, username);\n\treturn (PAM_SUCCESS);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "int ecc_map(ecc_point* P, mp_int* modulus, mp_digit mp)\n{\n return ecc_map_ex(P, modulus, mp, 0);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-203", "cwe_name": "Observable Discrepancy", "description": "The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.", "url": "https://cwe.mitre.org/data/definitions/203.html", "label_name": "safe"} {"code": "static bool check_underflow(const struct arpt_entry *e)\n{\n\tconst struct xt_entry_target *t;\n\tunsigned int verdict;\n\n\tif (!unconditional(&e->arp))\n\t\treturn false;\n\tt = arpt_get_target_c(e);\n\tif (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)\n\t\treturn false;\n\tverdict = ((struct xt_standard_target *)t)->verdict;\n\tverdict = -verdict - 1;\n\treturn verdict == NF_DROP || verdict == NF_ACCEPT;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void ntlm_write_message_fields(wStream* s, NTLM_MESSAGE_FIELDS* fields)\n{\n\tif (fields->MaxLen < 1)\n\t\tfields->MaxLen = fields->Len;\n\n\tStream_Write_UINT16(s, fields->Len); /* Len (2 bytes) */\n\tStream_Write_UINT16(s, fields->MaxLen); /* MaxLen (2 bytes) */\n\tStream_Write_UINT32(s, fields->BufferOffset); /* BufferOffset (4 bytes) */\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void fanout_release(struct sock *sk)\n{\n\tstruct packet_sock *po = pkt_sk(sk);\n\tstruct packet_fanout *f;\n\n\tf = po->fanout;\n\tif (!f)\n\t\treturn;\n\n\tmutex_lock(&fanout_mutex);\n\tpo->fanout = NULL;\n\n\tif (atomic_dec_and_test(&f->sk_ref)) {\n\t\tlist_del(&f->list);\n\t\tdev_remove_pack(&f->prot_hook);\n\t\tfanout_release_data(f);\n\t\tkfree(f);\n\t}\n\tmutex_unlock(&fanout_mutex);\n\n\tif (po->rollover)\n\t\tkfree_rcu(po->rollover, rcu);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "magic_getparam(struct magic_set *ms, int param, void *val)\n{\n\tswitch (param) {\n\tcase MAGIC_PARAM_INDIR_MAX:\n\t\t*(size_t *)val = ms->indir_max;\n\t\treturn 0;\n\tcase MAGIC_PARAM_NAME_MAX:\n\t\t*(size_t *)val = ms->name_max;\n\t\treturn 0;\n\tcase MAGIC_PARAM_ELF_PHNUM_MAX:\n\t\t*(size_t *)val = ms->elf_phnum_max;\n\t\treturn 0;\n\tcase MAGIC_PARAM_ELF_SHNUM_MAX:\n\t\t*(size_t *)val = ms->elf_shnum_max;\n\t\treturn 0;\n\tcase MAGIC_PARAM_ELF_NOTES_MAX:\n\t\t*(size_t *)val = ms->elf_notes_max;\n\t\treturn 0;\n\tdefault:\n\t\terrno = EINVAL;\n\t\treturn -1;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu)\n{\n\tstruct perf_event_context *src_ctx;\n\tstruct perf_event_context *dst_ctx;\n\tstruct perf_event *event, *tmp;\n\tLIST_HEAD(events);\n\n\tsrc_ctx = &per_cpu_ptr(pmu->pmu_cpu_context, src_cpu)->ctx;\n\tdst_ctx = &per_cpu_ptr(pmu->pmu_cpu_context, dst_cpu)->ctx;\n\n\t/*\n\t * See perf_event_ctx_lock() for comments on the details\n\t * of swizzling perf_event::ctx.\n\t */\n\tmutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex);\n\tlist_for_each_entry_safe(event, tmp, &src_ctx->event_list,\n\t\t\t\t event_entry) {\n\t\tperf_remove_from_context(event, false);\n\t\tunaccount_event_cpu(event, src_cpu);\n\t\tput_ctx(src_ctx);\n\t\tlist_add(&event->migrate_entry, &events);\n\t}\n\n\tsynchronize_rcu();\n\n\tlist_for_each_entry_safe(event, tmp, &events, migrate_entry) {\n\t\tlist_del(&event->migrate_entry);\n\t\tif (event->state >= PERF_EVENT_STATE_OFF)\n\t\t\tevent->state = PERF_EVENT_STATE_INACTIVE;\n\t\taccount_event_cpu(event, dst_cpu);\n\t\tperf_install_in_context(dst_ctx, event, dst_cpu);\n\t\tget_ctx(dst_ctx);\n\t}\n\tmutex_unlock(&dst_ctx->mutex);\n\tmutex_unlock(&src_ctx->mutex);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "guestfs___first_line_of_file (guestfs_h *g, const char *filename)\n{\n CLEANUP_FREE char **lines = NULL; /* sic: not CLEANUP_FREE_STRING_LIST */\n int64_t size;\n char *ret;\n\n /* Don't trust guestfs_head_n not to break with very large files.\n * Check the file size is something reasonable first.\n */\n size = guestfs_filesize (g, filename);\n if (size == -1)\n /* guestfs_filesize failed and has already set error in handle */\n return NULL;\n if (size > MAX_SMALL_FILE_SIZE) {\n error (g, _(\"size of %s is unreasonably large (%\" PRIi64 \" bytes)\"),\n filename, size);\n return NULL;\n }\n\n lines = guestfs_head_n (g, 1, filename);\n if (lines == NULL)\n return NULL;\n if (lines[0] == NULL) {\n guestfs___free_string_list (lines);\n /* Empty file: Return an empty string as explained above. */\n return safe_strdup (g, \"\");\n }\n /* lines[1] should be NULL because of '1' argument above ... */\n\n ret = lines[0]; /* caller frees */\n\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "void SavePayload(size_t handle, uint32_t *payload, uint32_t index)\n{\n\tmp4object *mp4 = (mp4object *)handle;\n\tif (mp4 == NULL) return;\n\n\tuint32_t *MP4buffer = NULL;\n\tif (index < mp4->indexcount && mp4->mediafp && payload)\n\t{\n\t\tLONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET);\n\t\tfwrite(payload, 1, mp4->metasizes[index], mp4->mediafp);\n\t}\n\treturn;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc)\n{\n uint16* wp = (uint16*) cp0;\n tmsize_t wc = cc / 2;\n\n horDiff16(tif, cp0, cc);\n\n TIFFSwabArrayOfShort(wp, wc);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "int snmp_version(void *context, size_t hdrlen, unsigned char tag,\n\t\t const void *data, size_t datalen)\n{\n\tif (datalen != 1)\n\t\treturn -EINVAL;\n\tif (*(unsigned char *)data > 1)\n\t\treturn -ENOTSUPP;\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "SPL_METHOD(SplFileObject, __construct)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tzend_bool use_include_path = 0;\n\tchar *p1, *p2;\n\tchar *tmp_path;\n\tint tmp_path_len;\n\tzend_error_handling error_handling;\n\n\tzend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);\n\n\tintern->u.file.open_mode = NULL;\n\tintern->u.file.open_mode_len = 0;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"p|sbr!\",\n\t\t\t&intern->file_name, &intern->file_name_len,\n\t\t\t&intern->u.file.open_mode, &intern->u.file.open_mode_len,\n\t\t\t&use_include_path, &intern->u.file.zcontext) == FAILURE) {\n\t\tintern->u.file.open_mode = NULL;\n\t\tintern->file_name = NULL;\n\t\tzend_restore_error_handling(&error_handling TSRMLS_CC);\n\t\treturn;\n\t}\n\n\tif (intern->u.file.open_mode == NULL) {\n\t\tintern->u.file.open_mode = \"r\";\n\t\tintern->u.file.open_mode_len = 1;\n\t}\n\n\tif (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == SUCCESS) {\n\t\ttmp_path_len = strlen(intern->u.file.stream->orig_path);\n\n\t\tif (tmp_path_len > 1 && IS_SLASH_AT(intern->u.file.stream->orig_path, tmp_path_len-1)) {\n\t\t\ttmp_path_len--;\n\t\t}\n\n\t\ttmp_path = estrndup(intern->u.file.stream->orig_path, tmp_path_len);\n\n\t\tp1 = strrchr(tmp_path, '/');\n#if defined(PHP_WIN32) || defined(NETWARE)\n\t\tp2 = strrchr(tmp_path, '\\\\');\n#else\n\t\tp2 = 0;\n#endif\n\t\tif (p1 || p2) {\n\t\t\tintern->_path_len = (p1 > p2 ? p1 : p2) - tmp_path;\n\t\t} else {\n\t\t\tintern->_path_len = 0;\n\t\t}\n\n\t\tefree(tmp_path);\n\n\t\tintern->_path = estrndup(intern->u.file.stream->orig_path, intern->_path_len);\n\t}\n\n\tzend_restore_error_handling(&error_handling TSRMLS_CC);\n\n} /* }}} */", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static void get_sem_elements(struct sem_data *p)\n{\n\tsize_t i;\n\n\tif (!p || !p->sem_nsems || p->sem_perm.id < 0)\n\t\treturn;\n\n\tp->elements = xcalloc(p->sem_nsems, sizeof(struct sem_elem));\n\n\tfor (i = 0; i < p->sem_nsems; i++) {\n\t\tstruct sem_elem *e = &p->elements[i];\n\t\tunion semun arg = { .val = 0 };\n\n\t\te->semval = semctl(p->sem_perm.id, i, GETVAL, arg);\n\t\tif (e->semval < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETVAL)\");\n\n\t\te->ncount = semctl(p->sem_perm.id, i, GETNCNT, arg);\n\t\tif (e->ncount < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETNCNT)\");\n\n\t\te->zcount = semctl(p->sem_perm.id, i, GETZCNT, arg);\n\t\tif (e->zcount < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETZCNT)\");\n\n\t\te->pid = semctl(p->sem_perm.id, i, GETPID, arg);\n\t\tif (e->pid < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETPID)\");\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static int handle_vmread(struct kvm_vcpu *vcpu)\n{\n\tunsigned long field;\n\tu64 field_value;\n\tunsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION);\n\tu32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);\n\tgva_t gva = 0;\n\n\tif (!nested_vmx_check_permission(vcpu))\n\t\treturn 1;\n\n\tif (!nested_vmx_check_vmcs12(vcpu))\n\t\treturn kvm_skip_emulated_instruction(vcpu);\n\n\t/* Decode instruction info and find the field to read */\n\tfield = kvm_register_readl(vcpu, (((vmx_instruction_info) >> 28) & 0xf));\n\t/* Read the field, zero-extended to a u64 field_value */\n\tif (vmcs12_read_any(vcpu, field, &field_value) < 0) {\n\t\tnested_vmx_failValid(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);\n\t\treturn kvm_skip_emulated_instruction(vcpu);\n\t}\n\t/*\n\t * Now copy part of this value to register or memory, as requested.\n\t * Note that the number of bits actually copied is 32 or 64 depending\n\t * on the guest's mode (32 or 64 bit), not on the given field's length.\n\t */\n\tif (vmx_instruction_info & (1u << 10)) {\n\t\tkvm_register_writel(vcpu, (((vmx_instruction_info) >> 3) & 0xf),\n\t\t\tfield_value);\n\t} else {\n\t\tif (get_vmx_mem_address(vcpu, exit_qualification,\n\t\t\t\tvmx_instruction_info, true, &gva))\n\t\t\treturn 1;\n\t\t/* _system ok, nested_vmx_check_permission has verified cpl=0 */\n\t\tkvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, gva,\n\t\t\t &field_value, (is_long_mode(vcpu) ? 8 : 4), NULL);\n\t}\n\n\tnested_vmx_succeed(vcpu);\n\treturn kvm_skip_emulated_instruction(vcpu);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "htmlGetText(tree_t *t)\t\t/* I - Tree to pick */\n{\n uchar\t\t*s,\t\t// String\n\t\t*s2,\t\t// New string\n\t\t*tdata = NULL,\t// Temporary string data\n\t\t*talloc = NULL;\t// Allocated string data\n size_t\tslen,\t\t// Length of string\n\t\ttlen;\t\t// Length of node string\n\n\n // Loop through all of the nodes in the tree and collect text...\n slen = 0;\n s = NULL;\n\n while (t != NULL)\n {\n if (t->child)\n tdata = talloc = htmlGetText(t->child);\n else\n tdata = t->data;\n\n if (tdata != NULL)\n {\n // Add the text to this string...\n tlen = strlen((char *)tdata);\n\n if (s)\n s2 = (uchar *)realloc(s, 1 + slen + tlen);\n else\n s2 = (uchar *)malloc(1 + tlen);\n\n if (!s2)\n break;\n\n s = s2;\n\n memcpy((char *)s + slen, (char *)tdata, tlen);\n\n slen += tlen;\n\n if (talloc)\n {\n\tfree(talloc);\n\ttalloc = NULL;\n }\n }\n\n t = t->next;\n }\n\n if (slen)\n s[slen] = '\\0';\n\n if (talloc)\n free(talloc);\n\n return (s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static void mark_key_instantiated(struct key *key, int reject_error)\n{\n\t/* Commit the payload before setting the state; barrier versus\n\t * key_read_state().\n\t */\n\tsmp_store_release(&key->state,\n\t\t\t (reject_error < 0) ? reject_error : KEY_IS_POSITIVE);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "GetStartupData(HANDLE pipe, STARTUP_DATA *sud)\n{\n size_t size, len;\n WCHAR *data = NULL;\n DWORD bytes, read;\n\n bytes = PeekNamedPipeAsync(pipe, 1, &exit_event);\n if (bytes == 0)\n {\n MsgToEventLog(M_SYSERR, TEXT(\"PeekNamedPipeAsync failed\"));\n ReturnLastError(pipe, L\"PeekNamedPipeAsync\");\n goto err;\n }\n\n size = bytes / sizeof(*data);\n if (size == 0)\n {\n MsgToEventLog(M_SYSERR, TEXT(\"malformed startup data: 1 byte received\"));\n ReturnError(pipe, ERROR_STARTUP_DATA, L\"GetStartupData\", 1, &exit_event);\n goto err;\n }\n\n data = malloc(bytes);\n if (data == NULL)\n {\n MsgToEventLog(M_SYSERR, TEXT(\"malloc failed\"));\n ReturnLastError(pipe, L\"malloc\");\n goto err;\n }\n\n read = ReadPipeAsync(pipe, data, bytes, 1, &exit_event);\n if (bytes != read)\n {\n MsgToEventLog(M_SYSERR, TEXT(\"ReadPipeAsync failed\"));\n ReturnLastError(pipe, L\"ReadPipeAsync\");\n goto err;\n }\n\n if (data[size - 1] != 0)\n {\n MsgToEventLog(M_ERR, TEXT(\"Startup data is not NULL terminated\"));\n ReturnError(pipe, ERROR_STARTUP_DATA, L\"GetStartupData\", 1, &exit_event);\n goto err;\n }\n\n sud->directory = data;\n len = wcslen(sud->directory) + 1;\n size -= len;\n if (size <= 0)\n {\n MsgToEventLog(M_ERR, TEXT(\"Startup data ends at working directory\"));\n ReturnError(pipe, ERROR_STARTUP_DATA, L\"GetStartupData\", 1, &exit_event);\n goto err;\n }\n\n sud->options = sud->directory + len;\n len = wcslen(sud->options) + 1;\n size -= len;\n if (size <= 0)\n {\n MsgToEventLog(M_ERR, TEXT(\"Startup data ends at command line options\"));\n ReturnError(pipe, ERROR_STARTUP_DATA, L\"GetStartupData\", 1, &exit_event);\n goto err;\n }\n\n sud->std_input = sud->options + len;\n return TRUE;\n\nerr:\n sud->directory = NULL;\t\t/* caller must not free() */\n free(data);\n return FALSE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "file_push_buffer(struct magic_set *ms)\n{\n\tfile_pushbuf_t *pb;\n\n\tif (ms->event_flags & EVENT_HAD_ERR)\n\t\treturn NULL;\n\n\tif ((pb = (CAST(file_pushbuf_t *, malloc(sizeof(*pb))))) == NULL)\n\t\treturn NULL;\n\n\tpb->buf = ms->o.buf;\n\tpb->offset = ms->offset;\n\n\tms->o.buf = NULL;\n\tms->offset = 0;\n\n\treturn pb;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static RList *r_bin_wasm_get_data_entries (RBinWasmObj *bin, RBinWasmSection *sec) {\n\n\tRList *ret = NULL;\n\tRBinWasmDataEntry *ptr = NULL;\n\n\tif (!(ret = r_list_newf ((RListFree)free))) {\n\t\treturn NULL;\n\t}\n\n\tut8* buf = bin->buf->buf + (ut32)sec->payload_data;\n\tut32 len = sec->payload_len;\n\tut32 count = sec->count;\n\tut32 i = 0, r = 0;\n\tsize_t n = 0;\n\n\twhile (i < len && r < count) {\n\n\t\tif (!(ptr = R_NEW0 (RBinWasmDataEntry))) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (!(consume_u32 (buf + i, buf + len, &ptr->index, &i))) {\n\t\t\tfree (ptr);\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (!(n = consume_init_expr (buf + i, buf + len, R_BIN_WASM_END_OF_CODE, NULL, &i))) {\n\t\t\tfree (ptr);\n\t\t\treturn ret;\n\t\t}\n\n\t\tptr->offset.len = n;\n\n\t\tif (!(consume_u32 (buf + i, buf + len, &ptr->size, &i))) {\t\n\t\t\tfree (ptr);\n\t\t\treturn ret;\n\t\t}\n\n\t\tptr->data = sec->payload_data + i;\n\n\t\tr_list_append (ret, ptr);\n\n\t\tr += 1;\n\n\t}\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "proc_lambda(mrb_state *mrb, mrb_value self)\n{\n mrb_value blk;\n struct RProc *p;\n\n mrb_get_args(mrb, \"&\", &blk);\n if (mrb_nil_p(blk)) {\n mrb_raise(mrb, E_ARGUMENT_ERROR, \"tried to create Proc object without a block\");\n }\n if (!mrb_proc_p(blk)) {\n mrb_raise(mrb, E_ARGUMENT_ERROR, \"not a proc\");\n }\n p = mrb_proc_ptr(blk);\n if (!MRB_PROC_STRICT_P(p)) {\n struct RProc *p2 = MRB_OBJ_ALLOC(mrb, MRB_TT_PROC, p->c);\n mrb_proc_copy(mrb, p2, p);\n p2->flags |= MRB_PROC_STRICT;\n return mrb_obj_value(p2);\n }\n return blk;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)\n{\n\tvoid *buf;\n\tint ret;\n\n\tbuf = kmalloc(size, GFP_NOIO);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),\n\t\t\t RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,\n\t\t\t indx, 0, buf, size, 500);\n\tif (ret > 0 && ret <= size)\n\t\tmemcpy(data, buf, ret);\n\tkfree(buf);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "get_html_data (MAPI_Attr *a)\n{\n VarLenData **body = XCALLOC(VarLenData*, a->num_values + 1);\n\n int j;\n for (j = 0; j < a->num_values; j++)\n {\n if (a->type == szMAPI_BINARY) {\n \t body[j] = XMALLOC(VarLenData, 1);\n\t body[j]->len = a->values[j].len;\n\t body[j]->data = CHECKED_XCALLOC(unsigned char, a->values[j].len);\n\t memmove (body[j]->data, a->values[j].data.buf, body[j]->len);\n }\n }\n return body;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)\n{\n\tenum hrtimer_restart ret = HRTIMER_RESTART;\n\tstruct perf_sample_data data;\n\tstruct pt_regs *regs;\n\tstruct perf_event *event;\n\tu64 period;\n\n\tevent = container_of(hrtimer, struct perf_event, hw.hrtimer);\n\n\tif (event->state != PERF_EVENT_STATE_ACTIVE)\n\t\treturn HRTIMER_NORESTART;\n\n\tevent->pmu->read(event);\n\n\tperf_sample_data_init(&data, 0);\n\tdata.period = event->hw.last_period;\n\tregs = get_irq_regs();\n\n\tif (regs && !perf_exclude_event(event, regs)) {\n\t\tif (!(event->attr.exclude_idle && current->pid == 0))\n\t\t\tif (perf_event_overflow(event, 0, &data, regs))\n\t\t\t\tret = HRTIMER_NORESTART;\n\t}\n\n\tperiod = max_t(u64, 10000, event->hw.sample_period);\n\thrtimer_forward_now(hrtimer, ns_to_ktime(period));\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) {\n StkId base = ci->func + 1;\n const char *name = NULL;\n if (isLua(ci)) {\n if (n < 0) /* access to vararg values? */\n return findvararg(ci, -n, pos);\n else\n name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));\n }\n if (name == NULL) { /* no 'standard' name? */\n StkId limit = (ci == L->ci) ? L->top : ci->next->func;\n if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */\n /* generic name for any valid slot */\n name = isLua(ci) ? \"(temporary)\" : \"(C temporary)\";\n }\n else\n return NULL; /* no name */\n }\n if (pos)\n *pos = base + (n - 1);\n return name;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-191", "cwe_name": "Integer Underflow (Wrap or Wraparound)", "description": "The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.", "url": "https://cwe.mitre.org/data/definitions/191.html", "label_name": "vulnerable"} {"code": "mrb_obj_clone(mrb_state *mrb, mrb_value self)\n{\n struct RObject *p;\n mrb_value clone;\n\n if (mrb_immediate_p(self)) {\n mrb_raisef(mrb, E_TYPE_ERROR, \"can't clone %S\", self);\n }\n if (mrb_type(self) == MRB_TT_SCLASS) {\n mrb_raise(mrb, E_TYPE_ERROR, \"can't clone singleton class\");\n }\n p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self));\n p->c = mrb_singleton_class_clone(mrb, self);\n mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)p->c);\n clone = mrb_obj_value(p);\n init_copy(mrb, clone, self);\n p->flags = mrb_obj_ptr(self)->flags;\n\n return clone;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "void imap_quote_string(char *dest, size_t dlen, const char *src)\n{\n static const char quote[] = \"\\\"\\\\\";\n char *pt = dest;\n const char *s = src;\n\n *pt++ = '\"';\n /* save room for trailing quote-char */\n dlen -= 2;\n\n for (; *s && dlen; s++)\n {\n if (strchr(quote, *s))\n {\n dlen -= 2;\n if (dlen == 0)\n break;\n *pt++ = '\\\\';\n *pt++ = *s;\n }\n else\n {\n *pt++ = *s;\n dlen--;\n }\n }\n *pt++ = '\"';\n *pt = '\\0';\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "static void perf_event_interrupt(struct pt_regs *regs)\n{\n\tint i;\n\tstruct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);\n\tstruct perf_event *event;\n\tunsigned long val;\n\tint found = 0;\n\tint nmi;\n\n\tif (cpuhw->n_limited)\n\t\tfreeze_limited_counters(cpuhw, mfspr(SPRN_PMC5),\n\t\t\t\t\tmfspr(SPRN_PMC6));\n\n\tperf_read_regs(regs);\n\n\tnmi = perf_intr_is_nmi(regs);\n\tif (nmi)\n\t\tnmi_enter();\n\telse\n\t\tirq_enter();\n\n\tfor (i = 0; i < cpuhw->n_events; ++i) {\n\t\tevent = cpuhw->event[i];\n\t\tif (!event->hw.idx || is_limited_pmc(event->hw.idx))\n\t\t\tcontinue;\n\t\tval = read_pmc(event->hw.idx);\n\t\tif ((int)val < 0) {\n\t\t\t/* event has overflowed */\n\t\t\tfound = 1;\n\t\t\trecord_and_restart(event, val, regs);\n\t\t}\n\t}\n\n\t/*\n\t * In case we didn't find and reset the event that caused\n\t * the interrupt, scan all events and reset any that are\n\t * negative, to avoid getting continual interrupts.\n\t * Any that we processed in the previous loop will not be negative.\n\t */\n\tif (!found) {\n\t\tfor (i = 0; i < ppmu->n_counter; ++i) {\n\t\t\tif (is_limited_pmc(i + 1))\n\t\t\t\tcontinue;\n\t\t\tval = read_pmc(i + 1);\n\t\t\tif (pmc_overflow(val))\n\t\t\t\twrite_pmc(i + 1, 0);\n\t\t}\n\t}\n\n\t/*\n\t * Reset MMCR0 to its normal value. This will set PMXE and\n\t * clear FC (freeze counters) and PMAO (perf mon alert occurred)\n\t * and thus allow interrupts to occur again.\n\t * XXX might want to use MSR.PM to keep the events frozen until\n\t * we get back out of this interrupt.\n\t */\n\twrite_mmcr0(cpuhw, cpuhw->mmcr[0]);\n\n\tif (nmi)\n\t\tnmi_exit();\n\telse\n\t\tirq_exit();\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "static int snd_timer_user_tselect(struct file *file,\n\t\t\t\t struct snd_timer_select __user *_tselect)\n{\n\tstruct snd_timer_user *tu;\n\tstruct snd_timer_select tselect;\n\tchar str[32];\n\tint err = 0;\n\n\ttu = file->private_data;\n\tmutex_lock(&tu->tread_sem);\n\tif (tu->timeri) {\n\t\tsnd_timer_close(tu->timeri);\n\t\ttu->timeri = NULL;\n\t}\n\tif (copy_from_user(&tselect, _tselect, sizeof(tselect))) {\n\t\terr = -EFAULT;\n\t\tgoto __err;\n\t}\n\tsprintf(str, \"application %i\", current->pid);\n\tif (tselect.id.dev_class != SNDRV_TIMER_CLASS_SLAVE)\n\t\ttselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION;\n\terr = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid);\n\tif (err < 0)\n\t\tgoto __err;\n\n\tkfree(tu->queue);\n\ttu->queue = NULL;\n\tkfree(tu->tqueue);\n\ttu->tqueue = NULL;\n\tif (tu->tread) {\n\t\ttu->tqueue = kmalloc(tu->queue_size * sizeof(struct snd_timer_tread),\n\t\t\t\t GFP_KERNEL);\n\t\tif (tu->tqueue == NULL)\n\t\t\terr = -ENOMEM;\n\t} else {\n\t\ttu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read),\n\t\t\t\t GFP_KERNEL);\n\t\tif (tu->queue == NULL)\n\t\t\terr = -ENOMEM;\n\t}\n\n \tif (err < 0) {\n\t\tsnd_timer_close(tu->timeri);\n \t\ttu->timeri = NULL;\n \t} else {\n\t\ttu->timeri->flags |= SNDRV_TIMER_IFLG_FAST;\n\t\ttu->timeri->callback = tu->tread\n\t\t\t? snd_timer_user_tinterrupt : snd_timer_user_interrupt;\n\t\ttu->timeri->ccallback = snd_timer_user_ccallback;\n\t\ttu->timeri->callback_data = (void *)tu;\n\t}\n\n __err:\n \tmutex_unlock(&tu->tread_sem);\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static RList* sections(RBinFile* bf) {\n\tRList* ret = NULL;\n\tRBinSection* sect = NULL;\n\tpsxexe_header psxheader = {0};\n\tut64 sz = 0;\n\n\tif (!(ret = r_list_new ())) {\n\t\treturn NULL;\n\t}\n\n\tif (!(sect = R_NEW0 (RBinSection))) {\n\t\tr_list_free (ret);\n\t\treturn NULL;\n\t}\n\n\tif (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, \"8c17i\", 1) != sizeof (psxexe_header)) {\n\t\teprintf (\"Truncated Header\\n\");\n\t\tfree (sect);\n\t\tr_list_free (ret);\n\t\treturn NULL;\n\t}\n\n\tsz = r_buf_size (bf->buf);\n\n\tsect->name = strdup (\"TEXT\");\n\tsect->paddr = PSXEXE_TEXTSECTION_OFFSET;\n\tsect->size = sz - PSXEXE_TEXTSECTION_OFFSET;\n\tsect->vaddr = psxheader.t_addr;\n\tsect->vsize = psxheader.t_size;\n\tsect->perm = R_PERM_RX;\n\tsect->add = true;\n\tsect->has_strings = true;\n\n\tr_list_append (ret, sect);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "void rose_start_t1timer(struct sock *sk)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\n\tsk_stop_timer(sk, &rose->timer);\n\n\trose->timer.function = rose_timer_expiry;\n\trose->timer.expires = jiffies + rose->t1;\n\n\tsk_reset_timer(sk, &rose->timer, rose->timer.expires);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)\n{\n\tstruct au1100fb_device *fbdev;\n\tunsigned int len;\n\tunsigned long start=0, off;\n\n\tfbdev = to_au1100fb_device(fbi);\n\n\tif (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {\n\t\treturn -EINVAL;\n\t}\n\n\tstart = fbdev->fb_phys & PAGE_MASK;\n\tlen = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);\n\n\toff = vma->vm_pgoff << PAGE_SHIFT;\n\n\tif ((vma->vm_end - vma->vm_start + off) > len) {\n\t\treturn -EINVAL;\n\t}\n\n\toff += start;\n\tvma->vm_pgoff = off >> PAGE_SHIFT;\n\n\tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n\tpgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6\n\n\tif (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,\n\t\t\t\tvma->vm_end - vma->vm_start,\n\t\t\t\tvma->vm_page_prot)) {\n\t\treturn -EAGAIN;\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "\nint read_escaped_char(\n yyscan_t yyscanner,\n uint8_t* escaped_char)\n{\n char text[4] = {0, 0, 0, 0};\n\n text[0] = '\\\\';\n text[1] = RE_YY_INPUT(yyscanner);\n\n if (text[1] == EOF)\n return 0;\n\n if (text[1] == 'x')\n {\n text[2] = RE_YY_INPUT(yyscanner);\n\n if (text[2] == EOF)\n return 0;\n\n text[3] = RE_YY_INPUT(yyscanner);\n\n if (text[3] == EOF)\n return 0;\n }\n\n *escaped_char = escaped_char_value(text);\n\n return 1;", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "int audio_level_json(struct list *levell,\n\t\t const char *userid_self, const char *clientid_self,\n\t\t char **json_str, char **anon_str)\n{\n\tstruct json_object *jobj;\n\tstruct json_object *jarr;\n\tchar uid_anon[ANON_ID_LEN];\n\tchar cid_anon[ANON_CLIENT_LEN];\n\tstruct mbuf *pmb = NULL;\n\tint err = 0;\n\tstruct le *le;\n\n\tif (!levell || !json_str)\n\t\treturn EINVAL;\n\t\n\tjobj = jzon_alloc_object();\n\tif (!jobj)\n\t\treturn ENOMEM;\n\n\tjarr = jzon_alloc_array();\n\tif (!jarr) {\n\t\terr = ENOMEM;\n\t\tgoto out;\n\t}\n\n\tif (anon_str) {\n\t\tpmb = mbuf_alloc(512);\n\t\tmbuf_printf(pmb, \"%zu levels: \", list_count(levell));\n\t}\n\t\n\tLIST_FOREACH(levell, le) {\n\t\tstruct audio_level *a = le->data;\n\t\tstruct json_object *ja;\n\t\tconst char *userid = a->userid;\n\t\tconst char *clientid = a->clientid;\n\n\t\tif (a->is_self) {\n\t\t\tif (userid_self)\n\t\t\t\tuserid = userid_self;\n\t\t\tif (clientid_self)\n\t\t\t\tclientid = clientid_self;\n\t\t}\n\n\t\tja = jzon_alloc_object();\n\t\tif (ja) {\n\t\t\tjzon_add_str(ja, \"userid\", userid);\n\t\t\tjzon_add_str(ja, \"clientid\", clientid);\n\t\t\tjzon_add_int(ja, \"audio_level\",\n\t\t\t\t (int32_t)a->aulevel_smooth);\n\t\t\tjzon_add_int(ja, \"audio_level_now\",\n\t\t\t\t (int32_t)a->aulevel);\n\t\t}\n\t\tjson_object_array_add(jarr, ja);\n\n\t\t/* add to info string */\n\t\tif (pmb) {\n\t\t\tanon_id(uid_anon, userid);\n\t\t\tanon_client(cid_anon, clientid);\n\t\t\tmbuf_printf(pmb, \"{[%s.%s] audio_level: %d/%d}\",\n\t\t\t\t uid_anon, cid_anon,\n\t\t\t\t a->aulevel_smooth, a->aulevel);\n\t\t\tif (le != levell->tail)\n\t\t\t\tmbuf_printf(pmb, \",\");\n\t\t}\t\t\n\t}\n\tjson_object_object_add(jobj, \"audio_levels\", jarr);\n\n\tif (pmb) {\n\t\tpmb->pos = 0;\n\t\tmbuf_strdup(pmb, anon_str, pmb->end);\n\t\tmem_deref(pmb);\n\t}\n\n\tjzon_encode(json_str, jobj);\n out:\t\n\tmem_deref(jobj);\n\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "vulnerable"} {"code": "static void _perf_event_disable(struct perf_event *event)\n{\n\tstruct perf_event_context *ctx = event->ctx;\n\tstruct task_struct *task = ctx->task;\n\n\tif (!task) {\n\t\t/*\n\t\t * Disable the event on the cpu that it's on\n\t\t */\n\t\tcpu_function_call(event->cpu, __perf_event_disable, event);\n\t\treturn;\n\t}\n\nretry:\n\tif (!task_function_call(task, __perf_event_disable, event))\n\t\treturn;\n\n\traw_spin_lock_irq(&ctx->lock);\n\t/*\n\t * If the event is still active, we need to retry the cross-call.\n\t */\n\tif (event->state == PERF_EVENT_STATE_ACTIVE) {\n\t\traw_spin_unlock_irq(&ctx->lock);\n\t\t/*\n\t\t * Reload the task pointer, it might have been changed by\n\t\t * a concurrent perf_event_context_sched_out().\n\t\t */\n\t\ttask = ctx->task;\n\t\tgoto retry;\n\t}\n\n\t/*\n\t * Since we have the lock this context can't be scheduled\n\t * in, so we can change the state safely.\n\t */\n\tif (event->state == PERF_EVENT_STATE_INACTIVE) {\n\t\tupdate_group_times(event);\n\t\tevent->state = PERF_EVENT_STATE_OFF;\n\t}\n\traw_spin_unlock_irq(&ctx->lock);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateNull(void)\t\t\t\t\t{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p,\n\t\t\t\t\tstruct nfsd3_symlinkargs *args)\n{\n\tunsigned int len, avail;\n\tchar *old, *new;\n\tstruct kvec *vec;\n\n\tif (!(p = decode_fh(p, &args->ffh)) ||\n\t !(p = decode_filename(p, &args->fname, &args->flen))\n\t\t)\n\t\treturn 0;\n\tp = decode_sattr3(p, &args->attrs);\n\n\t/* now decode the pathname, which might be larger than the first page.\n\t * As we have to check for nul's anyway, we copy it into a new page\n\t * This page appears in the rq_res.pages list, but as pages_len is always\n\t * 0, it won't get in the way\n\t */\n\tlen = ntohl(*p++);\n\tif (len == 0 || len > NFS3_MAXPATHLEN || len >= PAGE_SIZE)\n\t\treturn 0;\n\targs->tname = new = page_address(*(rqstp->rq_next_page++));\n\targs->tlen = len;\n\t/* first copy and check from the first page */\n\told = (char*)p;\n\tvec = &rqstp->rq_arg.head[0];\n\tif ((void *)old > vec->iov_base + vec->iov_len)\n\t\treturn 0;\n\tavail = vec->iov_len - (old - (char*)vec->iov_base);\n\twhile (len && avail && *old) {\n\t\t*new++ = *old++;\n\t\tlen--;\n\t\tavail--;\n\t}\n\t/* now copy next page if there is one */\n\tif (len && !avail && rqstp->rq_arg.page_len) {\n\t\tavail = min_t(unsigned int, rqstp->rq_arg.page_len, PAGE_SIZE);\n\t\told = page_address(rqstp->rq_arg.pages[0]);\n\t}\n\twhile (len && avail && *old) {\n\t\t*new++ = *old++;\n\t\tlen--;\n\t\tavail--;\n\t}\n\t*new = '\\0';\n\tif (len)\n\t\treturn 0;\n\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, const nfs4_stateid *deleg_stateid, int open_flags)\n{\n\t/*\n\t * Protect the call to nfs4_state_set_mode_locked and\n\t * serialise the stateid update\n\t */\n\twrite_seqlock(&state->seqlock);\n\tif (deleg_stateid != NULL) {\n\t\tmemcpy(state->stateid.data, deleg_stateid->data, sizeof(state->stateid.data));\n\t\tset_bit(NFS_DELEGATED_STATE, &state->flags);\n\t}\n\tif (open_stateid != NULL)\n\t\tnfs_set_open_stateid_locked(state, open_stateid, open_flags);\n\twrite_sequnlock(&state->seqlock);\n\tspin_lock(&state->owner->so_lock);\n\tupdate_open_stateflags(state, open_flags);\n\tspin_unlock(&state->owner->so_lock);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)\n{\n\tstruct nci_dev *ndev = priv->ndev;\n\n\tif (priv->ndev->nfc_dev->fw_download_in_progress)\n\t\tnfcmrvl_fw_dnld_abort(priv);\n\n\tnfcmrvl_fw_dnld_deinit(priv);\n\n\tif (gpio_is_valid(priv->config.reset_n_io))\n\t\tgpio_free(priv->config.reset_n_io);\n\n\tnci_unregister_device(ndev);\n\tnci_free_device(ndev);\n\tkfree(priv);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_comp rcomp;\n\n\tsnprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"compression\");\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS,\n\t\t sizeof(struct crypto_report_comp), &rcomp))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "u32 cdk_pk_get_keyid(cdk_pubkey_t pk, u32 * keyid)\n{\n\tu32 lowbits = 0;\n\tbyte buf[24];\n\n\tif (pk && (!pk->keyid[0] || !pk->keyid[1])) {\n\t\tif (pk->version < 4 && is_RSA(pk->pubkey_algo)) {\n\t\t\tbyte p[MAX_MPI_BYTES];\n\t\t\tsize_t n;\n\n\t\t\tn = MAX_MPI_BYTES;\n\t\t\t_gnutls_mpi_print(pk->mpi[0], p, &n);\n\t\t\tpk->keyid[0] =\n\t\t\t p[n - 8] << 24 | p[n - 7] << 16 | p[n -\n\t\t\t\t\t\t\t\t6] << 8 |\n\t\t\t p[n - 5];\n\t\t\tpk->keyid[1] =\n\t\t\t p[n - 4] << 24 | p[n - 3] << 16 | p[n -\n\t\t\t\t\t\t\t\t2] << 8 |\n\t\t\t p[n - 1];\n\t\t} else if (pk->version == 4) {\n\t\t\tcdk_pk_get_fingerprint(pk, buf);\n\t\t\tpk->keyid[0] = _cdk_buftou32(buf + 12);\n\t\t\tpk->keyid[1] = _cdk_buftou32(buf + 16);\n\t\t}\n\t}\n\tlowbits = pk ? pk->keyid[1] : 0;\n\tif (keyid && pk) {\n\t\tkeyid[0] = pk->keyid[0];\n\t\tkeyid[1] = pk->keyid[1];\n\t}\n\n\treturn lowbits;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)\n{\n\tconst char *sysinfo_table[] = {\n\t\tutsname()->sysname,\n\t\tutsname()->nodename,\n\t\tutsname()->release,\n\t\tutsname()->version,\n\t\tutsname()->machine,\n\t\t\"alpha\",\t/* instruction set architecture */\n\t\t\"dummy\",\t/* hardware serial number */\n\t\t\"dummy\",\t/* hardware manufacturer */\n\t\t\"dummy\",\t/* secure RPC domain */\n\t};\n\tunsigned long offset;\n\tconst char *res;\n\tlong len, err = -EINVAL;\n\n\toffset = command-1;\n\tif (offset >= ARRAY_SIZE(sysinfo_table)) {\n\t\t/* Digital UNIX has a few unpublished interfaces here */\n\t\tprintk(\"sysinfo(%d)\", command);\n\t\tgoto out;\n\t}\n\n\tdown_read(&uts_sem);\n\tres = sysinfo_table[offset];\n\tlen = strlen(res)+1;\n\tif ((unsigned long)len > (unsigned long)count)\n\t\tlen = count;\n\tif (copy_to_user(buf, res, len))\n\t\terr = -EFAULT;\n\telse\n\t\terr = 0;\n\tup_read(&uts_sem);\n out:\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "horizontalDifference8(unsigned char *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From8)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n#undef\t CLAMP\n#define CLAMP(v) (From8[(v)])\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\tr1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\twp += 3;\n\t\tip += 3;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\tr1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1;\n\t\twp += 4;\n\t\tip += 4;\n\t }\n\t} else {\n\t wp += n + stride - 1;\t/* point to last one */\n\t ip += n + stride - 1;\t/* point to last one */\n\t n -= stride;\n\t while (n > 0) {\n\t\tREPEAT(stride, wp[0] = CLAMP(ip[0]);\n\t\t\t\twp[stride] -= wp[0];\n\t\t\t\twp[stride] &= mask;\n\t\t\t\twp--; ip--)\n\t\tn -= stride;\n\t }\n\t REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--)\n\t}\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static int ext4_split_unwritten_extents(handle_t *handle,\n\t\t\t\t\tstruct inode *inode,\n\t\t\t\t\tstruct ext4_map_blocks *map,\n\t\t\t\t\tstruct ext4_ext_path *path,\n\t\t\t\t\tint flags)\n{\n\text4_lblk_t eof_block;\n\text4_lblk_t ee_block;\n\tstruct ext4_extent *ex;\n\tunsigned int ee_len;\n\tint split_flag = 0, depth;\n\n\text_debug(\"ext4_split_unwritten_extents: inode %lu, logical\"\n\t\t\"block %llu, max_blocks %u\\n\", inode->i_ino,\n\t\t(unsigned long long)map->m_lblk, map->m_len);\n\n\teof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>\n\t\tinode->i_sb->s_blocksize_bits;\n\tif (eof_block < map->m_lblk + map->m_len)\n\t\teof_block = map->m_lblk + map->m_len;\n\t/*\n\t * It is safe to convert extent to initialized via explicit\n\t * zeroout only if extent is fully insde i_size or new_size.\n\t */\n\tdepth = ext_depth(inode);\n\tex = path[depth].p_ext;\n\tee_block = le32_to_cpu(ex->ee_block);\n\tee_len = ext4_ext_get_actual_len(ex);\n\n\tsplit_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0;\n\tsplit_flag |= EXT4_EXT_MARK_UNINIT2;\n\tif (flags & EXT4_GET_BLOCKS_CONVERT)\n\t\tsplit_flag |= EXT4_EXT_DATA_VALID2;\n\tflags |= EXT4_GET_BLOCKS_PRE_IO;\n\treturn ext4_split_extent(handle, inode, path, map, split_flag, flags);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "void sctp_generate_proto_unreach_event(unsigned long data)\n{\n\tstruct sctp_transport *transport = (struct sctp_transport *) data;\n\tstruct sctp_association *asoc = transport->asoc;\n\tstruct net *net = sock_net(asoc->base.sk);\n\n\tbh_lock_sock(asoc->base.sk);\n\tif (sock_owned_by_user(asoc->base.sk)) {\n\t\tpr_debug(\"%s: sock is busy\\n\", __func__);\n\n\t\t/* Try again later. */\n\t\tif (!mod_timer(&transport->proto_unreach_timer,\n\t\t\t\tjiffies + (HZ/20)))\n\t\t\tsctp_association_hold(asoc);\n\t\tgoto out_unlock;\n\t}\n\n\t/* Is this structure just waiting around for us to actually\n\t * get destroyed?\n\t */\n\tif (asoc->base.dead)\n\t\tgoto out_unlock;\n\n\tsctp_do_sm(net, SCTP_EVENT_T_OTHER,\n\t\t SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),\n\t\t asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);\n\nout_unlock:\n\tbh_unlock_sock(asoc->base.sk);\n\tsctp_association_put(asoc);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "set_lenIV(const char* line)\n{\n char *p = strstr(line, \"/lenIV \");\n\n /* Allow lenIV to be negative. Thanks to Tom Kacvinsky */\n if (p && (isdigit((unsigned char) p[7]) || p[7] == '+' || p[7] == '-')) {\n lenIV = atoi(p + 7);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int hash_recvmsg(struct kiocb *unused, struct socket *sock,\n\t\t\tstruct msghdr *msg, size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct hash_ctx *ctx = ask->private;\n\tunsigned ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));\n\tint err;\n\n\tif (len > ds)\n\t\tlen = ds;\n\telse if (len < ds)\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\n\tmsg->msg_namelen = 0;\n\n\tlock_sock(sk);\n\tif (ctx->more) {\n\t\tctx->more = 0;\n\t\tahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0);\n\t\terr = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req),\n\t\t\t\t\t\t &ctx->completion);\n\t\tif (err)\n\t\t\tgoto unlock;\n\t}\n\n\terr = memcpy_toiovec(msg->msg_iov, ctx->result, len);\n\nunlock:\n\trelease_sock(sk);\n\n\treturn err ?: len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "ast_for_atom_expr(struct compiling *c, const node *n)\n{\n int i, nch, start = 0;\n expr_ty e, tmp;\n\n REQ(n, atom_expr);\n nch = NCH(n);\n\n if (TYPE(CHILD(n, 0)) == AWAIT) {\n if (c->c_feature_version < 5) {\n ast_error(c, n,\n \"Await expressions are only supported in Python 3.5 and greater\");\n return NULL;\n }\n start = 1;\n assert(nch > 1);\n }\n\n e = ast_for_atom(c, CHILD(n, start));\n if (!e)\n return NULL;\n if (nch == 1)\n return e;\n if (start && nch == 2) {\n return Await(e, LINENO(n), n->n_col_offset, c->c_arena);\n }\n\n for (i = start + 1; i < nch; i++) {\n node *ch = CHILD(n, i);\n if (TYPE(ch) != trailer)\n break;\n tmp = ast_for_trailer(c, ch, e);\n if (!tmp)\n return NULL;\n tmp->lineno = e->lineno;\n tmp->col_offset = e->col_offset;\n e = tmp;\n }\n\n if (start) {\n /* there was an AWAIT */\n return Await(e, LINENO(n), n->n_col_offset, c->c_arena);\n }\n else {\n return e;\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "void show_object_with_name(FILE *out, struct object *obj, const char *name)\n{\n\tconst char *p;\n\n\tfprintf(out, \"%s \", oid_to_hex(&obj->oid));\n\tfor (p = name; *p && *p != '\\n'; p++)\n\t\tfputc(*p, out);\n\tfputc('\\n', out);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static inline void blk_mq_tag_set_rq(struct blk_mq_hw_ctx *hctx,\n\t\tunsigned int tag, struct request *rq)\n{\n\thctx->tags->rqs[tag] = rq;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static void __exit pcd_exit(void)\n{\n\tstruct pcd_unit *cd;\n\tint unit;\n\n\tfor (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {\n\t\tif (!cd->disk)\n\t\t\tcontinue;\n\n\t\tif (cd->present) {\n\t\t\tdel_gendisk(cd->disk);\n\t\t\tpi_release(cd->pi);\n\t\t\tunregister_cdrom(&cd->info);\n\t\t}\n\t\tblk_cleanup_queue(cd->disk->queue);\n\t\tblk_mq_free_tag_set(&cd->tag_set);\n\t\tput_disk(cd->disk);\n\t}\n\tunregister_blkdev(major, name);\n\tpi_unregister_driver(par_drv);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static void cjson_get_object_item_case_sensitive_should_not_crash_with_array(void) {\n cJSON *array = NULL;\n cJSON *found = NULL;\n array = cJSON_Parse(\"[1]\");\n\n found = cJSON_GetObjectItemCaseSensitive(array, \"name\");\n TEST_ASSERT_NULL(found);\n\n cJSON_Delete(array);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-754", "cwe_name": "Improper Check for Unusual or Exceptional Conditions", "description": "The software does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the software.", "url": "https://cwe.mitre.org/data/definitions/754.html", "label_name": "safe"} {"code": "obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n expr_ty context_expr;\n expr_ty optional_vars;\n\n if (_PyObject_HasAttrId(obj, &PyId_context_expr)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);\n if (tmp == NULL) goto failed;\n res = obj2ast_expr(tmp, &context_expr, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"context_expr\\\" missing from withitem\");\n return 1;\n }\n if (exists_not_none(obj, &PyId_optional_vars)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars);\n if (tmp == NULL) goto failed;\n res = obj2ast_expr(tmp, &optional_vars, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n optional_vars = NULL;\n }\n *out = withitem(context_expr, optional_vars, arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,\n\t\tsize_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct atm_vcc *vcc;\n\tstruct sk_buff *skb;\n\tint copied, error = -EINVAL;\n\n\tmsg->msg_namelen = 0;\n\n\tif (sock->state != SS_CONNECTED)\n\t\treturn -ENOTCONN;\n\n\t/* only handle MSG_DONTWAIT and MSG_PEEK */\n\tif (flags & ~(MSG_DONTWAIT | MSG_PEEK))\n\t\treturn -EOPNOTSUPP;\n\n\tvcc = ATM_SD(sock);\n\tif (test_bit(ATM_VF_RELEASED, &vcc->flags) ||\n\t test_bit(ATM_VF_CLOSE, &vcc->flags) ||\n\t !test_bit(ATM_VF_READY, &vcc->flags))\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &error);\n\tif (!skb)\n\t\treturn error;\n\n\tcopied = skb->len;\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\terror = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (error)\n\t\treturn error;\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\tif (!(flags & MSG_PEEK)) {\n\t\tpr_debug(\"%d -= %d\\n\", atomic_read(&sk->sk_rmem_alloc),\n\t\t\t skb->truesize);\n\t\tatm_return(vcc, skb->truesize);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\treturn copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "batchCopyElem(batch_obj_t *pDest, batch_obj_t *pSrc) {\n\tmemcpy(pDest, pSrc, sizeof(batch_obj_t));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-772", "cwe_name": "Missing Release of Resource after Effective Lifetime", "description": "The software does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.", "url": "https://cwe.mitre.org/data/definitions/772.html", "label_name": "vulnerable"} {"code": "static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t char *const argv[])\n{\n\tuint\tchip;\n\tulong\taddr;\n\tint\talen;\n\tint\tcount;\n\tuchar\tbyte;\n\tulong\tcrc;\n\tulong\terr;\n\tint ret = 0;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n#endif\n\n\tif (argc < 4)\n\t\treturn CMD_RET_USAGE;\n\n\t/*\n\t * Chip is always specified.\n\t */\n\tchip = hextoul(argv[1], NULL);\n\n\t/*\n\t * Address is always specified.\n\t */\n\taddr = hextoul(argv[2], NULL);\n\talen = get_alen(argv[2], DEFAULT_ADDR_LEN);\n\tif (alen > 3)\n\t\treturn CMD_RET_USAGE;\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n#endif\n\t/*\n\t * Count is always specified\n\t */\n\tcount = hextoul(argv[3], NULL);\n\n\tprintf (\"CRC32 for %08lx ... %08lx ==> \", addr, addr + count - 1);\n\t/*\n\t * CRC a byte at a time. This is going to be slooow, but hey, the\n\t * memories are small and slow too so hopefully nobody notices.\n\t */\n\tcrc = 0;\n\terr = 0;\n\twhile (count-- > 0) {\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = dm_i2c_read(dev, addr, &byte, 1);\n#else\n\t\tret = i2c_read(chip, addr, alen, &byte, 1);\n#endif\n\t\tif (ret)\n\t\t\terr++;\n\t\tcrc = crc32(crc, &byte, 1);\n\t\taddr++;\n\t}\n\tif (err > 0)\n\t\ti2c_report_err(ret, I2C_ERR_READ);\n\telse\n\t\tprintf (\"%08lx\\n\", crc);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " */\nstatic void re_yyensure_buffer_stack (yyscan_t yyscanner)\n{\n\tyy_size_t num_to_alloc;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif (!yyg->yy_buffer_stack) {\n\n\t\t/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate realloc on the next call.\n */\n\t\tnum_to_alloc = 1; // After all that talk, this was set to 1 anyways...\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyalloc\n\t\t\t\t\t\t\t\t(num_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\n\t\tmemset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));\n\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t\tyyg->yy_buffer_stack_top = 0;\n\t\treturn;\n\t}\n\n\tif (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){\n\n\t\t/* Increase the buffer to prepare for a possible push. */\n\t\tyy_size_t grow_size = 8 /* arbitrary grow size */;\n\n\t\tnum_to_alloc = yyg->yy_buffer_stack_max + grow_size;\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyrealloc\n\t\t\t\t\t\t\t\t(yyg->yy_buffer_stack,\n\t\t\t\t\t\t\t\tnum_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\n\t\t/* zero only the new slots.*/\n\t\tmemset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)\n\n{\n\tunsigned int len;\n\tunsigned long start=0, off;\n\tstruct au1200fb_device *fbdev = info->par;\n\n\tif (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {\n\t\treturn -EINVAL;\n\t}\n\n\tstart = fbdev->fb_phys & PAGE_MASK;\n\tlen = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);\n\n\toff = vma->vm_pgoff << PAGE_SHIFT;\n\n\tif ((vma->vm_end - vma->vm_start + off) > len) {\n\t\treturn -EINVAL;\n\t}\n\n\toff += start;\n\tvma->vm_pgoff = off >> PAGE_SHIFT;\n\n\tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n\tpgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */\n\n\treturn io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,\n\t\t\t\t vma->vm_end - vma->vm_start,\n\t\t\t\t vma->vm_page_prot);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "xfs_file_splice_write(\n\tstruct pipe_inode_info\t*pipe,\n\tstruct file\t\t*outfilp,\n\tloff_t\t\t\t*ppos,\n\tsize_t\t\t\tcount,\n\tunsigned int\t\tflags)\n{\n\tstruct inode\t\t*inode = outfilp->f_mapping->host;\n\tstruct xfs_inode\t*ip = XFS_I(inode);\n\tint\t\t\tioflags = 0;\n\tssize_t\t\t\tret;\n\n\tXFS_STATS_INC(xs_write_calls);\n\n\tif (outfilp->f_mode & FMODE_NOCMTIME)\n\t\tioflags |= IO_INVIS;\n\n\tif (XFS_FORCED_SHUTDOWN(ip->i_mount))\n\t\treturn -EIO;\n\n\txfs_ilock(ip, XFS_IOLOCK_EXCL);\n\n\ttrace_xfs_file_splice_write(ip, count, *ppos, ioflags);\n\n\tret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);\n\tif (ret > 0)\n\t\tXFS_STATS_ADD(xs_write_bytes, ret);\n\n\txfs_iunlock(ip, XFS_IOLOCK_EXCL);\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "horizontalDifference8(unsigned char *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From8)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n#undef\t CLAMP\n#define CLAMP(v) (From8[(v)])\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\tr1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\twp += 3;\n\t\tip += 3;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\tr1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1;\n\t\twp += 4;\n\t\tip += 4;\n\t }\n\t} else {\n REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)\n n -= stride;\n while (n > 0) {\n REPEAT(stride,\n wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);\n wp++; ip++)\n n -= stride;\n }\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static char *print_string_ptr(const char *str,printbuffer *p)\n{\n\tconst char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;\n\n\tif (!str)\n\t{\n\t\tif (p)\tout=ensure(p,3);\n\t\telse\tout=(char*)cJSON_malloc(3);\n\t\tif (!out) return 0;\n\t\tstrcpy(out,\"\\\"\\\"\");\n\t\treturn out;\n\t}\n\t\n\tfor (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\\\"')||(*ptr=='\\\\'))?1:0;\n\tif (!flag)\n\t{\n\t\tlen=ptr-str;\n\t\tif (p) out=ensure(p,len+3);\n\t\telse\t\tout=(char*)cJSON_malloc(len+3);\n\t\tif (!out) return 0;\n\t\tptr2=out;*ptr2++='\\\"';\n\t\tstrcpy(ptr2,str);\n\t\tptr2[len]='\\\"';\n\t\tptr2[len+1]=0;\n\t\treturn out;\n\t}\n\t\n\tptr=str;while ((token=*ptr) && ++len) {if (strchr(\"\\\"\\\\\\b\\f\\n\\r\\t\",token)) len++; else if (token<32) len+=5;ptr++;}\n\t\n\tif (p)\tout=ensure(p,len+3);\n\telse\tout=(char*)cJSON_malloc(len+3);\n\tif (!out) return 0;\n\n\tptr2=out;ptr=str;\n\t*ptr2++='\\\"';\n\twhile (*ptr)\n\t{\n\t\tif ((unsigned char)*ptr>31 && *ptr!='\\\"' && *ptr!='\\\\') *ptr2++=*ptr++;\n\t\telse\n\t\t{\n\t\t\t*ptr2++='\\\\';\n\t\t\tswitch (token=*ptr++)\n\t\t\t{\n\t\t\t\tcase '\\\\':\t*ptr2++='\\\\';\tbreak;\n\t\t\t\tcase '\\\"':\t*ptr2++='\\\"';\tbreak;\n\t\t\t\tcase '\\b':\t*ptr2++='b';\tbreak;\n\t\t\t\tcase '\\f':\t*ptr2++='f';\tbreak;\n\t\t\t\tcase '\\n':\t*ptr2++='n';\tbreak;\n\t\t\t\tcase '\\r':\t*ptr2++='r';\tbreak;\n\t\t\t\tcase '\\t':\t*ptr2++='t';\tbreak;\n\t\t\t\tdefault: sprintf(ptr2,\"u%04x\",token);ptr2+=5;\tbreak;\t/* escape and print */\n\t\t\t}\n\t\t}\n\t}\n\t*ptr2++='\\\"';*ptr2++=0;\n\treturn out;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "int ecall_answer(struct ecall *ecall, enum icall_call_type call_type,\n\t\t bool audio_cbr)\n{\n\tint err = 0;\n\n\tif (!ecall)\n\t\treturn EINVAL;\n\n#ifdef ECALL_CBR_ALWAYS_ON\n\taudio_cbr = true;\n#endif\n\t\n\n\tinfo(\"ecall(%p): answer on pending econn %p call_type=%d\\n\", ecall, ecall->econn, call_type);\n\n\tif (!ecall->econn) {\n\t\twarning(\"ecall: answer: econn does not exist!\\n\");\n\t\treturn ENOENT;\n\t}\n\n\tif (ECONN_PENDING_INCOMING != econn_current_state(ecall->econn)) {\n\t\tinfo(\"ecall(%p): answer: invalid state (%s)\\n\", ecall,\n\t\t econn_state_name(econn_current_state(ecall->econn)));\n\t\treturn EPROTO;\n\t}\n\n\tif (!ecall->flow) {\n\t\twarning(\"ecall: answer: no mediaflow\\n\");\n\t\treturn EPROTO;\n\t}\n\n\tecall->call_type = call_type;\n\tIFLOW_CALL(ecall->flow, set_call_type, call_type);\n\n\tecall->audio_cbr = audio_cbr;\n\tIFLOW_CALL(ecall->flow, set_audio_cbr, audio_cbr);\n\n#if 0\n\tif (ecall->props_local) {\n\t\tconst char *vstate_string =\n\t\t\tcall_type == ICALL_CALL_TYPE_VIDEO ? \"true\" : \"false\";\n\t\tint err2 = econn_props_update(ecall->props_local, \"videosend\", vstate_string);\n\t\tif (err2) {\n\t\t\twarning(\"ecall(%p): econn_props_update(videosend)\",\n\t\t\t\t\" failed (%m)\\n\", ecall, err2);\n\t\t\t/* Non fatal, carry on */\n\t\t}\n\t}\n#endif\n\n\terr = generate_or_gather_answer(ecall, ecall->econn);\n\tif (err) {\n\t\twarning(\"ecall: answer: failed to gather_or_answer\\n\");\n\t\tgoto out;\n\t}\n\n\tecall->answered = true;\n\tecall->audio_setup_time = -1;\n\tecall->call_estab_time = -1;\n\tecall->ts_answered = tmr_jiffies();\n\n out:\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "vulnerable"} {"code": "DefragIPv4TooLargeTest(void)\n{\n DefragContext *dc = NULL;\n Packet *p = NULL;\n int ret = 0;\n\n DefragInit();\n\n dc = DefragContextNew();\n if (dc == NULL)\n goto end;\n\n /* Create a fragment that would extend past the max allowable size\n * for an IPv4 packet. */\n p = BuildTestPacket(1, 8183, 0, 'A', 71);\n if (p == NULL)\n goto end;\n\n /* We do not expect a packet returned. */\n if (Defrag(NULL, NULL, p, NULL) != NULL)\n goto end;\n if (!ENGINE_ISSET_EVENT(p, IPV4_FRAG_PKT_TOO_LARGE))\n goto end;\n\n /* The fragment should have been ignored so no fragments should have\n * been allocated from the pool. */\n if (dc->frag_pool->outstanding != 0)\n return 0;\n\n ret = 1;\nend:\n if (dc != NULL)\n DefragContextDestroy(dc);\n if (p != NULL)\n SCFree(p);\n\n DefragDestroy();\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "vulnerable"} {"code": "nautilus_file_mark_desktop_file_executable (GFile *file,\n GtkWindow *parent_window,\n gboolean interactive,\n NautilusOpCallback done_callback,\n gpointer done_callback_data)\n{\n GTask *task;\n MarkTrustedJob *job;\n\n job = op_job_new (MarkTrustedJob, parent_window);\n job->file = g_object_ref (file);\n job->interactive = interactive;\n job->done_callback = done_callback;\n job->done_callback_data = done_callback_data;\n\n task = g_task_new (NULL, NULL, mark_desktop_file_executable_task_done, job);\n g_task_set_task_data (task, job, NULL);\n g_task_run_in_thread (task, mark_desktop_file_executable_task_thread_func);\n g_object_unref (task);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)\n{\n /* MPEG-4 Studio Profile only, not supported by hardware */\n if (avctx->bits_per_raw_sample > 8) {\n av_assert1(avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO);\n return avctx->pix_fmt;\n }\n\n if (avctx->codec->id == AV_CODEC_ID_MSS2)\n return AV_PIX_FMT_YUV420P;\n\n if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) {\n if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)\n avctx->color_range = AVCOL_RANGE_MPEG;\n return AV_PIX_FMT_GRAY8;\n }\n\n return avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "static void sycc422_to_rgb(opj_image_t *img)\n{\t\n\tint *d0, *d1, *d2, *r, *g, *b;\n\tconst int *y, *cb, *cr;\n\tsize_t maxw, maxh, max, offx, loopmaxw;\n\tint offset, upb;\n\tsize_t i;\n\n\tupb = (int)img->comps[0].prec;\n\toffset = 1<<(upb - 1); upb = (1<comps[0].w; maxh = (size_t)img->comps[0].h;\n\tmax = maxw * maxh;\n\n\ty = img->comps[0].data;\n\tcb = img->comps[1].data;\n\tcr = img->comps[2].data;\n\n\td0 = r = (int*)malloc(sizeof(int) * max);\n\td1 = g = (int*)malloc(sizeof(int) * max);\n\td2 = b = (int*)malloc(sizeof(int) * max);\n\n\tif(r == NULL || g == NULL || b == NULL) goto fails;\n\n\t/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */\n\toffx = img->x0 & 1U;\n\tloopmaxw = maxw - offx;\n\t\n\tfor(i=0U; i < maxh; ++i)\n\t{\n\t\tsize_t j;\n\t\t\n\t\tif (offx > 0U) {\n\t\t\tsycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);\n\t\t\t++y; ++r; ++g; ++b;\n\t\t}\n\t\t\n\t\tfor(j=0U; j < (loopmaxw & ~(size_t)1U); j += 2U)\n\t\t{\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b;\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b; ++cb; ++cr;\n\t\t}\n\t\tif (j < loopmaxw) {\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b; ++cb; ++cr;\n\t\t}\n\t}\n\t\n\tfree(img->comps[0].data); img->comps[0].data = d0;\n\tfree(img->comps[1].data); img->comps[1].data = d1;\n\tfree(img->comps[2].data); img->comps[2].data = d2;\n\n\timg->comps[1].w = img->comps[2].w = img->comps[0].w;\n\timg->comps[1].h = img->comps[2].h = img->comps[0].h;\n\timg->comps[1].dx = img->comps[2].dx = img->comps[0].dx;\n\timg->comps[1].dy = img->comps[2].dy = img->comps[0].dy;\n\timg->color_space = OPJ_CLRSPC_SRGB;\n\treturn;\n\nfails:\n\tfree(r);\n\tfree(g);\n\tfree(b);\n}/* sycc422_to_rgb() */", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static int read_public_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I1012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read public key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_public_key(p, keysize, rsa);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int jpc_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_ppm_t *ppm = &ms->parms.ppm;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tppm->data = 0;\n\n\tif (ms->len < 1) {\n\t\tgoto error;\n\t}\n\tif (jpc_getuint8(in, &ppm->ind)) {\n\t\tgoto error;\n\t}\n\n\tppm->len = ms->len - 1;\n\tif (ppm->len > 0) {\n\t\tif (!(ppm->data = jas_malloc(ppm->len))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (JAS_CAST(jas_uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {\n\t\t\tgoto error;\n\t\t}\n\t} else {\n\t\tppm->data = 0;\n\t}\n\treturn 0;\n\nerror:\n\tjpc_ppm_destroyparms(ms);\n\treturn -1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "mcs_recv_connect_response(STREAM mcs_data)\n{\n\tUNUSED(mcs_data);\n\tuint8 result;\n\tint length;\n\tSTREAM s;\n\tRD_BOOL is_fastpath;\n\tuint8 fastpath_hdr;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\ts = iso_recv(&is_fastpath, &fastpath_hdr);\n\n\tif (s == NULL)\n\t\treturn False;\n\n\tber_parse_header(s, MCS_CONNECT_RESPONSE, &length);\n\n\tber_parse_header(s, BER_TAG_RESULT, &length);\n\tin_uint8(s, result);\n\tif (result != 0)\n\t{\n\t\tlogger(Protocol, Error, \"mcs_recv_connect_response(), result=%d\", result);\n\t\treturn False;\n\t}\n\n\tber_parse_header(s, BER_TAG_INTEGER, &length);\n\tin_uint8s(s, length);\t/* connect id */\n\tmcs_parse_domain_params(s);\n\n\tber_parse_header(s, BER_TAG_OCTET_STRING, &length);\n\n\tsec_process_mcs_data(s);\n\t/*\n\t if (length > mcs_data->size)\n\t {\n\t logger(Protocol, Error, \"mcs_recv_connect_response(), expected length=%d, got %d\",length, mcs_data->size);\n\t length = mcs_data->size;\n\t }\n\n\t in_uint8a(s, mcs_data->data, length);\n\t mcs_data->p = mcs_data->data;\n\t mcs_data->end = mcs_data->data + length;\n\t */\n\treturn s_check_end(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "horizontalDifference8(unsigned char *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From8)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n#undef\t CLAMP\n#define CLAMP(v) (From8[(v)])\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\tr1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\twp += 3;\n\t\tip += 3;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\tr1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1;\n\t\twp += 4;\n\t\tip += 4;\n\t }\n\t} else {\n REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)\n n -= stride;\n while (n > 0) {\n REPEAT(stride,\n wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);\n wp++; ip++)\n n -= stride;\n }\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "cib_recv_tls(gnutls_session * session)\n{\n char *buf = NULL;\n\n int rc = 0;\n int len = 0;\n int chunk_size = 1024;\n\n if (session == NULL) {\n return NULL;\n }\n\n buf = calloc(1, chunk_size);\n\n while (TRUE) {\n errno = 0;\n rc = gnutls_record_recv(*session, buf + len, chunk_size);\n crm_trace(\"Got %d more bytes. errno=%d\", rc, errno);\n\n if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {\n crm_trace(\"Retry\");\n\n } else if (rc == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) {\n crm_trace(\"Session disconnected\");\n goto bail;\n\n } else if (rc < 0) {\n crm_err(\"Error receiving message: %s (%d)\", gnutls_strerror(rc), rc);\n goto bail;\n\n } else if (rc == chunk_size) {\n len += rc;\n chunk_size *= 2;\n buf = realloc(buf, len + chunk_size);\n crm_trace(\"Retry with %d more bytes\", (int)chunk_size);\n CRM_ASSERT(buf != NULL);\n\n } else if (buf[len + rc - 1] != 0) {\n crm_trace(\"Last char is %d '%c'\", buf[len + rc - 1], buf[len + rc - 1]);\n crm_trace(\"Retry with %d more bytes\", (int)chunk_size);\n len += rc;\n buf = realloc(buf, len + chunk_size);\n CRM_ASSERT(buf != NULL);\n\n } else {\n crm_trace(\"Got %d more bytes\", (int)rc);\n return buf;\n }\n }\n bail:\n free(buf);\n return NULL;\n\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,\n\t\t\t __be32 saddr, __be32 daddr, struct ip_options_rcu *opt)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct rtable *rt = skb_rtable(skb);\n\tstruct iphdr *iph;\n\n\t/* Build the IP header. */\n\tskb_push(skb, sizeof(struct iphdr) + (opt ? opt->opt.optlen : 0));\n\tskb_reset_network_header(skb);\n\tiph = ip_hdr(skb);\n\tiph->version = 4;\n\tiph->ihl = 5;\n\tiph->tos = inet->tos;\n\tif (ip_dont_fragment(sk, &rt->dst))\n\t\tiph->frag_off = htons(IP_DF);\n\telse\n\t\tiph->frag_off = 0;\n\tiph->ttl = ip_select_ttl(inet, &rt->dst);\n\tiph->daddr = rt->rt_dst;\n\tiph->saddr = rt->rt_src;\n\tiph->protocol = sk->sk_protocol;\n\tip_select_ident(iph, &rt->dst, sk);\n\n\tif (opt && opt->opt.optlen) {\n\t\tiph->ihl += opt->opt.optlen>>2;\n\t\tip_options_build(skb, &opt->opt, daddr, rt, 0);\n\t}\n\n\tskb->priority = sk->sk_priority;\n\tskb->mark = sk->sk_mark;\n\n\t/* Send it out. */\n\treturn ip_local_out(skb);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "IPV6DefragReverseSimpleTest(void)\n{\n DefragContext *dc = NULL;\n Packet *p1 = NULL, *p2 = NULL, *p3 = NULL;\n Packet *reassembled = NULL;\n int id = 12;\n int i;\n int ret = 0;\n\n DefragInit();\n\n dc = DefragContextNew();\n if (dc == NULL)\n goto end;\n\n p1 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 8);\n if (p1 == NULL)\n goto end;\n p2 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 1, 1, 'B', 8);\n if (p2 == NULL)\n goto end;\n p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3);\n if (p3 == NULL)\n goto end;\n\n if (Defrag(NULL, NULL, p3, NULL) != NULL)\n goto end;\n if (Defrag(NULL, NULL, p2, NULL) != NULL)\n goto end;\n reassembled = Defrag(NULL, NULL, p1, NULL);\n if (reassembled == NULL)\n goto end;\n\n /* 40 bytes in we should find 8 bytes of A. */\n for (i = 40; i < 40 + 8; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'A')\n goto end;\n }\n\n /* 28 bytes in we should find 8 bytes of B. */\n for (i = 48; i < 48 + 8; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'B')\n goto end;\n }\n\n /* And 36 bytes in we should find 3 bytes of C. */\n for (i = 56; i < 56 + 3; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'C')\n goto end;\n }\n\n ret = 1;\nend:\n if (dc != NULL)\n DefragContextDestroy(dc);\n if (p1 != NULL)\n SCFree(p1);\n if (p2 != NULL)\n SCFree(p2);\n if (p3 != NULL)\n SCFree(p3);\n if (reassembled != NULL)\n SCFree(reassembled);\n\n DefragDestroy();\n return ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "safe"} {"code": "decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len)\n{\n\tsize_t cipher_len;\n\tsize_t i;\n\tunsigned char iv[16] = { 0 };\n\tunsigned char plaintext[4096] = { 0 };\n\tepass2003_exdata *exdata = NULL;\n\n\tif (!card->drv_data) \n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\texdata = (epass2003_exdata *)card->drv_data;\n\n\t/* no cipher */\n\tif (in[0] == 0x99)\n\t\treturn 0;\n\n\t/* parse cipher length */\n\tif (0x01 == in[2] && 0x82 != in[1]) {\n\t\tcipher_len = in[1];\n\t\ti = 3;\n\t}\n\telse if (0x01 == in[3] && 0x81 == in[1]) {\n\t\tcipher_len = in[2];\n\t\ti = 4;\n\t}\n\telse if (0x01 == in[4] && 0x82 == in[1]) {\n\t\tcipher_len = in[2] * 0x100;\n\t\tcipher_len += in[3];\n\t\ti = 5;\n\t}\n\telse {\n\t\treturn -1;\n\t}\n\n\tif (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext)\n\t\treturn -1;\n\n\t/* decrypt */\n\tif (KEY_TYPE_AES == exdata->smtype)\n\t\taes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\telse\n\t\tdes3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\n\t/* unpadding */\n\twhile (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0))\n\t\tcipher_len--;\n\n\tif (2 == cipher_len || *out_len < cipher_len - 2)\n\t\treturn -1;\n\n\tmemcpy(out, plaintext, cipher_len - 2);\n\t*out_len = cipher_len - 2;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "archive_wstring_append_from_mbs(struct archive_wstring *dest,\n const char *p, size_t len)\n{\n\tsize_t r;\n\tint ret_val = 0;\n\t/*\n\t * No single byte will be more than one wide character,\n\t * so this length estimate will always be big enough.\n\t */\n\tsize_t wcs_length = len;\n\tsize_t mbs_length = len;\n\tconst char *mbs = p;\n\twchar_t *wcs;\n#if HAVE_MBRTOWC\n\tmbstate_t shift_state;\n\n\tmemset(&shift_state, 0, sizeof(shift_state));\n#endif\n\tif (NULL == archive_wstring_ensure(dest, dest->length + wcs_length + 1))\n\t\treturn (-1);\n\twcs = dest->s + dest->length;\n\t/*\n\t * We cannot use mbsrtowcs/mbstowcs here because those may convert\n\t * extra MBS when strlen(p) > len and one wide character consists of\n\t * multi bytes.\n\t */\n\twhile (*mbs && mbs_length > 0) {\n\t\tif (wcs_length == 0) {\n\t\t\tdest->length = wcs - dest->s;\n\t\t\tdest->s[dest->length] = L'\\0';\n\t\t\twcs_length = mbs_length;\n\t\t\tif (NULL == archive_wstring_ensure(dest,\n\t\t\t dest->length + wcs_length + 1))\n\t\t\t\treturn (-1);\n\t\t\twcs = dest->s + dest->length;\n\t\t}\n#if HAVE_MBRTOWC\n\t\tr = mbrtowc(wcs, mbs, wcs_length, &shift_state);\n#else\n\t\tr = mbtowc(wcs, mbs, wcs_length);\n#endif\n\t\tif (r == (size_t)-1 || r == (size_t)-2) {\n\t\t\tret_val = -1;\n\t\t\tif (errno == EILSEQ) {\n\t\t\t\t++mbs;\n\t\t\t\t--mbs_length;\n\t\t\t\tcontinue;\n\t\t\t} else\n\t\t\t\tbreak;\n\t\t}\n\t\tif (r == 0 || r > mbs_length)\n\t\t\tbreak;\n\t\twcs++;\n\t\twcs_length--;\n\t\tmbs += r;\n\t\tmbs_length -= r;\n\t}\n\tdest->length = wcs - dest->s;\n\tdest->s[dest->length] = L'\\0';\n\treturn (ret_val);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int sd_isoc_init(struct gspca_dev *gspca_dev)\n{\n\tstruct usb_interface_cache *intfc;\n\tstruct usb_host_interface *alt;\n\tint max_packet_size;\n\n\tswitch (gspca_dev->pixfmt.width) {\n\tcase 160:\n\t\tmax_packet_size = 450;\n\t\tbreak;\n\tcase 176:\n\t\tmax_packet_size = 600;\n\t\tbreak;\n\tdefault:\n\t\tmax_packet_size = 1022;\n\t\tbreak;\n\t}\n\n\tintfc = gspca_dev->dev->actconfig->intf_cache[0];\n\n\tif (intfc->num_altsetting < 2)\n\t\treturn -ENODEV;\n\n\talt = &intfc->altsetting[1];\n\n\tif (alt->desc.bNumEndpoints < 1)\n\t\treturn -ENODEV;\n\n\t/* Start isoc bandwidth \"negotiation\" at max isoc bandwidth */\n\talt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(max_packet_size);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int masq_inet_event(struct notifier_block *this,\n\t\t\t unsigned long event,\n\t\t\t void *ptr)\n{\n\tstruct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;\n\tstruct netdev_notifier_info info;\n\n\tnetdev_notifier_info_init(&info, dev);\n\treturn masq_device_event(this, event, &info);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "static int cg_open(const char *path, struct fuse_file_info *fi)\n{\n\tconst char *cgroup;\n\tchar *fpath = NULL, *path1, *path2, * cgdir = NULL, *controller;\n\tstruct cgfs_files *k = NULL;\n\tstruct file_info *file_info;\n\tstruct fuse_context *fc = fuse_get_context();\n\tint ret;\n\n\tif (!fc)\n\t\treturn -EIO;\n\n\tcontroller = pick_controller_from_path(fc, path);\n\tif (!controller)\n\t\treturn -EIO;\n\tcgroup = find_cgroup_in_path(path);\n\tif (!cgroup)\n\t\treturn -EINVAL;\n\n\tget_cgdir_and_path(cgroup, &cgdir, &fpath);\n\tif (!fpath) {\n\t\tpath1 = \"/\";\n\t\tpath2 = cgdir;\n\t} else {\n\t\tpath1 = cgdir;\n\t\tpath2 = fpath;\n\t}\n\n\tk = cgfs_get_key(controller, path1, path2);\n\tif (!k) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\tfree_key(k);\n\n\tif (!caller_may_see_dir(fc->pid, controller, path1)) {\n\t\tret = -ENOENT;\n\t\tgoto out;\n\t}\n\tif (!fc_may_access(fc, controller, path1, path2, fi->flags)) {\n\t\t// should never get here\n\t\tret = -EACCES;\n\t\tgoto out;\n\t}\n\n\t/* we'll free this at cg_release */\n\tfile_info = malloc(sizeof(*file_info));\n\tif (!file_info) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tfile_info->controller = must_copy_string(controller);\n\tfile_info->cgroup = must_copy_string(path1);\n\tfile_info->file = must_copy_string(path2);\n\tfile_info->type = LXC_TYPE_CGFILE;\n\tfile_info->buf = NULL;\n\tfile_info->buflen = 0;\n\n\tfi->fh = (unsigned long)file_info;\n\tret = 0;\n\nout:\n\tfree(cgdir);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,\n\t\t\t\t const struct sk_buff *skb,\n\t\t\t\t int flags, pol_lookup_t lookup)\n{\n\tstruct rt6_info *rt;\n\n\trt = lookup(net, net->ipv6.fib6_main_tbl, fl6, skb, flags);\n\tif (rt->dst.error == -EAGAIN) {\n\t\tip6_rt_put_flags(rt, flags);\n\t\trt = net->ipv6.ip6_null_entry;\n\t\tif (!(flags | RT6_LOOKUP_F_DST_NOREF))\n\t\t\tdst_hold(&rt->dst);\n\t}\n\n\treturn &rt->dst;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\tsize_t copied;\n\tstruct sk_buff *skb;\n\tint er;\n\n\t/*\n\t * This works for seqpacket too. The receiver has ordered the queue for\n\t * us! We do one quick check first though\n\t */\n\n\tlock_sock(sk);\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\trelease_sock(sk);\n\t\treturn -ENOTCONN;\n\t}\n\n\t/* Now we can treat all alike */\n\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (er < 0) {\n\t\tskb_free_datagram(sk, skb);\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tif (sax != NULL) {\n\t\tmemset(sax, 0, sizeof(*sax));\n\t\tsax->sax25_family = AF_NETROM;\n\t\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\n\t\t\t AX25_ADDR_LEN);\n\t\tmsg->msg_namelen = sizeof(*sax);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\trelease_sock(sk);\n\treturn copied;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new)\n{\n unsigned char *data = NULL;\n int size;\n loff_t offs;\n\n if (new == -1)\n\tnew = FAT_EOF(fs);\n else if ((long)new == -2)\n\tnew = FAT_BAD(fs);\n switch (fs->fat_bits) {\n case 12:\n\tdata = fs->fat + cluster * 3 / 2;\n\toffs = fs->fat_start + cluster * 3 / 2;\n\tif (cluster & 1) {\n\t FAT_ENTRY prevEntry;\n\t get_fat(&prevEntry, fs->fat, cluster - 1, fs);\n\t data[0] = ((new & 0xf) << 4) | (prevEntry.value >> 8);\n\t data[1] = new >> 4;\n\t} else {\n\t FAT_ENTRY subseqEntry;\n\t if (cluster != fs->clusters + 1)\n\t\tget_fat(&subseqEntry, fs->fat, cluster + 1, fs);\n\t else\n\t\tsubseqEntry.value = 0;\n\t data[0] = new & 0xff;\n\t data[1] = (new >> 8) | ((0xff & subseqEntry.value) << 4);\n\t}\n\tsize = 2;\n\tbreak;\n case 16:\n\tdata = fs->fat + cluster * 2;\n\toffs = fs->fat_start + cluster * 2;\n\t*(unsigned short *)data = htole16(new);\n\tsize = 2;\n\tbreak;\n case 32:\n\t{\n\t FAT_ENTRY curEntry;\n\t get_fat(&curEntry, fs->fat, cluster, fs);\n\n\t data = fs->fat + cluster * 4;\n\t offs = fs->fat_start + cluster * 4;\n\t /* According to M$, the high 4 bits of a FAT32 entry are reserved and\n\t * are not part of the cluster number. So we never touch them. */\n\t *(uint32_t *)data = htole32((new & 0xfffffff) |\n\t\t\t\t\t (curEntry.reserved << 28));\n\t size = 4;\n\t}\n\tbreak;\n default:\n\tdie(\"Bad FAT entry size: %d bits.\", fs->fat_bits);\n }\n fs_write(offs, size, data);\n if (fs->nfats > 1) {\n\tfs_write(offs + fs->fat_size, size, data);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "TRIO_PRIVATE void TrioWriteString TRIO_ARGS5((self, string, flags, width, precision),\n trio_class_t* self, TRIO_CONST char* string,\n trio_flags_t flags, int width, int precision)\n{\n\tint length;\n\tint ch;\n\n\tassert(VALID(self));\n\tassert(VALID(self->OutStream));\n\n\tif (string == NULL)\n\t{\n\t\tstring = internalNullString;\n\t\tlength = sizeof(internalNullString) - 1;\n#if TRIO_FEATURE_QUOTE\n\t\t/* Disable quoting for the null pointer */\n\t\tflags &= (~FLAGS_QUOTE);\n#endif\n\t\twidth = 0;\n\t}\n\telse\n\t{\n\t\tif (precision == 0)\n\t\t{\n\t\t\tlength = trio_length(string);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlength = trio_length_max(string, precision);\n\t\t}\n\t}\n\tif ((NO_PRECISION != precision) && (precision < length))\n\t{\n\t\tlength = precision;\n\t}\n\twidth -= length;\n\n#if TRIO_FEATURE_QUOTE\n\tif (flags & FLAGS_QUOTE)\n\t\tself->OutStream(self, CHAR_QUOTE);\n#endif\n\n\tif (!(flags & FLAGS_LEFTADJUST))\n\t{\n\t\twhile (width-- > 0)\n\t\t\tself->OutStream(self, CHAR_ADJUST);\n\t}\n\n\twhile (length-- > 0)\n\t{\n\t\t/* The ctype parameters must be an unsigned char (or EOF) */\n\t\tch = (int)((unsigned char)(*string++));\n\t\tTrioWriteStringCharacter(self, ch, flags);\n\t}\n\n\tif (flags & FLAGS_LEFTADJUST)\n\t{\n\t\twhile (width-- > 0)\n\t\t\tself->OutStream(self, CHAR_ADJUST);\n\t}\n#if TRIO_FEATURE_QUOTE\n\tif (flags & FLAGS_QUOTE)\n\t\tself->OutStream(self, CHAR_QUOTE);\n#endif\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)TypeIgnore_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n int lineno;\n\n if (_PyObject_HasAttrId(obj, &PyId_lineno)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_lineno);\n if (tmp == NULL) goto failed;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from TypeIgnore\");\n return 1;\n }\n *out = TypeIgnore(lineno, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of type_ignore, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static const char *parse_value(cJSON *item,const char *value,const char **ep)\n{\n\tif (!value)\t\t\t\t\t\treturn 0;\t/* Fail on null. */\n\tif (!strncmp(value,\"null\",4))\t{ item->type=cJSON_NULL; return value+4; }\n\tif (!strncmp(value,\"false\",5))\t{ item->type=cJSON_False; return value+5; }\n\tif (!strncmp(value,\"true\",4))\t{ item->type=cJSON_True; item->valueint=1;\treturn value+4; }\n\tif (*value=='\\\"')\t\t\t\t{ return parse_string(item,value,ep); }\n\tif (*value=='-' || (*value>='0' && *value<='9'))\t{ return parse_number(item,value); }\n\tif (*value=='[')\t\t\t\t{ return parse_array(item,value,ep); }\n\tif (*value=='{')\t\t\t\t{ return parse_object(item,value,ep); }\n\n\t*ep=value;return 0;\t/* failure. */\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "accept_xsmp_connection (SmsConn sms_conn,\n GsmXsmpServer *server,\n unsigned long *mask_ret,\n SmsCallbacks *callbacks_ret,\n char **failure_reason_ret)\n{\n IceConn ice_conn;\n GsmClient *client;\n GsmIceConnectionWatch *data;\n\n /* FIXME: what about during shutdown but before gsm_xsmp_shutdown? */\n if (server->priv->xsmp_sockets == NULL) {\n g_debug (\"GsmXsmpServer: In shutdown, rejecting new client\");\n\n *failure_reason_ret = strdup (_(\"Refusing new client connection because the session is currently being shut down\\n\"));\n return FALSE;\n }\n\n ice_conn = SmsGetIceConnection (sms_conn);\n data = ice_conn->context;\n\n /* Each GsmXSMPClient has its own IceConn watcher */\n free_ice_connection_watch (data);\n\n client = gsm_xsmp_client_new (ice_conn);\n\n gsm_store_add (server->priv->client_store, gsm_client_peek_id (client), G_OBJECT (client));\n /* the store will own the ref */\n g_object_unref (client);\n\n gsm_xsmp_client_connect (GSM_XSMP_CLIENT (client), sms_conn, mask_ret, callbacks_ret);\n\n return TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "safe"} {"code": "SPL_METHOD(DirectoryIterator, rewind)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tintern->u.dir.index = 0;\n\tif (intern->u.dir.dirp) {\n\t\tphp_stream_rewinddir(intern->u.dir.dirp);\n\t}\n\tspl_filesystem_dir_read(intern TSRMLS_CC);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "xfs_acl_from_disk(struct xfs_acl *aclp)\n{\n\tstruct posix_acl_entry *acl_e;\n\tstruct posix_acl *acl;\n\tstruct xfs_acl_entry *ace;\n\tunsigned int count, i;\n\n\tcount = be32_to_cpu(aclp->acl_cnt);\n\tif (count > XFS_ACL_MAX_ENTRIES)\n\t\treturn ERR_PTR(-EFSCORRUPTED);\n\n\tacl = posix_acl_alloc(count, GFP_KERNEL);\n\tif (!acl)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tfor (i = 0; i < count; i++) {\n\t\tacl_e = &acl->a_entries[i];\n\t\tace = &aclp->acl_entry[i];\n\n\t\t/*\n\t\t * The tag is 32 bits on disk and 16 bits in core.\n\t\t *\n\t\t * Because every access to it goes through the core\n\t\t * format first this is not a problem.\n\t\t */\n\t\tacl_e->e_tag = be32_to_cpu(ace->ae_tag);\n\t\tacl_e->e_perm = be16_to_cpu(ace->ae_perm);\n\n\t\tswitch (acl_e->e_tag) {\n\t\tcase ACL_USER:\n\t\tcase ACL_GROUP:\n\t\t\tacl_e->e_id = be32_to_cpu(ace->ae_id);\n\t\t\tbreak;\n\t\tcase ACL_USER_OBJ:\n\t\tcase ACL_GROUP_OBJ:\n\t\tcase ACL_MASK:\n\t\tcase ACL_OTHER:\n\t\t\tacl_e->e_id = ACL_UNDEFINED_ID;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn acl;\n\nfail:\n\tposix_acl_release(acl);\n\treturn ERR_PTR(-EINVAL);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,\n\tstruct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint copied;\n\tint err = 0;\n\n\tlock_sock(sk);\n\t/*\n\t * \tThis works for seqpacket too. The receiver has ordered the\n\t *\tqueue for us! We do one quick check first though\n\t */\n\tif (sk->sk_type == SOCK_SEQPACKET && sk->sk_state != TCP_ESTABLISHED) {\n\t\terr = -ENOTCONN;\n\t\tgoto out;\n\t}\n\n\t/* Now we can treat all alike */\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\tflags & MSG_DONTWAIT, &err);\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tif (!ax25_sk(sk)->pidincl)\n\t\tskb_pull(skb, 1);\t\t/* Remove PID */\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\tskb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tif (msg->msg_name) {\n\t\tax25_digi digi;\n\t\tax25_address src;\n\t\tconst unsigned char *mac = skb_mac_header(skb);\n\t\tstruct sockaddr_ax25 *sax = msg->msg_name;\n\n\t\tmemset(sax, 0, sizeof(struct full_sockaddr_ax25));\n\t\tax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL,\n\t\t\t\t&digi, NULL, NULL);\n\t\tsax->sax25_family = AF_AX25;\n\t\t/* We set this correctly, even though we may not let the\n\t\t application know the digi calls further down (because it\n\t\t did NOT ask to know them). This could get political... **/\n\t\tsax->sax25_ndigis = digi.ndigi;\n\t\tsax->sax25_call = src;\n\n\t\tif (sax->sax25_ndigis != 0) {\n\t\t\tint ct;\n\t\t\tstruct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)sax;\n\n\t\t\tfor (ct = 0; ct < digi.ndigi; ct++)\n\t\t\t\tfsa->fsa_digipeater[ct] = digi.calls[ct];\n\t\t}\n\t\tmsg->msg_namelen = sizeof(struct full_sockaddr_ax25);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\terr = copied;\n\nout:\n\trelease_sock(sk);\n\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int adjust_insn_aux_data(struct bpf_verifier_env *env, u32 prog_len,\n\t\t\t\tu32 off, u32 cnt)\n{\n\tstruct bpf_insn_aux_data *new_data, *old_data = env->insn_aux_data;\n\tint i;\n\n\tif (cnt == 1)\n\t\treturn 0;\n\tnew_data = vzalloc(sizeof(struct bpf_insn_aux_data) * prog_len);\n\tif (!new_data)\n\t\treturn -ENOMEM;\n\tmemcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);\n\tmemcpy(new_data + off + cnt - 1, old_data + off,\n\t sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));\n\tfor (i = off; i < off + cnt - 1; i++)\n\t\tnew_data[i].seen = true;\n\tenv->insn_aux_data = new_data;\n\tvfree(old_data);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tint noblock = flags & MSG_DONTWAIT;\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint copied;\n\tint rc;\n\n\tpr_debug(\"sock=%p sk=%p len=%zu flags=%d\\n\", sock, sk, len, flags);\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &rc);\n\tif (!skb)\n\t\treturn rc;\n\n\tmsg->msg_namelen = 0;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\trc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tskb_free_datagram(sk, skb);\n\n\treturn rc ? : copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,\n\t\t bool add_on_replace)\n{\n\tstruct snd_ctl_elem_id id;\n\tunsigned int count;\n\tunsigned int idx;\n\tstruct snd_kcontrol *old;\n\tint ret;\n\n\tif (!kcontrol)\n\t\treturn -EINVAL;\n\tif (snd_BUG_ON(!card || !kcontrol->info)) {\n\t\tret = -EINVAL;\n\t\tgoto error;\n\t}\n\tid = kcontrol->id;\n\tdown_write(&card->controls_rwsem);\n\told = snd_ctl_find_id(card, &id);\n\tif (!old) {\n\t\tif (add_on_replace)\n\t\t\tgoto add;\n\t\tup_write(&card->controls_rwsem);\n\t\tret = -EINVAL;\n\t\tgoto error;\n\t}\n\tret = snd_ctl_remove(card, old);\n\tif (ret < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\tgoto error;\n\t}\nadd:\n\tif (snd_ctl_find_hole(card, kcontrol->count) < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\tret = -ENOMEM;\n\t\tgoto error;\n\t}\n\tlist_add_tail(&kcontrol->list, &card->controls);\n\tcard->controls_count += kcontrol->count;\n\tkcontrol->id.numid = card->last_numid + 1;\n\tcard->last_numid += kcontrol->count;\n\tcount = kcontrol->count;\n\tup_write(&card->controls_rwsem);\n\tfor (idx = 0; idx < count; idx++, id.index++, id.numid++)\n\t\tsnd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);\n\treturn 0;\n\nerror:\n\tsnd_ctl_free_one(kcontrol);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,\n int flags, struct nameidata *nd)\n{\n\tstruct path path = {\n\t\t.mnt = nd->path.mnt,\n\t\t.dentry = dentry,\n\t};\n\tstruct nfs4_state *state;\n\tstruct rpc_cred *cred;\n\tfmode_t fmode = flags & (FMODE_READ | FMODE_WRITE);\n\tint status = 0;\n\n\tcred = rpc_lookup_cred();\n\tif (IS_ERR(cred)) {\n\t\tstatus = PTR_ERR(cred);\n\t\tgoto out;\n\t}\n\tstate = nfs4_do_open(dir, &path, fmode, flags, sattr, cred);\n\td_drop(dentry);\n\tif (IS_ERR(state)) {\n\t\tstatus = PTR_ERR(state);\n\t\tgoto out_putcred;\n\t}\n\td_add(dentry, igrab(state->inode));\n\tnfs_set_verifier(dentry, nfs_save_change_attribute(dir));\n\tif (flags & O_EXCL) {\n\t\tstruct nfs_fattr fattr;\n\t\tstatus = nfs4_do_setattr(state->inode, cred, &fattr, sattr, state);\n\t\tif (status == 0)\n\t\t\tnfs_setattr_update_inode(state->inode, sattr);\n\t\tnfs_post_op_update_inode(state->inode, &fattr);\n\t}\n\tif (status == 0 && (nd->flags & LOOKUP_OPEN) != 0)\n\t\tstatus = nfs4_intent_set_file(nd, &path, state, fmode);\n\telse\n\t\tnfs4_close_sync(&path, state, fmode);\nout_putcred:\n\tput_rpccred(cred);\nout:\n\treturn status;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, \n uint8 *src, uint8 *dst)\n {\n int i;\n uint32 col, bytes_per_pixel, col_offset;\n uint8 bytebuff1;\n unsigned char swapbuff[32];\n \n if ((src == NULL) || (dst == NULL))\n {\n TIFFError(\"reverseSamplesBytes\",\"Invalid input or output buffer\");\n return (1);\n }\n\n bytes_per_pixel = ((bps * spp) + 7) / 8;\n if( bytes_per_pixel > sizeof(swapbuff) )\n {\n TIFFError(\"reverseSamplesBytes\",\"bytes_per_pixel too large\");\n return (1);\n }\n switch (bps / 8)\n {\n case 8: /* Use memcpy for multiple bytes per sample data */\n case 4:\n case 3:\n case 2: for (col = 0; col < (width / 2); col++)\n {\n\t col_offset = col * bytes_per_pixel; \n\t _TIFFmemcpy (swapbuff, src + col_offset, bytes_per_pixel);\n\t _TIFFmemcpy (src + col_offset, dst - col_offset - bytes_per_pixel, bytes_per_pixel);\n\t _TIFFmemcpy (dst - col_offset - bytes_per_pixel, swapbuff, bytes_per_pixel);\n }\n\t break;\n case 1: /* Use byte copy only for single byte per sample data */\n for (col = 0; col < (width / 2); col++)\n { \n\t for (i = 0; i < spp; i++)\n {\n\t\t bytebuff1 = *src;\n\t\t *src++ = *(dst - spp + i);\n *(dst - spp + i) = bytebuff1;\n\t\t }\n\t\tdst -= spp;\n }\n\t break;\n default: TIFFError(\"reverseSamplesBytes\",\"Unsupported bit depth %d\", bps);\n return (1);\n }\n return (0);\n } /* end reverseSamplesBytes */", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static VTermScreen *screen_new(VTerm *vt)\n{\n VTermState *state = vterm_obtain_state(vt);\n VTermScreen *screen;\n int rows, cols;\n\n if (state == NULL)\n return NULL;\n screen = vterm_allocator_malloc(vt, sizeof(VTermScreen));\n if (screen == NULL)\n return NULL;\n\n vterm_get_size(vt, &rows, &cols);\n\n screen->vt = vt;\n screen->state = state;\n\n screen->damage_merge = VTERM_DAMAGE_CELL;\n screen->damaged.start_row = -1;\n screen->pending_scrollrect.start_row = -1;\n\n screen->rows = rows;\n screen->cols = cols;\n\n screen->callbacks = NULL;\n screen->cbdata = NULL;\n\n screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols);\n screen->buffer = screen->buffers[0];\n screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols);\n if (screen->buffer == NULL || screen->sb_buffer == NULL)\n {\n vterm_screen_free(screen);\n return NULL;\n }\n\n vterm_state_set_callbacks(screen->state, &state_cbs, screen);\n\n return screen;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int pfkey_recvmsg(struct kiocb *kiocb,\n\t\t\t struct socket *sock, struct msghdr *msg, size_t len,\n\t\t\t int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct pfkey_sock *pfk = pfkey_sk(sk);\n\tstruct sk_buff *skb;\n\tint copied, err;\n\n\terr = -EINVAL;\n\tif (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT))\n\t\tgoto out;\n\n\tmsg->msg_namelen = 0;\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (copied > len) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\tskb_reset_transport_header(skb);\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto out_free;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\terr = (flags & MSG_TRUNC) ? skb->len : copied;\n\n\tif (pfk->dump.dump != NULL &&\n\t 3 * atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf)\n\t\tpfkey_do_dump(pfk);\n\nout_free:\n\tskb_free_datagram(sk, skb);\nout:\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static u_int mp_dss_len(const struct mp_dss *m, int csum)\n{\n u_int len;\n\n len = 4;\n if (m->flags & MP_DSS_A) {\n /* Ack present - 4 or 8 octets */\n len += (m->flags & MP_DSS_a) ? 8 : 4;\n }\n if (m->flags & MP_DSS_M) {\n /*\n * Data Sequence Number (DSN), Subflow Sequence Number (SSN),\n * Data-Level Length present, and Checksum possibly present.\n * All but the Checksum are 10 bytes if the m flag is\n * clear (4-byte DSN) and 14 bytes if the m flag is set\n * (8-byte DSN).\n */\n len += (m->flags & MP_DSS_m) ? 14 : 10;\n\n /*\n * The Checksum is present only if negotiated.\n */\n if (csum)\n len += 2;\n\t}\n\treturn len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int f2fs_set_data_page_dirty(struct page *page)\n{\n\tstruct address_space *mapping = page->mapping;\n\tstruct inode *inode = mapping->host;\n\n\ttrace_f2fs_set_page_dirty(page, DATA);\n\n\tif (!PageUptodate(page))\n\t\tSetPageUptodate(page);\n\n\tif (f2fs_is_atomic_file(inode) && !f2fs_is_commit_atomic_write(inode)) {\n\t\tif (!IS_ATOMIC_WRITTEN_PAGE(page)) {\n\t\t\tf2fs_register_inmem_page(inode, page);\n\t\t\treturn 1;\n\t\t}\n\t\t/*\n\t\t * Previously, this page has been registered, we just\n\t\t * return here.\n\t\t */\n\t\treturn 0;\n\t}\n\n\tif (!PageDirty(page)) {\n\t\t__set_page_dirty_nobuffers(page);\n\t\tf2fs_update_dirty_page(inode, page);\n\t\treturn 1;\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "uint32_t GetPayloadTime(size_t handle, uint32_t index, float *in, float *out)\n{\n\tmp4object *mp4 = (mp4object *)handle;\n\tif (mp4 == NULL) return 0;\n\n\tif (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return 1;\n\n\t*in = (float)((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\t*out = (float)((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "receive_carbon(void **state)\n{\n prof_input(\"/carbons on\");\n\n prof_connect();\n assert_true(stbbr_received(\n \"\"\n ));\n\n stbbr_send(\n \"\"\n \"10\"\n \"On my mobile\"\n \"\"\n );\n assert_true(prof_output_exact(\"Buddy1 (mobile) is online, \\\"On my mobile\\\"\"));\n prof_input(\"/msg Buddy1\");\n assert_true(prof_output_exact(\"unencrypted\"));\n\n stbbr_send(\n \"\"\n \"\"\n \"\"\n \"\"\n \"test carbon from recipient\"\n \"\"\n \"\"\n \"\"\n \"\"\n );\n\n assert_true(prof_output_regex(\"Buddy1/mobile: .+test carbon from recipient\"));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "void Con_Dump_f (void)\n{\n\tint\t\tl, x, i;\n\tshort\t*line;\n\tfileHandle_t\tf;\n\tint\t\tbufferlen;\n\tchar\t*buffer;\n\tchar\tfilename[MAX_QPATH];\n\n\tif (Cmd_Argc() != 2)\n\t{\n\t\tCom_Printf (\"usage: condump \\n\");\n\t\treturn;\n\t}\n\n\tQ_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );\n\tCOM_DefaultExtension( filename, sizeof( filename ), \".txt\" );\n\n\tif (!COM_CompareExtension(filename, \".txt\"))\n\t{\n\t\tCom_Printf(\"Con_Dump_f: Only the \\\".txt\\\" extension is supported by this command!\\n\");\n\t\treturn;\n\t}\n\n\tf = FS_FOpenFileWrite( filename );\n\tif (!f)\n\t{\n\t\tCom_Printf (\"ERROR: couldn't open %s.\\n\", filename);\n\t\treturn;\n\t}\n\n\tCom_Printf (\"Dumped console text to %s.\\n\", filename );\n\n\t// skip empty lines\n\tfor (l = con.current - con.totallines + 1 ; l <= con.current ; l++)\n\t{\n\t\tline = con.text + (l%con.totallines)*con.linewidth;\n\t\tfor (x=0 ; x=0 ; x--)\n\t\t{\n\t\t\tif (buffer[x] == ' ')\n\t\t\t\tbuffer[x] = 0;\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n#ifdef _WIN32\n\t\tQ_strcat(buffer, bufferlen, \"\\r\\n\");\n#else\n\t\tQ_strcat(buffer, bufferlen, \"\\n\");\n#endif\n\t\tFS_Write(buffer, strlen(buffer), f);\n\t}\n\n\tHunk_FreeTempMemory( buffer );\n\tFS_FCloseFile( f );\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "static MagickPixelPacket **AcquirePixelThreadSet(const Image *images)\n{\n const Image\n *next;\n\n MagickPixelPacket\n **pixels;\n\n register ssize_t\n i,\n j;\n\n size_t\n columns,\n number_threads;\n\n number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n pixels=(MagickPixelPacket **) AcquireQuantumMemory(number_threads,\n sizeof(*pixels));\n if (pixels == (MagickPixelPacket **) NULL)\n return((MagickPixelPacket **) NULL);\n (void) memset(pixels,0,number_threads*sizeof(*pixels));\n columns=images->columns;\n for (next=images; next != (Image *) NULL; next=next->next)\n columns=MagickMax(next->columns,columns);\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(columns,\n sizeof(**pixels));\n if (pixels[i] == (MagickPixelPacket *) NULL)\n return(DestroyPixelThreadSet(pixels));\n for (j=0; j < (ssize_t) columns; j++)\n GetMagickPixelPacket(images,&pixels[i][j]);\n }\n return(pixels);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static void read_module(RBuffer *b, ut64 addr, struct minidump_module *module) {\n\tst64 o_addr = r_buf_seek (b, 0, R_BUF_CUR);\n\tr_buf_seek (b, addr, R_BUF_SET);\n\tmodule->base_of_image = r_buf_read_le64 (b);\n\tmodule->size_of_image = r_buf_read_le32 (b);\n\tmodule->check_sum = r_buf_read_le32 (b);\n\tmodule->time_date_stamp = r_buf_read_le32 (b);\n\tmodule->module_name_rva = r_buf_read_le32 (b);\n\tmodule->version_info.dw_signature = r_buf_read_le32 (b);\n\tmodule->version_info.dw_struc_version = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_version_ms = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_version_ls = r_buf_read_le32 (b);\n\tmodule->version_info.dw_product_version_ms = r_buf_read_le32 (b);\n\tmodule->version_info.dw_product_version_ls = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_flags_mask = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_flags = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_os = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_type = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_subtype = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_date_ms = r_buf_read_le32 (b);\n\tmodule->version_info.dw_file_date_ls = r_buf_read_le32 (b);\n\tmodule->cv_record.data_size = r_buf_read_le32 (b);\n\tmodule->cv_record.rva = r_buf_read_le32 (b);\n\tmodule->misc_record.data_size = r_buf_read_le32 (b);\n\tmodule->misc_record.rva = r_buf_read_le32 (b);\n\tmodule->reserved_0 = r_buf_read_le64 (b);\n\tmodule->reserved_1 = r_buf_read_le64 (b);\n\tr_buf_seek (b, o_addr, R_BUF_SET);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "int l2tp_packet_send(int sock, struct l2tp_packet_t *pack)\n{\n\tuint8_t *buf = mempool_alloc(buf_pool);\n\tstruct l2tp_avp_t *avp;\n\tstruct l2tp_attr_t *attr;\n\tuint8_t *ptr;\n\tint n;\n\tint len = sizeof(pack->hdr);\n\n\tif (!buf) {\n\t\tlog_emerg(\"l2tp: out of memory\\n\");\n\t\treturn -1;\n\t}\n\n\tmemset(buf, 0, L2TP_MAX_PACKET_SIZE);\n\n\tptr = buf + sizeof(pack->hdr);\n\n\tlist_for_each_entry(attr, &pack->attrs, entry) {\n\t\tif (len + sizeof(*avp) + attr->length >= L2TP_MAX_PACKET_SIZE) {\n\t\t\tlog_error(\"l2tp: cann't send packet (exceeds maximum size)\\n\");\n\t\t\tmempool_free(buf);\n\t\t\treturn -1;\n\t\t}\n\t\tavp = (struct l2tp_avp_t *)ptr;\n\t\tavp->type = htons(attr->attr->id);\n\t\tavp->M = attr->M;\n\t\tavp->H = attr->H;\n\t\tavp->length = sizeof(*avp) + attr->length;\n\t\t*(uint16_t *)ptr = htons(*(uint16_t *)ptr);\n\t\tif (attr->H)\n\t\t\tmemcpy(avp->val, attr->val.octets, attr->length);\n\t\telse\n\t\t\tswitch (attr->attr->type) {\n\t\t\tcase ATTR_TYPE_INT16:\n\t\t\t\t*(int16_t *)avp->val = htons(attr->val.int16);\n\t\t\t\tbreak;\n\t\t\tcase ATTR_TYPE_INT32:\n\t\t\t\t*(int32_t *)avp->val = htonl(attr->val.int32);\n\t\t\t\tbreak;\n\t\t\tcase ATTR_TYPE_INT64:\n\t\t\t\t*(uint64_t *)avp->val = htobe64(attr->val.uint64);\n\t\t\t\tbreak;\n\t\t\tcase ATTR_TYPE_STRING:\n\t\t\tcase ATTR_TYPE_OCTETS:\n\t\t\t\tmemcpy(avp->val, attr->val.string, attr->length);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tptr += sizeof(*avp) + attr->length;\n\t\tlen += sizeof(*avp) + attr->length;\n\t}\n\n\tpack->hdr.length = htons(len);\n\tmemcpy(buf, &pack->hdr, sizeof(pack->hdr));\n\n\tn = sendto(sock, buf, ntohs(pack->hdr.length), 0,\n\t\t &pack->addr, sizeof(pack->addr));\n\tmempool_free(buf);\n\n\tif (n < 0) {\n\t\tif (errno == EAGAIN) {\n\t\t\tif (conf_verbose)\n\t\t\t\tlog_warn(\"l2tp: buffer overflow (packet lost)\\n\");\n\t\t} else {\n\t\t\tif (conf_verbose)\n\t\t\t\tlog_warn(\"l2tp: sendto: %s\\n\", strerror(errno));\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (n != ntohs(pack->hdr.length)) {\n\t\tif (conf_verbose)\n\t\t\tlog_warn(\"l2tp: short write (%i/%i)\\n\", n, ntohs(pack->hdr.length));\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "void IGDstartelt(void * d, const char * name, int l)\n{\n\tstruct IGDdatas * datas = (struct IGDdatas *)d;\n\tmemcpy( datas->cureltname, name, l);\n\tdatas->cureltname[l] = '\\0';\n\tdatas->level++;\n\tif( (l==7) && !memcmp(name, \"service\", l) ) {\n\t\tdatas->tmp.controlurl[0] = '\\0';\n\t\tdatas->tmp.eventsuburl[0] = '\\0';\n\t\tdatas->tmp.scpdurl[0] = '\\0';\n\t\tdatas->tmp.servicetype[0] = '\\0';\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "void _moddeinit(module_unload_intent_t intent)\n{\n\tservice_named_unbind_command(\"chanserv\", &cs_flags);\n\n\thook_del_nick_can_register(check_registration_keywords);\n\n\thook_del_user_can_register(check_registration_keywords);\n\n\tdel_conf_item(\"ANOPE_FLAGS_COMPAT\", &chansvs.me->conf_table);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,\n\t\tunsigned int, flags, struct sockaddr __user *, addr,\n\t\tint __user *, addr_len)\n{\n\tstruct socket *sock;\n\tstruct iovec iov;\n\tstruct msghdr msg;\n\tstruct sockaddr_storage address;\n\tint err, err2;\n\tint fput_needed;\n\n\tif (size > INT_MAX)\n\t\tsize = INT_MAX;\n\tsock = sockfd_lookup_light(fd, &err, &fput_needed);\n\tif (!sock)\n\t\tgoto out;\n\n\tmsg.msg_control = NULL;\n\tmsg.msg_controllen = 0;\n\tmsg.msg_iovlen = 1;\n\tmsg.msg_iov = &iov;\n\tiov.iov_len = size;\n\tiov.iov_base = ubuf;\n\tmsg.msg_name = (struct sockaddr *)&address;\n\tmsg.msg_namelen = sizeof(address);\n\tif (sock->file->f_flags & O_NONBLOCK)\n\t\tflags |= MSG_DONTWAIT;\n\terr = sock_recvmsg(sock, &msg, size, flags);\n\n\tif (err >= 0 && addr != NULL) {\n\t\terr2 = move_addr_to_user(&address,\n\t\t\t\t\t msg.msg_namelen, addr, addr_len);\n\t\tif (err2 < 0)\n\t\t\terr = err2;\n\t}\n\n\tfput_light(sock->file, fput_needed);\nout:\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)\n{\n\tenum direction dir;\n\n\tif(!(current->thread.flags & SPARC_FLAG_UNALIGNED) ||\n\t (((insn >> 30) & 3) != 3))\n\t\tgoto kill_user;\n\tdir = decode_direction(insn);\n\tif(!ok_for_user(regs, insn, dir)) {\n\t\tgoto kill_user;\n\t} else {\n\t\tint err, size = decode_access_size(insn);\n\t\tunsigned long addr;\n\n\t\tif(floating_point_load_or_store_p(insn)) {\n\t\t\tprintk(\"User FPU load/store unaligned unsupported.\\n\");\n\t\t\tgoto kill_user;\n\t\t}\n\n\t\taddr = compute_effective_address(regs, insn);\n\t\tperf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);\n\t\tswitch(dir) {\n\t\tcase load:\n\t\t\terr = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),\n\t\t\t\t\t\t\t regs),\n\t\t\t\t\t size, (unsigned long *) addr,\n\t\t\t\t\t decode_signedness(insn));\n\t\t\tbreak;\n\n\t\tcase store:\n\t\t\terr = do_int_store(((insn>>25)&0x1f), size,\n\t\t\t\t\t (unsigned long *) addr, regs);\n\t\t\tbreak;\n\n\t\tcase both:\n\t\t\t/*\n\t\t\t * This was supported in 2.4. However, we question\n\t\t\t * the value of SWAP instruction across word boundaries.\n\t\t\t */\n\t\t\tprintk(\"Unaligned SWAP unsupported.\\n\");\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tunaligned_panic(\"Impossible user unaligned trap.\");\n\t\t\tgoto out;\n\t\t}\n\t\tif (err)\n\t\t\tgoto kill_user;\n\t\telse\n\t\t\tadvance(regs);\n\t\tgoto out;\n\t}\n\nkill_user:\n\tuser_mna_trap_fault(regs, insn);\nout:\n\t;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,\n\t\tconst unsigned char *sigbuf, int sig_len, EC_KEY *eckey)\n \t{\n\tECDSA_SIG *s;\n\tconst unsigned char *p = sigbuf;\n\tunsigned char *der = NULL;\n\tint derlen = -1;\n\tint ret=-1;\n\n\ts = ECDSA_SIG_new();\n\tif (s == NULL) return(ret);\n\tif (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err;\n\t/* Ensure signature uses DER and doesn't have trailing garbage */\n\tderlen = i2d_ECDSA_SIG(s, &der);\n\tif (derlen != sig_len || memcmp(sigbuf, der, derlen))\n\t\tgoto err;\n\tret=ECDSA_do_verify(dgst, dgst_len, s, eckey);\nerr:\n\tif (derlen > 0)\n\t\t{\n\t\tOPENSSL_cleanse(der, derlen);\n\t\tOPENSSL_free(der);\n\t\t}\n\tECDSA_SIG_free(s);\n\treturn(ret);\n\t}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "static int uio_mmap_physical(struct vm_area_struct *vma)\n{\n\tstruct uio_device *idev = vma->vm_private_data;\n\tint mi = uio_find_mem_index(vma);\n\tif (mi < 0)\n\t\treturn -EINVAL;\n\n\tvma->vm_ops = &uio_physical_vm_ops;\n\n\tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n\n\treturn remap_pfn_range(vma,\n\t\t\t vma->vm_start,\n\t\t\t idev->info->mem[mi].addr >> PAGE_SHIFT,\n\t\t\t vma->vm_end - vma->vm_start,\n\t\t\t vma->vm_page_prot);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)\n{\n VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);\n uint32_t val = data;\n\n if (addr > (vdev->config_len - sizeof(val)))\n return;\n\n stl_p(vdev->config + addr, val);\n\n if (k->set_config) {\n k->set_config(vdev, vdev->config);\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "vulnerable"} {"code": "static bool kvm_vcpu_check_breakpoint(struct kvm_vcpu *vcpu, int *r)\n{\n\tif (unlikely(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) &&\n\t (vcpu->arch.guest_debug_dr7 & DR7_BP_EN_MASK)) {\n\t\tstruct kvm_run *kvm_run = vcpu->run;\n\t\tunsigned long eip = kvm_get_linear_rip(vcpu);\n\t\tu32 dr6 = kvm_vcpu_check_hw_bp(eip, 0,\n\t\t\t\t\t vcpu->arch.guest_debug_dr7,\n\t\t\t\t\t vcpu->arch.eff_db);\n\n\t\tif (dr6 != 0) {\n\t\t\tkvm_run->debug.arch.dr6 = dr6 | DR6_ACTIVE_LOW;\n\t\t\tkvm_run->debug.arch.pc = eip;\n\t\t\tkvm_run->debug.arch.exception = DB_VECTOR;\n\t\t\tkvm_run->exit_reason = KVM_EXIT_DEBUG;\n\t\t\t*r = 0;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tif (unlikely(vcpu->arch.dr7 & DR7_BP_EN_MASK) &&\n\t !(kvm_get_rflags(vcpu) & X86_EFLAGS_RF)) {\n\t\tunsigned long eip = kvm_get_linear_rip(vcpu);\n\t\tu32 dr6 = kvm_vcpu_check_hw_bp(eip, 0,\n\t\t\t\t\t vcpu->arch.dr7,\n\t\t\t\t\t vcpu->arch.db);\n\n\t\tif (dr6 != 0) {\n\t\t\tkvm_queue_exception_p(vcpu, DB_VECTOR, dr6);\n\t\t\t*r = 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "uint32_t GetPayloadTime(size_t handle, uint32_t index, float *in, float *out)\n{\n\tmp4object *mp4 = (mp4object *)handle;\n\tif (mp4 == NULL) return 0;\n\n\tif (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return 1;\n\n\t*in = (float)((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\t*out = (float)((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len)\n{\n\tsize_t cipher_len;\n\tsize_t i;\n\tunsigned char iv[16] = { 0 };\n\tunsigned char plaintext[4096] = { 0 };\n\tepass2003_exdata *exdata = NULL;\n\n\tif (!card->drv_data) \n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\texdata = (epass2003_exdata *)card->drv_data;\n\n\t/* no cipher */\n\tif (in[0] == 0x99)\n\t\treturn 0;\n\n\t/* parse cipher length */\n\tif (0x01 == in[2] && 0x82 != in[1]) {\n\t\tcipher_len = in[1];\n\t\ti = 3;\n\t}\n\telse if (0x01 == in[3] && 0x81 == in[1]) {\n\t\tcipher_len = in[2];\n\t\ti = 4;\n\t}\n\telse if (0x01 == in[4] && 0x82 == in[1]) {\n\t\tcipher_len = in[2] * 0x100;\n\t\tcipher_len += in[3];\n\t\ti = 5;\n\t}\n\telse {\n\t\treturn -1;\n\t}\n\n\tif (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext)\n\t\treturn -1;\n\n\t/* decrypt */\n\tif (KEY_TYPE_AES == exdata->smtype)\n\t\taes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\telse\n\t\tdes3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\n\t/* unpadding */\n\twhile (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0))\n\t\tcipher_len--;\n\n\tif (2 == cipher_len)\n\t\treturn -1;\n\n\tmemcpy(out, plaintext, cipher_len - 2);\n\t*out_len = cipher_len - 2;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int load_script(struct linux_binprm *bprm)\n{\n\tconst char *i_arg, *i_name;\n\tchar *cp;\n\tstruct file *file;\n\tchar interp[BINPRM_BUF_SIZE];\n\tint retval;\n\n\tif ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))\n\t\treturn -ENOEXEC;\n\t/*\n\t * This section does the #! interpretation.\n\t * Sorta complicated, but hopefully it will work. -TYT\n\t */\n\n\tallow_write_access(bprm->file);\n\tfput(bprm->file);\n\tbprm->file = NULL;\n\n\tbprm->buf[BINPRM_BUF_SIZE - 1] = '\\0';\n\tif ((cp = strchr(bprm->buf, '\\n')) == NULL)\n\t\tcp = bprm->buf+BINPRM_BUF_SIZE-1;\n\t*cp = '\\0';\n\twhile (cp > bprm->buf) {\n\t\tcp--;\n\t\tif ((*cp == ' ') || (*cp == '\\t'))\n\t\t\t*cp = '\\0';\n\t\telse\n\t\t\tbreak;\n\t}\n\tfor (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\\t'); cp++);\n\tif (*cp == '\\0') \n\t\treturn -ENOEXEC; /* No interpreter name found */\n\ti_name = cp;\n\ti_arg = NULL;\n\tfor ( ; *cp && (*cp != ' ') && (*cp != '\\t'); cp++)\n\t\t/* nothing */ ;\n\twhile ((*cp == ' ') || (*cp == '\\t'))\n\t\t*cp++ = '\\0';\n\tif (*cp)\n\t\ti_arg = cp;\n\tstrcpy (interp, i_name);\n\t/*\n\t * OK, we've parsed out the interpreter name and\n\t * (optional) argument.\n\t * Splice in (1) the interpreter's name for argv[0]\n\t * (2) (optional) argument to interpreter\n\t * (3) filename of shell script (replace argv[0])\n\t *\n\t * This is done in reverse order, because of how the\n\t * user environment and arguments are stored.\n\t */\n\tretval = remove_arg_zero(bprm);\n\tif (retval)\n\t\treturn retval;\n\tretval = copy_strings_kernel(1, &bprm->interp, bprm);\n\tif (retval < 0) return retval; \n\tbprm->argc++;\n\tif (i_arg) {\n\t\tretval = copy_strings_kernel(1, &i_arg, bprm);\n\t\tif (retval < 0) return retval; \n\t\tbprm->argc++;\n\t}\n\tretval = copy_strings_kernel(1, &i_name, bprm);\n\tif (retval) return retval; \n\tbprm->argc++;\n\tbprm->interp = interp;\n\n\t/*\n\t * OK, now restart the process with the interpreter's dentry.\n\t */\n\tfile = open_exec(interp);\n\tif (IS_ERR(file))\n\t\treturn PTR_ERR(file);\n\n\tbprm->file = file;\n\tretval = prepare_binprm(bprm);\n\tif (retval < 0)\n\t\treturn retval;\n\treturn search_binary_handler(bprm);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) {\n _cleanup_close_ int fd;\n int r;\n\n assert(path);\n\n if (parents)\n mkdir_parents(path, 0755);\n\n fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, mode > 0 ? mode : 0644);\n if (fd < 0)\n return -errno;\n\n if (mode != MODE_INVALID) {\n r = fchmod(fd, mode);\n if (r < 0)\n return -errno;\n }\n\n if (uid != UID_INVALID || gid != GID_INVALID) {\n r = fchown(fd, uid, gid);\n if (r < 0)\n return -errno;\n }\n\n if (stamp != USEC_INFINITY) {\n struct timespec ts[2];\n\n timespec_store(&ts[0], stamp);\n ts[1] = ts[0];\n r = futimens(fd, ts);\n } else\n r = futimens(fd, NULL);\n if (r < 0)\n return -errno;\n\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev)\n{\n\tstruct virtproc_info *vrp = vdev->priv;\n\tstruct virtio_rpmsg_channel *vch;\n\tstruct rpmsg_device *rpdev_ctrl;\n\tint err = 0;\n\n\tvch = kzalloc(sizeof(*vch), GFP_KERNEL);\n\tif (!vch)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\t/* Link the channel to the vrp */\n\tvch->vrp = vrp;\n\n\t/* Assign public information to the rpmsg_device */\n\trpdev_ctrl = &vch->rpdev;\n\trpdev_ctrl->ops = &virtio_rpmsg_ops;\n\n\trpdev_ctrl->dev.parent = &vrp->vdev->dev;\n\trpdev_ctrl->dev.release = virtio_rpmsg_release_device;\n\trpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev);\n\n\terr = rpmsg_ctrldev_register_device(rpdev_ctrl);\n\tif (err) {\n\t\t/* vch will be free in virtio_rpmsg_release_device() */\n\t\treturn ERR_PTR(err);\n\t}\n\n\treturn rpdev_ctrl;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "int perf_event_task_disable(void)\n{\n\tstruct perf_event *event;\n\n\tmutex_lock(¤t->perf_event_mutex);\n\tlist_for_each_entry(event, ¤t->perf_event_list, owner_entry)\n\t\tperf_event_for_each_child(event, perf_event_disable);\n\tmutex_unlock(¤t->perf_event_mutex);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "fst_get_iface(struct fst_card_info *card, struct fst_port_info *port,\n\t struct ifreq *ifr)\n{\n\tsync_serial_settings sync;\n\tint i;\n\n\t/* First check what line type is set, we'll default to reporting X.21\n\t * if nothing is set as IF_IFACE_SYNC_SERIAL implies it can't be\n\t * changed\n\t */\n\tswitch (port->hwif) {\n\tcase E1:\n\t\tifr->ifr_settings.type = IF_IFACE_E1;\n\t\tbreak;\n\tcase T1:\n\t\tifr->ifr_settings.type = IF_IFACE_T1;\n\t\tbreak;\n\tcase V35:\n\t\tifr->ifr_settings.type = IF_IFACE_V35;\n\t\tbreak;\n\tcase V24:\n\t\tifr->ifr_settings.type = IF_IFACE_V24;\n\t\tbreak;\n\tcase X21D:\n\t\tifr->ifr_settings.type = IF_IFACE_X21D;\n\t\tbreak;\n\tcase X21:\n\tdefault:\n\t\tifr->ifr_settings.type = IF_IFACE_X21;\n\t\tbreak;\n\t}\n\tif (ifr->ifr_settings.size == 0) {\n\t\treturn 0;\t/* only type requested */\n\t}\n\tif (ifr->ifr_settings.size < sizeof (sync)) {\n\t\treturn -ENOMEM;\n\t}\n\n\ti = port->index;\n\tmemset(&sync, 0, sizeof(sync));\n\tsync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);\n\t/* Lucky card and linux use same encoding here */\n\tsync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==\n\t INTCLK ? CLOCK_INT : CLOCK_EXT;\n\tsync.loopback = 0;\n\n\tif (copy_to_user(ifr->ifr_settings.ifs_ifsu.sync, &sync, sizeof (sync))) {\n\t\treturn -EFAULT;\n\t}\n\n\tifr->ifr_settings.size = sizeof (sync);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,\n\t\tinfop, int, options, struct rusage __user *, ru)\n{\n\tstruct rusage r;\n\tstruct waitid_info info = {.status = 0};\n\tlong err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL);\n\tint signo = 0;\n\tif (err > 0) {\n\t\tsigno = SIGCHLD;\n\t\terr = 0;\n\t}\n\n\tif (!err) {\n\t\tif (ru && copy_to_user(ru, &r, sizeof(struct rusage)))\n\t\t\treturn -EFAULT;\n\t}\n\tif (!infop)\n\t\treturn err;\n\n\tuser_access_begin();\n\tunsafe_put_user(signo, &infop->si_signo, Efault);\n\tunsafe_put_user(0, &infop->si_errno, Efault);\n\tunsafe_put_user(info.cause, &infop->si_code, Efault);\n\tunsafe_put_user(info.pid, &infop->si_pid, Efault);\n\tunsafe_put_user(info.uid, &infop->si_uid, Efault);\n\tunsafe_put_user(info.status, &infop->si_status, Efault);\n\tuser_access_end();\n\treturn err;\nEfault:\n\tuser_access_end();\n\treturn -EFAULT;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "static pj_status_t pjsip_auth_verify( const pjsip_authorization_hdr *hdr,\n\t\t\t\t const pj_str_t *method,\n\t\t\t\t const pjsip_cred_info *cred_info )\n{\n if (pj_stricmp(&hdr->scheme, &pjsip_DIGEST_STR) == 0) {\n\tchar digest_buf[PJSIP_MD5STRLEN];\n\tpj_str_t digest;\n\tconst pjsip_digest_credential *dig = &hdr->credential.digest;\n\n\t/* Check that username and realm match. \n\t * These checks should have been performed before entering this\n\t * function.\n\t */\n\tPJ_ASSERT_RETURN(pj_strcmp(&dig->username, &cred_info->username) == 0,\n\t\t\t PJ_EINVALIDOP);\n\tPJ_ASSERT_RETURN(pj_strcmp(&dig->realm, &cred_info->realm) == 0,\n\t\t\t PJ_EINVALIDOP);\n\n\t/* Prepare for our digest calculation. */\n\tdigest.ptr = digest_buf;\n\tdigest.slen = PJSIP_MD5STRLEN;\n\n\t/* Create digest for comparison. */\n\tpjsip_auth_create_digest(&digest, \n\t\t\t\t &hdr->credential.digest.nonce,\n\t\t\t\t &hdr->credential.digest.nc, \n\t\t\t\t &hdr->credential.digest.cnonce,\n\t\t\t\t &hdr->credential.digest.qop,\n\t\t\t\t &hdr->credential.digest.uri,\n\t\t\t\t &cred_info->realm,\n\t\t\t\t cred_info, \n\t\t\t\t method );\n\n\t/* Compare digest. */\n\treturn (pj_stricmp(&digest, &hdr->credential.digest.response) == 0) ?\n\t PJ_SUCCESS : PJSIP_EAUTHINVALIDDIGEST;\n\n } else {\n\tpj_assert(!\"Unsupported authentication scheme\");\n\treturn PJSIP_EINVALIDAUTHSCHEME;\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "krb5_gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,\n const gss_ctx_id_t context_handle,\n const gss_OID desired_object,\n gss_buffer_set_t *data_set)\n{\n krb5_gss_ctx_id_rec *ctx;\n size_t i;\n\n if (minor_status == NULL)\n return GSS_S_CALL_INACCESSIBLE_WRITE;\n\n *minor_status = 0;\n\n if (desired_object == GSS_C_NO_OID)\n return GSS_S_CALL_INACCESSIBLE_READ;\n\n if (data_set == NULL)\n return GSS_S_CALL_INACCESSIBLE_WRITE;\n\n *data_set = GSS_C_NO_BUFFER_SET;\n\n ctx = (krb5_gss_ctx_id_rec *) context_handle;\n\n if (ctx->terminated || !ctx->established)\n return GSS_S_NO_CONTEXT;\n\n for (i = 0; i < sizeof(krb5_gss_inquire_sec_context_by_oid_ops)/\n sizeof(krb5_gss_inquire_sec_context_by_oid_ops[0]); i++) {\n if (g_OID_prefix_equal(desired_object, &krb5_gss_inquire_sec_context_by_oid_ops[i].oid)) {\n return (*krb5_gss_inquire_sec_context_by_oid_ops[i].func)(minor_status,\n context_handle,\n desired_object,\n data_set);\n }\n }\n\n *minor_status = EINVAL;\n\n return GSS_S_UNAVAILABLE;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "crm_parse_remote_buffer(char **msg_buf)\n{\n char *buf = NULL;\n char *start = NULL;\n char *end = NULL;\n xmlNode *xml = NULL;\n\n if (*msg_buf == NULL) {\n return NULL;\n }\n\n /* take ownership of the buffer */\n buf = *msg_buf;\n *msg_buf = NULL;\n\n /* MSGS are separated by a '\\r\\n\\r\\n'. Split a message off the buffer and return it. */\n start = buf;\n end = strstr(start, REMOTE_MSG_TERMINATOR);\n\n while (!xml && end) {\n\n /* grab the message */\n end[0] = '\\0';\n end += strlen(REMOTE_MSG_TERMINATOR);\n\n xml = string2xml(start);\n if (xml == NULL) {\n crm_err(\"Couldn't parse: '%.120s'\", start);\n }\n start = end;\n end = strstr(start, REMOTE_MSG_TERMINATOR);\n }\n\n if (xml && start) {\n /* we have msgs left over, save it until next time */\n *msg_buf = strdup(start);\n free(buf);\n } else if (!xml) {\n /* no msg present */\n *msg_buf = buf;\n }\n\n return xml;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static int mwifiex_update_vs_ie(const u8 *ies, int ies_len,\n\t\t\t\tstruct mwifiex_ie **ie_ptr, u16 mask,\n\t\t\t\tunsigned int oui, u8 oui_type)\n{\n\tstruct ieee_types_header *vs_ie;\n\tstruct mwifiex_ie *ie = *ie_ptr;\n\tconst u8 *vendor_ie;\n\n\tvendor_ie = cfg80211_find_vendor_ie(oui, oui_type, ies, ies_len);\n\tif (vendor_ie) {\n\t\tif (!*ie_ptr) {\n\t\t\t*ie_ptr = kzalloc(sizeof(struct mwifiex_ie),\n\t\t\t\t\t GFP_KERNEL);\n\t\t\tif (!*ie_ptr)\n\t\t\t\treturn -ENOMEM;\n\t\t\tie = *ie_ptr;\n\t\t}\n\n\t\tvs_ie = (struct ieee_types_header *)vendor_ie;\n\t\tif (le16_to_cpu(ie->ie_length) + vs_ie->len + 2 >\n\t\t\tIEEE_MAX_IE_SIZE)\n\t\t\treturn -EINVAL;\n\t\tmemcpy(ie->ie_buffer + le16_to_cpu(ie->ie_length),\n\t\t vs_ie, vs_ie->len + 2);\n\t\tle16_unaligned_add_cpu(&ie->ie_length, vs_ie->len + 2);\n\t\tie->mgmt_subtype_mask = cpu_to_le16(mask);\n\t\tie->ie_index = cpu_to_le16(MWIFIEX_AUTO_IDX_MASK);\n\t}\n\n\t*ie_ptr = ie;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb,\n\t\t\t\t struct udphdr *uh)\n{\n\tstruct udp_offload_priv *uo_priv;\n\tstruct sk_buff *p, **pp = NULL;\n\tstruct udphdr *uh2;\n\tunsigned int off = skb_gro_offset(skb);\n\tint flush = 1;\n\n\tif (NAPI_GRO_CB(skb)->udp_mark ||\n\t (skb->ip_summed != CHECKSUM_PARTIAL &&\n\t NAPI_GRO_CB(skb)->csum_cnt == 0 &&\n\t !NAPI_GRO_CB(skb)->csum_valid))\n\t\tgoto out;\n\n\t/* mark that this skb passed once through the udp gro layer */\n\tNAPI_GRO_CB(skb)->udp_mark = 1;\n\n\trcu_read_lock();\n\tuo_priv = rcu_dereference(udp_offload_base);\n\tfor (; uo_priv != NULL; uo_priv = rcu_dereference(uo_priv->next)) {\n\t\tif (net_eq(read_pnet(&uo_priv->net), dev_net(skb->dev)) &&\n\t\t uo_priv->offload->port == uh->dest &&\n\t\t uo_priv->offload->callbacks.gro_receive)\n\t\t\tgoto unflush;\n\t}\n\tgoto out_unlock;\n\nunflush:\n\tflush = 0;\n\n\tfor (p = *head; p; p = p->next) {\n\t\tif (!NAPI_GRO_CB(p)->same_flow)\n\t\t\tcontinue;\n\n\t\tuh2 = (struct udphdr *)(p->data + off);\n\n\t\t/* Match ports and either checksums are either both zero\n\t\t * or nonzero.\n\t\t */\n\t\tif ((*(u32 *)&uh->source != *(u32 *)&uh2->source) ||\n\t\t (!uh->check ^ !uh2->check)) {\n\t\t\tNAPI_GRO_CB(p)->same_flow = 0;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tskb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */\n\tskb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));\n\tNAPI_GRO_CB(skb)->proto = uo_priv->offload->ipproto;\n\tpp = uo_priv->offload->callbacks.gro_receive(head, skb,\n\t\t\t\t\t\t uo_priv->offload);\n\nout_unlock:\n\trcu_read_unlock();\nout:\n\tNAPI_GRO_CB(skb)->flush |= flush;\n\treturn pp;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,\n\t\t\t\t int op_flag,\n\t\t\t\t unsigned int size,\n\t\t\t\t unsigned int __user *tlv)\n{\n\tstruct user_element *ue = kcontrol->private_data;\n\tint change = 0;\n\tvoid *new_data;\n\n\tif (op_flag > 0) {\n\t\tif (size > 1024 * 128)\t/* sane value */\n\t\t\treturn -EINVAL;\n\n\t\tnew_data = memdup_user(tlv, size);\n\t\tif (IS_ERR(new_data))\n\t\t\treturn PTR_ERR(new_data);\n\t\tmutex_lock(&ue->card->user_ctl_lock);\n\t\tchange = ue->tlv_data_size != size;\n\t\tif (!change)\n\t\t\tchange = memcmp(ue->tlv_data, new_data, size);\n\t\tkfree(ue->tlv_data);\n\t\tue->tlv_data = new_data;\n\t\tue->tlv_data_size = size;\n\t\tmutex_unlock(&ue->card->user_ctl_lock);\n\t} else {\n\t\tint ret = 0;\n\n\t\tmutex_lock(&ue->card->user_ctl_lock);\n\t\tif (!ue->tlv_data_size || !ue->tlv_data) {\n\t\t\tret = -ENXIO;\n\t\t\tgoto err_unlock;\n\t\t}\n\t\tif (size < ue->tlv_data_size) {\n\t\t\tret = -ENOSPC;\n\t\t\tgoto err_unlock;\n\t\t}\n\t\tif (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size))\n\t\t\tret = -EFAULT;\nerr_unlock:\n\t\tmutex_unlock(&ue->card->user_ctl_lock);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn change;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)\n{\n#ifdef HAVE_KSID\n\tksid_t\t\t*ksid = crgetsid(cr, KSID_GROUP);\n\tksidlist_t\t*ksidlist = crgetsidlist(cr);\n\tuid_t\t\tgid;\n\n\tif (ksid && ksidlist) {\n\t\tint\t\ti;\n\t\tksid_t\t\t*ksid_groups;\n\t\tuint32_t\tidx = FUID_INDEX(id);\n\t\tuint32_t\trid = FUID_RID(id);\n\n\t\tksid_groups = ksidlist->ksl_sids;\n\n\t\tfor (i = 0; i != ksidlist->ksl_nsid; i++) {\n\t\t\tif (idx == 0) {\n\t\t\t\tif (id != IDMAP_WK_CREATOR_GROUP_GID &&\n\t\t\t\t id == ksid_groups[i].ks_id) {\n\t\t\t\t\treturn (B_TRUE);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst char *domain;\n\n\t\t\t\tdomain = zfs_fuid_find_by_idx(zfsvfs, idx);\n\t\t\t\tASSERT(domain != NULL);\n\n\t\t\t\tif (strcmp(domain,\n\t\t\t\t IDMAP_WK_CREATOR_SID_AUTHORITY) == 0)\n\t\t\t\t\treturn (B_FALSE);\n\n\t\t\t\tif ((strcmp(domain,\n\t\t\t\t ksid_groups[i].ks_domain->kd_name) == 0) &&\n\t\t\t\t rid == ksid_groups[i].ks_rid)\n\t\t\t\t\treturn (B_TRUE);\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Not found in ksidlist, check posix groups\n\t */\n\tgid = zfs_fuid_map_id(zfsvfs, id, cr, ZFS_GROUP);\n\treturn (groupmember(gid, cr));\n#else\n\treturn (B_TRUE);\n#endif\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "vulnerable"} {"code": "chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)\n{\n\tu_int proto;\n\tconst u_char *bp = p;\n\n\tif (length < CHDLC_HDRLEN)\n\t\tgoto trunc;\n\tND_TCHECK2(*p, CHDLC_HDRLEN);\n\tproto = EXTRACT_16BITS(&p[2]);\n\tif (ndo->ndo_eflag) {\n ND_PRINT((ndo, \"%s, ethertype %s (0x%04x), length %u: \",\n tok2str(chdlc_cast_values, \"0x%02x\", p[0]),\n tok2str(ethertype_values, \"Unknown\", proto),\n proto,\n length));\n\t}\n\n\tlength -= CHDLC_HDRLEN;\n\tp += CHDLC_HDRLEN;\n\n\tswitch (proto) {\n\tcase ETHERTYPE_IP:\n\t\tip_print(ndo, p, length);\n\t\tbreak;\n\tcase ETHERTYPE_IPV6:\n\t\tip6_print(ndo, p, length);\n\t\tbreak;\n\tcase CHDLC_TYPE_SLARP:\n\t\tchdlc_slarp_print(ndo, p, length);\n\t\tbreak;\n#if 0\n\tcase CHDLC_TYPE_CDP:\n\t\tchdlc_cdp_print(p, length);\n\t\tbreak;\n#endif\n case ETHERTYPE_MPLS:\n case ETHERTYPE_MPLS_MULTI:\n mpls_print(ndo, p, length);\n\t\tbreak;\n case ETHERTYPE_ISO:\n /* is the fudge byte set ? lets verify by spotting ISO headers */\n if (length < 2)\n goto trunc;\n ND_TCHECK_16BITS(p);\n if (*(p+1) == 0x81 ||\n *(p+1) == 0x82 ||\n *(p+1) == 0x83)\n isoclns_print(ndo, p + 1, length - 1);\n else\n isoclns_print(ndo, p, length);\n break;\n\tdefault:\n if (!ndo->ndo_eflag)\n ND_PRINT((ndo, \"unknown CHDLC protocol (0x%04x)\", proto));\n break;\n\t}\n\n\treturn (CHDLC_HDRLEN);\n\ntrunc:\n\tND_PRINT((ndo, \"[|chdlc]\"));\n\treturn ndo->ndo_snapend - bp;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateDoubleArray(const double *numbers,int count)\t{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "static inline int cipso_v4_validate(const struct sk_buff *skb,\n\t\t\t\t unsigned char **option)\n{\n\tunsigned char *opt = *option;\n\tunsigned char err_offset = 0;\n\tu8 opt_len = opt[1];\n\tu8 opt_iter;\n\n\tif (opt_len < 8) {\n\t\terr_offset = 1;\n\t\tgoto out;\n\t}\n\n\tif (get_unaligned_be32(&opt[2]) == 0) {\n\t\terr_offset = 2;\n\t\tgoto out;\n\t}\n\n\tfor (opt_iter = 6; opt_iter < opt_len;) {\n\t\tif (opt[opt_iter + 1] > (opt_len - opt_iter)) {\n\t\t\terr_offset = opt_iter + 1;\n\t\t\tgoto out;\n\t\t}\n\t\topt_iter += opt[opt_iter + 1];\n\t}\n\nout:\n\t*option = opt + err_offset;\n\treturn err_offset;\n\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2)\n{\n int32 r1, g1, b1, a1, r2, g2, b2, a2, mask;\n float fltsize = Fltsize;\n\n#define CLAMP(v) ( (v<(float)0.) ? 0\t\t\t\t\\\n\t\t : (v<(float)2.) ? FromLT2[(int)(v*fltsize)]\t\\\n\t\t : (v>(float)24.2) ? 2047\t\t\t\\\n\t\t : LogK1*log(v*LogK2) + 0.5 )\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = (uint16) CLAMP(ip[0]);\n\t g2 = wp[1] = (uint16) CLAMP(ip[1]);\n\t b2 = wp[2] = (uint16) CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\twp += 3;\n\t\tip += 3;\n\t\tr1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = (uint16) CLAMP(ip[0]);\n\t g2 = wp[1] = (uint16) CLAMP(ip[1]);\n\t b2 = wp[2] = (uint16) CLAMP(ip[2]);\n\t a2 = wp[3] = (uint16) CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\twp += 4;\n\t\tip += 4;\n\t\tr1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = (int32) CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1;\n\t }\n\t} else {\n\t ip += n - 1;\t/* point to last one */\n\t wp += n - 1;\t/* point to last one */\n\t n -= stride;\n\t while (n > 0) {\n\t\tREPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]);\n\t\t\t\twp[stride] -= wp[0];\n\t\t\t\twp[stride] &= mask;\n\t\t\t\twp--; ip--)\n\t\tn -= stride;\n\t }\n\t REPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]); wp--; ip--)\n\t}\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int validate_user_key(struct fscrypt_info *crypt_info,\n\t\t\tstruct fscrypt_context *ctx, u8 *raw_key,\n\t\t\tconst char *prefix)\n{\n\tchar *description;\n\tstruct key *keyring_key;\n\tstruct fscrypt_key *master_key;\n\tconst struct user_key_payload *ukp;\n\tint res;\n\n\tdescription = kasprintf(GFP_NOFS, \"%s%*phN\", prefix,\n\t\t\t\tFS_KEY_DESCRIPTOR_SIZE,\n\t\t\t\tctx->master_key_descriptor);\n\tif (!description)\n\t\treturn -ENOMEM;\n\n\tkeyring_key = request_key(&key_type_logon, description, NULL);\n\tkfree(description);\n\tif (IS_ERR(keyring_key))\n\t\treturn PTR_ERR(keyring_key);\n\n\tif (keyring_key->type != &key_type_logon) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key type must be logon\\n\", __func__);\n\t\tres = -ENOKEY;\n\t\tgoto out;\n\t}\n\tdown_read(&keyring_key->sem);\n\tukp = user_key_payload(keyring_key);\n\tif (ukp->datalen != sizeof(struct fscrypt_key)) {\n\t\tres = -EINVAL;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tmaster_key = (struct fscrypt_key *)ukp->data;\n\tBUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);\n\n\tif (master_key->size != FS_AES_256_XTS_KEY_SIZE) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key size incorrect: %d\\n\",\n\t\t\t\t__func__, master_key->size);\n\t\tres = -ENOKEY;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tres = derive_key_aes(ctx->nonce, master_key->raw, raw_key);\n\tup_read(&keyring_key->sem);\n\tif (res)\n\t\tgoto out;\n\n\tcrypt_info->ci_keyring_key = keyring_key;\n\treturn 0;\nout:\n\tkey_put(keyring_key);\n\treturn res;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static void utee_param_to_param(struct tee_ta_param *p, struct utee_params *up)\n{\n\tsize_t n;\n\tuint32_t types = up->types;\n\n\tp->types = types;\n\tfor (n = 0; n < TEE_NUM_PARAMS; n++) {\n\t\tuintptr_t a = up->vals[n * 2];\n\t\tsize_t b = up->vals[n * 2 + 1];\n\n\t\tswitch (TEE_PARAM_TYPE_GET(types, n)) {\n\t\tcase TEE_PARAM_TYPE_MEMREF_INPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_OUTPUT:\n\t\tcase TEE_PARAM_TYPE_MEMREF_INOUT:\n\t\t\tp->u[n].mem.mobj = &mobj_virt;\n\t\t\tp->u[n].mem.offs = a;\n\t\t\tp->u[n].mem.size = b;\n\t\t\tbreak;\n\t\tcase TEE_PARAM_TYPE_VALUE_INPUT:\n\t\tcase TEE_PARAM_TYPE_VALUE_INOUT:\n\t\t\tp->u[n].val.a = a;\n\t\t\tp->u[n].val.b = b;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmemset(&p->u[n], 0, sizeof(p->u[n]));\n\t\t\tbreak;\n\t\t}\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int set_evtchn_to_irq(evtchn_port_t evtchn, unsigned int irq)\n{\n\tunsigned row;\n\tunsigned col;\n\n\tif (evtchn >= xen_evtchn_max_channels())\n\t\treturn -EINVAL;\n\n\trow = EVTCHN_ROW(evtchn);\n\tcol = EVTCHN_COL(evtchn);\n\n\tif (evtchn_to_irq[row] == NULL) {\n\t\t/* Unallocated irq entries return -1 anyway */\n\t\tif (irq == -1)\n\t\t\treturn 0;\n\n\t\tevtchn_to_irq[row] = (int *)get_zeroed_page(GFP_KERNEL);\n\t\tif (evtchn_to_irq[row] == NULL)\n\t\t\treturn -ENOMEM;\n\n\t\tclear_evtchn_to_irq_row(row);\n\t}\n\n\tevtchn_to_irq[row][col] = irq;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)\n{\n\tstruct key *key;\n\tkey_ref_t key_ref;\n\tlong ret;\n\n\t/* find the key first */\n\tkey_ref = lookup_user_key(keyid, 0, 0);\n\tif (IS_ERR(key_ref)) {\n\t\tret = -ENOKEY;\n\t\tgoto error;\n\t}\n\n\tkey = key_ref_to_ptr(key_ref);\n\n\t/* see if we can read it directly */\n\tret = key_permission(key_ref, KEY_NEED_READ);\n\tif (ret == 0)\n\t\tgoto can_read_key;\n\tif (ret != -EACCES)\n\t\tgoto error;\n\n\t/* we can't; see if it's searchable from this process's keyrings\n\t * - we automatically take account of the fact that it may be\n\t * dangling off an instantiation key\n\t */\n\tif (!is_key_possessed(key_ref)) {\n\t\tret = -EACCES;\n\t\tgoto error2;\n\t}\n\n\t/* the key is probably readable - now try to read it */\ncan_read_key:\n\tret = -EOPNOTSUPP;\n\tif (key->type->read) {\n\t\t/* Read the data with the semaphore held (since we might sleep)\n\t\t * to protect against the key being updated or revoked.\n\t\t */\n\t\tdown_read(&key->sem);\n\t\tret = key_validate(key);\n\t\tif (ret == 0)\n\t\t\tret = key->type->read(key, buffer, buflen);\n\t\tup_read(&key->sem);\n\t}\n\nerror2:\n\tkey_put(key);\nerror:\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static int rock_continue(struct rock_state *rs)\n{\n\tint ret = 1;\n\tint blocksize = 1 << rs->inode->i_blkbits;\n\tconst int min_de_size = offsetof(struct rock_ridge, u);\n\n\tkfree(rs->buffer);\n\trs->buffer = NULL;\n\n\tif ((unsigned)rs->cont_offset > blocksize - min_de_size ||\n\t (unsigned)rs->cont_size > blocksize ||\n\t (unsigned)(rs->cont_offset + rs->cont_size) > blocksize) {\n\t\tprintk(KERN_NOTICE \"rock: corrupted directory entry. \"\n\t\t\t\"extent=%d, offset=%d, size=%d\\n\",\n\t\t\trs->cont_extent, rs->cont_offset, rs->cont_size);\n\t\tret = -EIO;\n\t\tgoto out;\n\t}\n\n\tif (rs->cont_extent) {\n\t\tstruct buffer_head *bh;\n\n\t\trs->buffer = kmalloc(rs->cont_size, GFP_KERNEL);\n\t\tif (!rs->buffer) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t\tret = -EIO;\n\t\tif (++rs->cont_loops >= RR_MAX_CE_ENTRIES)\n\t\t\tgoto out;\n\t\tbh = sb_bread(rs->inode->i_sb, rs->cont_extent);\n\t\tif (bh) {\n\t\t\tmemcpy(rs->buffer, bh->b_data + rs->cont_offset,\n\t\t\t\t\trs->cont_size);\n\t\t\tput_bh(bh);\n\t\t\trs->chr = rs->buffer;\n\t\t\trs->len = rs->cont_size;\n\t\t\trs->cont_extent = 0;\n\t\t\trs->cont_size = 0;\n\t\t\trs->cont_offset = 0;\n\t\t\treturn 0;\n\t\t}\n\t\tprintk(\"Unable to read rock-ridge attributes\\n\");\n\t}\nout:\n\tkfree(rs->buffer);\n\trs->buffer = NULL;\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "void inode_init_owner(struct inode *inode, const struct inode *dir,\n\t\t\tumode_t mode)\n{\n\tinode->i_uid = current_fsuid();\n\tif (dir && dir->i_mode & S_ISGID) {\n\t\tinode->i_gid = dir->i_gid;\n\n\t\t/* Directories are special, and always inherit S_ISGID */\n\t\tif (S_ISDIR(mode))\n\t\t\tmode |= S_ISGID;\n\t\telse if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&\n\t\t\t !in_group_p(inode->i_gid) &&\n\t\t\t !capable_wrt_inode_uidgid(dir, CAP_FSETID))\n\t\t\tmode &= ~S_ISGID;\n\t} else\n\t\tinode->i_gid = current_fsgid();\n\tinode->i_mode = mode;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,\n\t\t void *buffer, size_t buffer_size)\n{\n\tstruct buffer_head *bh = NULL;\n\tstruct ext4_xattr_entry *entry;\n\tsize_t size;\n\tint error;\n\tstruct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);\n\n\tea_idebug(inode, \"name=%d.%s, buffer=%p, buffer_size=%ld\",\n\t\t name_index, name, buffer, (long)buffer_size);\n\n\terror = -ENODATA;\n\tif (!EXT4_I(inode)->i_file_acl)\n\t\tgoto cleanup;\n\tea_idebug(inode, \"reading block %llu\",\n\t\t (unsigned long long)EXT4_I(inode)->i_file_acl);\n\tbh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);\n\tif (!bh)\n\t\tgoto cleanup;\n\tea_bdebug(bh, \"b_count=%d, refcount=%d\",\n\t\tatomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));\n\tif (ext4_xattr_check_block(inode, bh)) {\nbad_block:\n\t\tEXT4_ERROR_INODE(inode, \"bad block %llu\",\n\t\t\t\t EXT4_I(inode)->i_file_acl);\n\t\terror = -EFSCORRUPTED;\n\t\tgoto cleanup;\n\t}\n\text4_xattr_cache_insert(ext4_mb_cache, bh);\n\tentry = BFIRST(bh);\n\terror = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);\n\tif (error == -EFSCORRUPTED)\n\t\tgoto bad_block;\n\tif (error)\n\t\tgoto cleanup;\n\tsize = le32_to_cpu(entry->e_value_size);\n\tif (buffer) {\n\t\terror = -ERANGE;\n\t\tif (size > buffer_size)\n\t\t\tgoto cleanup;\n\t\tmemcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),\n\t\t size);\n\t}\n\terror = size;\n\ncleanup:\n\tbrelse(bh);\n\treturn error;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "vulnerable"} {"code": "static void make_response(struct xen_blkif_ring *ring, u64 id,\n\t\t\t unsigned short op, int st)\n{\n\tstruct blkif_response resp;\n\tunsigned long flags;\n\tunion blkif_back_rings *blk_rings;\n\tint notify;\n\n\tresp.id = id;\n\tresp.operation = op;\n\tresp.status = st;\n\n\tspin_lock_irqsave(&ring->blk_ring_lock, flags);\n\tblk_rings = &ring->blk_rings;\n\t/* Place on the response ring for the relevant domain. */\n\tswitch (ring->blkif->blk_protocol) {\n\tcase BLKIF_PROTOCOL_NATIVE:\n\t\tmemcpy(RING_GET_RESPONSE(&blk_rings->native, blk_rings->native.rsp_prod_pvt),\n\t\t &resp, sizeof(resp));\n\t\tbreak;\n\tcase BLKIF_PROTOCOL_X86_32:\n\t\tmemcpy(RING_GET_RESPONSE(&blk_rings->x86_32, blk_rings->x86_32.rsp_prod_pvt),\n\t\t &resp, sizeof(resp));\n\t\tbreak;\n\tcase BLKIF_PROTOCOL_X86_64:\n\t\tmemcpy(RING_GET_RESPONSE(&blk_rings->x86_64, blk_rings->x86_64.rsp_prod_pvt),\n\t\t &resp, sizeof(resp));\n\t\tbreak;\n\tdefault:\n\t\tBUG();\n\t}\n\tblk_rings->common.rsp_prod_pvt++;\n\tRING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify);\n\tspin_unlock_irqrestore(&ring->blk_ring_lock, flags);\n\tif (notify)\n\t\tnotify_remote_via_irq(ring->irq);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "static void account_pipe_buffers(struct pipe_inode_info *pipe,\n unsigned long old, unsigned long new)\n{\n\tatomic_long_add(new - old, &pipe->user->pipe_bufs);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "mp_join_print(netdissect_options *ndo,\n const u_char *opt, u_int opt_len, u_char flags)\n{\n const struct mp_join *mpj = (const struct mp_join *) opt;\n\n if (!(opt_len == 12 && (flags & TH_SYN)) &&\n !(opt_len == 16 && (flags & (TH_SYN | TH_ACK)) == (TH_SYN | TH_ACK)) &&\n !(opt_len == 24 && (flags & TH_ACK)))\n return 0;\n\n if (opt_len != 24) {\n if (mpj->sub_b & MP_JOIN_B)\n ND_PRINT((ndo, \" backup\"));\n ND_PRINT((ndo, \" id %u\", mpj->addr_id));\n }\n\n switch (opt_len) {\n case 12: /* SYN */\n ND_PRINT((ndo, \" token 0x%x\" \" nonce 0x%x\",\n EXTRACT_32BITS(mpj->u.syn.token),\n EXTRACT_32BITS(mpj->u.syn.nonce)));\n break;\n case 16: /* SYN/ACK */\n ND_PRINT((ndo, \" hmac 0x%\" PRIx64 \" nonce 0x%x\",\n EXTRACT_64BITS(mpj->u.synack.mac),\n EXTRACT_32BITS(mpj->u.synack.nonce)));\n break;\n case 24: {/* ACK */\n size_t i;\n ND_PRINT((ndo, \" hmac 0x\"));\n for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)\n ND_PRINT((ndo, \"%02x\", mpj->u.ack.mac[i]));\n }\n default:\n break;\n }\n return 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int main()\n{\n gdImagePtr im;\n char *buffer;\n size_t size;\n\n size = read_test_file(&buffer, \"heap_overflow.tga\");\n im = gdImageCreateFromTgaPtr(size, (void *) buffer);\n gdTestAssert(im == NULL);\n free(buffer);\n\n return gdNumFailures();\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)\n{\n\tunsigned len;\n\tint i;\n\n\tif (!access_ok(VERIFY_WRITE, name, namelen))\n\t\treturn -EFAULT;\n\n\tlen = namelen;\n\tif (len > 32)\n\t\tlen = 32;\n\n\tdown_read(&uts_sem);\n\tfor (i = 0; i < len; ++i) {\n\t\t__put_user(utsname()->domainname[i], name + i);\n\t\tif (utsname()->domainname[i] == '\\0')\n\t\t\tbreak;\n\t}\n\tup_read(&uts_sem);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "int main(int argc, char **argv)\n{\n\tint opt;\n\tuid_t uid = geteuid();\n\tgid_t gid = getgid();\n\tmode_t mode = 0;\n\tstruct passwd *pw = NULL;\n\tstruct group *gr = NULL;\n\tinode_t type = inode_unknown;\n\tint retval = EXIT_SUCCESS;\n\tbool trunc = false;\n\tbool chowner = false;\n\tbool symlinks = false;\n\tbool writable = false;\n\tbool selinux_on = false;\n\n\tapplet = basename_c(argv[0]);\n\twhile ((opt = getopt_long(argc, argv, getoptstring,\n\t\t longopts, (int *) 0)) != -1)\n\t{\n\t\tswitch (opt) {\n\t\tcase 'D':\n\t\t\ttrunc = true;\n\t\t\t/* falls through */\n\t\tcase 'd':\n\t\t\ttype = inode_dir;\n\t\t\tbreak;\n\t\tcase 'F':\n\t\t\ttrunc = true;\n\t\t\t/* falls through */\n\t\tcase 'f':\n\t\t\ttype = inode_file;\n\t\t\tbreak;\n\t\tcase 'p':\n\t\t\ttype = inode_fifo;\n\t\t\tbreak;\n\t\tcase 'm':\n\t\t\tif (parse_mode(&mode, optarg) != 0)\n\t\t\t\teerrorx(\"%s: invalid mode `%s'\",\n\t\t\t\t applet, optarg);\n\t\t\tbreak;\n\t\tcase 'o':\n\t\t\tchowner = true;\n\t\t\tif (parse_owner(&pw, &gr, optarg) != 0)\n\t\t\t\teerrorx(\"%s: owner `%s' not found\",\n\t\t\t\t applet, optarg);\n\t\t\tbreak;\n\t\tcase 's':\n#ifndef O_PATH\n\t\t\tsymlinks = true;\n#endif\n\t\t\tbreak;\n\t\tcase 'W':\n\t\t\twritable = true;\n\t\t\tbreak;\n\n\t\tcase_RC_COMMON_GETOPT\n\t\t}\n\t}\n\n\tif (optind >= argc)\n\t\tusage(EXIT_FAILURE);\n\n\tif (writable && type != inode_unknown)\n\t\teerrorx(\"%s: -W cannot be specified along with -d, -f or -p\", applet);\n\n\tif (pw) {\n\t\tuid = pw->pw_uid;\n\t\tgid = pw->pw_gid;\n\t}\n\tif (gr)\n\t\tgid = gr->gr_gid;\n\n\tif (selinux_util_open() == 1)\n\t\tselinux_on = true;\n\n\twhile (optind < argc) {\n\t\tif (writable)\n\t\t\texit(!is_writable(argv[optind]));\n\t\tif (do_check(argv[optind], uid, gid, mode, type, trunc, chowner,\n\t\t\t\t\tsymlinks, selinux_on))\n\t\t\tretval = EXIT_FAILURE;\n\t\toptind++;\n\t}\n\n\tif (selinux_on)\n\t\tselinux_util_close();\n\n\treturn retval;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "check_vim9_unlet(char_u *name)\n{\n if (*name == NUL)\n {\n\tsemsg(_(e_argument_required_for_str), \"unlet\");\n\treturn FAIL;\n }\n\n if (name[1] != ':' || vim_strchr((char_u *)\"gwtb\", *name) == NULL)\n {\n\t// \"unlet s:var\" is allowed in legacy script.\n\tif (*name == 's' && !script_is_vim9())\n\t return OK;\n\tsemsg(_(e_cannot_unlet_str), name);\n\treturn FAIL;\n }\n return OK;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static u64 distribute_cfs_runtime(struct cfs_bandwidth *cfs_b,\n\t\tu64 remaining, u64 expires)\n{\n\tstruct cfs_rq *cfs_rq;\n\tu64 runtime;\n\tu64 starting_runtime = remaining;\n\n\trcu_read_lock();\n\tlist_for_each_entry_rcu(cfs_rq, &cfs_b->throttled_cfs_rq,\n\t\t\t\tthrottled_list) {\n\t\tstruct rq *rq = rq_of(cfs_rq);\n\t\tstruct rq_flags rf;\n\n\t\trq_lock_irqsave(rq, &rf);\n\t\tif (!cfs_rq_throttled(cfs_rq))\n\t\t\tgoto next;\n\n\t\truntime = -cfs_rq->runtime_remaining + 1;\n\t\tif (runtime > remaining)\n\t\t\truntime = remaining;\n\t\tremaining -= runtime;\n\n\t\tcfs_rq->runtime_remaining += runtime;\n\t\tcfs_rq->runtime_expires = expires;\n\n\t\t/* we check whether we're throttled above */\n\t\tif (cfs_rq->runtime_remaining > 0)\n\t\t\tunthrottle_cfs_rq(cfs_rq);\n\nnext:\n\t\trq_unlock_irqrestore(rq, &rf);\n\n\t\tif (!remaining)\n\t\t\tbreak;\n\t}\n\trcu_read_unlock();\n\n\treturn starting_runtime - remaining;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,\n\t\t\tint len)\n{\n\tint r;\n\tunsigned long addr;\n\n\taddr = gfn_to_hva(kvm, gfn);\n\tif (kvm_is_error_hva(addr))\n\t\treturn -EFAULT;\n\tr = __copy_from_user(data, (void __user *)addr + offset, len);\n\tif (r)\n\t\treturn -EFAULT;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "horizontalDifference16(unsigned short *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From14)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n/* assumption is unsigned pixel values */\n#undef CLAMP\n#define CLAMP(v) From14[(v) >> 2]\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\twp += 3;\n\t\tip += 3;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\twp += 4;\n\t\tip += 4;\n\t\tr1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1;\n\t }\n\t} else {\n REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)\n\t n -= stride;\n\t while (n > 0) {\n REPEAT(stride,\n wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);\n wp++; ip++)\n n -= stride;\n }\n\t}\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static void get_sem_elements(struct sem_data *p)\n{\n\tsize_t i;\n\n\tif (!p || !p->sem_nsems || p->sem_nsems > SIZE_MAX || p->sem_perm.id < 0)\n\t\treturn;\n\n\tp->elements = xcalloc(p->sem_nsems, sizeof(struct sem_elem));\n\n\tfor (i = 0; i < p->sem_nsems; i++) {\n\t\tstruct sem_elem *e = &p->elements[i];\n\t\tunion semun arg = { .val = 0 };\n\n\t\te->semval = semctl(p->sem_perm.id, i, GETVAL, arg);\n\t\tif (e->semval < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETVAL)\");\n\n\t\te->ncount = semctl(p->sem_perm.id, i, GETNCNT, arg);\n\t\tif (e->ncount < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETNCNT)\");\n\n\t\te->zcount = semctl(p->sem_perm.id, i, GETZCNT, arg);\n\t\tif (e->zcount < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETZCNT)\");\n\n\t\te->pid = semctl(p->sem_perm.id, i, GETPID, arg);\n\t\tif (e->pid < 0)\n\t\t\terr(EXIT_FAILURE, _(\"%s failed\"), \"semctl(GETPID)\");\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static void ext4_free_io_end(ext4_io_end_t *io)\n{\n\tBUG_ON(!io);\n\tiput(io->inode);\n\tkfree(io);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static ssize_t fuse_fill_write_pages(struct fuse_req *req,\n\t\t\t struct address_space *mapping,\n\t\t\t struct iov_iter *ii, loff_t pos)\n{\n\tstruct fuse_conn *fc = get_fuse_conn(mapping->host);\n\tunsigned offset = pos & (PAGE_CACHE_SIZE - 1);\n\tsize_t count = 0;\n\tint err;\n\n\treq->in.argpages = 1;\n\treq->page_descs[0].offset = offset;\n\n\tdo {\n\t\tsize_t tmp;\n\t\tstruct page *page;\n\t\tpgoff_t index = pos >> PAGE_CACHE_SHIFT;\n\t\tsize_t bytes = min_t(size_t, PAGE_CACHE_SIZE - offset,\n\t\t\t\t iov_iter_count(ii));\n\n\t\tbytes = min_t(size_t, bytes, fc->max_write - count);\n\n again:\n\t\terr = -EFAULT;\n\t\tif (iov_iter_fault_in_readable(ii, bytes))\n\t\t\tbreak;\n\n\t\terr = -ENOMEM;\n\t\tpage = grab_cache_page_write_begin(mapping, index, 0);\n\t\tif (!page)\n\t\t\tbreak;\n\n\t\tif (mapping_writably_mapped(mapping))\n\t\t\tflush_dcache_page(page);\n\n\t\ttmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);\n\t\tflush_dcache_page(page);\n\n\t\tiov_iter_advance(ii, tmp);\n\t\tif (!tmp) {\n\t\t\tunlock_page(page);\n\t\t\tpage_cache_release(page);\n\t\t\tbytes = min(bytes, iov_iter_single_seg_count(ii));\n\t\t\tgoto again;\n\t\t}\n\n\t\terr = 0;\n\t\treq->pages[req->num_pages] = page;\n\t\treq->page_descs[req->num_pages].length = tmp;\n\t\treq->num_pages++;\n\n\t\tcount += tmp;\n\t\tpos += tmp;\n\t\toffset += tmp;\n\t\tif (offset == PAGE_CACHE_SIZE)\n\t\t\toffset = 0;\n\n\t\tif (!fc->big_writes)\n\t\t\tbreak;\n\t} while (iov_iter_count(ii) && count < fc->max_write &&\n\t\t req->num_pages < req->max_pages && offset == 0);\n\n\treturn count > 0 ? count : err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "safe"} {"code": "smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)\n{\n\tunsigned char key2[8];\n\tstruct crypto_cipher *tfm_des;\n\n\tstr_to_key(key, key2);\n\n\ttfm_des = crypto_alloc_cipher(\"des\", 0, 0);\n\tif (IS_ERR(tfm_des)) {\n\t\tcifs_dbg(VFS, \"could not allocate des crypto API\\n\");\n\t\treturn PTR_ERR(tfm_des);\n\t}\n\n\tcrypto_cipher_setkey(tfm_des, key2, 8);\n\tcrypto_cipher_encrypt_one(tfm_des, out, in);\n\tcrypto_free_cipher(tfm_des);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "GF_AV1Config *gf_isom_av1_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex)\n{\n\tGF_TrackBox *trak;\n\tGF_MPEGVisualSampleEntryBox *entry;\n\tif (gf_isom_get_reference_count(the_file, trackNumber, GF_ISOM_REF_TBAS)) {\n\t\tu32 ref_track;\n\t\tGF_Err e = gf_isom_get_reference(the_file, trackNumber, GF_ISOM_REF_TBAS, 1, &ref_track);\n\t\tif (e == GF_OK) {\n\t\t\ttrackNumber = ref_track;\n\t\t}\n\t}\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !trak->Media || !DescriptionIndex) return NULL;\n\tentry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex - 1);\n\tif (!entry || !entry->av1_config) return NULL;\n\treturn AV1_DuplicateConfig(entry->av1_config->config);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "LIBOPENMPT_MODPLUG_API unsigned int ModPlug_SampleName(ModPlugFile* file, unsigned int qual, char* buff)\n{\n\tconst char* str;\n\tunsigned int retval;\n\tsize_t tmpretval;\n\tif(!file) return 0;\n\tstr = openmpt_module_get_sample_name(file->mod,qual-1);\n\tif(!str){\n\t\tif(buff){\n\t\t\t*buff = '\\0';\n\t\t}\n\t\treturn 0;\n\t}\n\ttmpretval = strlen(str);\n\tif(tmpretval>=INT_MAX){\n\t\ttmpretval = INT_MAX-1;\n\t}\n\tretval = (int)tmpretval;\n\tif(buff){\n\t\tmemcpy(buff,str,retval+1);\n\t\tbuff[retval] = '\\0';\n\t}\n\topenmpt_free_string(str);\n\treturn retval;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "static inline Quantum ClampPixel(const MagickRealType value)\n{\n#if !defined(MAGICKCORE_HDRI_SUPPORT)\n return((Quantum) value);\n#else\n if (value < 0.0)\n return((Quantum) 0.0);\n if (value >= (MagickRealType) QuantumRange)\n return((Quantum) QuantumRange);\n return((Quantum) value);\n#endif\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm,\n\t\t\t unsigned int hdr_off, unsigned int sg,\n\t\t\t unsigned int off)\n{\n\t/* Do not send cong updates to loopback */\n\tif (rm->m_inc.i_hdr.h_flags & RDS_FLAG_CONG_BITMAP) {\n\t\trds_cong_map_updated(conn->c_fcong, ~(u64) 0);\n\t\treturn sizeof(struct rds_header) + RDS_CONG_MAP_BYTES;\n\t}\n\n\tBUG_ON(hdr_off || sg || off);\n\n\trds_inc_init(&rm->m_inc, conn, conn->c_laddr);\n\t/* For the embedded inc. Matching put is in loop_inc_free() */\n\trds_message_addref(rm);\n\n\trds_recv_incoming(conn, conn->c_laddr, conn->c_faddr, &rm->m_inc,\n\t\t\t GFP_KERNEL, KM_USER0);\n\n\trds_send_drop_acked(conn, be64_to_cpu(rm->m_inc.i_hdr.h_sequence),\n\t\t\t NULL);\n\n\trds_inc_put(&rm->m_inc);\n\n\treturn sizeof(struct rds_header) + be32_to_cpu(rm->m_inc.i_hdr.h_len);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static int jas_iccputuint(jas_stream_t *out, int n, jas_ulonglong val)\n{\n\tint i;\n\tint c;\n\tfor (i = n; i > 0; --i) {\n\t\tc = (val >> (8 * (i - 1))) & 0xff;\n\t\tif (jas_stream_putc(out, c) == EOF)\n\t\t\treturn -1;\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,\n\t\tconst void __user * __user *, pages,\n\t\tconst int __user *, nodes,\n\t\tint __user *, status, int, flags)\n{\n\tconst struct cred *cred = current_cred(), *tcred;\n\tstruct task_struct *task;\n\tstruct mm_struct *mm;\n\tint err;\n\tnodemask_t task_nodes;\n\n\t/* Check flags */\n\tif (flags & ~(MPOL_MF_MOVE|MPOL_MF_MOVE_ALL))\n\t\treturn -EINVAL;\n\n\tif ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE))\n\t\treturn -EPERM;\n\n\t/* Find the mm_struct */\n\trcu_read_lock();\n\ttask = pid ? find_task_by_vpid(pid) : current;\n\tif (!task) {\n\t\trcu_read_unlock();\n\t\treturn -ESRCH;\n\t}\n\tget_task_struct(task);\n\n\t/*\n\t * Check if this process has the right to modify the specified\n\t * process. The right exists if the process has administrative\n\t * capabilities, superuser privileges or the same\n\t * userid as the target process.\n\t */\n\ttcred = __task_cred(task);\n\tif (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&\n\t !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&\n\t !capable(CAP_SYS_NICE)) {\n\t\trcu_read_unlock();\n\t\terr = -EPERM;\n\t\tgoto out;\n\t}\n\trcu_read_unlock();\n\n \terr = security_task_movememory(task);\n \tif (err)\n\t\tgoto out;\n\n\ttask_nodes = cpuset_mems_allowed(task);\n\tmm = get_task_mm(task);\n\tput_task_struct(task);\n\n\tif (!mm)\n\t\treturn -EINVAL;\n\n\tif (nodes)\n\t\terr = do_pages_move(mm, task_nodes, nr_pages, pages,\n\t\t\t\t nodes, status, flags);\n\telse\n\t\terr = do_pages_stat(mm, nr_pages, pages, status);\n\n\tmmput(mm);\n\treturn err;\n\nout:\n\tput_task_struct(task);\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "usage(void)\n{\n\tfprintf(stderr,\n\t \"usage: ssh-agent [-c | -s] [-Dd] [-a bind_address] [-E fingerprint_hash]\\n\"\n\t \" [-t life] [command [arg ...]]\\n\"\n\t \" ssh-agent [-c | -s] -k\\n\");\n\texit(1);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-426", "cwe_name": "Untrusted Search Path", "description": "The application searches for critical resources using an externally-supplied search path that can point to resources that are not under the application's direct control.", "url": "https://cwe.mitre.org/data/definitions/426.html", "label_name": "vulnerable"} {"code": "int ip_options_get(struct net *net, struct ip_options_rcu **optp,\n\t\t unsigned char *data, int optlen)\n{\n\tstruct ip_options_rcu *opt = ip_options_get_alloc(optlen);\n\n\tif (!opt)\n\t\treturn -ENOMEM;\n\tif (optlen)\n\t\tmemcpy(opt->opt.__data, data, optlen);\n\treturn ip_options_get_finish(net, optp, opt, optlen);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateObject( void )\n{\n\tcJSON *item = cJSON_New_Item();\n\tif ( item )\n\t\titem->type = cJSON_Object;\n\treturn item;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "decode_sequence(const uint8_t *asn1, size_t len, const struct seq_info *seq,\n void *val)\n{\n krb5_error_code ret;\n const uint8_t *contents;\n size_t i, j, clen;\n taginfo t;\n\n assert(seq->n_fields > 0);\n for (i = 0; i < seq->n_fields; i++) {\n if (len == 0)\n break;\n ret = get_tag(asn1, len, &t, &contents, &clen, &asn1, &len);\n if (ret)\n goto error;\n /*\n * Find the applicable sequence field. This logic is a little\n * oversimplified; we could match an element to an optional extensible\n * choice or optional stored-DER type when we ought to match a\n * subsequent non-optional field. But it's unwise and (hopefully) very\n * rare for ASN.1 modules to require such precision.\n */\n for (; i < seq->n_fields; i++) {\n if (check_atype_tag(seq->fields[i], &t))\n break;\n ret = omit_atype(seq->fields[i], val);\n if (ret)\n goto error;\n }\n /* We currently model all sequences as extensible. We should consider\n * changing this before making the encoder visible to plugins. */\n if (i == seq->n_fields)\n break;\n ret = decode_atype(&t, contents, clen, seq->fields[i], val);\n if (ret)\n goto error;\n }\n /* Initialize any fields in the C object which were not accounted for in\n * the sequence. Error out if any of them aren't optional. */\n for (; i < seq->n_fields; i++) {\n ret = omit_atype(seq->fields[i], val);\n if (ret)\n goto error;\n }\n return 0;\n\nerror:\n /* Free what we've decoded so far. Free pointers in a second pass in\n * case multiple fields refer to the same pointer. */\n for (j = 0; j < i; j++)\n free_atype(seq->fields[j], val);\n for (j = 0; j < i; j++)\n free_atype_ptr(seq->fields[j], val);\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "vulnerable"} {"code": "extract_header_length(uint16_t fc)\n{\n\tint len = 0;\n\n\tswitch ((fc >> 10) & 0x3) {\n\tcase 0x00:\n\t\tif (fc & (1 << 6)) /* intra-PAN with none dest addr */\n\t\t\treturn -1;\n\t\tbreak;\n\tcase 0x01:\n\t\treturn -1;\n\tcase 0x02:\n\t\tlen += 4;\n\t\tbreak;\n\tcase 0x03:\n\t\tlen += 10;\n\t\tbreak;\n\t}\n\n\tswitch ((fc >> 14) & 0x3) {\n\tcase 0x00:\n\t\tbreak;\n\tcase 0x01:\n\t\treturn -1;\n\tcase 0x02:\n\t\tlen += 4;\n\t\tbreak;\n\tcase 0x03:\n\t\tlen += 10;\n\t\tbreak;\n\t}\n\n\tif (fc & (1 << 6)) {\n\t\tif (len < 2)\n\t\t\treturn -1;\n\t\tlen -= 2;\n\t}\n\n\treturn len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)\n{\n\tint err = simple_setattr(dentry, iattr);\n\n\tif (!err && (iattr->ia_valid & ATTR_UID)) {\n\t\tstruct socket *sock = SOCKET_I(d_inode(dentry));\n\n\t\tsock->sk->sk_uid = iattr->ia_uid;\n\t}\n\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static int update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, nfs4_stateid *delegation, int open_flags)\n{\n\tstruct nfs_inode *nfsi = NFS_I(state->inode);\n\tstruct nfs_delegation *deleg_cur;\n\tint ret = 0;\n\n\topen_flags &= (FMODE_READ|FMODE_WRITE);\n\n\trcu_read_lock();\n\tdeleg_cur = rcu_dereference(nfsi->delegation);\n\tif (deleg_cur == NULL)\n\t\tgoto no_delegation;\n\n\tspin_lock(&deleg_cur->lock);\n\tif (nfsi->delegation != deleg_cur ||\n\t (deleg_cur->type & open_flags) != open_flags)\n\t\tgoto no_delegation_unlock;\n\n\tif (delegation == NULL)\n\t\tdelegation = &deleg_cur->stateid;\n\telse if (memcmp(deleg_cur->stateid.data, delegation->data, NFS4_STATEID_SIZE) != 0)\n\t\tgoto no_delegation_unlock;\n\n\tnfs_mark_delegation_referenced(deleg_cur);\n\t__update_open_stateid(state, open_stateid, &deleg_cur->stateid, open_flags);\n\tret = 1;\nno_delegation_unlock:\n\tspin_unlock(&deleg_cur->lock);\nno_delegation:\n\trcu_read_unlock();\n\n\tif (!ret && open_stateid != NULL) {\n\t\t__update_open_stateid(state, open_stateid, NULL, open_flags);\n\t\tret = 1;\n\t}\n\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out)\n{\n#if 0\n\tjp2_pclr_t *pclr = &box->data.pclr;\n#endif\n/* Eliminate warning about unused variable. */\nbox = 0;\nout = 0;\n\treturn -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static inline int ext4_should_dioread_nolock(struct inode *inode)\n{\n\tif (!test_opt(inode->i_sb, DIOREAD_NOLOCK))\n\t\treturn 0;\n\tif (test_opt(inode->i_sb, NOBH))\n\t\treturn 0;\n\tif (!S_ISREG(inode->i_mode))\n\t\treturn 0;\n\tif (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))\n\t\treturn 0;\n\tif (ext4_should_journal_data(inode))\n\t\treturn 0;\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "process_bitmap_updates(STREAM s)\n{\n\tuint16 num_updates;\n\tuint16 left, top, right, bottom, width, height;\n\tuint16 cx, cy, bpp, Bpp, compress, bufsize, size;\n\tuint8 *data, *bmpdata;\n\tint i;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\n\tin_uint16_le(s, num_updates);\n\n\tfor (i = 0; i < num_updates; i++)\n\t{\n\t\tin_uint16_le(s, left);\n\t\tin_uint16_le(s, top);\n\t\tin_uint16_le(s, right);\n\t\tin_uint16_le(s, bottom);\n\t\tin_uint16_le(s, width);\n\t\tin_uint16_le(s, height);\n\t\tin_uint16_le(s, bpp);\n\t\tBpp = (bpp + 7) / 8;\n\t\tin_uint16_le(s, compress);\n\t\tin_uint16_le(s, bufsize);\n\n\t\tcx = right - left + 1;\n\t\tcy = bottom - top + 1;\n\n\t\tlogger(Graphics, Debug,\n\t\t \"process_bitmap_updates(), [%d,%d,%d,%d], [%d,%d], bpp=%d, compression=%d\",\n\t\t left, top, right, bottom, width, height, Bpp, compress);\n\n\t\tif (!compress)\n\t\t{\n\t\t\tint y;\n\t\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tin_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],\n\t\t\t\t\t width * Bpp);\n\t\t\t}\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t\txfree(bmpdata);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\tif (compress & 0x400)\n\t\t{\n\t\t\tsize = bufsize;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_uint8s(s, 2);\t/* pad */\n\t\t\tin_uint16_le(s, size);\n\t\t\tin_uint8s(s, 4);\t/* line_size, final_size */\n\t\t}\n\t\tin_uint8p(s, data, size);\n\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\tif (bitmap_decompress(bmpdata, width, height, data, size, Bpp))\n\t\t{\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t \"process_bitmap_updates(), failed to decompress bitmap\");\n\t\t}\n\n\t\txfree(bmpdata);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int readContigStripsIntoBuffer (TIFF* in, uint8* buf)\n{\n uint8* bufp = buf;\n int32 bytes_read = 0;\n uint32 strip, nstrips = TIFFNumberOfStrips(in);\n uint32 stripsize = TIFFStripSize(in);\n uint32 rows = 0;\n uint32 rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps);\n tsize_t scanline_size = TIFFScanlineSize(in);\n\n if (scanline_size == 0) {\n TIFFError(\"\", \"TIFF scanline size is zero!\"); \n return 0;\n }\n\n for (strip = 0; strip < nstrips; strip++) {\n bytes_read = TIFFReadEncodedStrip (in, strip, bufp, -1);\n rows = bytes_read / scanline_size;\n if ((strip < (nstrips - 1)) && (bytes_read != (int32)stripsize))\n TIFFError(\"\", \"Strip %d: read %lu bytes, strip size %lu\",\n (int)strip + 1, (unsigned long) bytes_read,\n (unsigned long)stripsize);\n\n if (bytes_read < 0 && !ignore) {\n TIFFError(\"\", \"Error reading strip %lu after %lu rows\",\n (unsigned long) strip, (unsigned long)rows);\n return 0;\n }\n bufp += bytes_read;\n }\n\n return 1;\n} /* end readContigStripsIntoBuffer */", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)\n{\n\tu64 runtime = 0, slice = sched_cfs_bandwidth_slice();\n\tunsigned long flags;\n\n\t/* confirm we're still not at a refresh boundary */\n\traw_spin_lock_irqsave(&cfs_b->lock, flags);\n\tcfs_b->slack_started = false;\n\tif (cfs_b->distribute_running) {\n\t\traw_spin_unlock_irqrestore(&cfs_b->lock, flags);\n\t\treturn;\n\t}\n\n\tif (runtime_refresh_within(cfs_b, min_bandwidth_expiration)) {\n\t\traw_spin_unlock_irqrestore(&cfs_b->lock, flags);\n\t\treturn;\n\t}\n\n\tif (cfs_b->quota != RUNTIME_INF && cfs_b->runtime > slice)\n\t\truntime = cfs_b->runtime;\n\n\tif (runtime)\n\t\tcfs_b->distribute_running = 1;\n\n\traw_spin_unlock_irqrestore(&cfs_b->lock, flags);\n\n\tif (!runtime)\n\t\treturn;\n\n\truntime = distribute_cfs_runtime(cfs_b, runtime);\n\n\traw_spin_lock_irqsave(&cfs_b->lock, flags);\n\tlsub_positive(&cfs_b->runtime, runtime);\n\tcfs_b->distribute_running = 0;\n\traw_spin_unlock_irqrestore(&cfs_b->lock, flags);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "static enum try_read_result try_read_network(conn *c) {\n enum try_read_result gotdata = READ_NO_DATA_RECEIVED;\n int res;\n\n assert(c != NULL);\n\n if (c->rcurr != c->rbuf) {\n if (c->rbytes != 0) /* otherwise there's nothing to copy */\n memmove(c->rbuf, c->rcurr, c->rbytes);\n c->rcurr = c->rbuf;\n }\n\n while (1) {\n if (c->rbytes >= c->rsize) {\n char *new_rbuf = realloc(c->rbuf, c->rsize * 2);\n if (!new_rbuf) {\n if (settings.verbose > 0)\n fprintf(stderr, \"Couldn't realloc input buffer\\n\");\n c->rbytes = 0; /* ignore what we read */\n out_string(c, \"SERVER_ERROR out of memory reading request\");\n c->write_and_go = conn_closing;\n return READ_MEMORY_ERROR;\n }\n c->rcurr = c->rbuf = new_rbuf;\n c->rsize *= 2;\n }\n\n int avail = c->rsize - c->rbytes;\n res = read(c->sfd, c->rbuf + c->rbytes, avail);\n if (res > 0) {\n pthread_mutex_lock(&c->thread->stats.mutex);\n c->thread->stats.bytes_read += res;\n pthread_mutex_unlock(&c->thread->stats.mutex);\n gotdata = READ_DATA_RECEIVED;\n c->rbytes += res;\n if (res == avail) {\n continue;\n } else {\n break;\n }\n }\n if (res == 0) {\n return READ_ERROR;\n }\n if (res == -1) {\n if (errno == EAGAIN || errno == EWOULDBLOCK) {\n break;\n }\n return READ_ERROR;\n }\n }\n return gotdata;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int pop_sync_mailbox(struct Context *ctx, int *index_hint)\n{\n int i, j, ret = 0;\n char buf[LONG_STRING];\n struct PopData *pop_data = (struct PopData *) ctx->data;\n struct Progress progress;\n#ifdef USE_HCACHE\n header_cache_t *hc = NULL;\n#endif\n\n pop_data->check_time = 0;\n\n while (true)\n {\n if (pop_reconnect(ctx) < 0)\n return -1;\n\n mutt_progress_init(&progress, _(\"Marking messages deleted...\"),\n MUTT_PROGRESS_MSG, WriteInc, ctx->deleted);\n\n#ifdef USE_HCACHE\n hc = pop_hcache_open(pop_data, ctx->path);\n#endif\n\n for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++)\n {\n if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->refno != -1)\n {\n j++;\n if (!ctx->quiet)\n mutt_progress_update(&progress, j, -1);\n snprintf(buf, sizeof(buf), \"DELE %d\\r\\n\", ctx->hdrs[i]->refno);\n ret = pop_query(pop_data, buf, sizeof(buf));\n if (ret == 0)\n {\n mutt_bcache_del(pop_data->bcache, ctx->hdrs[i]->data);\n#ifdef USE_HCACHE\n mutt_hcache_delete(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data));\n#endif\n }\n }\n\n#ifdef USE_HCACHE\n if (ctx->hdrs[i]->changed)\n {\n mutt_hcache_store(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data),\n ctx->hdrs[i], 0);\n }\n#endif\n }\n\n#ifdef USE_HCACHE\n mutt_hcache_close(hc);\n#endif\n\n if (ret == 0)\n {\n mutt_str_strfcpy(buf, \"QUIT\\r\\n\", sizeof(buf));\n ret = pop_query(pop_data, buf, sizeof(buf));\n }\n\n if (ret == 0)\n {\n pop_data->clear_cache = true;\n pop_clear_cache(pop_data);\n pop_data->status = POP_DISCONNECTED;\n return 0;\n }\n\n if (ret == -2)\n {\n mutt_error(\"%s\", pop_data->err_msg);\n return -1;\n }\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int follow_dotdot_rcu(struct nameidata *nd)\n{\n\tstruct inode *inode = nd->inode;\n\tif (!nd->root.mnt)\n\t\tset_root_rcu(nd);\n\n\twhile (1) {\n\t\tif (path_equal(&nd->path, &nd->root))\n\t\t\tbreak;\n\t\tif (nd->path.dentry != nd->path.mnt->mnt_root) {\n\t\t\tstruct dentry *old = nd->path.dentry;\n\t\t\tstruct dentry *parent = old->d_parent;\n\t\t\tunsigned seq;\n\n\t\t\tinode = parent->d_inode;\n\t\t\tseq = read_seqcount_begin(&parent->d_seq);\n\t\t\tif (unlikely(read_seqcount_retry(&old->d_seq, nd->seq)))\n\t\t\t\treturn -ECHILD;\n\t\t\tnd->path.dentry = parent;\n\t\t\tnd->seq = seq;\n\t\t\tif (unlikely(!path_connected(&nd->path)))\n\t\t\t\treturn -ENOENT;\n\t\t\tbreak;\n\t\t} else {\n\t\t\tstruct mount *mnt = real_mount(nd->path.mnt);\n\t\t\tstruct mount *mparent = mnt->mnt_parent;\n\t\t\tstruct dentry *mountpoint = mnt->mnt_mountpoint;\n\t\t\tstruct inode *inode2 = mountpoint->d_inode;\n\t\t\tunsigned seq = read_seqcount_begin(&mountpoint->d_seq);\n\t\t\tif (unlikely(read_seqretry(&mount_lock, nd->m_seq)))\n\t\t\t\treturn -ECHILD;\n\t\t\tif (&mparent->mnt == nd->path.mnt)\n\t\t\t\tbreak;\n\t\t\t/* we know that mountpoint was pinned */\n\t\t\tnd->path.dentry = mountpoint;\n\t\t\tnd->path.mnt = &mparent->mnt;\n\t\t\tinode = inode2;\n\t\t\tnd->seq = seq;\n\t\t}\n\t}\n\twhile (unlikely(d_mountpoint(nd->path.dentry))) {\n\t\tstruct mount *mounted;\n\t\tmounted = __lookup_mnt(nd->path.mnt, nd->path.dentry);\n\t\tif (unlikely(read_seqretry(&mount_lock, nd->m_seq)))\n\t\t\treturn -ECHILD;\n\t\tif (!mounted)\n\t\t\tbreak;\n\t\tnd->path.mnt = &mounted->mnt;\n\t\tnd->path.dentry = mounted->mnt.mnt_root;\n\t\tinode = nd->path.dentry->d_inode;\n\t\tnd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);\n\t}\n\tnd->inode = inode;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "safe"} {"code": "static void process_blob(struct rev_info *revs,\n\t\t\t struct blob *blob,\n\t\t\t show_object_fn show,\n\t\t\t struct strbuf *path,\n\t\t\t const char *name,\n\t\t\t void *cb_data)\n{\n\tstruct object *obj = &blob->object;\n\n\tif (!revs->blob_objects)\n\t\treturn;\n\tif (!obj)\n\t\tdie(\"bad blob object\");\n\tif (obj->flags & (UNINTERESTING | SEEN))\n\t\treturn;\n\tobj->flags |= SEEN;\n\tshow(obj, path, name, cb_data);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "void set_cfg_option(char *opt_string)\n{\n\tchar *sep, *sep2, szSec[1024], szKey[1024], szVal[1024];\n\tsep = strchr(opt_string, ':');\n\tif (!sep) {\n\t\tfprintf(stderr, \"Badly formatted option %s - expected Section:Name=Value\\n\", opt_string);\n\t\treturn;\n\t}\n\t{\n\t\tconst size_t sepIdx = sep - opt_string;\n\t\tif (sepIdx >= sizeof(szSec)) {\n\t\t\tfprintf(stderr, \"Badly formatted option %s - Section name is too long\\n\", opt_string);\n\t\t\treturn;\n\t\t}\n\n\t\tstrncpy(szSec, opt_string, sepIdx);\n\t\tszSec[sepIdx] = 0;\n\t}\n\tsep ++;\n\tsep2 = strchr(sep, '=');\n\tif (!sep2) {\n\t\tfprintf(stderr, \"Badly formatted option %s - expected Section:Name=Value\\n\", opt_string);\n\t\treturn;\n\t}\n\t{\n\t\tconst size_t sepIdx = sep2 - sep;\n\t\tif (sepIdx >= sizeof(szKey)) {\n\t\t\tfprintf(stderr, \"Badly formatted option %s - key name is too long\\n\", opt_string);\n\t\t\treturn;\n\t\t}\n\t\tstrncpy(szKey, sep, sepIdx);\n\t\tszKey[sepIdx] = 0;\n\t\tif (strlen(sep2 + 1) >= sizeof(szVal)) {\n\t\t\tfprintf(stderr, \"Badly formatted option %s - value is too long\\n\", opt_string);\n\t\t\treturn;\n\t\t}\n\t\tstrcpy(szVal, sep2+1);\n\t}\n\n\tif (!stricmp(szKey, \"*\")) {\n\t\tif (stricmp(szVal, \"null\")) {\n\t\t\tfprintf(stderr, \"Badly formatted option %s - expected Section:*=null\\n\", opt_string);\n\t\t\treturn;\n\t\t}\n\t\tgf_cfg_del_section(cfg_file, szSec);\n\t\treturn;\n\t}\n\n\tif (!stricmp(szVal, \"null\")) {\n\t\tszVal[0]=0;\n\t}\n\tgf_cfg_set_key(cfg_file, szSec, szKey, szVal[0] ? szVal : NULL);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "R_API st64 r_buf_fread_at(RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int n) {\n\tr_return_val_if_fail (b && buf && fmt, -1);\n\tst64 o_addr = r_buf_seek (b, 0, R_BUF_CUR);\n\tst64 r = r_buf_seek (b, addr, R_BUF_SET);\n\tif (r < 0) {\n\t\treturn r;\n\t}\n\tr = r_buf_fread (b, buf, fmt, n);\n\tr_buf_seek (b, o_addr, R_BUF_SET);\n\treturn r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "static void update_blocked_averages(int cpu)\n{\n\tstruct rq *rq = cpu_rq(cpu);\n\tstruct cfs_rq *cfs_rq;\n\tconst struct sched_class *curr_class;\n\tstruct rq_flags rf;\n\tbool done = true;\n\n\trq_lock_irqsave(rq, &rf);\n\tupdate_rq_clock(rq);\n\n\t/*\n\t * Iterates the task_group tree in a bottom up fashion, see\n\t * list_add_leaf_cfs_rq() for details.\n\t */\n\tfor_each_leaf_cfs_rq(rq, cfs_rq) {\n\t\tstruct sched_entity *se;\n\n\t\t/* throttled entities do not contribute to load */\n\t\tif (throttled_hierarchy(cfs_rq))\n\t\t\tcontinue;\n\n\t\tif (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq))\n\t\t\tupdate_tg_load_avg(cfs_rq, 0);\n\n\t\t/* Propagate pending load changes to the parent, if any: */\n\t\tse = cfs_rq->tg->se[cpu];\n\t\tif (se && !skip_blocked_update(se))\n\t\t\tupdate_load_avg(cfs_rq_of(se), se, 0);\n\n\t\t/* Don't need periodic decay once load/util_avg are null */\n\t\tif (cfs_rq_has_blocked(cfs_rq))\n\t\t\tdone = false;\n\t}\n\n\tcurr_class = rq->curr->sched_class;\n\tupdate_rt_rq_load_avg(rq_clock_task(rq), rq, curr_class == &rt_sched_class);\n\tupdate_dl_rq_load_avg(rq_clock_task(rq), rq, curr_class == &dl_sched_class);\n\tupdate_irq_load_avg(rq, 0);\n\t/* Don't need periodic decay once load/util_avg are null */\n\tif (others_have_blocked(rq))\n\t\tdone = false;\n\n#ifdef CONFIG_NO_HZ_COMMON\n\trq->last_blocked_load_update_tick = jiffies;\n\tif (done)\n\t\trq->has_blocked_load = 0;\n#endif\n\trq_unlock_irqrestore(rq, &rf);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "safe"} {"code": "static inline int page_is_allowed(unsigned long pfn)\n{\n\treturn devmem_is_allowed(pfn);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": "static struct child_process *git_connect_git(int fd[2], char *hostandport,\n\t\t\t\t\t const char *path, const char *prog,\n\t\t\t\t\t enum protocol_version version,\n\t\t\t\t\t int flags)\n{\n\tstruct child_process *conn;\n\tstruct strbuf request = STRBUF_INIT;\n\t/*\n\t * Set up virtual host information based on where we will\n\t * connect, unless the user has overridden us in\n\t * the environment.\n\t */\n\tchar *target_host = getenv(\"GIT_OVERRIDE_VIRTUAL_HOST\");\n\tif (target_host)\n\t\ttarget_host = xstrdup(target_host);\n\telse\n\t\ttarget_host = xstrdup(hostandport);\n\n\ttransport_check_allowed(\"git\");\n\tif (strchr(target_host, '\\n') || strchr(path, '\\n'))\n\t\tdie(_(\"newline is forbidden in git:// hosts and repo paths\"));\n\n\t/*\n\t * These underlying connection commands die() if they\n\t * cannot connect.\n\t */\n\tif (git_use_proxy(hostandport))\n\t\tconn = git_proxy_connect(fd, hostandport);\n\telse\n\t\tconn = git_tcp_connect(fd, hostandport, flags);\n\t/*\n\t * Separate original protocol components prog and path\n\t * from extended host header with a NUL byte.\n\t *\n\t * Note: Do not add any other headers here! Doing so\n\t * will cause older git-daemon servers to crash.\n\t */\n\tstrbuf_addf(&request,\n\t\t \"%s %s%chost=%s%c\",\n\t\t prog, path, 0,\n\t\t target_host, 0);\n\n\t/* If using a new version put that stuff here after a second null byte */\n\tif (version > 0) {\n\t\tstrbuf_addch(&request, '\\0');\n\t\tstrbuf_addf(&request, \"version=%d%c\",\n\t\t\t version, '\\0');\n\t}\n\n\tpacket_write(fd[1], request.buf, request.len);\n\n\tfree(target_host);\n\tstrbuf_release(&request);\n\treturn conn;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "void ipc_rcu_getref(void *ptr)\n{\n\tcontainer_of(ptr, struct ipc_rcu_hdr, data)->refcount++;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "static int i8042_start(struct serio *serio)\n{\n\tstruct i8042_port *port = serio->port_data;\n\n\tport->exists = true;\n\tmb();\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int\n lineno, int col_offset, int end_lineno, int end_col_offset, PyArena\n *arena)\n{\n stmt_ty p;\n if (!target) {\n PyErr_SetString(PyExc_ValueError,\n \"field target is required for AsyncFor\");\n return NULL;\n }\n if (!iter) {\n PyErr_SetString(PyExc_ValueError,\n \"field iter is required for AsyncFor\");\n return NULL;\n }\n p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));\n if (!p)\n return NULL;\n p->kind = AsyncFor_kind;\n p->v.AsyncFor.target = target;\n p->v.AsyncFor.iter = iter;\n p->v.AsyncFor.body = body;\n p->v.AsyncFor.orelse = orelse;\n p->lineno = lineno;\n p->col_offset = col_offset;\n p->end_lineno = end_lineno;\n p->end_col_offset = end_col_offset;\n return p;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static void xar_get_checksum_values(xmlTextReaderPtr reader, unsigned char ** cksum, int * hash)\n{\n xmlChar * style = xmlTextReaderGetAttribute(reader, (const xmlChar *)\"style\");\n const xmlChar * xmlval;\n\n *hash = XAR_CKSUM_NONE;\n if (style == NULL) {\n cli_dbgmsg(\"cli_scaxar: xmlTextReaderGetAttribute no style attribute \"\n \"for checksum element\\n\");\n } else {\n cli_dbgmsg(\"cli_scanxar: checksum algorithm is %s.\\n\", style); \n if (0 == xmlStrcasecmp(style, (const xmlChar *)\"sha1\")) {\n *hash = XAR_CKSUM_SHA1;\n } else if (0 == xmlStrcasecmp(style, (const xmlChar *)\"md5\")) {\n *hash = XAR_CKSUM_MD5;\n } else {\n cli_dbgmsg(\"cli_scanxar: checksum algorithm %s is unsupported.\\n\", style);\n *hash = XAR_CKSUM_OTHER;\n }\n }\n if (style != NULL)\n xmlFree(style);\n\n if (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT) {\n xmlval = xmlTextReaderConstValue(reader);\n if (xmlval) {\n cli_dbgmsg(\"cli_scanxar: checksum value is %s.\\n\", xmlval);\n if (*hash == XAR_CKSUM_SHA1 && xmlStrlen(xmlval) == 2 * CLI_HASHLEN_SHA1 ||\n *hash == XAR_CKSUM_MD5 && xmlStrlen(xmlval) == 2 * CLI_HASHLEN_MD5)\n {\n *cksum = xmlStrdup(xmlval); \n } \n else\n {\n cli_dbgmsg(\"cli_scanxar: checksum type is unknown or length is invalid.\\n\");\n *hash = XAR_CKSUM_OTHER;\n *cksum = NULL;\n }\n } else {\n *cksum = NULL;\n cli_dbgmsg(\"cli_scanxar: xmlTextReaderConstValue() returns NULL for checksum value.\\n\"); \n }\n }\n else\n cli_dbgmsg(\"cli_scanxar: No text for XML checksum element.\\n\");\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void process_tree(struct rev_info *revs,\n\t\t\t struct tree *tree,\n\t\t\t show_object_fn show,\n\t\t\t struct strbuf *base,\n\t\t\t const char *name,\n\t\t\t void *cb_data)\n{\n\tstruct object *obj = &tree->object;\n\tstruct tree_desc desc;\n\tstruct name_entry entry;\n\tenum interesting match = revs->diffopt.pathspec.nr == 0 ?\n\t\tall_entries_interesting: entry_not_interesting;\n\tint baselen = base->len;\n\n\tif (!revs->tree_objects)\n\t\treturn;\n\tif (!obj)\n\t\tdie(\"bad tree object\");\n\tif (obj->flags & (UNINTERESTING | SEEN))\n\t\treturn;\n\tif (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {\n\t\tif (revs->ignore_missing_links)\n\t\t\treturn;\n\t\tdie(\"bad tree object %s\", oid_to_hex(&obj->oid));\n\t}\n\n\tobj->flags |= SEEN;\n\tstrbuf_addstr(base, name);\n\tshow(obj, base->buf, cb_data);\n\tif (base->len)\n\t\tstrbuf_addch(base, '/');\n\n\tinit_tree_desc(&desc, tree->buffer, tree->size);\n\n\twhile (tree_entry(&desc, &entry)) {\n\t\tif (match != all_entries_interesting) {\n\t\t\tmatch = tree_entry_interesting(&entry, base, 0,\n\t\t\t\t\t\t &revs->diffopt.pathspec);\n\t\t\tif (match == all_entries_not_interesting)\n\t\t\t\tbreak;\n\t\t\tif (match == entry_not_interesting)\n\t\t\t\tcontinue;\n\t\t}\n\n\t\tif (S_ISDIR(entry.mode))\n\t\t\tprocess_tree(revs,\n\t\t\t\t lookup_tree(entry.sha1),\n\t\t\t\t show, base, entry.path,\n\t\t\t\t cb_data);\n\t\telse if (S_ISGITLINK(entry.mode))\n\t\t\tprocess_gitlink(revs, entry.sha1,\n\t\t\t\t\tshow, base, entry.path,\n\t\t\t\t\tcb_data);\n\t\telse\n\t\t\tprocess_blob(revs,\n\t\t\t\t lookup_blob(entry.sha1),\n\t\t\t\t show, base, entry.path,\n\t\t\t\t cb_data);\n\t}\n\tstrbuf_setlen(base, baselen);\n\tfree_tree_buffer(tree);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int gss_iakerbmechglue_init(void)\n{\n struct gss_mech_config mech_iakerb;\n struct gss_config iakerb_mechanism = krb5_mechanism;\n\n /* IAKERB mechanism mirrors krb5, but with different context SPIs */\n iakerb_mechanism.gss_accept_sec_context = iakerb_gss_accept_sec_context;\n iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context;\n iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context;\n iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred;\n iakerb_mechanism.gssspi_acquire_cred_with_password\n = iakerb_gss_acquire_cred_with_password;\n\n memset(&mech_iakerb, 0, sizeof(mech_iakerb));\n mech_iakerb.mech = &iakerb_mechanism;\n\n mech_iakerb.mechNameStr = \"iakerb\";\n mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb;\n gssint_register_mechinfo(&mech_iakerb);\n\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-18", "cwe_name": "DEPRECATED: Source Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/18.html", "label_name": "vulnerable"} {"code": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,\n\t\t\t\t compat_long_t addr, compat_long_t data)\n{\n\tstruct task_struct *child;\n\tlong ret;\n\n\tif (request == PTRACE_TRACEME) {\n\t\tret = ptrace_traceme();\n\t\tgoto out;\n\t}\n\n\tchild = ptrace_get_task_struct(pid);\n\tif (IS_ERR(child)) {\n\t\tret = PTR_ERR(child);\n\t\tgoto out;\n\t}\n\n\tif (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {\n\t\tret = ptrace_attach(child, request, addr, data);\n\t\t/*\n\t\t * Some architectures need to do book-keeping after\n\t\t * a ptrace attach.\n\t\t */\n\t\tif (!ret)\n\t\t\tarch_ptrace_attach(child);\n\t\tgoto out_put_task_struct;\n\t}\n\n\tret = ptrace_check_attach(child, request == PTRACE_KILL ||\n\t\t\t\t request == PTRACE_INTERRUPT);\n\tif (!ret)\n\t\tret = compat_arch_ptrace(child, request, addr, data);\n\n out_put_task_struct:\n\tput_task_struct(child);\n out:\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static LUA_FUNCTION(openssl_x509_check_host)\n{\n X509 * cert = CHECK_OBJECT(1, X509, \"openssl.x509\");\n if (lua_isstring(L, 2))\n {\n const char *hostname = lua_tostring(L, 2);\n lua_pushboolean(L, X509_check_host(cert, hostname, strlen(hostname), 0, NULL));\n }\n else\n {\n lua_pushboolean(L, 0);\n }\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t len, int flags)\n{\n\tstruct sk_buff\t\t*skb;\n\tstruct sock\t\t*sk = sock->sk;\n\n\tint\t\tcopied, err;\n\n\tif (*debug & DEBUG_SOCKET)\n\t\tprintk(KERN_DEBUG \"%s: len %d, flags %x ch.nr %d, proto %x\\n\",\n\t\t __func__, (int)len, flags, _pms(sk)->ch.nr,\n\t\t sk->sk_protocol);\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tif (sk->sk_state == MISDN_CLOSED)\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_mISDN *maddr = msg->msg_name;\n\n\t\tmaddr->family = AF_ISDN;\n\t\tmaddr->dev = _pms(sk)->dev->id;\n\t\tif ((sk->sk_protocol == ISDN_P_LAPD_TE) ||\n\t\t (sk->sk_protocol == ISDN_P_LAPD_NT)) {\n\t\t\tmaddr->channel = (mISDN_HEAD_ID(skb) >> 16) & 0xff;\n\t\t\tmaddr->tei = (mISDN_HEAD_ID(skb) >> 8) & 0xff;\n\t\t\tmaddr->sapi = mISDN_HEAD_ID(skb) & 0xff;\n\t\t} else {\n\t\t\tmaddr->channel = _pms(sk)->ch.nr;\n\t\t\tmaddr->sapi = _pms(sk)->ch.addr & 0xFF;\n\t\t\tmaddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF;\n\t\t}\n\t\tmsg->msg_namelen = sizeof(*maddr);\n\t}\n\n\tcopied = skb->len + MISDN_HEADER_LEN;\n\tif (len < copied) {\n\t\tif (flags & MSG_PEEK)\n\t\t\tatomic_dec(&skb->users);\n\t\telse\n\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\treturn -ENOSPC;\n\t}\n\tmemcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb),\n\t MISDN_HEADER_LEN);\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tmISDN_sock_cmsg(sk, msg, skb);\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,\n\t\t struct sockaddr_storage *kern_address, int mode)\n{\n\tint tot_len;\n\n\tif (kern_msg->msg_namelen) {\n\t\tif (mode == VERIFY_READ) {\n\t\t\tint err = move_addr_to_kernel(kern_msg->msg_name,\n\t\t\t\t\t\t kern_msg->msg_namelen,\n\t\t\t\t\t\t kern_address);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t}\n\t\tkern_msg->msg_name = kern_address;\n\t} else\n\t\tkern_msg->msg_name = NULL;\n\n\ttot_len = iov_from_user_compat_to_kern(kern_iov,\n\t\t\t\t\t (struct compat_iovec __user *)kern_msg->msg_iov,\n\t\t\t\t\t kern_msg->msg_iovlen);\n\tif (tot_len >= 0)\n\t\tkern_msg->msg_iov = kern_iov;\n\n\treturn tot_len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len)\n{\n\tsize_t cipher_len;\n\tsize_t i;\n\tunsigned char iv[16] = { 0 };\n\tunsigned char plaintext[4096] = { 0 };\n\tepass2003_exdata *exdata = NULL;\n\n\tif (!card->drv_data) \n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\texdata = (epass2003_exdata *)card->drv_data;\n\n\t/* no cipher */\n\tif (in[0] == 0x99)\n\t\treturn 0;\n\n\t/* parse cipher length */\n\tif (0x01 == in[2] && 0x82 != in[1]) {\n\t\tcipher_len = in[1];\n\t\ti = 3;\n\t}\n\telse if (0x01 == in[3] && 0x81 == in[1]) {\n\t\tcipher_len = in[2];\n\t\ti = 4;\n\t}\n\telse if (0x01 == in[4] && 0x82 == in[1]) {\n\t\tcipher_len = in[2] * 0x100;\n\t\tcipher_len += in[3];\n\t\ti = 5;\n\t}\n\telse {\n\t\treturn -1;\n\t}\n\n\tif (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext)\n\t\treturn -1;\n\n\t/* decrypt */\n\tif (KEY_TYPE_AES == exdata->smtype)\n\t\taes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\telse\n\t\tdes3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\n\t/* unpadding */\n\twhile (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0))\n\t\tcipher_len--;\n\n\tif (2 == cipher_len || *out_len < cipher_len - 2)\n\t\treturn -1;\n\n\tmemcpy(out, plaintext, cipher_len - 2);\n\t*out_len = cipher_len - 2;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int get_exif_tag_dbl_value(struct iw_exif_state *e, unsigned int tag_pos,\n\tdouble *pv)\n{\n\tunsigned int field_type;\n\tunsigned int value_count;\n\tunsigned int value_pos;\n\tunsigned int numer, denom;\n\n\tfield_type = get_exif_ui16(e, tag_pos+2);\n\tvalue_count = get_exif_ui32(e, tag_pos+4);\n\n\tif(value_count!=1) return 0;\n\n\tif(field_type!=5) return 0; // 5=Rational (two uint32's)\n\n\t// A rational is 8 bytes. Since 8>4, it is stored indirectly. First, read\n\t// the location where it is stored.\n\n\tvalue_pos = get_exif_ui32(e, tag_pos+8);\n\tif(value_pos > e->d_len-8) return 0;\n\n\t// Read the actual value.\n\tnumer = get_exif_ui32(e, value_pos);\n\tdenom = get_exif_ui32(e, value_pos+4);\n\tif(denom==0) return 0;\n\n\t*pv = ((double)numer)/denom;\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int hugepage_madvise(struct vm_area_struct *vma,\n\t\t unsigned long *vm_flags, int advice)\n{\n\tswitch (advice) {\n\tcase MADV_HUGEPAGE:\n\t\t/*\n\t\t * Be somewhat over-protective like KSM for now!\n\t\t */\n\t\tif (*vm_flags & (VM_HUGEPAGE | VM_NO_THP))\n\t\t\treturn -EINVAL;\n\t\t*vm_flags &= ~VM_NOHUGEPAGE;\n\t\t*vm_flags |= VM_HUGEPAGE;\n\t\t/*\n\t\t * If the vma become good for khugepaged to scan,\n\t\t * register it here without waiting a page fault that\n\t\t * may not happen any time soon.\n\t\t */\n\t\tif (unlikely(khugepaged_enter_vma_merge(vma)))\n\t\t\treturn -ENOMEM;\n\t\tbreak;\n\tcase MADV_NOHUGEPAGE:\n\t\t/*\n\t\t * Be somewhat over-protective like KSM for now!\n\t\t */\n\t\tif (*vm_flags & (VM_NOHUGEPAGE | VM_NO_THP))\n\t\t\treturn -EINVAL;\n\t\t*vm_flags &= ~VM_HUGEPAGE;\n\t\t*vm_flags |= VM_NOHUGEPAGE;\n\t\t/*\n\t\t * Setting VM_NOHUGEPAGE will prevent khugepaged from scanning\n\t\t * this vma even if we leave the mm registered in khugepaged if\n\t\t * it got registered before VM_NOHUGEPAGE was set.\n\t\t */\n\t\tbreak;\n\t}\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-191", "cwe_name": "Integer Underflow (Wrap or Wraparound)", "description": "The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.", "url": "https://cwe.mitre.org/data/definitions/191.html", "label_name": "vulnerable"} {"code": "int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)\n{\n\tstruct page *page;\n\tstruct kvm *kvm;\n\tint r;\n\n\tBUG_ON(vcpu->kvm == NULL);\n\tkvm = vcpu->kvm;\n\n\tvcpu->arch.emulate_ctxt.ops = &emulate_ops;\n\tif (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu))\n\t\tvcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;\n\telse\n\t\tvcpu->arch.mp_state = KVM_MP_STATE_UNINITIALIZED;\n\n\tpage = alloc_page(GFP_KERNEL | __GFP_ZERO);\n\tif (!page) {\n\t\tr = -ENOMEM;\n\t\tgoto fail;\n\t}\n\tvcpu->arch.pio_data = page_address(page);\n\n\tkvm_set_tsc_khz(vcpu, max_tsc_khz);\n\n\tr = kvm_mmu_create(vcpu);\n\tif (r < 0)\n\t\tgoto fail_free_pio_data;\n\n\tif (irqchip_in_kernel(kvm)) {\n\t\tr = kvm_create_lapic(vcpu);\n\t\tif (r < 0)\n\t\t\tgoto fail_mmu_destroy;\n\t} else\n\t\tstatic_key_slow_inc(&kvm_no_apic_vcpu);\n\n\tvcpu->arch.mce_banks = kzalloc(KVM_MAX_MCE_BANKS * sizeof(u64) * 4,\n\t\t\t\t GFP_KERNEL);\n\tif (!vcpu->arch.mce_banks) {\n\t\tr = -ENOMEM;\n\t\tgoto fail_free_lapic;\n\t}\n\tvcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS;\n\n\tif (!zalloc_cpumask_var(&vcpu->arch.wbinvd_dirty_mask, GFP_KERNEL))\n\t\tgoto fail_free_mce_banks;\n\n\tr = fx_init(vcpu);\n\tif (r)\n\t\tgoto fail_free_wbinvd_dirty_mask;\n\n\tvcpu->arch.ia32_tsc_adjust_msr = 0x0;\n\tvcpu->arch.pv_time_enabled = false;\n\tkvm_async_pf_hash_reset(vcpu);\n\tkvm_pmu_init(vcpu);\n\n\treturn 0;\nfail_free_wbinvd_dirty_mask:\n\tfree_cpumask_var(vcpu->arch.wbinvd_dirty_mask);\nfail_free_mce_banks:\n\tkfree(vcpu->arch.mce_banks);\nfail_free_lapic:\n\tkvm_free_lapic(vcpu);\nfail_mmu_destroy:\n\tkvm_mmu_destroy(vcpu);\nfail_free_pio_data:\n\tfree_page((unsigned long)vcpu->arch.pio_data);\nfail:\n\treturn r;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "spnego_gss_unwrap_aead(OM_uint32 *minor_status,\n\t\t gss_ctx_id_t context_handle,\n\t\t gss_buffer_t input_message_buffer,\n\t\t gss_buffer_t input_assoc_buffer,\n\t\t gss_buffer_t output_payload_buffer,\n\t\t int *conf_state,\n\t\t gss_qop_t *qop_state)\n{\n\tOM_uint32 ret;\n\tret = gss_unwrap_aead(minor_status,\n\t\t\t context_handle,\n\t\t\t input_message_buffer,\n\t\t\t input_assoc_buffer,\n\t\t\t output_payload_buffer,\n\t\t\t conf_state,\n\t\t\t qop_state);\n\treturn (ret);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "vulnerable"} {"code": "static CURLcode pop3_parse_url_path(struct connectdata *conn)\n{\n /* the pop3 struct is already inited in pop3_connect() */\n struct pop3_conn *pop3c = &conn->proto.pop3c;\n struct SessionHandle *data = conn->data;\n const char *path = data->state.path;\n\n /* url decode the path and use this mailbox */\n return Curl_urldecode(data, path, 0, &pop3c->mailbox, NULL, TRUE);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)\n{\n\tstruct inode *inode = d_inode(dentry);\n\tstruct buffer_head *bh = NULL;\n\tint error;\n\tstruct mb2_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);\n\n\tea_idebug(inode, \"buffer=%p, buffer_size=%ld\",\n\t\t buffer, (long)buffer_size);\n\n\terror = 0;\n\tif (!EXT4_I(inode)->i_file_acl)\n\t\tgoto cleanup;\n\tea_idebug(inode, \"reading block %llu\",\n\t\t (unsigned long long)EXT4_I(inode)->i_file_acl);\n\tbh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);\n\terror = -EIO;\n\tif (!bh)\n\t\tgoto cleanup;\n\tea_bdebug(bh, \"b_count=%d, refcount=%d\",\n\t\tatomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));\n\tif (ext4_xattr_check_block(inode, bh)) {\n\t\tEXT4_ERROR_INODE(inode, \"bad block %llu\",\n\t\t\t\t EXT4_I(inode)->i_file_acl);\n\t\terror = -EFSCORRUPTED;\n\t\tgoto cleanup;\n\t}\n\text4_xattr_cache_insert(ext4_mb_cache, bh);\n\terror = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);\n\ncleanup:\n\tbrelse(bh);\n\n\treturn error;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "safe"} {"code": "static int wdm_post_reset(struct usb_interface *intf)\n{\n\tstruct wdm_device *desc = wdm_find_device(intf);\n\tint rv;\n\n\tclear_bit(WDM_OVERFLOW, &desc->flags);\n\tclear_bit(WDM_RESETTING, &desc->flags);\n\trv = recover_from_urb_loss(desc);\n\tmutex_unlock(&desc->wlock);\n\tmutex_unlock(&desc->rlock);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,\n\tconst unsigned long *scan_mask)\n{\n\tstruct adis *adis = iio_device_get_drvdata(indio_dev);\n\tunsigned int burst_length;\n\tu8 *tx;\n\n\t/* All but the timestamp channel */\n\tburst_length = (indio_dev->num_channels - 1) * sizeof(u16);\n\tburst_length += adis->burst->extra_len;\n\n\tadis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);\n\tif (!adis->xfer)\n\t\treturn -ENOMEM;\n\n\tadis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);\n\tif (!adis->buffer)\n\t\treturn -ENOMEM;\n\n\ttx = adis->buffer + burst_length;\n\ttx[0] = ADIS_READ_REG(adis->burst->reg_cmd);\n\ttx[1] = 0;\n\n\tadis->xfer[0].tx_buf = tx;\n\tadis->xfer[0].bits_per_word = 8;\n\tadis->xfer[0].len = 2;\n\tadis->xfer[1].rx_buf = adis->buffer;\n\tadis->xfer[1].bits_per_word = 8;\n\tadis->xfer[1].len = burst_length;\n\n\tspi_message_init(&adis->msg);\n\tspi_message_add_tail(&adis->xfer[0], &adis->msg);\n\tspi_message_add_tail(&adis->xfer[1], &adis->msg);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-401", "cwe_name": "Missing Release of Memory after Effective Lifetime", "description": "The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.", "url": "https://cwe.mitre.org/data/definitions/401.html", "label_name": "vulnerable"} {"code": "static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)\n{\n\tstruct nfs4_state *state = opendata->state;\n\tstruct nfs_inode *nfsi = NFS_I(state->inode);\n\tstruct nfs_delegation *delegation;\n\tint open_mode = opendata->o_arg.open_flags & (FMODE_READ|FMODE_WRITE|O_EXCL);\n\tnfs4_stateid stateid;\n\tint ret = -EAGAIN;\n\n\tfor (;;) {\n\t\tif (can_open_cached(state, open_mode)) {\n\t\t\tspin_lock(&state->owner->so_lock);\n\t\t\tif (can_open_cached(state, open_mode)) {\n\t\t\t\tupdate_open_stateflags(state, open_mode);\n\t\t\t\tspin_unlock(&state->owner->so_lock);\n\t\t\t\tgoto out_return_state;\n\t\t\t}\n\t\t\tspin_unlock(&state->owner->so_lock);\n\t\t}\n\t\trcu_read_lock();\n\t\tdelegation = rcu_dereference(nfsi->delegation);\n\t\tif (delegation == NULL ||\n\t\t !can_open_delegated(delegation, open_mode)) {\n\t\t\trcu_read_unlock();\n\t\t\tbreak;\n\t\t}\n\t\t/* Save the delegation */\n\t\tmemcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data));\n\t\trcu_read_unlock();\n\t\tret = nfs_may_open(state->inode, state->owner->so_cred, open_mode);\n\t\tif (ret != 0)\n\t\t\tgoto out;\n\t\tret = -EAGAIN;\n\n\t\t/* Try to update the stateid using the delegation */\n\t\tif (update_open_stateid(state, NULL, &stateid, open_mode))\n\t\t\tgoto out_return_state;\n\t}\nout:\n\treturn ERR_PTR(ret);\nout_return_state:\n\tatomic_inc(&state->count);\n\treturn state;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,\n\t\t\t\t size_t count, loff_t *offset)\n{\n\tstruct snd_timer_user *tu;\n\tlong result = 0, unit;\n\tint qhead;\n\tint err = 0;\n\n\ttu = file->private_data;\n\tunit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read);\n\tmutex_lock(&tu->ioctl_lock);\n\tspin_lock_irq(&tu->qlock);\n\twhile ((long)count - result >= unit) {\n\t\twhile (!tu->qused) {\n\t\t\twait_queue_t wait;\n\n\t\t\tif ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {\n\t\t\t\terr = -EAGAIN;\n\t\t\t\tgoto _error;\n\t\t\t}\n\n\t\t\tset_current_state(TASK_INTERRUPTIBLE);\n\t\t\tinit_waitqueue_entry(&wait, current);\n\t\t\tadd_wait_queue(&tu->qchange_sleep, &wait);\n\n\t\t\tspin_unlock_irq(&tu->qlock);\n\t\t\tmutex_unlock(&tu->ioctl_lock);\n\t\t\tschedule();\n\t\t\tmutex_lock(&tu->ioctl_lock);\n\t\t\tspin_lock_irq(&tu->qlock);\n\n\t\t\tremove_wait_queue(&tu->qchange_sleep, &wait);\n\n\t\t\tif (tu->disconnected) {\n\t\t\t\terr = -ENODEV;\n\t\t\t\tgoto _error;\n\t\t\t}\n\t\t\tif (signal_pending(current)) {\n\t\t\t\terr = -ERESTARTSYS;\n\t\t\t\tgoto _error;\n\t\t\t}\n\t\t}\n\n\t\tqhead = tu->qhead++;\n\t\ttu->qhead %= tu->queue_size;\n\t\ttu->qused--;\n\t\tspin_unlock_irq(&tu->qlock);\n\n\t\tif (tu->tread) {\n\t\t\tif (copy_to_user(buffer, &tu->tqueue[qhead],\n\t\t\t\t\t sizeof(struct snd_timer_tread)))\n\t\t\t\terr = -EFAULT;\n\t\t} else {\n\t\t\tif (copy_to_user(buffer, &tu->queue[qhead],\n\t\t\t\t\t sizeof(struct snd_timer_read)))\n\t\t\t\terr = -EFAULT;\n\t\t}\n\n\t\tspin_lock_irq(&tu->qlock);\n\t\tif (err < 0)\n\t\t\tgoto _error;\n\t\tresult += unit;\n\t\tbuffer += unit;\n\t}\n _error:\n\tspin_unlock_irq(&tu->qlock);\n\tmutex_unlock(&tu->ioctl_lock);\n\treturn result > 0 ? result : err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static inline void pipe_buf_get(struct pipe_inode_info *pipe,\n\t\t\t\tstruct pipe_buffer *buf)\n{\n\tbuf->ops->get(pipe, buf);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int jpc_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_ppm_t *ppm = &ms->parms.ppm;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tppm->data = 0;\n\n\tif (ms->len < 1) {\n\t\tgoto error;\n\t}\n\tif (jpc_getuint8(in, &ppm->ind)) {\n\t\tgoto error;\n\t}\n\n\tppm->len = ms->len - 1;\n\tif (ppm->len > 0) {\n\t\tif (!(ppm->data = jas_malloc(ppm->len))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (JAS_CAST(uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {\n\t\t\tgoto error;\n\t\t}\n\t} else {\n\t\tppm->data = 0;\n\t}\n\treturn 0;\n\nerror:\n\tjpc_ppm_destroyparms(ms);\n\treturn -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "decode_bytes_with_escapes(struct compiling *c, const node *n, const char *s,\n size_t len)\n{\n return PyBytes_DecodeEscape(s, len, NULL, 0, NULL);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_aead raead;\n\tstruct aead_alg *aead = &alg->cra_aead;\n\n\tsnprintf(raead.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"aead\");\n\tsnprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, \"%s\",\n\t\t aead->geniv ?: \"\");\n\n\traead.blocksize = alg->cra_blocksize;\n\traead.maxauthsize = aead->maxauthsize;\n\traead.ivsize = aead->ivsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_AEAD,\n\t\t sizeof(struct crypto_report_aead), &raead))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t\tstruct msghdr *msg, size_t len, int flags)\n{\n\tint noblock = flags & MSG_DONTWAIT;\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tsize_t copied;\n\tint err;\n\n\tBT_DBG(\"sock %p sk %p len %zu\", sock, sk, len);\n\n\tif (flags & (MSG_OOB))\n\t\treturn -EOPNOTSUPP;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb) {\n\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\treturn 0;\n\n\t\treturn err;\n\t}\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\tskb_reset_transport_header(skb);\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err == 0) {\n\t\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t\tif (bt_sk(sk)->skb_msg_name)\n\t\t\tbt_sk(sk)->skb_msg_name(skb, msg->msg_name,\n\t\t\t\t\t\t&msg->msg_namelen);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\treturn err ? : copied;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "BOOL glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyph* glyph)\n{\n\trdpGlyph* prevGlyph;\n\n\tif (id > 9)\n\t{\n\t\tWLog_ERR(TAG, \"invalid glyph cache id: %\" PRIu32 \"\", id);\n\t\treturn FALSE;\n\t}\n\n\tif (index > glyphCache->glyphCache[id].number)\n\t{\n\t\tWLog_ERR(TAG, \"invalid glyph cache index: %\" PRIu32 \" in cache id: %\" PRIu32 \"\", index, id);\n\t\treturn FALSE;\n\t}\n\n\tWLog_Print(glyphCache->log, WLOG_DEBUG, \"GlyphCachePut: id: %\" PRIu32 \" index: %\" PRIu32 \"\", id,\n\t index);\n\tprevGlyph = glyphCache->glyphCache[id].entries[index];\n\n\tif (prevGlyph)\n\t\tprevGlyph->Free(glyphCache->context, prevGlyph);\n\n\tglyphCache->glyphCache[id].entries[index] = glyph;\n\treturn TRUE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "setup_connection (GsmXSMPClient *client)\n{\n GIOChannel *channel;\n int fd;\n\n g_debug (\"GsmXSMPClient: Setting up new connection\");\n\n fd = IceConnectionNumber (client->priv->ice_connection);\n fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);\n channel = g_io_channel_unix_new (fd);\n client->priv->watch_id = g_io_add_watch (channel,\n G_IO_IN | G_IO_ERR,\n (GIOFunc)client_iochannel_watch,\n client);\n g_io_channel_unref (channel);\n\n client->priv->protocol_timeout = g_timeout_add_seconds (5,\n (GSourceFunc)_client_protocol_timeout,\n client);\n\n set_description (client);\n\n g_debug (\"GsmXSMPClient: New client '%s'\", client->priv->description);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": "static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_rng rrng;\n\n\tstrncpy(rrng.type, \"rng\", sizeof(rrng.type));\n\n\trrng.seedsize = alg->cra_rng.seedsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_RNG,\n\t\t sizeof(struct crypto_report_rng), &rrng))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "int ipmi_si_port_setup(struct si_sm_io *io)\n{\n\tunsigned int addr = io->addr_data;\n\tint idx;\n\n\tif (!addr)\n\t\treturn -ENODEV;\n\n\t/*\n\t * Figure out the actual inb/inw/inl/etc routine to use based\n\t * upon the register size.\n\t */\n\tswitch (io->regsize) {\n\tcase 1:\n\t\tio->inputb = port_inb;\n\t\tio->outputb = port_outb;\n\t\tbreak;\n\tcase 2:\n\t\tio->inputb = port_inw;\n\t\tio->outputb = port_outw;\n\t\tbreak;\n\tcase 4:\n\t\tio->inputb = port_inl;\n\t\tio->outputb = port_outl;\n\t\tbreak;\n\tdefault:\n\t\tdev_warn(io->dev, \"Invalid register size: %d\\n\",\n\t\t\t io->regsize);\n\t\treturn -EINVAL;\n\t}\n\n\t/*\n\t * Some BIOSes reserve disjoint I/O regions in their ACPI\n\t * tables. This causes problems when trying to register the\n\t * entire I/O region. Therefore we must register each I/O\n\t * port separately.\n\t */\n\tfor (idx = 0; idx < io->io_size; idx++) {\n\t\tif (request_region(addr + idx * io->regspacing,\n\t\t\t\t io->regsize, DEVICE_NAME) == NULL) {\n\t\t\t/* Undo allocations */\n\t\t\twhile (idx--)\n\t\t\t\trelease_region(addr + idx * io->regspacing,\n\t\t\t\t\t io->regsize);\n\t\t\treturn -EIO;\n\t\t}\n\t}\n\n\tio->io_cleanup = port_cleanup;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "int rose_parse_facilities(unsigned char *p,\n\tstruct rose_facilities_struct *facilities)\n{\n\tint facilities_len, len;\n\n\tfacilities_len = *p++;\n\n\tif (facilities_len == 0)\n\t\treturn 0;\n\n\twhile (facilities_len > 0) {\n\t\tif (*p == 0x00) {\n\t\t\tfacilities_len--;\n\t\t\tp++;\n\n\t\t\tswitch (*p) {\n\t\t\tcase FAC_NATIONAL:\t\t/* National */\n\t\t\t\tlen = rose_parse_national(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tcase FAC_CCITT:\t\t/* CCITT */\n\t\t\t\tlen = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tprintk(KERN_DEBUG \"ROSE: rose_parse_facilities - unknown facilities family %02X\\n\", *p);\n\t\t\t\tfacilities_len--;\n\t\t\t\tp++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tbreak;\t/* Error in facilities format */\n\t}\n\n\treturn 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,\n\t\t\t\t size_t count)\n{\n\tstruct o2nm_node *node = to_o2nm_node(item);\n\tstruct o2nm_cluster *cluster;\n\tunsigned long tmp;\n\tchar *p = (char *)page;\n\tssize_t ret;\n\n\ttmp = simple_strtoul(p, &p, 0);\n\tif (!p || (*p && (*p != '\\n')))\n\t\treturn -EINVAL;\n\n\ttmp = !!tmp; /* boolean of whether this node wants to be local */\n\n\t/* setting local turns on networking rx for now so we require having\n\t * set everything else first */\n\tif (!test_bit(O2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) ||\n\t !test_bit(O2NM_NODE_ATTR_NUM, &node->nd_set_attributes) ||\n\t !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))\n\t\treturn -EINVAL; /* XXX */\n\n\to2nm_lock_subsystem();\n\tcluster = to_o2nm_cluster_from_node(node);\n\tif (!cluster) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t/* the only failure case is trying to set a new local node\n\t * when a different one is already set */\n\tif (tmp && tmp == cluster->cl_has_local &&\n\t cluster->cl_local_node != node->nd_num) {\n\t\tret = -EBUSY;\n\t\tgoto out;\n\t}\n\n\t/* bring up the rx thread if we're setting the new local node. */\n\tif (tmp && !cluster->cl_has_local) {\n\t\tret = o2net_start_listening(node);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}\n\n\tif (!tmp && cluster->cl_has_local &&\n\t cluster->cl_local_node == node->nd_num) {\n\t\to2net_stop_listening(node);\n\t\tcluster->cl_local_node = O2NM_INVALID_NODE_NUM;\n\t}\n\n\tnode->nd_local = tmp;\n\tif (node->nd_local) {\n\t\tcluster->cl_has_local = tmp;\n\t\tcluster->cl_local_node = node->nd_num;\n\t}\n\n\tret = count;\n\nout:\n\to2nm_unlock_subsystem();\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "void show_object_with_name(FILE *out, struct object *obj,\n\t\t\t struct strbuf *path, const char *component)\n{\n\tchar *name = path_name(path, component);\n\tchar *p;\n\n\tfprintf(out, \"%s \", oid_to_hex(&obj->oid));\n\tfor (p = name; *p && *p != '\\n'; p++)\n\t\tfputc(*p, out);\n\tfputc('\\n', out);\n\n\tfree(name);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "SPL_METHOD(DirectoryIterator, next)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tint skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tintern->u.dir.index++;\n\tdo {\n\t\tspl_filesystem_dir_read(intern TSRMLS_CC);\n\t} while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));\n\tif (intern->file_name) {\n\t\tefree(intern->file_name);\n\t\tintern->file_name = NULL;\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];\n\tjpc_fix_t *buf = splitbuf;\n\tregister jpc_fix_t *srcptr;\n\tregister jpc_fix_t *dstptr;\n\tregister int n;\n\tregister int m;\n\tint hstartrow;\n\n\t/* Get a buffer. */\n\tif (bufsize > QMFB_SPLITBUFSIZE) {\n\t\tif (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide in this case. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\tif (numrows >= 2) {\n\t\thstartrow = (numrows + 1 - parity) >> 1;\n\t\t// ORIGINAL (WRONG): m = (parity) ? hstartrow : (numrows - hstartrow);\n\t\tm = numrows - hstartrow;\n\n\t\t/* Save the samples destined for the highpass channel. */\n\t\tn = m;\n\t\tdstptr = buf;\n\t\tsrcptr = &a[(1 - parity) * stride];\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\t++dstptr;\n\t\t\tsrcptr += stride << 1;\n\t\t}\n\t\t/* Copy the appropriate samples into the lowpass channel. */\n\t\tdstptr = &a[(1 - parity) * stride];\n\t\tsrcptr = &a[(2 - parity) * stride];\n\t\tn = numrows - m - (!parity);\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\tdstptr += stride;\n\t\t\tsrcptr += stride << 1;\n\t\t}\n\t\t/* Copy the saved samples into the highpass channel. */\n\t\tdstptr = &a[hstartrow * stride];\n\t\tsrcptr = buf;\n\t\tn = m;\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\tdstptr += stride;\n\t\t\t++srcptr;\n\t\t}\n\t}\n\n\t/* If the split buffer was allocated on the heap, free this memory. */\n\tif (buf != splitbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int get_evtchn_to_irq(evtchn_port_t evtchn)\n{\n\tif (evtchn >= xen_evtchn_max_channels())\n\t\treturn -1;\n\tif (evtchn_to_irq[EVTCHN_ROW(evtchn)] == NULL)\n\t\treturn -1;\n\treturn READ_ONCE(evtchn_to_irq[EVTCHN_ROW(evtchn)][EVTCHN_COL(evtchn)]);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static RList* entries(RBinFile* bf) {\n\tRList* ret = NULL;\n\tRBinAddr* addr = NULL;\n\tpsxexe_header psxheader;\n\n\tif (!(ret = r_list_new ())) {\n\t\treturn NULL;\n\t}\n\n\tif (!(addr = R_NEW0 (RBinAddr))) {\n\t\tr_list_free (ret);\n\t\treturn NULL;\n\t}\n\n\tif (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, \"8c17i\", 1) != sizeof (psxexe_header)) {\n\t\teprintf (\"PSXEXE Header truncated\\n\");\n\t\tr_list_free (ret);\n\t\tfree (addr);\n\t\treturn NULL;\n\t}\n\n\taddr->paddr = (psxheader.pc0 - psxheader.t_addr) + PSXEXE_TEXTSECTION_OFFSET;\n\taddr->vaddr = psxheader.pc0;\n\n\tr_list_append (ret, addr);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "static char *print_number( cJSON *item )\n{\n\tchar *str;\n\tdouble f, f2;\n\tint64_t i;\n\n\tstr = (char*) cJSON_malloc( 64 );\n\tif ( str ) {\n\t\tf = item->valuefloat;\n\t\ti = f;\n\t\tf2 = i;\n\t\tif ( f2 == f && item->valueint >= LLONG_MIN && item->valueint <= LLONG_MAX )\n\t\t\tsprintf( str, \"%lld\", (long long) item->valueint );\n\t\telse\n\t\t\tsprintf( str, \"%g\", item->valuefloat );\n\t}\n\treturn str;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "static int hash_recvmsg(struct kiocb *unused, struct socket *sock,\n\t\t\tstruct msghdr *msg, size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct hash_ctx *ctx = ask->private;\n\tunsigned ds = crypto_ahash_digestsize(crypto_ahash_reqtfm(&ctx->req));\n\tint err;\n\n\tif (len > ds)\n\t\tlen = ds;\n\telse if (len < ds)\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\n\tmsg->msg_namelen = 0;\n\n\tlock_sock(sk);\n\tif (ctx->more) {\n\t\tctx->more = 0;\n\t\tahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0);\n\t\terr = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req),\n\t\t\t\t\t\t &ctx->completion);\n\t\tif (err)\n\t\t\tgoto unlock;\n\t}\n\n\terr = memcpy_toiovec(msg->msg_iov, ctx->result, len);\n\nunlock:\n\trelease_sock(sk);\n\n\treturn err ?: len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int myrecvfrom6(int sockfd, void *buf, size_t *buflen, int flags,\n\t\t struct in6_addr *addr, uint32_t *ifindex, int *hoplimit)\n{\n\tstruct sockaddr_in6 sin6;\n\tunsigned char cbuf[2 * CMSG_SPACE(sizeof(struct in6_pktinfo))];\n\tstruct iovec iovec;\n\tstruct msghdr msghdr;\n\tstruct cmsghdr *cmsghdr;\n\tssize_t len;\n\n\tiovec.iov_len = *buflen;\n\tiovec.iov_base = buf;\n\tmemset(&msghdr, 0, sizeof(msghdr));\n\tmsghdr.msg_name = &sin6;\n\tmsghdr.msg_namelen = sizeof(sin6);\n\tmsghdr.msg_iov = &iovec;\n\tmsghdr.msg_iovlen = 1;\n\tmsghdr.msg_control = cbuf;\n\tmsghdr.msg_controllen = sizeof(cbuf);\n\n\tlen = recvmsg(sockfd, &msghdr, flags);\n\tif (len == -1)\n\t\treturn -errno;\n\t*buflen = len;\n\n\t/* Set ifindex to scope_id now. But since scope_id gets not\n\t * set by kernel for linklocal addresses, use pktinfo to obtain that\n\t * value right after.\n\t */\n\t*ifindex = sin6.sin6_scope_id;\n for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr;\n\t cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) {\n\t\tif (cmsghdr->cmsg_level != IPPROTO_IPV6)\n\t\t\tcontinue;\n\n\t\tswitch(cmsghdr->cmsg_type) {\n\t\tcase IPV6_PKTINFO:\n\t\t\tif (cmsghdr->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) {\n\t\t\t\tstruct in6_pktinfo *pktinfo;\n\n\t\t\t\tpktinfo = (struct in6_pktinfo *) CMSG_DATA(cmsghdr);\n\t\t\t\t*ifindex = pktinfo->ipi6_ifindex;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase IPV6_HOPLIMIT:\n\t\t\tif (cmsghdr->cmsg_len == CMSG_LEN(sizeof(int))) {\n\t\t\t\tint *val;\n\n\t\t\t\tval = (int *) CMSG_DATA(cmsghdr);\n\t\t\t\t*hoplimit = *val;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\t*addr = sin6.sin6_addr;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "static void update_exception_bitmap(struct kvm_vcpu *vcpu)\n{\n\tu32 eb;\n\n\teb = (1u << PF_VECTOR) | (1u << UD_VECTOR) | (1u << MC_VECTOR) |\n\t (1u << NM_VECTOR) | (1u << DB_VECTOR) | (1u << AC_VECTOR);\n\tif ((vcpu->guest_debug &\n\t (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)) ==\n\t (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP))\n\t\teb |= 1u << BP_VECTOR;\n\tif (to_vmx(vcpu)->rmode.vm86_active)\n\t\teb = ~0;\n\tif (enable_ept)\n\t\teb &= ~(1u << PF_VECTOR); /* bypass_guest_pf = 0 */\n\tif (vcpu->fpu_active)\n\t\teb &= ~(1u << NM_VECTOR);\n\n\t/* When we are running a nested L2 guest and L1 specified for it a\n\t * certain exception bitmap, we must trap the same exceptions and pass\n\t * them to L1. When running L2, we will only handle the exceptions\n\t * specified above if L1 did not want them.\n\t */\n\tif (is_guest_mode(vcpu))\n\t\teb |= get_vmcs12(vcpu)->exception_bitmap;\n\n\tvmcs_write32(EXCEPTION_BITMAP, eb);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static int cJSON_strcasecmp( const char *s1, const char *s2 )\n{\n\tif ( ! s1 )\n\t\treturn ( s1 == s2 ) ? 0 : 1;\n\tif ( ! s2 )\n\t\treturn 1;\n\tfor ( ; tolower(*s1) == tolower(*s2); ++s1, ++s2)\n\t\tif( *s1 == 0 )\n\t\t\treturn 0;\n\treturn tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "init_ctx_new(OM_uint32 *minor_status,\n\t spnego_gss_cred_id_t spcred,\n\t gss_ctx_id_t *ctx,\n\t send_token_flag *tokflag)\n{\n\tOM_uint32 ret;\n\tspnego_gss_ctx_id_t sc = NULL;\n\n\tsc = create_spnego_ctx(1);\n\tif (sc == NULL)\n\t\treturn GSS_S_FAILURE;\n\n\t/* determine negotiation mech set */\n\tret = get_negotiable_mechs(minor_status, spcred, GSS_C_INITIATE,\n\t\t\t\t &sc->mech_set);\n\tif (ret != GSS_S_COMPLETE)\n\t\tgoto cleanup;\n\n\t/* Set an initial internal mech to make the first context token. */\n\tsc->internal_mech = &sc->mech_set->elements[0];\n\n\tif (put_mech_set(sc->mech_set, &sc->DER_mechTypes) < 0) {\n\t\tret = GSS_S_FAILURE;\n\t\tgoto cleanup;\n\t}\n\n\tsc->ctx_handle = GSS_C_NO_CONTEXT;\n\t*ctx = (gss_ctx_id_t)sc;\n\tsc = NULL;\n\t*tokflag = INIT_TOKEN_SEND;\n\tret = GSS_S_CONTINUE_NEEDED;\n\ncleanup:\n\trelease_spnego_ctx(&sc);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "safe"} {"code": "static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)\n{\n\text3_fsblk_t\tsb_block;\n\tchar\t\t*options = (char *) *data;\n\n\tif (!options || strncmp(options, \"sb=\", 3) != 0)\n\t\treturn 1;\t/* Default location */\n\toptions += 3;\n\t/*todo: use simple_strtoll with >32bit ext3 */\n\tsb_block = simple_strtoul(options, &options, 0);\n\tif (*options && *options != ',') {\n\t\text3_msg(sb, KERN_ERR, \"error: invalid sb specification: %s\",\n\t\t (char *) *data);\n\t\treturn 1;\n\t}\n\tif (*options == ',')\n\t\toptions++;\n\t*data = (void *) options;\n\treturn sb_block;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "R_API RConfigNode* r_config_set(RConfig *cfg, const char *name, const char *value) {\n\tRConfigNode *node = NULL;\n\tchar *ov = NULL;\n\tut64 oi;\n\tif (!cfg || STRNULL (name)) {\n\t\treturn NULL;\n\t}\n\tnode = r_config_node_get (cfg, name);\n\tif (node) {\n\t\tif (node->flags & CN_RO) {\n\t\t\teprintf (\"(error: '%s' config key is read only)\\n\", name);\n\t\t\treturn node;\n\t\t}\n\t\toi = node->i_value;\n\t\tif (node->value) {\n\t\t\tov = strdup (node->value);\n\t\t\tif (!ov) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (\"\");\n\t\t}\n\t\tif (node->flags & CN_BOOL) {\n\t\t\tbool b = is_true (value);\n\t\t\tnode->i_value = (ut64) b? 1: 0;\n\t\t\tchar *value = strdup (r_str_bool (b));\n\t\t\tif (value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = value;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!value) {\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = strdup (\"\");\n\t\t\t\tnode->i_value = 0;\n\t\t\t} else {\n\t\t\t\tif (node->value == value) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tfree (node->value);\n\t\t\t\tnode->value = strdup (value);\n\t\t\t\tif (IS_DIGIT (*value)) {\n\t\t\t\t\tif (strchr (value, '/')) {\n\t\t\t\t\t\tnode->i_value = r_num_get (cfg->num, value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode->i_value = r_num_math (cfg->num, value);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnode->i_value = 0;\n\t\t\t\t}\n\t\t\t\tnode->flags |= CN_INT;\n\t\t\t}\n\t\t}\n\t} else { // Create a new RConfigNode\n\t\toi = UT64_MAX;\n\t\tif (!cfg->lock) {\n\t\t\tnode = r_config_node_new (name, value);\n\t\t\tif (node) {\n\t\t\t\tif (value && is_bool (value)) {\n\t\t\t\t\tnode->flags |= CN_BOOL;\n\t\t\t\t\tnode->i_value = is_true (value)? 1: 0;\n\t\t\t\t}\n\t\t\t\tif (cfg->ht) {\n\t\t\t\t\tht_insert (cfg->ht, node->name, node);\n\t\t\t\t\tr_list_append (cfg->nodes, node);\n\t\t\t\t\tcfg->n_nodes++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teprintf (\"r_config_set: unable to create a new RConfigNode\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"r_config_set: variable '%s' not found\\n\", name);\n\t\t}\n\t}\n\n\tif (node && node->setter) {\n\t\tint ret = node->setter (cfg->user, node);\n\t\tif (ret == false) {\n\t\t\tif (oi != UT64_MAX) {\n\t\t\t\tnode->i_value = oi;\n\t\t\t}\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (ov? ov: \"\");\n\t\t}\n\t}\nbeach:\n\tfree (ov);\n\treturn node;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static void hugetlb_vm_op_close(struct vm_area_struct *vma)\n{\n\tstruct hstate *h = hstate_vma(vma);\n\tstruct resv_map *reservations = vma_resv_map(vma);\n\tstruct hugepage_subpool *spool = subpool_vma(vma);\n\tunsigned long reserve;\n\tunsigned long start;\n\tunsigned long end;\n\n\tif (reservations) {\n\t\tstart = vma_hugecache_offset(h, vma, vma->vm_start);\n\t\tend = vma_hugecache_offset(h, vma, vma->vm_end);\n\n\t\treserve = (end - start) -\n\t\t\tregion_count(&reservations->regions, start, end);\n\n\t\tkref_put(&reservations->refs, resv_map_release);\n\n\t\tif (reserve) {\n\t\t\thugetlb_acct_memory(h, -reserve);\n\t\t\thugepage_subpool_put_pages(spool, reserve);\n\t\t}\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "\nvoid __skb_tstamp_tx(struct sk_buff *orig_skb,\n\t\t struct skb_shared_hwtstamps *hwtstamps,\n\t\t struct sock *sk, int tstype)\n{\n\tstruct sk_buff *skb;\n\tbool tsonly;\n\n\tif (!sk)\n\t\treturn;\n\n\ttsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;\n\tif (!skb_may_tx_timestamp(sk, tsonly))\n\t\treturn;\n\n\tif (tsonly) {\n#ifdef CONFIG_INET\n\t\tif ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_STATS) &&\n\t\t sk->sk_protocol == IPPROTO_TCP &&\n\t\t sk->sk_type == SOCK_STREAM)\n\t\t\tskb = tcp_get_timestamping_opt_stats(sk);\n\t\telse\n#endif\n\t\t\tskb = alloc_skb(0, GFP_ATOMIC);\n\t} else {\n\t\tskb = skb_clone(orig_skb, GFP_ATOMIC);\n\t}\n\tif (!skb)\n\t\treturn;\n\n\tif (tsonly) {\n\t\tskb_shinfo(skb)->tx_flags = skb_shinfo(orig_skb)->tx_flags;\n\t\tskb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey;\n\t}\n\n\tif (hwtstamps)\n\t\t*skb_hwtstamps(skb) = *hwtstamps;\n\telse\n\t\tskb->tstamp = ktime_get_real();\n\n\t__skb_complete_tx_timestamp(skb, sk, tstype);", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "unsigned paravirt_patch_jmp(void *insnbuf, const void *target,\n\t\t\t unsigned long addr, unsigned len)\n{\n\tstruct branch *b = insnbuf;\n\tunsigned long delta = (unsigned long)target - (addr+5);\n\n\tif (len < 5) {\n#ifdef CONFIG_RETPOLINE\n\t\tWARN_ONCE(\"Failing to patch indirect JMP in %ps\\n\", (void *)addr);\n#endif\n\t\treturn len;\t/* call too long for patch site */\n\t}\n\n\tb->opcode = 0xe9;\t/* jmp */\n\tb->delta = delta;\n\n\treturn 5;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len)\n{\n\tsize_t cipher_len;\n\tsize_t i;\n\tunsigned char iv[16] = { 0 };\n\tunsigned char plaintext[4096] = { 0 };\n\tepass2003_exdata *exdata = NULL;\n\n\tif (!card->drv_data) \n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\texdata = (epass2003_exdata *)card->drv_data;\n\n\t/* no cipher */\n\tif (in[0] == 0x99)\n\t\treturn 0;\n\n\t/* parse cipher length */\n\tif (0x01 == in[2] && 0x82 != in[1]) {\n\t\tcipher_len = in[1];\n\t\ti = 3;\n\t}\n\telse if (0x01 == in[3] && 0x81 == in[1]) {\n\t\tcipher_len = in[2];\n\t\ti = 4;\n\t}\n\telse if (0x01 == in[4] && 0x82 == in[1]) {\n\t\tcipher_len = in[2] * 0x100;\n\t\tcipher_len += in[3];\n\t\ti = 5;\n\t}\n\telse {\n\t\treturn -1;\n\t}\n\n\tif (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext)\n\t\treturn -1;\n\n\t/* decrypt */\n\tif (KEY_TYPE_AES == exdata->smtype)\n\t\taes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\telse\n\t\tdes3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\n\t/* unpadding */\n\twhile (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0))\n\t\tcipher_len--;\n\n\tif (2 == cipher_len)\n\t\treturn -1;\n\n\tmemcpy(out, plaintext, cipher_len - 2);\n\t*out_len = cipher_len - 2;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,\n const char **elem_rtrn, const char **field_rtrn,\n ExprDef **index_rtrn)\n{\n switch (expr->expr.op) {\n case EXPR_IDENT:\n *elem_rtrn = NULL;\n *field_rtrn = xkb_atom_text(ctx, expr->ident.ident);\n *index_rtrn = NULL;\n return true;\n case EXPR_FIELD_REF:\n *elem_rtrn = xkb_atom_text(ctx, expr->field_ref.element);\n *field_rtrn = xkb_atom_text(ctx, expr->field_ref.field);\n *index_rtrn = NULL;\n return true;\n case EXPR_ARRAY_REF:\n *elem_rtrn = xkb_atom_text(ctx, expr->array_ref.element);\n *field_rtrn = xkb_atom_text(ctx, expr->array_ref.field);\n *index_rtrn = expr->array_ref.entry;\n return true;\n default:\n break;\n }\n log_wsgo(ctx, \"Unexpected operator %d in ResolveLhs\\n\", expr->expr.op);\n return false;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static void php_mb_regex_free_cache(php_mb_regex_t **pre)\n{\n\tonig_free(*pre);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "void snd_pcm_period_elapsed(struct snd_pcm_substream *substream)\n{\n\tstruct snd_pcm_runtime *runtime;\n\tunsigned long flags;\n\n\tif (PCM_RUNTIME_CHECK(substream))\n\t\treturn;\n\truntime = substream->runtime;\n\n\tsnd_pcm_stream_lock_irqsave(substream, flags);\n\tif (!snd_pcm_running(substream) ||\n\t snd_pcm_update_hw_ptr0(substream, 1) < 0)\n\t\tgoto _end;\n\n#ifdef CONFIG_SND_PCM_TIMER\n\tif (substream->timer_running)\n\t\tsnd_timer_interrupt(substream->timer, 1);\n#endif\n _end:\n\tsnd_pcm_stream_unlock_irqrestore(substream, flags);\n\tkill_fasync(&runtime->fasync, SIGIO, POLL_IN);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,\n\t\t\t unsigned long size, bool kernel, bool pinned,\n\t\t\t struct virtio_gpu_object **bo_ptr)\n{\n\tstruct virtio_gpu_object *bo;\n\tenum ttm_bo_type type;\n\tsize_t acc_size;\n\tint ret;\n\n\tif (kernel)\n\t\ttype = ttm_bo_type_kernel;\n\telse\n\t\ttype = ttm_bo_type_device;\n\t*bo_ptr = NULL;\n\n\tacc_size = ttm_bo_dma_acc_size(&vgdev->mman.bdev, size,\n\t\t\t\t sizeof(struct virtio_gpu_object));\n\n\tbo = kzalloc(sizeof(struct virtio_gpu_object), GFP_KERNEL);\n\tif (bo == NULL)\n\t\treturn -ENOMEM;\n\tsize = roundup(size, PAGE_SIZE);\n\tret = drm_gem_object_init(vgdev->ddev, &bo->gem_base, size);\n\tif (ret != 0)\n\t\treturn ret;\n\tbo->dumb = false;\n\tvirtio_gpu_init_ttm_placement(bo, pinned);\n\n\tret = ttm_bo_init(&vgdev->mman.bdev, &bo->tbo, size, type,\n\t\t\t &bo->placement, 0, !kernel, NULL, acc_size,\n\t\t\t NULL, NULL, &virtio_gpu_ttm_bo_destroy);\n\t/* ttm_bo_init failure will call the destroy */\n\tif (ret != 0)\n\t\treturn ret;\n\n\t*bo_ptr = bo;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-772", "cwe_name": "Missing Release of Resource after Effective Lifetime", "description": "The software does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.", "url": "https://cwe.mitre.org/data/definitions/772.html", "label_name": "vulnerable"} {"code": "unsigned int munlock_vma_page(struct page *page)\n{\n\tunsigned int nr_pages;\n\tstruct zone *zone = page_zone(page);\n\n\t/* For try_to_munlock() and to serialize with page migration */\n\tBUG_ON(!PageLocked(page));\n\n\t/*\n\t * Serialize with any parallel __split_huge_page_refcount() which\n\t * might otherwise copy PageMlocked to part of the tail pages before\n\t * we clear it in the head page. It also stabilizes hpage_nr_pages().\n\t */\n\tspin_lock_irq(&zone->lru_lock);\n\n\tnr_pages = hpage_nr_pages(page);\n\tif (!TestClearPageMlocked(page))\n\t\tgoto unlock_out;\n\n\t__mod_zone_page_state(zone, NR_MLOCK, -nr_pages);\n\n\tif (__munlock_isolate_lru_page(page, true)) {\n\t\tspin_unlock_irq(&zone->lru_lock);\n\t\t__munlock_isolated_page(page);\n\t\tgoto out;\n\t}\n\t__munlock_isolation_failed(page);\n\nunlock_out:\n\tspin_unlock_irq(&zone->lru_lock);\n\nout:\n\treturn nr_pages - 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "void mt_init(mtrand *mt, uint32_t seed) {\n int i;\n mt->mt_buffer_[0] = seed;\n mt->mt_index_ = MT_LEN;\n for (i = 1; i < MT_LEN; i++) {\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n mt->mt_buffer_[i] =\n\t(1812433253UL * (mt->mt_buffer_[i-1] ^ \n\t\t\t (mt->mt_buffer_[i-1] >> 30)) + i);\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "GF_Err ilst_item_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 sub_type;\n\tGF_Box *a = NULL;\n\tGF_ListItemBox *ptr = (GF_ListItemBox *)s;\n\t/*iTunes way: there's a data atom containing the data*/\n\tsub_type = gf_bs_peek_bits(bs, 32, 4);\n\tif (sub_type == GF_ISOM_BOX_TYPE_DATA ) {\n\t\te = gf_isom_box_parse(&a, bs);\n\n\t\tif (!e && a && (ptr->size < a->size)) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[isom] not enough bytes in box %s: %d left, reading %d (file %s, line %d)\\n\", gf_4cc_to_str(ptr->type), ptr->size, a->size, __FILE__, __LINE__ )); \\\n\t\t\te = GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tif (e) {\n\t\t\tif (a) gf_isom_box_del(a);\n\t\t\treturn e;\n\t\t}\n\t\tif (!a) return GF_NON_COMPLIANT_BITSTREAM;\n\n\t\tISOM_DECREASE_SIZE(ptr, a->size);\n\n\t\tif (a && ptr->data) gf_isom_box_del_parent(&ptr->child_boxes, (GF_Box *) ptr->data);\n\n\t\t/* otherwise a->data will always overflow */\n\t\tif (a && a->size > 4 && a->type != GF_ISOM_BOX_TYPE_VOID) {\n\t\t\tptr->data = (GF_DataBox *)a;\n\t\t\tif (!ptr->child_boxes) ptr->child_boxes = gf_list_new();\n\t\t\tgf_list_add(ptr->child_boxes, ptr->data);\n\t\t} else {\n\t\t\tptr->data = NULL;\n\t\t\tgf_isom_box_del(a);\n\t\t}\n\t}\n\t/*QT way*/\n\telse {\n\t\tu64 pos = gf_bs_get_position(bs);\n\t\tu64 prev_size = s->size;\n\t\t/*try parsing as generic box list*/\n\t\te = gf_isom_box_array_read(s, bs, NULL);\n\t\tif (e==GF_OK) return GF_OK;\n\t\t//reset content and retry - this deletes ptr->data !!\n\t\tgf_isom_box_array_del(s->child_boxes);\n\t\ts->child_boxes=NULL;\n\t\tgf_bs_seek(bs, pos);\n\t\ts->size = prev_size;\n\n\t\tptr->data = (GF_DataBox *)gf_isom_box_new_parent(&ptr->child_boxes, GF_ISOM_BOX_TYPE_DATA);\n\t\t//nope, check qt-style\n\t\tptr->data->qt_style = GF_TRUE;\n\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t\tptr->data->dataSize = gf_bs_read_u16(bs);\n\t\tgf_bs_read_u16(bs);\n\n\t\tptr->data->data = (char *) gf_malloc(sizeof(char)*(ptr->data->dataSize + 1));\n\t\tgf_bs_read_data(bs, ptr->data->data, ptr->data->dataSize);\n\t\tptr->data->data[ptr->data->dataSize] = 0;\n\t\tISOM_DECREASE_SIZE(ptr, ptr->data->dataSize);\n\t}\n\treturn GF_OK;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "archive_read_format_zip_cleanup(struct archive_read *a)\n{\n\tstruct zip *zip;\n\tstruct zip_entry *zip_entry, *next_zip_entry;\n\n\tzip = (struct zip *)(a->format->data);\n\n#ifdef HAVE_ZLIB_H\n\tif (zip->stream_valid)\n\t\tinflateEnd(&zip->stream);\n#endif\n\n#if HAVA_LZMA_H && HAVE_LIBLZMA\n if (zip->zipx_lzma_valid) {\n\t\tlzma_end(&zip->zipx_lzma_stream);\n\t}\n#endif\n\n#ifdef HAVE_BZLIB_H\n\tif (zip->bzstream_valid) {\n\t\tBZ2_bzDecompressEnd(&zip->bzstream);\n\t}\n#endif\n\n\tfree(zip->uncompressed_buffer);\n\n\tif (zip->ppmd8_valid)\n\t\t__archive_ppmd8_functions.Ppmd8_Free(&zip->ppmd8);\n\n\tif (zip->zip_entries) {\n\t\tzip_entry = zip->zip_entries;\n\t\twhile (zip_entry != NULL) {\n\t\t\tnext_zip_entry = zip_entry->next;\n\t\t\tarchive_string_free(&zip_entry->rsrcname);\n\t\t\tfree(zip_entry);\n\t\t\tzip_entry = next_zip_entry;\n\t\t}\n\t}\n\tfree(zip->decrypted_buffer);\n\tif (zip->cctx_valid)\n\t\tarchive_decrypto_aes_ctr_release(&zip->cctx);\n\tif (zip->hctx_valid)\n\t\tarchive_hmac_sha1_cleanup(&zip->hctx);\n\tfree(zip->iv);\n\tfree(zip->erd);\n\tfree(zip->v_data);\n\tarchive_string_free(&zip->format_name);\n\tfree(zip);\n\t(a->format->data) = NULL;\n\treturn (ARCHIVE_OK);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-401", "cwe_name": "Missing Release of Memory after Effective Lifetime", "description": "The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.", "url": "https://cwe.mitre.org/data/definitions/401.html", "label_name": "vulnerable"} {"code": "set_lenIV(char *line)\n{\n char *p = strstr(line, \"/lenIV \");\n\n /* Allow lenIV to be negative. Thanks to Tom Kacvinsky */\n if (p && (isdigit(p[7]) || p[7] == '+' || p[7] == '-')) {\n lenIV = atoi(p + 7);\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "check_text_locked(oparg_T *oap)\n{\n if (text_locked())\n {\n\tclearopbeep(oap);\n\ttext_locked_msg();\n\treturn TRUE;\n }\n return FALSE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static RList *r_bin_wasm_get_global_entries (RBinWasmObj *bin, RBinWasmSection *sec) {\n\tRList *ret = NULL;\n\tRBinWasmGlobalEntry *ptr = NULL;\n\n\tif (!(ret = r_list_newf ((RListFree)free))) {\n\t\treturn NULL;\n\t}\n\n\tut8* buf = bin->buf->buf + (ut32)sec->payload_data;\n\tint buflen = bin->buf->length - (ut32)sec->payload_data;\n\tut32 len = sec->payload_len;\n\tut32 count = sec->count;\n\tut32 i = 0, r = 0;\n\n\twhile (i < len && len < buflen && r < count) {\n\t\tif (!(ptr = R_NEW0 (RBinWasmGlobalEntry))) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, (ut8*)&ptr->content_type, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, &ptr->mutability, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_init_expr (buf + i, buf + len, R_BIN_WASM_END_OF_CODE, NULL, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tr_list_append (ret, ptr);\n\t\tr++;\n\t}\n\treturn ret;\nbeach:\n\tfree (ptr);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "cpStripToTile(uint8* out, uint8* in,\n uint32 rows, uint32 cols, int outskew, int64 inskew)\n{\n\twhile (rows-- > 0) {\n\t\tuint32 j = cols;\n\t\twhile (j-- > 0)\n\t\t\t*out++ = *in++;\n\t\tout += outskew;\n\t\tin += inskew;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static void snd_timer_check_master(struct snd_timer_instance *master)\n{\n\tstruct snd_timer_instance *slave, *tmp;\n\n\t/* check all pending slaves */\n\tlist_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) {\n\t\tif (slave->slave_class == master->slave_class &&\n\t\t slave->slave_id == master->slave_id) {\n\t\t\tlist_move_tail(&slave->open_list, &master->slave_list_head);\n\t\t\tspin_lock_irq(&slave_active_lock);\n\t\t\tspin_lock(&master->timer->lock);\n\t\t\tslave->master = master;\n\t\t\tslave->timer = master->timer;\n\t\t\tif (slave->flags & SNDRV_TIMER_IFLG_RUNNING)\n\t\t\t\tlist_add_tail(&slave->active_list,\n\t\t\t\t\t &master->slave_active_head);\n\t\t\tspin_unlock(&master->timer->lock);\n\t\t\tspin_unlock_irq(&slave_active_lock);\n\t\t}\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)\n{\n\tint name_index;\n\tvoid *value = NULL;\n\tsize_t size = 0;\n\tint error;\n\n\tswitch(type) {\n\t\tcase ACL_TYPE_ACCESS:\n\t\t\tname_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;\n\t\t\tif (acl) {\n\t\t\t\terror = posix_acl_update_mode(inode, &inode->i_mode, &acl);\n\t\t\t\tif (error)\n\t\t\t\t\treturn error;\n\t\t\t\tinode->i_ctime = CURRENT_TIME_SEC;\n\t\t\t\tmark_inode_dirty(inode);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ACL_TYPE_DEFAULT:\n\t\t\tname_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;\n\t\t\tif (!S_ISDIR(inode->i_mode))\n\t\t\t\treturn acl ? -EACCES : 0;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t}\n \tif (acl) {\n\t\tvalue = ext2_acl_to_disk(acl, &size);\n\t\tif (IS_ERR(value))\n\t\t\treturn (int)PTR_ERR(value);\n\t}\n\n\terror = ext2_xattr_set(inode, name_index, \"\", value, size, 0);\n\n\tkfree(value);\n\tif (!error)\n\t\tset_cached_acl(inode, type, acl);\n\treturn error;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-285", "cwe_name": "Improper Authorization", "description": "The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/285.html", "label_name": "safe"} {"code": "static int perf_swevent_add(struct perf_event *event, int flags)\n{\n\tstruct swevent_htable *swhash = this_cpu_ptr(&swevent_htable);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct hlist_head *head;\n\n\tif (is_sampling_event(event)) {\n\t\thwc->last_period = hwc->sample_period;\n\t\tperf_swevent_set_period(event);\n\t}\n\n\thwc->state = !(flags & PERF_EF_START);\n\n\thead = find_swevent_head(swhash, event);\n\tif (!head) {\n\t\t/*\n\t\t * We can race with cpu hotplug code. Do not\n\t\t * WARN if the cpu just got unplugged.\n\t\t */\n\t\tWARN_ON_ONCE(swhash->online);\n\t\treturn -EINVAL;\n\t}\n\n\thlist_add_head_rcu(&event->hlist_entry, head);\n\tperf_event_update_userpage(event);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t ignored, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_ctx *ctx = ask->private;\n\tunsigned bs = crypto_ablkcipher_blocksize(crypto_ablkcipher_reqtfm(\n\t\t&ctx->req));\n\tstruct skcipher_sg_list *sgl;\n\tstruct scatterlist *sg;\n\tunsigned long iovlen;\n\tstruct iovec *iov;\n\tint err = -EAGAIN;\n\tint used;\n\tlong copied = 0;\n\n\tlock_sock(sk);\n\tmsg->msg_namelen = 0;\n\tfor (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0;\n\t iovlen--, iov++) {\n\t\tunsigned long seglen = iov->iov_len;\n\t\tchar __user *from = iov->iov_base;\n\n\t\twhile (seglen) {\n\t\t\tsgl = list_first_entry(&ctx->tsgl,\n\t\t\t\t\t struct skcipher_sg_list, list);\n\t\t\tsg = sgl->sg;\n\n\t\t\twhile (!sg->length)\n\t\t\t\tsg++;\n\n\t\t\tused = ctx->used;\n\t\t\tif (!used) {\n\t\t\t\terr = skcipher_wait_for_data(sk, flags);\n\t\t\t\tif (err)\n\t\t\t\t\tgoto unlock;\n\t\t\t}\n\n\t\t\tused = min_t(unsigned long, used, seglen);\n\n\t\t\tused = af_alg_make_sg(&ctx->rsgl, from, used, 1);\n\t\t\terr = used;\n\t\t\tif (err < 0)\n\t\t\t\tgoto unlock;\n\n\t\t\tif (ctx->more || used < ctx->used)\n\t\t\t\tused -= used % bs;\n\n\t\t\terr = -EINVAL;\n\t\t\tif (!used)\n\t\t\t\tgoto free;\n\n\t\t\tablkcipher_request_set_crypt(&ctx->req, sg,\n\t\t\t\t\t\t ctx->rsgl.sg, used,\n\t\t\t\t\t\t ctx->iv);\n\n\t\t\terr = af_alg_wait_for_completion(\n\t\t\t\tctx->enc ?\n\t\t\t\t\tcrypto_ablkcipher_encrypt(&ctx->req) :\n\t\t\t\t\tcrypto_ablkcipher_decrypt(&ctx->req),\n\t\t\t\t&ctx->completion);\n\nfree:\n\t\t\taf_alg_free_sg(&ctx->rsgl);\n\n\t\t\tif (err)\n\t\t\t\tgoto unlock;\n\n\t\t\tcopied += used;\n\t\t\tfrom += used;\n\t\t\tseglen -= used;\n\t\t\tskcipher_pull_sgl(sk, used);\n\t\t}\n\t}\n\n\terr = 0;\n\nunlock:\n\tskcipher_wmem_wakeup(sk);\n\trelease_sock(sk);\n\n\treturn copied ?: err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static void smp_task_timedout(struct timer_list *t)\n{\n\tstruct sas_task_slow *slow = from_timer(slow, t, timer);\n\tstruct sas_task *task = slow->task;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&task->task_state_lock, flags);\n\tif (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {\n\t\ttask->task_state_flags |= SAS_TASK_STATE_ABORTED;\n\t\tcomplete(&task->slow_task->completion);\n\t}\n\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static int DefragMfIpv6Test(void)\n{\n int retval = 0;\n int ip_id = 9;\n Packet *p = NULL;\n\n DefragInit();\n\n Packet *p1 = IPV6BuildTestPacket(ip_id, 2, 1, 'C', 8);\n Packet *p2 = IPV6BuildTestPacket(ip_id, 0, 1, 'A', 8);\n Packet *p3 = IPV6BuildTestPacket(ip_id, 1, 0, 'B', 8);\n if (p1 == NULL || p2 == NULL || p3 == NULL) {\n goto end;\n }\n\n p = Defrag(NULL, NULL, p1, NULL);\n if (p != NULL) {\n goto end;\n }\n\n p = Defrag(NULL, NULL, p2, NULL);\n if (p != NULL) {\n goto end;\n }\n\n /* This should return a packet as MF=0. */\n p = Defrag(NULL, NULL, p3, NULL);\n if (p == NULL) {\n goto end;\n }\n\n /* For IPv6 the expected length is just the length of the payload\n * of 2 fragments, so 16. */\n if (IPV6_GET_PLEN(p) != 16) {\n goto end;\n }\n\n retval = 1;\nend:\n if (p1 != NULL) {\n SCFree(p1);\n }\n if (p2 != NULL) {\n SCFree(p2);\n }\n if (p3 != NULL) {\n SCFree(p3);\n }\n if (p != NULL) {\n SCFree(p);\n }\n DefragDestroy();\n return retval;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "vulnerable"} {"code": "int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)\n{\n\tstruct ip_options_rcu *opt;\n\tint res = -ENOMSG;\n\n\trcu_read_lock();\n\topt = rcu_dereference(inet_sk(sk)->inet_opt);\n\tif (opt && opt->opt.cipso)\n\t\tres = cipso_v4_getattr(opt->opt.__data +\n\t\t\t\t\t\topt->opt.cipso -\n\t\t\t\t\t\tsizeof(struct iphdr),\n\t\t\t\t secattr);\n\trcu_read_unlock();\n\treturn res;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "xfs_attr_rmtval_get(\n\tstruct xfs_da_args\t*args)\n{\n\tstruct xfs_bmbt_irec\tmap[ATTR_RMTVALUE_MAPSIZE];\n\tstruct xfs_mount\t*mp = args->dp->i_mount;\n\tstruct xfs_buf\t\t*bp;\n\txfs_dablk_t\t\tlblkno = args->rmtblkno;\n\t__uint8_t\t\t*dst = args->value;\n\tint\t\t\tvaluelen = args->valuelen;\n\tint\t\t\tnmap;\n\tint\t\t\terror;\n\tint\t\t\tblkcnt = args->rmtblkcnt;\n\tint\t\t\ti;\n\tint\t\t\toffset = 0;\n\n\ttrace_xfs_attr_rmtval_get(args);\n\n\tASSERT(!(args->flags & ATTR_KERNOVAL));\n\n\twhile (valuelen > 0) {\n\t\tnmap = ATTR_RMTVALUE_MAPSIZE;\n\t\terror = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,\n\t\t\t\t blkcnt, map, &nmap,\n\t\t\t\t XFS_BMAPI_ATTRFORK);\n\t\tif (error)\n\t\t\treturn error;\n\t\tASSERT(nmap >= 1);\n\n\t\tfor (i = 0; (i < nmap) && (valuelen > 0); i++) {\n\t\t\txfs_daddr_t\tdblkno;\n\t\t\tint\t\tdblkcnt;\n\n\t\t\tASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&\n\t\t\t (map[i].br_startblock != HOLESTARTBLOCK));\n\t\t\tdblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);\n\t\t\tdblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);\n\t\t\terror = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,\n\t\t\t\t\t\t dblkno, dblkcnt, 0, &bp,\n\t\t\t\t\t\t &xfs_attr3_rmt_buf_ops);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\n\t\t\terror = xfs_attr_rmtval_copyout(mp, bp, args->dp->i_ino,\n\t\t\t\t\t\t\t&offset, &valuelen,\n\t\t\t\t\t\t\t&dst);\n\t\t\txfs_buf_relse(bp);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\n\t\t\t/* roll attribute extent map forwards */\n\t\t\tlblkno += map[i].br_blockcount;\n\t\t\tblkcnt -= map[i].br_blockcount;\n\t\t}\n\t}\n\tASSERT(valuelen == 0);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "vulnerable"} {"code": "sshkey_load_file(int fd, struct sshbuf *blob)\n{\n\tu_char buf[1024];\n\tsize_t len;\n\tstruct stat st;\n\tint r, dontmax = 0;\n\n\tif (fstat(fd, &st) < 0)\n\t\treturn SSH_ERR_SYSTEM_ERROR;\n\tif ((st.st_mode & (S_IFSOCK|S_IFCHR|S_IFIFO)) == 0 &&\n\t st.st_size > MAX_KEY_FILE_SIZE)\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\t/*\n\t * Pre-allocate the buffer used for the key contents and clamp its\n\t * maximum size. This ensures that key contents are never leaked via\n\t * implicit realloc() in the sshbuf code.\n\t */\n\tif ((st.st_mode & S_IFREG) == 0 || st.st_size <= 0) {\n\t\tst.st_size = 64*1024; /* 64k should be enough for anyone :) */\n\t\tdontmax = 1;\n\t}\n\tif ((r = sshbuf_allocate(blob, st.st_size)) != 0 ||\n\t (dontmax && (r = sshbuf_set_max_size(blob, st.st_size)) != 0))\n\t\treturn r;\n\tfor (;;) {\n\t\tif ((len = atomicio(read, fd, buf, sizeof(buf))) == 0) {\n\t\t\tif (errno == EPIPE)\n\t\t\t\tbreak;\n\t\t\tr = SSH_ERR_SYSTEM_ERROR;\n\t\t\tgoto out;\n\t\t}\n\t\tif ((r = sshbuf_put(blob, buf, len)) != 0)\n\t\t\tgoto out;\n\t\tif (sshbuf_len(blob) > MAX_KEY_FILE_SIZE) {\n\t\t\tr = SSH_ERR_INVALID_FORMAT;\n\t\t\tgoto out;\n\t\t}\n\t}\n\tif ((st.st_mode & (S_IFSOCK|S_IFCHR|S_IFIFO)) == 0 &&\n\t st.st_size != (off_t)sshbuf_len(blob)) {\n\t\tr = SSH_ERR_FILE_CHANGED;\n\t\tgoto out;\n\t}\n\tr = 0;\n\n out:\n\texplicit_bzero(buf, sizeof(buf));\n\tif (r != 0)\n\t\tsshbuf_reset(blob);\n\treturn r;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-320", "cwe_name": "Key Management Errors", "description": "Weaknesses in this category are related to errors in the management of cryptographic keys.", "url": "https://cwe.mitre.org/data/definitions/320.html", "label_name": "safe"} {"code": "void vmacache_flush_all(struct mm_struct *mm)\n{\n\tstruct task_struct *g, *p;\n\n\tcount_vm_vmacache_event(VMACACHE_FULL_FLUSHES);\n\n\t/*\n\t * Single threaded tasks need not iterate the entire\n\t * list of process. We can avoid the flushing as well\n\t * since the mm's seqnum was increased and don't have\n\t * to worry about other threads' seqnum. Current's\n\t * flush will occur upon the next lookup.\n\t */\n\tif (atomic_read(&mm->mm_users) == 1)\n\t\treturn;\n\n\trcu_read_lock();\n\tfor_each_process_thread(g, p) {\n\t\t/*\n\t\t * Only flush the vmacache pointers as the\n\t\t * mm seqnum is already set and curr's will\n\t\t * be set upon invalidation when the next\n\t\t * lookup is done.\n\t\t */\n\t\tif (mm == p->mm)\n\t\t\tvmacache_flush(p);\n\t}\n\trcu_read_unlock();\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)\n{\n\tstruct xen_pcibk_dev_data *dev_data;\n\tint err;\n\tu16 val;\n\tstruct pci_cmd_info *cmd = data;\n\n\tdev_data = pci_get_drvdata(dev);\n\tif (!pci_is_enabled(dev) && is_enable_cmd(value)) {\n\t\tif (unlikely(verbose_request))\n\t\t\tprintk(KERN_DEBUG DRV_NAME \": %s: enable\\n\",\n\t\t\t pci_name(dev));\n\t\terr = pci_enable_device(dev);\n\t\tif (err)\n\t\t\treturn err;\n\t\tif (dev_data)\n\t\t\tdev_data->enable_intx = 1;\n\t} else if (pci_is_enabled(dev) && !is_enable_cmd(value)) {\n\t\tif (unlikely(verbose_request))\n\t\t\tprintk(KERN_DEBUG DRV_NAME \": %s: disable\\n\",\n\t\t\t pci_name(dev));\n\t\tpci_disable_device(dev);\n\t\tif (dev_data)\n\t\t\tdev_data->enable_intx = 0;\n\t}\n\n\tif (!dev->is_busmaster && is_master_cmd(value)) {\n\t\tif (unlikely(verbose_request))\n\t\t\tprintk(KERN_DEBUG DRV_NAME \": %s: set bus master\\n\",\n\t\t\t pci_name(dev));\n\t\tpci_set_master(dev);\n\t}\n\n\tif (value & PCI_COMMAND_INVALIDATE) {\n\t\tif (unlikely(verbose_request))\n\t\t\tprintk(KERN_DEBUG\n\t\t\t DRV_NAME \": %s: enable memory-write-invalidate\\n\",\n\t\t\t pci_name(dev));\n\t\terr = pci_set_mwi(dev);\n\t\tif (err) {\n\t\t\tpr_warn(\"%s: cannot enable memory-write-invalidate (%d)\\n\",\n\t\t\t\tpci_name(dev), err);\n\t\t\tvalue &= ~PCI_COMMAND_INVALIDATE;\n\t\t}\n\t}\n\n\tcmd->val = value;\n\n\tif (!permissive && (!dev_data || !dev_data->permissive))\n\t\treturn 0;\n\n\t/* Only allow the guest to control certain bits. */\n\terr = pci_read_config_word(dev, offset, &val);\n\tif (err || val == value)\n\t\treturn err;\n\n\tvalue &= PCI_COMMAND_GUEST;\n\tvalue |= val & ~PCI_COMMAND_GUEST;\n\n\treturn pci_write_config_word(dev, offset, value);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static void encode_share_access(struct xdr_stream *xdr, int open_flags)\n{\n\t__be32 *p;\n\n\tRESERVE_SPACE(8);\n\tswitch (open_flags & (FMODE_READ|FMODE_WRITE)) {\n\t\tcase FMODE_READ:\n\t\t\tWRITE32(NFS4_SHARE_ACCESS_READ);\n\t\t\tbreak;\n\t\tcase FMODE_WRITE:\n\t\t\tWRITE32(NFS4_SHARE_ACCESS_WRITE);\n\t\t\tbreak;\n\t\tcase FMODE_READ|FMODE_WRITE:\n\t\t\tWRITE32(NFS4_SHARE_ACCESS_BOTH);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tBUG();\n\t}\n\tWRITE32(0);\t\t/* for linux, share_deny = 0 always */\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,\n\t\t\t\tunsigned long end, unsigned long vmflag)\n{\n\tunsigned long addr;\n\t/* do a global flush by default */\n\tunsigned long base_pages_to_flush = TLB_FLUSH_ALL;\n\n\tpreempt_disable();\n\tif (current->active_mm != mm) {\n\t\t/* Synchronize with switch_mm. */\n\t\tsmp_mb();\n\n\t\tgoto out;\n\t}\n\n\tif (!current->mm) {\n\t\tleave_mm(smp_processor_id());\n\n\t\t/* Synchronize with switch_mm. */\n\t\tsmp_mb();\n\n\t\tgoto out;\n\t}\n\n\tif ((end != TLB_FLUSH_ALL) && !(vmflag & VM_HUGETLB))\n\t\tbase_pages_to_flush = (end - start) >> PAGE_SHIFT;\n\n\t/*\n\t * Both branches below are implicit full barriers (MOV to CR or\n\t * INVLPG) that synchronize with switch_mm.\n\t */\n\tif (base_pages_to_flush > tlb_single_page_flush_ceiling) {\n\t\tbase_pages_to_flush = TLB_FLUSH_ALL;\n\t\tcount_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);\n\t\tlocal_flush_tlb();\n\t} else {\n\t\t/* flush range by one by one 'invlpg' */\n\t\tfor (addr = start; addr < end;\taddr += PAGE_SIZE) {\n\t\t\tcount_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);\n\t\t\t__flush_tlb_single(addr);\n\t\t}\n\t}\n\ttrace_tlb_flush(TLB_LOCAL_MM_SHOOTDOWN, base_pages_to_flush);\nout:\n\tif (base_pages_to_flush == TLB_FLUSH_ALL) {\n\t\tstart = 0UL;\n\t\tend = TLB_FLUSH_ALL;\n\t}\n\tif (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids)\n\t\tflush_tlb_others(mm_cpumask(mm), mm, start, end);\n\tpreempt_enable();\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "BOOL rdp_decrypt(rdpRdp* rdp, STREAM* s, int length, UINT16 securityFlags)\n{\n\tBYTE cmac[8];\n\tBYTE wmac[8];\n\n\tif (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)\n\t{\n\t\tUINT16 len;\n\t\tBYTE version, pad;\n\t\tBYTE* sig;\n\n\t\tif (stream_get_left(s) < 12)\n\t\t\treturn FALSE;\n\n\t\tstream_read_UINT16(s, len); /* 0x10 */\n\t\tstream_read_BYTE(s, version); /* 0x1 */\n\t\tstream_read_BYTE(s, pad);\n\n\t\tsig = s->p;\n\t\tstream_seek(s, 8);\t/* signature */\n\n\t\tlength -= 12;\n\n\t\tif (!security_fips_decrypt(s->p, length, rdp))\n\t\t{\n\t\t\tprintf(\"FATAL: cannot decrypt\\n\");\n\t\t\treturn FALSE; /* TODO */\n\t\t}\n\n\t\tif (!security_fips_check_signature(s->p, length - pad, sig, rdp))\n\t\t{\n\t\t\tprintf(\"FATAL: invalid packet signature\\n\");\n\t\t\treturn FALSE; /* TODO */\n\t\t}\n\n\t\t/* is this what needs adjusting? */\n\t\ts->size -= pad;\n\t\treturn TRUE;\n\t}\n\n\tif (stream_get_left(s) < 8)\n\t\treturn FALSE;\n\n\tstream_read(s, wmac, sizeof(wmac));\n\tlength -= sizeof(wmac);\n\tif (!security_decrypt(s->p, length, rdp))\n\t\treturn FALSE;\n\n\tif (securityFlags & SEC_SECURE_CHECKSUM)\n\t\tsecurity_salted_mac_signature(rdp, s->p, length, FALSE, cmac);\n\telse\n\t\tsecurity_mac_signature(rdp, s->p, length, cmac);\n\n\tif (memcmp(wmac, cmac, sizeof(wmac)) != 0)\n\t{\n\t\tprintf(\"WARNING: invalid packet signature\\n\");\n\t\t/*\n\t\t * Because Standard RDP Security is totally broken,\n\t\t * and cannot protect against MITM, don't treat signature\n\t\t * verification failure as critical. This at least enables\n\t\t * us to work with broken RDP clients and servers that\n\t\t * generate invalid signatures.\n\t\t */\n\t\t//return FALSE;\n\t}\n\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node)\n{\n\t/* through the first node_set .parent\n\t * mycluster/nodes/mynode == o2nm_cluster->o2nm_node_group->o2nm_node */\n\treturn to_o2nm_cluster(node->nd_item.ci_parent->ci_parent);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "ossl_cipher_initialize(VALUE self, VALUE str)\n{\n EVP_CIPHER_CTX *ctx;\n const EVP_CIPHER *cipher;\n char *name;\n unsigned char dummy_key[EVP_MAX_KEY_LENGTH] = { 0 };\n\n name = StringValueCStr(str);\n GetCipherInit(self, ctx);\n if (ctx) {\n\tossl_raise(rb_eRuntimeError, \"Cipher already inititalized!\");\n }\n AllocCipher(self, ctx);\n if (!(cipher = EVP_get_cipherbyname(name))) {\n\tossl_raise(rb_eRuntimeError, \"unsupported cipher algorithm (%\"PRIsVALUE\")\", str);\n }\n /*\n * EVP_CipherInit_ex() allows to specify NULL to key and IV, however some\n * ciphers don't handle well (OpenSSL's bug). [Bug #2768]\n *\n * The EVP which has EVP_CIPH_RAND_KEY flag (such as DES3) allows\n * uninitialized key, but other EVPs (such as AES) does not allow it.\n * Calling EVP_CipherUpdate() without initializing key causes SEGV so we\n * set the data filled with \"\\0\" as the key by default.\n */\n if (EVP_CipherInit_ex(ctx, cipher, NULL, dummy_key, NULL, -1) != 1)\n\tossl_raise(eCipherError, NULL);\n\n return self;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-326", "cwe_name": "Inadequate Encryption Strength", "description": "The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.", "url": "https://cwe.mitre.org/data/definitions/326.html", "label_name": "vulnerable"} {"code": "BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)\n{\n\t_gdImageJpegCtx(im, outfile, quality);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "DECLAREcpFunc(cpSeparate2ContigByRow)\n{\n\ttsize_t scanlinesizein = TIFFScanlineSize(in);\n\ttsize_t scanlinesizeout = TIFFScanlineSize(out);\n\ttdata_t inbuf;\n\ttdata_t outbuf;\n\tregister uint8 *inp, *outp;\n\tregister uint32 n;\n\tuint32 row;\n\ttsample_t s;\n uint16 bps = 0;\n\n (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);\n if( bps != 8 )\n {\n TIFFError(TIFFFileName(in),\n \"Error, can only handle BitsPerSample=8 in %s\",\n \"cpSeparate2ContigByRow\");\n return 0;\n }\n\n\tinbuf = _TIFFmalloc(scanlinesizein);\n\toutbuf = _TIFFmalloc(scanlinesizeout);\n\tif (!inbuf || !outbuf)\n goto bad;\n\t_TIFFmemset(inbuf, 0, scanlinesizein);\n\t_TIFFmemset(outbuf, 0, scanlinesizeout);\n\tfor (row = 0; row < imagelength; row++) {\n\t\t/* merge channels */\n\t\tfor (s = 0; s < spp; s++) {\n\t\t\tif (TIFFReadScanline(in, inbuf, row, s) < 0\n\t\t\t && !ignore) {\n\t\t\t\tTIFFError(TIFFFileName(in),\n\t\t\t\t \"Error, can't read scanline %lu\",\n\t\t\t\t (unsigned long) row);\n\t\t\t\tgoto bad;\n\t\t\t}\n\t\t\tinp = (uint8*)inbuf;\n\t\t\toutp = ((uint8*)outbuf) + s;\n\t\t\tfor (n = imagewidth; n-- > 0;) {\n\t\t\t\t*outp = *inp++;\n\t\t\t\toutp += spp;\n\t\t\t}\n\t\t}\n\t\tif (TIFFWriteScanline(out, outbuf, row, 0) < 0) {\n\t\t\tTIFFError(TIFFFileName(out),\n\t\t\t \"Error, can't write scanline %lu\",\n\t\t\t (unsigned long) row);\n\t\t\tgoto bad;\n\t\t}\n\t}\n\tif (inbuf) _TIFFfree(inbuf);\n\tif (outbuf) _TIFFfree(outbuf);\n\treturn 1;\nbad:\n\tif (inbuf) _TIFFfree(inbuf);\n\tif (outbuf) _TIFFfree(outbuf);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,\n\t\t\t size_t cnt, loff_t *ppos)\n{\n\tint r, i;\n\tchar *pdata;\n\tchar *p;\n\tchar *p0;\n\tchar *p1;\n\tchar *p2;\n\tstruct debug_data *d = f->private_data;\n\n\tpdata = kmalloc(cnt, GFP_KERNEL);\n\tif (pdata == NULL)\n\t\treturn 0;\n\n\tif (copy_from_user(pdata, buf, cnt)) {\n\t\tlbs_deb_debugfs(\"Copy from user failed\\n\");\n\t\tkfree(pdata);\n\t\treturn 0;\n\t}\n\n\tp0 = pdata;\n\tfor (i = 0; i < num_of_items; i++) {\n\t\tdo {\n\t\t\tp = strstr(p0, d[i].name);\n\t\t\tif (p == NULL)\n\t\t\t\tbreak;\n\t\t\tp1 = strchr(p, '\\n');\n\t\t\tif (p1 == NULL)\n\t\t\t\tbreak;\n\t\t\tp0 = p1++;\n\t\t\tp2 = strchr(p, '=');\n\t\t\tif (!p2)\n\t\t\t\tbreak;\n\t\t\tp2++;\n\t\t\tr = simple_strtoul(p2, NULL, 0);\n\t\t\tif (d[i].size == 1)\n\t\t\t\t*((u8 *) d[i].addr) = (u8) r;\n\t\t\telse if (d[i].size == 2)\n\t\t\t\t*((u16 *) d[i].addr) = (u16) r;\n\t\t\telse if (d[i].size == 4)\n\t\t\t\t*((u32 *) d[i].addr) = (u32) r;\n\t\t\telse if (d[i].size == 8)\n\t\t\t\t*((u64 *) d[i].addr) = (u64) r;\n\t\t\tbreak;\n\t\t} while (1);\n\t}\n\tkfree(pdata);\n\n\treturn (ssize_t)cnt;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t *\n p_code_block)\n{\n OPJ_UINT32 l_data_size;\n\n /* The +1 is needed for https://github.com/uclouvain/openjpeg/issues/835 */\n l_data_size = 1 + (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) *\n (p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32));\n\n if (l_data_size > p_code_block->data_size) {\n if (p_code_block->data) {\n /* We refer to data - 1 since below we incremented it */\n opj_free(p_code_block->data - 1);\n }\n p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size + 1);\n if (! p_code_block->data) {\n p_code_block->data_size = 0U;\n return OPJ_FALSE;\n }\n p_code_block->data_size = l_data_size;\n\n /* We reserve the initial byte as a fake byte to a non-FF value */\n /* and increment the data pointer, so that opj_mqc_init_enc() */\n /* can do bp = data - 1, and opj_mqc_byteout() can safely dereference */\n /* it. */\n p_code_block->data[0] = 0;\n p_code_block->data += 1; /*why +1 ?*/\n }\n return OPJ_TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int crypto_report_one(struct crypto_alg *alg,\n\t\t\t struct crypto_user_alg *ualg, struct sk_buff *skb)\n{\n\tstrncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));\n\tstrncpy(ualg->cru_driver_name, alg->cra_driver_name,\n\t\tsizeof(ualg->cru_driver_name));\n\tstrncpy(ualg->cru_module_name, module_name(alg->cra_module),\n\t\tsizeof(ualg->cru_module_name));\n\n\tualg->cru_type = 0;\n\tualg->cru_mask = 0;\n\tualg->cru_flags = alg->cra_flags;\n\tualg->cru_refcnt = refcount_read(&alg->cra_refcnt);\n\n\tif (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority))\n\t\tgoto nla_put_failure;\n\tif (alg->cra_flags & CRYPTO_ALG_LARVAL) {\n\t\tstruct crypto_report_larval rl;\n\n\t\tstrncpy(rl.type, \"larval\", sizeof(rl.type));\n\t\tif (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL,\n\t\t\t sizeof(struct crypto_report_larval), &rl))\n\t\t\tgoto nla_put_failure;\n\t\tgoto out;\n\t}\n\n\tif (alg->cra_type && alg->cra_type->report) {\n\t\tif (alg->cra_type->report(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tgoto out;\n\t}\n\n\tswitch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {\n\tcase CRYPTO_ALG_TYPE_CIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_COMPRESS:\n\t\tif (crypto_report_comp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_ACOMPRESS:\n\t\tif (crypto_report_acomp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_AKCIPHER:\n\t\tif (crypto_report_akcipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_KPP:\n\t\tif (crypto_report_kpp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\t}\n\nout:\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "videobuf_vm_open(struct vm_area_struct *vma)\n{\n\tstruct videobuf_mapping *map = vma->vm_private_data;\n\n\tdprintk(2,\"vm_open %p [count=%u,vma=%08lx-%08lx]\\n\",map,\n\t\tmap->count,vma->vm_start,vma->vm_end);\n\n\tmap->count++;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static Jsi_RC DebugRemoveCmd_(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n Jsi_Value **ret, Jsi_Func *funcPtr, int op)\n{\n Jsi_Value *val = Jsi_ValueArrayIndex(interp, args, 0);\n if (interp->breakpointHash)\n {\n int num;\n char nbuf[100];\n if (Jsi_GetIntFromValue(interp, val, &num) != JSI_OK) \n return Jsi_LogError(\"bad number\");\n \n snprintf(nbuf, sizeof(nbuf), \"%d\", num);\n Jsi_HashEntry *hPtr = Jsi_HashEntryFind(interp->breakpointHash, nbuf);\n jsi_BreakPoint* bptr;\n if (hPtr && (bptr = (jsi_BreakPoint*)Jsi_HashValueGet(hPtr))) {\n switch (op) {\n case 1: bptr->enabled = 0; break;\n case 2: bptr->enabled = 1; break;\n default:\n Jsi_HashEntryDelete(hPtr);\n }\n return JSI_OK;\n }\n }\n return Jsi_LogError(\"unknown breakpoint\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)TypeIgnore_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n int lineno;\n\n if (_PyObject_HasAttrId(obj, &PyId_lineno)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_lineno);\n if (tmp == NULL) goto failed;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from TypeIgnore\");\n return 1;\n }\n *out = TypeIgnore(lineno, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of type_ignore, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)\n{\n png_alloc_size_t limit = PNG_UINT_31_MAX;\n\n# ifdef PNG_SET_USER_LIMITS_SUPPORTED\n if (png_ptr->user_chunk_malloc_max > 0 &&\n png_ptr->user_chunk_malloc_max < limit)\n limit = png_ptr->user_chunk_malloc_max;\n# elif PNG_USER_CHUNK_MALLOC_MAX > 0\n if (PNG_USER_CHUNK_MALLOC_MAX < limit)\n limit = PNG_USER_CHUNK_MALLOC_MAX;\n# endif\n if (png_ptr->chunk_name == png_IDAT)\n {\n png_alloc_size_t idat_limit = PNG_UINT_31_MAX;\n size_t row_factor =\n (size_t)png_ptr->width\n * (size_t)png_ptr->channels\n * (png_ptr->bit_depth > 8? 2: 1)\n + 1\n + (png_ptr->interlaced? 6: 0);\n if (png_ptr->height > PNG_UINT_32_MAX/row_factor)\n idat_limit = PNG_UINT_31_MAX;\n else\n idat_limit = png_ptr->height * row_factor;\n row_factor = row_factor > 32566? 32566 : row_factor;\n idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */\n idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;\n limit = limit < idat_limit? idat_limit : limit;\n }\n\n if (length > limit)\n {\n png_debug2(0,\" length = %lu, limit = %lu\",\n (unsigned long)length,(unsigned long)limit);\n png_chunk_error(png_ptr, \"chunk data is too large\");\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "pci_emul_add_msixcap(struct pci_vdev *dev, int msgnum, int barnum)\n{\n\tuint32_t tab_size;\n\tstruct msixcap msixcap;\n\n\tassert(msgnum >= 1 && msgnum <= MAX_MSIX_TABLE_ENTRIES);\n\tassert(barnum >= 0 && barnum <= PCIR_MAX_BAR_0);\n\n\ttab_size = msgnum * MSIX_TABLE_ENTRY_SIZE;\n\n\t/* Align table size to nearest 4K */\n\ttab_size = roundup2(tab_size, 4096);\n\n\tdev->msix.table_bar = barnum;\n\tdev->msix.pba_bar = barnum;\n\tdev->msix.table_offset = 0;\n\tdev->msix.table_count = msgnum;\n\tdev->msix.pba_offset = tab_size;\n\tdev->msix.pba_size = PBA_SIZE(msgnum);\n\n\tpci_msix_table_init(dev, msgnum);\n\n\tpci_populate_msixcap(&msixcap, msgnum, barnum, tab_size);\n\n\t/* allocate memory for MSI-X Table and PBA */\n\tpci_emul_alloc_bar(dev, barnum, PCIBAR_MEM32,\n\t\t\t\ttab_size + dev->msix.pba_size);\n\n\treturn (pci_emul_add_capability(dev, (u_char *)&msixcap,\n\t\t\t\t\tsizeof(msixcap)));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "static inline void init_idle_pids(struct pid_link *links)\n{\n\tenum pid_type type;\n\n\tfor (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) {\n\t\tINIT_HLIST_NODE(&links[type].node); /* not really needed */\n\t\tlinks[type].pid = &init_struct_pid;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int hns_gmac_get_sset_count(int stringset)\n{\n\tif (stringset == ETH_SS_STATS)\n\t\treturn ARRAY_SIZE(g_gmac_stats_string);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int get_gate_page(struct mm_struct *mm, unsigned long address,\n\t\tunsigned int gup_flags, struct vm_area_struct **vma,\n\t\tstruct page **page)\n{\n\tpgd_t *pgd;\n\tp4d_t *p4d;\n\tpud_t *pud;\n\tpmd_t *pmd;\n\tpte_t *pte;\n\tint ret = -EFAULT;\n\n\t/* user gate pages are read-only */\n\tif (gup_flags & FOLL_WRITE)\n\t\treturn -EFAULT;\n\tif (address > TASK_SIZE)\n\t\tpgd = pgd_offset_k(address);\n\telse\n\t\tpgd = pgd_offset_gate(mm, address);\n\tBUG_ON(pgd_none(*pgd));\n\tp4d = p4d_offset(pgd, address);\n\tBUG_ON(p4d_none(*p4d));\n\tpud = pud_offset(p4d, address);\n\tBUG_ON(pud_none(*pud));\n\tpmd = pmd_offset(pud, address);\n\tif (!pmd_present(*pmd))\n\t\treturn -EFAULT;\n\tVM_BUG_ON(pmd_trans_huge(*pmd));\n\tpte = pte_offset_map(pmd, address);\n\tif (pte_none(*pte))\n\t\tgoto unmap;\n\t*vma = get_gate_vma(mm);\n\tif (!page)\n\t\tgoto out;\n\t*page = vm_normal_page(*vma, address, *pte);\n\tif (!*page) {\n\t\tif ((gup_flags & FOLL_DUMP) || !is_zero_pfn(pte_pfn(*pte)))\n\t\t\tgoto unmap;\n\t\t*page = pte_page(*pte);\n\n\t\t/*\n\t\t * This should never happen (a device public page in the gate\n\t\t * area).\n\t\t */\n\t\tif (is_device_public_page(*page))\n\t\t\tgoto unmap;\n\t}\n\tget_page(*page);\nout:\n\tret = 0;\nunmap:\n\tpte_unmap(pte);\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "int key_reject_and_link(struct key *key,\n\t\t\tunsigned timeout,\n\t\t\tunsigned error,\n\t\t\tstruct key *keyring,\n\t\t\tstruct key *authkey)\n{\n\tstruct assoc_array_edit *edit;\n\tstruct timespec now;\n\tint ret, awaken, link_ret = 0;\n\n\tkey_check(key);\n\tkey_check(keyring);\n\n\tawaken = 0;\n\tret = -EBUSY;\n\n\tif (keyring) {\n\t\tif (keyring->restrict_link)\n\t\t\treturn -EPERM;\n\n\t\tlink_ret = __key_link_begin(keyring, &key->index_key, &edit);\n\t}\n\n\tmutex_lock(&key_construction_mutex);\n\n\t/* can't instantiate twice */\n\tif (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) {\n\t\t/* mark the key as being negatively instantiated */\n\t\tatomic_inc(&key->user->nikeys);\n\t\tkey->reject_error = -error;\n\t\tsmp_wmb();\n\t\tset_bit(KEY_FLAG_NEGATIVE, &key->flags);\n\t\tset_bit(KEY_FLAG_INSTANTIATED, &key->flags);\n\t\tnow = current_kernel_time();\n\t\tkey->expiry = now.tv_sec + timeout;\n\t\tkey_schedule_gc(key->expiry + key_gc_delay);\n\n\t\tif (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags))\n\t\t\tawaken = 1;\n\n\t\tret = 0;\n\n\t\t/* and link it into the destination keyring */\n\t\tif (keyring && link_ret == 0)\n\t\t\t__key_link(key, &edit);\n\n\t\t/* disable the authorisation key */\n\t\tif (authkey)\n\t\t\tkey_revoke(authkey);\n\t}\n\n\tmutex_unlock(&key_construction_mutex);\n\n\tif (keyring)\n\t\t__key_link_end(keyring, &key->index_key, edit);\n\n\t/* wake up anyone waiting for a key to be constructed */\n\tif (awaken)\n\t\twake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT);\n\n\treturn ret == 0 ? link_ret : ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static int muscle_list_files(sc_card_t *card, u8 *buf, size_t bufLen)\n{\n\tmuscle_private_t* priv = MUSCLE_DATA(card);\n\tmscfs_t *fs = priv->fs;\n\tint x;\n\tint count = 0;\n\n\tmscfs_check_cache(priv->fs);\n\n\tfor(x = 0; x < fs->cache.size; x++) {\n\t\tu8* oid= fs->cache.array[x].objectId.id;\n\t\tsc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,\n\t\t\t\"FILE: %02X%02X%02X%02X\\n\",\n\t\t\toid[0],oid[1],oid[2],oid[3]);\n\t\tif(0 == memcmp(fs->currentPath, oid, 2)) {\n\t\t\tbuf[0] = oid[2];\n\t\t\tbuf[1] = oid[3];\n\t\t\tif(buf[0] == 0x00 && buf[1] == 0x00) continue; /* No directories/null names outside of root */\n\t\t\tbuf += 2;\n\t\t\tcount+=2;\n\t\t}\n\t}\n\treturn count;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "spnego_gss_get_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle,\n\t\t gss_qop_t qop_req, gss_iov_buffer_desc *iov,\n\t\t int iov_count)\n{\n spnego_gss_ctx_id_t sc = (spnego_gss_ctx_id_t)context_handle;\n\n if (sc->ctx_handle == GSS_C_NO_CONTEXT)\n\t return (GSS_S_NO_CONTEXT);\n\n return gss_get_mic_iov(minor_status, sc->ctx_handle, qop_req, iov,\n\t\t\t iov_count);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "safe"} {"code": "int __cil_build_ast_first_child_helper(__attribute__((unused)) struct cil_tree_node *parse_current, void *extra_args)\n{\n\tstruct cil_args_build *args = extra_args;\n\tstruct cil_tree_node *ast = args->ast;\n\n\tif (ast->flavor == CIL_TUNABLEIF) {\n\t\targs->tunif = ast;\n\t}\n\n\tif (ast->flavor == CIL_IN) {\n\t\targs->in = ast;\n\t}\n\n\tif (ast->flavor == CIL_MACRO) {\n\t\targs->macro = ast;\n\t}\n\n\tif (ast->flavor == CIL_OPTIONAL) {\n\t\targs->optional = ast;\n\t}\n\n\tif (ast->flavor == CIL_BOOLEANIF) {\n\t\targs->boolif = ast;\n\t}\n\n\treturn SEPOL_OK;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int socket_accept(int fd, uint16_t port)\n{\n#ifdef WIN32\n\tint addr_len;\n#else\n\tsocklen_t addr_len;\n#endif\n\tint result;\n\tstruct sockaddr_in addr;\n\n\tmemset(&addr, 0, sizeof(addr));\n\taddr.sin_family = AF_INET;\n\taddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n\taddr.sin_port = htons(port);\n\n\taddr_len = sizeof(addr);\n\tresult = accept(fd, (struct sockaddr*)&addr, &addr_len);\n\n\treturn result;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "static void pcd_init_units(void)\n{\n\tstruct pcd_unit *cd;\n\tint unit;\n\n\tpcd_drive_count = 0;\n\tfor (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {\n\t\tstruct gendisk *disk = alloc_disk(1);\n\n\t\tif (!disk)\n\t\t\tcontinue;\n\n\t\tdisk->queue = blk_mq_init_sq_queue(&cd->tag_set, &pcd_mq_ops,\n\t\t\t\t\t\t 1, BLK_MQ_F_SHOULD_MERGE);\n\t\tif (IS_ERR(disk->queue)) {\n\t\t\tput_disk(disk);\n\t\t\tdisk->queue = NULL;\n\t\t\tcontinue;\n\t\t}\n\n\t\tINIT_LIST_HEAD(&cd->rq_list);\n\t\tdisk->queue->queuedata = cd;\n\t\tblk_queue_bounce_limit(disk->queue, BLK_BOUNCE_HIGH);\n\t\tcd->disk = disk;\n\t\tcd->pi = &cd->pia;\n\t\tcd->present = 0;\n\t\tcd->last_sense = 0;\n\t\tcd->changed = 1;\n\t\tcd->drive = (*drives[unit])[D_SLV];\n\t\tif ((*drives[unit])[D_PRT])\n\t\t\tpcd_drive_count++;\n\n\t\tcd->name = &cd->info.name[0];\n\t\tsnprintf(cd->name, sizeof(cd->info.name), \"%s%d\", name, unit);\n\t\tcd->info.ops = &pcd_dops;\n\t\tcd->info.handle = cd;\n\t\tcd->info.speed = 0;\n\t\tcd->info.capacity = 1;\n\t\tcd->info.mask = 0;\n\t\tdisk->major = major;\n\t\tdisk->first_minor = unit;\n\t\tstrcpy(disk->disk_name, cd->name);\t/* umm... */\n\t\tdisk->fops = &pcd_bdops;\n\t\tdisk->flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,\n\t\tconst unsigned char *sigbuf, int sig_len, EC_KEY *eckey)\n \t{\n\tECDSA_SIG *s;\n\tint ret=-1;\n\n\ts = ECDSA_SIG_new();\n\tif (s == NULL) return(ret);\n\tif (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err;\n\tret=ECDSA_do_verify(dgst, dgst_len, s, eckey);\nerr:\n\tECDSA_SIG_free(s);\n\treturn(ret);\n\t}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "static bool parse_reconnect(struct pool *pool, json_t *val)\n{\n\tif (opt_disable_client_reconnect) {\n\t\tapplog(LOG_WARNING, \"Stratum client.reconnect received but is disabled, not reconnecting.\");\n\t\treturn false;\n\t}\n\n\tchar *url, *port, address[256];\n\tchar *sockaddr_url, *stratum_port, *tmp; /* Tempvars. */\n\n\turl = (char *)json_string_value(json_array_get(val, 0));\n\tif (!url)\n\t\turl = pool->sockaddr_url;\n\n\tport = (char *)json_string_value(json_array_get(val, 1));\n\tif (!port)\n\t\tport = pool->stratum_port;\n\n\tsnprintf(address, sizeof(address), \"%s:%s\", url, port);\n\tif (!extract_sockaddr(address, &sockaddr_url, &stratum_port))\n\t\treturn false;\n\n\tapplog(LOG_NOTICE, \"Reconnect requested from %s to %s\", get_pool_name(pool), address);\n\n\tclear_pool_work(pool);\n\n\tmutex_lock(&pool->stratum_lock);\n\t__suspend_stratum(pool);\n\ttmp = pool->sockaddr_url;\n\tpool->sockaddr_url = sockaddr_url;\n\tpool->stratum_url = pool->sockaddr_url;\n\tfree(tmp);\n\ttmp = pool->stratum_port;\n\tpool->stratum_port = stratum_port;\n\tfree(tmp);\n\tmutex_unlock(&pool->stratum_lock);\n\n\tif (!restart_stratum(pool)) {\n\t\tpool_failed(pool);\n\t\treturn false;\n\t}\n\n\treturn true;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int packet_do_bind(struct sock *sk, const char *name, int ifindex,\n\t\t\t __be16 proto)\n{\n\tstruct packet_sock *po = pkt_sk(sk);\n\tstruct net_device *dev_curr;\n\t__be16 proto_curr;\n\tbool need_rehook;\n\tstruct net_device *dev = NULL;\n\tint ret = 0;\n\tbool unlisted = false;\n\n\tlock_sock(sk);\n\tspin_lock(&po->bind_lock);\n\trcu_read_lock();\n\n\tif (po->fanout) {\n\t\tret = -EINVAL;\n\t\tgoto out_unlock;\n\t}\n\n\tif (name) {\n\t\tdev = dev_get_by_name_rcu(sock_net(sk), name);\n\t\tif (!dev) {\n\t\t\tret = -ENODEV;\n\t\t\tgoto out_unlock;\n\t\t}\n\t} else if (ifindex) {\n\t\tdev = dev_get_by_index_rcu(sock_net(sk), ifindex);\n\t\tif (!dev) {\n\t\t\tret = -ENODEV;\n\t\t\tgoto out_unlock;\n\t\t}\n\t}\n\n\tif (dev)\n\t\tdev_hold(dev);\n\n\tproto_curr = po->prot_hook.type;\n\tdev_curr = po->prot_hook.dev;\n\n\tneed_rehook = proto_curr != proto || dev_curr != dev;\n\n\tif (need_rehook) {\n\t\tif (po->running) {\n\t\t\trcu_read_unlock();\n\t\t\t__unregister_prot_hook(sk, true);\n\t\t\trcu_read_lock();\n\t\t\tdev_curr = po->prot_hook.dev;\n\t\t\tif (dev)\n\t\t\t\tunlisted = !dev_get_by_index_rcu(sock_net(sk),\n\t\t\t\t\t\t\t\t dev->ifindex);\n\t\t}\n\n\t\tpo->num = proto;\n\t\tpo->prot_hook.type = proto;\n\n\t\tif (unlikely(unlisted)) {\n\t\t\tdev_put(dev);\n\t\t\tpo->prot_hook.dev = NULL;\n\t\t\tpo->ifindex = -1;\n\t\t\tpacket_cached_dev_reset(po);\n\t\t} else {\n\t\t\tpo->prot_hook.dev = dev;\n\t\t\tpo->ifindex = dev ? dev->ifindex : 0;\n\t\t\tpacket_cached_dev_assign(po, dev);\n\t\t}\n\t}\n\tif (dev_curr)\n\t\tdev_put(dev_curr);\n\n\tif (proto == 0 || !need_rehook)\n\t\tgoto out_unlock;\n\n\tif (!unlisted && (!dev || (dev->flags & IFF_UP))) {\n\t\tregister_prot_hook(sk);\n\t} else {\n\t\tsk->sk_err = ENETDOWN;\n\t\tif (!sock_flag(sk, SOCK_DEAD))\n\t\t\tsk->sk_error_report(sk);\n\t}\n\nout_unlock:\n\trcu_read_unlock();\n\tspin_unlock(&po->bind_lock);\n\trelease_sock(sk);\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len)\n{\n\tsize_t cipher_len;\n\tsize_t i;\n\tunsigned char iv[16] = { 0 };\n\tunsigned char plaintext[4096] = { 0 };\n\tepass2003_exdata *exdata = NULL;\n\n\tif (!card->drv_data) \n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\texdata = (epass2003_exdata *)card->drv_data;\n\n\t/* no cipher */\n\tif (in[0] == 0x99)\n\t\treturn 0;\n\n\t/* parse cipher length */\n\tif (0x01 == in[2] && 0x82 != in[1]) {\n\t\tcipher_len = in[1];\n\t\ti = 3;\n\t}\n\telse if (0x01 == in[3] && 0x81 == in[1]) {\n\t\tcipher_len = in[2];\n\t\ti = 4;\n\t}\n\telse if (0x01 == in[4] && 0x82 == in[1]) {\n\t\tcipher_len = in[2] * 0x100;\n\t\tcipher_len += in[3];\n\t\ti = 5;\n\t}\n\telse {\n\t\treturn -1;\n\t}\n\n\tif (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext)\n\t\treturn -1;\n\n\t/* decrypt */\n\tif (KEY_TYPE_AES == exdata->smtype)\n\t\taes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\telse\n\t\tdes3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext);\n\n\t/* unpadding */\n\twhile (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0))\n\t\tcipher_len--;\n\n\tif (2 == cipher_len || *out_len < cipher_len - 2)\n\t\treturn -1;\n\n\tmemcpy(out, plaintext, cipher_len - 2);\n\t*out_len = cipher_len - 2;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "cJSON *cJSON_CreateBool(int b)\t\t\t\t\t{cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)\n{\n\tstruct fsck_gitmodules_data *data = vdata;\n\tconst char *subsection, *key;\n\tint subsection_len;\n\tchar *name;\n\n\tif (parse_config_key(var, \"submodule\", &subsection, &subsection_len, &key) < 0 ||\n\t !subsection)\n\t\treturn 0;\n\n\tname = xmemdupz(subsection, subsection_len);\n\tif (check_submodule_name(name) < 0)\n\t\tdata->ret |= report(data->options, data->obj,\n\t\t\t\t FSCK_MSG_GITMODULES_NAME,\n\t\t\t\t \"disallowed submodule name: %s\",\n\t\t\t\t name);\n\tif (!strcmp(key, \"url\") && value &&\n\t looks_like_command_line_option(value))\n\t\tdata->ret |= report(data->options, data->obj,\n\t\t\t\t FSCK_MSG_GITMODULES_URL,\n\t\t\t\t \"disallowed submodule url: %s\",\n\t\t\t\t value);\n\tfree(name);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "static void __sock_release(struct socket *sock, struct inode *inode)\n{\n\tif (sock->ops) {\n\t\tstruct module *owner = sock->ops->owner;\n\n\t\tif (inode)\n\t\t\tinode_lock(inode);\n\t\tsock->ops->release(sock);\n\t\tif (inode)\n\t\t\tinode_unlock(inode);\n\t\tsock->ops = NULL;\n\t\tmodule_put(owner);\n\t}\n\n\tif (rcu_dereference_protected(sock->wq, 1)->fasync_list)\n\t\tpr_err(\"%s: fasync list not empty!\\n\", __func__);\n\n\tif (!sock->file) {\n\t\tiput(SOCK_INODE(sock));\n\t\treturn;\n\t}\n\tsock->file = NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,\n\t\tstruct nfs4_acl *acl)\n{\n\t__be32 error;\n\tint host_error;\n\tstruct dentry *dentry;\n\tstruct inode *inode;\n\tstruct posix_acl *pacl = NULL, *dpacl = NULL;\n\tunsigned int flags = 0;\n\n\t/* Get inode */\n\terror = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR);\n\tif (error)\n\t\treturn error;\n\n\tdentry = fhp->fh_dentry;\n\tinode = d_inode(dentry);\n\n\tif (S_ISDIR(inode->i_mode))\n\t\tflags = NFS4_ACL_DIR;\n\n\thost_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);\n\tif (host_error == -EINVAL)\n\t\treturn nfserr_attrnotsupp;\n\tif (host_error < 0)\n\t\tgoto out_nfserr;\n\n\tfh_lock(fhp);\n\n\thost_error = set_posix_acl(inode, ACL_TYPE_ACCESS, pacl);\n\tif (host_error < 0)\n\t\tgoto out_drop_lock;\n\n\tif (S_ISDIR(inode->i_mode)) {\n\t\thost_error = set_posix_acl(inode, ACL_TYPE_DEFAULT, dpacl);\n\t}\n\nout_drop_lock:\n\tfh_unlock(fhp);\n\n\tposix_acl_release(pacl);\n\tposix_acl_release(dpacl);\nout_nfserr:\n\tif (host_error == -EOPNOTSUPP)\n\t\treturn nfserr_attrnotsupp;\n\telse\n\t\treturn nfserrno(host_error);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "safe"} {"code": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-191", "cwe_name": "Integer Underflow (Wrap or Wraparound)", "description": "The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.", "url": "https://cwe.mitre.org/data/definitions/191.html", "label_name": "vulnerable"} {"code": "asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,\n\t\t\t\t unsigned int vlen, unsigned int flags,\n\t\t\t\t struct compat_timespec __user *timeout)\n{\n\tint datagrams;\n\tstruct timespec ktspec;\n\n\tif (flags & MSG_CMSG_COMPAT)\n\t\treturn -EINVAL;\n\n\tif (timeout == NULL)\n\t\treturn __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, NULL);\n\n\tif (compat_get_timespec(&ktspec, timeout))\n\t\treturn -EFAULT;\n\n\tdatagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, &ktspec);\n\tif (datagrams > 0 && compat_put_timespec(&ktspec, timeout))\n\t\tdatagrams = -EFAULT;\n\n\treturn datagrams;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "PUBLIC int espLoadApp(HttpRoute *route)\n{\n#if !ME_STATIC\n EspRoute *eroute;\n eroute = route->eroute;\n if (!eroute->skipApps) {\n MprJson *preload, *item;\n cchar *errMsg, *source;\n char *kind;\n int i;\n\n /*\n Note: the config parser pauses GC, so this will never yield\n */\n if (!loadApp(route, NULL)) {\n return MPR_ERR_CANT_LOAD;\n }\n if (!route->combine && (preload = mprGetJsonObj(route->config, \"esp.preload\")) != 0) {\n for (ITERATE_JSON(preload, item, i)) {\n source = stok(sclone(item->value), \":\", &kind);\n if (!kind) kind = \"controller\";\n source = mprJoinPath(httpGetDir(route, \"controllers\"), source);\n if (espLoadModule(route, NULL, kind, source, &errMsg) < 0) {\n mprLog(\"error esp\", 0, \"Cannot preload esp module %s. %s\", source, errMsg);\n return MPR_ERR_CANT_LOAD;\n }\n }\n }\n }\n#endif\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static void doGet(HttpRequest req, HttpResponse res) {\n set_content_type(res, \"text/html\");\n if (ACTION(HOME)) {\n LOCK(Run.mutex)\n do_home(res);\n END_LOCK;\n } else if (ACTION(RUN)) {\n handle_run(req, res);\n } else if (ACTION(TEST)) {\n is_monit_running(res);\n } else if (ACTION(VIEWLOG)) {\n do_viewlog(req, res);\n } else if (ACTION(ABOUT)) {\n do_about(res);\n } else if (ACTION(FAVICON)) {\n printFavicon(res);\n } else if (ACTION(PING)) {\n do_ping(res);\n } else if (ACTION(GETID)) {\n do_getid(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 }\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)\n{\n\tstruct usb_interface_cache *intfc;\n\tstruct usb_host_interface *alt;\n\tstruct sd *sd = (struct sd *) gspca_dev;\n\n\tintfc = gspca_dev->dev->actconfig->intf_cache[0];\n\n\tif (intfc->num_altsetting < 2)\n\t\treturn -ENODEV;\n\n\talt = &intfc->altsetting[1];\n\n\tif (alt->desc.bNumEndpoints < 1)\n\t\treturn -ENODEV;\n\n\t/* Start isoc bandwidth \"negotiation\" at max isoc bandwidth */\n\talt->endpoint[0].desc.wMaxPacketSize =\n\t\tcpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static void\nfree_dynamic_method (void *dynamic_method)\n{\n\tDynamicMethodReleaseData *data = dynamic_method;\n\n\tmono_runtime_free_method (data->domain, data->handle);\n\tg_free (data);", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb)\n{\n\treturn secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\t\t dccp_hdr(skb)->dccph_dport,\n\t\t\t\t\t dccp_hdr(skb)->dccph_sport );\n\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "ns_nprint(netdissect_options *ndo,\n register const u_char *cp, register const u_char *bp)\n{\n\tregister u_int i, l;\n\tregister const u_char *rp = NULL;\n\tregister int compress = 0;\n\tint chars_processed;\n\tint elt;\n\tint data_size = ndo->ndo_snapend - bp;\n\n\tif ((l = labellen(ndo, cp)) == (u_int)-1)\n\t\treturn(NULL);\n\tif (!ND_TTEST2(*cp, 1))\n\t\treturn(NULL);\n\tchars_processed = 1;\n\tif (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {\n\t\tcompress = 0;\n\t\trp = cp + l;\n\t}\n\n\tif (i != 0)\n\t\twhile (i && cp < ndo->ndo_snapend) {\n\t\t\tif ((i & INDIR_MASK) == INDIR_MASK) {\n\t\t\t\tif (!compress) {\n\t\t\t\t\trp = cp + 1;\n\t\t\t\t\tcompress = 1;\n\t\t\t\t}\n\t\t\t\tif (!ND_TTEST2(*cp, 1))\n\t\t\t\t\treturn(NULL);\n\t\t\t\tcp = bp + (((i << 8) | *cp) & 0x3fff);\n\t\t\t\tif ((l = labellen(ndo, cp)) == (u_int)-1)\n\t\t\t\t\treturn(NULL);\n\t\t\t\tif (!ND_TTEST2(*cp, 1))\n\t\t\t\t\treturn(NULL);\n\t\t\t\ti = *cp++;\n\t\t\t\tchars_processed++;\n\n\t\t\t\t/*\n\t\t\t\t * If we've looked at every character in\n\t\t\t\t * the message, this pointer will make\n\t\t\t\t * us look at some character again,\n\t\t\t\t * which means we're looping.\n\t\t\t\t */\n\t\t\t\tif (chars_processed >= data_size) {\n\t\t\t\t\tND_PRINT((ndo, \"\"));\n\t\t\t\t\treturn (NULL);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((i & INDIR_MASK) == EDNS0_MASK) {\n\t\t\t\telt = (i & ~INDIR_MASK);\n\t\t\t\tswitch(elt) {\n\t\t\t\tcase EDNS0_ELT_BITLABEL:\n\t\t\t\t\tif (blabel_print(ndo, cp) == NULL)\n\t\t\t\t\t\treturn (NULL);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t/* unknown ELT */\n\t\t\t\t\tND_PRINT((ndo, \"\", elt));\n\t\t\t\t\treturn(NULL);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (fn_printn(ndo, cp, l, ndo->ndo_snapend))\n\t\t\t\t\treturn(NULL);\n\t\t\t}\n\n\t\t\tcp += l;\n\t\t\tchars_processed += l;\n\t\t\tND_PRINT((ndo, \".\"));\n\t\t\tif ((l = labellen(ndo, cp)) == (u_int)-1)\n\t\t\t\treturn(NULL);\n\t\t\tif (!ND_TTEST2(*cp, 1))\n\t\t\t\treturn(NULL);\n\t\t\ti = *cp++;\n\t\t\tchars_processed++;\n\t\t\tif (!compress)\n\t\t\t\trp += l + 1;\n\t\t}\n\telse\n\t\tND_PRINT((ndo, \".\"));\n\treturn (rp);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": "static BOOL nsc_context_initialize_encode(NSC_CONTEXT* context)\n{\n\tint i;\n\tUINT32 length;\n\tUINT32 tempWidth;\n\tUINT32 tempHeight;\n\ttempWidth = ROUND_UP_TO(context->width, 8);\n\ttempHeight = ROUND_UP_TO(context->height, 2);\n\t/* The maximum length a decoded plane can reach in all cases */\n\tlength = tempWidth * tempHeight + 16;\n\n\tif (length > context->priv->PlaneBuffersLength)\n\t{\n\t\tfor (i = 0; i < 5; i++)\n\t\t{\n\t\t\tBYTE* tmp = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);\n\n\t\t\tif (!tmp)\n\t\t\t\tgoto fail;\n\n\t\t\tcontext->priv->PlaneBuffers[i] = tmp;\n\t\t}\n\n\t\tcontext->priv->PlaneBuffersLength = length;\n\t}\n\n\tif (context->ChromaSubsamplingLevel)\n\t{\n\t\tcontext->OrgByteCount[0] = tempWidth * context->height;\n\t\tcontext->OrgByteCount[1] = tempWidth * tempHeight / 4;\n\t\tcontext->OrgByteCount[2] = tempWidth * tempHeight / 4;\n\t\tcontext->OrgByteCount[3] = context->width * context->height;\n\t}\n\telse\n\t{\n\t\tcontext->OrgByteCount[0] = context->width * context->height;\n\t\tcontext->OrgByteCount[1] = context->width * context->height;\n\t\tcontext->OrgByteCount[2] = context->width * context->height;\n\t\tcontext->OrgByteCount[3] = context->width * context->height;\n\t}\n\n\treturn TRUE;\nfail:\n\n\tif (length > context->priv->PlaneBuffersLength)\n\t{\n\t\tfor (i = 0; i < 5; i++)\n\t\t\tfree(context->priv->PlaneBuffers[i]);\n\t}\n\n\treturn FALSE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "devzvol_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred,\n int *eofp, caller_context_t *ct_unused, int flags_unused)\n{\n\tstruct sdev_node *sdvp = VTOSDEV(dvp);\n\tchar *ptr;\n\n\tsdcmn_err13((\"zv readdir of '%s' %s'\", sdvp->sdev_path,\n\t sdvp->sdev_name));\n\n\tif (strcmp(sdvp->sdev_path, ZVOL_DIR) == 0) {\n\t\tstruct vnode *vp;\n\n\t\trw_exit(&sdvp->sdev_contents);\n\t\t(void) devname_lookup_func(sdvp, \"dsk\", &vp, cred,\n\t\t devzvol_create_dir, SDEV_VATTR);\n\t\tVN_RELE(vp);\n\t\t(void) devname_lookup_func(sdvp, \"rdsk\", &vp, cred,\n\t\t devzvol_create_dir, SDEV_VATTR);\n\t\tVN_RELE(vp);\n\t\trw_enter(&sdvp->sdev_contents, RW_READER);\n\t\treturn (devname_readdir_func(dvp, uiop, cred, eofp, 0));\n\t}\n\tif (uiop->uio_offset == 0)\n\t\tdevzvol_prunedir(sdvp);\n\tptr = sdvp->sdev_path + strlen(ZVOL_DIR);\n\tif ((strcmp(ptr, \"/dsk\") == 0) || (strcmp(ptr, \"/rdsk\") == 0)) {\n\t\trw_exit(&sdvp->sdev_contents);\n\t\tdevzvol_create_pool_dirs(dvp);\n\t\trw_enter(&sdvp->sdev_contents, RW_READER);\n\t\treturn (devname_readdir_func(dvp, uiop, cred, eofp, 0));\n\t}\n\n\tptr = strchr(ptr + 1, '/') + 1;\n\trw_exit(&sdvp->sdev_contents);\n\tsdev_iter_datasets(dvp, ZFS_IOC_DATASET_LIST_NEXT, ptr);\n\trw_enter(&sdvp->sdev_contents, RW_READER);\n\treturn (devname_readdir_func(dvp, uiop, cred, eofp, 0));\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,\n\t\t\t\t unsigned long arg)\n{\n\tstruct snd_timer_user *tu;\n\tvoid __user *argp = (void __user *)arg;\n\tint __user *p = argp;\n\n\ttu = file->private_data;\n\tswitch (cmd) {\n\tcase SNDRV_TIMER_IOCTL_PVERSION:\n\t\treturn put_user(SNDRV_TIMER_VERSION, p) ? -EFAULT : 0;\n\tcase SNDRV_TIMER_IOCTL_NEXT_DEVICE:\n\t\treturn snd_timer_user_next_device(argp);\n\tcase SNDRV_TIMER_IOCTL_TREAD:\n\t{\n\t\tint xarg;\n\n\t\tif (tu->timeri)\t/* too late */\n\t\t\treturn -EBUSY;\n\t\tif (get_user(xarg, p))\n\t\t\treturn -EFAULT;\n\t\ttu->tread = xarg ? 1 : 0;\n\t\treturn 0;\n\t}\n\tcase SNDRV_TIMER_IOCTL_GINFO:\n\t\treturn snd_timer_user_ginfo(file, argp);\n\tcase SNDRV_TIMER_IOCTL_GPARAMS:\n\t\treturn snd_timer_user_gparams(file, argp);\n\tcase SNDRV_TIMER_IOCTL_GSTATUS:\n\t\treturn snd_timer_user_gstatus(file, argp);\n\tcase SNDRV_TIMER_IOCTL_SELECT:\n\t\treturn snd_timer_user_tselect(file, argp);\n\tcase SNDRV_TIMER_IOCTL_INFO:\n\t\treturn snd_timer_user_info(file, argp);\n\tcase SNDRV_TIMER_IOCTL_PARAMS:\n\t\treturn snd_timer_user_params(file, argp);\n\tcase SNDRV_TIMER_IOCTL_STATUS:\n\t\treturn snd_timer_user_status(file, argp);\n\tcase SNDRV_TIMER_IOCTL_START:\n\tcase SNDRV_TIMER_IOCTL_START_OLD:\n\t\treturn snd_timer_user_start(file);\n\tcase SNDRV_TIMER_IOCTL_STOP:\n\tcase SNDRV_TIMER_IOCTL_STOP_OLD:\n\t\treturn snd_timer_user_stop(file);\n\tcase SNDRV_TIMER_IOCTL_CONTINUE:\n\tcase SNDRV_TIMER_IOCTL_CONTINUE_OLD:\n\t\treturn snd_timer_user_continue(file);\n\tcase SNDRV_TIMER_IOCTL_PAUSE:\n\tcase SNDRV_TIMER_IOCTL_PAUSE_OLD:\n\t\treturn snd_timer_user_pause(file);\n\t}\n\treturn -ENOTTY;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,\n\t\tstruct user_namespace *user_ns, struct fs_struct *fs)\n{\n\tstruct mnt_namespace *new_ns;\n\tstruct vfsmount *rootmnt = NULL, *pwdmnt = NULL;\n\tstruct mount *p, *q;\n\tstruct mount *old = mnt_ns->root;\n\tstruct mount *new;\n\tint copy_flags;\n\n\tnew_ns = alloc_mnt_ns(user_ns);\n\tif (IS_ERR(new_ns))\n\t\treturn new_ns;\n\n\tdown_write(&namespace_sem);\n\t/* First pass: copy the tree topology */\n\tcopy_flags = CL_COPY_ALL | CL_EXPIRE;\n\tif (user_ns != mnt_ns->user_ns)\n\t\tcopy_flags |= CL_SHARED_TO_SLAVE | CL_UNPRIVILEGED;\n\tnew = copy_tree(old, old->mnt.mnt_root, copy_flags);\n\tif (IS_ERR(new)) {\n\t\tup_write(&namespace_sem);\n\t\tfree_mnt_ns(new_ns);\n\t\treturn ERR_CAST(new);\n\t}\n\tnew_ns->root = new;\n\tbr_write_lock(&vfsmount_lock);\n\tlist_add_tail(&new_ns->list, &new->mnt_list);\n\tbr_write_unlock(&vfsmount_lock);\n\n\t/*\n\t * Second pass: switch the tsk->fs->* elements and mark new vfsmounts\n\t * as belonging to new namespace. We have already acquired a private\n\t * fs_struct, so tsk->fs->lock is not needed.\n\t */\n\tp = old;\n\tq = new;\n\twhile (p) {\n\t\tq->mnt_ns = new_ns;\n\t\tif (fs) {\n\t\t\tif (&p->mnt == fs->root.mnt) {\n\t\t\t\tfs->root.mnt = mntget(&q->mnt);\n\t\t\t\trootmnt = &p->mnt;\n\t\t\t}\n\t\t\tif (&p->mnt == fs->pwd.mnt) {\n\t\t\t\tfs->pwd.mnt = mntget(&q->mnt);\n\t\t\t\tpwdmnt = &p->mnt;\n\t\t\t}\n\t\t}\n\t\tp = next_mnt(p, old);\n\t\tq = next_mnt(q, new);\n\t}\n\tup_write(&namespace_sem);\n\n\tif (rootmnt)\n\t\tmntput(rootmnt);\n\tif (pwdmnt)\n\t\tmntput(pwdmnt);\n\n\treturn new_ns;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "process_bitmap_updates(STREAM s)\n{\n\tuint16 num_updates;\n\tuint16 left, top, right, bottom, width, height;\n\tuint16 cx, cy, bpp, Bpp, compress, bufsize, size;\n\tuint8 *data, *bmpdata;\n\tint i;\n\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\n\tin_uint16_le(s, num_updates);\n\n\tfor (i = 0; i < num_updates; i++)\n\t{\n\t\tin_uint16_le(s, left);\n\t\tin_uint16_le(s, top);\n\t\tin_uint16_le(s, right);\n\t\tin_uint16_le(s, bottom);\n\t\tin_uint16_le(s, width);\n\t\tin_uint16_le(s, height);\n\t\tin_uint16_le(s, bpp);\n\t\tBpp = (bpp + 7) / 8;\n\t\tin_uint16_le(s, compress);\n\t\tin_uint16_le(s, bufsize);\n\n\t\tcx = right - left + 1;\n\t\tcy = bottom - top + 1;\n\n\t\tlogger(Graphics, Debug,\n\t\t \"process_bitmap_updates(), [%d,%d,%d,%d], [%d,%d], bpp=%d, compression=%d\",\n\t\t left, top, right, bottom, width, height, Bpp, compress);\n\n\t\tif (!compress)\n\t\t{\n\t\t\tint y;\n\t\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tin_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],\n\t\t\t\t\t width * Bpp);\n\t\t\t}\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t\txfree(bmpdata);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\tif (compress & 0x400)\n\t\t{\n\t\t\tsize = bufsize;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_uint8s(s, 2);\t/* pad */\n\t\t\tin_uint16_le(s, size);\n\t\t\tin_uint8s(s, 4);\t/* line_size, final_size */\n\t\t}\n\t\tin_uint8p(s, data, size);\n\t\tbmpdata = (uint8 *) xmalloc(width * height * Bpp);\n\t\tif (bitmap_decompress(bmpdata, width, height, data, size, Bpp))\n\t\t{\n\t\t\tui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t \"process_bitmap_updates(), failed to decompress bitmap\");\n\t\t}\n\n\t\txfree(bmpdata);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "ber_parse_header(STREAM s, int tagval, int *length)\n{\n\tint tag, len;\n\n\tif (tagval > 0xff)\n\t{\n\t\tin_uint16_be(s, tag);\n\t}\n\telse\n\t{\n\t\tin_uint8(s, tag);\n\t}\n\n\tif (tag != tagval)\n\t{\n\t\tlogger(Core, Error, \"ber_parse_header(), expected tag %d, got %d\", tagval, tag);\n\t\treturn False;\n\t}\n\n\tin_uint8(s, len);\n\n\tif (len & 0x80)\n\t{\n\t\tlen &= ~0x80;\n\t\t*length = 0;\n\t\twhile (len--)\n\t\t\tnext_be(s, *length);\n\t}\n\telse\n\t\t*length = len;\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)\n{\n\tskb_orphan(skb);\n\n\tif (!(dev->flags & IFF_UP))\n\t\treturn NET_RX_DROP;\n\n\tif (skb->len > (dev->mtu + dev->hard_header_len))\n\t\treturn NET_RX_DROP;\n\n\tskb_set_dev(skb, dev);\n\tskb->tstamp.tv64 = 0;\n\tskb->pkt_type = PACKET_HOST;\n\tskb->protocol = eth_type_trans(skb, dev);\n\treturn netif_rx(skb);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "static void xen_free_irq(unsigned irq)\n{\n\tstruct irq_info *info = info_for_irq(irq);\n\tunsigned long flags;\n\n\tif (WARN_ON(!info))\n\t\treturn;\n\n\twrite_lock_irqsave(&evtchn_rwlock, flags);\n\n\tlist_del(&info->list);\n\n\tset_info_for_irq(irq, NULL);\n\n\tWARN_ON(info->refcnt > 0);\n\n\twrite_unlock_irqrestore(&evtchn_rwlock, flags);\n\n\tkfree(info);\n\n\t/* Legacy IRQ descriptors are managed by the arch. */\n\tif (irq < nr_legacy_irqs())\n\t\treturn;\n\n\tirq_free_desc(irq);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static int propagate_one(struct mount *m)\n{\n\tstruct mount *child;\n\tint type;\n\t/* skip ones added by this propagate_mnt() */\n\tif (IS_MNT_NEW(m))\n\t\treturn 0;\n\t/* skip if mountpoint isn't covered by it */\n\tif (!is_subdir(mp->m_dentry, m->mnt.mnt_root))\n\t\treturn 0;\n\tif (peers(m, last_dest)) {\n\t\ttype = CL_MAKE_SHARED;\n\t} else {\n\t\tstruct mount *n, *p;\n\t\tbool done;\n\t\tfor (n = m; ; n = p) {\n\t\t\tp = n->mnt_master;\n\t\t\tif (p == dest_master || IS_MNT_MARKED(p))\n\t\t\t\tbreak;\n\t\t}\n\t\tdo {\n\t\t\tstruct mount *parent = last_source->mnt_parent;\n\t\t\tif (last_source == first_source)\n\t\t\t\tbreak;\n\t\t\tdone = parent->mnt_master == p;\n\t\t\tif (done && peers(n, parent))\n\t\t\t\tbreak;\n\t\t\tlast_source = last_source->mnt_master;\n\t\t} while (!done);\n\n\t\ttype = CL_SLAVE;\n\t\t/* beginning of peer group among the slaves? */\n\t\tif (IS_MNT_SHARED(m))\n\t\t\ttype |= CL_MAKE_SHARED;\n\t}\n\t\t\n\t/* Notice when we are propagating across user namespaces */\n\tif (m->mnt_ns->user_ns != user_ns)\n\t\ttype |= CL_UNPRIVILEGED;\n\tchild = copy_tree(last_source, last_source->mnt.mnt_root, type);\n\tif (IS_ERR(child))\n\t\treturn PTR_ERR(child);\n\tchild->mnt.mnt_flags &= ~MNT_LOCKED;\n\tmnt_set_mountpoint(m, mp, child);\n\tlast_dest = m;\n\tlast_source = child;\n\tif (m->mnt_master != dest_master) {\n\t\tread_seqlock_excl(&mount_lock);\n\t\tSET_MNT_MARK(m->mnt_master);\n\t\tread_sequnlock_excl(&mount_lock);\n\t}\n\thlist_add_head(&child->mnt_hash, list);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,\n\t\tstruct msghdr *msg, size_t len, int noblock, int flags,\n\t\tint *addr_len)\n{\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tstruct sk_buff *skb;\n\tstruct sockaddr_ieee802154 *saddr;\n\n\tsaddr = (struct sockaddr_ieee802154 *)msg->msg_name;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\t/* FIXME: skip headers if necessary ?! */\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\tif (saddr) {\n\t\tsaddr->family = AF_IEEE802154;\n\t\tsaddr->addr = mac_cb(skb)->sa;\n\t\t*addr_len = sizeof(*saddr);\n\t}\n\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\tif (err)\n\t\treturn err;\n\treturn copied;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,\n\t\tunsigned long, nbytes, int __user *, start, void __user *, arg)\n{\n\tunsigned long w;\n\tstruct percpu_struct *cpu;\n\n\tswitch (op) {\n\tcase GSI_IEEE_FP_CONTROL:\n\t\t/* Return current software fp control & status bits. */\n\t\t/* Note that DU doesn't verify available space here. */\n\n \t\tw = current_thread_info()->ieee_state & IEEE_SW_MASK;\n \t\tw = swcr_update_status(w, rdfpcr());\n\t\tif (put_user(w, (unsigned long __user *) buffer))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tcase GSI_IEEE_STATE_AT_SIGNAL:\n\t\t/*\n\t\t * Not sure anybody will ever use this weird stuff. These\n\t\t * ops can be used (under OSF/1) to set the fpcr that should\n\t\t * be used when a signal handler starts executing.\n\t\t */\n\t\tbreak;\n\n \tcase GSI_UACPROC:\n\t\tif (nbytes < sizeof(unsigned int))\n\t\t\treturn -EINVAL;\n \t\tw = (current_thread_info()->flags >> UAC_SHIFT) & UAC_BITMASK;\n \t\tif (put_user(w, (unsigned int __user *)buffer))\n \t\t\treturn -EFAULT;\n \t\treturn 1;\n\n\tcase GSI_PROC_TYPE:\n\t\tif (nbytes < sizeof(unsigned long))\n\t\t\treturn -EINVAL;\n\t\tcpu = (struct percpu_struct*)\n\t\t ((char*)hwrpb + hwrpb->processor_offset);\n\t\tw = cpu->type;\n\t\tif (put_user(w, (unsigned long __user*)buffer))\n\t\t\treturn -EFAULT;\n\t\treturn 1;\n\n\tcase GSI_GET_HWRPB:\n\t\tif (nbytes > sizeof(*hwrpb))\n\t\t\treturn -EINVAL;\n\t\tif (copy_to_user(buffer, hwrpb, nbytes) != 0)\n\t\t\treturn -EFAULT;\n\t\treturn 1;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn -EOPNOTSUPP;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "horizontalDifference8(unsigned char *ip, int n, int stride, \n\tunsigned short *wp, uint16 *From8)\n{\n register int r1, g1, b1, a1, r2, g2, b2, a2, mask;\n\n#undef\t CLAMP\n#define CLAMP(v) (From8[(v)])\n\n mask = CODE_MASK;\n if (n >= stride) {\n\tif (stride == 3) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]);\n\t n -= 3;\n\t while (n > 0) {\n\t\tn -= 3;\n\t\tr1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\twp += 3;\n\t\tip += 3;\n\t }\n\t} else if (stride == 4) {\n\t r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);\n\t b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);\n\t n -= 4;\n\t while (n > 0) {\n\t\tn -= 4;\n\t\tr1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1;\n\t\tg1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1;\n\t\tb1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1;\n\t\ta1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1;\n\t\twp += 4;\n\t\tip += 4;\n\t }\n\t} else {\n REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)\n n -= stride;\n while (n > 0) {\n REPEAT(stride,\n wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);\n wp++; ip++)\n n -= stride;\n }\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static void sycc422_to_rgb(opj_image_t *img)\n{\t\n\tint *d0, *d1, *d2, *r, *g, *b;\n\tconst int *y, *cb, *cr;\n\tunsigned int maxw, maxh, max;\n\tint offset, upb;\n\tunsigned int i, j;\n\n\tupb = (int)img->comps[0].prec;\n\toffset = 1<<(upb - 1); upb = (1<comps[0].w; maxh = (unsigned int)img->comps[0].h;\n\tmax = maxw * maxh;\n\n\ty = img->comps[0].data;\n\tcb = img->comps[1].data;\n\tcr = img->comps[2].data;\n\n\td0 = r = (int*)malloc(sizeof(int) * (size_t)max);\n\td1 = g = (int*)malloc(sizeof(int) * (size_t)max);\n\td2 = b = (int*)malloc(sizeof(int) * (size_t)max);\n\n\tif(r == NULL || g == NULL || b == NULL) goto fails;\n\n\tfor(i=0U; i < maxh; ++i)\n\t{\n\t\tfor(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)\n\t\t{\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b;\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b; ++cb; ++cr;\n\t\t}\n\t\tif (j < maxw) {\n\t\t\tsycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);\n\t\t\t++y; ++r; ++g; ++b; ++cb; ++cr;\n\t\t}\n\t}\n\tfree(img->comps[0].data); img->comps[0].data = d0;\n\tfree(img->comps[1].data); img->comps[1].data = d1;\n\tfree(img->comps[2].data); img->comps[2].data = d2;\n\n#if defined(USE_JPWL) || defined(USE_MJ2)\n\timg->comps[1].w = maxw; img->comps[1].h = maxh;\n\timg->comps[2].w = maxw; img->comps[2].h = maxh;\n#else\n\timg->comps[1].w = (OPJ_UINT32)maxw; img->comps[1].h = (OPJ_UINT32)maxh;\n\timg->comps[2].w = (OPJ_UINT32)maxw; img->comps[2].h = (OPJ_UINT32)maxh;\n#endif\n\timg->comps[1].dx = img->comps[0].dx;\n\timg->comps[2].dx = img->comps[0].dx;\n\timg->comps[1].dy = img->comps[0].dy;\n\timg->comps[2].dy = img->comps[0].dy;\n\treturn;\n\nfails:\n\tif(r) free(r);\n\tif(g) free(g);\n\tif(b) free(b);\n\n}/* sycc422_to_rgb() */", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "init_connection_options(MYSQL *mysql)\n{\n SSL_SET_OPTIONS(mysql);\n\n if (opt_protocol)\n mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);\n\n#ifdef HAVE_SMEM\n if (shared_memory_base_name)\n mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME, shared_memory_base_name);\n#endif\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "safe"} {"code": "void dev_load(struct net *net, const char *name)\n{\n\tstruct net_device *dev;\n\tint no_module;\n\n\trcu_read_lock();\n\tdev = dev_get_by_name_rcu(net, name);\n\trcu_read_unlock();\n\n\tno_module = !dev;\n\tif (no_module && capable(CAP_NET_ADMIN))\n\t\tno_module = request_module(\"netdev-%s\", name);\n\tif (no_module && capable(CAP_SYS_MODULE)) {\n\t\tif (!request_module(\"%s\", name))\n\t\t\tpr_err(\"Loading kernel module for a network device \"\n\"with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s \"\n\"instead\\n\", name);\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "error_t mqttSnClientSendUnsubscribe(MqttSnClientContext *context,\n const char_t *topicName)\n{\n error_t error;\n systime_t time;\n uint16_t topicId;\n MqttSnFlags flags;\n\n //Initialize status code\n error = NO_ERROR;\n\n //Reset unused flags\n flags.all = 0;\n\n //Check whether a predefined topic ID has been registered\n topicId = mqttSnClientFindPredefTopicName(context, topicName);\n\n //Predefined topic ID found?\n if(topicId != MQTT_SN_INVALID_TOPIC_ID)\n {\n //The UNSUBSCRIBE message contains a predefined topic ID\n flags.topicIdType = MQTT_SN_PREDEFINED_TOPIC_ID;\n }\n else\n {\n //Short topic name?\n if(osStrlen(topicName) == 2 && strchr(topicName, '#') == NULL &&\n strchr(topicName, '+') == NULL)\n {\n //The UNSUBSCRIBE message contains a short topic name\n flags.topicIdType = MQTT_SN_SHORT_TOPIC_NAME;\n }\n else\n {\n //The UNSUBSCRIBE message contains a normal topic name\n flags.topicIdType = MQTT_SN_NORMAL_TOPIC_NAME;\n }\n\n //Format UNSUBSCRIBE message\n error = mqttSnFormatUnsubscribe(&context->message, flags,\n context->msgId, topicId, topicName);\n }\n\n //Check status code\n if(!error)\n {\n //Debug message\n TRACE_INFO(\"Sending UNSUBSCRIBE message (%\" PRIuSIZE \" bytes)...\\r\\n\",\n context->message.length);\n\n //Dump the contents of the message for debugging purpose\n mqttSnDumpMessage(context->message.buffer, context->message.length);\n\n //Send MQTT-SN message\n error = mqttSnClientSendDatagram(context, context->message.buffer,\n context->message.length);\n\n //Get current time\n time = osGetSystemTime();\n\n //Save the time at which the message was sent\n context->retransmitStartTime = time;\n context->keepAliveTimestamp = time;\n\n //Update MQTT-SN client state\n context->state = MQTT_SN_CLIENT_STATE_SENDING_REQ;\n context->msgType = MQTT_SN_MSG_TYPE_UNSUBSCRIBE;\n }\n\n //Return status code\n return error;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static void command_port_read_callback(struct urb *urb)\n{\n\tstruct usb_serial_port *command_port = urb->context;\n\tstruct whiteheat_command_private *command_info;\n\tint status = urb->status;\n\tunsigned char *data = urb->transfer_buffer;\n\tint result;\n\n\tcommand_info = usb_get_serial_port_data(command_port);\n\tif (!command_info) {\n\t\tdev_dbg(&urb->dev->dev, \"%s - command_info is NULL, exiting.\\n\", __func__);\n\t\treturn;\n\t}\n\tif (status) {\n\t\tdev_dbg(&urb->dev->dev, \"%s - nonzero urb status: %d\\n\", __func__, status);\n\t\tif (status != -ENOENT)\n\t\t\tcommand_info->command_finished = WHITEHEAT_CMD_FAILURE;\n\t\twake_up(&command_info->wait_command);\n\t\treturn;\n\t}\n\n\tusb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data);\n\n\tif (data[0] == WHITEHEAT_CMD_COMPLETE) {\n\t\tcommand_info->command_finished = WHITEHEAT_CMD_COMPLETE;\n\t\twake_up(&command_info->wait_command);\n\t} else if (data[0] == WHITEHEAT_CMD_FAILURE) {\n\t\tcommand_info->command_finished = WHITEHEAT_CMD_FAILURE;\n\t\twake_up(&command_info->wait_command);\n\t} else if (data[0] == WHITEHEAT_EVENT) {\n\t\t/* These are unsolicited reports from the firmware, hence no\n\t\t waiting command to wakeup */\n\t\tdev_dbg(&urb->dev->dev, \"%s - event received\\n\", __func__);\n\t} else if (data[0] == WHITEHEAT_GET_DTR_RTS) {\n\t\tmemcpy(command_info->result_buffer, &data[1],\n\t\t\t\t\t\turb->actual_length - 1);\n\t\tcommand_info->command_finished = WHITEHEAT_CMD_COMPLETE;\n\t\twake_up(&command_info->wait_command);\n\t} else\n\t\tdev_dbg(&urb->dev->dev, \"%s - bad reply from firmware\\n\", __func__);\n\n\t/* Continue trying to always read */\n\tresult = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);\n\tif (result)\n\t\tdev_dbg(&urb->dev->dev, \"%s - failed resubmitting read urb, error %d\\n\",\n\t\t\t__func__, result);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static void dns_resolver_describe(const struct key *key, struct seq_file *m)\n{\n\tseq_puts(m, key->description);\n\tif (key_is_instantiated(key)) {\n\t\tint err = PTR_ERR(key->payload.data[dns_key_error]);\n\n\t\tif (err)\n\t\t\tseq_printf(m, \": %d\", err);\n\t\telse\n\t\t\tseq_printf(m, \": %u\", key->datalen);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)\n{\n\tTIFFPredictorState *sp = PredictorState(tif);\n\n\tassert(sp != NULL);\n\tassert(sp->encodepfunc != NULL);\n\tassert(sp->encoderow != NULL);\n\n\t/* XXX horizontal differencing alters user's data XXX */\n\t(*sp->encodepfunc)(tif, bp, cc);\n\treturn (*sp->encoderow)(tif, bp, cc, s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "spnego_gss_context_time(\n\t\t\tOM_uint32\t*minor_status,\n\t\t\tconst gss_ctx_id_t context_handle,\n\t\t\tOM_uint32\t*time_rec)\n{\n\tOM_uint32 ret;\n\tret = gss_context_time(minor_status,\n\t\t\t context_handle,\n\t\t\t time_rec);\n\treturn (ret);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "vulnerable"} {"code": "static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_rng rrng;\n\n\tsnprintf(rrng.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"rng\");\n\n\trrng.seedsize = alg->cra_rng.seedsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_RNG,\n\t\t sizeof(struct crypto_report_rng), &rrng))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "static int handle_emulation_failure(struct kvm_vcpu *vcpu)\n{\n\tint r = EMULATE_DONE;\n\n\t++vcpu->stat.insn_emulation_fail;\n\ttrace_kvm_emulate_insn_failed(vcpu);\n\tif (!is_guest_mode(vcpu)) {\n\t\tvcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;\n\t\tvcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;\n\t\tvcpu->run->internal.ndata = 0;\n\t\tr = EMULATE_FAIL;\n\t}\n\tkvm_queue_exception(vcpu, UD_VECTOR);\n\n\treturn r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)\n{\n\tstruct trace_array *tr = data;\n\tstruct ftrace_event_file *ftrace_file;\n\tstruct syscall_trace_exit *entry;\n\tstruct syscall_metadata *sys_data;\n\tstruct ring_buffer_event *event;\n\tstruct ring_buffer *buffer;\n\tunsigned long irq_flags;\n\tint pc;\n\tint syscall_nr;\n\n\tsyscall_nr = trace_get_syscall_nr(current, regs);\n\tif (syscall_nr < 0 || syscall_nr >= NR_syscalls)\n\t\treturn;\n\n\t/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */\n\tftrace_file = rcu_dereference_sched(tr->exit_syscall_files[syscall_nr]);\n\tif (!ftrace_file)\n\t\treturn;\n\n\tif (ftrace_trigger_soft_disabled(ftrace_file))\n\t\treturn;\n\n\tsys_data = syscall_nr_to_meta(syscall_nr);\n\tif (!sys_data)\n\t\treturn;\n\n\tlocal_save_flags(irq_flags);\n\tpc = preempt_count();\n\n\tbuffer = tr->trace_buffer.buffer;\n\tevent = trace_buffer_lock_reserve(buffer,\n\t\t\tsys_data->exit_event->event.type, sizeof(*entry),\n\t\t\tirq_flags, pc);\n\tif (!event)\n\t\treturn;\n\n\tentry = ring_buffer_event_data(event);\n\tentry->nr = syscall_nr;\n\tentry->ret = syscall_get_return_value(current, regs);\n\n\tevent_trigger_unlock_commit(ftrace_file, buffer, event, entry,\n\t\t\t\t irq_flags, pc);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "int do_set_thread_area(struct task_struct *p, int idx,\n\t\t struct user_desc __user *u_info,\n\t\t int can_allocate)\n{\n\tstruct user_desc info;\n\n\tif (copy_from_user(&info, u_info, sizeof(info)))\n\t\treturn -EFAULT;\n\n\tif (!tls_desc_okay(&info))\n\t\treturn -EINVAL;\n\n\tif (idx == -1)\n\t\tidx = info.entry_number;\n\n\t/*\n\t * index -1 means the kernel should try to find and\n\t * allocate an empty descriptor:\n\t */\n\tif (idx == -1 && can_allocate) {\n\t\tidx = get_free_idx();\n\t\tif (idx < 0)\n\t\t\treturn idx;\n\t\tif (put_user(idx, &u_info->entry_number))\n\t\t\treturn -EFAULT;\n\t}\n\n\tif (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)\n\t\treturn -EINVAL;\n\n\tset_tls_desc(p, idx, &info, 1);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "jp2_box_t *jp2_box_get(jas_stream_t *in)\n{\n\tjp2_box_t *box;\n\tjp2_boxinfo_t *boxinfo;\n\tjas_stream_t *tmpstream;\n\tuint_fast32_t len;\n\tuint_fast64_t extlen;\n\tbool dataflag;\n\n\tbox = 0;\n\ttmpstream = 0;\n\n\tif (!(box = jas_malloc(sizeof(jp2_box_t)))) {\n\t\tgoto error;\n\t}\n\n\t// Mark the box data as never having been constructed\n\t// so that we will not errantly attempt to destroy it later.\n\tbox->ops = &jp2_boxinfo_unk.ops;\n\n\tif (jp2_getuint32(in, &len) || jp2_getuint32(in, &box->type)) {\n\t\tgoto error;\n\t}\n\tboxinfo = jp2_boxinfolookup(box->type);\n\tbox->info = boxinfo;\n\tbox->len = len;\n\tJAS_DBGLOG(10, (\n\t \"preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\\n\",\n\t '\"', boxinfo->name, '\"', box->type, box->len\n\t ));\n\tif (box->len == 1) {\n\t\tif (jp2_getuint64(in, &extlen)) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (extlen > 0xffffffffUL) {\n\t\t\tjas_eprintf(\"warning: cannot handle large 64-bit box length\\n\");\n\t\t\textlen = 0xffffffffUL;\n\t\t}\n\t\tbox->len = extlen;\n\t\tbox->datalen = extlen - JP2_BOX_HDRLEN(true);\n\t} else {\n\t\tbox->datalen = box->len - JP2_BOX_HDRLEN(false);\n\t}\n\tif (box->len != 0 && box->len < 8) {\n\t\tgoto error;\n\t}\n\n\tdataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));\n\n\tif (dataflag) {\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jas_stream_copy(tmpstream, in, box->datalen)) {\n\t\t\tjas_eprintf(\"cannot copy box data\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tjas_stream_rewind(tmpstream);\n\n\t\t// From here onwards, the box data will need to be destroyed.\n\t\t// So, initialize the box operations.\n\t\tbox->ops = &boxinfo->ops;\n\n\t\tif (box->ops->getdata) {\n\t\t\tif ((*box->ops->getdata)(box, tmpstream)) {\n\t\t\t\tjas_eprintf(\"cannot parse box data\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t\tjas_stream_close(tmpstream);\n\t}\n\n\tif (jas_getdbglevel() >= 1) {\n\t\tjp2_box_dump(box, stderr);\n\t}\n\n\treturn box;\n\nerror:\n\tif (box) {\n\t\tjp2_box_destroy(box);\n\t}\n\tif (tmpstream) {\n\t\tjas_stream_close(tmpstream);\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "BOOL update_recv(rdpUpdate* update, wStream* s)\n{\n\tBOOL rc = FALSE;\n\tUINT16 updateType;\n\trdpContext* context = update->context;\n\n\tif (Stream_GetRemainingLength(s) < 2)\n\t{\n\t\tWLog_ERR(TAG, \"Stream_GetRemainingLength(s) < 2\");\n\t\treturn FALSE;\n\t}\n\n\tStream_Read_UINT16(s, updateType); /* updateType (2 bytes) */\n\tWLog_Print(update->log, WLOG_TRACE, \"%s Update Data PDU\", UPDATE_TYPE_STRINGS[updateType]);\n\n\tif (!update_begin_paint(update))\n\t\tgoto fail;\n\n\tswitch (updateType)\n\t{\n\t\tcase UPDATE_TYPE_ORDERS:\n\t\t\trc = update_recv_orders(update, s);\n\t\t\tbreak;\n\n\t\tcase UPDATE_TYPE_BITMAP:\n\t\t{\n\t\t\tBITMAP_UPDATE* bitmap_update = update_read_bitmap_update(update, s);\n\n\t\t\tif (!bitmap_update)\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"UPDATE_TYPE_BITMAP - update_read_bitmap_update() failed\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\trc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update);\n\t\t\tfree_bitmap_update(update->context, bitmap_update);\n\t\t}\n\t\tbreak;\n\n\t\tcase UPDATE_TYPE_PALETTE:\n\t\t{\n\t\t\tPALETTE_UPDATE* palette_update = update_read_palette(update, s);\n\n\t\t\tif (!palette_update)\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"UPDATE_TYPE_PALETTE - update_read_palette() failed\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\trc = IFCALLRESULT(FALSE, update->Palette, context, palette_update);\n\t\t\tfree_palette_update(context, palette_update);\n\t\t}\n\t\tbreak;\n\n\t\tcase UPDATE_TYPE_SYNCHRONIZE:\n\t\t\tif (!update_read_synchronize(update, s))\n\t\t\t\tgoto fail;\n\t\t\trc = IFCALLRESULT(TRUE, update->Synchronize, context);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\nfail:\n\n\tif (!update_end_paint(update))\n\t\trc = FALSE;\n\n\tif (!rc)\n\t{\n\t\tWLog_ERR(TAG, \"UPDATE_TYPE %s [%\" PRIu16 \"] failed\", update_type_to_string(updateType),\n\t\t updateType);\n\t\treturn FALSE;\n\t}\n\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "DECLAREreadFunc(readContigTilesIntoBuffer)\n{\n\tint status = 1;\n\ttsize_t tilesize = TIFFTileSize(in);\n\ttdata_t tilebuf;\n\tuint32 imagew = TIFFScanlineSize(in);\n\tuint32 tilew = TIFFTileRowSize(in);\n\tint64 iskew = (int64)imagew - (int64)tilew;\n\tuint8* bufp = (uint8*) buf;\n\tuint32 tw, tl;\n\tuint32 row;\n\n\t(void) spp;\n\ttilebuf = _TIFFmalloc(tilesize);\n\tif (tilebuf == 0)\n\t\treturn 0;\n\t_TIFFmemset(tilebuf, 0, tilesize);\n\t(void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);\n\t(void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);\n \n\tfor (row = 0; row < imagelength; row += tl) {\n\t\tuint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;\n\t\tuint32 colb = 0;\n\t\tuint32 col;\n\n\t\tfor (col = 0; col < imagewidth && colb < imagew; col += tw) {\n\t\t\tif (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0\n\t\t\t && !ignore) {\n\t\t\t\tTIFFError(TIFFFileName(in),\n\t\t\t\t \"Error, can't read tile at %lu %lu\",\n\t\t\t\t (unsigned long) col,\n\t\t\t\t (unsigned long) row);\n\t\t\t\tstatus = 0;\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t\tif (colb > iskew) {\n\t\t\t\tuint32 width = imagew - colb;\n\t\t\t\tuint32 oskew = tilew - width;\n\t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, width,\n\t\t\t\t oskew + iskew, oskew );\n\t\t\t} else\n\t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, tilew,\n\t\t\t\t iskew, 0);\n\t\t\tcolb += tilew;\n\t\t}\n\t\tbufp += imagew * nrow;\n\t}\ndone:\n\t_TIFFfree(tilebuf);\n\treturn status;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static inline FILE *xfmkstemp(char **tmpname, char *dir)\n{\n\tint fd;\n\tFILE *ret;\n\n\tfd = xmkstemp(tmpname, dir);\n\tif (fd == -1)\n\t\treturn NULL;\n\n\tif (!(ret = fdopen(fd, \"w+\" UL_CLOEXECSTR))) {\n\t\tclose(fd);\n\t\treturn NULL;\n\t}\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "static pyc_object *get_none_object(void) {\n\tpyc_object *ret;\n\n\tret = R_NEW0 (pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->type = TYPE_NONE;\n\tret->data = strdup (\"None\");\n\tif (!ret->data) {\n\t\tR_FREE (ret);\n\t}\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int cg_rmdir(const char *path)\n{\n\tstruct fuse_context *fc = fuse_get_context();\n\tchar *fpath = NULL, *cgdir = NULL, *controller;\n\tconst char *cgroup;\n\tint ret;\n\n\tif (!fc)\n\t\treturn -EIO;\n\n\tcontroller = pick_controller_from_path(fc, path);\n\tif (!controller)\n\t\treturn -EINVAL;\n\n\tcgroup = find_cgroup_in_path(path);\n\tif (!cgroup)\n\t\treturn -EINVAL;\n\n\tget_cgdir_and_path(cgroup, &cgdir, &fpath);\n\tif (!fpath) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tfprintf(stderr, \"rmdir: verifying access to %s:%s (req path %s)\\n\",\n\t\t\tcontroller, cgdir, path);\n\tif (!fc_may_access(fc, controller, cgdir, NULL, O_WRONLY)) {\n\t\tret = -EACCES;\n\t\tgoto out;\n\t}\n\tif (!caller_is_in_ancestor(fc->pid, controller, cgroup, NULL)) {\n\t\tret = -EACCES;\n\t\tgoto out;\n\t}\n\n\tif (!cgfs_remove(controller, cgroup)) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tret = 0;\n\nout:\n\tfree(cgdir);\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,\n\t\t\t size_t len, loff_t *pos)\n{\n\tstruct ib_ucm_file *file = filp->private_data;\n\tstruct ib_ucm_cmd_hdr hdr;\n\tssize_t result;\n\n\tif (WARN_ON_ONCE(!ib_safe_file_access(filp)))\n\t\treturn -EACCES;\n\n\tif (len < sizeof(hdr))\n\t\treturn -EINVAL;\n\n\tif (copy_from_user(&hdr, buf, sizeof(hdr)))\n\t\treturn -EFAULT;\n\n\tif (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))\n\t\treturn -EINVAL;\n\n\tif (hdr.in + sizeof(hdr) > len)\n\t\treturn -EINVAL;\n\n\tresult = ucm_cmd_table[hdr.cmd](file, buf + sizeof(hdr),\n\t\t\t\t\thdr.in, hdr.out);\n\tif (!result)\n\t\tresult = len;\n\n\treturn result;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,\n xkb_mod_mask_t *mods_rtrn, CompatInfo *info)\n{\n if (expr == NULL) {\n *pred_rtrn = MATCH_ANY_OR_NONE;\n *mods_rtrn = MOD_REAL_MASK_ALL;\n return true;\n }\n\n *pred_rtrn = MATCH_EXACTLY;\n if (expr->expr.op == EXPR_ACTION_DECL) {\n const char *pred_txt = xkb_atom_text(info->ctx, expr->action.name);\n if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn) ||\n !expr->action.args) {\n log_err(info->ctx,\n \"Illegal modifier predicate \\\"%s\\\"; Ignored\\n\", pred_txt);\n return false;\n }\n expr = expr->action.args;\n }\n else if (expr->expr.op == EXPR_IDENT) {\n const char *pred_txt = xkb_atom_text(info->ctx, expr->ident.ident);\n if (pred_txt && istreq(pred_txt, \"any\")) {\n *pred_rtrn = MATCH_ANY;\n *mods_rtrn = MOD_REAL_MASK_ALL;\n return true;\n }\n }\n\n return ExprResolveModMask(info->ctx, expr, MOD_REAL, &info->mods,\n mods_rtrn);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int xfrm_dump_policy_start(struct netlink_callback *cb)\n{\n\tstruct xfrm_policy_walk *walk = (struct xfrm_policy_walk *)cb->args;\n\n\tBUILD_BUG_ON(sizeof(*walk) > sizeof(cb->args));\n\n\txfrm_policy_walk_init(walk, XFRM_POLICY_TYPE_ANY);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "find_jws(struct tang_keys_info* tki, const char* thp)\n{\n if (!tki) {\n return NULL;\n }\n\n if (thp == NULL) {\n /* Default advertisement. */\n json_auto_t* jws = jwk_sign(tki->m_payload, tki->m_sign);\n if (!jws) {\n return NULL;\n }\n return json_incref(jws);\n }\n return find_by_thp(tki, thp);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "isakmp_rfc3948_print(netdissect_options *ndo,\n\t\t const u_char *bp, u_int length,\n\t\t const u_char *bp2)\n{\n\tND_TCHECK(bp[0]);\n\tif(length == 1 && bp[0]==0xff) {\n\t\tND_PRINT((ndo, \"isakmp-nat-keep-alive\"));\n\t\treturn;\n\t}\n\n\tif(length < 4) {\n\t\tgoto trunc;\n\t}\n\tND_TCHECK(bp[3]);\n\n\t/*\n\t * see if this is an IKE packet\n\t */\n\tif(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {\n\t\tND_PRINT((ndo, \"NONESP-encap: \"));\n\t\tisakmp_print(ndo, bp+4, length-4, bp2);\n\t\treturn;\n\t}\n\n\t/* must be an ESP packet */\n\t{\n\t\tint nh, enh, padlen;\n\t\tint advance;\n\n\t\tND_PRINT((ndo, \"UDP-encap: \"));\n\n\t\tadvance = esp_print(ndo, bp, length, bp2, &enh, &padlen);\n\t\tif(advance <= 0)\n\t\t\treturn;\n\n\t\tbp += advance;\n\t\tlength -= advance + padlen;\n\t\tnh = enh & 0xff;\n\n\t\tip_print_inner(ndo, bp, length, nh, bp2);\n\t\treturn;\n\t}\n\ntrunc:\n\tND_PRINT((ndo,\"[|isakmp]\"));\n\treturn;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void blendMode(HttpRoute *route, MprJson *config)\n{\n MprJson *currentMode, *app;\n cchar *mode;\n\n mode = mprGetJson(config, \"app.mode\");\n if (!mode) {\n mode = sclone(\"debug\");\n }\n route->debug = smatch(mode, \"debug\");\n if ((currentMode = mprGetJsonObj(config, sfmt(\"app.modes.%s\", mode))) != 0) {\n app = mprLookupJsonObj(config, \"app\");\n mprBlendJson(app, currentMode, MPR_JSON_OVERWRITE);\n mprSetJson(app, \"app.mode\", mode);\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "int perf_event_task_enable(void)\n{\n\tstruct perf_event_context *ctx;\n\tstruct perf_event *event;\n\n\tmutex_lock(¤t->perf_event_mutex);\n\tlist_for_each_entry(event, ¤t->perf_event_list, owner_entry) {\n\t\tctx = perf_event_ctx_lock(event);\n\t\tperf_event_for_each_child(event, _perf_event_enable);\n\t\tperf_event_ctx_unlock(event, ctx);\n\t}\n\tmutex_unlock(¤t->perf_event_mutex);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static void _imap_quote_string (char *dest, size_t dlen, const char *src,\n const char *to_quote)\n{\n char *pt;\n const char *s;\n\n pt = dest;\n s = src;\n\n *pt++ = '\"';\n /* save room for trailing quote-char */\n dlen -= 2;\n\n for (; *s && dlen; s++)\n {\n if (strchr (to_quote, *s))\n {\n dlen -= 2;\n if (!dlen)\n\tbreak;\n *pt++ = '\\\\';\n *pt++ = *s;\n }\n else\n {\n *pt++ = *s;\n dlen--;\n }\n }\n *pt++ = '\"';\n *pt = 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-191", "cwe_name": "Integer Underflow (Wrap or Wraparound)", "description": "The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.", "url": "https://cwe.mitre.org/data/definitions/191.html", "label_name": "vulnerable"} {"code": "cleanup_pathname(struct archive_write_disk *a)\n{\n\tchar *dest, *src;\n\tchar separator = '\\0';\n\n\tdest = src = a->name;\n\tif (*src == '\\0') {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"Invalid empty pathname\");\n\t\treturn (ARCHIVE_FAILED);\n\t}\n\n#if defined(__CYGWIN__)\n\tcleanup_pathname_win(a);\n#endif\n\t/* Skip leading '/'. */\n\tif (*src == '/')\n\t\tseparator = *src++;\n\n\t/* Scan the pathname one element at a time. */\n\tfor (;;) {\n\t\t/* src points to first char after '/' */\n\t\tif (src[0] == '\\0') {\n\t\t\tbreak;\n\t\t} else if (src[0] == '/') {\n\t\t\t/* Found '//', ignore second one. */\n\t\t\tsrc++;\n\t\t\tcontinue;\n\t\t} else if (src[0] == '.') {\n\t\t\tif (src[1] == '\\0') {\n\t\t\t\t/* Ignore trailing '.' */\n\t\t\t\tbreak;\n\t\t\t} else if (src[1] == '/') {\n\t\t\t\t/* Skip './'. */\n\t\t\t\tsrc += 2;\n\t\t\t\tcontinue;\n\t\t\t} else if (src[1] == '.') {\n\t\t\t\tif (src[2] == '/' || src[2] == '\\0') {\n\t\t\t\t\t/* Conditionally warn about '..' */\n\t\t\t\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {\n\t\t\t\t\t\tarchive_set_error(&a->archive,\n\t\t\t\t\t\t ARCHIVE_ERRNO_MISC,\n\t\t\t\t\t\t \"Path contains '..'\");\n\t\t\t\t\t\treturn (ARCHIVE_FAILED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/*\n\t\t\t\t * Note: Under no circumstances do we\n\t\t\t\t * remove '..' elements. In\n\t\t\t\t * particular, restoring\n\t\t\t\t * '/foo/../bar/' should create the\n\t\t\t\t * 'foo' dir as a side-effect.\n\t\t\t\t */\n\t\t\t}\n\t\t}\n\n\t\t/* Copy current element, including leading '/'. */\n\t\tif (separator)\n\t\t\t*dest++ = '/';\n\t\twhile (*src != '\\0' && *src != '/') {\n\t\t\t*dest++ = *src++;\n\t\t}\n\n\t\tif (*src == '\\0')\n\t\t\tbreak;\n\n\t\t/* Skip '/' separator. */\n\t\tseparator = *src++;\n\t}\n\t/*\n\t * We've just copied zero or more path elements, not including the\n\t * final '/'.\n\t */\n\tif (dest == a->name) {\n\t\t/*\n\t\t * Nothing got copied. The path must have been something\n\t\t * like '.' or '/' or './' or '/././././/./'.\n\t\t */\n\t\tif (separator)\n\t\t\t*dest++ = '/';\n\t\telse\n\t\t\t*dest++ = '.';\n\t}\n\t/* Terminate the result. */\n\t*dest = '\\0';\n\treturn (ARCHIVE_OK);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create)\n{\n char *path = xstrdup(p);\n char *dp = path;\n char *sp = NULL, *bn;\n int oflags = O_RDONLY;\n\n int dirfd = fsmOpenat(-1, \"/\", oflags);\n int fd = dirfd; /* special case of \"/\" */\n\n while ((bn = strtok_r(dp, \"/\", &sp)) != NULL) {\n\tstruct stat sb;\n\tfd = fsmOpenat(dirfd, bn, oflags);\n\n\tif (fd < 0 && errno == ENOENT && create) {\n\t mode_t mode = S_IFDIR | (_dirPerms & 07777);\n\t if (fsmDoMkDir(plugins, dirfd, bn, owned, mode) == 0) {\n\t\tfd = fsmOpenat(dirfd, bn, oflags|O_NOFOLLOW);\n\t }\n\t}\n\n\tif (fd >= 0 && fstat(fd, &sb) == 0 && !S_ISDIR(sb.st_mode)) {\n\t close(fd);\n\t errno = ENOTDIR;\n\t fd = -1;\n\t}\n\n\tclose(dirfd);\n\tif (fd >= 0) {\n\t dirfd = fd;\n\t} else {\n\t dirfd = -1;\n\t rpmlog(RPMLOG_ERR, _(\"failed to open dir %s of %s: %s\\n\"),\n\t\t\t\tbn, p, strerror(errno));\n\t break;\n\t}\n\n\tdp = NULL;\n }\n\n free(path);\n return dirfd;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "videobuf_vm_open(struct vm_area_struct *vma)\n{\n\tstruct videobuf_mapping *map = vma->vm_private_data;\n\n\tdprintk(2,\"vm_open %p [count=%d,vma=%08lx-%08lx]\\n\",map,\n\t\tmap->count,vma->vm_start,vma->vm_end);\n\n\tmap->count++;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message, uint64_t msgLen) {\n\n if (!message) {\n LOG_ERROR(\"Null message in AES_encrypt\");\n return -1;\n }\n\n if (!encr_message) {\n LOG_ERROR(\"Null encr message in AES_encrypt\");\n return -2;\n }\n\n\n if (length < SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE) {\n LOG_ERROR(\"length < SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE\");\n return -1;\n }\n\n\n\n uint64_t len = length - SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE;\n\n if (msgLen < len) {\n LOG_ERROR(\"Output buffer not large enough\");\n return -2;\n }\n\n sgx_status_t status = sgx_rijndael128GCM_decrypt(&AES_key,\n encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE, len,\n (unsigned char*) message,\n encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE,\n NULL, 0,\n (sgx_aes_gcm_128bit_tag_t *)encr_message);\n\n return status;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void user_describe(const struct key *key, struct seq_file *m)\n{\n\tseq_puts(m, key->description);\n\tif (key_is_positive(key))\n\t\tseq_printf(m, \": %u\", key->datalen);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "static int er_supported(ERContext *s)\n{\n if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||\n !s->cur_pic.f ||\n s->cur_pic.field_picture\n )\n return 0;\n return 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "safe"} {"code": "static Var* Pe_r_bin_pe_parse_var(RBinPEObj* pe, PE_DWord* curAddr) {\n\tVar* var = calloc (1, sizeof (*var));\n\tif (!var) {\n\t\tpe_printf (\"Warning: calloc (Var)\\n\");\n\t\treturn NULL;\n\t}\n\tif ((var->wLength = r_buf_read_le16_at (pe->b, *curAddr)) == UT16_MAX) {\n\t\tpe_printf (\"Warning: read (Var wLength)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\t*curAddr += sizeof (var->wLength);\n\tif ((var->wValueLength = r_buf_read_le16_at (pe->b, *curAddr)) == UT16_MAX) {\n\t\tpe_printf (\"Warning: read (Var wValueLength)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\t*curAddr += sizeof (var->wValueLength);\n\tif ((var->wType = r_buf_read_le16_at (pe->b, *curAddr)) == UT16_MAX) {\n\t\tpe_printf (\"Warning: read (Var wType)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\t*curAddr += sizeof (var->wType);\n\tif (var->wType != 0 && var->wType != 1) {\n\t\tpe_printf (\"Warning: check (Var wType)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\n\tvar->szKey = (ut16*) malloc (UT16_ALIGN (TRANSLATION_UTF_16_LEN)); //L\"Translation\"\n\tif (!var->szKey) {\n\t\tpe_printf (\"Warning: malloc (Var szKey)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\tif (r_buf_read_at (pe->b, *curAddr, (ut8*) var->szKey, TRANSLATION_UTF_16_LEN) != TRANSLATION_UTF_16_LEN) {\n\t\tpe_printf (\"Warning: read (Var szKey)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\t*curAddr += TRANSLATION_UTF_16_LEN;\n\tif (memcmp (var->szKey, TRANSLATION_UTF_16, TRANSLATION_UTF_16_LEN)) {\n\t\tpe_printf (\"Warning: check (Var szKey)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\talign32 (*curAddr);\n\tvar->numOfValues = var->wValueLength / 4;\n\tif (!var->numOfValues) {\n\t\tpe_printf (\"Warning: check (Var numOfValues)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\tvar->Value = (ut32*) malloc (var->wValueLength);\n\tif (!var->Value) {\n\t\tpe_printf (\"Warning: malloc (Var Value)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\tif (r_buf_read_at (pe->b, *curAddr, (ut8*) var->Value, var->wValueLength) != var->wValueLength) {\n\t\tpe_printf (\"Warning: read (Var Value)\\n\");\n\t\tfree_Var (var);\n\t\treturn NULL;\n\t}\n\t*curAddr += var->wValueLength;\n\treturn var;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "char *string_crypt(const char *key, const char *salt) {\n assertx(key);\n assertx(salt);\n\n char random_salt[12];\n if (!*salt) {\n memcpy(random_salt,\"$1$\",3);\n ito64(random_salt+3,rand(),8);\n random_salt[11] = '\\0';\n return string_crypt(key, random_salt);\n }\n\n auto const saltLen = strlen(salt);\n if ((saltLen > sizeof(\"$2X$00$\")) &&\n (salt[0] == '$') &&\n (salt[1] == '2') &&\n (salt[2] >= 'a') && (salt[2] <= 'z') &&\n (salt[3] == '$') &&\n (salt[4] >= '0') && (salt[4] <= '3') &&\n (salt[5] >= '0') && (salt[5] <= '9') &&\n (salt[6] == '$')) {\n // Bundled blowfish crypt()\n char output[61];\n\n static constexpr size_t maxSaltLength = 123;\n char paddedSalt[maxSaltLength + 1];\n paddedSalt[0] = paddedSalt[maxSaltLength] = '\\0';\n\n memset(&paddedSalt[1], '$', maxSaltLength - 1);\n memcpy(paddedSalt, salt, std::min(maxSaltLength, saltLen));\n paddedSalt[std::min(maxSaltLength, saltLen)] = '\\0';\n\n if (php_crypt_blowfish_rn(key, paddedSalt, output, sizeof(output))) {\n return strdup(output);\n }\n\n } else {\n // System crypt() function\n#ifdef USE_PHP_CRYPT_R\n return php_crypt_r(key, salt);\n#else\n static Mutex mutex;\n Lock lock(mutex);\n char *crypt_res = crypt(key,salt);\n\n if (crypt_res) {\n return strdup(crypt_res);\n }\n#endif\n }\n\n return ((salt[0] == '*') && (salt[1] == '0'))\n ? strdup(\"*1\") : strdup(\"*0\");\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static void editPackageValue(int argc, char **argv)\n{\n cchar *key, *value;\n int i;\n\n if (argc < 1) {\n usageError();\n return;\n }\n for (i = 0; i < argc; i++) {\n key = ssplit(sclone(argv[i]), \"=\", (char**) &value);\n if (value) {\n setPackageKey(key, value);\n } else {\n value = getConfigValue(key, 0);\n if (value) { \n printf(\"%s\\n\", value);\n } else {\n printf(\"undefined\\n\");\n }\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static int parse_exports_table(long long *table_start)\n{\n\tint res;\n\tint indexes = SQUASHFS_LOOKUP_BLOCKS(sBlk.s.inodes);\n\tlong long export_index_table[indexes];\n\n\tres = read_fs_bytes(fd, sBlk.s.lookup_table_start,\n\t\tSQUASHFS_LOOKUP_BLOCK_BYTES(sBlk.s.inodes), export_index_table);\n\tif(res == FALSE) {\n\t\tERROR(\"parse_exports_table: failed to read export index table\\n\");\n\t\treturn FALSE;\n\t}\n\tSQUASHFS_INSWAP_LOOKUP_BLOCKS(export_index_table, indexes);\n\n\t/*\n\t * export_index_table[0] stores the start of the compressed export blocks.\n\t * This by definition is also the end of the previous filesystem\n\t * table - the fragment table.\n\t */\n\t*table_start = export_index_table[0];\n\n\treturn TRUE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "R_API void r_core_fini(RCore *c) {\n\tif (!c) {\n\t\treturn;\n\t}\n\tr_core_task_break_all (&c->tasks);\n\tr_core_task_join (&c->tasks, NULL, -1);\n\tr_core_wait (c);\n\t/* TODO: it leaks as shit */\n\t//update_sdb (c);\n\t// avoid double free\n\tr_list_free (c->ropchain);\n\tr_event_free (c->ev);\n\tfree (c->cmdlog);\n\tfree (c->lastsearch);\n\tR_FREE (c->cons->pager);\n\tfree (c->cmdqueue);\n\tfree (c->lastcmd);\n\tfree (c->stkcmd);\n\tr_list_free (c->visual.tabs);\n\tfree (c->block);\n\tr_core_autocomplete_free (c->autocomplete);\n\n\tr_list_free (c->gadgets);\n\tr_list_free (c->undos);\n\tr_num_free (c->num);\n\t// TODO: sync or not? sdb_sync (c->sdb);\n\t// TODO: sync all dbs?\n\t//r_core_file_free (c->file);\n\t//c->file = NULL;\n\tfree (c->table_query);\n\tr_list_free (c->files);\n\tr_list_free (c->watchers);\n\tr_list_free (c->scriptstack);\n\tr_core_task_scheduler_fini (&c->tasks);\n\tc->rcmd = r_cmd_free (c->rcmd);\n\tr_list_free (c->cmd_descriptors);\n\tc->anal = r_anal_free (c->anal);\n\tr_asm_free (c->assembler);\n\tc->assembler = NULL;\n\tc->print = r_print_free (c->print);\n\tc->bin = (r_bin_free (c->bin), NULL);\n\tc->lang = (r_lang_free (c->lang), NULL);\n\tc->dbg = (r_debug_free (c->dbg), NULL);\n\tr_io_free (c->io);\n\tr_config_free (c->config);\n\t/* after r_config_free, the value of I.teefile is trashed */\n\t/* rconfig doesnt knows how to deinitialize vars, so we\n\tshould probably need to add a r_config_free_payload callback */\n\tr_cons_free ();\n\tr_cons_singleton ()->teefile = NULL; // HACK\n\tr_search_free (c->search);\n\tr_flag_free (c->flags);\n\tr_fs_free (c->fs);\n\tr_egg_free (c->egg);\n\tr_lib_free (c->lib);\n\tr_buf_free (c->yank_buf);\n\tr_agraph_free (c->graph);\n\tfree (c->asmqjmps);\n\tsdb_free (c->sdb);\n\tr_core_log_free (c->log);\n\tr_parse_free (c->parser);\n\tfree (c->times);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static void process_tree(struct rev_info *revs,\n\t\t\t struct tree *tree,\n\t\t\t show_object_fn show,\n\t\t\t struct strbuf *base,\n\t\t\t const char *name,\n\t\t\t void *cb_data)\n{\n\tstruct object *obj = &tree->object;\n\tstruct tree_desc desc;\n\tstruct name_entry entry;\n\tenum interesting match = revs->diffopt.pathspec.nr == 0 ?\n\t\tall_entries_interesting: entry_not_interesting;\n\tint baselen = base->len;\n\n\tif (!revs->tree_objects)\n\t\treturn;\n\tif (!obj)\n\t\tdie(\"bad tree object\");\n\tif (obj->flags & (UNINTERESTING | SEEN))\n\t\treturn;\n\tif (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {\n\t\tif (revs->ignore_missing_links)\n\t\t\treturn;\n\t\tdie(\"bad tree object %s\", oid_to_hex(&obj->oid));\n\t}\n\n\tobj->flags |= SEEN;\n\tshow(obj, base, name, cb_data);\n\n\tstrbuf_addstr(base, name);\n\tif (base->len)\n\t\tstrbuf_addch(base, '/');\n\n\tinit_tree_desc(&desc, tree->buffer, tree->size);\n\n\twhile (tree_entry(&desc, &entry)) {\n\t\tif (match != all_entries_interesting) {\n\t\t\tmatch = tree_entry_interesting(&entry, base, 0,\n\t\t\t\t\t\t &revs->diffopt.pathspec);\n\t\t\tif (match == all_entries_not_interesting)\n\t\t\t\tbreak;\n\t\t\tif (match == entry_not_interesting)\n\t\t\t\tcontinue;\n\t\t}\n\n\t\tif (S_ISDIR(entry.mode))\n\t\t\tprocess_tree(revs,\n\t\t\t\t lookup_tree(entry.sha1),\n\t\t\t\t show, base, entry.path,\n\t\t\t\t cb_data);\n\t\telse if (S_ISGITLINK(entry.mode))\n\t\t\tprocess_gitlink(revs, entry.sha1,\n\t\t\t\t\tshow, base, entry.path,\n\t\t\t\t\tcb_data);\n\t\telse\n\t\t\tprocess_blob(revs,\n\t\t\t\t lookup_blob(entry.sha1),\n\t\t\t\t show, base, entry.path,\n\t\t\t\t cb_data);\n\t}\n\tstrbuf_setlen(base, baselen);\n\tfree_tree_buffer(tree);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {\n PyObject *__pyx_r = NULL;\n __Pyx_RefNannyDeclarations\n PyObject *__pyx_t_1 = NULL;\n __Pyx_RefNannySetupContext(\"__get__\", 0);\n __Pyx_XDECREF(__pyx_r);\n __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)\n __Pyx_GOTREF(__pyx_t_1);\n __pyx_r = __pyx_t_1;\n __pyx_t_1 = 0;\n goto __pyx_L0;\n\n /* function exit code */\n __pyx_L1_error:;\n __Pyx_XDECREF(__pyx_t_1);\n __Pyx_AddTraceback(\"clickhouse_driver.bufferedreader.BufferedReader.position.__get__\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n __pyx_r = NULL;\n __pyx_L0:;\n __Pyx_XGIVEREF(__pyx_r);\n __Pyx_RefNannyFinishContext();\n return __pyx_r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "static int ac_interception(struct vcpu_svm *svm)\n{\n\tkvm_queue_exception_e(&svm->vcpu, AC_VECTOR, 0);\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,\n\t\tunsigned int *rsize)\n{\n\tif (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&\n\t\t\trdesc[106] == 0x03) {\n\t\thid_info(hdev, \"fixing up Sunplus Wireless Desktop report descriptor\\n\");\n\t\trdesc[105] = rdesc[110] = 0x03;\n\t\trdesc[106] = rdesc[111] = 0x21;\n\t}\n\treturn rdesc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "iakerb_gss_delete_sec_context(OM_uint32 *minor_status,\n gss_ctx_id_t *context_handle,\n gss_buffer_t output_token)\n{\n iakerb_ctx_id_t iakerb_ctx = (iakerb_ctx_id_t)*context_handle;\n\n if (output_token != GSS_C_NO_BUFFER) {\n output_token->length = 0;\n output_token->value = NULL;\n }\n\n *minor_status = 0;\n *context_handle = GSS_C_NO_CONTEXT;\n iakerb_release_context(iakerb_ctx);\n\n return GSS_S_COMPLETE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-18", "cwe_name": "DEPRECATED: Source Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/18.html", "label_name": "safe"} {"code": "int build_segment_manager(struct f2fs_sb_info *sbi)\n{\n\tstruct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);\n\tstruct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);\n\tstruct f2fs_sm_info *sm_info;\n\tint err;\n\n\tsm_info = kzalloc(sizeof(struct f2fs_sm_info), GFP_KERNEL);\n\tif (!sm_info)\n\t\treturn -ENOMEM;\n\n\t/* init sm info */\n\tsbi->sm_info = sm_info;\n\tsm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr);\n\tsm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr);\n\tsm_info->segment_count = le32_to_cpu(raw_super->segment_count);\n\tsm_info->reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count);\n\tsm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count);\n\tsm_info->main_segments = le32_to_cpu(raw_super->segment_count_main);\n\tsm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);\n\tsm_info->rec_prefree_segments = sm_info->main_segments *\n\t\t\t\t\tDEF_RECLAIM_PREFREE_SEGMENTS / 100;\n\tif (sm_info->rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS)\n\t\tsm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS;\n\n\tif (!test_opt(sbi, LFS))\n\t\tsm_info->ipu_policy = 1 << F2FS_IPU_FSYNC;\n\tsm_info->min_ipu_util = DEF_MIN_IPU_UTIL;\n\tsm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;\n\tsm_info->min_hot_blocks = DEF_MIN_HOT_BLOCKS;\n\n\tsm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;\n\n\tINIT_LIST_HEAD(&sm_info->sit_entry_set);\n\n\tif (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) {\n\t\terr = create_flush_cmd_control(sbi);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\terr = create_discard_cmd_control(sbi);\n\tif (err)\n\t\treturn err;\n\n\terr = build_sit_info(sbi);\n\tif (err)\n\t\treturn err;\n\terr = build_free_segmap(sbi);\n\tif (err)\n\t\treturn err;\n\terr = build_curseg(sbi);\n\tif (err)\n\t\treturn err;\n\n\t/* reinit free segmap based on SIT */\n\tbuild_sit_entries(sbi);\n\n\tinit_free_segmap(sbi);\n\terr = build_dirty_segmap(sbi);\n\tif (err)\n\t\treturn err;\n\n\tinit_min_max_mtime(sbi);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)\n{\n\tstruct trace_array *tr = data;\n\tstruct ftrace_event_file *ftrace_file;\n\tstruct syscall_trace_enter *entry;\n\tstruct syscall_metadata *sys_data;\n\tstruct ring_buffer_event *event;\n\tstruct ring_buffer *buffer;\n\tunsigned long irq_flags;\n\tint pc;\n\tint syscall_nr;\n\tint size;\n\n\tsyscall_nr = trace_get_syscall_nr(current, regs);\n\tif (syscall_nr < 0 || syscall_nr >= NR_syscalls)\n\t\treturn;\n\n\t/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */\n\tftrace_file = rcu_dereference_sched(tr->enter_syscall_files[syscall_nr]);\n\tif (!ftrace_file)\n\t\treturn;\n\n\tif (ftrace_trigger_soft_disabled(ftrace_file))\n\t\treturn;\n\n\tsys_data = syscall_nr_to_meta(syscall_nr);\n\tif (!sys_data)\n\t\treturn;\n\n\tsize = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;\n\n\tlocal_save_flags(irq_flags);\n\tpc = preempt_count();\n\n\tbuffer = tr->trace_buffer.buffer;\n\tevent = trace_buffer_lock_reserve(buffer,\n\t\t\tsys_data->enter_event->event.type, size, irq_flags, pc);\n\tif (!event)\n\t\treturn;\n\n\tentry = ring_buffer_event_data(event);\n\tentry->nr = syscall_nr;\n\tsyscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);\n\n\tevent_trigger_unlock_commit(ftrace_file, buffer, event, entry,\n\t\t\t\t irq_flags, pc);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "void trustedGetPublicSharesAES(int *errStatus, char *errString, uint8_t *encrypted_dkg_secret, uint32_t enc_len,\n char *public_shares,\n unsigned _t, unsigned _n) {\n LOG_INFO(__FUNCTION__);\n\n INIT_ERROR_STATE\n\n CHECK_STATE(encrypted_dkg_secret);\n CHECK_STATE(public_shares);\n CHECK_STATE(_t <= _n && _n > 0)\n\n SAFE_CHAR_BUF(decrypted_dkg_secret, DKG_MAX_SEALED_LEN);\n\n int status = AES_decrypt(encrypted_dkg_secret, enc_len, decrypted_dkg_secret,\n DKG_MAX_SEALED_LEN);\n\n CHECK_STATUS2(\"aes decrypt data - encrypted_dkg_secret failed with status %d\");\n\n status = calc_public_shares(decrypted_dkg_secret, public_shares, _t) != 0;\n CHECK_STATUS(\"t does not match polynomial in db\");\n\n SET_SUCCESS\n\n clean:\n ;\n LOG_INFO(\"SGX call completed\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "AcpiNsTerminate (\n void)\n{\n ACPI_STATUS Status;\n\n\n ACPI_FUNCTION_TRACE (NsTerminate);\n\n\n#ifdef ACPI_EXEC_APP\n {\n ACPI_OPERAND_OBJECT *Prev;\n ACPI_OPERAND_OBJECT *Next;\n\n /* Delete any module-level code blocks */\n\n Next = AcpiGbl_ModuleCodeList;\n while (Next)\n {\n Prev = Next;\n Next = Next->Method.Mutex;\n Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */\n AcpiUtRemoveReference (Prev);\n }\n }\n#endif\n\n /*\n * Free the entire namespace -- all nodes and all objects\n * attached to the nodes\n */\n AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);\n\n /* Delete any objects attached to the root node */\n\n Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);\n if (ACPI_FAILURE (Status))\n {\n return_VOID;\n }\n\n AcpiNsDeleteNode (AcpiGbl_RootNode);\n (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);\n\n ACPI_DEBUG_PRINT ((ACPI_DB_INFO, \"Namespace freed\\n\"));\n return_VOID;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)\n{\n\tstruct key *key;\n\tkey_ref_t key_ref;\n\tlong ret;\n\n\t/* find the key first */\n\tkey_ref = lookup_user_key(keyid, 0, 0);\n\tif (IS_ERR(key_ref)) {\n\t\tret = -ENOKEY;\n\t\tgoto error;\n\t}\n\n\tkey = key_ref_to_ptr(key_ref);\n\n\t/* see if we can read it directly */\n\tret = key_permission(key_ref, KEY_NEED_READ);\n\tif (ret == 0)\n\t\tgoto can_read_key;\n\tif (ret != -EACCES)\n\t\tgoto error;\n\n\t/* we can't; see if it's searchable from this process's keyrings\n\t * - we automatically take account of the fact that it may be\n\t * dangling off an instantiation key\n\t */\n\tif (!is_key_possessed(key_ref)) {\n\t\tret = -EACCES;\n\t\tgoto error2;\n\t}\n\n\t/* the key is probably readable - now try to read it */\ncan_read_key:\n\tret = key_validate(key);\n\tif (ret == 0) {\n\t\tret = -EOPNOTSUPP;\n\t\tif (key->type->read) {\n\t\t\t/* read the data with the semaphore held (since we\n\t\t\t * might sleep) */\n\t\t\tdown_read(&key->sem);\n\t\t\tret = key->type->read(key, buffer, buflen);\n\t\t\tup_read(&key->sem);\n\t\t}\n\t}\n\nerror2:\n\tkey_put(key);\nerror:\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static void udf_pc_to_char(struct super_block *sb, unsigned char *from,\n\t\t\t int fromlen, unsigned char *to)\n{\n\tstruct pathComponent *pc;\n\tint elen = 0;\n\tunsigned char *p = to;\n\n\twhile (elen < fromlen) {\n\t\tpc = (struct pathComponent *)(from + elen);\n\t\tswitch (pc->componentType) {\n\t\tcase 1:\n\t\t\t/*\n\t\t\t * Symlink points to some place which should be agreed\n \t\t\t * upon between originator and receiver of the media. Ignore.\n\t\t\t */\n\t\t\tif (pc->lengthComponentIdent > 0)\n\t\t\t\tbreak;\n\t\t\t/* Fall through */\n\t\tcase 2:\n\t\t\tp = to;\n\t\t\t*p++ = '/';\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmemcpy(p, \"../\", 3);\n\t\t\tp += 3;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tmemcpy(p, \"./\", 2);\n\t\t\tp += 2;\n\t\t\t/* that would be . - just ignore */\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tp += udf_get_filename(sb, pc->componentIdent, p,\n\t\t\t\t\t pc->lengthComponentIdent);\n\t\t\t*p++ = '/';\n\t\t\tbreak;\n\t\t}\n\t\telen += sizeof(struct pathComponent) + pc->lengthComponentIdent;\n\t}\n\tif (p > to + 1)\n\t\tp[-1] = '\\0';\n\telse\n\t\tp[0] = '\\0';\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-17", "cwe_name": "DEPRECATED: Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/17.html", "label_name": "vulnerable"} {"code": "void release_dentry_name_snapshot(struct name_snapshot *name)\n{\n\tif (unlikely(name->name != name->inline_name)) {\n\t\tstruct external_name *p;\n\t\tp = container_of(name->name, struct external_name, name[0]);\n\t\tif (unlikely(atomic_dec_and_test(&p->u.count)))\n\t\t\tkfree_rcu(p, u.head);\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static int cac_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* serial)\n{\n\tcac_private_data_t * priv = CAC_DATA(card);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);\n if (card->serialnr.len) {\n *serial = card->serialnr;\n SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n }\n\tif (priv->cac_id_len) {\n\t\tserial->len = MIN(priv->cac_id_len, SC_MAX_SERIALNR);\n\t\tmemcpy(serial->value, priv->cac_id, priv->cac_id_len);\n\t\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n\t}\n\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "cJSON *cJSON_CreateNumber(double num)\t\t\t{cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int64_t)num;}return item;}", "label": 1, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "void luaD_shrinkstack (lua_State *L) {\n int inuse = stackinuse(L);\n int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;\n if (goodsize > LUAI_MAXSTACK)\n goodsize = LUAI_MAXSTACK; /* respect stack limit */\n /* if thread is currently not handling a stack overflow and its\n good size is smaller than current size, shrink its stack */\n if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&\n goodsize < L->stacksize)\n luaD_reallocstack(L, goodsize, 0); /* ok if that fails */\n else /* don't change stack */\n condmovestack(L,{},{}); /* (change only for debugging) */\n luaE_shrinkCI(L); /* shrink CI list */\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)\n{\n\tstruct sockaddr_rc *sa = (struct sockaddr_rc *) addr;\n\tstruct sock *sk = sock->sk;\n\tint chan = sa->rc_channel;\n\tint err = 0;\n\n\tBT_DBG(\"sk %p %pMR\", sk, &sa->rc_bdaddr);\n\n\tif (!addr || addr->sa_family != AF_BLUETOOTH)\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state != BT_OPEN) {\n\t\terr = -EBADFD;\n\t\tgoto done;\n\t}\n\n\tif (sk->sk_type != SOCK_STREAM) {\n\t\terr = -EINVAL;\n\t\tgoto done;\n\t}\n\n\twrite_lock(&rfcomm_sk_list.lock);\n\n\tif (chan && __rfcomm_get_listen_sock_by_addr(chan, &sa->rc_bdaddr)) {\n\t\terr = -EADDRINUSE;\n\t} else {\n\t\t/* Save source address */\n\t\tbacpy(&rfcomm_pi(sk)->src, &sa->rc_bdaddr);\n\t\trfcomm_pi(sk)->channel = chan;\n\t\tsk->sk_state = BT_BOUND;\n\t}\n\n\twrite_unlock(&rfcomm_sk_list.lock);\n\ndone:\n\trelease_sock(sk);\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "ieee802_15_4_if_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, const u_char *p)\n{\n\tu_int caplen = h->caplen;\n\tint hdrlen;\n\tuint16_t fc;\n\tuint8_t seq;\n\n\tif (caplen < 3) {\n\t\tND_PRINT((ndo, \"[|802.15.4] %x\", caplen));\n\t\treturn caplen;\n\t}\n\n\tfc = EXTRACT_LE_16BITS(p);\n\thdrlen = extract_header_length(fc);\n\n\tseq = EXTRACT_LE_8BITS(p + 2);\n\n\tp += 3;\n\tcaplen -= 3;\n\n\tND_PRINT((ndo,\"IEEE 802.15.4 %s packet \", ftypes[fc & 0x7]));\n\tif (ndo->ndo_vflag)\n\t\tND_PRINT((ndo,\"seq %02x \", seq));\n\tif (hdrlen == -1) {\n\t\tND_PRINT((ndo,\"invalid! \"));\n\t\treturn caplen;\n\t}\n\n\n\tif (!ndo->ndo_vflag) {\n\t\tp+= hdrlen;\n\t\tcaplen -= hdrlen;\n\t} else {\n\t\tuint16_t panid = 0;\n\n\t\tswitch ((fc >> 10) & 0x3) {\n\t\tcase 0x00:\n\t\t\tND_PRINT((ndo,\"none \"));\n\t\t\tbreak;\n\t\tcase 0x01:\n\t\t\tND_PRINT((ndo,\"reserved destination addressing mode\"));\n\t\t\treturn 0;\n\t\tcase 0x02:\n\t\t\tpanid = EXTRACT_LE_16BITS(p);\n\t\t\tp += 2;\n\t\t\tND_PRINT((ndo,\"%04x:%04x \", panid, EXTRACT_LE_16BITS(p)));\n\t\t\tp += 2;\n\t\t\tbreak;\n\t\tcase 0x03:\n\t\t\tpanid = EXTRACT_LE_16BITS(p);\n\t\t\tp += 2;\n\t\t\tND_PRINT((ndo,\"%04x:%s \", panid, le64addr_string(ndo, p)));\n\t\t\tp += 8;\n\t\t\tbreak;\n\t\t}\n\t\tND_PRINT((ndo,\"< \"));\n\n\t\tswitch ((fc >> 14) & 0x3) {\n\t\tcase 0x00:\n\t\t\tND_PRINT((ndo,\"none \"));\n\t\t\tbreak;\n\t\tcase 0x01:\n\t\t\tND_PRINT((ndo,\"reserved source addressing mode\"));\n\t\t\treturn 0;\n\t\tcase 0x02:\n\t\t\tif (!(fc & (1 << 6))) {\n\t\t\t\tpanid = EXTRACT_LE_16BITS(p);\n\t\t\t\tp += 2;\n\t\t\t}\n\t\t\tND_PRINT((ndo,\"%04x:%04x \", panid, EXTRACT_LE_16BITS(p)));\n\t\t\tp += 2;\n\t\t\tbreak;\n\t\tcase 0x03:\n\t\t\tif (!(fc & (1 << 6))) {\n\t\t\t\tpanid = EXTRACT_LE_16BITS(p);\n\t\t\t\tp += 2;\n\t\t\t}\n ND_PRINT((ndo,\"%04x:%s \", panid, le64addr_string(ndo, p)));\n\t\t\tp += 8;\n\t\t\tbreak;\n\t\t}\n\n\t\tcaplen -= hdrlen;\n\t}\n\n\tif (!ndo->ndo_suppress_default_print)\n\t\tND_DEFAULTPRINT(p, caplen);\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "PUBLIC void httpDetailTraceFormatter(HttpTrace *trace, HttpConn *conn, cchar *event, cchar *type, cchar *values, \n cchar *data, ssize len)\n{\n MprBuf *buf;\n MprTime now;\n char *cp;\n int client, sessionSeqno, gotColon;\n\n assert(trace);\n assert(event);\n assert(type);\n\n lock(trace);\n if (!trace->buf) {\n trace->buf = mprCreateBuf(0, 0);\n }\n buf = trace->buf;\n mprFlushBuf(buf);\n\n if (conn) {\n now = mprGetTime();\n if (trace->lastMark < (now + TPS) || trace->lastTime == 0) {\n trace->lastTime = mprGetDate(\"%T\");\n trace->lastMark = now;\n }\n client = conn->address ? conn->address->seqno : 0;\n sessionSeqno = conn->rx->session ? (int) stoi(conn->rx->session->id) : 0;\n mprPutToBuf(buf, \"\\n%s %d-%d-%d-%d %s\", trace->lastTime, client, sessionSeqno, conn->seqno, conn->rx->seqno, event);\n } else {\n mprPutToBuf(buf, \"\\n%s: %s\", trace->lastTime, event);\n }\n if (values) {\n mprPutCharToBuf(buf, ' ');\n gotColon = 0;\n for (cp = (char*) values; *cp; cp++) {\n if (cp[0] == ':' && !gotColon) {\n cp[0] = '=';\n gotColon = 1;\n } else if (cp[0] == ',') {\n cp[0] = ' ';\n gotColon = 0;\n }\n }\n mprPutStringToBuf(buf, values);\n mprPutCharToBuf(buf, '\\n');\n }\n if (data) {\n mprPutToBuf(buf, \"\\n----\\n\");\n data = httpMakePrintable(trace, conn, event, data, &len);\n mprPutBlockToBuf(buf, data, len);\n if (len > 0 && data[len - 1] != '\\n') {\n mprPutCharToBuf(buf, '\\n');\n }\n mprPutToBuf(buf, \"----\\n\");\n }\n if (!values && !data) {\n mprPutCharToBuf(buf, '\\n');\n }\n httpWriteTrace(trace, mprGetBufStart(buf), mprGetBufLength(buf));\n unlock(trace);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "int regset_tls_set(struct task_struct *target, const struct user_regset *regset,\n\t\t unsigned int pos, unsigned int count,\n\t\t const void *kbuf, const void __user *ubuf)\n{\n\tstruct user_desc infobuf[GDT_ENTRY_TLS_ENTRIES];\n\tconst struct user_desc *info;\n\tint i;\n\n\tif (pos >= GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||\n\t (pos % sizeof(struct user_desc)) != 0 ||\n\t (count % sizeof(struct user_desc)) != 0)\n\t\treturn -EINVAL;\n\n\tif (kbuf)\n\t\tinfo = kbuf;\n\telse if (__copy_from_user(infobuf, ubuf, count))\n\t\treturn -EFAULT;\n\telse\n\t\tinfo = infobuf;\n\n\tfor (i = 0; i < count / sizeof(struct user_desc); i++)\n\t\tif (!tls_desc_okay(info + i))\n\t\t\treturn -EINVAL;\n\n\tset_tls_desc(target,\n\t\t GDT_ENTRY_TLS_MIN + (pos / sizeof(struct user_desc)),\n\t\t info, count / sizeof(struct user_desc));\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "int cg_write(const char *path, const char *buf, size_t size, off_t offset,\n\t struct fuse_file_info *fi)\n{\n\tstruct fuse_context *fc = fuse_get_context();\n\tchar *localbuf = NULL;\n\tstruct cgfs_files *k = NULL;\n\tstruct file_info *f = (struct file_info *)fi->fh;\n\tbool r;\n\n\tif (f->type != LXC_TYPE_CGFILE) {\n\t\tfprintf(stderr, \"Internal error: directory cache info used in cg_write\\n\");\n\t\treturn -EIO;\n\t}\n\n\tif (offset)\n\t\treturn 0;\n\n\tif (!fc)\n\t\treturn -EIO;\n\n\tlocalbuf = alloca(size+1);\n\tlocalbuf[size] = '\\0';\n\tmemcpy(localbuf, buf, size);\n\n\tif ((k = cgfs_get_key(f->controller, f->cgroup, f->file)) == NULL) {\n\t\tsize = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tif (!fc_may_access(fc, f->controller, f->cgroup, f->file, O_WRONLY)) {\n\t\tsize = -EACCES;\n\t\tgoto out;\n\t}\n\n\tif (strcmp(f->file, \"tasks\") == 0 ||\n\t\t\tstrcmp(f->file, \"/tasks\") == 0 ||\n\t\t\tstrcmp(f->file, \"/cgroup.procs\") == 0 ||\n\t\t\tstrcmp(f->file, \"cgroup.procs\") == 0)\n\t\t// special case - we have to translate the pids\n\t\tr = do_write_pids(fc->pid, fc->uid, f->controller, f->cgroup, f->file, localbuf);\n\telse\n\t\tr = cgfs_set_value(f->controller, f->cgroup, f->file, localbuf);\n\n\tif (!r)\n\t\tsize = -EINVAL;\n\nout:\n\tfree_key(k);\n\treturn size;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static char* get_private_subtags(const char* loc_name)\n{\n\tchar* \tresult =NULL;\n\tint \tsingletonPos = 0;\n\tint \tlen =0; \n\tconst char* \tmod_loc_name =NULL;\n\n\tif( loc_name && (len = strlen(loc_name)>0 ) ){\n\t\tmod_loc_name = loc_name ; \n\t\tlen = strlen(mod_loc_name);\n\t\twhile( (singletonPos = getSingletonPos(mod_loc_name))!= -1){\n\n\t\t\tif( singletonPos!=-1){ \n\t\t\t\tif( (*(mod_loc_name+singletonPos)=='x') || (*(mod_loc_name+singletonPos)=='X') ){\t\t\n\t\t\t\t\t/* private subtag start found */\n\t\t\t\t\tif( singletonPos + 2 == len){\n\t\t\t\t\t\t/* loc_name ends with '-x-' ; return NULL */\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t/* result = mod_loc_name + singletonPos +2; */\n\t\t\t\t\t\tresult = estrndup(mod_loc_name + singletonPos+2 , (len -( singletonPos +2) ) );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif( singletonPos + 1 >= len){\n\t\t\t\t\t\t/* String end */\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/* singleton found but not a private subtag , hence check further in the string for the private subtag */\n\t\t\t\t\t\tmod_loc_name = mod_loc_name + singletonPos +1;\n\t\t\t\t\t\tlen = strlen(mod_loc_name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t} /* end of while */\n\t}\n\t\n\treturn result;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static void opt_kfree_rcu(struct rcu_head *head)\n{\n\tkfree(container_of(head, struct ip_options_rcu, rcu));\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static void nsc_rle_decompress_data(NSC_CONTEXT* context)\n{\n\tUINT16 i;\n\tBYTE* rle;\n\tUINT32 planeSize;\n\tUINT32 originalSize;\n\trle = context->Planes;\n\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\toriginalSize = context->OrgByteCount[i];\n\t\tplaneSize = context->PlaneByteCount[i];\n\n\t\tif (planeSize == 0)\n\t\t\tFillMemory(context->priv->PlaneBuffers[i], originalSize, 0xFF);\n\t\telse if (planeSize < originalSize)\n\t\t\tnsc_rle_decode(rle, context->priv->PlaneBuffers[i], originalSize);\n\t\telse\n\t\t\tCopyMemory(context->priv->PlaneBuffers[i], rle, originalSize);\n\n\t\trle += planeSize;\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static int sdp_parse_fmtp_config_h264(AVFormatContext *s,\n AVStream *stream,\n PayloadContext *h264_data,\n const char *attr, const char *value)\n{\n AVCodecParameters *par = stream->codecpar;\n\n if (!strcmp(attr, \"packetization-mode\")) {\n av_log(s, AV_LOG_DEBUG, \"RTP Packetization Mode: %d\\n\", atoi(value));\n h264_data->packetization_mode = atoi(value);\n /*\n * Packetization Mode:\n * 0 or not present: Single NAL mode (Only nals from 1-23 are allowed)\n * 1: Non-interleaved Mode: 1-23, 24 (STAP-A), 28 (FU-A) are allowed.\n * 2: Interleaved Mode: 25 (STAP-B), 26 (MTAP16), 27 (MTAP24), 28 (FU-A),\n * and 29 (FU-B) are allowed.\n */\n if (h264_data->packetization_mode > 1)\n av_log(s, AV_LOG_ERROR,\n \"Interleaved RTP mode is not supported yet.\\n\");\n } else if (!strcmp(attr, \"profile-level-id\")) {\n if (strlen(value) == 6)\n parse_profile_level_id(s, h264_data, value);\n } else if (!strcmp(attr, \"sprop-parameter-sets\")) {\n int ret;\n if (*value == 0 || value[strlen(value) - 1] == ',') {\n av_log(s, AV_LOG_WARNING, \"Missing PPS in sprop-parameter-sets, ignoring\\n\");\n return 0;\n }\n par->extradata_size = 0;\n av_freep(&par->extradata);\n ret = ff_h264_parse_sprop_parameter_sets(s, &par->extradata,\n &par->extradata_size, value);\n av_log(s, AV_LOG_DEBUG, \"Extradata set to %p (size: %d)\\n\",\n par->extradata, par->extradata_size);\n return ret;\n }\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "error_t enc28j60SendPacket(NetInterface *interface,\n const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)\n{\n size_t length;\n\n //Retrieve the length of the packet\n length = netBufferGetLength(buffer) - offset;\n\n //Check the frame length\n if(length > 1536)\n {\n //The transmitter can accept another packet\n osSetEvent(&interface->nicTxEvent);\n //Report an error\n return ERROR_INVALID_LENGTH;\n }\n\n //Make sure the link is up before transmitting the frame\n if(!interface->linkState)\n {\n //The transmitter can accept another packet\n osSetEvent(&interface->nicTxEvent);\n //Drop current packet\n return NO_ERROR;\n }\n\n //It is recommended to reset the transmit logic before\n //attempting to transmit a packet\n enc28j60SetBit(interface, ENC28J60_REG_ECON1, ECON1_TXRST);\n enc28j60ClearBit(interface, ENC28J60_REG_ECON1, ECON1_TXRST);\n\n //Interrupt flags should be cleared after the reset is completed\n enc28j60ClearBit(interface, ENC28J60_REG_EIR, EIR_TXIF | EIR_TXERIF);\n\n //Set transmit buffer location\n enc28j60WriteReg(interface, ENC28J60_REG_ETXSTL, LSB(ENC28J60_TX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_REG_ETXSTH, MSB(ENC28J60_TX_BUFFER_START));\n\n //Point to start of transmit buffer\n enc28j60WriteReg(interface, ENC28J60_REG_EWRPTL, LSB(ENC28J60_TX_BUFFER_START));\n enc28j60WriteReg(interface, ENC28J60_REG_EWRPTH, MSB(ENC28J60_TX_BUFFER_START));\n\n //Copy the data to the transmit buffer\n enc28j60WriteBuffer(interface, buffer, offset);\n\n //ETXND should point to the last byte in the data payload\n enc28j60WriteReg(interface, ENC28J60_REG_ETXNDL, LSB(ENC28J60_TX_BUFFER_START + length));\n enc28j60WriteReg(interface, ENC28J60_REG_ETXNDH, MSB(ENC28J60_TX_BUFFER_START + length));\n\n //Start transmission\n enc28j60SetBit(interface, ENC28J60_REG_ECON1, ECON1_TXRTS);\n\n //Successful processing\n return NO_ERROR;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "mrb_realloc(mrb_state *mrb, void *p, size_t len)\n{\n void *p2;\n\n p2 = mrb_realloc_simple(mrb, p, len);\n if (len == 0) return p2;\n if (p2 == NULL) {\n mrb_free(mrb, p);\n mrb->gc.out_of_memory = TRUE;\n mrb_raise_nomemory(mrb);\n }\n else {\n mrb->gc.out_of_memory = FALSE;\n }\n\n return p2;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "error_t ksz8851UpdateMacAddrFilter(NetInterface *interface)\n{\n uint_t i;\n uint_t k;\n uint32_t crc;\n uint16_t hashTable[4];\n MacFilterEntry *entry;\n\n //Debug message\n TRACE_DEBUG(\"Updating MAC filter...\\r\\n\");\n\n //Clear hash table\n osMemset(hashTable, 0, sizeof(hashTable));\n\n //The MAC address filter contains the list of MAC addresses to accept\n //when receiving an Ethernet frame\n for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)\n {\n //Point to the current entry\n entry = &interface->macAddrFilter[i];\n\n //Valid entry?\n if(entry->refCount > 0)\n {\n //Compute CRC over the current MAC address\n crc = ksz8851CalcCrc(&entry->addr, sizeof(MacAddr));\n //Calculate the corresponding index in the table\n k = (crc >> 26) & 0x3F;\n //Update hash table contents\n hashTable[k / 16] |= (1 << (k % 16));\n }\n }\n\n //Write the hash table to the KSZ8851 controller\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR0, hashTable[0]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR1, hashTable[1]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR2, hashTable[2]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR3, hashTable[3]);\n\n //Debug message\n TRACE_DEBUG(\" MAHTR0 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR0));\n TRACE_DEBUG(\" MAHTR1 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR1));\n TRACE_DEBUG(\" MAHTR2 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR2));\n TRACE_DEBUG(\" MAHTR3 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR3));\n\n //Successful processing\n return NO_ERROR;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int perf_swevent_add(struct perf_event *event, int flags)\n{\n\tstruct swevent_htable *swhash = this_cpu_ptr(&swevent_htable);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct hlist_head *head;\n\n\tif (is_sampling_event(event)) {\n\t\thwc->last_period = hwc->sample_period;\n\t\tperf_swevent_set_period(event);\n\t}\n\n\thwc->state = !(flags & PERF_EF_START);\n\n\thead = find_swevent_head(swhash, event);\n\tif (WARN_ON_ONCE(!head))\n\t\treturn -EINVAL;\n\n\thlist_add_head_rcu(&event->hlist_entry, head);\n\tperf_event_update_userpage(event);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static int rds_ib_laddr_check(__be32 addr)\n{\n\tint ret;\n\tstruct rdma_cm_id *cm_id;\n\tstruct sockaddr_in sin;\n\n\t/* Create a CMA ID and try to bind it. This catches both\n\t * IB and iWARP capable NICs.\n\t */\n\tcm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP, IB_QPT_RC);\n\tif (IS_ERR(cm_id))\n\t\treturn PTR_ERR(cm_id);\n\n\tmemset(&sin, 0, sizeof(sin));\n\tsin.sin_family = AF_INET;\n\tsin.sin_addr.s_addr = addr;\n\n\t/* rdma_bind_addr will only succeed for IB & iWARP devices */\n\tret = rdma_bind_addr(cm_id, (struct sockaddr *)&sin);\n\t/* due to this, we will claim to support iWARP devices unless we\n\t check node_type. */\n\tif (ret || !cm_id->device ||\n\t cm_id->device->node_type != RDMA_NODE_IB_CA)\n\t\tret = -EADDRNOTAVAIL;\n\n\trdsdebug(\"addr %pI4 ret %d node type %d\\n\",\n\t\t&addr, ret,\n\t\tcm_id->device ? cm_id->device->node_type : -1);\n\n\trdma_destroy_id(cm_id);\n\n\treturn ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static inline void sctp_copy_descendant(struct sock *sk_to,\n\t\t\t\t\tconst struct sock *sk_from)\n{\n\tint ancestor_size = sizeof(struct inet_sock) +\n\t\t\t sizeof(struct sctp_sock) -\n\t\t\t offsetof(struct sctp_sock, auto_asconf_list);\n\n\tif (sk_from->sk_family == PF_INET6)\n\t\tancestor_size += sizeof(struct ipv6_pinfo);\n\n\t__inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,\n\t\t\tunsigned long end, int write,\n\t\t\tstruct page **pages, int *nr)\n{\n\tint refs;\n\tstruct page *head, *page;\n\n\tif (!pgd_access_permitted(orig, write))\n\t\treturn 0;\n\n\tBUILD_BUG_ON(pgd_devmap(orig));\n\trefs = 0;\n\tpage = pgd_page(orig) + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT);\n\tdo {\n\t\tpages[*nr] = page;\n\t\t(*nr)++;\n\t\tpage++;\n\t\trefs++;\n\t} while (addr += PAGE_SIZE, addr != end);\n\n\thead = compound_head(pgd_page(orig));\n\tif (!page_cache_add_speculative(head, refs)) {\n\t\t*nr -= refs;\n\t\treturn 0;\n\t}\n\n\tif (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {\n\t\t*nr -= refs;\n\t\twhile (refs--)\n\t\t\tput_page(head);\n\t\treturn 0;\n\t}\n\n\tSetPageReferenced(head);\n\treturn 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int _nfs4_do_open(struct inode *dir, struct path *path, int flags, struct iattr *sattr, struct rpc_cred *cred, struct nfs4_state **res)\n{\n\tstruct nfs4_state_owner *sp;\n\tstruct nfs4_state *state = NULL;\n\tstruct nfs_server *server = NFS_SERVER(dir);\n\tstruct nfs4_opendata *opendata;\n\tint status;\n\n\t/* Protect against reboot recovery conflicts */\n\tstatus = -ENOMEM;\n\tif (!(sp = nfs4_get_state_owner(server, cred))) {\n\t\tdprintk(\"nfs4_do_open: nfs4_get_state_owner failed!\\n\");\n\t\tgoto out_err;\n\t}\n\tstatus = nfs4_recover_expired_lease(server);\n\tif (status != 0)\n\t\tgoto err_put_state_owner;\n\tif (path->dentry->d_inode != NULL)\n\t\tnfs4_return_incompatible_delegation(path->dentry->d_inode, flags & (FMODE_READ|FMODE_WRITE));\n\tstatus = -ENOMEM;\n\topendata = nfs4_opendata_alloc(path, sp, flags, sattr);\n\tif (opendata == NULL)\n\t\tgoto err_put_state_owner;\n\n\tif (path->dentry->d_inode != NULL)\n\t\topendata->state = nfs4_get_open_state(path->dentry->d_inode, sp);\n\n\tstatus = _nfs4_proc_open(opendata);\n\tif (status != 0)\n\t\tgoto err_opendata_put;\n\n\tif (opendata->o_arg.open_flags & O_EXCL)\n\t\tnfs4_exclusive_attrset(opendata, sattr);\n\n\tstate = nfs4_opendata_to_nfs4_state(opendata);\n\tstatus = PTR_ERR(state);\n\tif (IS_ERR(state))\n\t\tgoto err_opendata_put;\n\tnfs4_opendata_put(opendata);\n\tnfs4_put_state_owner(sp);\n\t*res = state;\n\treturn 0;\nerr_opendata_put:\n\tnfs4_opendata_put(opendata);\nerr_put_state_owner:\n\tnfs4_put_state_owner(sp);\nout_err:\n\t*res = NULL;\n\treturn status;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tstruct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;\n\tstruct sk_buff *skb;\n\n\tif (flags & MSG_OOB)\n\t\tgoto out;\n\n\tif (addr_len)\n\t\t*addr_len = sizeof(*sin);\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = ip_recv_error(sk, msg, len);\n\t\tgoto out;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tsin->sin_port = 0;\n\t\tmemset(&sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\tif (err)\n\t\treturn err;\n\treturn copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static void scsi_write_complete(void * opaque, int ret)\n{\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n uint32_t n;\n\n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->bs, &r->acct);\n }\n\n if (ret) {\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_WRITE)) {\n return;\n }\n }\n\n n = r->qiov.size / 512;\n r->sector += n;\n r->sector_count -= n;\n if (r->sector_count == 0) {\n scsi_req_complete(&r->req, GOOD);\n } else {\n scsi_init_iovec(r);\n DPRINTF(\"Write complete tag=0x%x more=%d\\n\", r->req.tag, r->qiov.size);\n scsi_req_data(&r->req, r->qiov.size);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int netbk_set_skb_gso(struct xenvif *vif,\n\t\t\t struct sk_buff *skb,\n\t\t\t struct xen_netif_extra_info *gso)\n{\n\tif (!gso->u.gso.size) {\n\t\tnetdev_dbg(vif->dev, \"GSO size must not be zero.\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t/* Currently only TCPv4 S.O. is supported. */\n\tif (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) {\n\t\tnetdev_dbg(vif->dev, \"Bad GSO type %d.\\n\", gso->u.gso.type);\n\t\treturn -EINVAL;\n\t}\n\n\tskb_shinfo(skb)->gso_size = gso->u.gso.size;\n\tskb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;\n\n\t/* Header must be checked, and gso_segs computed. */\n\tskb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;\n\tskb_shinfo(skb)->gso_segs = 0;\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len)\n{\n rfbClientPtr cl;\n rfbServerCutTextMsg sct;\n rfbClientIteratorPtr iterator;\n\n memset((char *)&sct, 0, sizeof(sct));\n\n iterator = rfbGetClientIterator(rfbScreen);\n while ((cl = rfbClientIteratorNext(iterator)) != NULL) {\n sct.type = rfbServerCutText;\n sct.length = Swap32IfLE(len);\n LOCK(cl->sendMutex);\n if (rfbWriteExact(cl, (char *)&sct,\n sz_rfbServerCutTextMsg) < 0) {\n rfbLogPerror(\"rfbSendServerCutText: write\");\n rfbCloseClient(cl);\n UNLOCK(cl->sendMutex);\n continue;\n }\n if (rfbWriteExact(cl, str, len) < 0) {\n rfbLogPerror(\"rfbSendServerCutText: write\");\n rfbCloseClient(cl);\n }\n UNLOCK(cl->sendMutex);\n rfbStatRecordMessageSent(cl, rfbServerCutText, sz_rfbServerCutTextMsg+len, sz_rfbServerCutTextMsg+len);\n }\n rfbReleaseClientIterator(iterator);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-665", "cwe_name": "Improper Initialization", "description": "The software does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.", "url": "https://cwe.mitre.org/data/definitions/665.html", "label_name": "safe"} {"code": "static int crypto_report_one(struct crypto_alg *alg,\n\t\t\t struct crypto_user_alg *ualg, struct sk_buff *skb)\n{\n\tstrncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));\n\tstrncpy(ualg->cru_driver_name, alg->cra_driver_name,\n\t\tsizeof(ualg->cru_driver_name));\n\tstrncpy(ualg->cru_module_name, module_name(alg->cra_module),\n\t\tsizeof(ualg->cru_module_name));\n\n\tualg->cru_type = 0;\n\tualg->cru_mask = 0;\n\tualg->cru_flags = alg->cra_flags;\n\tualg->cru_refcnt = atomic_read(&alg->cra_refcnt);\n\n\tif (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority))\n\t\tgoto nla_put_failure;\n\tif (alg->cra_flags & CRYPTO_ALG_LARVAL) {\n\t\tstruct crypto_report_larval rl;\n\n\t\tstrncpy(rl.type, \"larval\", sizeof(rl.type));\n\t\tif (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL,\n\t\t\t sizeof(struct crypto_report_larval), &rl))\n\t\t\tgoto nla_put_failure;\n\t\tgoto out;\n\t}\n\n\tif (alg->cra_type && alg->cra_type->report) {\n\t\tif (alg->cra_type->report(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tgoto out;\n\t}\n\n\tswitch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {\n\tcase CRYPTO_ALG_TYPE_CIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_COMPRESS:\n\t\tif (crypto_report_comp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\n\t\tbreak;\n\t}\n\nout:\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct irda_sock *self = irda_sk(sk);\n\tstruct sk_buff *skb;\n\tsize_t copied;\n\tint err;\n\n\tIRDA_DEBUG(4, \"%s()\\n\", __func__);\n\n\tmsg->msg_namelen = 0;\n\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\tflags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\treturn err;\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tIRDA_DEBUG(2, \"%s(), Received truncated frame (%zd < %zd)!\\n\",\n\t\t\t __func__, copied, size);\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\tskb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\n\tskb_free_datagram(sk, skb);\n\n\t/*\n\t * Check if we have previously stopped IrTTP and we know\n\t * have more free space in our rx_queue. If so tell IrTTP\n\t * to start delivering frames again before our rx_queue gets\n\t * empty\n\t */\n\tif (self->rx_flow == FLOW_STOP) {\n\t\tif ((atomic_read(&sk->sk_rmem_alloc) << 2) <= sk->sk_rcvbuf) {\n\t\t\tIRDA_DEBUG(2, \"%s(), Starting IrTTP\\n\", __func__);\n\t\t\tself->rx_flow = FLOW_START;\n\t\t\tirttp_flow_request(self->tsap, FLOW_START);\n\t\t}\n\t}\n\n\treturn copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) {\n int __pyx_r;\n __Pyx_RefNannyDeclarations\n Py_ssize_t __pyx_t_1;\n __Pyx_RefNannySetupContext(\"__set__\", 0);\n __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)\n __pyx_v_self->current_buffer_size = __pyx_t_1;\n\n /* function exit code */\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1_error:;\n __Pyx_AddTraceback(\"clickhouse_driver.bufferedreader.BufferedReader.current_buffer_size.__set__\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n __pyx_r = -1;\n __pyx_L0:;\n __Pyx_RefNannyFinishContext();\n return __pyx_r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "mrb_io_initialize_copy(mrb_state *mrb, mrb_value copy)\n{\n mrb_value orig;\n mrb_value buf;\n struct mrb_io *fptr_copy;\n struct mrb_io *fptr_orig;\n mrb_bool failed = TRUE;\n\n mrb_get_args(mrb, \"o\", &orig);\n fptr_copy = (struct mrb_io *)DATA_PTR(copy);\n if (fptr_copy != NULL) {\n fptr_finalize(mrb, fptr_copy, FALSE);\n mrb_free(mrb, fptr_copy);\n }\n fptr_copy = (struct mrb_io *)mrb_io_alloc(mrb);\n fptr_orig = io_get_open_fptr(mrb, orig);\n\n DATA_TYPE(copy) = &mrb_io_type;\n DATA_PTR(copy) = fptr_copy;\n\n buf = mrb_iv_get(mrb, orig, mrb_intern_cstr(mrb, \"@buf\"));\n mrb_iv_set(mrb, copy, mrb_intern_cstr(mrb, \"@buf\"), buf);\n\n fptr_copy->fd = mrb_dup(mrb, fptr_orig->fd, &failed);\n if (failed) {\n mrb_sys_fail(mrb, 0);\n }\n mrb_fd_cloexec(mrb, fptr_copy->fd);\n\n if (fptr_orig->fd2 != -1) {\n fptr_copy->fd2 = mrb_dup(mrb, fptr_orig->fd2, &failed);\n if (failed) {\n close(fptr_copy->fd);\n mrb_sys_fail(mrb, 0);\n }\n mrb_fd_cloexec(mrb, fptr_copy->fd2);\n }\n\n fptr_copy->pid = fptr_orig->pid;\n fptr_copy->readable = fptr_orig->readable;\n fptr_copy->writable = fptr_orig->writable;\n fptr_copy->sync = fptr_orig->sync;\n fptr_copy->is_socket = fptr_orig->is_socket;\n\n return copy;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "static int usb_enumerate_device_otg(struct usb_device *udev)\n{\n\tint err = 0;\n\n#ifdef\tCONFIG_USB_OTG\n\t/*\n\t * OTG-aware devices on OTG-capable root hubs may be able to use SRP,\n\t * to wake us after we've powered off VBUS; and HNP, switching roles\n\t * \"host\" to \"peripheral\". The OTG descriptor helps figure this out.\n\t */\n\tif (!udev->bus->is_b_host\n\t\t\t&& udev->config\n\t\t\t&& udev->parent == udev->bus->root_hub) {\n\t\tstruct usb_otg_descriptor\t*desc = NULL;\n\t\tstruct usb_bus\t\t\t*bus = udev->bus;\n\t\tunsigned\t\t\tport1 = udev->portnum;\n\n\t\t/* descriptor may appear anywhere in config */\n\t\terr = __usb_get_extra_descriptor(udev->rawdescriptors[0],\n\t\t\t\tle16_to_cpu(udev->config[0].desc.wTotalLength),\n\t\t\t\tUSB_DT_OTG, (void **) &desc);\n\t\tif (err || !(desc->bmAttributes & USB_OTG_HNP))\n\t\t\treturn 0;\n\n\t\tdev_info(&udev->dev, \"Dual-Role OTG device on %sHNP port\\n\",\n\t\t\t\t\t(port1 == bus->otg_port) ? \"\" : \"non-\");\n\n\t\t/* enable HNP before suspend, it's simpler */\n\t\tif (port1 == bus->otg_port) {\n\t\t\tbus->b_hnp_enable = 1;\n\t\t\terr = usb_control_msg(udev,\n\t\t\t\tusb_sndctrlpipe(udev, 0),\n\t\t\t\tUSB_REQ_SET_FEATURE, 0,\n\t\t\t\tUSB_DEVICE_B_HNP_ENABLE,\n\t\t\t\t0, NULL, 0,\n\t\t\t\tUSB_CTRL_SET_TIMEOUT);\n\t\t\tif (err < 0) {\n\t\t\t\t/*\n\t\t\t\t * OTG MESSAGE: report errors here,\n\t\t\t\t * customize to match your product.\n\t\t\t\t */\n\t\t\t\tdev_err(&udev->dev, \"can't set HNP mode: %d\\n\",\n\t\t\t\t\t\t\t\t\terr);\n\t\t\t\tbus->b_hnp_enable = 0;\n\t\t\t}\n\t\t} else if (desc->bLength == sizeof\n\t\t\t\t(struct usb_otg_descriptor)) {\n\t\t\t/* Set a_alt_hnp_support for legacy otg device */\n\t\t\terr = usb_control_msg(udev,\n\t\t\t\tusb_sndctrlpipe(udev, 0),\n\t\t\t\tUSB_REQ_SET_FEATURE, 0,\n\t\t\t\tUSB_DEVICE_A_ALT_HNP_SUPPORT,\n\t\t\t\t0, NULL, 0,\n\t\t\t\tUSB_CTRL_SET_TIMEOUT);\n\t\t\tif (err < 0)\n\t\t\t\tdev_err(&udev->dev,\n\t\t\t\t\t\"set a_alt_hnp_support failed: %d\\n\",\n\t\t\t\t\terr);\n\t\t}\n\t}\n#endif\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "sysDescr_handler(snmp_varbind_t *varbind, uint32_t *oid)\n{\n snmp_api_set_string(varbind, oid, CONTIKI_VERSION_STRING);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "BOOL rdp_decrypt(rdpRdp* rdp, STREAM* s, int length, UINT16 securityFlags)\n{\n\tBYTE cmac[8];\n\tBYTE wmac[8];\n\n\tif (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)\n\t{\n\t\tUINT16 len;\n\t\tBYTE version, pad;\n\t\tBYTE* sig;\n\n\t\tif (stream_get_left(s) < 12)\n\t\t\treturn FALSE;\n\n\t\tstream_read_UINT16(s, len); /* 0x10 */\n\t\tstream_read_BYTE(s, version); /* 0x1 */\n\t\tstream_read_BYTE(s, pad);\n\n\t\tsig = s->p;\n\t\tstream_seek(s, 8);\t/* signature */\n\n\t\tlength -= 12;\n\n\t\tif (!security_fips_decrypt(s->p, length, rdp))\n\t\t{\n\t\t\tprintf(\"FATAL: cannot decrypt\\n\");\n\t\t\treturn FALSE; /* TODO */\n\t\t}\n\n\t\tif (!security_fips_check_signature(s->p, length - pad, sig, rdp))\n\t\t{\n\t\t\tprintf(\"FATAL: invalid packet signature\\n\");\n\t\t\treturn FALSE; /* TODO */\n\t\t}\n\n\t\t/* is this what needs adjusting? */\n\t\ts->size -= pad;\n\t\treturn TRUE;\n\t}\n\n\tif (stream_get_left(s) < 8)\n\t\treturn FALSE;\n\n\tstream_read(s, wmac, sizeof(wmac));\n\tlength -= sizeof(wmac);\n\tsecurity_decrypt(s->p, length, rdp);\n\n\tif (securityFlags & SEC_SECURE_CHECKSUM)\n\t\tsecurity_salted_mac_signature(rdp, s->p, length, FALSE, cmac);\n\telse\n\t\tsecurity_mac_signature(rdp, s->p, length, cmac);\n\n\tif (memcmp(wmac, cmac, sizeof(wmac)) != 0)\n\t{\n\t\tprintf(\"WARNING: invalid packet signature\\n\");\n\t\t/*\n\t\t * Because Standard RDP Security is totally broken,\n\t\t * and cannot protect against MITM, don't treat signature\n\t\t * verification failure as critical. This at least enables\n\t\t * us to work with broken RDP clients and servers that\n\t\t * generate invalid signatures.\n\t\t */\n\t\t//return FALSE;\n\t}\n\n\treturn TRUE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "void hugetlb_put_quota(struct address_space *mapping, long delta)\n{\n\tstruct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(mapping->host->i_sb);\n\n\tif (sbinfo->free_blocks > -1) {\n\t\tspin_lock(&sbinfo->stat_lock);\n\t\tsbinfo->free_blocks += delta;\n\t\tspin_unlock(&sbinfo->stat_lock);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "static int rawsock_create(struct net *net, struct socket *sock,\n\t\t\t const struct nfc_protocol *nfc_proto, int kern)\n{\n\tstruct sock *sk;\n\n\tpr_debug(\"sock=%p\\n\", sock);\n\n\tif ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))\n\t\treturn -ESOCKTNOSUPPORT;\n\n\tif (sock->type == SOCK_RAW)\n\t\tsock->ops = &rawsock_raw_ops;\n\telse\n\t\tsock->ops = &rawsock_ops;\n\n\tsk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern);\n\tif (!sk)\n\t\treturn -ENOMEM;\n\n\tsock_init_data(sock, sk);\n\tsk->sk_protocol = nfc_proto->id;\n\tsk->sk_destruct = rawsock_destruct;\n\tsock->state = SS_UNCONNECTED;\n\tif (sock->type == SOCK_RAW)\n\t\tnfc_sock_link(&raw_sk_list, sk);\n\telse {\n\t\tINIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work);\n\t\tnfc_rawsock(sk)->tx_work_scheduled = false;\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "vulnerable"} {"code": "MemoryRegion *memory_map_ptr(struct uc_struct *uc, hwaddr begin, size_t size, uint32_t perms, void *ptr)\n{\n MemoryRegion *ram = g_new(MemoryRegion, 1);\n\n memory_region_init_ram_ptr(uc, ram, size, ptr);\n ram->perms = perms;\n if (ram->addr == -1) {\n // out of memory\n return NULL;\n }\n\n memory_region_add_subregion(uc->system_memory, begin, ram);\n\n if (uc->cpu) {\n tlb_flush(uc->cpu);\n }\n\n return ram;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static int parse_video_info(AVIOContext *pb, AVStream *st)\n{\n uint16_t size_asf; // ASF-specific Format Data size\n uint32_t size_bmp; // BMP_HEADER-specific Format Data size\n unsigned int tag;\n\n st->codecpar->width = avio_rl32(pb);\n st->codecpar->height = avio_rl32(pb);\n avio_skip(pb, 1); // skip reserved flags\n size_asf = avio_rl16(pb);\n tag = ff_get_bmp_header(pb, st, &size_bmp);\n st->codecpar->codec_tag = tag;\n st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);\n size_bmp = FFMAX(size_asf, size_bmp);\n\n if (size_bmp > BMP_HEADER_SIZE &&\n size_bmp < INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {\n int ret;\n st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE;\n if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +\n AV_INPUT_BUFFER_PADDING_SIZE))) {\n st->codecpar->extradata_size = 0;\n return AVERROR(ENOMEM);\n }\n memset(st->codecpar->extradata + st->codecpar->extradata_size , 0,\n AV_INPUT_BUFFER_PADDING_SIZE);\n if ((ret = avio_read(pb, st->codecpar->extradata,\n st->codecpar->extradata_size)) < 0)\n return ret;\n }\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "void acpi_ns_terminate(void)\n{\n\tacpi_status status;\n\n\tACPI_FUNCTION_TRACE(ns_terminate);\n\n#ifdef ACPI_EXEC_APP\n\t{\n\t\tunion acpi_operand_object *prev;\n\t\tunion acpi_operand_object *next;\n\n\t\t/* Delete any module-level code blocks */\n\n\t\tnext = acpi_gbl_module_code_list;\n\t\twhile (next) {\n\t\t\tprev = next;\n\t\t\tnext = next->method.mutex;\n\t\t\tprev->method.mutex = NULL;\t/* Clear the Mutex (cheated) field */\n\t\t\tacpi_ut_remove_reference(prev);\n\t\t}\n\t}\n#endif\n\n\t/*\n\t * Free the entire namespace -- all nodes and all objects\n\t * attached to the nodes\n\t */\n\tacpi_ns_delete_namespace_subtree(acpi_gbl_root_node);\n\n\t/* Delete any objects attached to the root node */\n\n\tstatus = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);\n\tif (ACPI_FAILURE(status)) {\n\t\treturn_VOID;\n\t}\n\n\tacpi_ns_delete_node(acpi_gbl_root_node);\n\t(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);\n\n\tACPI_DEBUG_PRINT((ACPI_DB_INFO, \"Namespace freed\\n\"));\n\treturn_VOID;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "static int decode_bit_string(const u8 * inbuf, size_t inlen, void *outbuf,\n\t\t\t size_t outlen, int invert)\n{\n\tconst u8 *in = inbuf;\n\tu8 *out = (u8 *) outbuf;\n\tint zero_bits = *in & 0x07;\n\tsize_t octets_left = inlen - 1;\n\tint i, count = 0;\n\n\tmemset(outbuf, 0, outlen);\n\tin++;\n\tif (outlen < octets_left)\n\t\treturn SC_ERROR_BUFFER_TOO_SMALL;\n\tif (inlen < 1)\n\t\treturn SC_ERROR_INVALID_ASN1_OBJECT;\n\twhile (octets_left) {\n\t\t/* 1st octet of input: ABCDEFGH, where A is the MSB */\n\t\t/* 1st octet of output: HGFEDCBA, where A is the LSB */\n\t\t/* first bit in bit string is the LSB in first resulting octet */\n\t\tint bits_to_go;\n\n\t\t*out = 0;\n\t\tif (octets_left == 1)\n\t\t\tbits_to_go = 8 - zero_bits;\n\t\telse\n\t\t\tbits_to_go = 8;\n\t\tif (invert)\n\t\t\tfor (i = 0; i < bits_to_go; i++) {\n\t\t\t\t*out |= ((*in >> (7 - i)) & 1) << i;\n\t\t\t}\n\t\telse {\n\t\t\t*out = *in;\n\t\t}\n\t\tout++;\n\t\tin++;\n\t\toctets_left--;\n\t\tcount++;\n\t}\n\treturn (count * 8) - zero_bits;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "ASC_destroyAssociation(T_ASC_Association ** association)\n{\n OFCondition cond = EC_Normal;\n\n /* don't worry if already destroyed */\n if (association == NULL) return EC_Normal;\n if (*association == NULL) return EC_Normal;\n\n if ((*association)->DULassociation != NULL) {\n ASC_dropAssociation(*association);\n }\n\n if ((*association)->params != NULL) {\n cond = ASC_destroyAssociationParameters(&(*association)->params);\n if (cond.bad()) return cond;\n }\n\n if ((*association)->sendPDVBuffer != NULL)\n free((*association)->sendPDVBuffer);\n\n free(*association);\n *association = NULL;\n\n return EC_Normal;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int perf_trace_event_perm(struct ftrace_event_call *tp_event,\n\t\t\t\t struct perf_event *p_event)\n{\n\t/* The ftrace function trace is allowed only for root. */\n\tif (ftrace_event_is_function(tp_event) &&\n\t perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\t/* No tracing, just counting, so no obvious leak */\n\tif (!(p_event->attr.sample_type & PERF_SAMPLE_RAW))\n\t\treturn 0;\n\n\t/* Some events are ok to be traced by non-root users... */\n\tif (p_event->attach_state == PERF_ATTACH_TASK) {\n\t\tif (tp_event->flags & TRACE_EVENT_FL_CAP_ANY)\n\t\t\treturn 0;\n\t}\n\n\t/*\n\t * ...otherwise raw tracepoint data can be a severe data leak,\n\t * only allow root to have these.\n\t */\n\tif (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "void TEMPLATE(process_block_dec)(decoder_info_t *decoder_info,int size,int yposY,int xposY,int sub)\n{\n int width = decoder_info->width;\n int height = decoder_info->height;\n stream_t *stream = decoder_info->stream;\n frame_type_t frame_type = decoder_info->frame_info.frame_type;\n int split_flag = 0;\n\n if (yposY >= height || xposY >= width)\n return;\n\n int decode_this_size = (yposY + size <= height) && (xposY + size <= width);\n int decode_rectangular_size = !decode_this_size && frame_type != I_FRAME;\n\n int bit_start = stream->bitcnt;\n\n int mode = MODE_SKIP;\n \n block_context_t block_context;\n TEMPLATE(find_block_contexts)(yposY, xposY, height, width, size, decoder_info->deblock_data, &block_context, decoder_info->use_block_contexts);\n decoder_info->block_context = &block_context;\n\n split_flag = decode_super_mode(decoder_info,size,decode_this_size);\n mode = decoder_info->mode;\n \n /* Read delta_qp and set block-level qp */\n if (size == (1<log2_sb_size) && (split_flag || mode != MODE_SKIP) && decoder_info->max_delta_qp > 0) {\n /* Read delta_qp */\n int delta_qp = read_delta_qp(stream);\n int prev_qp;\n if (yposY == 0 && xposY == 0)\n prev_qp = decoder_info->frame_info.qp;\n else\n prev_qp = decoder_info->frame_info.qpb;\n decoder_info->frame_info.qpb = prev_qp + delta_qp;\n }\n\n decoder_info->bit_count.super_mode[decoder_info->bit_count.stat_frame_type] += (stream->bitcnt - bit_start);\n\n if (split_flag && size >= MIN_BLOCK_SIZE){\n int new_size = size/2;\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+0*new_size,xposY+0*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+1*new_size,xposY+0*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+0*new_size,xposY+1*new_size,sub);\n TEMPLATE(process_block_dec)(decoder_info,new_size,yposY+1*new_size,xposY+1*new_size,sub);\n }\n else if (decode_this_size || decode_rectangular_size){\n decode_block(decoder_info,size,yposY,xposY,sub);\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int fscrypt_get_encryption_info(struct inode *inode)\n{\n\tstruct fscrypt_info *ci = inode->i_crypt_info;\n\n\tif (!ci ||\n\t\t(ci->ci_keyring_key &&\n\t\t (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |\n\t\t\t\t\t (1 << KEY_FLAG_REVOKED) |\n\t\t\t\t\t (1 << KEY_FLAG_DEAD)))))\n\t\treturn fscrypt_get_crypt_info(inode);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "jpeg_error_handler(j_common_ptr)\n{\n return;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "vulnerable"} {"code": "static int pgx_gethdr(jas_stream_t *in, pgx_hdr_t *hdr)\n{\n\tint c;\n\tuchar buf[2];\n\n\tif ((c = jas_stream_getc(in)) == EOF) {\n\t\tgoto error;\n\t}\n\tbuf[0] = c;\n\tif ((c = jas_stream_getc(in)) == EOF) {\n\t\tgoto error;\n\t}\n\tbuf[1] = c;\n\thdr->magic = buf[0] << 8 | buf[1];\n\tif (hdr->magic != PGX_MAGIC) {\n\t\tjas_eprintf(\"invalid PGX signature\\n\");\n\t\tgoto error;\n\t}\n\tif ((c = pgx_getc(in)) == EOF || !isspace(c)) {\n\t\tgoto error;\n\t}\n\tif (pgx_getbyteorder(in, &hdr->bigendian)) {\n\t\tjas_eprintf(\"cannot get byte order\\n\");\n\t\tgoto error;\n\t}\n\tif (pgx_getsgnd(in, &hdr->sgnd)) {\n\t\tjas_eprintf(\"cannot get signedness\\n\");\n\t\tgoto error;\n\t}\n\tif (pgx_getuint32(in, &hdr->prec)) {\n\t\tjas_eprintf(\"cannot get precision\\n\");\n\t\tgoto error;\n\t}\n\tif (pgx_getuint32(in, &hdr->width)) {\n\t\tjas_eprintf(\"cannot get width\\n\");\n\t\tgoto error;\n\t}\n\tif (pgx_getuint32(in, &hdr->height)) {\n\t\tjas_eprintf(\"cannot get height\\n\");\n\t\tgoto error;\n\t}\n\treturn 0;\n\nerror:\n\treturn -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "INST_HANDLER (sbrx) {\t// SBRC Rr, b\n\t\t\t// SBRS Rr, b\n\tint b = buf[0] & 0x7;\n\tint r = ((buf[0] >> 4) & 0xf) | ((buf[1] & 0x01) << 4);\n\tRAnalOp next_op = {0};\n\n\t// calculate next instruction size (call recursively avr_op_analyze)\n\t// and free next_op's esil string (we dont need it now)\n\tavr_op_analyze (anal,\n\t\t\t&next_op,\n\t\t\top->addr + op->size, buf + op->size, len - op->size,\n\t\t\tcpu);\n\tr_strbuf_fini (&next_op.esil);\n\top->jump = op->addr + next_op.size + 2;\n\n\t// cycles\n\top->cycles = 1;\t// XXX: This is a bug, because depends on eval state,\n\t\t\t// so it cannot be really be known until this\n\t\t\t// instruction is executed by the ESIL interpreter!!!\n\t\t\t// In case of evaluating to false, this instruction\n\t\t\t// needs 2/3 cycles, elsewhere it needs only 1 cycle.\n\tESIL_A (\"%d,1,<<,r%d,&,\", b, r);\t\t\t// Rr(b)\n\tESIL_A ((buf[1] & 0xe) == 0xc\n\t\t\t? \"!,\"\t\t// SBRC => branch if cleared\n\t\t\t: \"!,!,\");\t// SBRS => branch if set\n\tESIL_A (\"?{,%\"PFMT64d\",pc,=,},\", op->jump);\t// ?true => jmp\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)\n{\n\tconst uint32_t *ptr = (const uint32_t *)dat;\n\n\tif (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {\n\t\tND_PRINT((ndo, \"A\"));\n\t}\n\tif (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {\n\t\tND_PRINT((ndo, \"S\"));\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "snmp_api_replace_oid(snmp_varbind_t *varbind, uint32_t *oid)\n{\n uint8_t i;\n\n i = 0;\n while(oid[i] != ((uint32_t)-1)) {\n varbind->oid[i] = oid[i];\n i++;\n }\n varbind->oid[i] = ((uint32_t)-1);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq)\n{\n\tstruct list_head *pending = &fq->flush_queue[fq->flush_pending_idx];\n\tstruct request *first_rq =\n\t\tlist_first_entry(pending, struct request, flush.list);\n\tstruct request *flush_rq = fq->flush_rq;\n\n\t/* C1 described at the top of this file */\n\tif (fq->flush_pending_idx != fq->flush_running_idx || list_empty(pending))\n\t\treturn false;\n\n\t/* C2 and C3 */\n\tif (!list_empty(&fq->flush_data_in_flight) &&\n\t time_before(jiffies,\n\t\t\tfq->flush_pending_since + FLUSH_PENDING_TIMEOUT))\n\t\treturn false;\n\n\t/*\n\t * Issue flush and toggle pending_idx. This makes pending_idx\n\t * different from running_idx, which means flush is in flight.\n\t */\n\tfq->flush_pending_idx ^= 1;\n\n\tblk_rq_init(q, flush_rq);\n\n\t/*\n\t * Borrow tag from the first request since they can't\n\t * be in flight at the same time. And acquire the tag's\n\t * ownership for flush req.\n\t */\n\tif (q->mq_ops) {\n\t\tstruct blk_mq_hw_ctx *hctx;\n\n\t\tflush_rq->mq_ctx = first_rq->mq_ctx;\n\t\tflush_rq->tag = first_rq->tag;\n\t\tfq->orig_rq = first_rq;\n\n\t\thctx = q->mq_ops->map_queue(q, first_rq->mq_ctx->cpu);\n\t\tblk_mq_tag_set_rq(hctx, first_rq->tag, flush_rq);\n\t}\n\n\tflush_rq->cmd_type = REQ_TYPE_FS;\n\tflush_rq->cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ;\n\tflush_rq->rq_disk = first_rq->rq_disk;\n\tflush_rq->end_io = flush_end_io;\n\n\treturn blk_flush_queue_rq(flush_rq, false);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "int secure_decrypt(void *data, unsigned int data_length, int is_signed)\n{\n\tat91_aes_key_size_t key_size;\n\tunsigned int cmac_key[8], cipher_key[8];\n\tunsigned int iv[AT91_AES_IV_SIZE_WORD];\n\tunsigned int computed_cmac[AT91_AES_BLOCK_SIZE_WORD];\n\tunsigned int fixed_length;\n\tconst unsigned int *cmac;\n\tint rc = -1;\n\n\t/* Init keys */\n\tinit_keys(&key_size, cipher_key, cmac_key, iv);\n\n\t/* Init periph */\n\tat91_aes_init();\n\n\t/* Check signature if required */\n\tif (is_signed) {\n\t\t/* Compute the CMAC */\n\t\tif (at91_aes_cmac(data_length, data, computed_cmac,\n\t\t\t\t key_size, cmac_key))\n\t\t\tgoto exit;\n\n\t\t/* Check the CMAC */\n\t\tfixed_length = at91_aes_roundup(data_length);\n\t\tcmac = (const unsigned int *)((char *)data + fixed_length);\n\t\tif (memcmp(cmac, computed_cmac, AT91_AES_BLOCK_SIZE_BYTE))\n\t\t\tgoto exit;\n\t}\n\n\t/* Decrypt the whole file */\n\tif (at91_aes_cbc(data_length, data, data, 0,\n\t\t\t key_size, cipher_key, iv))\n\t\tgoto exit;\n\n\trc = 0;\nexit:\n\t/* Reset periph */\n\tat91_aes_cleanup();\n\n\t/* Reset keys */\n\tmemset(cmac_key, 0, sizeof(cmac_key));\n\tmemset(cipher_key, 0, sizeof(cipher_key));\n\tmemset(iv, 0, sizeof(iv));\n\n\treturn rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-203", "cwe_name": "Observable Discrepancy", "description": "The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.", "url": "https://cwe.mitre.org/data/definitions/203.html", "label_name": "vulnerable"} {"code": "grub_ext4_find_leaf (struct grub_ext2_data *data, char *buf,\n struct grub_ext4_extent_header *ext_block,\n grub_uint32_t fileblock)\n{\n struct grub_ext4_extent_idx *index;\n\n while (1)\n {\n int i;\n grub_disk_addr_t block;\n\n index = (struct grub_ext4_extent_idx *) (ext_block + 1);\n\n if (grub_le_to_cpu16(ext_block->magic) != EXT4_EXT_MAGIC)\n return 0;\n\n if (ext_block->depth == 0)\n return ext_block;\n\n for (i = 0; i < grub_le_to_cpu16 (ext_block->entries); i++)\n {\n if (fileblock < grub_le_to_cpu32(index[i].block))\n break;\n }\n\n if (--i < 0)\n return 0;\n\n block = grub_le_to_cpu16 (index[i].leaf_hi);\n block = (block << 32) + grub_le_to_cpu32 (index[i].leaf);\n if (grub_disk_read (data->disk,\n block << LOG2_EXT2_BLOCK_SIZE (data),\n 0, EXT2_BLOCK_SIZE(data), buf)) {\n return 0;\n }\n\n ext_block = (struct grub_ext4_extent_header *) buf;\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "sysUpTime_handler(snmp_varbind_t *varbind, uint32_t *oid)\n{\n snmp_api_set_time_ticks(varbind, oid, clock_seconds() * 100);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int mutt_seqset_iterator_next(struct SeqsetIterator *iter, unsigned int *next)\n{\n if (!iter || !next)\n return -1;\n\n if (iter->in_range)\n {\n if ((iter->down && (iter->range_cur == (iter->range_end - 1))) ||\n (!iter->down && (iter->range_cur == (iter->range_end + 1))))\n {\n iter->in_range = 0;\n }\n }\n\n if (!iter->in_range)\n {\n iter->substr_cur = iter->substr_end;\n if (iter->substr_cur == iter->eostr)\n return 1;\n\n iter->substr_end = strchr(iter->substr_cur, ',');\n if (!iter->substr_end)\n iter->substr_end = iter->eostr;\n else\n *(iter->substr_end++) = '\\0';\n\n char *range_sep = strchr(iter->substr_cur, ':');\n if (range_sep)\n *range_sep++ = '\\0';\n\n if (mutt_str_atoui(iter->substr_cur, &iter->range_cur) != 0)\n return -1;\n if (range_sep)\n {\n if (mutt_str_atoui(range_sep, &iter->range_end) != 0)\n return -1;\n }\n else\n iter->range_end = iter->range_cur;\n\n iter->down = (iter->range_end < iter->range_cur);\n iter->in_range = 1;\n }\n\n *next = iter->range_cur;\n if (iter->down)\n iter->range_cur--;\n else\n iter->range_cur++;\n\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "bool_t enc624j600IrqHandler(NetInterface *interface)\n{\n bool_t flag;\n uint16_t status;\n\n //This flag will be set if a higher priority task must be woken\n flag = FALSE;\n\n //Clear the INTIE bit, immediately after an interrupt event\n enc624j600ClearBit(interface, ENC624J600_REG_EIE, EIE_INTIE);\n\n //Read interrupt status register\n status = enc624j600ReadReg(interface, ENC624J600_REG_EIR);\n\n //Link status change?\n if((status & EIR_LINKIF) != 0)\n {\n //Disable LINKIE interrupt\n enc624j600ClearBit(interface, ENC624J600_REG_EIE, EIE_LINKIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet received?\n if((status & EIR_PKTIF) != 0)\n {\n //Disable PKTIE interrupt\n enc624j600ClearBit(interface, ENC624J600_REG_EIE, EIE_PKTIE);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet transmission complete?\n if((status & (EIR_TXIF | EIR_TXABTIF)) != 0)\n {\n //Clear interrupt flags\n enc624j600ClearBit(interface, ENC624J600_REG_EIR, EIR_TXIF | EIR_TXABTIF);\n\n //Notify the TCP/IP stack that the transmitter is ready to send\n flag |= osSetEventFromIsr(&interface->nicTxEvent);\n }\n\n //Once the interrupt has been serviced, the INTIE bit\n //is set again to re-enable interrupts\n enc624j600SetBit(interface, ENC624J600_REG_EIE, EIE_INTIE);\n\n //A higher priority task must be woken?\n return flag;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static inline int xrstor_state(struct xsave_struct *fx, u64 mask)\n{\n\tint err = 0;\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\n\t/*\n\t * Use xrstors to restore context if it is enabled. xrstors supports\n\t * compacted format of xsave area which is not supported by xrstor.\n\t */\n\talternative_input(\n\t\t\"1: \" XRSTOR,\n\t\tXRSTORS,\n\t\tX86_FEATURE_XSAVES,\n\t\t\"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t: \"memory\");\n\n\tasm volatile(\"2:\\n\"\n\t\t xstate_fault\n\t\t : \"0\" (0)\n\t\t : \"memory\");\n\n\treturn err;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "set_umask(const char *optarg)\n{\n\tlong umask_long;\n\tmode_t umask_val;\n\tchar *endptr;\n\n\tumask_long = strtoll(optarg, &endptr, 0);\n\n\tif (*endptr || umask_long < 0 || umask_long & ~0777L) {\n\t\tfprintf(stderr, \"Invalid --umask option %s\", optarg);\n\t\treturn;\n\t}\n\n\tumask_val = umask_long & 0777;\n\tumask(umask_val);\n\n\tumask_cmdline = true;\n\n\treturn umask_val;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)\n{\n PyObject* tmp = NULL;\n identifier arg;\n expr_ty value;\n\n if (exists_not_none(obj, &PyId_arg)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_arg);\n if (tmp == NULL) goto failed;\n res = obj2ast_identifier(tmp, &arg, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n arg = NULL;\n }\n if (_PyObject_HasAttrId(obj, &PyId_value)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_value);\n if (tmp == NULL) goto failed;\n res = obj2ast_expr(tmp, &value, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"value\\\" missing from keyword\");\n return 1;\n }\n *out = keyword(arg, value, arena);\n return 0;\nfailed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "mountpoint_last(struct nameidata *nd, struct path *path)\n{\n\tint error = 0;\n\tstruct dentry *dentry;\n\tstruct dentry *dir = nd->path.dentry;\n\n\t/* If we're in rcuwalk, drop out of it to handle last component */\n\tif (nd->flags & LOOKUP_RCU) {\n\t\tif (unlazy_walk(nd, NULL)) {\n\t\t\terror = -ECHILD;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tnd->flags &= ~LOOKUP_PARENT;\n\n\tif (unlikely(nd->last_type != LAST_NORM)) {\n\t\terror = handle_dots(nd, nd->last_type);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tdentry = dget(nd->path.dentry);\n\t\tgoto done;\n\t}\n\n\tmutex_lock(&dir->d_inode->i_mutex);\n\tdentry = d_lookup(dir, &nd->last);\n\tif (!dentry) {\n\t\t/*\n\t\t * No cached dentry. Mounted dentries are pinned in the cache,\n\t\t * so that means that this dentry is probably a symlink or the\n\t\t * path doesn't actually point to a mounted dentry.\n\t\t */\n\t\tdentry = d_alloc(dir, &nd->last);\n\t\tif (!dentry) {\n\t\t\terror = -ENOMEM;\n\t\t\tmutex_unlock(&dir->d_inode->i_mutex);\n\t\t\tgoto out;\n\t\t}\n\t\tdentry = lookup_real(dir->d_inode, dentry, nd->flags);\n\t\terror = PTR_ERR(dentry);\n\t\tif (IS_ERR(dentry)) {\n\t\t\tmutex_unlock(&dir->d_inode->i_mutex);\n\t\t\tgoto out;\n\t\t}\n\t}\n\tmutex_unlock(&dir->d_inode->i_mutex);\n\ndone:\n\tif (!dentry->d_inode || d_is_negative(dentry)) {\n\t\terror = -ENOENT;\n\t\tdput(dentry);\n\t\tgoto out;\n\t}\n\tpath->dentry = dentry;\n\tpath->mnt = nd->path.mnt;\n\tif (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW))\n\t\treturn 1;\n\tmntget(path->mnt);\n\tfollow_mount(path);\n\terror = 0;\nout:\n\tterminate_walk(nd);\n\treturn error;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "smb_ofile_flush(struct smb_request *sr, struct smb_ofile *of)\n{\n\tswitch (of->f_ftype) {\n\tcase SMB_FTYPE_DISK:\n\t\tif ((of->f_node->flags & NODE_FLAGS_WRITE_THROUGH) == 0)\n\t\t\t(void) smb_fsop_commit(sr, of->f_cr, of->f_node);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "bfad_im_get_stats(struct Scsi_Host *shost)\n{\n\tstruct bfad_im_port_s *im_port =\n\t\t\t(struct bfad_im_port_s *) shost->hostdata[0];\n\tstruct bfad_s *bfad = im_port->bfad;\n\tstruct bfad_hal_comp fcomp;\n\tunion bfa_port_stats_u *fcstats;\n\tstruct fc_host_statistics *hstats;\n\tbfa_status_t rc;\n\tunsigned long flags;\n\n\tfcstats = kzalloc(sizeof(union bfa_port_stats_u), GFP_KERNEL);\n\tif (fcstats == NULL)\n\t\treturn NULL;\n\n\thstats = &bfad->link_stats;\n\tinit_completion(&fcomp.comp);\n\tspin_lock_irqsave(&bfad->bfad_lock, flags);\n\tmemset(hstats, 0, sizeof(struct fc_host_statistics));\n\trc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),\n\t\t\t\tfcstats, bfad_hcb_comp, &fcomp);\n\tspin_unlock_irqrestore(&bfad->bfad_lock, flags);\n\tif (rc != BFA_STATUS_OK) {\n\t\tkfree(fcstats);\n\t\treturn NULL;\n\t}\n\n\twait_for_completion(&fcomp.comp);\n\n\t/* Fill the fc_host_statistics structure */\n\thstats->seconds_since_last_reset = fcstats->fc.secs_reset;\n\thstats->tx_frames = fcstats->fc.tx_frames;\n\thstats->tx_words = fcstats->fc.tx_words;\n\thstats->rx_frames = fcstats->fc.rx_frames;\n\thstats->rx_words = fcstats->fc.rx_words;\n\thstats->lip_count = fcstats->fc.lip_count;\n\thstats->nos_count = fcstats->fc.nos_count;\n\thstats->error_frames = fcstats->fc.error_frames;\n\thstats->dumped_frames = fcstats->fc.dropped_frames;\n\thstats->link_failure_count = fcstats->fc.link_failures;\n\thstats->loss_of_sync_count = fcstats->fc.loss_of_syncs;\n\thstats->loss_of_signal_count = fcstats->fc.loss_of_signals;\n\thstats->prim_seq_protocol_err_count = fcstats->fc.primseq_errs;\n\thstats->invalid_crc_count = fcstats->fc.invalid_crcs;\n\n\tkfree(fcstats);\n\treturn hstats;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-401", "cwe_name": "Missing Release of Memory after Effective Lifetime", "description": "The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.", "url": "https://cwe.mitre.org/data/definitions/401.html", "label_name": "safe"} {"code": "_SSL_check_hostname (X509 *cert, const char *host)\n{\n\tint rv;\n\n\trv = _SSL_check_subject_altname (cert, host);\n\tif (rv == 0 || rv == -2)\n\t\treturn rv;\n\n\treturn _SSL_check_common_name (cert, host);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "static void update_read_synchronize(rdpUpdate* update, wStream* s)\n{\n\tWINPR_UNUSED(update);\n\tStream_Seek_UINT16(s); /* pad2Octets (2 bytes) */\n\t /**\n\t * The Synchronize Update is an artifact from the\n\t * T.128 protocol and should be ignored.\n\t */\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static int g2m_init_buffers(G2MContext *c)\n{\n int aligned_height;\n\n if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {\n c->framebuf_stride = FFALIGN(c->width * 3, 16);\n aligned_height = FFALIGN(c->height, 16);\n av_free(c->framebuf);\n c->framebuf = av_mallocz(c->framebuf_stride * aligned_height);\n if (!c->framebuf)\n return AVERROR(ENOMEM);\n }\n if (!c->synth_tile || !c->jpeg_tile ||\n c->old_tile_w < c->tile_width ||\n c->old_tile_h < c->tile_height) {\n c->tile_stride = FFALIGN(c->tile_width, 16) * 3;\n aligned_height = FFALIGN(c->tile_height, 16);\n av_free(c->synth_tile);\n av_free(c->jpeg_tile);\n av_free(c->kempf_buf);\n av_free(c->kempf_flags);\n c->synth_tile = av_mallocz(c->tile_stride * aligned_height);\n c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height);\n c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height\n + FF_INPUT_BUFFER_PADDING_SIZE);\n c->kempf_flags = av_mallocz( c->tile_width * aligned_height);\n if (!c->synth_tile || !c->jpeg_tile ||\n !c->kempf_buf || !c->kempf_flags)\n return AVERROR(ENOMEM);\n }\n\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "cib_notify_client(gpointer key, gpointer value, gpointer user_data)\n{\n const char *type = NULL;\n gboolean do_send = FALSE;\n\n cib_client_t *client = value;\n xmlNode *update_msg = user_data;\n\n CRM_CHECK(client != NULL, return TRUE);\n CRM_CHECK(update_msg != NULL, return TRUE);\n\n if (client->ipc == NULL) {\n crm_warn(\"Skipping client with NULL channel\");\n return FALSE;\n }\n\n type = crm_element_value(update_msg, F_SUBTYPE);\n\n CRM_LOG_ASSERT(type != NULL);\n if (client->diffs && safe_str_eq(type, T_CIB_DIFF_NOTIFY)) {\n do_send = TRUE;\n\n } else if (client->replace && safe_str_eq(type, T_CIB_REPLACE_NOTIFY)) {\n do_send = TRUE;\n\n } else if (client->confirmations && safe_str_eq(type, T_CIB_UPDATE_CONFIRM)) {\n do_send = TRUE;\n\n } else if (client->pre_notify && safe_str_eq(type, T_CIB_PRE_NOTIFY)) {\n do_send = TRUE;\n\n } else if (client->post_notify && safe_str_eq(type, T_CIB_POST_NOTIFY)) {\n do_send = TRUE;\n }\n\n if (do_send) {\n if (client->ipc) {\n if(crm_ipcs_send(client->ipc, 0, update_msg, TRUE) == FALSE) {\n crm_warn(\"Notification of client %s/%s failed\", client->name, client->id);\n }\n\n#ifdef HAVE_GNUTLS_GNUTLS_H\n } else if (client->session) {\n crm_debug(\"Sent %s notification to client %s/%s\", type, client->name, client->id);\n crm_send_remote_msg(client->session, update_msg, client->encrypted);\n\n#endif\n } else {\n crm_err(\"Unknown transport for %s\", client->name);\n }\n }\n return FALSE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,\n\t\t int newtype,\n\t\t struct ipv6_opt_hdr __user *newopt, int newoptlen)\n{\n\tint tot_len = 0;\n\tchar *p;\n\tstruct ipv6_txoptions *opt2;\n\tint err;\n\n\tif (opt) {\n\t\tif (newtype != IPV6_HOPOPTS && opt->hopopt)\n\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt));\n\t\tif (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt)\n\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt));\n\t\tif (newtype != IPV6_RTHDR && opt->srcrt)\n\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt));\n\t\tif (newtype != IPV6_DSTOPTS && opt->dst1opt)\n\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));\n\t}\n\n\tif (newopt && newoptlen)\n\t\ttot_len += CMSG_ALIGN(newoptlen);\n\n\tif (!tot_len)\n\t\treturn NULL;\n\n\ttot_len += sizeof(*opt2);\n\topt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC);\n\tif (!opt2)\n\t\treturn ERR_PTR(-ENOBUFS);\n\n\tmemset(opt2, 0, tot_len);\n\n\topt2->tot_len = tot_len;\n\tp = (char *)(opt2 + 1);\n\n\terr = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,\n\t\t\t\tnewtype != IPV6_HOPOPTS,\n\t\t\t\t&opt2->hopopt, &p);\n\tif (err)\n\t\tgoto out;\n\n\terr = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,\n\t\t\t\tnewtype != IPV6_RTHDRDSTOPTS,\n\t\t\t\t&opt2->dst0opt, &p);\n\tif (err)\n\t\tgoto out;\n\n\terr = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,\n\t\t\t\tnewtype != IPV6_RTHDR,\n\t\t\t\t(struct ipv6_opt_hdr **)&opt2->srcrt, &p);\n\tif (err)\n\t\tgoto out;\n\n\terr = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,\n\t\t\t\tnewtype != IPV6_DSTOPTS,\n\t\t\t\t&opt2->dst1opt, &p);\n\tif (err)\n\t\tgoto out;\n\n\topt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +\n\t\t\t (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +\n\t\t\t (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0);\n\topt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);\n\n\treturn opt2;\nout:\n\tsock_kfree_s(sk, opt2, opt2->tot_len);\n\treturn ERR_PTR(err);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "static int userfaultfd_release(struct inode *inode, struct file *file)\n{\n\tstruct userfaultfd_ctx *ctx = file->private_data;\n\tstruct mm_struct *mm = ctx->mm;\n\tstruct vm_area_struct *vma, *prev;\n\t/* len == 0 means wake all */\n\tstruct userfaultfd_wake_range range = { .len = 0, };\n\tunsigned long new_flags;\n\n\tWRITE_ONCE(ctx->released, true);\n\n\tif (!mmget_not_zero(mm))\n\t\tgoto wakeup;\n\n\t/*\n\t * Flush page faults out of all CPUs. NOTE: all page faults\n\t * must be retried without returning VM_FAULT_SIGBUS if\n\t * userfaultfd_ctx_get() succeeds but vma->vma_userfault_ctx\n\t * changes while handle_userfault released the mmap_sem. So\n\t * it's critical that released is set to true (above), before\n\t * taking the mmap_sem for writing.\n\t */\n\tdown_write(&mm->mmap_sem);\n\tif (!mmget_still_valid(mm))\n\t\tgoto skip_mm;\n\tprev = NULL;\n\tfor (vma = mm->mmap; vma; vma = vma->vm_next) {\n\t\tcond_resched();\n\t\tBUG_ON(!!vma->vm_userfaultfd_ctx.ctx ^\n\t\t !!(vma->vm_flags & (VM_UFFD_MISSING | VM_UFFD_WP)));\n\t\tif (vma->vm_userfaultfd_ctx.ctx != ctx) {\n\t\t\tprev = vma;\n\t\t\tcontinue;\n\t\t}\n\t\tnew_flags = vma->vm_flags & ~(VM_UFFD_MISSING | VM_UFFD_WP);\n\t\tprev = vma_merge(mm, prev, vma->vm_start, vma->vm_end,\n\t\t\t\t new_flags, vma->anon_vma,\n\t\t\t\t vma->vm_file, vma->vm_pgoff,\n\t\t\t\t vma_policy(vma),\n\t\t\t\t NULL_VM_UFFD_CTX);\n\t\tif (prev)\n\t\t\tvma = prev;\n\t\telse\n\t\t\tprev = vma;\n\t\tvma->vm_flags = new_flags;\n\t\tvma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;\n\t}\nskip_mm:\n\tup_write(&mm->mmap_sem);\n\tmmput(mm);\nwakeup:\n\t/*\n\t * After no new page faults can wait on this fault_*wqh, flush\n\t * the last page faults that may have been already waiting on\n\t * the fault_*wqh.\n\t */\n\tspin_lock(&ctx->fault_pending_wqh.lock);\n\t__wake_up_locked_key(&ctx->fault_pending_wqh, TASK_NORMAL, &range);\n\t__wake_up(&ctx->fault_wqh, TASK_NORMAL, 1, &range);\n\tspin_unlock(&ctx->fault_pending_wqh.lock);\n\n\t/* Flush pending events that may still wait on event_wqh */\n\twake_up_all(&ctx->event_wqh);\n\n\twake_up_poll(&ctx->fd_wqh, EPOLLHUP);\n\tuserfaultfd_ctx_put(ctx);\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-667", "cwe_name": "Improper Locking", "description": "The software does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors.", "url": "https://cwe.mitre.org/data/definitions/667.html", "label_name": "safe"} {"code": "cib_tls_close(cib_t * cib)\n{\n cib_remote_opaque_t *private = cib->variant_opaque;\n\n shutdown(private->command.socket, SHUT_RDWR); /* no more receptions */\n shutdown(private->callback.socket, SHUT_RDWR); /* no more receptions */\n close(private->command.socket);\n close(private->callback.socket);\n\n#ifdef HAVE_GNUTLS_GNUTLS_H\n if (private->command.encrypted) {\n gnutls_bye(*(private->command.session), GNUTLS_SHUT_RDWR);\n gnutls_deinit(*(private->command.session));\n gnutls_free(private->command.session);\n\n gnutls_bye(*(private->callback.session), GNUTLS_SHUT_RDWR);\n gnutls_deinit(*(private->callback.session));\n gnutls_free(private->callback.session);\n\n gnutls_anon_free_client_credentials(anon_cred_c);\n gnutls_global_deinit();\n }\n#endif\n return 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "xid_map_enter(netdissect_options *ndo,\n const struct sunrpc_msg *rp, const u_char *bp)\n{\n\tconst struct ip *ip = NULL;\n\tconst struct ip6_hdr *ip6 = NULL;\n\tstruct xid_map_entry *xmep;\n\n\tif (!ND_TTEST(rp->rm_call.cb_vers))\n\t\treturn (0);\n\tswitch (IP_V((const struct ip *)bp)) {\n\tcase 4:\n\t\tip = (const struct ip *)bp;\n\t\tbreak;\n\tcase 6:\n\t\tip6 = (const struct ip6_hdr *)bp;\n\t\tbreak;\n\tdefault:\n\t\treturn (1);\n\t}\n\n\txmep = &xid_map[xid_map_next];\n\n\tif (++xid_map_next >= XIDMAPSIZE)\n\t\txid_map_next = 0;\n\n\tUNALIGNED_MEMCPY(&xmep->xid, &rp->rm_xid, sizeof(xmep->xid));\n\tif (ip) {\n\t\txmep->ipver = 4;\n\t\tUNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));\n\t\tUNALIGNED_MEMCPY(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));\n\t}\n\telse if (ip6) {\n\t\txmep->ipver = 6;\n\t\tUNALIGNED_MEMCPY(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));\n\t\tUNALIGNED_MEMCPY(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));\n\t}\n\tif (!ND_TTEST(rp->rm_call.cb_proc))\n\t\treturn (0);\n\txmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);\n\tif (!ND_TTEST(rp->rm_call.cb_vers))\n\t\treturn (0);\n\txmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers);\n\treturn (1);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "sraSpanRemove(sraSpan *span) {\n span->_prev->_next = span->_next;\n span->_next->_prev = span->_prev;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)\n{\n\tstruct net_device *dev = skb->dev;\n\tint fhoff, nhoff, ret;\n\tstruct frag_hdr *fhdr;\n\tstruct frag_queue *fq;\n\tstruct ipv6hdr *hdr;\n\tu8 prevhdr;\n\n\t/* Jumbo payload inhibits frag. header */\n\tif (ipv6_hdr(skb)->payload_len == 0) {\n\t\tpr_debug(\"payload len = 0\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)\n\t\treturn -EINVAL;\n\n\tif (!pskb_may_pull(skb, fhoff + sizeof(*fhdr)))\n\t\treturn -ENOMEM;\n\n\tskb_set_transport_header(skb, fhoff);\n\thdr = ipv6_hdr(skb);\n\tfhdr = (struct frag_hdr *)skb_transport_header(skb);\n\n\tfq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr,\n\t\t skb->dev ? skb->dev->ifindex : 0, ip6_frag_ecn(hdr));\n\tif (fq == NULL) {\n\t\tpr_debug(\"Can't find and can't create new queue\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\tspin_lock_bh(&fq->q.lock);\n\n\tif (nf_ct_frag6_queue(fq, skb, fhdr, nhoff) < 0) {\n\t\tret = -EINVAL;\n\t\tgoto out_unlock;\n\t}\n\n\t/* after queue has assumed skb ownership, only 0 or -EINPROGRESS\n\t * must be returned.\n\t */\n\tret = -EINPROGRESS;\n\tif (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&\n\t fq->q.meat == fq->q.len &&\n\t nf_ct_frag6_reasm(fq, skb, dev))\n\t\tret = 0;\n\nout_unlock:\n\tspin_unlock_bh(&fq->q.lock);\n\tinet_frag_put(&fq->q, &nf_frags);\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static ssize_t _epoll_readv(\n oe_fd_t* desc,\n const struct oe_iovec* iov,\n int iovcnt)\n{\n ssize_t ret = -1;\n epoll_t* file = _cast_epoll(desc);\n void* buf = NULL;\n size_t buf_size = 0;\n\n if (!file || (iovcnt && !iov) || iovcnt < 0 || iovcnt > OE_IOV_MAX)\n OE_RAISE_ERRNO(OE_EINVAL);\n\n /* Flatten the IO vector into contiguous heap memory. */\n if (oe_iov_pack(iov, iovcnt, &buf, &buf_size) != 0)\n OE_RAISE_ERRNO(OE_ENOMEM);\n\n /* Call the host. */\n if (oe_syscall_readv_ocall(&ret, file->host_fd, buf, iovcnt, buf_size) !=\n OE_OK)\n {\n OE_RAISE_ERRNO(OE_EINVAL);\n }\n\n /* Synchronize data read with IO vector. */\n if (oe_iov_sync(iov, iovcnt, buf, buf_size) != 0)\n OE_RAISE_ERRNO(OE_EINVAL);\n\ndone:\n\n if (buf)\n oe_free(buf);\n\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "lookup_bytestring(netdissect_options *ndo, register const u_char *bs,\n\t\t const unsigned int nlen)\n{\n\tstruct enamemem *tp;\n\tregister u_int i, j, k;\n\n\tif (nlen >= 6) {\n\t\tk = (bs[0] << 8) | bs[1];\n\t\tj = (bs[2] << 8) | bs[3];\n\t\ti = (bs[4] << 8) | bs[5];\n\t} else if (nlen >= 4) {\n\t\tk = (bs[0] << 8) | bs[1];\n\t\tj = (bs[2] << 8) | bs[3];\n\t\ti = 0;\n\t} else\n\t\ti = j = k = 0;\n\n\ttp = &bytestringtable[(i ^ j) & (HASHNAMESIZE-1)];\n\twhile (tp->e_nxt)\n\t\tif (tp->e_addr0 == i &&\n\t\t tp->e_addr1 == j &&\n\t\t tp->e_addr2 == k &&\n\t\t memcmp((const char *)bs, (const char *)(tp->e_bs), nlen) == 0)\n\t\t\treturn tp;\n\t\telse\n\t\t\ttp = tp->e_nxt;\n\n\ttp->e_addr0 = i;\n\ttp->e_addr1 = j;\n\ttp->e_addr2 = k;\n\n\ttp->e_bs = (u_char *) calloc(1, nlen + 1);\n\tif (tp->e_bs == NULL)\n\t\t(*ndo->ndo_error)(ndo, \"lookup_bytestring: calloc\");\n\n\tmemcpy(tp->e_bs, bs, nlen);\n\ttp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));\n\tif (tp->e_nxt == NULL)\n\t\t(*ndo->ndo_error)(ndo, \"lookup_bytestring: calloc\");\n\n\treturn tp;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "jp2_box_t *jp2_box_get(jas_stream_t *in)\n{\n\tjp2_box_t *box;\n\tjp2_boxinfo_t *boxinfo;\n\tjas_stream_t *tmpstream;\n\tuint_fast32_t len;\n\tuint_fast64_t extlen;\n\tbool dataflag;\n\n\tbox = 0;\n\ttmpstream = 0;\n\n\tif (!(box = jas_malloc(sizeof(jp2_box_t)))) {\n\t\tgoto error;\n\t}\n\n\t// Mark the box data as never having been constructed\n\t// so that we will not errantly attempt to destroy it later.\n\tbox->ops = &jp2_boxinfo_unk.ops;\n\n\tif (jp2_getuint32(in, &len) || jp2_getuint32(in, &box->type)) {\n\t\tgoto error;\n\t}\n\tboxinfo = jp2_boxinfolookup(box->type);\n\tbox->info = boxinfo;\n\tbox->len = len;\n\tJAS_DBGLOG(10, (\n\t \"preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\\n\",\n\t '\"', boxinfo->name, '\"', box->type, box->len\n\t ));\n\tif (box->len == 1) {\n\t\tif (jp2_getuint64(in, &extlen)) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (extlen > 0xffffffffUL) {\n\t\t\tjas_eprintf(\"warning: cannot handle large 64-bit box length\\n\");\n\t\t\textlen = 0xffffffffUL;\n\t\t}\n\t\tbox->len = extlen;\n\t\tbox->datalen = extlen - JP2_BOX_HDRLEN(true);\n\t} else {\n\t\tbox->datalen = box->len - JP2_BOX_HDRLEN(false);\n\t}\n\tif (box->len != 0 && box->len < 8) {\n\t\tgoto error;\n\t}\n\n\tdataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));\n\n\tif (dataflag) {\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jas_stream_copy(tmpstream, in, box->datalen)) {\n\t\t\tjas_eprintf(\"cannot copy box data\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tjas_stream_rewind(tmpstream);\n\n\t\t// From here onwards, the box data will need to be destroyed.\n\t\t// So, initialize the box operations.\n\t\tbox->ops = &boxinfo->ops;\n\n\t\tif (box->ops->getdata) {\n\t\t\tif ((*box->ops->getdata)(box, tmpstream)) {\n\t\t\t\tjas_eprintf(\"cannot parse box data\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t\tjas_stream_close(tmpstream);\n\t}\n\n\tif (jas_getdbglevel() >= 1) {\n\t\tjp2_box_dump(box, stderr);\n\t}\n\n\treturn box;\n\nerror:\n\tif (box) {\n\t\tjp2_box_destroy(box);\n\t}\n\tif (tmpstream) {\n\t\tjas_stream_close(tmpstream);\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "mcs_parse_domain_params(STREAM s)\n{\n\tint length;\n\n\tber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);\n\tin_uint8s(s, length);\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "gss_get_mic (minor_status,\n\t context_handle,\n\t qop_req,\n\t message_buffer,\n\t msg_token)\n\nOM_uint32 *\t\tminor_status;\ngss_ctx_id_t\t\tcontext_handle;\ngss_qop_t\t\tqop_req;\ngss_buffer_t\t\tmessage_buffer;\ngss_buffer_t\t\tmsg_token;\n\n{\n OM_uint32\t\tstatus;\n gss_union_ctx_id_t\tctx;\n gss_mechanism\tmech;\n\n status = val_get_mic_args(minor_status, context_handle,\n\t\t\t qop_req, message_buffer, msg_token);\n if (status != GSS_S_COMPLETE)\n\treturn (status);\n\n /*\n * select the approprate underlying mechanism routine and\n * call it.\n */\n\n ctx = (gss_union_ctx_id_t) context_handle;\n if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT)\n\treturn (GSS_S_NO_CONTEXT);\n mech = gssint_get_mechanism (ctx->mech_type);\n\n if (mech) {\n\tif (mech->gss_get_mic) {\n\t status = mech->gss_get_mic(\n\t\t\t\t minor_status,\n\t\t\t\t ctx->internal_ctx_id,\n\t\t\t\t qop_req,\n\t\t\t\t message_buffer,\n\t\t\t\t msg_token);\n\t if (status != GSS_S_COMPLETE)\n\t\tmap_error(minor_status, mech);\n\t} else\n\t status = GSS_S_UNAVAILABLE;\n\n\treturn(status);\n }\n\n return (GSS_S_BAD_MECH);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "cib_remote_signon(cib_t * cib, const char *name, enum cib_conn_type type)\n{\n int rc = pcmk_ok;\n cib_remote_opaque_t *private = cib->variant_opaque;\n\n if (private->passwd == NULL) {\n struct termios settings;\n int rc;\n\n rc = tcgetattr(0, &settings);\n settings.c_lflag &= ~ECHO;\n rc = tcsetattr(0, TCSANOW, &settings);\n\n fprintf(stderr, \"Password: \");\n private->passwd = calloc(1, 1024);\n rc = scanf(\"%s\", private->passwd);\n fprintf(stdout, \"\\n\");\n /* fprintf(stderr, \"entered: '%s'\\n\", buffer); */\n if (rc < 1) {\n private->passwd = NULL;\n }\n\n settings.c_lflag |= ECHO;\n rc = tcsetattr(0, TCSANOW, &settings);\n }\n\n if (private->server == NULL || private->user == NULL) {\n rc = -EINVAL;\n }\n\n if (rc == pcmk_ok) {\n rc = cib_tls_signon(cib, &(private->command));\n }\n\n if (rc == pcmk_ok) {\n rc = cib_tls_signon(cib, &(private->callback));\n }\n\n if (rc == pcmk_ok) {\n xmlNode *hello =\n cib_create_op(0, private->callback.token, CRM_OP_REGISTER, NULL, NULL, NULL, 0, NULL);\n crm_xml_add(hello, F_CIB_CLIENTNAME, name);\n crm_send_remote_msg(private->command.session, hello, private->command.encrypted);\n free_xml(hello);\n }\n\n if (rc == pcmk_ok) {\n fprintf(stderr, \"%s: Opened connection to %s:%d\\n\", name, private->server, private->port);\n cib->state = cib_connected_command;\n cib->type = cib_command;\n\n } else {\n fprintf(stderr, \"%s: Connection to %s:%d failed: %s\\n\",\n name, private->server, private->port, pcmk_strerror(rc));\n }\n\n return rc;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "vulnerable"} {"code": "void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)\n{\n\t/*\n\t * Convert jiffies to nanoseconds and separate with\n\t * one divide.\n\t */\n\tu32 rem;\n\n\tvalue->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,\n\t\t\t\t NSEC_PER_SEC, &rem);\n\tvalue->tv_usec = rem / NSEC_PER_USEC;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tstruct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;\n\tstruct sk_buff *skb;\n\n\tif (flags & MSG_OOB)\n\t\tgoto out;\n\n\tif (addr_len)\n\t\t*addr_len = sizeof(*sin);\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = ip_recv_error(sk, msg, len);\n\t\tgoto out;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tsin->sin_port = 0;\n\t\tmemset(&sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\tif (err)\n\t\treturn err;\n\treturn copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{\n return snprintf(dest, destlen, \"%s.hcache\", path);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "GetOutboundPinholeTimeout(struct upnphttp * h, const char * action, const char * ns)\n{\n\tint r;\n\n\tstatic const char resp[] =\n\t\t\"\"\n\t\t\"%d\"\n\t\t\"\";\n\n\tchar body[512];\n\tint bodylen;\n\tstruct NameValueParserData data;\n\tchar * int_ip, * int_port, * rem_host, * rem_port, * protocol;\n\tint opt=0;\n\t/*int proto=0;*/\n\tunsigned short iport, rport;\n\n\tif (GETFLAG(IPV6FCFWDISABLEDMASK))\n\t{\n\t\tSoapError(h, 702, \"FirewallDisabled\");\n\t\treturn;\n\t}\n\n\tParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);\n\tint_ip = GetValueFromNameValueList(&data, \"InternalClient\");\n\tint_port = GetValueFromNameValueList(&data, \"InternalPort\");\n\trem_host = GetValueFromNameValueList(&data, \"RemoteHost\");\n\trem_port = GetValueFromNameValueList(&data, \"RemotePort\");\n\tprotocol = GetValueFromNameValueList(&data, \"Protocol\");\n\n\tif (!int_port || !ext_port || !protocol)\n\t{\n\t\tClearNameValueList(&data);\n\t\tSoapError(h, 402, \"Invalid Args\");\n\t\treturn;\n\t}\n\n\trport = (unsigned short)atoi(rem_port);\n\tiport = (unsigned short)atoi(int_port);\n\t/*proto = atoi(protocol);*/\n\n\tsyslog(LOG_INFO, \"%s: retrieving timeout for outbound pinhole from [%s]:%hu to [%s]:%hu protocol %s\", action, int_ip, iport,rem_host, rport, protocol);\n\n\t/* TODO */\n\tr = -1;/*upnp_check_outbound_pinhole(proto, &opt);*/\n\n\tswitch(r)\n\t{\n\t\tcase 1:\t/* success */\n\t\t\tbodylen = snprintf(body, sizeof(body), resp,\n\t\t\t action, ns/*\"urn:schemas-upnp-org:service:WANIPv6FirewallControl:1\"*/,\n\t\t\t opt, action);\n\t\t\tBuildSendAndCloseSoapResp(h, body, bodylen);\n\t\t\tbreak;\n\t\tcase -5:\t/* Protocol not supported */\n\t\t\tSoapError(h, 705, \"ProtocolNotSupported\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tSoapError(h, 501, \"ActionFailed\");\n\t}\n\tClearNameValueList(&data);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "BGD_DECLARE(void *) gdImageJpegPtr(gdImagePtr im, int *size, int quality)\n{\n\tvoid *rv;\n\tgdIOCtx *out = gdNewDynamicCtx(2048, NULL);\n\tif (out == NULL) return NULL;\n\tif (!_gdImageJpegCtx(im, out, quality)) {\n\t\trv = gdDPExtractData(out, size);\n\t} else {\n\t\trv = NULL;\n\t}\n\tout->gd_free(out);\n\treturn rv;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "void trustedGetEncryptedSecretShareAES(int *errStatus, char *errString, uint8_t *encrypted_skey, uint32_t *dec_len,\n char *result_str, char *s_shareG2, char *pub_keyB, uint8_t _t, uint8_t _n,\n uint8_t ind) {\n\n LOG_INFO(__FUNCTION__);\n INIT_ERROR_STATE\n\n uint32_t enc_len;\n int status;\n\n CHECK_STATE(encrypted_skey);\n CHECK_STATE(result_str);\n CHECK_STATE(s_shareG2);\n CHECK_STATE(pub_keyB);\n\n LOG_DEBUG(__FUNCTION__);\n\n SAFE_CHAR_BUF(skey, ECDSA_SKEY_LEN);\n\n SAFE_CHAR_BUF(pub_key_x, BUF_LEN);SAFE_CHAR_BUF(pub_key_y, BUF_LEN);\n\n trustedGenerateEcdsaKeyAES(&status, errString, encrypted_skey, &enc_len, pub_key_x, pub_key_y);\n\n CHECK_STATUS(\"trustedGenerateEcdsaKeyAES failed\");\n\n status = AES_decrypt(encrypted_skey, enc_len, skey, ECDSA_SKEY_LEN);\n\n skey[ECDSA_SKEY_LEN - 1] = 0;\n\n CHECK_STATUS2(\"AES_decrypt failed (in trustedGetEncryptedSecretShareAES) with status %d\");\n\n *dec_len = enc_len;\n\n SAFE_CHAR_BUF(common_key, ECDSA_SKEY_LEN);\n\n status = gen_session_key(skey, pub_keyB, common_key);\n\n CHECK_STATUS(\"gen_session_key failed\")\n\n SAFE_CHAR_BUF(s_share, ECDSA_SKEY_LEN);\n\n status = calc_secret_share(getThreadLocalDecryptedDkgPoly(), s_share, _t, _n, ind);\n CHECK_STATUS(\"calc secret share failed\")\n\n\n status = calc_secret_shareG2(s_share, s_shareG2);\n CHECK_STATUS(\"invalid decr secret share\");\n\n SAFE_CHAR_BUF(cypher, ECDSA_SKEY_LEN);\n status=xor_encrypt(common_key, s_share, cypher);\n\n CHECK_STATUS(\"xor_encrypt failed\")\n\n strncpy(result_str, cypher, strlen(cypher));\n strncpy(result_str + strlen(cypher), pub_key_x, strlen(pub_key_x));\n strncpy(result_str + strlen(pub_key_x) + strlen(pub_key_y), pub_key_y, strlen(pub_key_y));\n\n SET_SUCCESS\n\n clean:\n ;\n LOG_INFO(__FUNCTION__ );\n LOG_INFO(\"SGX call completed\");\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static LUA_FUNCTION(openssl_x509_check_host)\n{\n X509 * cert = CHECK_OBJECT(1, X509, \"openssl.x509\");\n if (lua_isstring(L, 2))\n {\n const char *hostname = lua_tostring(L, 2);\n lua_pushboolean(L, X509_check_host(cert, hostname, strlen(hostname), 0, NULL));\n }\n else\n {\n lua_pushboolean(L, 0);\n }\n return 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "get_matching_model_microcode(int cpu, unsigned long start,\n\t\t\t void *data, size_t size,\n\t\t\t struct mc_saved_data *mc_saved_data,\n\t\t\t unsigned long *mc_saved_in_initrd,\n\t\t\t struct ucode_cpu_info *uci)\n{\n\tu8 *ucode_ptr = data;\n\tunsigned int leftover = size;\n\tenum ucode_state state = UCODE_OK;\n\tunsigned int mc_size;\n\tstruct microcode_header_intel *mc_header;\n\tstruct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];\n\tunsigned int mc_saved_count = mc_saved_data->mc_saved_count;\n\tint i;\n\n\twhile (leftover) {\n\t\tmc_header = (struct microcode_header_intel *)ucode_ptr;\n\n\t\tmc_size = get_totalsize(mc_header);\n\t\tif (!mc_size || mc_size > leftover ||\n\t\t\tmicrocode_sanity_check(ucode_ptr, 0) < 0)\n\t\t\tbreak;\n\n\t\tleftover -= mc_size;\n\n\t\t/*\n\t\t * Since APs with same family and model as the BSP may boot in\n\t\t * the platform, we need to find and save microcode patches\n\t\t * with the same family and model as the BSP.\n\t\t */\n\t\tif (matching_model_microcode(mc_header, uci->cpu_sig.sig) !=\n\t\t\t UCODE_OK) {\n\t\t\tucode_ptr += mc_size;\n\t\t\tcontinue;\n\t\t}\n\n\t\t_save_mc(mc_saved_tmp, ucode_ptr, &mc_saved_count);\n\n\t\tucode_ptr += mc_size;\n\t}\n\n\tif (leftover) {\n\t\tstate = UCODE_ERROR;\n\t\tgoto out;\n\t}\n\n\tif (mc_saved_count == 0) {\n\t\tstate = UCODE_NFOUND;\n\t\tgoto out;\n\t}\n\n\tfor (i = 0; i < mc_saved_count; i++)\n\t\tmc_saved_in_initrd[i] = (unsigned long)mc_saved_tmp[i] - start;\n\n\tmc_saved_data->mc_saved_count = mc_saved_count;\nout:\n\treturn state;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "IW_IMPL(int) iw_get_input_density(struct iw_context *ctx,\n double *px, double *py, int *pcode)\n{\n\t*px = 1.0;\n\t*py = 1.0;\n\t*pcode = IW_DENSITY_UNKNOWN;\n\n\tif(ctx->img1.density_code==IW_DENSITY_UNKNOWN) {\n\t\treturn 0;\n\t}\n\tif(!iw_is_valid_density(ctx->img1.density_x, ctx->img1.density_y,\n\t\tctx->img1.density_code))\n\t{\n\t\treturn 0;\n\t}\n\t*px = ctx->img1.density_x;\n\t*py = ctx->img1.density_y;\n\t*pcode = ctx->img1.density_code;\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-369", "cwe_name": "Divide By Zero", "description": "The product divides a value by zero.", "url": "https://cwe.mitre.org/data/definitions/369.html", "label_name": "safe"} {"code": "ex_function(exarg_T *eap)\n{\n garray_T lines_to_free;\n\n ga_init2(&lines_to_free, sizeof(char_u *), 50);\n (void)define_function(eap, NULL, &lines_to_free);\n ga_clear_strings(&lines_to_free);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "static inline void xen_evtchn_handle_events(unsigned cpu,\n\t\t\t\t\t struct evtchn_loop_ctrl *ctrl)\n{\n\treturn evtchn_ops->handle_events(cpu, ctrl);\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices,\n\t\t\t\t u64 devid, u8 *uuid, u8 *fsid)\n{\n\tstruct btrfs_device *device;\n\n\twhile (fs_devices) {\n\t\tif (!fsid ||\n\t\t !memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE)) {\n\t\t\tdevice = find_device(fs_devices, devid, uuid);\n\t\t\tif (device)\n\t\t\t\treturn device;\n\t\t}\n\t\tfs_devices = fs_devices->seed;\n\t}\n\treturn NULL;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "SMB2_sess_establish_session(struct SMB2_sess_data *sess_data)\n{\n\tint rc = 0;\n\tstruct cifs_ses *ses = sess_data->ses;\n\n\tmutex_lock(&ses->server->srv_mutex);\n\tif (ses->server->ops->generate_signingkey) {\n\t\trc = ses->server->ops->generate_signingkey(ses);\n\t\tif (rc) {\n\t\t\tcifs_dbg(FYI,\n\t\t\t\t\"SMB3 session key generation failed\\n\");\n\t\t\tmutex_unlock(&ses->server->srv_mutex);\n\t\t\treturn rc;\n\t\t}\n\t}\n\tif (!ses->server->session_estab) {\n\t\tses->server->sequence_number = 0x2;\n\t\tses->server->session_estab = true;\n\t}\n\tmutex_unlock(&ses->server->srv_mutex);\n\n\tcifs_dbg(FYI, \"SMB2/3 session established successfully\\n\");\n\tspin_lock(&GlobalMid_Lock);\n\tses->status = CifsGood;\n\tses->need_reconnect = false;\n\tspin_unlock(&GlobalMid_Lock);\n\treturn rc;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static int oidc_cache_crypto_encrypt(request_rec *r, const char *plaintext,\n\t\tunsigned char *key, char **result) {\n\tchar *encoded = NULL, *p = NULL, *e_tag = NULL;\n\tunsigned char *ciphertext = NULL;\n\tint plaintext_len, ciphertext_len, encoded_len, e_tag_len;\n\tunsigned char tag[OIDC_CACHE_TAG_LEN];\n\n\t/* allocate space for the ciphertext */\n\tplaintext_len = strlen(plaintext) + 1;\n\tciphertext = apr_pcalloc(r->pool,\n\t\t\t(plaintext_len + EVP_CIPHER_block_size(OIDC_CACHE_CIPHER)));\n\n\tciphertext_len = oidc_cache_crypto_encrypt_impl(r,\n\t\t\t(unsigned char *) plaintext, plaintext_len,\n\t\t\tOIDC_CACHE_CRYPTO_GCM_AAD, sizeof(OIDC_CACHE_CRYPTO_GCM_AAD), key,\n\t\t\tOIDC_CACHE_CRYPTO_GCM_IV, sizeof(OIDC_CACHE_CRYPTO_GCM_IV),\n\t\t\tciphertext, tag, sizeof(tag));\n\n\t/* base64url encode the resulting ciphertext */\n\tencoded_len = oidc_base64url_encode(r, &encoded, (const char *) ciphertext,\n\t\t\tciphertext_len, 1);\n\tif (encoded_len > 0) {\n\t\tp = encoded;\n\n\t\t/* base64url encode the tag */\n\t\te_tag_len = oidc_base64url_encode(r, &e_tag, (const char *) tag,\n\t\t\t\tOIDC_CACHE_TAG_LEN, 1);\n\n\t\t/* now allocated space for the concatenated base64url encoded ciphertext and tag */\n\t\tencoded = apr_pcalloc(r->pool, encoded_len + 1 + e_tag_len + 1);\n\t\tmemcpy(encoded, p, encoded_len);\n\t\tp = encoded + encoded_len;\n\t\t*p = OIDC_CHAR_DOT;\n\t\tp++;\n\n\t\t/* append the tag in the buffer */\n\t\tmemcpy(p, e_tag, e_tag_len);\n\t\tencoded_len += e_tag_len + 1;\n\n\t\t/* make sure the result is \\0 terminated */\n\t\tencoded[encoded_len] = '\\0';\n\n\t\t*result = encoded;\n\t}\n\n\treturn encoded_len;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-330", "cwe_name": "Use of Insufficiently Random Values", "description": "The software uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.", "url": "https://cwe.mitre.org/data/definitions/330.html", "label_name": "vulnerable"} {"code": "static int propagate_one(struct mount *m)\n{\n\tstruct mount *child;\n\tint type;\n\t/* skip ones added by this propagate_mnt() */\n\tif (IS_MNT_NEW(m))\n\t\treturn 0;\n\t/* skip if mountpoint isn't covered by it */\n\tif (!is_subdir(mp->m_dentry, m->mnt.mnt_root))\n\t\treturn 0;\n\tif (peers(m, last_dest)) {\n\t\ttype = CL_MAKE_SHARED;\n\t} else {\n\t\tstruct mount *n, *p;\n\t\tfor (n = m; ; n = p) {\n\t\t\tp = n->mnt_master;\n\t\t\tif (p == dest_master || IS_MNT_MARKED(p)) {\n\t\t\t\twhile (last_dest->mnt_master != p) {\n\t\t\t\t\tlast_source = last_source->mnt_master;\n\t\t\t\t\tlast_dest = last_source->mnt_parent;\n\t\t\t\t}\n\t\t\t\tif (!peers(n, last_dest)) {\n\t\t\t\t\tlast_source = last_source->mnt_master;\n\t\t\t\t\tlast_dest = last_source->mnt_parent;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\ttype = CL_SLAVE;\n\t\t/* beginning of peer group among the slaves? */\n\t\tif (IS_MNT_SHARED(m))\n\t\t\ttype |= CL_MAKE_SHARED;\n\t}\n\t\t\n\t/* Notice when we are propagating across user namespaces */\n\tif (m->mnt_ns->user_ns != user_ns)\n\t\ttype |= CL_UNPRIVILEGED;\n\tchild = copy_tree(last_source, last_source->mnt.mnt_root, type);\n\tif (IS_ERR(child))\n\t\treturn PTR_ERR(child);\n\tchild->mnt.mnt_flags &= ~MNT_LOCKED;\n\tmnt_set_mountpoint(m, mp, child);\n\tlast_dest = m;\n\tlast_source = child;\n\tif (m->mnt_master != dest_master) {\n\t\tread_seqlock_excl(&mount_lock);\n\t\tSET_MNT_MARK(m->mnt_master);\n\t\tread_sequnlock_excl(&mount_lock);\n\t}\n\thlist_add_head(&child->mnt_hash, list);\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int\n lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena)\n{\n stmt_ty p;\n if (!target) {\n PyErr_SetString(PyExc_ValueError,\n \"field target is required for For\");\n return NULL;\n }\n if (!iter) {\n PyErr_SetString(PyExc_ValueError,\n \"field iter is required for For\");\n return NULL;\n }\n p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));\n if (!p)\n return NULL;\n p->kind = For_kind;\n p->v.For.target = target;\n p->v.For.iter = iter;\n p->v.For.body = body;\n p->v.For.orelse = orelse;\n p->lineno = lineno;\n p->col_offset = col_offset;\n p->end_lineno = end_lineno;\n p->end_col_offset = end_col_offset;\n return p;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "l_strnstart(netdissect_options *ndo, const char *tstr1, u_int tl1,\n const char *str2, u_int l2)\n{\n\tif (!ND_TTEST2(*str2, tl1)) {\n\t\t/*\n\t\t * We don't have tl1 bytes worth of captured data\n\t\t * for the string, so we can't check for this\n\t\t * string.\n\t\t */\n\t\treturn 0;\n\t}\n\tif (tl1 > l2)\n\t\treturn 0;\n\n\treturn (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_esn,\n\t\t\t\t\t struct nlattr *rp)\n{\n\tstruct xfrm_replay_state_esn *up;\n\n\tif (!replay_esn || !rp)\n\t\treturn 0;\n\n\tup = nla_data(rp);\n\n\tif (xfrm_replay_state_esn_len(replay_esn) !=\n\t\t\txfrm_replay_state_esn_len(up))\n\t\treturn -EINVAL;\n\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "IPV6DefragInOrderSimpleTest(void)\n{\n Packet *p1 = NULL, *p2 = NULL, *p3 = NULL;\n Packet *reassembled = NULL;\n int id = 12;\n int i;\n int ret = 0;\n\n DefragInit();\n\n p1 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 8);\n if (p1 == NULL)\n goto end;\n p2 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 1, 1, 'B', 8);\n if (p2 == NULL)\n goto end;\n p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3);\n if (p3 == NULL)\n goto end;\n\n if (Defrag(NULL, NULL, p1, NULL) != NULL)\n goto end;\n if (Defrag(NULL, NULL, p2, NULL) != NULL)\n goto end;\n reassembled = Defrag(NULL, NULL, p3, NULL);\n if (reassembled == NULL)\n goto end;\n\n if (IPV6_GET_PLEN(reassembled) != 19)\n goto end;\n\n /* 40 bytes in we should find 8 bytes of A. */\n for (i = 40; i < 40 + 8; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'A')\n goto end;\n }\n\n /* 28 bytes in we should find 8 bytes of B. */\n for (i = 48; i < 48 + 8; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'B')\n goto end;\n }\n\n /* And 36 bytes in we should find 3 bytes of C. */\n for (i = 56; i < 56 + 3; i++) {\n if (GET_PKT_DATA(reassembled)[i] != 'C')\n goto end;\n }\n\n ret = 1;\nend:\n if (p1 != NULL)\n SCFree(p1);\n if (p2 != NULL)\n SCFree(p2);\n if (p3 != NULL)\n SCFree(p3);\n if (reassembled != NULL)\n SCFree(reassembled);\n\n DefragDestroy();\n return ret;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "safe"} {"code": "path_poly(PG_FUNCTION_ARGS)\n{\n\tPATH\t *path = PG_GETARG_PATH_P(0);\n\tPOLYGON *poly;\n\tint\t\t\tsize;\n\tint\t\t\ti;\n\n\t/* This is not very consistent --- other similar cases return NULL ... */\n\tif (!path->closed)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_PARAMETER_VALUE),\n\t\t\t\t errmsg(\"open path cannot be converted to polygon\")));\n\n\t/*\n\t * Never overflows: the old size fit in MaxAllocSize, and the new size is\n\t * just a small constant larger.\n\t */\n\tsize = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts;\n\tpoly = (POLYGON *) palloc(size);\n\n\tSET_VARSIZE(poly, size);\n\tpoly->npts = path->npts;\n\n\tfor (i = 0; i < path->npts; i++)\n\t{\n\t\tpoly->p[i].x = path->p[i].x;\n\t\tpoly->p[i].y = path->p[i].y;\n\t}\n\n\tmake_bound_box(poly);\n\n\tPG_RETURN_POLYGON_P(poly);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "safe"} {"code": "int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,\n\t\t uint8_t *dname, int dlen)\n{\n\tstruct ustr *filename, *unifilename;\n\tint len = 0;\n\n\tfilename = kmalloc(sizeof(struct ustr), GFP_NOFS);\n\tif (!filename)\n\t\treturn 0;\n\n\tunifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);\n\tif (!unifilename)\n\t\tgoto out1;\n\n\tif (udf_build_ustr_exact(unifilename, sname, slen))\n\t\tgoto out2;\n\n\tif (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {\n\t\tif (!udf_CS0toUTF8(filename, unifilename)) {\n\t\t\tudf_debug(\"Failed in udf_get_filename: sname = %s\\n\",\n\t\t\t\t sname);\n\t\t\tgoto out2;\n\t\t}\n\t} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {\n\t\tif (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,\n\t\t\t\t unifilename)) {\n\t\t\tudf_debug(\"Failed in udf_get_filename: sname = %s\\n\",\n\t\t\t\t sname);\n\t\t\tgoto out2;\n\t\t}\n\t} else\n\t\tgoto out2;\n\n\tlen = udf_translate_to_linux(dname, dlen,\n\t\t\t\t filename->u_name, filename->u_len,\n\t\t\t\t unifilename->u_name, unifilename->u_len);\nout2:\n\tkfree(unifilename);\nout1:\n\tkfree(filename);\n\treturn len;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-17", "cwe_name": "DEPRECATED: Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/17.html", "label_name": "safe"} {"code": "mrb_f_send(mrb_state *mrb, mrb_value self)\n{\n mrb_sym name;\n mrb_value block, *regs;\n mrb_method_t m;\n struct RClass *c;\n mrb_callinfo *ci = mrb->c->ci;\n int n = ci->n;\n\n if (ci->cci > CINFO_NONE) {\n funcall:;\n const mrb_value *argv;\n mrb_int argc;\n mrb_get_args(mrb, \"n*&\", &name, &argv, &argc, &block);\n return mrb_funcall_with_block(mrb, self, name, argc, argv, block);\n }\n\n regs = mrb->c->ci->stack+1;\n\n if (n == 0) {\n argnum_error:\n mrb_argnum_error(mrb, 0, 1, -1);\n }\n else if (n == 15) {\n if (RARRAY_LEN(regs[0]) == 0) goto argnum_error;\n name = mrb_obj_to_sym(mrb, RARRAY_PTR(regs[0])[0]);\n }\n else {\n name = mrb_obj_to_sym(mrb, regs[0]);\n }\n\n c = mrb_class(mrb, self);\n m = mrb_method_search_vm(mrb, &c, name);\n if (MRB_METHOD_UNDEF_P(m)) { /* call method_mising */\n goto funcall;\n }\n\n ci->mid = name;\n ci->u.target_class = c;\n /* remove first symbol from arguments */\n if (n == 15) { /* variable length arguments */\n regs[0] = mrb_ary_subseq(mrb, regs[0], 1, RARRAY_LEN(regs[0]) - 1);\n }\n else { /* n > 0 */\n for (int i=0; ink > 0) {\n regs[n+1] = regs[n+2]; /* copy block */\n }\n ci->n--;\n }\n\n if (MRB_METHOD_CFUNC_P(m)) {\n if (MRB_METHOD_NOARG_P(m)) {\n check_method_noarg(mrb, ci);\n }\n\n if (MRB_METHOD_PROC_P(m)) {\n mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n }\n return MRB_METHOD_CFUNC(m)(mrb, self);\n }\n return exec_irep(mrb, self, MRB_METHOD_PROC(m));\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-122", "cwe_name": "Heap-based Buffer Overflow", "description": "A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().", "url": "https://cwe.mitre.org/data/definitions/122.html", "label_name": "safe"} {"code": "static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data)\n{\n struct Context *ctx = (struct Context *) data;\n if (!ctx)\n return -1;\n struct PopData *pop_data = (struct PopData *) ctx->data;\n if (!pop_data)\n return -1;\n\n#ifdef USE_HCACHE\n /* keep hcache file if hcache == bcache */\n if (strcmp(HC_FNAME \".\" HC_FEXT, id) == 0)\n return 0;\n#endif\n\n for (int i = 0; i < ctx->msgcount; i++)\n {\n /* if the id we get is known for a header: done (i.e. keep in cache) */\n if (ctx->hdrs[i]->data && (mutt_str_strcmp(ctx->hdrs[i]->data, id) == 0))\n return 0;\n }\n\n /* message not found in context -> remove it from cache\n * return the result of bcache, so we stop upon its first error\n */\n return mutt_bcache_del(bcache, cache_id(id));\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int get_exif_tag_dbl_value(struct iw_exif_state *e, unsigned int tag_pos,\n\tdouble *pv)\n{\n\tunsigned int field_type;\n\tunsigned int value_count;\n\tunsigned int value_pos;\n\tunsigned int numer, denom;\n\n\tfield_type = iw_get_ui16_e(&e->d[tag_pos+2],e->endian);\n\tvalue_count = iw_get_ui32_e(&e->d[tag_pos+4],e->endian);\n\n\tif(value_count!=1) return 0;\n\n\tif(field_type!=5) return 0; // 5=Rational (two uint32's)\n\n\t// A rational is 8 bytes. Since 8>4, it is stored indirectly. First, read\n\t// the location where it is stored.\n\n\tvalue_pos = iw_get_ui32_e(&e->d[tag_pos+8],e->endian);\n\tif(value_pos > e->d_len-8) return 0;\n\n\t// Read the actual value.\n\tnumer = iw_get_ui32_e(&e->d[value_pos ],e->endian);\n\tdenom = iw_get_ui32_e(&e->d[value_pos+4],e->endian);\n\tif(denom==0) return 0;\n\n\t*pv = ((double)numer)/denom;\n\treturn 1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "dhcpv4_print(netdissect_options *ndo,\n const u_char *cp, u_int length, int indent)\n{\n u_int i, t;\n const u_char *tlv, *value;\n uint8_t type, optlen;\n\n i = 0;\n while (i < length) {\n if (i + 2 > length)\n return -1;\n tlv = cp + i;\n type = (uint8_t)tlv[0];\n optlen = (uint8_t)tlv[1];\n value = tlv + 2;\n\n ND_PRINT((ndo, \"\\n\"));\n for (t = indent; t > 0; t--)\n ND_PRINT((ndo, \"\\t\"));\n\n ND_PRINT((ndo, \"%s\", tok2str(dh4opt_str, \"Unknown\", type)));\n ND_PRINT((ndo,\" (%u)\", optlen + 2 ));\n if (i + 2 + optlen > length)\n return -1;\n\n switch (type) {\n case DH4OPT_DNS_SERVERS:\n case DH4OPT_NTP_SERVERS: {\n if (optlen < 4 || optlen % 4 != 0) {\n return -1;\n }\n for (t = 0; t < optlen; t += 4)\n ND_PRINT((ndo, \" %s\", ipaddr_string(ndo, value + t)));\n }\n break;\n case DH4OPT_DOMAIN_SEARCH: {\n const u_char *tp = value;\n while (tp < value + optlen) {\n ND_PRINT((ndo, \" \"));\n if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL)\n return -1;\n }\n }\n break;\n }\n\n i += 2 + optlen;\n }\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static void parseContentCompress(HttpRoute *route, cchar *key, MprJson *prop)\n{\n MprJson *child;\n int ji;\n\n for (ITERATE_CONFIG(route, prop, child, ji)) {\n if (mprGetJson(route->config, sfmt(\"app.http.content.minify[@ = '%s']\", child->value))) {\n httpAddRouteMapping(route, child->value, \"${1}.gz, min.${1}.gz, min.${1}\");\n } else {\n httpAddRouteMapping(route, child->value, \"${1}.gz\");\n }\n }\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,\n\t\tsize_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct atm_vcc *vcc;\n\tstruct sk_buff *skb;\n\tint copied, error = -EINVAL;\n\n\tmsg->msg_namelen = 0;\n\n\tif (sock->state != SS_CONNECTED)\n\t\treturn -ENOTCONN;\n\n\t/* only handle MSG_DONTWAIT and MSG_PEEK */\n\tif (flags & ~(MSG_DONTWAIT | MSG_PEEK))\n\t\treturn -EOPNOTSUPP;\n\n\tvcc = ATM_SD(sock);\n\tif (test_bit(ATM_VF_RELEASED, &vcc->flags) ||\n\t test_bit(ATM_VF_CLOSE, &vcc->flags) ||\n\t !test_bit(ATM_VF_READY, &vcc->flags))\n\t\treturn 0;\n\n\tskb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &error);\n\tif (!skb)\n\t\treturn error;\n\n\tcopied = skb->len;\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\terror = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (error)\n\t\treturn error;\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\tif (!(flags & MSG_PEEK)) {\n\t\tpr_debug(\"%d -= %d\\n\", atomic_read(&sk->sk_rmem_alloc),\n\t\t\t skb->truesize);\n\t\tatm_return(vcc, skb->truesize);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\treturn copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static void nfs4_close_done(struct rpc_task *task, void *data)\n{\n\tstruct nfs4_closedata *calldata = data;\n\tstruct nfs4_state *state = calldata->state;\n\tstruct nfs_server *server = NFS_SERVER(calldata->inode);\n\n\tif (RPC_ASSASSINATED(task))\n\t\treturn;\n /* hmm. we are done with the inode, and in the process of freeing\n\t * the state_owner. we keep this around to process errors\n\t */\n\tswitch (task->tk_status) {\n\t\tcase 0:\n\t\t\tnfs_set_open_stateid(state, &calldata->res.stateid, 0);\n\t\t\trenew_lease(server, calldata->timestamp);\n\t\t\tbreak;\n\t\tcase -NFS4ERR_STALE_STATEID:\n\t\tcase -NFS4ERR_OLD_STATEID:\n\t\tcase -NFS4ERR_BAD_STATEID:\n\t\tcase -NFS4ERR_EXPIRED:\n\t\t\tif (calldata->arg.open_flags == 0)\n\t\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (nfs4_async_handle_error(task, server, state) == -EAGAIN) {\n\t\t\t\trpc_restart_call(task);\n\t\t\t\treturn;\n\t\t\t}\n\t}\n\tnfs_refresh_inode(calldata->inode, calldata->res.fattr);\n}", "label": 0, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "static void parseServerAccount(HttpRoute *route, cchar *key, MprJson *prop)\n{\n cchar *value;\n\n if ((value = mprReadJson(prop, \"user\")) != 0) {\n if (!smatch(value, \"_unchanged_\") && !mprGetDebugMode()) {\n httpSetGroupAccount(value);\n }\n }\n if ((value = mprReadJson(prop, \"user\")) != 0) {\n if (!smatch(value, \"_unchanged_\") && !mprGetDebugMode()) {\n httpSetUserAccount(value);\n }\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "zfs_fastaccesschk_execute(znode_t *zdp, cred_t *cr)\n{\n\tboolean_t owner = B_FALSE;\n\tboolean_t groupmbr = B_FALSE;\n\tboolean_t is_attr;\n\tuid_t uid = crgetuid(cr);\n\n\tif (zdp->z_pflags & ZFS_AV_QUARANTINED)\n\t\treturn (1);\n\n\tis_attr = ((zdp->z_pflags & ZFS_XATTR) &&\n\t (ZTOV(zdp)->v_type == VDIR));\n\tif (is_attr)\n\t\treturn (1);\n\n\tif (zdp->z_pflags & ZFS_NO_EXECS_DENIED)\n\t\treturn (0);\n\n\tmutex_enter(&zdp->z_acl_lock);\n\tif (FUID_INDEX(zdp->z_uid) != 0 || FUID_INDEX(zdp->z_gid) != 0) {\n\t\tgoto out_slow;\n\t}\n\n\tif (uid == zdp->z_uid) {\n\t\towner = B_TRUE;\n\t\tif (zdp->z_mode & S_IXUSR) {\n\t\t\tgoto out;\n\t\t} else {\n\t\t\tgoto out_slow;\n\t\t}\n\t}\n\tif (groupmember(zdp->z_gid, cr)) {\n\t\tgroupmbr = B_TRUE;\n\t\tif (zdp->z_mode & S_IXGRP) {\n\t\t\tgoto out;\n\t\t} else {\n\t\t\tgoto out_slow;\n\t\t}\n\t}\n\tif (!owner && !groupmbr) {\n\t\tif (zdp->z_mode & S_IXOTH) {\n\t\t\tgoto out;\n\t\t}\n\t}\nout:\n\tmutex_exit(&zdp->z_acl_lock);\n\treturn (0);\nout_slow:\n\tmutex_exit(&zdp->z_acl_lock);\n\treturn (1);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": "mcs_parse_domain_params(STREAM s)\n{\n\tint length;\n\n\tber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);\n\tin_uint8s(s, length);\n\n\treturn s_check(s);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static void youngcollection (lua_State *L, global_State *g) {\n GCObject **psurvival; /* to point to first non-dead survival object */\n lua_assert(g->gcstate == GCSpropagate);\n markold(g, g->survival, g->reallyold);\n markold(g, g->finobj, g->finobjrold);\n atomic(L);\n\n /* sweep nursery and get a pointer to its last live element */\n psurvival = sweepgen(L, g, &g->allgc, g->survival);\n /* sweep 'survival' and 'old' */\n sweepgen(L, g, psurvival, g->reallyold);\n g->reallyold = g->old;\n g->old = *psurvival; /* 'survival' survivals are old now */\n g->survival = g->allgc; /* all news are survivals */\n\n /* repeat for 'finobj' lists */\n psurvival = sweepgen(L, g, &g->finobj, g->finobjsur);\n /* sweep 'survival' and 'old' */\n sweepgen(L, g, psurvival, g->finobjrold);\n g->finobjrold = g->finobjold;\n g->finobjold = *psurvival; /* 'survival' survivals are old now */\n g->finobjsur = g->finobj; /* all news are survivals */\n\n sweepgen(L, g, &g->tobefnz, NULL);\n\n finishgencycle(L, g);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt)\n{\n\tstruct f_midi *midi = func_to_midi(f);\n\tunsigned i;\n\tint err;\n\n\t/* we only set alt for MIDIStreaming interface */\n\tif (intf != midi->ms_id)\n\t\treturn 0;\n\n\terr = f_midi_start_ep(midi, f, midi->in_ep);\n\tif (err)\n\t\treturn err;\n\n\terr = f_midi_start_ep(midi, f, midi->out_ep);\n\tif (err)\n\t\treturn err;\n\n\t/* pre-allocate write usb requests to use on f_midi_transmit. */\n\twhile (kfifo_avail(&midi->in_req_fifo)) {\n\t\tstruct usb_request *req =\n\t\t\tmidi_alloc_ep_req(midi->in_ep, midi->buflen);\n\n\t\tif (req == NULL)\n\t\t\treturn -ENOMEM;\n\n\t\treq->length = 0;\n\t\treq->complete = f_midi_complete;\n\n\t\tkfifo_put(&midi->in_req_fifo, req);\n\t}\n\n\t/* allocate a bunch of read buffers and queue them all at once. */\n\tfor (i = 0; i < midi->qlen && err == 0; i++) {\n\t\tstruct usb_request *req =\n\t\t\tmidi_alloc_ep_req(midi->out_ep, midi->buflen);\n\n\t\tif (req == NULL)\n\t\t\treturn -ENOMEM;\n\n\t\treq->complete = f_midi_complete;\n\t\terr = usb_ep_queue(midi->out_ep, req, GFP_ATOMIC);\n\t\tif (err) {\n\t\t\tERROR(midi, \"%s: couldn't enqueue request: %d\\n\",\n\t\t\t\t midi->out_ep->name, err);\n\t\t\tif (req->buf != NULL)\n\t\t\t\tfree_ep_req(midi->out_ep, req);\n\t\t\treturn err;\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-415", "cwe_name": "Double Free", "description": "The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.", "url": "https://cwe.mitre.org/data/definitions/415.html", "label_name": "safe"} {"code": "horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)\n{\n\ttmsize_t stride = PredictorState(tif)->stride;\n\n\tunsigned char* cp = (unsigned char*) cp0;\n if((cc%stride)!=0)\n {\n TIFFErrorExt(tif->tif_clientdata, \"horAcc8\",\n \"%s\", \"(cc%stride)!=0\");\n return 0;\n }\n\n\tif (cc > stride) {\n\t\t/*\n\t\t * Pipeline the most common cases.\n\t\t */\n\t\tif (stride == 3) {\n\t\t\tunsigned int cr = cp[0];\n\t\t\tunsigned int cg = cp[1];\n\t\t\tunsigned int cb = cp[2];\n\t\t\tcc -= 3;\n\t\t\tcp += 3;\n\t\t\twhile (cc>0) {\n\t\t\t\tcp[0] = (unsigned char) ((cr += cp[0]) & 0xff);\n\t\t\t\tcp[1] = (unsigned char) ((cg += cp[1]) & 0xff);\n\t\t\t\tcp[2] = (unsigned char) ((cb += cp[2]) & 0xff);\n\t\t\t\tcc -= 3;\n\t\t\t\tcp += 3;\n\t\t\t}\n\t\t} else if (stride == 4) {\n\t\t\tunsigned int cr = cp[0];\n\t\t\tunsigned int cg = cp[1];\n\t\t\tunsigned int cb = cp[2];\n\t\t\tunsigned int ca = cp[3];\n\t\t\tcc -= 4;\n\t\t\tcp += 4;\n\t\t\twhile (cc>0) {\n\t\t\t\tcp[0] = (unsigned char) ((cr += cp[0]) & 0xff);\n\t\t\t\tcp[1] = (unsigned char) ((cg += cp[1]) & 0xff);\n\t\t\t\tcp[2] = (unsigned char) ((cb += cp[2]) & 0xff);\n\t\t\t\tcp[3] = (unsigned char) ((ca += cp[3]) & 0xff);\n\t\t\t\tcc -= 4;\n\t\t\t\tcp += 4;\n\t\t\t}\n\t\t} else {\n\t\t\tcc -= stride;\n\t\t\tdo {\n\t\t\t\tREPEAT4(stride, cp[stride] =\n\t\t\t\t\t(unsigned char) ((cp[stride] + *cp) & 0xff); cp++)\n\t\t\t\tcc -= stride;\n\t\t\t} while (cc>0);\n\t\t}\n\t}\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,\n\t\t\t size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name;\n\tstruct ddpehdr *ddp;\n\tint copied = 0;\n\tint offset = 0;\n\tint err = 0;\n\tstruct sk_buff *skb;\n\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\t\t\tflags & MSG_DONTWAIT, &err);\n\tlock_sock(sk);\n\n\tif (!skb)\n\t\tgoto out;\n\n\t/* FIXME: use skb->cb to be able to use shared skbs */\n\tddp = ddp_hdr(skb);\n\tcopied = ntohs(ddp->deh_len_hops) & 1023;\n\n\tif (sk->sk_type != SOCK_RAW) {\n\t\toffset = sizeof(*ddp);\n\t\tcopied -= offset;\n\t}\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\terr = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied);\n\n\tif (!err) {\n\t\tif (sat) {\n\t\t\tsat->sat_family = AF_APPLETALK;\n\t\t\tsat->sat_port = ddp->deh_sport;\n\t\t\tsat->sat_addr.s_node = ddp->deh_snode;\n\t\t\tsat->sat_addr.s_net = ddp->deh_snet;\n\t\t}\n\t\tmsg->msg_namelen = sizeof(*sat);\n\t}\n\n\tskb_free_datagram(sk, skb);\t/* Free the datagram. */\n\nout:\n\trelease_sock(sk);\n\treturn err ? : copied;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int skcipher_accept_parent(void *private, struct sock *sk)\n{\n\tstruct skcipher_ctx *ctx;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_tfm *tfm = private;\n\tstruct crypto_skcipher *skcipher = tfm->skcipher;\n\tunsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(skcipher);\n\n\tif (!tfm->has_key)\n\t\treturn -ENOKEY;\n\n\tctx = sock_kmalloc(sk, len, GFP_KERNEL);\n\tif (!ctx)\n\t\treturn -ENOMEM;\n\n\tctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(skcipher),\n\t\t\t GFP_KERNEL);\n\tif (!ctx->iv) {\n\t\tsock_kfree_s(sk, ctx, len);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(ctx->iv, 0, crypto_skcipher_ivsize(skcipher));\n\n\tINIT_LIST_HEAD(&ctx->tsgl);\n\tctx->len = len;\n\tctx->used = 0;\n\tctx->more = 0;\n\tctx->merge = 0;\n\tctx->enc = 0;\n\tatomic_set(&ctx->inflight, 0);\n\taf_alg_init_completion(&ctx->completion);\n\n\task->private = ctx;\n\n\tskcipher_request_set_tfm(&ctx->req, skcipher);\n\tskcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG,\n\t\t\t\t af_alg_complete, &ctx->completion);\n\n\tsk->sk_destruct = skcipher_sock_destruct;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "static void perf_event_for_each(struct perf_event *event,\n\t\t\t\t void (*func)(struct perf_event *))\n{\n\tstruct perf_event_context *ctx = event->ctx;\n\tstruct perf_event *sibling;\n\n\tWARN_ON_ONCE(ctx->parent_ctx);\n\tmutex_lock(&ctx->mutex);\n\tevent = event->group_leader;\n\n\tperf_event_for_each_child(event, func);\n\tlist_for_each_entry(sibling, &event->sibling_list, group_entry)\n\t\tperf_event_for_each_child(sibling, func);\n\tmutex_unlock(&ctx->mutex);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "int socket_create(uint16_t port)\n{\n\tint sfd = -1;\n\tint yes = 1;\n#ifdef WIN32\n\tWSADATA wsa_data;\n\tif (!wsa_init) {\n\t\tif (WSAStartup(MAKEWORD(2,2), &wsa_data) != ERROR_SUCCESS) {\n\t\t\tfprintf(stderr, \"WSAStartup failed!\\n\");\n\t\t\tExitProcess(-1);\n\t\t}\n\t\twsa_init = 1;\n\t}\n#endif\n\tstruct sockaddr_in saddr;\n\n\tif (0 > (sfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))) {\n\t\tperror(\"socket()\");\n\t\treturn -1;\n\t}\n\n\tif (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void*)&yes, sizeof(int)) == -1) {\n\t\tperror(\"setsockopt()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n#ifdef SO_NOSIGPIPE\n\tif (setsockopt(sfd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&yes, sizeof(int)) == -1) {\n\t\tperror(\"setsockopt()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n#endif\n\n\tmemset((void *) &saddr, 0, sizeof(saddr));\n\tsaddr.sin_family = AF_INET;\n\tsaddr.sin_addr.s_addr = htonl(INADDR_ANY);\n\tsaddr.sin_port = htons(port);\n\n\tif (0 > bind(sfd, (struct sockaddr *) &saddr, sizeof(saddr))) {\n\t\tperror(\"bind()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n\tif (listen(sfd, 1) == -1) {\n\t\tperror(\"listen()\");\n\t\tsocket_close(sfd);\n\t\treturn -1;\n\t}\n\n\treturn sfd;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "vulnerable"} {"code": "struct pipe_inode_info *alloc_pipe_info(void)\n{\n\tstruct pipe_inode_info *pipe;\n\n\tpipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);\n\tif (pipe) {\n\t\tunsigned long pipe_bufs = PIPE_DEF_BUFFERS;\n\t\tstruct user_struct *user = get_current_user();\n\n\t\tif (!too_many_pipe_buffers_hard(user)) {\n\t\t\tif (too_many_pipe_buffers_soft(user))\n\t\t\t\tpipe_bufs = 1;\n\t\t\tpipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);\n\t\t}\n\n\t\tif (pipe->bufs) {\n\t\t\tinit_waitqueue_head(&pipe->wait);\n\t\t\tpipe->r_counter = pipe->w_counter = 1;\n\t\t\tpipe->buffers = pipe_bufs;\n\t\t\tpipe->user = user;\n\t\t\taccount_pipe_buffers(pipe, 0, pipe_bufs);\n\t\t\tmutex_init(&pipe->mutex);\n\t\t\treturn pipe;\n\t\t}\n\t\tfree_uid(user);\n\t\tkfree(pipe);\n\t}\n\n\treturn NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "int x86_decode_emulated_instruction(struct kvm_vcpu *vcpu, int emulation_type,\n\t\t\t\t void *insn, int insn_len)\n{\n\tint r = EMULATION_OK;\n\tstruct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt;\n\n\tinit_emulate_ctxt(vcpu);\n\n\t/*\n\t * We will reenter on the same instruction since we do not set\n\t * complete_userspace_io. This does not handle watchpoints yet,\n\t * those would be handled in the emulate_ops.\n\t */\n\tif (!(emulation_type & EMULTYPE_SKIP) &&\n\t kvm_vcpu_check_breakpoint(vcpu, &r))\n\t\treturn r;\n\n\tr = x86_decode_insn(ctxt, insn, insn_len, emulation_type);\n\n\ttrace_kvm_emulate_insn_start(vcpu);\n\t++vcpu->stat.insn_emulation;\n\n\treturn r;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static int __init init_ext2_fs(void)\n{\n\tint err = init_ext2_xattr();\n\tif (err)\n\t\treturn err;\n\terr = init_inodecache();\n\tif (err)\n\t\tgoto out1;\n err = register_filesystem(&ext2_fs_type);\n\tif (err)\n\t\tgoto out;\n\treturn 0;\nout:\n\tdestroy_inodecache();\nout1:\n\texit_ext2_xattr();\n\treturn err;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "vulnerable"} {"code": "int ZEXPORT deflatePrime (strm, bits, value)\n z_streamp strm;\n int bits;\n int value;\n{\n deflate_state *s;\n int put;\n\n if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n s = strm->state;\n if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))\n return Z_BUF_ERROR;\n do {\n put = Buf_size - s->bi_valid;\n if (put > bits)\n put = bits;\n s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);\n s->bi_valid += put;\n _tr_flush_bits(s);\n value >>= put;\n bits -= put;\n } while (bits);\n return Z_OK;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)\n{\n\tstruct mm_struct *mm;\n\n\t/* convert pages-jiffies to Mbyte-usec */\n\tstats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB;\n\tstats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB;\n\tmm = get_task_mm(p);\n\tif (mm) {\n\t\t/* adjust to KB unit */\n\t\tstats->hiwater_rss = mm->hiwater_rss * PAGE_SIZE / KB;\n\t\tstats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;\n\t\tmmput(mm);\n\t}\n\tstats->read_char\t= p->rchar;\n\tstats->write_char\t= p->wchar;\n\tstats->read_syscalls\t= p->syscr;\n\tstats->write_syscalls\t= p->syscw;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,\n\t\t\t size_t sec_attr_len)\n{\n\tu8 *tmp;\n\tif (!sc_file_valid(file)) {\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\t}\n\n\tif (sec_attr == NULL || sec_attr_len) {\n\t\tif (file->sec_attr != NULL)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn 0;\n\t }\n\ttmp = (u8 *) realloc(file->sec_attr, sec_attr_len);\n\tif (!tmp) {\n\t\tif (file->sec_attr)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\tfile->sec_attr = tmp;\n\tmemcpy(file->sec_attr, sec_attr, sec_attr_len);\n\tfile->sec_attr_len = sec_attr_len;\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "process_open(u_int32_t id)\n{\n\tu_int32_t pflags;\n\tAttrib a;\n\tchar *name;\n\tint r, handle, fd, flags, mode, status = SSH2_FX_FAILURE;\n\n\tif ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||\n\t (r = sshbuf_get_u32(iqueue, &pflags)) != 0 || /* portable flags */\n\t (r = decode_attrib(iqueue, &a)) != 0)\n\t\tfatal(\"%s: buffer error: %s\", __func__, ssh_err(r));\n\n\tdebug3(\"request %u: open flags %d\", id, pflags);\n\tflags = flags_from_portable(pflags);\n\tmode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a.perm : 0666;\n\tlogit(\"open \\\"%s\\\" flags %s mode 0%o\",\n\t name, string_from_portable(pflags), mode);\n\tif (readonly &&\n\t ((flags & O_ACCMODE) != O_RDONLY ||\n\t (flags & (O_CREAT|O_TRUNC)) != 0)) {\n\t\tverbose(\"Refusing open request in read-only mode\");\n\t\tstatus = SSH2_FX_PERMISSION_DENIED;\n\t} else {\n\t\tfd = open(name, flags, mode);\n\t\tif (fd < 0) {\n\t\t\tstatus = errno_to_portable(errno);\n\t\t} else {\n\t\t\thandle = handle_new(HANDLE_FILE, name, fd, flags, NULL);\n\t\t\tif (handle < 0) {\n\t\t\t\tclose(fd);\n\t\t\t} else {\n\t\t\t\tsend_handle(id, handle);\n\t\t\t\tstatus = SSH2_FX_OK;\n\t\t\t}\n\t\t}\n\t}\n\tif (status != SSH2_FX_OK)\n\t\tsend_status(id, status);\n\tfree(name);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-732", "cwe_name": "Incorrect Permission Assignment for Critical Resource", "description": "The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.", "url": "https://cwe.mitre.org/data/definitions/732.html", "label_name": "safe"} {"code": "mono_gc_reference_queue_add (MonoReferenceQueue *queue, MonoObject *obj, void *user_data)\n{\n\tRefQueueEntry *head;\n\tRefQueueEntry *entry;\n\tif (queue->should_be_deleted)\n\t\treturn FALSE;\n\n\tentry = g_new0 (RefQueueEntry, 1);\n\tentry->user_data = user_data;\n\tmono_gc_weak_link_add (&entry->dis_link, obj, TRUE);\n\tref_list_push (&queue->queue, entry);\n\treturn TRUE;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC)\n{\n\tsize_t retlen;\n\tchar *ret;\n\tenum entity_charset charset;\n\tconst entity_ht *inverse_map = NULL;\n\tsize_t new_size = TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(oldlen);\n\n\tif (all) {\n\t\tcharset = determine_charset(hint_charset TSRMLS_CC);\n\t} else {\n\t\tcharset = cs_8859_1; /* charset shouldn't matter, use ISO-8859-1 for performance */\n\t}\n\n\t/* don't use LIMIT_ALL! */\n\n\tif (oldlen > new_size) {\n\t\t/* overflow, refuse to do anything */\n\t\tret = estrndup((char*)old, oldlen);\n\t\tretlen = oldlen;\n\t\tgoto empty_source;\n\t}\n\tret = emalloc(new_size);\n\t*ret = '\\0';\n\tretlen = oldlen;\n\tif (retlen == 0) {\n\t\tgoto empty_source;\n\t}\n\t\n\tinverse_map = unescape_inverse_map(all, flags);\n\t\n\t/* replace numeric entities */\n\ttraverse_for_entities(old, oldlen, ret, &retlen, all, flags, inverse_map, charset);\n\nempty_source:\t\n\t*newlen = retlen;\n\treturn ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "parse_ranges(struct client *clt, char *str, size_t file_sz)\n{\n\tint\t\t\t i = 0;\n\tchar\t\t\t*p, *q;\n\tstruct range_data\t*r = &clt->clt_ranges;\n\n\tmemset(r, 0, sizeof(*r));\n\n\t/* Extract range unit */\n\tif ((p = strchr(str, '=')) == NULL)\n\t\treturn (-1);\n\n\t*p++ = '\\0';\n\t/* Check if it's a bytes range spec */\n\tif (strcmp(str, \"bytes\") != 0)\n\t\treturn (-1);\n\n\twhile ((q = strchr(p, ',')) != NULL) {\n\t\t*q++ = '\\0';\n\n\t\t/* Extract start and end positions */\n\t\tif (parse_range_spec(p, file_sz, &r->range[i]) == 0)\n\t\t\tcontinue;\n\n\t\ti++;\n\t\tif (i == SERVER_MAX_RANGES)\n\t\t\treturn (-1);\n\n\t\tp = q;\n\t}\n\n\tif (parse_range_spec(p, file_sz, &r->range[i]) != 0)\n\t\ti++;\n\n\tr->range_total = file_sz;\n\tr->range_count = i;\n\treturn (i);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": "void rose_start_heartbeat(struct sock *sk)\n{\n\tsk_stop_timer(sk, &sk->sk_timer);\n\n\tsk->sk_timer.function = rose_heartbeat_expiry;\n\tsk->sk_timer.expires = jiffies + 5 * HZ;\n\n\tsk_reset_timer(sk, &sk->sk_timer, sk->sk_timer.expires);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "spnego_gss_pseudo_random(OM_uint32 *minor_status,\n\t\t\t gss_ctx_id_t context,\n\t\t\t int prf_key,\n\t\t\t const gss_buffer_t prf_in,\n\t\t\t ssize_t desired_output_len,\n\t\t\t gss_buffer_t prf_out)\n{\n\tOM_uint32 ret;\n\tret = gss_pseudo_random(minor_status,\n\t\t\t\tcontext,\n\t\t\t\tprf_key,\n\t\t\t\tprf_in,\n\t\t\t\tdesired_output_len,\n\t\t\t\tprf_out);\n return (ret);\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-763", "cwe_name": "Release of Invalid Pointer or Reference", "description": "The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.", "url": "https://cwe.mitre.org/data/definitions/763.html", "label_name": "vulnerable"} {"code": "int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size)\n{\n\tkuid_t euid;\n\tkgid_t egid;\n\tint id;\n\tint next_id = ids->next_id;\n\n\tif (size > IPCMNI)\n\t\tsize = IPCMNI;\n\n\tif (ids->in_use >= size)\n\t\treturn -ENOSPC;\n\n\tidr_preload(GFP_KERNEL);\n\n\tspin_lock_init(&new->lock);\n\tnew->deleted = false;\n\trcu_read_lock();\n\tspin_lock(&new->lock);\n\n\tid = idr_alloc(&ids->ipcs_idr, new,\n\t\t (next_id < 0) ? 0 : ipcid_to_idx(next_id), 0,\n\t\t GFP_NOWAIT);\n\tidr_preload_end();\n\tif (id < 0) {\n\t\tspin_unlock(&new->lock);\n\t\trcu_read_unlock();\n\t\treturn id;\n\t}\n\n\tids->in_use++;\n\n\tcurrent_euid_egid(&euid, &egid);\n\tnew->cuid = new->uid = euid;\n\tnew->gid = new->cgid = egid;\n\n\tif (next_id < 0) {\n\t\tnew->seq = ids->seq++;\n\t\tif (ids->seq > IPCID_SEQ_MAX)\n\t\t\tids->seq = 0;\n\t} else {\n\t\tnew->seq = ipcid_to_seqx(next_id);\n\t\tids->next_id = -1;\n\t}\n\n\tnew->id = ipc_buildid(id, new->seq);\n\treturn id;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static void resv_map_put(struct vm_area_struct *vma)\n{\n\tstruct resv_map *reservations = vma_resv_map(vma);\n\n\tif (!reservations)\n\t\treturn;\n\tkref_put(&reservations->refs, resv_map_release);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *m, size_t total_len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint error = 0;\n\n\tif (sk->sk_state & PPPOX_BOUND) {\n\t\terror = -EIO;\n\t\tgoto end;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,\n\t\t\t\tflags & MSG_DONTWAIT, &error);\n\tif (error < 0)\n\t\tgoto end;\n\n\tm->msg_namelen = 0;\n\n\tif (skb) {\n\t\ttotal_len = min_t(size_t, total_len, skb->len);\n\t\terror = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len);\n\t\tif (error == 0) {\n\t\t\tconsume_skb(skb);\n\t\t\treturn total_len;\n\t\t}\n\t}\n\n\tkfree_skb(skb);\nend:\n\treturn error;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "void put_filp(struct file *file)\n{\n\tif (atomic_long_dec_and_test(&file->f_count)) {\n\t\tsecurity_file_free(file);\n\t\tfile_sb_list_del(file);\n\t\tfile_free(file);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-17", "cwe_name": "DEPRECATED: Code", "description": "This entry has been deprecated. It was originally used for organizing the Development View (CWE-699) and some other views, but it introduced unnecessary complexity and depth to the resulting tree.", "url": "https://cwe.mitre.org/data/definitions/17.html", "label_name": "vulnerable"} {"code": "__be32 ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)\n{\n\tstruct in6_addr buf[2];\n\tstruct in6_addr *addrs;\n\tu32 id;\n\n\taddrs = skb_header_pointer(skb,\n\t\t\t\t skb_network_offset(skb) +\n\t\t\t\t offsetof(struct ipv6hdr, saddr),\n\t\t\t\t sizeof(buf), buf);\n\tif (!addrs)\n\t\treturn 0;\n\n\tid = __ipv6_select_ident(net, &addrs[1], &addrs[0]);\n\treturn htonl(id);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-326", "cwe_name": "Inadequate Encryption Strength", "description": "The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.", "url": "https://cwe.mitre.org/data/definitions/326.html", "label_name": "safe"} {"code": "static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_aead raead;\n\tstruct aead_alg *aead = &alg->cra_aead;\n\n\tsnprintf(raead.type, CRYPTO_MAX_ALG_NAME, \"%s\", \"aead\");\n\tsnprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, \"%s\",\n\t\t aead->geniv ?: \"\");\n\n\traead.blocksize = alg->cra_blocksize;\n\traead.maxauthsize = aead->maxauthsize;\n\traead.ivsize = aead->ivsize;\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_AEAD,\n\t\t sizeof(struct crypto_report_aead), &raead))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "static void expire_cfs_rq_runtime(struct cfs_rq *cfs_rq)\n{\n\tstruct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg);\n\n\t/* if the deadline is ahead of our clock, nothing to do */\n\tif (likely((s64)(rq_clock(rq_of(cfs_rq)) - cfs_rq->runtime_expires) < 0))\n\t\treturn;\n\n\tif (cfs_rq->runtime_remaining < 0)\n\t\treturn;\n\n\t/*\n\t * If the local deadline has passed we have to consider the\n\t * possibility that our sched_clock is 'fast' and the global deadline\n\t * has not truly expired.\n\t *\n\t * Fortunately we can check determine whether this the case by checking\n\t * whether the global deadline(cfs_b->expires_seq) has advanced.\n\t */\n\tif (cfs_rq->expires_seq == cfs_b->expires_seq) {\n\t\t/* extend local deadline, drift is bounded above by 2 ticks */\n\t\tcfs_rq->runtime_expires += TICK_NSEC;\n\t} else {\n\t\t/* global deadline is ahead, expiration has passed */\n\t\tcfs_rq->runtime_remaining = 0;\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "static void unix_copy_addr(struct msghdr *msg, struct sock *sk)\n{\n\tstruct unix_sock *u = unix_sk(sk);\n\n\tmsg->msg_namelen = 0;\n\tif (u->addr) {\n\t\tmsg->msg_namelen = u->addr->len;\n\t\tmemcpy(msg->msg_name, u->addr->name, u->addr->len);\n\t}\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "struct dst_entry *inet_csk_route_req(struct sock *sk,\n\t\t\t\t const struct request_sock *req)\n{\n\tstruct rtable *rt;\n\tconst struct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ip_options_rcu *opt = inet_rsk(req)->opt;\n\tstruct net *net = sock_net(sk);\n\tstruct flowi4 fl4;\n\n\tflowi4_init_output(&fl4, sk->sk_bound_dev_if, sk->sk_mark,\n\t\t\t RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,\n\t\t\t sk->sk_protocol, inet_sk_flowi_flags(sk),\n\t\t\t (opt && opt->opt.srr) ? opt->opt.faddr : ireq->rmt_addr,\n\t\t\t ireq->loc_addr, ireq->rmt_port, inet_sk(sk)->inet_sport);\n\tsecurity_req_classify_flow(req, flowi4_to_flowi(&fl4));\n\trt = ip_route_output_flow(net, &fl4, sk);\n\tif (IS_ERR(rt))\n\t\tgoto no_route;\n\tif (opt && opt->opt.is_strictroute && rt->rt_dst != rt->rt_gateway)\n\t\tgoto route_err;\n\treturn &rt->dst;\n\nroute_err:\n\tip_rt_put(rt);\nno_route:\n\tIP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);\n\treturn NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "static void vgacon_scrollback_reset(int vc_num, size_t reset_size)\n{\n\tstruct vgacon_scrollback_info *scrollback = &vgacon_scrollbacks[vc_num];\n\n\tif (scrollback->data && reset_size > 0)\n\t\tmemset(scrollback->data, 0, reset_size);\n\n\tscrollback->cnt = 0;\n\tscrollback->tail = 0;\n\tscrollback->cur = 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "void unix_notinflight(struct file *fp)\n{\n\tstruct sock *s = unix_get_socket(fp);\n\n\tspin_lock(&unix_gc_lock);\n\n\tif (s) {\n\t\tstruct unix_sock *u = unix_sk(s);\n\n\t\tBUG_ON(list_empty(&u->link));\n\n\t\tif (atomic_long_dec_and_test(&u->inflight))\n\t\t\tlist_del_init(&u->link);\n\t\tunix_tot_inflight--;\n\t}\n\tfp->f_cred->user->unix_inflight--;\n\tspin_unlock(&unix_gc_lock);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)\n{\n if (!ndo->ndo_vflag) {\n\tND_PRINT((ndo, \", RPKI-RTR\"));\n\treturn;\n }\n while (len) {\n\tu_int pdu_len = rpki_rtr_pdu_print(ndo, pptr, len, 1, 8);\n\tlen -= pdu_len;\n\tpptr += pdu_len;\n }\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "unsigned long lh_char_hash(const void *k)\n{\n\tunsigned int h = 0;\n\tconst char* data = (const char*)k;\n \n\twhile( *data!=0 ) h = h*129 + (unsigned int)(*data++) + LH_PRIME;\n\n\treturn h;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "int perf_event_task_disable(void)\n{\n\tstruct perf_event_context *ctx;\n\tstruct perf_event *event;\n\n\tmutex_lock(¤t->perf_event_mutex);\n\tlist_for_each_entry(event, ¤t->perf_event_list, owner_entry) {\n\t\tctx = perf_event_ctx_lock(event);\n\t\tperf_event_for_each_child(event, _perf_event_disable);\n\t\tperf_event_ctx_unlock(event, ctx);\n\t}\n\tmutex_unlock(¤t->perf_event_mutex);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "static int handle_invvpid(struct kvm_vcpu *vcpu)\n{\n\tkvm_queue_exception(vcpu, UD_VECTOR);\n\treturn 1;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "DefragVlanQinQTest(void)\n{\n Packet *p1 = NULL, *p2 = NULL, *r = NULL;\n int ret = 0;\n\n DefragInit();\n\n p1 = BuildTestPacket(1, 0, 1, 'A', 8);\n if (p1 == NULL)\n goto end;\n p2 = BuildTestPacket(1, 1, 0, 'B', 8);\n if (p2 == NULL)\n goto end;\n\n /* With no VLAN IDs set, packets should re-assemble. */\n if ((r = Defrag(NULL, NULL, p1, NULL)) != NULL)\n goto end;\n if ((r = Defrag(NULL, NULL, p2, NULL)) == NULL)\n goto end;\n SCFree(r);\n\n /* With mismatched VLANs, packets should not re-assemble. */\n p1->vlan_id[0] = 1;\n p2->vlan_id[0] = 1;\n p1->vlan_id[1] = 1;\n p2->vlan_id[1] = 2;\n if ((r = Defrag(NULL, NULL, p1, NULL)) != NULL)\n goto end;\n if ((r = Defrag(NULL, NULL, p2, NULL)) != NULL)\n goto end;\n\n /* Pass. */\n ret = 1;\n\nend:\n if (p1 != NULL)\n SCFree(p1);\n if (p2 != NULL)\n SCFree(p2);\n DefragDestroy();\n\n return ret;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-358", "cwe_name": "Improperly Implemented Security Check for Standard", "description": "The software does not implement or incorrectly implements one or more security-relevant checks as specified by the design of a standardized algorithm, protocol, or technique.", "url": "https://cwe.mitre.org/data/definitions/358.html", "label_name": "vulnerable"} {"code": "mrb_ary_shift_m(mrb_state *mrb, mrb_value self)\n{\n mrb_int n;\n\n if (mrb_get_args(mrb, \"|i\", &n) == 0) {\n return mrb_ary_shift(mrb, self);\n }\n\n struct RArray *a = mrb_ary_ptr(self);\n mrb_int len = ARY_LEN(a);\n mrb_value val;\n\n ary_modify_check(mrb, a);\n if (len == 0 || n == 0) return mrb_ary_new(mrb);\n if (n < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, \"negative array shift\");\n if (n > len) n = len;\n val = mrb_ary_new_from_values(mrb, n, ARY_PTR(a));\n if (ARY_SHARED_P(a)) {\n L_SHIFT:\n a->as.heap.ptr+=n;\n a->as.heap.len-=n;\n return val;\n }\n if (len > ARY_SHIFT_SHARED_MIN) {\n ary_make_shared(mrb, a);\n goto L_SHIFT;\n }\n else if (len == n) {\n ARY_SET_LEN(a, 0);\n }\n else {\n mrb_value *ptr = ARY_PTR(a);\n mrb_int size = len-n;\n\n while (size--) {\n *ptr = *(ptr+n);\n ++ptr;\n }\n ARY_SET_LEN(a, len-n);\n }\n return val;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "bool_t dm9000IrqHandler(NetInterface *interface)\n{\n bool_t flag;\n uint8_t status;\n uint8_t mask;\n Dm9000Context *context;\n\n //This flag will be set if a higher priority task must be woken\n flag = FALSE;\n\n //Point to the driver context\n context = (Dm9000Context *) interface->nicContext;\n\n //Read interrupt status register\n status = dm9000ReadReg(DM9000_REG_ISR);\n\n //Link status change?\n if((status & ISR_LNKCHG) != 0)\n {\n //Read interrupt mask register\n mask = dm9000ReadReg(DM9000_REG_IMR);\n //Disable LNKCHGI interrupt\n dm9000WriteReg(DM9000_REG_IMR, mask & ~IMR_LNKCHGI);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //Packet transmission complete?\n if((status & ISR_PT) != 0)\n {\n //Check TX complete status bits\n if(dm9000ReadReg(DM9000_REG_NSR) & (NSR_TX2END | NSR_TX1END))\n {\n //The transmission of the current packet is complete\n if(context->queuedPackets > 0)\n {\n context->queuedPackets--;\n }\n\n //Notify the TCP/IP stack that the transmitter is ready to send\n flag |= osSetEventFromIsr(&interface->nicTxEvent);\n }\n\n //Clear interrupt flag\n dm9000WriteReg(DM9000_REG_ISR, ISR_PT);\n }\n\n //Packet received?\n if((status & ISR_PR) != 0)\n {\n //Read interrupt mask register\n mask = dm9000ReadReg(DM9000_REG_IMR);\n //Disable PRI interrupt\n dm9000WriteReg(DM9000_REG_IMR, mask & ~IMR_PRI);\n\n //Set event flag\n interface->nicEvent = TRUE;\n //Notify the TCP/IP stack of the event\n flag |= osSetEventFromIsr(&netEvent);\n }\n\n //A higher priority task must be woken?\n return flag;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "int use_env()\n{\n int indent;\n size_t flags = 0;\n json_t *json;\n json_error_t error;\n\n #ifdef _WIN32\n /* On Windows, set stdout and stderr to binary mode to avoid\n outputting DOS line terminators */\n _setmode(_fileno(stdout), _O_BINARY);\n _setmode(_fileno(stderr), _O_BINARY);\n #endif\n\n indent = getenv_int(\"JSON_INDENT\");\n if(indent < 0 || indent > 255) {\n fprintf(stderr, \"invalid value for JSON_INDENT: %d\\n\", indent);\n return 2;\n }\n\n if(indent > 0)\n flags |= JSON_INDENT(indent);\n\n if(getenv_int(\"JSON_COMPACT\") > 0)\n flags |= JSON_COMPACT;\n\n if(getenv_int(\"JSON_ENSURE_ASCII\"))\n flags |= JSON_ENSURE_ASCII;\n\n if(getenv_int(\"JSON_PRESERVE_ORDER\"))\n flags |= JSON_PRESERVE_ORDER;\n\n if(getenv_int(\"JSON_SORT_KEYS\"))\n flags |= JSON_SORT_KEYS;\n\n if(getenv(\"HASHSEED\"))\n json_object_seed(getenv_int(\"HASHSEED\"));\n\n if(getenv_int(\"STRIP\")) {\n /* Load to memory, strip leading and trailing whitespace */\n size_t size = 0, used = 0;\n char *buffer = NULL;\n\n while(1) {\n size_t count;\n\n size = (size == 0 ? 128 : size * 2);\n buffer = realloc(buffer, size);\n if(!buffer) {\n fprintf(stderr, \"Unable to allocate %d bytes\\n\", (int)size);\n return 1;\n }\n\n count = fread(buffer + used, 1, size - used, stdin);\n if(count < size - used) {\n buffer[used + count] = '\\0';\n break;\n }\n used += count;\n }\n\n json = json_loads(strip(buffer), 0, &error);\n free(buffer);\n }\n else\n json = json_loadf(stdin, 0, &error);\n\n if(!json) {\n fprintf(stderr, \"%d %d %d\\n%s\\n\",\n error.line, error.column,\n error.position, error.text);\n return 1;\n }\n\n json_dumpf(json, stdout, flags);\n json_decref(json);\n\n return 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,\n\t\tstruct nfs4_state_owner *sp, fmode_t fmode, int flags,\n\t\tconst struct iattr *attrs)\n{\n\tstruct dentry *parent = dget_parent(path->dentry);\n\tstruct inode *dir = parent->d_inode;\n\tstruct nfs_server *server = NFS_SERVER(dir);\n\tstruct nfs4_opendata *p;\n\n\tp = kzalloc(sizeof(*p), GFP_KERNEL);\n\tif (p == NULL)\n\t\tgoto err;\n\tp->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid);\n\tif (p->o_arg.seqid == NULL)\n\t\tgoto err_free;\n\tp->path.mnt = mntget(path->mnt);\n\tp->path.dentry = dget(path->dentry);\n\tp->dir = parent;\n\tp->owner = sp;\n\tatomic_inc(&sp->so_count);\n\tp->o_arg.fh = NFS_FH(dir);\n\tp->o_arg.open_flags = flags;\n\tp->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);\n\tp->o_arg.clientid = server->nfs_client->cl_clientid;\n\tp->o_arg.id = sp->so_owner_id.id;\n\tp->o_arg.name = &p->path.dentry->d_name;\n\tp->o_arg.server = server;\n\tp->o_arg.bitmask = server->attr_bitmask;\n\tp->o_arg.claim = NFS4_OPEN_CLAIM_NULL;\n\tif (flags & O_EXCL) {\n\t\tu32 *s = (u32 *) p->o_arg.u.verifier.data;\n\t\ts[0] = jiffies;\n\t\ts[1] = current->pid;\n\t} else if (flags & O_CREAT) {\n\t\tp->o_arg.u.attrs = &p->attrs;\n\t\tmemcpy(&p->attrs, attrs, sizeof(p->attrs));\n\t}\n\tp->c_arg.fh = &p->o_res.fh;\n\tp->c_arg.stateid = &p->o_res.stateid;\n\tp->c_arg.seqid = p->o_arg.seqid;\n\tnfs4_init_opendata_res(p);\n\tkref_init(&p->kref);\n\treturn p;\nerr_free:\n\tkfree(p);\nerr:\n\tdput(parent);\n\treturn NULL;\n}", "label": 1, "programming_language": "C", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "snmp_ber_decode_unsigned_integer(unsigned char *buf, uint32_t *buff_len, uint8_t expected_type, uint32_t *num)\n{\n uint8_t i, len, type;\n\n buf = snmp_ber_decode_type(buf, buff_len, &type);\n\n if(buf == NULL || type != expected_type) {\n /*\n * Sanity check\n * Invalid type in buffer\n */\n return NULL;\n }\n\n buf = snmp_ber_decode_length(buf, buff_len, &len);\n\n if(buf == NULL || len > 4) {\n /*\n * Sanity check\n * It will not fit in the uint32_t\n */\n return NULL;\n }\n\n if(*buff_len < len) {\n return NULL;\n }\n\n *num = (uint32_t)(*buf++ & 0xFF);\n (*buff_len)--;\n for(i = 1; i < len; ++i) {\n *num <<= 8;\n *num |= (uint8_t)(*buf++ & 0xFF);\n (*buff_len)--;\n }\n\n return buf;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "GF_Box *encs_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MPEGSampleEntryBox, GF_ISOM_BOX_TYPE_ENCS);\n\tgf_isom_sample_entry_init((GF_SampleEntryBox*)tmp);\n\ttmp->internal_type = GF_ISOM_SAMPLE_ENTRY_MP4S;\n\treturn (GF_Box *)tmp;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "static bool ndp_msg_check_valid(struct ndp_msg *msg)\n{\n\tsize_t len = ndp_msg_payload_len(msg);\n\tenum ndp_msg_type msg_type = ndp_msg_type(msg);\n\n\tif (len < ndp_msg_type_info(msg_type)->raw_struct_size)\n\t\treturn false;\n\treturn true;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "vulnerable"} {"code": "batchCopyElem(batch_obj_t *pDest, batch_obj_t *pSrc) {\n\tmemcpy(pDest, pSrc, sizeof(batch_obj_t));\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-772", "cwe_name": "Missing Release of Resource after Effective Lifetime", "description": "The software does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.", "url": "https://cwe.mitre.org/data/definitions/772.html", "label_name": "vulnerable"} {"code": "static int mincore_unmapped_range(unsigned long addr, unsigned long end,\n\t\t\t\t struct mm_walk *walk)\n{\n\tunsigned char *vec = walk->private;\n\tunsigned long nr = (end - addr) >> PAGE_SHIFT;\n\n\tmemset(vec, 0, nr);\n\twalk->private += nr;\n\treturn 0;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-319", "cwe_name": "Cleartext Transmission of Sensitive Information", "description": "The software transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors.", "url": "https://cwe.mitre.org/data/definitions/319.html", "label_name": "safe"} {"code": "static int nf_conntrack_standalone_init_sysctl(struct net *net)\n{\n\tstruct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id);\n\tstruct nf_udp_net *un = nf_udp_pernet(net);\n\tstruct ctl_table *table;\n\n\tBUILD_BUG_ON(ARRAY_SIZE(nf_ct_sysctl_table) != NF_SYSCTL_CT_LAST_SYSCTL);\n\n\ttable = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),\n\t\t\tGFP_KERNEL);\n\tif (!table)\n\t\treturn -ENOMEM;\n\n\ttable[NF_SYSCTL_CT_COUNT].data = &net->ct.count;\n\ttable[NF_SYSCTL_CT_CHECKSUM].data = &net->ct.sysctl_checksum;\n\ttable[NF_SYSCTL_CT_LOG_INVALID].data = &net->ct.sysctl_log_invalid;\n\ttable[NF_SYSCTL_CT_ACCT].data = &net->ct.sysctl_acct;\n\ttable[NF_SYSCTL_CT_HELPER].data = &net->ct.sysctl_auto_assign_helper;\n#ifdef CONFIG_NF_CONNTRACK_EVENTS\n\ttable[NF_SYSCTL_CT_EVENTS].data = &net->ct.sysctl_events;\n#endif\n#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP\n\ttable[NF_SYSCTL_CT_TIMESTAMP].data = &net->ct.sysctl_tstamp;\n#endif\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_GENERIC].data = &nf_generic_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_ICMP].data = &nf_icmp_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_ICMPV6].data = &nf_icmpv6_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_UDP].data = &un->timeouts[UDP_CT_UNREPLIED];\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_UDP_STREAM].data = &un->timeouts[UDP_CT_REPLIED];\n\n\tnf_conntrack_standalone_init_tcp_sysctl(net, table);\n\tnf_conntrack_standalone_init_sctp_sysctl(net, table);\n\tnf_conntrack_standalone_init_dccp_sysctl(net, table);\n\tnf_conntrack_standalone_init_gre_sysctl(net, table);\n\n\t/* Don't allow non-init_net ns to alter global sysctls */\n\tif (!net_eq(&init_net, net)) {\n\t\ttable[NF_SYSCTL_CT_MAX].mode = 0444;\n\t\ttable[NF_SYSCTL_CT_EXPECT_MAX].mode = 0444;\n\t\ttable[NF_SYSCTL_CT_BUCKETS].mode = 0444;\n\t}\n\n\tcnet->sysctl_header = register_net_sysctl(net, \"net/netfilter\", table);\n\tif (!cnet->sysctl_header)\n\t\tgoto out_unregister_netfilter;\n\n\treturn 0;\n\nout_unregister_netfilter:\n\tkfree(table);\n\treturn -ENOMEM;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-203", "cwe_name": "Observable Discrepancy", "description": "The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.", "url": "https://cwe.mitre.org/data/definitions/203.html", "label_name": "safe"} {"code": "grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,\n\t\t void (*read_hook) (grub_disk_addr_t sector,\n\t\t\t\t\t unsigned offset,\n\t\t\t\t\t unsigned length,\n\t\t\t\t\t void *closure),\n\t\t void *closure, int flags,\n\t\t grub_off_t pos, grub_size_t len, char *buf,\n\t\t grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,\n\t\t\t\t\t\t grub_disk_addr_t block),\n\t\t grub_off_t filesize, int log2blocksize)\n{\n grub_disk_addr_t i, blockcnt;\n int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);\n\n /* Adjust LEN so it we can't read past the end of the file. */\n if (pos + len > filesize)\n len = filesize - pos;\n\n if (len < 1 || len == 0xffffffff) {\n return -1;\n }\n\n blockcnt = ((len + pos) + blocksize - 1) >>\n (log2blocksize + GRUB_DISK_SECTOR_BITS);\n\n for (i = pos >> (log2blocksize + GRUB_DISK_SECTOR_BITS); i < blockcnt; i++)\n {\n grub_disk_addr_t blknr;\n int blockoff = pos & (blocksize - 1);\n int blockend = blocksize;\n\n int skipfirst = 0;\n\n blknr = get_block (node, i);\n if (grub_errno)\n\treturn -1;\n\n blknr = blknr << log2blocksize;\n\n /* Last block. */\n if (i == blockcnt - 1)\n\t{\n\t blockend = (len + pos) & (blocksize - 1);\n\n\t /* The last portion is exactly blocksize. */\n\t if (! blockend)\n\t blockend = blocksize;\n\t}\n\n /* First block. */\n if (i == (pos >> (log2blocksize + GRUB_DISK_SECTOR_BITS)))\n\t{\n\t skipfirst = blockoff;\n\t blockend -= skipfirst;\n\t}\n\n /* If the block number is 0 this block is not stored on disk but\n\t is zero filled instead. */\n if (blknr)\n\t{\n\t disk->read_hook = read_hook;\n\t disk->closure = closure;\n\n//printf (\"blknr: %d\\n\", blknr);\ngrub_hack_lastoff = blknr * 512;\n\t grub_disk_read_ex (disk, blknr, skipfirst, blockend, buf, flags);\n\t disk->read_hook = 0;\n\t if (grub_errno)\n\t return -1;\n\t}\n else if (buf)\n\tgrub_memset (buf, 0, blockend);\n\n if (buf)\n\tbuf += blocksize - skipfirst;\n }\n\n return len;\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void rose_start_hbtimer(struct sock *sk)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\n\tsk_stop_timer(sk, &rose->timer);\n\n\trose->timer.function = rose_timer_expiry;\n\trose->timer.expires = jiffies + rose->hb;\n\n\tsk_reset_timer(sk, &rose->timer, rose->timer.expires);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "void imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_backtick)\n{\n const char *quote = \"`\\\"\\\\\";\n if (!quote_backtick)\n quote++;\n\n char *pt = dest;\n const char *s = src;\n\n *pt++ = '\"';\n /* save room for quote-chars */\n dlen -= 3;\n\n for (; *s && dlen; s++)\n {\n if (strchr(quote, *s))\n {\n if (dlen < 2)\n break;\n dlen -= 2;\n *pt++ = '\\\\';\n *pt++ = *s;\n }\n else\n {\n *pt++ = *s;\n dlen--;\n }\n }\n *pt++ = '\"';\n *pt = '\\0';\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static int kvm_ioctl_create_device(struct kvm *kvm,\n\t\t\t\t struct kvm_create_device *cd)\n{\n\tstruct kvm_device_ops *ops = NULL;\n\tstruct kvm_device *dev;\n\tbool test = cd->flags & KVM_CREATE_DEVICE_TEST;\n\tint ret;\n\n\tif (cd->type >= ARRAY_SIZE(kvm_device_ops_table))\n\t\treturn -ENODEV;\n\n\tops = kvm_device_ops_table[cd->type];\n\tif (ops == NULL)\n\t\treturn -ENODEV;\n\n\tif (test)\n\t\treturn 0;\n\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev)\n\t\treturn -ENOMEM;\n\n\tdev->ops = ops;\n\tdev->kvm = kvm;\n\n\tmutex_lock(&kvm->lock);\n\tret = ops->create(dev, cd->type);\n\tif (ret < 0) {\n\t\tmutex_unlock(&kvm->lock);\n\t\tkfree(dev);\n\t\treturn ret;\n\t}\n\tlist_add(&dev->vm_node, &kvm->devices);\n\tmutex_unlock(&kvm->lock);\n\n\tif (ops->init)\n\t\tops->init(dev);\n\n\tret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);\n\tif (ret < 0) {\n\t\tops->destroy(dev);\n\t\tmutex_lock(&kvm->lock);\n\t\tlist_del(&dev->vm_node);\n\t\tmutex_unlock(&kvm->lock);\n\t\treturn ret;\n\t}\n\n\tkvm_get_kvm(kvm);\n\tcd->fd = ret;\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "count_comp_fors(struct compiling *c, const node *n)\n{\n int n_fors = 0;\n int is_async;\n\n count_comp_for:\n is_async = 0;\n n_fors++;\n REQ(n, comp_for);\n if (TYPE(CHILD(n, 0)) == ASYNC) {\n is_async = 1;\n }\n if (NCH(n) == (5 + is_async)) {\n n = CHILD(n, 4 + is_async);\n }\n else {\n return n_fors;\n }\n count_comp_iter:\n REQ(n, comp_iter);\n n = CHILD(n, 0);\n if (TYPE(n) == comp_for)\n goto count_comp_for;\n else if (TYPE(n) == comp_if) {\n if (NCH(n) == 3) {\n n = CHILD(n, 2);\n goto count_comp_iter;\n }\n else\n return n_fors;\n }\n\n /* Should never be reached */\n PyErr_SetString(PyExc_SystemError,\n \"logic error in count_comp_fors\");\n return -1;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static const uint8_t *get_signature(const uint8_t *asn1_sig, int *len)\n{\n int offset = 0;\n const uint8_t *ptr = NULL;\n\n if (asn1_next_obj(asn1_sig, &offset, ASN1_SEQUENCE) < 0 || \n asn1_skip_obj(asn1_sig, &offset, ASN1_SEQUENCE))\n goto end_get_sig;\n\n if (asn1_sig[offset++] != ASN1_OCTET_STRING)\n goto end_get_sig;\n *len = get_asn1_length(asn1_sig, &offset);\n ptr = &asn1_sig[offset]; /* all ok */\n\nend_get_sig:\n return ptr;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": "static int sock_close(struct inode *inode, struct file *filp)\n{\n\tsock_release(SOCKET_I(inode));\n\treturn 0;\n}", "label": 0, "programming_language": "C", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": "static void clear_evtchn_to_irq_row(unsigned row)\n{\n\tunsigned col;\n\n\tfor (col = 0; col < EVTCHN_PER_ROW; col++)\n\t\tWRITE_ONCE(evtchn_to_irq[row][col], -1);\n}", "label": 1, "programming_language": "C", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "def generate_auth_token(user_id):\n host_list = request.host.rsplit(':')\n if len(host_list) == 1:\n host = ':'.join(host_list)\n else:\n host = ':'.join(host_list[0:-1])\n if host.startswith('127.') or host.lower() == 'localhost' or host.startswith('[::ffff:7f'):\n warning = _('PLease access calibre-web from non localhost to get valid api_endpoint for kobo device')\n return render_title_template(\n \"generate_kobo_auth_url.html\",\n title=_(u\"Kobo Setup\"),\n warning = warning\n )\n else:\n # Invalidate any prevously generated Kobo Auth token for this user.\n auth_token = ub.session.query(ub.RemoteAuthToken).filter(\n ub.RemoteAuthToken.user_id == user_id\n ).filter(ub.RemoteAuthToken.token_type==1).first()\n\n if not auth_token:\n auth_token = ub.RemoteAuthToken()\n auth_token.user_id = user_id\n auth_token.expiration = datetime.max\n auth_token.auth_token = (hexlify(urandom(16))).decode(\"utf-8\")\n auth_token.token_type = 1\n\n ub.session.add(auth_token)\n ub.session_commit()\n\n books = calibre_db.session.query(db.Books).join(db.Data).all()\n\n for book in books:\n formats = [data.format for data in book.data]\n if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats:\n helper.convert_book_format(book.id, config.config_calibre_dir, 'EPUB', 'KEPUB', current_user.name)\n\n return render_title_template(\n \"generate_kobo_auth_url.html\",\n title=_(u\"Kobo Setup\"),\n kobo_auth_url=url_for(\n \"kobo.TopLevelEndpoint\", auth_token=auth_token.auth_token, _external=True\n ),\n warning = False\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-284", "cwe_name": "Improper Access Control", "description": "The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.", "url": "https://cwe.mitre.org/data/definitions/284.html", "label_name": "vulnerable"} {"code": " def test_bad_integer(self):\n # issue13436: Bad error message with invalid numeric values\n body = [ast.ImportFrom(module='time',\n names=[ast.alias(name='sleep')],\n level=None,\n lineno=None, col_offset=None)]\n mod = ast.Module(body, [])\n with self.assertRaises(ValueError) as cm:\n compile(mod, 'test', 'exec')\n self.assertIn(\"invalid integer value: None\", str(cm.exception))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " def _dump(self, file=None, format=None):\n import tempfile, os\n if not file:\n f, file = tempfile.mkstemp(format or '')\n os.close(f)\n \n self.load()\n if not format or format == \"PPM\":\n self.im.save_ppm(file)\n else:\n if file.endswith(format):\n file = file + \".\" + format\n self.save(file, format)\n return file", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def load_djpeg(self):\n\n # ALTERNATIVE: handle JPEGs via the IJG command line utilities\n\n import tempfile, os\n f, path = tempfile.mkstemp()\n os.close(f)\n if os.path.exists(self.filename):\n os.system(\"djpeg '%s' >'%s'\" % (self.filename, path))\n else:\n raise ValueError(\"Invalid Filename\")\n\n try:\n self.im = Image.core.open_ppm(path)\n finally:\n try: os.unlink(path)\n except: pass\n\n self.mode = self.im.mode\n self.size = self.im.size\n\n self.tile = []", "label": 1, "programming_language": "Python", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "def init():\n if proxy.rejectReinit is True and proxy.initialized is True:\n msg = 'Cannot initialize the action more than once.'\n sys.stderr.write(msg + '\\n')\n response = flask.jsonify({'error': msg})\n response.status_code = 403\n return complete(response)\n\n message = flask.request.get_json(force=True, silent=True)\n if message and not isinstance(message, dict):\n flask.abort(404)\n else:\n value = message.get('value', {}) if message else {}\n\n if not isinstance(value, dict):\n flask.abort(404)\n\n try:\n status = runner.init(value)\n except Exception as e:\n status = False\n\n if status is True:\n proxy.initialized = True\n return ('OK', 200)\n else:\n response = flask.jsonify({'error': 'The action failed to generate or locate a binary. See logs for details.'})\n response.status_code = 502\n return complete(response)", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " def close(self):\n self.lock.release()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " def test_notfilelike_nocl_http10(self):\n to_send = \"GET /notfilelike_nocl HTTP/1.0\\r\\n\\r\\n\"\n to_send = tobytes(to_send)\n\n self.connect()\n\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, response_body = read_http(fp)\n self.assertline(line, \"200\", \"OK\", \"HTTP/1.0\")\n ct = headers[\"content-type\"]\n self.assertEqual(ct, \"image/jpeg\")\n self.assertTrue(b\"\\377\\330\\377\" in response_body)\n # connection has been closed (no content-length)\n self.send_check_error(to_send)\n self.assertRaises(ConnectionClosed, read_http, fp)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "def test_class_instances_from_soap_enveloped_saml_thingies_xxe():\n xml = \"\"\"\n \n \n \n ]>\n &lol1;\n \"\"\"\n with raises(soap.XmlParseError):\n soap.class_instances_from_soap_enveloped_saml_thingies(xml, None)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " def test_replay_banner_metadata(self, fmod):\n \"\"\" Test adding metadata in replay banner (both framed and non-frame)\n \"\"\"\n resp = self.get('/test/20140103030321{0}/http://example.com/?example=1', fmod)\n assert '
    Custom Banner Here!
    ' in resp.text\n assert '\"some\":\"value\"' in resp.text", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "def main():\n _validate_untrusted_args(sys.argv)\n parser = get_argparser()\n argv = sys.argv[1:]\n args = parser.parse_args(argv)\n if args.json_args is not None:\n args = _unpack_json_args(args)\n earlyinit.early_init(args)\n # We do this imports late as earlyinit needs to be run first (because of\n # version checking and other early initialization)\n from qutebrowser import app\n return app.run(args)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-641", "cwe_name": "Improper Restriction of Names for Files and Other Resources", "description": "The application constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name.", "url": "https://cwe.mitre.org/data/definitions/641.html", "label_name": "safe"} {"code": " def traverse(cls, base, request, path_items):\n \"\"\"See ``zope.app.pagetemplate.engine``.\"\"\"\n\n path_items = list(path_items)\n path_items.reverse()\n\n while path_items:\n name = path_items.pop()\n\n if name == '_':\n warnings.warn('Traversing to the name `_` is deprecated '\n 'and will be removed in Zope 6.',\n DeprecationWarning)\n elif name.startswith('_'):\n raise NotFound(name)\n\n if ITraversable.providedBy(base):\n base = getattr(base, cls.traverse_method)(name)\n else:\n base = traversePathElement(base, name, path_items,\n request=request)\n\n return base", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def _process(tlist):\n def get_next_comment():\n # TODO(andi) Comment types should be unified, see related issue38\n return tlist.token_next_by(i=sql.Comment, t=T.Comment)\n\n def _get_insert_token(token):\n \"\"\"Returns either a whitespace or the line breaks from token.\"\"\"\n # See issue484 why line breaks should be preserved.\n m = re.search(r'((\\r\\n|\\r|\\n)+) *$', token.value)\n if m is not None:\n return sql.Token(T.Whitespace.Newline, m.groups()[0])\n else:\n return sql.Token(T.Whitespace, ' ')\n\n tidx, token = get_next_comment()\n while token:\n pidx, prev_ = tlist.token_prev(tidx, skip_ws=False)\n nidx, next_ = tlist.token_next(tidx, skip_ws=False)\n # Replace by whitespace if prev and next exist and if they're not\n # whitespaces. This doesn't apply if prev or next is a parenthesis.\n if (prev_ is None or next_ is None\n or prev_.is_whitespace or prev_.match(T.Punctuation, '(')\n or next_.is_whitespace or next_.match(T.Punctuation, ')')):\n # Insert a whitespace to ensure the following SQL produces\n # a valid SQL (see #425).\n if prev_ is not None and not prev_.match(T.Punctuation, '('):\n tlist.tokens.insert(tidx, _get_insert_token(token))\n tlist.tokens.remove(token)\n else:\n tlist.tokens[tidx] = _get_insert_token(token)\n\n tidx, token = get_next_comment()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def _maintain_token_expiration(self):\n \"\"\"Token expiration should be maintained after re-auth & validation.\"\"\"\n r = self.api.authenticate(\n {},\n auth={\n 'passwordCredentials': {\n 'username': self.user_foo['name'],\n 'password': self.user_foo['password']\n }\n })\n unscoped_token_id = r['access']['token']['id']\n original_expiration = r['access']['token']['expires']\n\n time.sleep(0.5)\n\n r = self.api.validate_token(\n dict(is_admin=True, query_string={}),\n token_id=unscoped_token_id)\n self.assertEqual(original_expiration, r['access']['token']['expires'])\n\n time.sleep(0.5)\n\n r = self.api.authenticate(\n {},\n auth={\n 'token': {\n 'id': unscoped_token_id,\n },\n 'tenantId': self.tenant_bar['id'],\n })\n scoped_token_id = r['access']['token']['id']\n self.assertEqual(original_expiration, r['access']['token']['expires'])\n\n time.sleep(0.5)\n\n r = self.api.validate_token(\n dict(is_admin=True, query_string={}),\n token_id=scoped_token_id)\n self.assertEqual(original_expiration, r['access']['token']['expires'])", "label": 1, "programming_language": "Python", "cwe_id": "CWE-255", "cwe_name": "Credentials Management Errors", "description": "Weaknesses in this category are related to the management of credentials.", "url": "https://cwe.mitre.org/data/definitions/255.html", "label_name": "safe"} {"code": " def test_svg_data_links(self):\n # Remove SVG images with potentially insecure content.\n svg = b''\n svgz = gzip.compress(svg)\n svg_b64 = base64.b64encode(svg).decode('ASCII')\n svgz_b64 = base64.b64encode(svgz).decode('ASCII')\n urls = [\n \"data:image/svg+xml;base64,\" + svg_b64,\n \"data:image/svg+xml-compressed;base64,\" + svgz_b64,\n ]\n for url in urls:\n html = '' % url\n s = lxml.html.fragment_fromstring(html)\n\n cleaned = lxml.html.tostring(clean_html(s))\n self.assertEqual(\n b'',\n cleaned,\n \"%s -> %s\" % (url, cleaned))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "def create_temp_dir(prefix, inner_dir=None, tmp_dir=None):\n \"\"\"\n Create intermediate dirs ///\n\n argument 'tmp_dir' is used in unit tests\n \"\"\"\n if not tmp_dir:\n tmp_dir_path = tempfile.mkdtemp(prefix=prefix)\n else:\n tmp_dir_path = tempfile.mkdtemp(prefix=prefix, dir=tmp_dir)\n if inner_dir:\n tmp_dir_path = os.path.join(tmp_dir_path, inner_dir)\n os.mkdir(tmp_dir_path, 0o700)\n return tmp_dir_path", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n hs = self.setup_test_homeserver(\n resource_for_federation=Mock(), http_client=None\n )\n return hs", "label": 0, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": "def _inject_key_into_fs(key, fs, execute=None):\n \"\"\"Add the given public ssh key to root's authorized_keys.\n\n key is an ssh key string.\n fs is the path to the base of the filesystem into which to inject the key.\n \"\"\"\n sshdir = _join_and_check_path_within_fs(fs, 'root', '.ssh')\n utils.execute('mkdir', '-p', sshdir, run_as_root=True)\n utils.execute('chown', 'root', sshdir, run_as_root=True)\n utils.execute('chmod', '700', sshdir, run_as_root=True)\n\n keyfile = os.path.join('root', '.ssh', 'authorized_keys')\n\n key_data = ''.join([\n '\\n',\n '# The following ssh key was injected by Nova',\n '\\n',\n key.strip(),\n '\\n',\n ])\n\n _inject_file_into_fs(fs, keyfile, key_data, append=True)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def should_run(self):\n if self.force:\n return True\n if not os.path.exists(self.bower_dir):\n return True\n if not os.path.exists(self.sanitizer_dir):\n return True\n\n bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))\n if bower_stale:\n return True\n\n return mtime(self.sanitizer_dir) < mtime(pjoin(repo_root, 'webpack.config.js'))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n hs = self.setup_test_homeserver(\"server\", federation_http_client=None)\n return hs", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": "def show_unit_extensions(request, course_id):\n \"\"\"\n Shows all of the students which have due date extensions for the given unit.\n \"\"\"\n course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(course_id))\n unit = find_unit(course, request.GET.get('url'))\n return JsonResponse(dump_module_extensions(course, unit))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "def _validate_untrusted_args(argv):\n # NOTE: Do not use f-strings here, as this should run with older Python\n # versions (so that a proper error can be displayed)\n try:\n untrusted_idx = argv.index('--untrusted-args')\n except ValueError:\n return\n\n rest = argv[untrusted_idx + 1:]\n if len(rest) > 1:\n sys.exit(\n \"Found multiple arguments ({}) after --untrusted-args, \"\n \"aborting.\".format(' '.join(rest)))\n\n for arg in rest:\n if arg.startswith(('-', ':')):\n sys.exit(\"Found {} after --untrusted-args, aborting.\".format(arg))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "safe"} {"code": " def get_recipe_from_file(self, file):\n\n recipe = Recipe.objects.create(\n name=file['name'].strip(),\n created_by=self.request.user, internal=True,\n space=self.request.space)\n\n try:\n if file['recipeYield'] != '':\n recipe.servings = int(file['recipeYield'])\n\n if file['totalTime'] != '':\n recipe.waiting_time = int(file['totalTime']) - int(file['timePrep'])\n\n if file['prepTime'] != '':\n recipe.working_time = int(file['timePrep'])\n\n recipe.save()\n except Exception as e:\n print('failed to parse yield or time ', str(e))\n\n ingredient_parser = IngredientParser(self.request, True)\n ingredients_added = False\n for s in file['recipeInstructions']:\n step = Step.objects.create(\n instruction=s['text'], space=self.request.space,\n )\n if not ingredients_added:\n ingredients_added = True\n\n for ingredient in file['recipeIngredient']:\n amount, unit, food, note = ingredient_parser.parse(ingredient)\n f = ingredient_parser.get_food(food)\n u = ingredient_parser.get_unit(unit)\n step.ingredients.add(Ingredient.objects.create(\n food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space,\n ))\n recipe.steps.add(step)\n\n if len(file['image']) > 0:\n try:\n response = requests.get(file['image'][0])\n self.import_recipe_image(recipe, BytesIO(response.content))\n except Exception as e:\n print('failed to import image ', str(e))\n\n return recipe", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def render_search_results(term, offset=None, order=None, limit=None):\n join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series\n entries, result_count, pagination = calibre_db.get_search_results(term,\n offset,\n order,\n limit,\n False,\n config.config_read_column,\n *join)\n return render_title_template('search.html',\n searchterm=term,\n pagination=pagination,\n query=term,\n adv_searchterm=term,\n entries=entries,\n result_count=result_count,\n title=_(u\"Search\"),\n page=\"search\",\n order=order[1])", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def test_received_nonsense_nothing(self):\n data = b\"\\r\\n\\r\\n\"\n result = self.parser.received(data)\n self.assertEqual(result, 4)\n self.assertTrue(self.parser.completed)\n self.assertEqual(self.parser.headers, {})", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def test_render_quoting(self):\n w = widgets.AdminURLFieldWidget()\n self.assertHTMLEqual(\n conditional_escape(w.render('test', 'http://example.com/some text')),\n '

    Currently:http://example.com/<sometag>some text</sometag>
    Change:some text\" />

    '\n )\n self.assertHTMLEqual(\n conditional_escape(w.render('test', 'http://example-\u00e4\u00fc\u00f6.com/some text')),\n '

    Currently:http://example-\u00e4\u00fc\u00f6.com/<sometag>some text</sometag>
    Change:some text\" />

    '\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def visit_BinOp(self, node):\n op = BIN_OPS.get(node.op.__class__)\n if op:\n return op(self.visit(node.left), self.visit(node.right))\n else:\n raise InvalidNode('illegal operator %s' % node.op.__class__.__name__)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def to_xml(self, data, options=None):\n \"\"\"\n Given some Python data, produces XML output.\n \"\"\"\n options = options or {}\n\n if lxml is None:\n raise ImproperlyConfigured(\"Usage of the XML aspects requires lxml.\")\n\n return tostring(self.to_etree(data, options), xml_declaration=True, encoding='utf-8')", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def verify(self, password, encoded):\n algorithm, data = encoded.split('$', 1)\n assert algorithm == self.algorithm\n encoded_2 = self.encode(password, force_bytes(data))\n return constant_time_compare(encoded, encoded_2)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def testInvalidBlockShape(self):\n with self.assertRaisesRegex(ValueError, \"block_shape must be positive\"):\n with self.session() as sess, self.test_scope():\n tf_in = constant_op.constant(\n -3.5e+35, shape=[10, 20, 20], dtype=dtypes.float32)\n block_shape = constant_op.constant(-10, shape=[2], dtype=dtypes.int64)\n paddings = constant_op.constant(0, shape=[2, 2], dtype=dtypes.int32)\n sess.run(array_ops.space_to_batch_nd(tf_in, block_shape, paddings))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": " def get_recipe_from_file(self, file):\n recipe_html = file.getvalue().decode(\"utf-8\")\n\n recipe_json, recipe_tree, html_data, images = get_recipe_from_source(recipe_html, 'CookBookApp', self.request)\n\n recipe = Recipe.objects.create(\n name=recipe_json['name'].strip(),\n created_by=self.request.user, internal=True,\n space=self.request.space)\n\n try:\n recipe.servings = re.findall('([0-9])+', recipe_json['recipeYield'])[0]\n except Exception as e:\n pass\n\n try:\n recipe.working_time = iso_duration_to_minutes(recipe_json['prepTime'])\n recipe.waiting_time = iso_duration_to_minutes(recipe_json['cookTime'])\n except Exception:\n pass\n\n step = Step.objects.create(instruction=recipe_json['recipeInstructions'], space=self.request.space, )\n\n if 'nutrition' in recipe_json:\n step.instruction = step.instruction + '\\n\\n' + recipe_json['nutrition']\n\n step.save()\n recipe.steps.add(step)\n\n ingredient_parser = IngredientParser(self.request, True)\n for ingredient in recipe_json['recipeIngredient']:\n f = ingredient_parser.get_food(ingredient['ingredient']['text'])\n u = ingredient_parser.get_unit(ingredient['unit']['text'])\n step.ingredients.add(Ingredient.objects.create(\n food=f, unit=u, amount=ingredient['amount'], note=ingredient['note'], space=self.request.space,\n ))\n\n if len(images) > 0:\n try:\n response = requests.get(images[0])\n self.import_recipe_image(recipe, BytesIO(response.content))\n except Exception as e:\n print('failed to import image ', str(e))\n\n recipe.save()\n return recipe", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def __init__(self,\n table,\n record=None,\n readonly=False,\n deletable=True,\n formstyle=FormStyleDefault,\n dbio=True,\n keepvalues=False,\n formname=False,\n hidden=None,\n csrf=True):", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def analyze(self, avc):\n import commands\n if avc.has_any_access_in(['execmod']):\n # MATCH\n if (commands.getstatusoutput(\"eu-readelf -d %s | fgrep -q TEXTREL\" % avc.tpath)[0] == 1):\n return self.report((\"unsafe\"))\n\n mcon = selinux.matchpathcon(avc.tpath.strip('\"'), S_IFREG)[1]\n if mcon.split(\":\")[2] == \"lib_t\":\n return self.report()\n return None", "label": 0, "programming_language": "Python", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " def test_quotas_update_as_user(self):\n body = {'quota_set': {'instances': 50, 'cores': 50,\n 'ram': 51200, 'volumes': 10,\n 'gigabytes': 1000, 'floating_ips': 10,\n 'metadata_items': 128, 'injected_files': 5,\n 'injected_file_content_bytes': 10240}}\n\n req = fakes.HTTPRequest.blank('/v2/fake4/os-quota-sets/update_me')\n self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,\n req, 'update_me', body)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "def list_users():\n off = int(request.args.get(\"offset\") or 0)\n limit = int(request.args.get(\"limit\") or 10)\n search = request.args.get(\"search\")\n sort = request.args.get(\"sort\", \"id\")\n state = None\n if sort == \"state\":\n state = json.loads(request.args.get(\"state\", \"[]\"))\n else:\n if sort not in ub.User.__table__.columns.keys():\n sort = \"id\"\n order = request.args.get(\"order\", \"\").lower()\n\n if sort != \"state\" and order:\n order = text(sort + \" \" + order)\n elif not state:\n order = ub.User.id.asc()\n\n all_user = ub.session.query(ub.User)\n if not config.config_anonbrowse:\n all_user = all_user.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS)\n\n total_count = filtered_count = all_user.count()\n\n if search:\n all_user = all_user.filter(or_(func.lower(ub.User.name).ilike(\"%\" + search + \"%\"),\n func.lower(ub.User.kindle_mail).ilike(\"%\" + search + \"%\"),\n func.lower(ub.User.email).ilike(\"%\" + search + \"%\")))\n if state:\n users = calibre_db.get_checkbox_sorted(all_user.all(), state, off, limit, request.args.get(\"order\", \"\").lower())\n else:\n users = all_user.order_by(order).offset(off).limit(limit).all()\n if search:\n filtered_count = len(users)\n\n for user in users:\n if user.default_language == \"all\":\n user.default = _(\"All\")\n else:\n user.default = LC.parse(user.default_language).get_language_name(get_locale())\n\n table_entries = {'totalNotFiltered': total_count, 'total': filtered_count, \"rows\": users}\n js_list = json.dumps(table_entries, cls=db.AlchemyEncoder)\n response = make_response(js_list)\n response.headers[\"Content-Type\"] = \"application/json; charset=utf-8\"\n return response", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def __init__(self, *, openapi: GeneratorData) -> None:\n self.openapi: GeneratorData = openapi\n self.env: Environment = Environment(loader=PackageLoader(__package__), trim_blocks=True, lstrip_blocks=True)\n\n self.project_name: str = self.project_name_override or f\"{utils.kebab_case(openapi.title).lower()}-client\"\n self.project_dir: Path = Path.cwd() / self.project_name\n\n self.package_name: str = self.package_name_override or self.project_name.replace(\"-\", \"_\")\n self.package_dir: Path = self.project_dir / self.package_name\n self.package_description: str = f\"A client library for accessing {self.openapi.title}\"\n self.version: str = openapi.version\n\n self.env.filters.update(self.TEMPLATE_FILTERS)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " def get_revision(self):\n \"\"\"Read svn revision information for the Bcfg2 repository.\"\"\"\n try:\n data = Popen((\"env LC_ALL=C svn info %s\" %\n (self.datastore)), shell=True,\n stdout=PIPE).communicate()[0].split('\\n')\n return [line.split(': ')[1] for line in data \\\n if line[:9] == 'Revision:'][-1]\n except IndexError:\n logger.error(\"Failed to read svn info; disabling svn support\")\n logger.error('''Ran command \"svn info %s\"''' % (self.datastore))\n logger.error(\"Got output: %s\" % data)\n raise Bcfg2.Server.Plugin.PluginInitError", "label": 0, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def setUp(self):\n shape = (2, 4, 3)\n rand = np.random.random\n self.x = rand(shape) + rand(shape).astype(np.complex)*1j\n self.x[0,:, 1] = [nan, inf, -inf, nan]\n self.dtype = self.x.dtype\n self.file = tempfile.NamedTemporaryFile()\n self.filename = self.file.name", "label": 1, "programming_language": "Python", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "def set_bookmark(book_id, book_format):\n bookmark_key = request.form[\"bookmark\"]\n ub.session.query(ub.Bookmark).filter(and_(ub.Bookmark.user_id == int(current_user.id),\n ub.Bookmark.book_id == book_id,\n ub.Bookmark.format == book_format)).delete()\n if not bookmark_key:\n ub.session_commit()\n return \"\", 204\n\n lbookmark = ub.Bookmark(user_id=current_user.id,\n book_id=book_id,\n format=book_format,\n bookmark_key=bookmark_key)\n ub.session.merge(lbookmark)\n ub.session_commit(\"Bookmark for user {} in book {} created\".format(current_user.id, book_id))\n return \"\", 201", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def test_send_empty_body(self):\n to_send = \"GET / HTTP/1.0\\r\\nContent-Length: 0\\r\\n\\r\\n\"\n to_send = tobytes(to_send)\n self.connect()\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, echo = self._read_echo(fp)\n self.assertline(line, \"200\", \"OK\", \"HTTP/1.0\")\n self.assertEqual(echo.content_length, \"0\")\n self.assertEqual(echo.body, b\"\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "def handler(request, operation, current_url):\n \"\"\"Scheme handler for qute:// URLs.\n\n Args:\n request: QNetworkRequest to answer to.\n operation: The HTTP operation being done.\n current_url: The page we're on currently.\n\n Return:\n A QNetworkReply.\n \"\"\"\n if operation != QNetworkAccessManager.GetOperation:\n return networkreply.ErrorNetworkReply(\n request, \"Unsupported request type\",\n QNetworkReply.ContentOperationNotPermittedError)\n\n url = request.url()\n\n if ((url.scheme(), url.host(), url.path()) ==\n ('qute', 'settings', '/set')):\n if current_url != QUrl('qute://settings/'):\n log.webview.warning(\"Blocking malicious request from {} to {}\"\n .format(current_url.toDisplayString(),\n url.toDisplayString()))\n return networkreply.ErrorNetworkReply(\n request, \"Invalid qute://settings request\",\n QNetworkReply.ContentAccessDenied)\n\n try:\n mimetype, data = qutescheme.data_for_url(url)\n except qutescheme.NoHandlerFound:\n errorstr = \"No handler found for {}!\".format(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": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " def _getKeysForServer(self, server_name):\n \"\"\"Get the signing key data from a homeserver.\n\n :param server_name: The name of the server to request the keys from.\n :type server_name: unicode\n\n :return: The verification keys returned by the server.\n :rtype: twisted.internet.defer.Deferred[dict[unicode, dict[unicode, unicode]]]\n \"\"\"\n\n if server_name in self.cache:\n cached = self.cache[server_name]\n now = int(time.time() * 1000)\n if cached['valid_until_ts'] > now:\n defer.returnValue(self.cache[server_name]['verify_keys'])\n\n client = FederationHttpClient(self.sydent)\n result = yield client.get_json(\"matrix://%s/_matrix/key/v2/server/\" % server_name)\n if 'verify_keys' not in result:\n raise SignatureVerifyException(\"No key found in response\")\n\n if 'valid_until_ts' in result:\n # Don't cache anything without a valid_until_ts or we wouldn't\n # know when to expire it.\n logger.info(\"Got keys for %s: caching until %s\", server_name, result['valid_until_ts'])\n self.cache[server_name] = result\n\n defer.returnValue(result['verify_keys'])", "label": 0, "programming_language": "Python", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "def parse_jwt_token(request: func.HttpRequest) -> Result[UserInfo]:\n \"\"\"Obtains the Access Token from the Authorization Header\"\"\"\n token_str = get_auth_token(request)\n if token_str is None:\n return Error(\n code=ErrorCode.INVALID_REQUEST,\n errors=[\"unable to find authorization token\"],\n )\n\n # This token has already been verified by the azure authentication layer\n token = jwt.decode(token_str, options={\"verify_signature\": False})\n\n application_id = UUID(token[\"appid\"]) if \"appid\" in token else None\n object_id = UUID(token[\"oid\"]) if \"oid\" in token else None\n upn = token.get(\"upn\")\n return UserInfo(application_id=application_id, object_id=object_id, upn=upn)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-285", "cwe_name": "Improper Authorization", "description": "The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/285.html", "label_name": "vulnerable"} {"code": " async def on_exchange_third_party_invite_request(\n self, room_id: str, event_dict: JsonDict", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def load_bytearray(side):\n return LOAD(bytes_data_ptr(side))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-697", "cwe_name": "Incorrect Comparison", "description": "The software compares two entities in a security-relevant context, but the comparison is incorrect, which may lead to resultant weaknesses.", "url": "https://cwe.mitre.org/data/definitions/697.html", "label_name": "vulnerable"} {"code": "def rescore_entrance_exam(request, course_id):\n \"\"\"\n Starts a background process a students attempts counter for entrance exam.\n Optionally deletes student state for a problem. Limited to instructor access.\n\n Takes either of the following query parameters\n - unique_student_identifier is an email or username\n - all_students is a boolean\n\n all_students and unique_student_identifier cannot both be present.\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n course = get_course_with_access(\n request.user, 'staff', course_id, depth=None\n )\n\n student_identifier = request.POST.get('unique_student_identifier', None)\n student = None\n if student_identifier is not None:\n student = get_student_from_identifier(student_identifier)\n\n all_students = request.POST.get('all_students') in ['true', 'True', True]\n\n if not course.entrance_exam_id:\n return HttpResponseBadRequest(\n _(\"Course has no entrance exam section.\")\n )\n\n if all_students and student:\n return HttpResponseBadRequest(\n _(\"Cannot rescore with all_students and unique_student_identifier.\")\n )\n\n try:\n entrance_exam_key = course_id.make_usage_key_from_deprecated_string(course.entrance_exam_id)\n except InvalidKeyError:\n return HttpResponseBadRequest(_(\"Course has no valid entrance exam section.\"))\n\n response_payload = {}\n if student:\n response_payload['student'] = student_identifier\n else:\n response_payload['student'] = _(\"All Students\")\n instructor_task.api.submit_rescore_entrance_exam_for_student(request, entrance_exam_key, student)\n response_payload['task'] = 'created'\n return JsonResponse(response_payload)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "def rescore_entrance_exam(request, course_id):\n \"\"\"\n Starts a background process a students attempts counter for entrance exam.\n Optionally deletes student state for a problem. Limited to instructor access.\n\n Takes either of the following query parameters\n - unique_student_identifier is an email or username\n - all_students is a boolean\n\n all_students and unique_student_identifier cannot both be present.\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n course = get_course_with_access(\n request.user, 'staff', course_id, depth=None\n )\n\n student_identifier = request.GET.get('unique_student_identifier', None)\n student = None\n if student_identifier is not None:\n student = get_student_from_identifier(student_identifier)\n\n all_students = request.GET.get('all_students') in ['true', 'True', True]\n\n if not course.entrance_exam_id:\n return HttpResponseBadRequest(\n _(\"Course has no entrance exam section.\")\n )\n\n if all_students and student:\n return HttpResponseBadRequest(\n _(\"Cannot rescore with all_students and unique_student_identifier.\")\n )\n\n try:\n entrance_exam_key = course_id.make_usage_key_from_deprecated_string(course.entrance_exam_id)\n except InvalidKeyError:\n return HttpResponseBadRequest(_(\"Course has no valid entrance exam section.\"))\n\n response_payload = {}\n if student:\n response_payload['student'] = student_identifier\n else:\n response_payload['student'] = _(\"All Students\")\n instructor_task.api.submit_rescore_entrance_exam_for_student(request, entrance_exam_key, student)\n response_payload['task'] = 'created'\n return JsonResponse(response_payload)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "def authorized():\n resp = google_remote_app().authorized_response()\n access_token = resp[\"access_token\"]\n\n if access_token is None:\n logger.warning(\"Access token missing in call back request.\")\n flash(\"Validation error. Please retry.\")\n return redirect(url_for(\"redash.login\"))\n\n profile = get_user_profile(access_token)\n if profile is None:\n flash(\"Validation error. Please retry.\")\n return redirect(url_for(\"redash.login\"))\n\n if \"org_slug\" in session:\n org = models.Organization.get_by_slug(session.pop(\"org_slug\"))\n else:\n org = current_org\n\n if not verify_profile(org, profile):\n logger.warning(\n \"User tried to login with unauthorized domain name: %s (org: %s)\",\n profile[\"email\"],\n org,\n )\n flash(\"Your Google Apps account ({}) isn't allowed.\".format(profile[\"email\"]))\n return redirect(url_for(\"redash.login\", org_slug=org.slug))\n\n picture_url = \"%s?sz=40\" % profile[\"picture\"]\n user = create_and_login_user(org, profile[\"name\"], profile[\"email\"], picture_url)\n if user is None:\n return logout_and_redirect_to_index()\n\n unsafe_next_path = request.args.get(\"state\") or url_for(\n \"redash.index\", org_slug=org.slug\n )\n next_path = get_next_path(unsafe_next_path)\n\n return redirect(next_path)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": " def testRaggedCountSparseOutputEmptySplits(self):\n splits = []\n values = [1, 1, 2, 1, 2, 10, 5]\n weights = [1, 2, 3, 4, 5, 6, 7]\n with self.assertRaisesRegex(\n errors.InvalidArgumentError,\n \"Must provide at least 2 elements for the splits argument\"):\n self.evaluate(\n gen_count_ops.RaggedCountSparseOutput(\n splits=splits,\n values=values,\n weights=weights,\n binary_output=False))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "def insensitive_ends_with(field: Term, value: str) -> Criterion:\n return Upper(field).like(Upper(f\"%{value}\"))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "def fetch_public_key_from_remote_node(node):\n \"\"\"\n Fetch public key file from remote node\n Return a temp file contains public key\n Return None if no key exist\n \"\"\"\n\n # For dsa, might need to add PubkeyAcceptedKeyTypes=+ssh-dss to config file, see\n # https://superuser.com/questions/1016989/ssh-dsa-keys-no-longer-work-for-password-less-authentication\n for key in (\"id_rsa\", \"id_ecdsa\", \"id_ed25519\", \"id_dsa\"):\n public_key_file = \"/root/.ssh/{}.pub\".format(key)\n cmd = \"ssh -oStrictHostKeyChecking=no root@{} 'test -f {}'\".format(node, public_key_file)\n if not invokerc(cmd):\n continue\n _, temp_public_key_file = tmpfiles.create()\n cmd = \"scp -oStrictHostKeyChecking=no root@{}:{} {}\".format(node, public_key_file, temp_public_key_file)\n rc, _, err = invoke(cmd)\n if not rc:\n error(\"Failed to run \\\"{}\\\": {}\".format(cmd, err))\n return temp_public_key_file\n raise ValueError(\"No ssh key exist on {}\".format(node))", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def _has_sneaky_javascript(self, style):\n \"\"\"\n Depending on the browser, stuff like ``e x p r e s s i o n(...)``\n can get interpreted, or ``expre/* stuff */ssion(...)``. This\n checks for attempt to do stuff like this.\n\n Typically the response will be to kill the entire style; if you\n have just a bit of Javascript in the style another rule will catch\n that and remove only the Javascript from the style; this catches\n more sneaky attempts.\n \"\"\"\n style = self._substitute_comments('', style)\n style = style.replace('\\\\', '')\n style = _substitute_whitespace('', style)\n style = style.lower()\n if 'javascript:' in style:\n return True\n if 'expression(' in style:\n return True\n if '@import' in style:\n return True\n if ''\n return True\n return False", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def __getitem__(self, key):\n if key == '':\n idx = self._last_index\n self._last_index += 1\n try:\n return self._args[idx]\n except LookupError:\n pass\n key = str(idx)\n return self._kwargs[key]", "label": 1, "programming_language": "Python", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": "def check_shelf_is_unique(shelf, title, shelf_id=False):\n if shelf_id:\n ident = ub.Shelf.id != shelf_id\n else:\n ident = true()\n if shelf.is_public == 1:\n is_shelf_name_unique = ub.session.query(ub.Shelf) \\\n .filter((ub.Shelf.name == title) & (ub.Shelf.is_public == 1)) \\\n .filter(ident) \\\n .first() is None\n\n if not is_shelf_name_unique:\n log.error(\"A public shelf with the name '{}' already exists.\".format(title))\n flash(_(u\"A public shelf with the name '%(title)s' already exists.\", title=title),\n category=\"error\")\n else:\n is_shelf_name_unique = ub.session.query(ub.Shelf) \\\n .filter((ub.Shelf.name == title) & (ub.Shelf.is_public == 0) &\n (ub.Shelf.user_id == int(current_user.id))) \\\n .filter(ident) \\\n .first() is None\n\n if not is_shelf_name_unique:\n log.error(\"A private shelf with the name '{}' already exists.\".format(title))\n flash(_(u\"A private shelf with the name '%(title)s' already exists.\", title=title),\n category=\"error\")\n return is_shelf_name_unique", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def test_scatter_ops_even_partition(self, op):\n v = variables_lib.Variable(array_ops.zeros((30, 1)))\n sparse_delta = ops.IndexedSlices(\n values=constant_op.constant([[0.], [1.], [2.], [3.], [4.]]),\n indices=constant_op.constant([0, 10, 12, 21, 22]))\n\n v0 = variables_lib.Variable(array_ops.zeros((10, 1)))\n v1 = variables_lib.Variable(array_ops.zeros((10, 1)))\n v2 = variables_lib.Variable(array_ops.zeros((10, 1)))\n sv = sharded_variable.ShardedVariable([v0, v1, v2])\n\n getattr(v, op)(sparse_delta, name='scatter_v')\n getattr(sv, op)(sparse_delta, name='scatter_sv')\n self.assertAllEqual(v, ops.convert_to_tensor(sv))\n\n @def_function.function\n def func():\n getattr(v, op)(sparse_delta, name='scatter_v')\n getattr(sv, op)(sparse_delta, name='scatter_sv')\n\n func()\n self.assertAllEqual(v, ops.convert_to_tensor(sv))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-369", "cwe_name": "Divide By Zero", "description": "The product divides a value by zero.", "url": "https://cwe.mitre.org/data/definitions/369.html", "label_name": "vulnerable"} {"code": " def test_login_get_non_idempotent(self):\n login_code = LoginCode.objects.create(user=self.user, next='/private/')\n\n response = self.client.get('/accounts/login/code/', {\n 'user': login_code.user.pk,\n 'code': login_code.code,\n })\n\n self.assertEqual(response.status_code, 302)\n self.assertEqual(response['Location'], '/private/')\n self.assertEqual(response.wsgi_request.user, self.user)\n self.assertFalse(LoginCode.objects.filter(pk=login_code.pk).exists())", "label": 1, "programming_language": "Python", "cwe_id": "CWE-312", "cwe_name": "Cleartext Storage of Sensitive Information", "description": "The application stores sensitive information in cleartext within a resource that might be accessible to another control sphere.", "url": "https://cwe.mitre.org/data/definitions/312.html", "label_name": "safe"} {"code": " def test_image_data_links(self):\n data = b'123'\n data_b64 = base64.b64encode(data).decode('ASCII')\n urls = [\n \"data:image/jpeg;base64,\" + data_b64,\n \"data:image/apng;base64,\" + data_b64,\n \"data:image/png;base64,\" + data_b64,\n \"data:image/gif;base64,\" + data_b64,\n \"data:image/webp;base64,\" + data_b64,\n \"data:image/bmp;base64,\" + data_b64,\n \"data:image/tiff;base64,\" + data_b64,\n \"data:image/x-icon;base64,\" + data_b64,\n ]\n for url in urls:\n html = '' % url\n s = lxml.html.fragment_fromstring(html)\n\n cleaned = lxml.html.tostring(clean_html(s))\n self.assertEqual(\n html.encode(\"UTF-8\"),\n cleaned,\n \"%s -> %s\" % (url, cleaned))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " def test_project_quotas_overrides_withclass(self):\n self._stub_class()\n self._stub_project(True)\n self.context.quota_class = 'test_class'\n result = quota.get_project_quotas(self.context, 'admin')\n self.assertEqual(result, dict(\n instances=2,\n cores=5,\n ram=12 * 1024,\n volumes=2,\n gigabytes=250,\n floating_ips=2,\n security_groups=5,\n security_group_rules=10,\n metadata_items=32,\n injected_files=1,\n injected_file_content_bytes=2 * 1024,\n ))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "def is_safe_url(url, host=None):\n \"\"\"\n Return ``True`` if the url is a safe redirection (i.e. it doesn't point to\n a different host and uses a safe scheme).\n\n Always returns ``False`` on an empty url.\n \"\"\"\n if not url:\n return False\n url_info = urllib_parse.urlparse(url)\n return (not url_info.netloc or url_info.netloc == host) and \\\n (not url_info.scheme or url_info.scheme in ['http', 'https'])", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "def add_objects(db_book_object, db_object, db_session, db_type, add_elements):\n changed = False\n if db_type == 'languages':\n db_filter = db_object.lang_code\n elif db_type == 'custom':\n db_filter = db_object.value\n else:\n db_filter = db_object.name\n for add_element in add_elements:\n # check if a element with that name exists\n db_element = db_session.query(db_object).filter(db_filter == add_element).first()\n # if no element is found add it\n if db_type == 'author':\n new_element = db_object(add_element, helper.get_sorted_author(add_element.replace('|', ',')), \"\")\n elif db_type == 'series':\n new_element = db_object(add_element, add_element)\n elif db_type == 'custom':\n new_element = db_object(value=add_element)\n elif db_type == 'publisher':\n new_element = db_object(add_element, None)\n else: # db_type should be tag or language\n new_element = db_object(add_element)\n if db_element is None:\n changed = True\n db_session.add(new_element)\n db_book_object.append(new_element)\n else:\n db_element = create_objects_for_addition(db_element, add_element, db_type)\n changed = True\n # add element to book\n changed = True\n db_book_object.append(db_element)\n return changed", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def boboAwareZopeTraverse(object, path_items, econtext):\n \"\"\"Traverses a sequence of names, first trying attributes then items.\n\n This uses zope.traversing path traversal where possible and interacts\n correctly with objects providing OFS.interface.ITraversable when\n necessary (bobo-awareness).\n \"\"\"\n request = getattr(econtext, 'request', None)\n path_items = list(path_items)\n path_items.reverse()\n\n while path_items:\n name = path_items.pop()\n\n if name == '_':\n warnings.warn('Traversing to the name `_` is deprecated '\n 'and will be removed in Zope 6.',\n DeprecationWarning)\n elif name.startswith('_'):\n raise NotFound(name)\n\n if OFS.interfaces.ITraversable.providedBy(object):\n object = object.restrictedTraverse(name)\n else:\n object = traversePathElement(object, name, path_items,\n request=request)\n return object", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " async def on_PUT(self, origin, content, query, room_id, event_id):\n content = await self.handler.on_send_leave_request(origin, content)\n return 200, (200, content)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def test_chunking_request_without_content(self):\n header = tobytes(\"GET / HTTP/1.1\\n\" \"Transfer-Encoding: chunked\\n\\n\")\n self.connect()\n self.sock.send(header)\n self.sock.send(b\"0\\r\\n\\r\\n\")\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, echo = self._read_echo(fp)\n self.assertline(line, \"200\", \"OK\", \"HTTP/1.1\")\n self.assertEqual(echo.body, b\"\")\n self.assertEqual(echo.content_length, \"0\")\n self.assertFalse(\"transfer-encoding\" in headers)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " def _on_ssl_errors(self, reply):\n self._insecure_hosts.add(reply.url().host())", "label": 1, "programming_language": "Python", "cwe_id": "CWE-684", "cwe_name": "Incorrect Provision of Specified Functionality", "description": "The code does not function according to its published specifications, potentially leading to incorrect usage.", "url": "https://cwe.mitre.org/data/definitions/684.html", "label_name": "safe"} {"code": " def setup_db(cls, config_calibre_dir, app_db_path):\n cls.dispose()\n\n if not config_calibre_dir:\n cls.config.invalidate()\n return False\n\n dbpath = os.path.join(config_calibre_dir, \"metadata.db\")\n if not os.path.exists(dbpath):\n cls.config.invalidate()\n return False\n\n try:\n cls.engine = create_engine('sqlite://',\n echo=False,\n isolation_level=\"SERIALIZABLE\",\n connect_args={'check_same_thread': False},\n poolclass=StaticPool)\n with cls.engine.begin() as connection:\n connection.execute(text(\"attach database '{}' as calibre;\".format(dbpath)))\n connection.execute(text(\"attach database '{}' as app_settings;\".format(app_db_path)))\n\n conn = cls.engine.connect()\n # conn.text_factory = lambda b: b.decode(errors = 'ignore') possible fix for #1302\n except Exception as ex:\n cls.config.invalidate(ex)\n return False\n\n cls.config.db_configured = True\n\n if not cc_classes:\n try:\n cc = conn.execute(text(\"SELECT id, datatype FROM custom_columns\"))\n cls.setup_db_cc_classes(cc)\n except OperationalError as e:\n log.error_or_exception(e)\n\n cls.session_factory = scoped_session(sessionmaker(autocommit=False,\n autoflush=True,\n bind=cls.engine))\n for inst in cls.instances:\n inst.initSession()\n\n cls._init = True\n return True", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def _default_logfile(exe_name):\n '''\n Retrieve the logfile name\n '''\n if salt.utils.is_windows():\n tmp_dir = os.path.join(__opts__['cachedir'], 'tmp')\n if not os.path.isdir(tmp_dir):\n os.mkdir(tmp_dir)\n logfile_tmp = tempfile.NamedTemporaryFile(dir=tmp_dir,\n prefix=exe_name,\n suffix='.log',\n delete=False)\n logfile = logfile_tmp.name\n logfile_tmp.close()\n else:\n logfile = salt.utils.path_join(\n '/var/log',\n '{0}.log'.format(exe_name)\n )\n\n return logfile", "label": 1, "programming_language": "Python", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "safe"} {"code": " def get_current_phase(self, requested_phase_identifier):\n found = False\n for phase in self.phases:\n if phase.is_valid():\n phase.process()\n if found or not requested_phase_identifier or requested_phase_identifier == phase.identifier:\n found = True # We're at or past the requested phase\n if not phase.should_skip():\n return phase\n if not phase.should_skip() and not phase.is_valid(): # A past phase is not valid, that's the current one\n return phase\n raise Http404(\"Error! Phase with identifier `%s` not found.\" % requested_phase_identifier) # pragma: no cover", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def testNonScalarKeyUnorderedMap(self):\n with ops.Graph().as_default() as g:\n x = array_ops.placeholder(dtypes.float32)\n v = 2. * (array_ops.zeros([128, 128]) + x)\n t = data_flow_ops.gen_data_flow_ops.map_stage(\n key=constant_op.constant(value=[1], shape=(1, 3), dtype=dtypes.int64),\n indices=np.array([[6]]),\n values=[x, v],\n dtypes=[dtypes.int64],\n capacity=0,\n memory_limit=0,\n container='container1',\n shared_name='',\n name=None)\n\n g.finalize()\n\n with self.session(graph=g) as sess:\n with self.assertRaisesRegex(errors.InvalidArgumentError,\n 'key must be an int64 scalar'):\n sess.run(t, feed_dict={x: 1})", "label": 1, "programming_language": "Python", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "safe"} {"code": " def test_federation_client_safe_ip(self, resolver):\n self.sydent.run()\n\n request, channel = make_request(\n self.sydent.reactor,\n \"POST\",\n \"/_matrix/identity/v2/account/register\",\n {\n \"access_token\": \"foo\",\n \"expires_in\": 300,\n \"matrix_server_name\": \"example.com\",\n \"token_type\": \"Bearer\",\n },\n )\n\n resolver.return_value = defer.succeed(\n [\n Server(\n host=self.safe_domain,\n port=443,\n priority=1,\n weight=1,\n expires=100,\n )\n ]\n )\n\n request.render(self.sydent.servlets.registerServlet)\n\n transport, protocol = self._get_http_request(self.safe_ip.decode(\"ascii\"), 443)\n\n self.assertRegex(\n transport.value(), b\"^GET /_matrix/federation/v1/openid/userinfo\"\n )\n self.assertRegex(transport.value(), b\"Host: example.com\")\n\n # Send it the HTTP response\n res_json = '{ \"sub\": \"@test:example.com\" }'.encode(\"ascii\")\n protocol.dataReceived(\n b\"HTTP/1.1 200 OK\\r\\n\"\n b\"Server: Fake\\r\\n\"\n b\"Content-Type: application/json\\r\\n\"\n b\"Content-Length: %i\\r\\n\"\n b\"\\r\\n\"\n b\"%s\" % (len(res_json), res_json)\n )\n\n self.assertEqual(channel.code, 200)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def insensitive_contains(field: Term, value: str) -> Criterion:\n return Upper(field).like(Upper(f\"%{value}%\"))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def test_received_control_line_finished_garbage_in_input(self):\n buf = DummyBuffer()\n inst = self._makeOne(buf)\n result = inst.received(b\"garbage\\n\")\n self.assertEqual(result, 8)\n self.assertTrue(inst.error)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " def load(self, stream):\n '''read vault steam and return python object'''\n return yaml.load(self.vault.decrypt(stream))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " def testRuntimeError(self,\n inputs,\n exception=errors.InvalidArgumentError,\n message=None):", "label": 0, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " def testBoostedTreesCalculateBestGainsPerFeatureSecurity(self):\n node_id_range = [1, 2]\n stats_summary_list = [[[[]]]]\n l1 = [1.0]\n l2 = [1.0]\n tree_complexity = [1.0]\n min_node_weight = [1.17]\n max_splits = 1\n with self.assertRaises((errors.InvalidArgumentError, ValueError)):\n gen_boosted_trees_ops.boosted_trees_calculate_best_gains_per_feature(\n node_id_range=node_id_range,\n stats_summary_list=stats_summary_list,\n l1=l1,\n l2=l2,\n tree_complexity=tree_complexity,\n min_node_weight=min_node_weight,\n max_splits=max_splits)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": " def post(self, request, *args, **kwargs): # doccov: ignore\n command = request.POST.get(\"command\")\n if command:\n dispatcher = getattr(self, \"dispatch_%s\" % command, None)\n if not callable(dispatcher):\n raise Problem(_(\"Unknown command: `%s`.\") % command)\n dispatch_kwargs = dict(request.POST.items())\n rv = dispatcher(**dispatch_kwargs)\n if rv:\n return rv\n self.request.method = \"GET\" # At this point, we won't want to cause form validation\n self.build_form() # and it's not a bad idea to rebuild the form\n return super(EditorView, self).get(request, *args, **kwargs)\n\n if request.POST.get(\"save\") and self.form and self.form.is_valid():\n self.form.save()\n self.save_layout()\n\n # after we save the new layout configs, make sure to reload the saved data in forms\n # so the returned get() response contains updated data\n self.build_form()\n\n if request.POST.get(\"publish\") == \"1\":\n return self.dispatch_publish()\n\n return self.get(request, *args, **kwargs)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "def get_format(format_type, lang=None, use_l10n=None):\n \"\"\"\n For a specific format type, returns the format for the current\n language (locale), defaults to the format in the settings.\n format_type is the name of the format, e.g. 'DATE_FORMAT'\n\n If use_l10n is provided and is not None, that will force the value to\n be localized (or not), overriding the value of settings.USE_L10N.\n \"\"\"\n format_type = force_str(format_type)\n if format_type not in FORMAT_SETTINGS:\n return format_type\n if use_l10n or (use_l10n is None and settings.USE_L10N):\n if lang is None:\n lang = get_language()\n cache_key = (format_type, lang)\n try:\n cached = _format_cache[cache_key]\n if cached is not None:\n return cached\n else:\n # Return the general setting by default\n return getattr(settings, format_type)\n except KeyError:\n for module in get_format_modules(lang):\n try:\n val = getattr(module, format_type)\n for iso_input in ISO_INPUT_FORMATS.get(format_type, ()):\n if iso_input not in val:\n if isinstance(val, tuple):\n val = list(val)\n val.append(iso_input)\n _format_cache[cache_key] = val\n return val\n except AttributeError:\n pass\n _format_cache[cache_key] = None\n return getattr(settings, format_type)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def test_list_course_role_members_beta(self):\n url = reverse('list_course_role_members', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {\n 'rolename': 'beta',\n })\n self.assertEqual(response.status_code, 200)\n\n # check response content\n expected = {\n 'course_id': self.course.id.to_deprecated_string(),\n 'beta': []\n }\n res_json = json.loads(response.content)\n self.assertEqual(res_json, expected)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def set_user_password(self, context, user_id, user):\n return self.update_user(context, user_id, user)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "def test_parse_www_authenticate_correct(data, strict):\n headers, info = data\n # FIXME: move strict to parse argument\n httplib2.USE_WWW_AUTH_STRICT_PARSING = strict\n try:\n assert httplib2._parse_www_authenticate(headers) == info\n finally:\n httplib2.USE_WWW_AUTH_STRICT_PARSING = 0", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def test_valid_id_pathsep(self):\n '''\n Path separators in id should make it invalid\n '''\n opts = {'pki_dir': '/tmp/whatever'}\n # We have to test both path separators because os.path.normpath will\n # convert forward slashes to backslashes on Windows.\n for pathsep in ('/', '\\\\'):\n self.assertFalse(valid_id(opts, pathsep.join(('..', 'foobar'))))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " def test_get_size_from_conf_custom(self, conf_ceph_stub):\n conf_ceph_stub('''\n [global]\n fsid=asdf\n [osd]\n osd_dmcrypt_key_size=256\n ''')\n assert encryption.get_key_size_from_conf() == '256'", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "def publish(request, category_id=None):\n if category_id:\n get_object_or_404(\n Category.objects.visible(),\n pk=category_id)\n\n user = request.user\n form = TopicForm(\n user=user,\n data=post_data(request),\n initial={'category': category_id})\n cform = CommentForm(\n user=user,\n data=post_data(request))\n if (is_post(request) and\n all([form.is_valid(), cform.is_valid()]) and\n not request.is_limited()):\n if not user.st.update_post_hash(form.get_topic_hash()):\n return redirect(\n request.POST.get('next', None) or\n form.get_category().get_absolute_url())\n # wrap in transaction.atomic?\n topic = form.save()\n cform.topic = topic\n comment = cform.save()\n comment_posted(comment=comment, mentions=cform.mentions)\n return redirect(topic.get_absolute_url())\n return render(\n request=request,\n template_name='spirit/topic/publish.html',\n context={'form': form, 'cform': cform})", "label": 0, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": " def test_entrance_exam_reset_student_attempts_nonsense(self):\n \"\"\" Test failure with both unique_student_identifier and all_students. \"\"\"\n url = reverse('reset_student_attempts_for_entrance_exam',\n kwargs={'course_id': unicode(self.course.id)})\n response = self.client.get(url, {\n 'unique_student_identifier': self.student.email,\n 'all_students': True,\n })\n self.assertEqual(response.status_code, 400)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def xml(self):\n return self.helper().xml()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " async def on_exchange_third_party_invite_request(self, event_dict: Dict):\n ret = await self.handler.on_exchange_third_party_invite_request(event_dict)\n return ret", "label": 1, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "def _read_from_sections(user, collection_url, permission):\n \"\"\"Get regex sections.\"\"\"\n filename = os.path.expanduser(config.get(\"rights\", \"file\"))\n rights_type = config.get(\"rights\", \"type\").lower()\n # Prevent \"regex injection\"\n user_escaped = re.escape(user)\n collection_url_escaped = re.escape(collection_url)\n regex = ConfigParser({\"login\": user_escaped, \"path\": collection_url_escaped})\n if rights_type in DEFINED_RIGHTS:\n log.LOGGER.debug(\"Rights type '%s'\" % rights_type)\n regex.readfp(StringIO(DEFINED_RIGHTS[rights_type]))\n elif rights_type == \"from_file\":\n log.LOGGER.debug(\"Reading rights from file %s\" % filename)\n if not regex.read(filename):\n log.LOGGER.error(\"File '%s' not found for rights\" % filename)\n return False\n else:\n log.LOGGER.error(\"Unknown rights type '%s'\" % rights_type)\n return False\n\n for section in regex.sections():\n re_user = regex.get(section, \"user\")\n re_collection = regex.get(section, \"collection\")\n log.LOGGER.debug(\n \"Test if '%s:%s' matches against '%s:%s' from section '%s'\" % (\n user, collection_url, re_user, re_collection, section))\n user_match = re.match(re_user, user)\n if user_match:\n re_collection = re_collection.format(*user_match.groups())\n if re.match(re_collection, collection_url):\n log.LOGGER.debug(\"Section '%s' matches\" % section)\n if permission in regex.get(section, \"permission\"):\n return True\n else:\n log.LOGGER.debug(\"Section '%s' does not match\" % section)\n return False", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def test_format_quota_set(self):\n raw_quota_set = {\n 'instances': 10,\n 'cores': 20,\n 'ram': 51200,\n 'volumes': 10,\n 'floating_ips': 10,\n 'metadata_items': 128,\n 'gigabytes': 1000,\n 'injected_files': 5,\n 'injected_file_content_bytes': 10240,\n 'security_groups': 10,\n 'security_group_rules': 20,\n }\n\n quota_set = self.controller._format_quota_set('1234', raw_quota_set)\n qs = quota_set['quota_set']\n\n self.assertEqual(qs['id'], '1234')\n self.assertEqual(qs['instances'], 10)\n self.assertEqual(qs['cores'], 20)\n self.assertEqual(qs['ram'], 51200)\n self.assertEqual(qs['volumes'], 10)\n self.assertEqual(qs['gigabytes'], 1000)\n self.assertEqual(qs['floating_ips'], 10)\n self.assertEqual(qs['metadata_items'], 128)\n self.assertEqual(qs['injected_files'], 5)\n self.assertEqual(qs['injected_file_content_bytes'], 10240)\n self.assertEqual(qs['security_groups'], 10)\n self.assertEqual(qs['security_group_rules'], 20)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def testExtraSpecifiers(self):\n x = [-4, -3, -2, -1, 0, 1, 2, 3]\n with self.assertRaisesRegex(\n errors.InvalidArgumentError,\n \"Destination and source format must determine a permutation\"):\n op = nn_ops.data_format_dim_map(x, src_format=\"1234\", dst_format=\"5321\")\n with test_util.use_gpu():\n self.evaluate(op)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "def _parse_www_authenticate(headers, headername=\"www-authenticate\"):\n \"\"\"Returns a dictionary of dictionaries, one dict\n per auth_scheme.\"\"\"\n retval = {}\n if headername in headers:\n try:\n authenticate = headers[headername].strip()\n www_auth = (\n USE_WWW_AUTH_STRICT_PARSING and WWW_AUTH_STRICT or WWW_AUTH_RELAXED\n )\n while authenticate:\n # Break off the scheme at the beginning of the line\n if headername == \"authentication-info\":\n (auth_scheme, the_rest) = (\"digest\", authenticate)\n else:\n (auth_scheme, the_rest) = authenticate.split(\" \", 1)\n # Now loop over all the key value pairs that come after the scheme,\n # being careful not to roll into the next scheme\n match = www_auth.search(the_rest)\n auth_params = {}\n while match:\n if match and len(match.groups()) == 3:\n (key, value, the_rest) = match.groups()\n auth_params[key.lower()] = UNQUOTE_PAIRS.sub(\n r\"\\1\", value\n ) # '\\\\'.join([x.replace('\\\\', '') for x in value.split('\\\\\\\\')])\n match = www_auth.search(the_rest)\n retval[auth_scheme.lower()] = auth_params\n authenticate = the_rest.strip()\n except ValueError:\n raise MalformedHeader(\"WWW-Authenticate\")\n return retval", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def resolve_orders(root: models.User, info, **kwargs):\n from ..order.types import OrderCountableConnection\n\n def _resolve_orders(orders):\n requester = get_user_or_app_from_context(info.context)\n if not requester.has_perm(OrderPermissions.MANAGE_ORDERS):\n orders = list(\n filter(lambda order: order.status != OrderStatus.DRAFT, orders)\n )\n\n return create_connection_slice(\n orders, info, kwargs, OrderCountableConnection\n )\n\n return OrdersByUserLoader(info.context).load(root.id).then(_resolve_orders)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": "def mysql_insensitive_exact(field: Field, value: str) -> Criterion:\n return functions.Upper(functions.Cast(field, SqlTypes.CHAR)).eq(functions.Upper(f\"{value}\"))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "def parse_server_name(server_name: str) -> Tuple[str, Optional[int]]:\n \"\"\"Split a server name into host/port parts.\n\n No validation is done on the host part. The port part is validated to be\n a valid port number.\n\n Args:\n server_name: server name to parse\n\n Returns:\n host/port parts.\n\n Raises:\n ValueError if the server name could not be parsed.\n \"\"\"\n try:\n if server_name[-1] == \"]\":\n # ipv6 literal, hopefully\n return server_name, None\n\n host_port = server_name.rsplit(\":\", 1)\n host = host_port[0]\n port = host_port[1] if host_port[1:] else None\n\n if port:\n port_num = int(port)\n\n # exclude things like '08090' or ' 8090'\n if port != str(port_num) or not (1 <= port_num < 65536):\n raise ValueError(\"Invalid port\")\n\n return host, port\n except Exception:\n raise ValueError(\"Invalid server name '%s'\" % server_name)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "def publisher_list():\n if current_user.get_view_property('publisher', 'dir') == 'desc':\n order = db.Publishers.name.desc()\n order_no = 0\n else:\n order = db.Publishers.name.asc()\n order_no = 1\n if current_user.check_visibility(constants.SIDEBAR_PUBLISHER):\n entries = calibre_db.session.query(db.Publishers, func.count('books_publishers_link.book').label('count')) \\\n .join(db.books_publishers_link).join(db.Books).filter(calibre_db.common_filters()) \\\n .group_by(text('books_publishers_link.publisher')).order_by(order).all()\n charlist = calibre_db.session.query(func.upper(func.substr(db.Publishers.name, 1, 1)).label('char')) \\\n .join(db.books_publishers_link).join(db.Books).filter(calibre_db.common_filters()) \\\n .group_by(func.upper(func.substr(db.Publishers.name, 1, 1))).all()\n return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=charlist,\n title=_(u\"Publishers\"), page=\"publisherlist\", data=\"publisher\", order=order_no)\n else:\n abort(404)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def testSparseFillEmptyRowsGradMatrix(self):\n reverse_index_map = [0, 1]\n grad_values = [[0, 1], [2, 3]]\n # Note: Eager mode and graph mode throw different errors here. Graph mode\n # will fail with a ValueError from the shape checking logic, while Eager\n # will fail with an InvalidArgumentError from the kernel itself.\n if context.executing_eagerly():\n with self.assertRaisesRegex(errors.InvalidArgumentError,\n r'grad_values must be a vector'):\n self.evaluate(\n gen_sparse_ops.SparseFillEmptyRowsGrad(\n reverse_index_map=reverse_index_map, grad_values=grad_values))\n else:\n with self.assertRaisesRegex(ValueError,\n r'Shape must be rank 1 but is rank 2'):\n self.evaluate(\n gen_sparse_ops.SparseFillEmptyRowsGrad(\n reverse_index_map=reverse_index_map, grad_values=grad_values))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def __init__(self, allow_ints):\n self._allow_ints = allow_ints\n self._env = UNSAFE_ENV if allow_ints else SAFE_ENV", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": "def checkin(pickledata):\n uncompressed = bz2.decompress(base64.urlsafe_b64decode(pickledata))\n try:\n config = json.loads(uncompressed)\n except ValueError:\n config = pickle.loads(uncompressed)\n r, message = read_host_config(SESSION, config)\n if r is not None:\n return message + 'checked in successful'\n else:\n return message + 'error checking in'", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": "async def account_register_post(\n request: Request,\n U: str = Form(default=str()), # Username\n E: str = Form(default=str()), # Email\n H: str = Form(default=False), # Hide Email\n BE: str = Form(default=None), # Backup Email\n R: str = Form(default=\"\"), # Real Name\n HP: str = Form(default=None), # Homepage\n I: str = Form(default=None), # IRC Nick # noqa: E741\n K: str = Form(default=None), # PGP Key\n L: str = Form(default=aurweb.config.get(\"options\", \"default_lang\")),\n TZ: str = Form(default=aurweb.config.get(\"options\", \"default_timezone\")),\n PK: str = Form(default=None), # SSH PubKey\n CN: bool = Form(default=False),\n UN: bool = Form(default=False),\n ON: bool = Form(default=False),\n captcha: str = Form(default=None),\n captcha_salt: str = Form(...),", "label": 0, "programming_language": "Python", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "def task_remove(request, task_id):\n \"\"\"\n remove task by task_id\n :param request:\n :return:\n \"\"\"\n if request.method == 'POST':\n try:\n # delete job from DjangoJob\n task = Task.objects.get(id=task_id)\n clients = clients_of_task(task)\n for client in clients:\n job_id = get_job_id(client, task)\n DjangoJob.objects.filter(name=job_id).delete()\n # delete task\n Task.objects.filter(id=task_id).delete()\n return JsonResponse({'result': '1'})\n except:\n return JsonResponse({'result': '0'})", "label": 0, "programming_language": "Python", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "def is_valid_client_secret(client_secret):\n \"\"\"Validate that a given string matches the client_secret regex defined by the spec\n\n :param client_secret: The client_secret to validate\n :type client_secret: unicode\n\n :return: Whether the client_secret is valid\n :rtype: bool\n \"\"\"\n return client_secret_regex.match(client_secret) is not None", "label": 0, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def test_win(self):\n \"\"\"\n test if default_dir for Windows platform is accessible\n\n since default_dir_win() does not have any Windows specific code,\n let's test it everywhere\n \"\"\"\n d = catalog.default_dir_win()\n assert_(catalog.is_writable(d))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def as_const(self, eval_ctx=None):\n eval_ctx = get_eval_context(self, eval_ctx)\n if eval_ctx.volatile:\n raise Impossible()\n obj = self.node.as_const(eval_ctx)\n\n # don't evaluate context functions\n args = [x.as_const(eval_ctx) for x in self.args]\n if isinstance(obj, _context_function_types):\n if getattr(obj, 'contextfunction', False):\n raise Impossible()\n elif getattr(obj, 'evalcontextfunction', False):\n args.insert(0, eval_ctx)\n elif getattr(obj, 'environmentfunction', False):\n args.insert(0, self.environment)\n\n kwargs = dict(x.as_const(eval_ctx) for x in self.kwargs)\n if self.dyn_args is not None:\n try:\n args.extend(self.dyn_args.as_const(eval_ctx))\n except Exception:\n raise Impossible()\n if self.dyn_kwargs is not None:\n try:\n kwargs.update(self.dyn_kwargs.as_const(eval_ctx))\n except Exception:\n raise Impossible()\n try:\n return obj(*args, **kwargs)\n except Exception:\n raise Impossible()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "vulnerable"} {"code": " def freeze(self, monkeypatch):\n \"\"\"Freeze datetime and UUID.\"\"\"\n monkeypatch.setattr(\n \"s3file.forms.S3FileInputMixin.upload_folder\",\n os.path.join(storage.aws_location, \"tmp\"),\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def test_send_with_body(self):\n to_send = \"GET / HTTP/1.0\\r\\nContent-Length: 5\\r\\n\\r\\n\"\n to_send += \"hello\"\n to_send = tobytes(to_send)\n self.connect()\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, echo = self._read_echo(fp)\n self.assertline(line, \"200\", \"OK\", \"HTTP/1.0\")\n self.assertEqual(echo.content_length, \"5\")\n self.assertEqual(echo.body, b\"hello\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def __init__(self, pidfile=None):\n if not pidfile:\n # PID file moved out of /tmp to avoid security vulnerability\n # changed by Debian maintainer per Debian bug #631912\n self.pidfile = \"/var/run/pyro-%s.pid\" % self.__class__.__name__.lower()\n else:\n self.pidfile = pidfile", "label": 1, "programming_language": "Python", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "def main():\n _validate_untrusted_args(sys.argv)\n parser = get_argparser()\n argv = sys.argv[1:]\n args = parser.parse_args(argv)\n if args.json_args is not None:\n args = _unpack_json_args(args)\n earlyinit.early_init(args)\n # We do this imports late as earlyinit needs to be run first (because of\n # version checking and other early initialization)\n from qutebrowser import app\n return app.run(args)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "safe"} {"code": " def test_manage_pools(self) -> None:\n user1 = uuid4()\n user2 = uuid4()\n\n # by default, any can modify\n self.assertIsNone(\n check_can_manage_pools_impl(\n InstanceConfig(allow_pool_management=True), UserInfo()\n )\n )\n\n # with oid, but no admin\n self.assertIsNone(\n check_can_manage_pools_impl(\n InstanceConfig(allow_pool_management=True), UserInfo(object_id=user1)\n )\n )\n\n # is admin\n self.assertIsNone(\n check_can_manage_pools_impl(\n InstanceConfig(allow_pool_management=False, admins=[user1]),\n UserInfo(object_id=user1),\n )\n )\n\n # no user oid set\n self.assertIsNotNone(\n check_can_manage_pools_impl(\n InstanceConfig(allow_pool_management=False, admins=[user1]), UserInfo()\n )\n )\n\n # not an admin\n self.assertIsNotNone(\n check_can_manage_pools_impl(\n InstanceConfig(allow_pool_management=False, admins=[user1]),\n UserInfo(object_id=user2),\n )\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-346", "cwe_name": "Origin Validation Error", "description": "The software does not properly verify that the source of data or communication is valid.", "url": "https://cwe.mitre.org/data/definitions/346.html", "label_name": "vulnerable"} {"code": " def import_bookmarks(self):\n files = choose_files(self, 'export-viewer-bookmarks', _('Import bookmarks'),\n filters=[(_('Saved bookmarks'), ['pickle'])], all_files=False, select_only_single_file=True)\n if not files:\n return\n filename = files[0]\n\n imported = None\n with open(filename, 'rb') as fileobj:\n imported = cPickle.load(fileobj)\n\n if imported is not None:\n bad = False\n try:\n for bm in imported:\n if 'title' not in bm:\n bad = True\n break\n except Exception:\n pass\n\n if not bad:\n bookmarks = self.get_bookmarks()\n for bm in imported:\n if bm not in bookmarks:\n bookmarks.append(bm)\n self.set_bookmarks([bm for bm in bookmarks if bm['title'] != 'calibre_current_page_bookmark'])\n self.edited.emit(self.get_bookmarks())", "label": 0, "programming_language": "Python", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": "def edit_book_series_index(series_index, book):\n # Add default series_index to book\n modif_date = False\n series_index = series_index or '1'\n if not series_index.replace('.', '', 1).isdigit():\n flash(_(\"%(seriesindex)s is not a valid number, skipping\", seriesindex=series_index), category=\"warning\")\n return False\n if str(book.series_index) != series_index:\n book.series_index = series_index\n modif_date = True\n return modif_date", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def do_transform(self, request, response, config):\n response += check_update(config)\n misp = get_misp_connection(config, request.parameters)\n if request.entity.tag_name:\n tag_name = request.entity.tag_name\n else:\n tag_name = request.entity.value\n events_json = misp.search(controller='events', tags=tag_name, with_attachments=False)\n for e in events_json:\n response += MISPEvent(e['Event']['id'], uuid=e['Event']['uuid'], info=e['Event']['info'], link_direction=LinkDirection.OutputToInput)\n return response", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def __init__(self, **values):\n self.values = values\n self.old_values = {}", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def conditional_escape(text):\n return escape(text) if autoescape and not safe_input else text", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def _callback() -> None:\n has_bad_ip = False\n for address in addresses:\n # We only expect IPv4 and IPv6 addresses since only A/AAAA lookups\n # should go through this path.\n if not isinstance(address, (IPv4Address, IPv6Address)):\n continue\n\n ip_address = IPAddress(address.host)\n\n if check_against_blacklist(\n ip_address, self._ip_whitelist, self._ip_blacklist\n ):\n logger.info(\n \"Dropped %s from DNS resolution to %s due to blacklist\"\n % (ip_address, hostname)\n )\n has_bad_ip = True\n\n # if we have a blacklisted IP, we'd like to raise an error to block the\n # request, but all we can really do from here is claim that there were no\n # valid results.\n if not has_bad_ip:\n for address in addresses:\n recv.addressResolved(address)\n recv.resolutionComplete()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "def admin():\n version = updater_thread.get_current_version_info()\n if version is False:\n commit = _(u'Unknown')\n else:\n if 'datetime' in version:\n commit = version['datetime']\n\n tz = timedelta(seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone)\n form_date = datetime.strptime(commit[:19], \"%Y-%m-%dT%H:%M:%S\")\n if len(commit) > 19: # check if string has timezone\n if commit[19] == '+':\n form_date -= timedelta(hours=int(commit[20:22]), minutes=int(commit[23:]))\n elif commit[19] == '-':\n form_date += timedelta(hours=int(commit[20:22]), minutes=int(commit[23:]))\n commit = format_datetime(form_date - tz, format='short', locale=get_locale())\n else:\n commit = version['version']\n\n allUser = ub.session.query(ub.User).all()\n email_settings = config.get_mail_settings()\n kobo_support = feature_support['kobo'] and config.config_kobo_sync\n return render_title_template(\"admin.html\", allUser=allUser, email=email_settings, config=config, commit=commit,\n feature_support=feature_support, kobo_support=kobo_support,\n title=_(u\"Admin page\"), page=\"admin\")", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def needs_clamp(t, encoding):\n if encoding not in (Encoding.ABI, Encoding.JSON_ABI):\n return False\n if isinstance(t, (ByteArrayLike, DArrayType)):\n if encoding == Encoding.JSON_ABI:\n # don't have bytestring size bound from json, don't clamp\n return False\n return True\n if isinstance(t, BaseType) and t.typ not in (\"int256\", \"uint256\", \"bytes32\"):\n return True\n if isinstance(t, SArrayType):\n return needs_clamp(t.subtype, encoding)\n if isinstance(t, TupleLike):\n return any(needs_clamp(m, encoding) for m in t.tuple_members())\n return False", "label": 0, "programming_language": "Python", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "def test_digest_auth_stale():\n # Test that we can handle a nonce becoming stale\n http = httplib2.Http()\n password = tests.gen_password()\n grenew_nonce = [None]\n requests = []\n handler = tests.http_reflect_with_auth(\n allow_scheme=\"digest\",\n allow_credentials=((\"joe\", password),),\n out_renew_nonce=grenew_nonce,\n out_requests=requests,\n )\n with tests.server_request(handler, request_count=4) as uri:\n http.add_credentials(\"joe\", password)\n response, _ = http.request(uri, \"GET\")\n assert response.status == 200\n info = httplib2._parse_www_authenticate(\n requests[0][1].headers, \"www-authenticate\"\n )\n grenew_nonce[0]()\n response, _ = http.request(uri, \"GET\")\n assert response.status == 200\n assert not response.fromcache\n assert getattr(response, \"_stale_digest\", False)\n info2 = httplib2._parse_www_authenticate(\n requests[2][1].headers, \"www-authenticate\"\n )\n nonce1 = info.get(\"digest\", {}).get(\"nonce\", \"\")\n nonce2 = info2.get(\"digest\", {}).get(\"nonce\", \"\")\n assert nonce1 != \"\"\n assert nonce2 != \"\"\n assert nonce1 != nonce2, (nonce1, nonce2)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def _cbrt(x):\n return math.pow(x, 1.0/3)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " def test_parse_header_gardenpath(self):\n data = b\"\"\"\\\nGET /foobar HTTP/8.4\nfoo: bar\"\"\"\n self.parser.parse_header(data)\n self.assertEqual(self.parser.first_line, b\"GET /foobar HTTP/8.4\")\n self.assertEqual(self.parser.headers[\"FOO\"], \"bar\")", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": "def shutdown():\n task = int(request.args.get(\"parameter\").strip())\n showtext = {}\n if task in (0, 1): # valid commandos received\n # close all database connections\n calibre_db.dispose()\n ub.dispose()\n\n if task == 0:\n showtext['text'] = _(u'Server restarted, please reload page')\n else:\n showtext['text'] = _(u'Performing shutdown of server, please close window')\n # stop gevent/tornado server\n web_server.stop(task == 0)\n return json.dumps(showtext)\n\n if task == 2:\n log.warning(\"reconnecting to calibre database\")\n calibre_db.reconnect_db(config, ub.app_DB_path)\n showtext['text'] = _(u'Reconnect successful')\n return json.dumps(showtext)\n\n showtext['text'] = _(u'Unknown command')\n return json.dumps(showtext), 400", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "def get_install_extras_require():\n extras_require = {\n 'action': ['chevron'],\n 'browser': ['zeroconf==0.19.1' if PY2 else 'zeroconf>=0.19.1'],\n 'cloud': ['requests'],\n 'docker': ['docker>=2.0.0'],\n 'export': ['bernhard', 'cassandra-driver', 'couchdb', 'elasticsearch',\n 'graphitesender', 'influxdb>=1.0.0', 'kafka-python', 'pika',\n 'paho-mqtt', 'potsdb', 'prometheus_client', 'pyzmq',\n 'statsd'],\n 'folders': ['scandir'], # python_version<\"3.5\"\n 'gpu': ['py3nvml'],\n 'graph': ['pygal'],\n 'ip': ['netifaces'],\n 'raid': ['pymdstat'],\n 'smart': ['pySMART.smartx'],\n 'snmp': ['pysnmp'],\n 'sparklines': ['sparklines'],\n 'web': ['bottle', 'requests'],\n 'wifi': ['wifi']\n }\n # Add automatically the 'all' target\n extras_require.update({'all': [i[0] for i in extras_require.values()]})\n\n return extras_require", "label": 0, "programming_language": "Python", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " def test_reset_student_attempts_all(self, act):\n \"\"\" Test reset all student attempts. \"\"\"\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 })\n self.assertEqual(response.status_code, 200)\n self.assertTrue(act.called)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def test_reset_entrance_exam_all_student_attempts(self, act):\n \"\"\" Test reset all student attempts for entrance exam. \"\"\"\n url = reverse('reset_student_attempts_for_entrance_exam',\n kwargs={'course_id': unicode(self.course.id)})\n response = self.client.post(url, {\n 'all_students': True,\n })\n self.assertEqual(response.status_code, 200)\n self.assertTrue(act.called)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " def validate_request(self, request):\n \"\"\"If configured for webhook basic auth, validate request has correct auth.\"\"\"\n if self.basic_auth:\n request_auth = get_request_basic_auth(request)\n # Use constant_time_compare to avoid timing attack on basic auth. (It's OK that any()\n # can terminate early: we're not trying to protect how many auth strings are allowed,\n # just the contents of each individual auth string.)\n auth_ok = any(constant_time_compare(request_auth, allowed_auth)\n for allowed_auth in self.basic_auth)\n if not auth_ok:\n # noinspection PyUnresolvedReferences\n raise AnymailWebhookValidationFailure(\n \"Missing or invalid basic auth in Anymail %s webhook\" % self.esp_name)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def __init__(self, hs):\n super().__init__(hs)\n\n # An HTTP client for contacting trusted URLs.\n self.http_client = SimpleHttpClient(hs)\n # An HTTP client for contacting identity servers specified by clients.\n self.blacklisting_http_client = SimpleHttpClient(\n hs, ip_blacklist=hs.config.federation_ip_range_blacklist\n )\n self.federation_http_client = hs.get_federation_http_client()\n self.hs = hs", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def test_process_request__no_location(self, rf, settings):\n settings.AWS_LOCATION = \"\"\n uploaded_file = SimpleUploadedFile(\"uploaded_file.txt\", b\"uploaded\")\n request = rf.post(\"/\", data={\"file\": uploaded_file})\n S3FileMiddleware(lambda x: None)(request)\n assert request.FILES.getlist(\"file\")\n assert request.FILES.get(\"file\").read() == b\"uploaded\"\n\n storage.save(\"tmp/s3file/s3_file.txt\", ContentFile(b\"s3file\"))\n request = rf.post(\n \"/\", data={\"file\": \"tmp/s3file/s3_file.txt\", \"s3file\": \"file\"}\n )\n S3FileMiddleware(lambda x: None)(request)\n assert request.FILES.getlist(\"file\")\n assert request.FILES.get(\"file\").read() == b\"s3file\"", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def test_prevent_control_characters_in_headers(self):\n apis = 'append', 'replace', '__setitem__', 'setdefault'\n masks = '{}test', 'test{}', 'te{}st'\n tests = '\\n', '\\r', '\\n\\r', '\\0'\n for api, mask, test in itertools.product(apis, masks, tests):\n hd = bottle.HeaderDict()\n func = getattr(hd, api)\n value = mask.replace(\"{}\", test)\n self.assertRaises(ValueError, func, value, \"test-value\")\n self.assertRaises(ValueError, func, \"test-name\", value)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-93", "cwe_name": "Improper Neutralization of CRLF Sequences ('CRLF Injection')", "description": "The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.", "url": "https://cwe.mitre.org/data/definitions/93.html", "label_name": "safe"} {"code": " def test_get_header_lines_folded(self):\n # From RFC2616:\n # HTTP/1.1 header field values can be folded onto multiple lines if the\n # continuation line begins with a space or horizontal tab. All linear\n # white space, including folding, has the same semantics as SP. A\n # recipient MAY replace any linear white space with a single SP before\n # interpreting the field value or forwarding the message downstream.\n\n # We are just preserving the whitespace that indicates folding.\n result = self._callFUT(b\"slim\\n slam\")\n self.assertEqual(result, [b\"slim slam\"])", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " def test_get_response_httperror_exception(self, mock_get):\n mock_response = mock.Mock()\n mock_response.status_code = 500\n mock_response.text = \"Server Error\"\n http_error = requests.HTTPError()\n mock_response.raise_for_status.side_effect = http_error\n mock_get.return_value = mock_response\n\n url = \"https://example.com/\"\n query_runner = BaseHTTPQueryRunner({})\n response, error = query_runner.get_response(url)\n mock_get.assert_called_once_with(\"get\", url, auth=None)\n self.assertIsNotNone(error)\n self.assertIn(\"Failed to execute query\", error)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def test_setup_if_htdocs_does_not_exist_but_library_does(self):\n shutil.copytree('tests/data/app-7', self.build_dir)\n setup_webdir_if_it_doesnt_exist(utils.FormattedDict({\n 'BUILD_DIR': self.build_dir,\n 'WEBDIR': 'htdocs',\n 'LIBDIR': 'lib'\n }))\n self.assert_exists(self.build_dir, 'htdocs')\n self.assert_exists(self.build_dir, 'htdocs', 'index.php')\n self.assert_exists(self.build_dir, 'htdocs', 'info.php')\n self.assert_exists(self.build_dir, 'htdocs',\n 'technical-difficulties1.jpg')\n self.assert_exists(self.build_dir, 'htdocs', 'library')\n self.assert_exists(self.build_dir, 'htdocs', 'library', 'junk.php')\n self.assert_exists(self.build_dir, 'lib')\n self.assert_exists(self.build_dir, 'lib', 'test.php')\n self.assert_exists(self.build_dir, '.bp-config')\n self.assert_exists(self.build_dir, '.bp-config', 'options.json')\n self.assert_exists(self.build_dir, '.bp-config', 'httpd', 'extra',\n 'httpd-remoteip.conf')\n self.assert_exists(self.build_dir, 'manifest.yml')\n eq_(4, len(os.listdir(self.build_dir)))\n eq_(4, len(os.listdir(os.path.join(self.build_dir, 'htdocs'))))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "vulnerable"} {"code": " def test_repository_swap_detection(self):\n self.create_test_files()\n os.environ['ATTIC_PASSPHRASE'] = 'passphrase'\n self.attic('init', '--encryption=passphrase', self.repository_location)\n repository_id = self._extract_repository_id(self.repository_path)\n self.attic('create', self.repository_location + '::test', 'input')\n shutil.rmtree(self.repository_path)\n self.attic('init', '--encryption=none', self.repository_location)\n self._set_repository_id(self.repository_path, repository_id)\n self.assert_equal(repository_id, self._extract_repository_id(self.repository_path))\n self.assert_raises(Cache.EncryptionMethodMismatch, lambda :self.attic('create', self.repository_location + '::test.2', 'input'))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def test_double_linefeed(self):\n self.assertEqual(self._callFUT(b\"\\n\\n\"), 2)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " def test_get_concealed_token(self):\n auth.HASH_PATH_PREFIX = 'start'\n auth.HASH_PATH_SUFFIX = 'end'\n token = 'token'\n\n # Check sha512 of \"start:token:end\"\n hashed_token = self.test_auth._get_concealed_token(token)\n self.assertEqual(hashed_token,\n 'cb320540b0b4c69eb83de2ffb80714cb6766e2d06b5579d1a35a9c4c3fb62'\n '981ec50bcc3fb94521133e69a87d1efcb83efd78f35a06b6375e410201476'\n '0722f6')\n\n # Check sha512 of \"start:token2:end\"\n token = 'token2'\n hashed_token = self.test_auth._get_concealed_token(token)\n self.assertEqual(hashed_token,\n 'ca400a6f884c168357f6af0609fda66aecd5aa613147167487495dd9f39fd'\n '8a77288568e65857294f01e398d7f14328e855f18517ccf94185d849e7f34'\n 'f4259d')\n\n # Check sha512 of \"start2:token2:end\"\n auth.HASH_PATH_PREFIX = 'start2'\n hashed_token = self.test_auth._get_concealed_token(token)\n self.assertEqual(hashed_token,\n 'ad594a69f44dd6e0aad54e360b01f15bd4833ccb4dcd9116d7aba0c25fb95'\n '670155b8cc7175def7aeeb4624a0f2bb7da5f0b204a4680ea7947d3d6a045'\n '22bdde')\n\n # Check sha512 of \"start2:token2:end2\"\n auth.HASH_PATH_SUFFIX = 'end2'\n hashed_token = self.test_auth._get_concealed_token(token)\n self.assertEqual(hashed_token,\n '446af2473ad6b28319a0fe02719a9d715b9941d12e0709851aedb4f53b890'\n '693e7f1328e68d870fe114f35f4ed9648b16a5013182db50d3d1f79a660f2'\n '0e078e')", "label": 1, "programming_language": "Python", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": " def testSparseCountSparseOutputBadNumberOfValues(self):\n indices = [[0, 0], [0, 1], [1, 0]]\n values = [1, 1, 1, 10]\n weights = [1, 2, 4, 6]\n dense_shape = [2, 3]\n with self.assertRaisesRegex(\n errors.InvalidArgumentError,\n \"Number of values must match first dimension of indices\"):\n self.evaluate(\n gen_count_ops.SparseCountSparseOutput(\n indices=indices,\n values=values,\n dense_shape=dense_shape,\n weights=weights,\n binary_output=False))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " def testWrongDimensions(self):\n # The matrix and right-hand sides should have the same number of rows.\n matrix = constant_op.constant([[1., 0.], [0., 1.]])\n rhs = constant_op.constant([[1., 0.]])\n with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)):\n self.evaluate(linalg_ops.matrix_solve(matrix, rhs))\n\n # The matrix and right-hand side should have the same batch dimensions\n matrix = np.random.normal(size=(2, 6, 2, 2))\n rhs = np.random.normal(size=(2, 3, 2, 2))\n with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)):\n self.evaluate(linalg_ops.matrix_solve(matrix, rhs))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-354", "cwe_name": "Improper Validation of Integrity Check Value", "description": "The software does not validate or incorrectly validates the integrity check values or \"checksums\" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission.", "url": "https://cwe.mitre.org/data/definitions/354.html", "label_name": "safe"} {"code": " def testPartialIndexInsert(self):\n with ops.Graph().as_default() as g:\n with ops.device('/cpu:0'):\n x = array_ops.placeholder(dtypes.float32)\n f = array_ops.placeholder(dtypes.float32)\n v = array_ops.placeholder(dtypes.float32)\n pi = array_ops.placeholder(dtypes.int64)\n gi = array_ops.placeholder(dtypes.int64)\n with ops.device(test.gpu_device_name()):\n stager = data_flow_ops.MapStagingArea(\n [dtypes.float32, dtypes.float32, dtypes.float32])\n stage_xf = stager.put(pi, [x, f], [0, 2])\n stage_v = stager.put(pi, [v], [1])\n key, ret = stager.get(gi)\n size = stager.size()\n isize = stager.incomplete_size()\n\n g.finalize()\n\n with self.session(graph=g) as sess:\n # 0 complete and incomplete entries\n self.assertEqual(sess.run([size, isize]), [0, 0])\n # Stage key 0, x and f tuple entries\n sess.run(stage_xf, feed_dict={pi: 0, x: 1, f: 2})\n self.assertEqual(sess.run([size, isize]), [0, 1])\n # Stage key 1, x and f tuple entries\n sess.run(stage_xf, feed_dict={pi: 1, x: 1, f: 2})\n self.assertEqual(sess.run([size, isize]), [0, 2])\n\n # Now complete key 0 with tuple entry v\n sess.run(stage_v, feed_dict={pi: 0, v: 1})\n # 1 complete and 1 incomplete entry\n self.assertEqual(sess.run([size, isize]), [1, 1])\n # We can now obtain tuple associated with key 0\n self.assertEqual(sess.run([key, ret], feed_dict={gi: 0}), [0, [1, 1, 2]])\n\n # 0 complete and 1 incomplete entry\n self.assertEqual(sess.run([size, isize]), [0, 1])\n # Now complete key 1 with tuple entry v\n sess.run(stage_v, feed_dict={pi: 1, v: 3})\n # We can now obtain tuple associated with key 1\n self.assertEqual(sess.run([key, ret], feed_dict={gi: 1}), [1, [1, 3, 2]])", "label": 1, "programming_language": "Python", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "safe"} {"code": " def item_to_bm(self, item):\n return cPickle.loads(bytes(item.data(Qt.UserRole)))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": "def list_entrance_exam_instructor_tasks(request, course_id): # pylint: disable=invalid-name\n \"\"\"\n List entrance exam related instructor tasks.\n\n Takes either of the following query parameters\n - unique_student_identifier is an email or username\n - all_students is a boolean\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n course = get_course_by_id(course_id)\n student = request.POST.get('unique_student_identifier', None)\n if student is not None:\n student = get_student_from_identifier(student)\n\n try:\n entrance_exam_key = course_id.make_usage_key_from_deprecated_string(course.entrance_exam_id)\n except InvalidKeyError:\n return HttpResponseBadRequest(_(\"Course has no valid entrance exam section.\"))\n if student:\n # Specifying for a single student's entrance exam history\n tasks = instructor_task.api.get_entrance_exam_instructor_task_history(course_id, entrance_exam_key, student)\n else:\n # Specifying for all student's entrance exam history\n tasks = instructor_task.api.get_entrance_exam_instructor_task_history(course_id, entrance_exam_key)\n\n response_payload = {\n 'tasks': map(extract_task_features, tasks),\n }\n return JsonResponse(response_payload)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n config = self.default_config()\n config[\"redaction_retention_period\"] = \"30d\"\n return self.setup_test_homeserver(\n resource_for_federation=Mock(), federation_http_client=None, config=config\n )", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def test_jwt_valid_issuer(self, hge_ctx, endpoint):\n jwt_conf = json.loads(hge_ctx.hge_jwt_conf)\n if 'issuer' not in jwt_conf:\n pytest.skip('issuer not present in conf, skipping testing issuer')\n\n issuer = jwt_conf['issuer']\n self.claims['https://hasura.io/jwt/claims'] = mk_claims(hge_ctx.hge_jwt_conf, {\n 'x-hasura-user-id': '1',\n 'x-hasura-default-role': 'user',\n 'x-hasura-allowed-roles': ['user'],\n })\n self.claims['iss'] = issuer\n\n token = jwt.encode(self.claims, hge_ctx.hge_jwt_key, algorithm='RS512').decode('utf-8')\n self.conf['headers']['Authorization'] = 'Bearer ' + token\n check_query(hge_ctx, self.conf, add_auth=False)", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " def test_get_server_key(self):\n \"\"\"\n Test that the correct path is given to the binding.\n \"\"\"\n static_request = StaticRequest(mock.MagicMock(spec=PulpConnection))\n response = static_request.get_server_key()\n static_request.server.GET.assert_called_once_with('/pulp/static/rsa_pub.key',\n ignore_prefix=True)\n self.assertTrue(response is static_request.server.GET.return_value)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "safe"} {"code": " def __init__(self, directory=None, pattern='__jinja2_%s.cache'):\n if directory is None:\n directory = tempfile.gettempdir()\n self.directory = directory\n self.pattern = pattern", "label": 0, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": "def lcase(s):\n try:\n return unidecode.unidecode(s.lower())\n except Exception as ex:\n log = logger.create()\n log.error_or_exception(ex)\n return s.lower()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def task_create(request):\n \"\"\"\n add task\n :param request: request object\n :return: Bool\n \"\"\"\n if request.method == 'POST':\n data = json.loads(request.body)\n task = Task.objects.create(clients=json.dumps(data.get('clients'), ensure_ascii=False),\n project=data.get('project'),\n name=data.get('name'),\n spider=data.get('spider'),\n trigger=data.get('trigger'),\n configuration=json.dumps(data.get('configuration'), ensure_ascii=False),\n modified=1)\n return JsonResponse({'result': '1', 'data': model_to_dict(task)})", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def test_unlimited_security_group_rules(self):\n\n def fake_security_group_rule_count_by_group(context, sec_group_id):\n return 0\n\n self.stubs.Set(db, 'security_group_rule_count_by_group',\n fake_security_group_rule_count_by_group)\n\n self.flags(quota_security_group_rules=20)\n rules = quota.allowed_security_group_rules(self.context, 1234, 100)\n self.assertEqual(rules, 20)\n db.quota_create(self.context, self.project_id, 'security_group_rules',\n -1)\n rules = quota.allowed_security_group_rules(self.context, 1234, 100)\n self.assertEqual(rules, 100)\n rules = quota.allowed_security_group_rules(self.context, 1234, 101)\n self.assertEqual(rules, 101)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def process_request(self, request):\n \"\"\" Adds data necessary for Horizon to function to the request.\n\n Adds the current \"active\" :class:`~horizon.Dashboard` and\n :class:`~horizon.Panel` to ``request.horizon``.\n\n Adds a :class:`~horizon.users.User` object to ``request.user``.\n \"\"\"\n # A quick and dirty way to log users out\n def user_logout(request):\n if hasattr(request, '_cached_user'):\n del request._cached_user\n # Use flush instead of clear, so we rotate session keys in\n # addition to clearing all the session data\n request.session.flush()\n request.__class__.user_logout = user_logout\n\n request.__class__.user = users.LazyUser()\n request.horizon = {'dashboard': None, 'panel': None}", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "def login_record(success=True):\n denied_hosts = read_hosts_deny()\n val = (0, 0)\n if success and request.client in denied_hosts:\n del denied_hosts[request.client]\n elif not success:\n val = denied_hosts.get(request.client, (0, 0))\n if time.time() - val[1] < expiration_failed_logins \\\n and val[0] >= allowed_number_of_attempts:\n return val[0] # locked out\n time.sleep(2 ** val[0])\n val = (val[0] + 1, int(time.time()))\n denied_hosts[request.client] = val\n write_hosts_deny(denied_hosts)\n return val[0]", "label": 1, "programming_language": "Python", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "safe"} {"code": " def test_can_read_token_from_query_parameters(self):\n \"\"\"Tests that Sydent correctly extracts an auth token from query parameters\"\"\"\n self.sydent.run()\n\n request, _ = make_request(\n self.sydent.reactor, \"GET\",\n \"/_matrix/identity/v2/hash_details?access_token=\" + self.test_token\n )\n\n token = tokenFromRequest(request)\n\n self.assertEqual(token, self.test_token)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n # we mock out the keyring so as to skip the authentication check on the\n # federation API call.\n mock_keyring = Mock(spec=[\"verify_json_for_server\"])\n mock_keyring.verify_json_for_server.return_value = defer.succeed(True)\n\n # we mock out the federation client too\n mock_federation_client = Mock(spec=[\"put_json\"])\n mock_federation_client.put_json.return_value = defer.succeed((200, \"OK\"))\n\n # the tests assume that we are starting at unix time 1000\n reactor.pump((1000,))\n\n hs = self.setup_test_homeserver(\n notifier=Mock(),\n federation_http_client=mock_federation_client,\n keyring=mock_keyring,\n replication_streams={},\n )\n\n return hs", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": "def preprocess_input_exprs_arg_string(input_exprs_str, safe=True):\n \"\"\"Parses input arg into dictionary that maps input key to python expression.\n\n Parses input string in the format of 'input_key=' into a\n dictionary that maps each input_key to its python expression.\n\n Args:\n input_exprs_str: A string that specifies python expression for input keys.\n Each input is separated by semicolon. For each input key:\n 'input_key='\n safe: Whether to evaluate the python expression as literals or allow\n arbitrary calls (e.g. numpy usage).\n\n Returns:\n A dictionary that maps input keys to their values.\n\n Raises:\n RuntimeError: An error when the given input string is in a bad format.\n \"\"\"\n input_dict = {}\n\n for input_raw in filter(bool, input_exprs_str.split(';')):\n if '=' not in input_exprs_str:\n raise RuntimeError('--input_exprs \"%s\" format is incorrect. Please follow'\n '\"=\"' % input_exprs_str)\n input_key, expr = input_raw.split('=', 1)\n if safe:\n try:\n input_dict[input_key] = ast.literal_eval(expr)\n except:\n raise RuntimeError(\n f'Expression \"{expr}\" is not a valid python literal.')\n else:\n # ast.literal_eval does not work with numpy expressions\n input_dict[input_key] = eval(expr) # pylint: disable=eval-used\n return input_dict", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def do_focus_out(self):\n if self.__has_input_purpose:\n self.__input_purpose = 0\n mode = self.__prefs.get_value('common', 'behavior_on_focus_out')\n if mode == 0 or mode == 1:\n self.__reset()\n self.__invalidate()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-255", "cwe_name": "Credentials Management Errors", "description": "Weaknesses in this category are related to the management of credentials.", "url": "https://cwe.mitre.org/data/definitions/255.html", "label_name": "safe"} {"code": " def test(self):\n actual = util.load_yaml('''\nid: 1\nnames:\n - tadashi\n - aikawa\n ''')\n assert actual == {\n \"id\": 1,\n \"names\": ['tadashi', 'aikawa']\n }", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "def quota_set(class_name):\n return {'quota_class_set': {'id': class_name, 'metadata_items': 128,\n 'volumes': 10, 'gigabytes': 1000, 'ram': 51200,\n 'floating_ips': 10, 'instances': 10, 'injected_files': 5,\n 'cores': 20, 'injected_file_content_bytes': 10240}}", "label": 0, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " def test_received_preq_completed_empty(self):\n inst, sock, map = self._makeOneWithMap()\n inst.server = DummyServer()\n preq = DummyParser()\n inst.request = preq\n preq.completed = True\n preq.empty = True\n inst.received(b\"GET / HTTP/1.1\\n\\n\")\n self.assertEqual(inst.request, None)\n self.assertEqual(inst.server.tasks, [])", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": "def main() -> None:\n formatter = argparse.ArgumentDefaultsHelpFormatter\n parser = argparse.ArgumentParser(formatter_class=formatter)\n parser.add_argument(\"resource_group\")\n parser.add_argument(\"storage_account\")\n parser.add_argument(\"admins\", type=UUID, nargs=\"*\")\n args = parser.parse_args()\n\n client = get_client_from_cli_profile(StorageManagementClient)\n storage_keys = client.storage_accounts.list_keys(\n args.resource_group, args.storage_account\n )\n table_service = TableService(\n account_name=args.storage_account, account_key=storage_keys.keys[0].value\n )\n update_admins(table_service, args.resource_group, args.admins)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-285", "cwe_name": "Improper Authorization", "description": "The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/285.html", "label_name": "vulnerable"} {"code": " def from_data(*, data: oai.Operation, path: str, method: str, tag: str) -> Union[Endpoint, ParseError]:\n \"\"\" Construct an endpoint from the OpenAPI data \"\"\"\n\n if data.operationId is None:\n return ParseError(data=data, detail=\"Path operations with operationId are not yet supported\")\n\n endpoint = Endpoint(\n path=path,\n method=method,\n description=data.description,\n name=data.operationId,\n requires_security=bool(data.security),\n tag=tag,\n )\n\n result = Endpoint._add_parameters(endpoint, data)\n if isinstance(result, ParseError):\n return result\n result = Endpoint._add_responses(result, data.responses)\n if isinstance(result, ParseError):\n return result\n result = Endpoint._add_body(result, data)\n\n return result", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " def test_list_course_role_members_beta(self):\n url = reverse('list_course_role_members', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.post(url, {\n 'rolename': 'beta',\n })\n self.assertEqual(response.status_code, 200)\n\n # check response content\n expected = {\n 'course_id': self.course.id.to_deprecated_string(),\n 'beta': []\n }\n res_json = json.loads(response.content)\n self.assertEqual(res_json, expected)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "def _glob_matches(glob: str, value: str, word_boundary: bool = False) -> bool:\n \"\"\"Tests if value matches glob.\n\n Args:\n glob\n value: String to test against glob.\n word_boundary: Whether to match against word boundaries or entire\n string. Defaults to False.\n \"\"\"\n\n try:\n r = regex_cache.get((glob, True, word_boundary), None)\n if not r:\n r = glob_to_regex(glob, word_boundary)\n regex_cache[(glob, True, word_boundary)] = r\n return bool(r.search(value))\n except re.error:\n logger.warning(\"Failed to parse glob to regex: %r\", glob)\n return False", "label": 1, "programming_language": "Python", "cwe_id": "CWE-331", "cwe_name": "Insufficient Entropy", "description": "The software uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.", "url": "https://cwe.mitre.org/data/definitions/331.html", "label_name": "safe"} {"code": "def mysql_ends_with(field: Term, value: str) -> Criterion:\n return Like(\n functions.Cast(field, SqlTypes.CHAR), StrWrapper(f\"%{escape_like(value)}\"), escape=\"\"\n )", "label": 1, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def test_keepalive_http_10(self):\n # Handling of Keep-Alive within HTTP 1.0\n data = \"Default: Don't keep me alive\"\n s = tobytes(\n \"GET / HTTP/1.0\\r\\nContent-Length: %d\\r\\n\\r\\n%s\" % (len(data), data)\n )\n self.connect()\n self.sock.send(s)\n response = httplib.HTTPResponse(self.sock)\n response.begin()\n self.assertEqual(int(response.status), 200)\n connection = response.getheader(\"Connection\", \"\")\n # We sent no Connection: Keep-Alive header\n # Connection: close (or no header) is default.\n self.assertTrue(connection != \"Keep-Alive\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def testRaggedCountSparseOutputBadWeightsShape(self):\n splits = [0, 4, 7]\n values = [1, 1, 2, 1, 2, 10, 5]\n weights = [1, 2, 3, 4, 5, 6]\n with self.assertRaisesRegex(errors.InvalidArgumentError,\n \"Weights and values must have the same shape\"):\n self.evaluate(\n gen_count_ops.RaggedCountSparseOutput(\n splits=splits,\n values=values,\n weights=weights,\n binary_output=False))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "def malt_regex_tagger():\n from nltk.tag import RegexpTagger\n\n _tagger = RegexpTagger(\n [\n (r\"\\.$\", \".\"),\n (r\"\\,$\", \",\"),\n (r\"\\?$\", \"?\"), # fullstop, comma, Qmark\n (r\"\\($\", \"(\"),\n (r\"\\)$\", \")\"), # round brackets\n (r\"\\[$\", \"[\"),\n (r\"\\]$\", \"]\"), # square brackets\n (r\"^-?[0-9]+(.[0-9]+)?$\", \"CD\"), # cardinal numbers\n (r\"(The|the|A|a|An|an)$\", \"DT\"), # articles\n (r\"(He|he|She|she|It|it|I|me|Me|You|you)$\", \"PRP\"), # pronouns\n (r\"(His|his|Her|her|Its|its)$\", \"PRP$\"), # possessive\n (r\"(my|Your|your|Yours|yours)$\", \"PRP$\"), # possessive\n (r\"(on|On|in|In|at|At|since|Since)$\", \"IN\"), # time prepopsitions\n (r\"(for|For|ago|Ago|before|Before)$\", \"IN\"), # time prepopsitions\n (r\"(till|Till|until|Until)$\", \"IN\"), # time prepopsitions\n (r\"(by|By|beside|Beside)$\", \"IN\"), # space prepopsitions\n (r\"(under|Under|below|Below)$\", \"IN\"), # space prepopsitions\n (r\"(over|Over|above|Above)$\", \"IN\"), # space prepopsitions\n (r\"(across|Across|through|Through)$\", \"IN\"), # space prepopsitions\n (r\"(into|Into|towards|Towards)$\", \"IN\"), # space prepopsitions\n (r\"(onto|Onto|from|From)$\", \"IN\"), # space prepopsitions\n (r\".*able$\", \"JJ\"), # adjectives\n (r\".*ness$\", \"NN\"), # nouns formed from adjectives\n (r\".*ly$\", \"RB\"), # adverbs\n (r\".*s$\", \"NNS\"), # plural nouns\n (r\".*ing$\", \"VBG\"), # gerunds\n (r\".*ed$\", \"VBD\"), # past tense verbs\n (r\".*\", \"NN\"), # nouns (default)\n ]\n )\n return _tagger.tag", "label": 0, "programming_language": "Python", "cwe_id": "CWE-1333", "cwe_name": "Inefficient Regular Expression Complexity", "description": "The product uses a regular expression with an inefficient, possibly exponential worst-case computational complexity that consumes excessive CPU cycles.", "url": "https://cwe.mitre.org/data/definitions/1333.html", "label_name": "vulnerable"} {"code": "def checkin(pickledata):\n config = pickle.loads(bz2.decompress(base64.urlsafe_b64decode(pickledata)))\n r, message = read_host_config(SESSION, config)\n if r is not None:\n return message + 'checked in successful'\n else:\n return message + 'error checking in'", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "def login_record(success=True):\n denied_hosts = read_hosts_deny()\n val = (0, 0)\n if success and request.client in denied_hosts:\n del denied_hosts[request.client]\n elif not success and not request.is_local:\n val = denied_hosts.get(request.client, (0, 0))\n if time.time() - val[1] < expiration_failed_logins \\\n and val[0] >= allowed_number_of_attempts:\n return val[0] # locked out\n time.sleep(2 ** val[0])\n val = (val[0] + 1, int(time.time()))\n denied_hosts[request.client] = val\n write_hosts_deny(denied_hosts)\n return val[0]", "label": 0, "programming_language": "Python", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "vulnerable"} {"code": " def test_received_no_doublecr(self):\n data = b\"GET /foobar HTTP/8.4\\r\\n\"\n result = self.parser.received(data)\n self.assertEqual(result, 22)\n self.assertFalse(self.parser.completed)\n self.assertEqual(self.parser.headers, {})", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "def _ensureValidMethod(method):\n \"\"\"\n An HTTP method is an HTTP token, which consists of any visible\n ASCII character that is not a delimiter (i.e. one of\n C{\"(),/:;<=>?@[\\\\]{}}.)\n\n @param method: the method to check\n @type method: L{bytes}\n\n @return: the method if it is valid\n @rtype: L{bytes}\n\n @raise ValueError: if the method is not valid\n\n @see: U{https://tools.ietf.org/html/rfc7230#section-3.1.1},\n U{https://tools.ietf.org/html/rfc7230#section-3.2.6},\n U{https://tools.ietf.org/html/rfc5234#appendix-B.1}\n \"\"\"\n if _VALID_METHOD.match(method):\n return method\n raise ValueError(\"Invalid method {!r}\".format(method))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " def test_pathWithNonASCIIRejected(self):\n \"\"\"\n Issuing a request with a URI whose path contains non-ASCII\n characters fails with a L{ValueError}.\n \"\"\"\n for c in NONASCII:\n uri = b\"http://twisted.invalid/OK%s\" % (bytearray([c]),)\n with self.assertRaises(ValueError) as cm:\n self.attemptRequestWithMaliciousURI(uri)\n self.assertRegex(str(cm.exception), \"^Invalid URI\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " def testSparseFillEmptyRowsGrad(self):\n reverse_index_map = [2, 1]\n grad_values = [0, 1, 2, 3]\n d_values, d_default_value = self.evaluate(\n gen_sparse_ops.SparseFillEmptyRowsGrad(\n reverse_index_map=reverse_index_map, grad_values=grad_values))\n self.assertAllEqual([2, 1], d_values)\n self.assertEqual(3, d_default_value)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def job_cancel(request, client_id, project_name, job_id):\n \"\"\"\n cancel a job\n :param request: request object\n :param client_id: client id\n :param project_name: project name\n :param job_id: job id\n :return: json of cancel\n \"\"\"\n if request.method == 'GET':\n client = Client.objects.get(id=client_id)\n try:\n scrapyd = get_scrapyd(client)\n result = scrapyd.cancel(project_name, job_id)\n return JsonResponse(result)\n except ConnectionError:\n return JsonResponse({'message': 'Connect Error'})", "label": 0, "programming_language": "Python", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " def __init__(\n self,\n host,\n port=None,\n key_file=None,\n cert_file=None,\n strict=None,\n timeout=None,\n proxy_info=None,", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def setup(self, request, hge_ctx):\n self.dir = 'queries/graphql_query/permissions'\n st_code, resp = hge_ctx.v1q_f(self.dir + '/setup.yaml')\n assert st_code == 200, resp\n yield\n st_code, resp = hge_ctx.v1q_f(self.dir + '/teardown.yaml')\n assert st_code == 200, resp", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " def is_node(cls, path):\n abs_path = os.path.join(FOLDER, path.replace(\"/\", os.sep))\n return os.path.isdir(abs_path)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-21", "cwe_name": "DEPRECATED: Pathname Traversal and Equivalence Errors", "description": "This category has been deprecated. It was originally used for organizing weaknesses involving file names, which enabled access to files outside of a restricted directory (path traversal) or to perform operations on files that would otherwise be restricted (path equivalence). Consider using either the File Handling Issues category (CWE-1219) or the class Use of Incorrectly-Resolved Name or Reference (CWE-706).", "url": "https://cwe.mitre.org/data/definitions/21.html", "label_name": "vulnerable"} {"code": "def spider_list(request, client_id, project_name):\n \"\"\"\n get spider list from one client\n :param request: request Object\n :param client_id: client id\n :param project_name: project name\n :return: json\n \"\"\"\n if request.method == 'GET':\n client = Client.objects.get(id=client_id)\n scrapyd = get_scrapyd(client)\n spiders = scrapyd.list_spiders(project_name)\n spiders = [{'name': spider, 'id': index + 1} for index, spider in enumerate(spiders)]\n return JsonResponse(spiders)", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def load(klass):\n \"\"\"\n Insantiates the configuration by attempting to load the\n configuration from YAML files specified by the CONF_PATH module\n variable. This should be the main entry point for configuration.\n \"\"\"\n config = klass()\n for path in klass.CONF_PATHS:\n if os.path.exists(path):\n with open(path, 'r') as conf:\n config.configure(yaml.safe_load(conf))\n return config", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " def test_incorrect_permissions(self):\n \"\"\"\n if permissions on existing im dir are not correct,\n new one should be created\n \"\"\"\n if sys.platform != 'win32':\n tmpdir = tempfile.mkdtemp()\n try:\n im_dir = catalog.create_intermediate_dir(tmpdir)\n root_im_dir = os.path.dirname(im_dir)\n try:\n os.chmod(root_im_dir, 0o777)\n except OSError:\n raise KnownFailureTest(\"Can't set file permissions.\")\n else:\n self.dirs_are_valid(im_dir, tmpdir)\n finally:\n remove_tree(tmpdir)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def emit(self, s, depth, reflow=True):\n # XXX reflow long lines?\n if reflow:\n lines = reflow_lines(s, depth)\n else:\n lines = [s]\n for line in lines:\n if line:\n line = (\" \" * TABSIZE * depth) + line\n self.file.write(line + \"\\n\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "def get_user_from_request(request):\n \"\"\" Checks the current session and returns a :class:`~horizon.users.User`.\n\n If the session contains user data the User will be treated as\n authenticated and the :class:`~horizon.users.User` will have all\n its attributes set.\n\n If not, the :class:`~horizon.users.User` will have no attributes set.\n\n If the session contains invalid data,\n :exc:`~horizon.exceptions.NotAuthorized` will be raised.\n \"\"\"\n if 'user_id' not in request.session:\n return User()\n try:\n return User(id=request.session['user_id'],\n token=request.session['token'],\n user=request.session['user_name'],\n tenant_id=request.session['tenant_id'],\n tenant_name=request.session['tenant'],\n service_catalog=request.session['serviceCatalog'],\n roles=request.session['roles'],\n request=request)\n except KeyError:\n # If any of those keys are missing from the session it is\n # overwhelmingly likely that we're dealing with an outdated session.\n LOG.exception(\"Error while creating User from session.\")\n request.user_logout()\n raise exceptions.NotAuthorized(_(\"Your session has expired. \"\n \"Please log in again.\"))", "label": 1, "programming_language": "Python", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " def text(self):\n components = (\n ical.Timezone, ical.Event, ical.Todo, ical.Journal, ical.Card)\n items = set()\n try:\n filenames = os.listdir(self._filesystem_path)\n except (OSError, IOError) as e:\n log.LOGGER.info('Error while reading collection %r: %r'\n % (self._filesystem_path, e))\n return \"\"\n\n for filename in filenames:\n path = os.path.join(self._filesystem_path, filename)\n try:\n with filesystem.open(path) as fd:\n items.update(self._parse(fd.read(), components))\n except (OSError, IOError) as e:\n log.LOGGER.warning('Error while reading item %r: %r'\n % (path, e))\n\n return ical.serialize(\n self.tag, self.headers, sorted(items, key=lambda x: x.name))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-21", "cwe_name": "DEPRECATED: Pathname Traversal and Equivalence Errors", "description": "This category has been deprecated. It was originally used for organizing weaknesses involving file names, which enabled access to files outside of a restricted directory (path traversal) or to perform operations on files that would otherwise be restricted (path equivalence). Consider using either the File Handling Issues category (CWE-1219) or the class Use of Incorrectly-Resolved Name or Reference (CWE-706).", "url": "https://cwe.mitre.org/data/definitions/21.html", "label_name": "safe"} {"code": " def test_symlink(self):\n \"\"\" im dir shouldn't be a symlink \"\"\"\n if sys.platform != 'win32':\n r_im_dir = os.path.dirname(catalog.intermediate_dir())\n assert_(os.path.islink(r_im_dir) is False)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def test_get_anon_ids(self):\n \"\"\"\n Test the CSV output for the anonymized user ids.\n \"\"\"\n url = reverse('get_anon_ids', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.post(url, {})\n self.assertEqual(response['Content-Type'], 'text/csv')\n body = response.content.replace('\\r', '')\n self.assertTrue(body.startswith(\n '\"User ID\",\"Anonymized User ID\",\"Course Specific Anonymized User ID\"'\n '\\n\"{user_id}\",\"41\",\"42\"\\n'.format(user_id=self.students[0].id)\n ))\n self.assertTrue(\n body.endswith('\"{user_id}\",\"41\",\"42\"\\n'.format(user_id=self.students[-1].id))\n )", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " def cmd_pasv(self, arg):\n with socket.create_server((self.socket.getsockname()[0], 0)) as sock:\n sock.settimeout(TIMEOUT)\n ip, port = sock.getsockname()[:2]\n ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256\n self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))\n conn, addr = sock.accept()\n self.dtp = self.dtp_handler(conn, baseclass=self)", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "def _bind_write_headers(msg):\n def _write_headers(self):\n # Self refers to the Generator object.\n for h, v in msg.items():\n print(\"%s:\" % h, end=\" \", file=self._fp)\n if isinstance(v, header.Header):\n print(v.encode(maxlinelen=self._maxheaderlen), file=self._fp)\n else:\n # email.Header got lots of smarts, so use it.\n headers = header.Header(\n v, maxlinelen=self._maxheaderlen, charset=\"utf-8\", header_name=h\n )\n print(headers.encode(), file=self._fp)\n # A blank line always separates headers from body.\n print(file=self._fp)\n\n return _write_headers", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def __str__(self):\n return \"Mock Exception str\"", "label": 1, "programming_language": "Python", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n hs = self.setup_test_homeserver(\"server\", federation_http_client=None)\n self.store = hs.get_datastore()\n return hs", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def test_string_agg_delimiter_escaping(self):\n values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimiter=\"'\"))\n self.assertEqual(values, {'stringagg': \"Foo1'Foo2'Foo4'Foo3\"})", "label": 1, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def from_plist(self, content):\n \"\"\"\n Given some binary plist data, returns a Python dictionary of the decoded data.\n \"\"\"\n if biplist is None:\n raise ImproperlyConfigured(\"Usage of the plist aspects requires biplist.\")\n\n return biplist.readPlistFromString(content)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def edit_book_comments(comments, book):\n modif_date = False\n if len(book.comments):\n if book.comments[0].text != comments:\n book.comments[0].text = comments\n modif_date = True\n else:\n if comments:\n book.comments.append(db.Comments(text=comments, book=book.id))\n modif_date = True\n return modif_date", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def test_process_request(self, rf):\n uploaded_file = SimpleUploadedFile(\"uploaded_file.txt\", b\"uploaded\")\n request = rf.post(\"/\", data={\"file\": uploaded_file})\n S3FileMiddleware(lambda x: None)(request)\n assert request.FILES.getlist(\"file\")\n assert request.FILES.get(\"file\").read() == b\"uploaded\"\n\n storage.save(\"tmp/s3file/s3_file.txt\", ContentFile(b\"s3file\"))\n request = rf.post(\n \"/\",\n data={\n \"file\": \"custom/location/tmp/s3file/s3_file.txt\",\n \"s3file\": \"file\",\n },\n )\n S3FileMiddleware(lambda x: None)(request)\n assert request.FILES.getlist(\"file\")\n assert request.FILES.get(\"file\").read() == b\"s3file\"", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def test_post_only(self):\n \"\"\"\n Verify that we can't call the view when we aren't using POST.\n \"\"\"\n self.client.login(username=self.staff_user.username, password='test')\n response = self.call_add_users_to_cohorts('', method='GET')\n self.assertEqual(response.status_code, 405)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def test_load_and_remap_invalid_dims(self):\n ckpt_path = constant_op.constant(\n '/tmp/warm_starting_util_test5kl2a3pc/tmpph76tep2/model-0',\n shape=[],\n dtype=dtypes.string)\n old_tensor_name = constant_op.constant(\n '/tmp/warm_starting_util_test5kl2a3pc/tmpph76tep2/model-0',\n shape=[],\n dtype=dtypes.string)\n row_remapping = constant_op.constant(0, shape=[], dtype=dtypes.int64)\n col_remapping = constant_op.constant(3, shape=[3], dtype=dtypes.int64)\n initializing_values = constant_op.constant([],\n shape=[0, 1],\n dtype=dtypes.float32)\n with self.cached_session(), self.assertRaisesRegex(\n (ValueError, errors.InvalidArgumentError), 'tensor must be 1-D'):\n self.evaluate(\n gen_checkpoint_ops.load_and_remap_matrix(\n ckpt_path=ckpt_path,\n old_tensor_name=old_tensor_name,\n row_remapping=row_remapping,\n col_remapping=col_remapping,\n initializing_values=initializing_values,\n num_rows=1,\n num_cols=1))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def make_sydent(test_config={}):\n \"\"\"Create a new sydent\n\n Args:\n test_config (dict): any configuration variables for overriding the default sydent\n config\n \"\"\"\n # Use an in-memory SQLite database. Note that the database isn't cleaned up between\n # tests, so by default the same database will be used for each test if changed to be\n # a file on disk.\n if \"db\" not in test_config:\n test_config[\"db\"] = {\"db.file\": \":memory:\"}\n else:\n test_config[\"db\"].setdefault(\"db.file\", \":memory:\")\n\n reactor = ResolvingMemoryReactorClock()\n return Sydent(reactor=reactor, cfg=parse_config_dict(test_config), use_tls_for_federation=False)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def export_bookmarks(self):\n filename = choose_save_file(\n self, 'export-viewer-bookmarks', _('Export bookmarks'),\n filters=[(_('Saved bookmarks'), ['pickle'])], all_files=False, initial_filename='bookmarks.pickle')\n if filename:\n with open(filename, 'wb') as fileobj:\n cPickle.dump(self.get_bookmarks(), fileobj, -1)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": "def py_intermediate_dir():\n \"\"\"\n Name of intermediate dir for current python interpreter:\n //pythonXY_intermediate/\n \"\"\"\n name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2])\n return name", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def test_request_body_too_large_chunked_encoding(self):\n control_line = \"20;\\r\\n\" # 20 hex = 32 dec\n s = \"This string has 32 characters.\\r\\n\"\n to_send = \"GET / HTTP/1.1\\r\\nTransfer-Encoding: chunked\\r\\n\\r\\n\"\n repeat = control_line + s\n to_send += repeat * ((self.toobig // len(repeat)) + 1)\n to_send = tobytes(to_send)\n self.connect()\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, response_body = read_http(fp)\n # body bytes counter caught a max_request_body_size overrun\n self.assertline(line, \"413\", \"Request Entity Too Large\", \"HTTP/1.1\")\n cl = int(headers[\"content-length\"])\n self.assertEqual(cl, len(response_body))\n self.assertEqual(headers[\"content-type\"], \"text/plain\")\n # connection has been closed\n self.send_check_error(to_send)\n self.assertRaises(ConnectionClosed, read_http, fp)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "def parse_soap_enveloped_saml(text, body_class, header_class=None):\n \"\"\"Parses a SOAP enveloped SAML thing and returns header parts and body\n\n :param text: The SOAP object as XML\n :return: header parts and body as saml.samlbase instances\n \"\"\"\n envelope = ElementTree.fromstring(text)\n assert envelope.tag == '{%s}Envelope' % NAMESPACE\n\n # print(len(envelope))\n body = None\n header = {}\n for part in envelope:\n # print(\">\",part.tag)\n if part.tag == '{%s}Body' % NAMESPACE:\n for sub in part:\n try:\n body = saml2.create_class_from_element_tree(body_class, sub)\n except Exception:\n raise Exception(\n \"Wrong body type (%s) in SOAP envelope\" % sub.tag)\n elif part.tag == '{%s}Header' % NAMESPACE:\n if not header_class:\n raise Exception(\"Header where I didn't expect one\")\n # print(\"--- HEADER ---\")\n for sub in part:\n # print(\">>\",sub.tag)\n for klass in header_class:\n # print(\"?{%s}%s\" % (klass.c_namespace,klass.c_tag))\n if sub.tag == \"{%s}%s\" % (klass.c_namespace, klass.c_tag):\n header[sub.tag] = \\\n saml2.create_class_from_element_tree(klass, sub)\n break\n\n return body, header", "label": 0, "programming_language": "Python", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": "def index():\n \"\"\" Index handler \"\"\"\n\n send = request.vars.send\n if DEMO_MODE:\n session.authorized = True\n session.last_time = t0\n if not send:\n send = URL('site')\n if session.authorized:\n redirect(send)\n elif failed_login_count() >= allowed_number_of_attempts:\n time.sleep(2 ** allowed_number_of_attempts)\n raise HTTP(403)\n elif request.vars.password:\n if verify_password(request.vars.password[:1024]):\n session.authorized = True\n login_record(True)\n\n if CHECK_VERSION:\n session.check_version = True\n else:\n session.check_version = False\n\n session.last_time = t0\n if isinstance(send, list): # ## why does this happen?\n send = str(send[0])\n\n redirect(send)\n else:\n times_denied = login_record(False)\n if times_denied >= allowed_number_of_attempts:\n response.flash = \\\n T('admin disabled because too many invalid login attempts')\n elif times_denied == allowed_number_of_attempts - 1:\n response.flash = \\\n T('You have one more login attempt before you are locked out')\n else:\n response.flash = T('invalid password.')\n return dict(send=send)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "safe"} {"code": " def make_homeserver(self, reactor, clock):\n\n hs = self.setup_test_homeserver(\n \"red\", federation_http_client=None, federation_client=Mock(),\n )\n\n self.event_source = hs.get_event_sources().sources[\"typing\"]\n\n hs.get_federation_handler = Mock()\n\n async def get_user_by_access_token(token=None, allow_guest=False):\n return {\n \"user\": UserID.from_string(self.auth_user_id),\n \"token_id\": 1,\n \"is_guest\": False,\n }\n\n hs.get_auth().get_user_by_access_token = get_user_by_access_token\n\n async def _insert_client_ip(*args, **kwargs):\n return None\n\n hs.get_datastore().insert_client_ip = _insert_client_ip\n\n def get_room_members(room_id):\n if room_id == self.room_id:\n return defer.succeed([self.user])\n else:\n return defer.succeed([])\n\n @defer.inlineCallbacks\n def fetch_room_distributions_into(\n room_id, localusers=None, remotedomains=None, ignore_user=None\n ):\n members = yield get_room_members(room_id)\n for member in members:\n if ignore_user is not None and member == ignore_user:\n continue\n\n if hs.is_mine(member):\n if localusers is not None:\n localusers.add(member)\n else:\n if remotedomains is not None:\n remotedomains.add(member.domain)\n\n hs.get_room_member_handler().fetch_room_distributions_into = (\n fetch_room_distributions_into\n )\n\n return hs", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def test_convert_string_to_number(self, dtype):\n with self.assertRaises(TypeError):\n constant_op.constant(\"hello\", dtype)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def print_train_stats():\n print(\n \"TEMPLATE STATISTICS (TRAIN) {} templates, {} rules)\".format(\n len(template_counts), len(tids)\n )\n )\n print(\n \"TRAIN ({tokencount:7d} tokens) initial {initialerrors:5d} {initialacc:.4f} \"\n \"final: {finalerrors:5d} {finalacc:.4f} \".format(**train_stats)\n )\n head = \"#ID | Score (train) | #Rules | Template\"\n print(head, \"\\n\", \"-\" * len(head), sep=\"\")\n train_tplscores = sorted(\n weighted_traincounts.items(), key=det_tplsort, reverse=True\n )\n for (tid, trainscore) in train_tplscores:\n s = \"{} | {:5d} {:5.3f} |{:4d} {:.3f} | {}\".format(\n tid,\n trainscore,\n trainscore / tottrainscores,\n template_counts[tid],\n template_counts[tid] / len(tids),\n Template.ALLTEMPLATES[int(tid)],\n )\n print(s)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-1333", "cwe_name": "Inefficient Regular Expression Complexity", "description": "The product uses a regular expression with an inefficient, possibly exponential worst-case computational complexity that consumes excessive CPU cycles.", "url": "https://cwe.mitre.org/data/definitions/1333.html", "label_name": "vulnerable"} {"code": "def render_delete_book_result(book_format, jsonResponse, warning, book_id):\n if book_format:\n if jsonResponse:\n return json.dumps([warning, {\"location\": url_for(\"editbook.edit_book\", book_id=book_id),\n \"type\": \"success\",\n \"format\": book_format,\n \"message\": _('Book Format Successfully Deleted')}])\n else:\n flash(_('Book Format Successfully Deleted'), category=\"success\")\n return redirect(url_for('editbook.edit_book', book_id=book_id))\n else:\n if jsonResponse:\n return json.dumps([warning, {\"location\": url_for('web.index'),\n \"type\": \"success\",\n \"format\": book_format,\n \"message\": _('Book Successfully Deleted')}])\n else:\n flash(_('Book Successfully Deleted'), category=\"success\")\n return redirect(url_for('web.index'))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def test_progress(self, driver, live_server, upload_file, freeze):\n driver.get(live_server + self.url)\n file_input = driver.find_element(By.XPATH, \"//input[@name='file']\")\n file_input.send_keys(upload_file)\n assert file_input.get_attribute(\"name\") == \"file\"\n save_button = driver.find_element(By.XPATH, \"//input[@name='save']\")\n with wait_for_page_load(driver, timeout=10):\n save_button.click()\n assert \"save\" in driver.page_source\n\n driver.get(live_server + self.url)\n file_input = driver.find_element(By.XPATH, \"//input[@name='file']\")\n file_input.send_keys(upload_file)\n assert file_input.get_attribute(\"name\") == \"file\"\n save_button = driver.find_element(By.XPATH, \"//button[@name='save_continue']\")\n with wait_for_page_load(driver, timeout=10):\n save_button.click()\n response = json.loads(driver.find_elements(By.CSS_SELECTOR, \"pre\")[0].text)\n assert response[\"POST\"][\"progress\"] == \"1\"", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def to_plist(self, data, options=None):\n \"\"\"\n Given some Python data, produces binary plist output.\n \"\"\"\n options = options or {}\n\n if biplist is None:\n raise ImproperlyConfigured(\"Usage of the plist aspects requires biplist.\")\n\n return biplist.writePlistToString(self.to_simple(data, options))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def delete_book_gdrive(book, book_format):\n error = None\n if book_format:\n name = ''\n for entry in book.data:\n if entry.format.upper() == book_format:\n name = entry.name + '.' + book_format\n gFile = gd.getFileFromEbooksFolder(book.path, name)\n else:\n gFile = gd.getFileFromEbooksFolder(os.path.dirname(book.path), book.path.split('/')[1])\n if gFile:\n gd.deleteDatabaseEntry(gFile['id'])\n gFile.Trash()\n else:\n error = _(u'Book path %(path)s not found on Google Drive', path=book.path) # file not found\n\n return error is None, error", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def test2DNoWH(self):\n x = [[0, 1], [2, 3]]\n with self.assertRaisesRegex(\n errors.InvalidArgumentError,\n \"Format specifier must contain H and W for 2D case\"):\n op = nn_ops.data_format_vec_permute(\n x, src_format=\"1234\", dst_format=\"4321\")\n with test_util.use_gpu():\n self.evaluate(op)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " def testSparseCountSparseOutputBadIndicesShape(self):\n indices = [[[0], [0]], [[0], [1]], [[1], [0]], [[1], [2]]]\n values = [1, 1, 1, 10]\n weights = [1, 2, 4, 6]\n dense_shape = [2, 3]\n with self.assertRaisesRegex(errors.InvalidArgumentError,\n \"Input indices must be a 2-dimensional tensor\"):\n self.evaluate(\n gen_count_ops.SparseCountSparseOutput(\n indices=indices,\n values=values,\n dense_shape=dense_shape,\n weights=weights,\n binary_output=False))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " def testInputPreProcessFormats(self):\n input_str = 'input1=/path/file.txt[ab3];input2=file2'\n input_expr_str = 'input3=np.zeros([2,2]);input4=[4,5]'\n input_dict = saved_model_cli.preprocess_inputs_arg_string(input_str)\n input_expr_dict = saved_model_cli.preprocess_input_exprs_arg_string(\n input_expr_str, safe=False)\n self.assertTrue(input_dict['input1'] == ('/path/file.txt', 'ab3'))\n self.assertTrue(input_dict['input2'] == ('file2', None))\n print(input_expr_dict['input3'])\n self.assertAllClose(input_expr_dict['input3'], np.zeros([2, 2]))\n self.assertAllClose(input_expr_dict['input4'], [4, 5])\n self.assertTrue(len(input_dict) == 2)\n self.assertTrue(len(input_expr_dict) == 2)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def test_value_from_datadict(self, client, upload_file):\n print(storage.location)\n with open(upload_file) as f:\n uploaded_file = storage.save(\"test.jpg\", f)\n response = client.post(\n reverse(\"upload\"),\n {\n \"file\": json.dumps([uploaded_file]),\n \"s3file\": '[\"file\"]',\n },\n )\n\n assert response.status_code == 201", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def _checkPolkitPrivilege(self, sender, conn, privilege):\n # from jockey\n \"\"\"\n Verify that sender has a given PolicyKit privilege.\n\n sender is the sender's (private) D-BUS name, such as \":1:42\"\n (sender_keyword in @dbus.service.methods). conn is\n the dbus.Connection object (connection_keyword in\n @dbus.service.methods). privilege is the PolicyKit privilege string.\n\n This method returns if the caller is privileged, and otherwise throws a\n PermissionDeniedByPolicy exception.\n \"\"\"\n if sender is None and conn is None:\n # called locally, not through D-BUS\n return\n if not self.enforce_polkit:\n # that happens for testing purposes when running on the session\n # bus, and it does not make sense to restrict operations here\n return\n\n info = SenderInfo(sender, conn)\n\n # get peer PID\n pid = info.connectionPid()\n\n # query PolicyKit\n self._initPolkit()\n try:\n # we don't need is_challenge return here, since we call with AllowUserInteraction\n (is_auth, _, details) = self.polkit.CheckAuthorization(\n ('unix-process', {'pid': dbus.UInt32(pid, variant_level=1),\n 'start-time': dbus.UInt64(0, variant_level=1)}),\n privilege, {'': ''}, dbus.UInt32(1), '', timeout=3000)\n except dbus.DBusException as e:\n if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':\n # polkitd timed out, connect again\n self.polkit = None\n return self._checkPolkitPrivilege(sender, conn, privilege)\n else:\n raise\n\n if not is_auth:\n raise PermissionDeniedByPolicy(privilege)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": " def _testSparseDenseInvalidInputs(self,\n a_indices,\n a_values,\n a_shape,\n b,\n expected_error=\"\"):", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def get_simple_http_client(self) -> SimpleHttpClient:\n \"\"\"\n An HTTP client with no special configuration.\n \"\"\"\n return SimpleHttpClient(self)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": "def list_course_role_members(request, course_id):\n \"\"\"\n List instructors and staff.\n Requires instructor access.\n\n rolename is one of ['instructor', 'staff', 'beta', 'ccx_coach']\n\n Returns JSON of the form {\n \"course_id\": \"some/course/id\",\n \"staff\": [\n {\n \"username\": \"staff1\",\n \"email\": \"staff1@example.org\",\n \"first_name\": \"Joe\",\n \"last_name\": \"Shmoe\",\n }\n ]\n }\n \"\"\"\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n course = get_course_with_access(\n request.user, 'instructor', course_id, depth=None\n )\n\n rolename = request.GET.get('rolename')\n\n if rolename not in ROLES:\n return HttpResponseBadRequest()\n\n def extract_user_info(user):\n \"\"\" convert user into dicts for json view \"\"\"\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, list_with_level(\n course, rolename\n )),\n }\n return JsonResponse(response_payload)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def test_get_anon_ids(self):\n \"\"\"\n Test the CSV output for the anonymized user ids.\n \"\"\"\n url = reverse('get_anon_ids', kwargs={'course_id': self.course.id.to_deprecated_string()})\n response = self.client.get(url, {})\n self.assertEqual(response['Content-Type'], 'text/csv')\n body = response.content.replace('\\r', '')\n self.assertTrue(body.startswith(\n '\"User ID\",\"Anonymized User ID\",\"Course Specific Anonymized User ID\"'\n '\\n\"{user_id}\",\"41\",\"42\"\\n'.format(user_id=self.students[0].id)\n ))\n self.assertTrue(\n body.endswith('\"{user_id}\",\"41\",\"42\"\\n'.format(user_id=self.students[-1].id))\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def list_tokens(self, user_id):\n session = self.get_session()\n tokens = []\n now = datetime.datetime.utcnow()\n for token_ref in session.query(TokenModel)\\\n .filter(TokenModel.expires > now):\n token_ref_dict = token_ref.to_dict()\n if 'user' not in token_ref_dict:\n continue\n if token_ref_dict['user'].get('id') != user_id:\n continue\n tokens.append(token_ref['id'])\n return tokens", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "def load(doc):\n code = config.retrieveBoilerplateFile(doc, \"bs-extensions\")\n exec(code, globals())", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def save(self, text):\n self._create_dirs()\n with open(self._filesystem_path, \"w\") as fd:\n fd.write(text)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-21", "cwe_name": "DEPRECATED: Pathname Traversal and Equivalence Errors", "description": "This category has been deprecated. It was originally used for organizing weaknesses involving file names, which enabled access to files outside of a restricted directory (path traversal) or to perform operations on files that would otherwise be restricted (path equivalence). Consider using either the File Handling Issues category (CWE-1219) or the class Use of Incorrectly-Resolved Name or Reference (CWE-706).", "url": "https://cwe.mitre.org/data/definitions/21.html", "label_name": "safe"} {"code": " def testCapacity(self):\n capacity = 3\n\n with ops.Graph().as_default() as G:\n with ops.device('/cpu:0'):\n x = array_ops.placeholder(dtypes.int32, name='x')\n pi = array_ops.placeholder(dtypes.int64, name='pi')\n gi = array_ops.placeholder(dtypes.int64, name='gi')\n with ops.device(test.gpu_device_name()):\n stager = data_flow_ops.MapStagingArea(\n [\n dtypes.int32,\n ], capacity=capacity, shapes=[[]])\n\n stage = stager.put(pi, [x], [0])\n get = stager.get()\n size = stager.size()\n\n G.finalize()\n\n from six.moves import queue as Queue\n import threading\n\n queue = Queue.Queue()\n n = 8\n\n with self.session(graph=G) as sess:\n # Stage data in a separate thread which will block\n # when it hits the staging area's capacity and thus\n # not fill the queue with n tokens\n def thread_run():\n for i in range(n):\n sess.run(stage, feed_dict={x: i, pi: i})\n queue.put(0)\n\n t = threading.Thread(target=thread_run)\n t.daemon = True\n t.start()\n\n # Get tokens from the queue until a timeout occurs\n try:\n for i in range(n):\n queue.get(timeout=TIMEOUT)\n except Queue.Empty:\n pass\n\n # Should've timed out on the iteration 'capacity'\n if not i == capacity:\n self.fail(\"Expected to timeout on iteration '{}' \"\n \"but instead timed out on iteration '{}' \"\n \"Staging Area size is '{}' and configured \"\n \"capacity is '{}'.\".format(capacity, i, sess.run(size),\n capacity))\n\n # Should have capacity elements in the staging area\n self.assertTrue(sess.run(size) == capacity)\n\n # Clear the staging area completely\n for i in range(n):\n sess.run(get)\n\n self.assertTrue(sess.run(size) == 0)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "vulnerable"} {"code": " def __init__(self, expression, delimiter, **extra):\n super().__init__(expression, delimiter=delimiter, **extra)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def test_format_quota_set(self):\n raw_quota_set = {\n 'instances': 10,\n 'cores': 20,\n 'ram': 51200,\n 'volumes': 10,\n 'floating_ips': 10,\n 'metadata_items': 128,\n 'gigabytes': 1000,\n 'injected_files': 5,\n 'injected_file_content_bytes': 10240,\n 'security_groups': 10,\n 'security_group_rules': 20,\n }\n\n quota_set = self.controller._format_quota_set('test_class',\n raw_quota_set)\n qs = quota_set['quota_class_set']\n\n self.assertEqual(qs['id'], 'test_class')\n self.assertEqual(qs['instances'], 10)\n self.assertEqual(qs['cores'], 20)\n self.assertEqual(qs['ram'], 51200)\n self.assertEqual(qs['volumes'], 10)\n self.assertEqual(qs['gigabytes'], 1000)\n self.assertEqual(qs['floating_ips'], 10)\n self.assertEqual(qs['metadata_items'], 128)\n self.assertEqual(qs['injected_files'], 5)\n self.assertEqual(qs['injected_file_content_bytes'], 10240)\n self.assertEqual(qs['security_groups'], 10)\n self.assertEqual(qs['security_group_rules'], 20)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def _access_endpoint(self, endpoint, args, status_code, msg):\n \"\"\"\n Asserts that accessing the given `endpoint` gets a response of `status_code`.\n\n endpoint: string, endpoint for instructor dash API\n args: dict, kwargs for `reverse` call\n status_code: expected HTTP status code response\n msg: message to display if assertion fails.\n \"\"\"\n url = reverse(endpoint, kwargs={'course_id': self.course.id.to_deprecated_string()})\n if endpoint in INSTRUCTOR_GET_ENDPOINTS:\n response = self.client.get(url, args)\n else:\n response = self.client.post(url, args)\n self.assertEqual(\n response.status_code,\n status_code,\n msg=msg\n )", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "def parse(source, filename='', mode='exec'):\n \"\"\"\n Parse the source into an AST node.\n Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).\n \"\"\"\n return compile(source, filename, mode, PyCF_ONLY_AST)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " def test_keepalive_http10_explicit(self):\n # If header Connection: Keep-Alive is explicitly sent,\n # we want to keept the connection open, we also need to return\n # the corresponding header\n data = \"Keep me alive\"\n s = tobytes(\n \"GET / HTTP/1.0\\r\\n\"\n \"Connection: Keep-Alive\\r\\n\"\n \"Content-Length: %d\\r\\n\"\n \"\\r\\n\"\n \"%s\" % (len(data), data)\n )\n self.connect()\n self.sock.send(s)\n response = httplib.HTTPResponse(self.sock)\n response.begin()\n self.assertEqual(int(response.status), 200)\n connection = response.getheader(\"Connection\", \"\")\n self.assertEqual(connection, \"Keep-Alive\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def testRunCommandInvalidInputKeyError(self, use_tfrt):\n self.parser = saved_model_cli.create_parser()\n base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n args = self.parser.parse_args([\n 'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',\n 'regress_x2_to_y3', '--input_exprs', 'x2=[1,2,3]'\n ] + (['--use_tfrt'] if use_tfrt else []))\n with self.assertRaises(ValueError):\n saved_model_cli.run(args)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def get_pos_tagger(self):\n from nltk.corpus import brown\n\n regexp_tagger = RegexpTagger(\n [\n (r\"^-?[0-9]+(.[0-9]+)?$\", \"CD\"), # cardinal numbers\n (r\"(The|the|A|a|An|an)$\", \"AT\"), # articles\n (r\".*able$\", \"JJ\"), # adjectives\n (r\".*ness$\", \"NN\"), # nouns formed from adjectives\n (r\".*ly$\", \"RB\"), # adverbs\n (r\".*s$\", \"NNS\"), # plural nouns\n (r\".*ing$\", \"VBG\"), # gerunds\n (r\".*ed$\", \"VBD\"), # past tense verbs\n (r\".*\", \"NN\"), # nouns (default)\n ]\n )\n brown_train = brown.tagged_sents(categories=\"news\")\n unigram_tagger = UnigramTagger(brown_train, backoff=regexp_tagger)\n bigram_tagger = BigramTagger(brown_train, backoff=unigram_tagger)\n trigram_tagger = TrigramTagger(brown_train, backoff=bigram_tagger)\n\n # Override particular words\n main_tagger = RegexpTagger(\n [(r\"(A|a|An|an)$\", \"ex_quant\"), (r\"(Every|every|All|all)$\", \"univ_quant\")],\n backoff=trigram_tagger,\n )\n\n return main_tagger", "label": 0, "programming_language": "Python", "cwe_id": "CWE-1333", "cwe_name": "Inefficient Regular Expression Complexity", "description": "The product uses a regular expression with an inefficient, possibly exponential worst-case computational complexity that consumes excessive CPU cycles.", "url": "https://cwe.mitre.org/data/definitions/1333.html", "label_name": "vulnerable"} {"code": " def test_get_problem_responses_already_running(self):\n \"\"\"\n Test whether get_problem_responses returns an appropriate status\n message if CSV generation is already in progress.\n \"\"\"\n url = reverse(\n 'get_problem_responses',\n kwargs={'course_id': unicode(self.course.id)}\n )\n\n with patch('instructor_task.api.submit_calculate_problem_responses_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('already in progress', res_json['status'])", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def _contains_display_name(self, display_name: str) -> bool:\n if not display_name:\n return False\n\n body = self._event.content.get(\"body\", None)\n if not body or not isinstance(body, str):\n return False\n\n # Similar to _glob_matches, but do not treat display_name as a glob.\n r = regex_cache.get((display_name, False, True), None)\n if not r:\n r1 = re.escape(display_name)\n r1 = re_word_boundary(r1)\n r = re.compile(r1, flags=re.IGNORECASE)\n regex_cache[(display_name, False, True)] = r\n\n return bool(r.search(body))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-331", "cwe_name": "Insufficient Entropy", "description": "The software uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.", "url": "https://cwe.mitre.org/data/definitions/331.html", "label_name": "safe"} {"code": "def _hval(value):\n value = value if isinstance(value, unicode) else str(value)\n if '\\n' in value or '\\r' in value or '\\0' in value:\n raise ValueError(\"Header value must not contain control characters: %r\" % value)\n return value", "label": 1, "programming_language": "Python", "cwe_id": "CWE-93", "cwe_name": "Improper Neutralization of CRLF Sequences ('CRLF Injection')", "description": "The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.", "url": "https://cwe.mitre.org/data/definitions/93.html", "label_name": "safe"} {"code": " def load_djpeg(self):\n\n # ALTERNATIVE: handle JPEGs via the IJG command line utilities\n\n import tempfile, os\n f, path = tempfile.mkstemp()\n os.close(f)\n if os.path.exists(self.filename):\n os.system(\"djpeg '%s' >'%s'\" % (self.filename, path))\n else:\n raise ValueError(\"Invalid Filename\")\n\n try:\n self.im = Image.core.open_ppm(path)\n finally:\n try: os.unlink(path)\n except: pass\n\n self.mode = self.im.mode\n self.size = self.im.size\n\n self.tile = []", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def test_pbkdf2_harden_runtime(self):\n hasher = get_hasher('default')\n self.assertEqual('pbkdf2_sha256', hasher.algorithm)\n\n with mock.patch.object(hasher, 'iterations', 1):\n encoded = make_password('letmein')\n\n with mock.patch.object(hasher, 'iterations', 6), \\\n mock.patch.object(hasher, 'encode', side_effect=hasher.encode):\n hasher.harden_runtime('wrong_password', encoded)\n\n # Encode should get called once ...\n self.assertEqual(hasher.encode.call_count, 1)\n\n # ... with the original salt and 5 iterations.\n algorithm, iterations, salt, hash = encoded.split('$', 3)\n expected_call = (('wrong_password', salt, 5),)\n self.assertEqual(hasher.encode.call_args, expected_call)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " async def on_exchange_third_party_invite_request(\n self, room_id: str, event_dict: Dict", "label": 0, "programming_language": "Python", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "def testSpecQuoteAttribute(c):\n input_ = [[\"StartTag\", \"http://www.w3.org/1999/xhtml\", \"span\",\n [{\"namespace\": None, \"name\": \"foo\", \"value\": c}]]]\n if c == '\"':\n output_ = [\"\" % c]\n else:\n output_ = ['' % c]\n options_ = {\"quote_attr_values\": \"spec\"}\n runSerializerTest(input_, output_, options_)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def __getattr__(_self, attr):\n if attr == \"nameResolver\":\n return nameResolver\n else:\n return getattr(real_reactor, attr)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": " def test_login(self):\n login_code = LoginCode.objects.create(user=self.user, code='foobar', next='/private/')\n\n response = self.client.post('/accounts-rest/login/code/', {\n 'code': login_code.code,\n })\n\n self.assertEqual(response.status_code, 200)\n self.assertFalse(LoginCode.objects.filter(pk=login_code.pk).exists())\n\n token = Token.objects.filter(user=self.user).first()\n\n self.assertIsNotNone(token)\n self.assertEqual(response.data, {\n 'key': token.key,\n 'next': '/private/',\n })", "label": 0, "programming_language": "Python", "cwe_id": "CWE-312", "cwe_name": "Cleartext Storage of Sensitive Information", "description": "The application stores sensitive information in cleartext within a resource that might be accessible to another control sphere.", "url": "https://cwe.mitre.org/data/definitions/312.html", "label_name": "vulnerable"} {"code": " def testSparseFillEmptyRowsGrad(self):\n reverse_index_map = [2, 1]\n grad_values = [0, 1, 2, 3]\n d_values, d_default_value = self.evaluate(\n gen_sparse_ops.SparseFillEmptyRowsGrad(\n reverse_index_map=reverse_index_map, grad_values=grad_values))\n self.assertAllEqual([2, 1], d_values)\n self.assertEqual(3, d_default_value)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "def group_title(value: str) -> str:\n value = re.sub(r\"([A-Z]{2,})([A-Z][a-z]|[ -_]|$)\", lambda m: m.group(1).title() + m.group(2), value.strip())\n value = re.sub(r\"(^|[ _-])([A-Z])\", lambda m: m.group(1) + m.group(2).lower(), value)\n return value", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "def feed_get_cover(book_id):\n return get_book_cover(book_id)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def join_ssh(seed_host):\n \"\"\"\n SSH configuration for joining node.\n \"\"\"\n if not seed_host:\n error(\"No existing IP/hostname specified (use -c option)\")\n\n utils.start_service(\"sshd.service\", enable=True)\n configure_local_ssh_key()\n swap_public_ssh_key(seed_host)\n\n # This makes sure the seed host has its own SSH keys in its own\n # authorized_keys file (again, to help with the case where the\n # user has done manual initial setup without the assistance of\n # ha-cluster-init).\n rc, _, err = invoke(\"ssh root@{} crm cluster init -i {} ssh_remote\".format(seed_host, _context.default_nic_list[0]))\n if not rc:\n error(\"Can't invoke crm cluster init -i {} ssh_remote on {}: {}\".format(_context.default_nic_list[0], seed_host, err))", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "def feed_category(book_id):\n off = request.args.get(\"offset\") or 0\n entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,\n db.Books,\n db.Books.tags.any(db.Tags.id == book_id),\n [db.Books.timestamp.desc()])\n return render_xml_template('feed.xml', entries=entries, pagination=pagination)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "def valid_id(opts, id_):\n '''\n Returns if the passed id is valid\n '''\n try:\n return bool(clean_path(opts['pki_dir'], id_)) and clean_id(id_)\n except (AttributeError, KeyError, TypeError) as e:\n return False", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def POST(self, path, body=None, ensure_encoding=True, log_request_body=True):\n return self._request('POST', path, body=body, ensure_encoding=ensure_encoding,\n log_request_body=log_request_body)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": " def __init__(self, servers, connect_timeout=CONN_TIMEOUT,\n io_timeout=IO_TIMEOUT, tries=TRY_COUNT,\n allow_pickle=False, allow_unpickle=False):", "label": 1, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def to_yaml(self, **kwargs):\n \"\"\"Returns a yaml string containing the network configuration.\n\n To load a network from a yaml save file, use\n `keras.models.model_from_yaml(yaml_string, custom_objects={})`.\n\n `custom_objects` should be a dictionary mapping\n the names of custom losses / layers / etc to the corresponding\n functions / classes.\n\n Args:\n **kwargs: Additional keyword arguments\n to be passed to `yaml.dump()`.\n\n Returns:\n A YAML string.\n\n Raises:\n ImportError: if yaml module is not found.\n \"\"\"\n if yaml is None:\n raise ImportError(\n 'Requires yaml module installed (`pip install pyyaml`).')\n return yaml.dump(self._updated_config(), **kwargs)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " def test_before_start_response_http_10(self):\n to_send = \"GET /before_start_response HTTP/1.0\\n\\n\"\n to_send = tobytes(to_send)\n self.connect()\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, response_body = read_http(fp)\n self.assertline(line, \"500\", \"Internal Server Error\", \"HTTP/1.0\")\n cl = int(headers[\"content-length\"])\n self.assertEqual(cl, len(response_body))\n self.assertTrue(response_body.startswith(b\"Internal Server Error\"))\n self.assertEqual(headers[\"connection\"], \"close\")\n # connection has been closed\n self.send_check_error(to_send)\n self.assertRaises(ConnectionClosed, read_http, fp)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": "def is_valid_client_secret(client_secret):\n \"\"\"Validate that a given string matches the client_secret regex defined by the spec\n\n :param client_secret: The client_secret to validate\n :type client_secret: unicode\n\n :return: Whether the client_secret is valid\n :rtype: bool\n \"\"\"\n return client_secret_regex.match(client_secret) is not None", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def run(self):\n if not self.should_run():\n print(\"bower dependencies up to date\")\n return\n \n if self.should_run_npm():\n print(\"installing build dependencies with npm\")\n run(['npm', 'install'], cwd=repo_root)\n os.utime(self.node_modules, None)\n \n env = os.environ.copy()\n env['PATH'] = npm_path\n \n try:\n run(\n ['bower', 'install', '--allow-root', '--config.interactive=false'],\n cwd=repo_root,\n env=env\n )\n except OSError as e:\n print(\"Failed to run bower: %s\" % e, file=sys.stderr)\n print(\"You can install js dependencies with `npm install`\", file=sys.stderr)\n raise\n # self.npm_components()\n if not os.path.exists(self.sanitizer_dir):\n run(['npm', 'run', 'build:webpack'], cwd=repo_root, env=env)\n os.utime(self.bower_dir, None)\n # update package data in case this created new files\n update_package_data(self.distribution)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def login_user(self, username, password, otp, context, **kwargs):\n user = authenticate(request=context.get('request'),\n username=username, password=password)\n if not user:\n login_reject.send(sender=self.__class__, username=username, reason='creds')\n raise FormattedException(m='incorrect_username_or_password', d={'reason': 'incorrect_username_or_password'},\n status_code=HTTP_401_UNAUTHORIZED)\n\n if not user.email_verified and not user.is_superuser:\n login_reject.send(sender=self.__class__, username=username, reason='email')\n raise FormattedException(m='email_verification_required', d={'reason': 'email_verification_required'},\n status_code=HTTP_401_UNAUTHORIZED)\n\n if not user.can_login():\n login_reject.send(sender=self.__class__, username=username, reason='closed')\n raise FormattedException(m='login_not_open', d={'reason': 'login_not_open'},\n status_code=HTTP_401_UNAUTHORIZED)\n\n if user.totp_status == TOTPStatus.ENABLED:\n if not otp or otp == '':\n login_reject.send(sender=self.__class__, username=username, reason='no_2fa')\n raise FormattedException(m='2fa_required', d={'reason': '2fa_required'},\n status_code=HTTP_401_UNAUTHORIZED)\n totp = pyotp.TOTP(user.totp_secret)\n if not totp.verify(otp, valid_window=1):\n login_reject.send(sender=self.__class__, username=username, reason='incorrect_2fa')\n raise FormattedException(m='incorrect_2fa', d={'reason': 'incorrect_2fa'},\n status_code=HTTP_401_UNAUTHORIZED)\n login.send(sender=self.__class__, user=user)\n return user", "label": 0, "programming_language": "Python", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": "def parse_jwt_token(request: func.HttpRequest) -> Result[UserInfo]:\n \"\"\"Obtains the Access Token from the Authorization Header\"\"\"\n token_str = get_auth_token(request)\n if token_str is None:\n return Error(\n code=ErrorCode.INVALID_REQUEST,\n errors=[\"unable to find authorization token\"],\n )\n\n # This token has already been verified by the azure authentication layer\n token = jwt.decode(token_str, options={\"verify_signature\": False})\n\n application_id = UUID(token[\"appid\"]) if \"appid\" in token else None\n object_id = UUID(token[\"oid\"]) if \"oid\" in token else None\n upn = token.get(\"upn\")\n return UserInfo(application_id=application_id, object_id=object_id, upn=upn)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-346", "cwe_name": "Origin Validation Error", "description": "The software does not properly verify that the source of data or communication is valid.", "url": "https://cwe.mitre.org/data/definitions/346.html", "label_name": "vulnerable"} {"code": " def test_26_checksecure_quoted_command(self):\n \"\"\" U26 | quoted command should be parsed \"\"\"\n INPUT = 'echo 1 && \"bash\"'\n return self.assertEqual(sec.check_secure(INPUT, self.userconf)[0], 1)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def test_modify_access_revoke_not_allowed(self):\n \"\"\" Test revoking access that a user does not have. \"\"\"\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': 'instructor',\n 'action': 'revoke',\n })\n self.assertEqual(response.status_code, 200)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " def _getKeysForServer(self, server_name):\n \"\"\"Get the signing key data from a homeserver.\n\n :param server_name: The name of the server to request the keys from.\n :type server_name: unicode\n\n :return: The verification keys returned by the server.\n :rtype: twisted.internet.defer.Deferred[dict[unicode, dict[unicode, unicode]]]\n \"\"\"\n\n if server_name in self.cache:\n cached = self.cache[server_name]\n now = int(time.time() * 1000)\n if cached['valid_until_ts'] > now:\n defer.returnValue(self.cache[server_name]['verify_keys'])\n\n client = FederationHttpClient(self.sydent)\n result = yield client.get_json(\"matrix://%s/_matrix/key/v2/server/\" % server_name, 1024 * 50)\n if 'verify_keys' not in result:\n raise SignatureVerifyException(\"No key found in response\")\n\n if 'valid_until_ts' in result:\n # Don't cache anything without a valid_until_ts or we wouldn't\n # know when to expire it.\n logger.info(\"Got keys for %s: caching until %s\", server_name, result['valid_until_ts'])\n self.cache[server_name] = result\n\n defer.returnValue(result['verify_keys'])", "label": 1, "programming_language": "Python", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": " def test_federation_client_unsafe_ip(self, resolver):\n self.sydent.run()\n\n request, channel = make_request(\n self.sydent.reactor,\n \"POST\",\n \"/_matrix/identity/v2/account/register\",\n {\n \"access_token\": \"foo\",\n \"expires_in\": 300,\n \"matrix_server_name\": \"example.com\",\n \"token_type\": \"Bearer\",\n },\n )\n\n resolver.return_value = defer.succeed(\n [\n Server(\n host=self.unsafe_domain,\n port=443,\n priority=1,\n weight=1,\n expires=100,\n )\n ]\n )\n\n request.render(self.sydent.servlets.registerServlet)\n\n self.assertNot(self.reactor.tcpClients)\n\n self.assertEqual(channel.code, 500)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def test_certificates_features_group_by_mode(self):\n \"\"\"\n Test for certificate csv features against mode. Certificates should be group by 'mode' in reponse.\n \"\"\"\n url = reverse('get_issued_certificates', kwargs={'course_id': unicode(self.course.id)})\n # firstly generating downloadable certificates with 'honor' mode\n certificate_count = 3\n for __ in xrange(certificate_count):\n self.generate_certificate(course_id=self.course.id, mode='honor', status=CertificateStatuses.downloadable)\n\n response = self.client.post(url)\n res_json = json.loads(response.content)\n self.assertIn('certificates', res_json)\n self.assertEqual(len(res_json['certificates']), 1)\n\n # retrieve the first certificate from the list, there should be 3 certificates for 'honor' mode.\n certificate = res_json['certificates'][0]\n self.assertEqual(certificate.get('total_issued_certificate'), 3)\n self.assertEqual(certificate.get('mode'), 'honor')\n self.assertEqual(certificate.get('course_id'), str(self.course.id))\n\n # Now generating downloadable certificates with 'verified' mode\n for __ in xrange(certificate_count):\n self.generate_certificate(\n course_id=self.course.id,\n mode='verified',\n status=CertificateStatuses.downloadable\n )\n\n response = self.client.post(url)\n res_json = json.loads(response.content)\n self.assertIn('certificates', res_json)\n\n # total certificate count should be 2 for 'verified' mode.\n self.assertEqual(len(res_json['certificates']), 2)\n\n # retrieve the second certificate from the list\n certificate = res_json['certificates'][1]\n self.assertEqual(certificate.get('total_issued_certificate'), 3)\n self.assertEqual(certificate.get('mode'), 'verified')", "label": 1, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " def skip(self, type):\n if type == TType.STOP:\n return\n elif type == TType.BOOL:\n self.readBool()\n elif type == TType.BYTE:\n self.readByte()\n elif type == TType.I16:\n self.readI16()\n elif type == TType.I32:\n self.readI32()\n elif type == TType.I64:\n self.readI64()\n elif type == TType.DOUBLE:\n self.readDouble()\n elif type == TType.FLOAT:\n self.readFloat()\n elif type == TType.STRING:\n self.readString()\n elif type == TType.STRUCT:\n name = self.readStructBegin()\n while True:\n (name, type, id) = self.readFieldBegin()\n if type == TType.STOP:\n break\n self.skip(type)\n self.readFieldEnd()\n self.readStructEnd()\n elif type == TType.MAP:\n (ktype, vtype, size) = self.readMapBegin()\n for _ in range(size):\n self.skip(ktype)\n self.skip(vtype)\n self.readMapEnd()\n elif type == TType.SET:\n (etype, size) = self.readSetBegin()\n for _ in range(size):\n self.skip(etype)\n self.readSetEnd()\n elif type == TType.LIST:\n (etype, size) = self.readListBegin()\n for _ in range(size):\n self.skip(etype)\n self.readListEnd()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": " def test_received_control_line_finished_garbage_in_input(self):\n buf = DummyBuffer()\n inst = self._makeOne(buf)\n result = inst.received(b\"garbage\\r\\n\")\n self.assertEqual(result, 9)\n self.assertTrue(inst.error)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def test_auth_type_stored_in_session_file(self, httpbin):\n self.config_dir = mk_config_dir()\n self.session_path = self.config_dir / 'test-session.json'\n\n class Plugin(AuthPlugin):\n auth_type = 'test-saved'\n auth_require = True\n\n def get_auth(self, username=None, password=None):\n return basic_auth()\n\n plugin_manager.register(Plugin)\n http('--session', str(self.session_path),\n httpbin + '/basic-auth/user/password',\n '--auth-type',\n Plugin.auth_type,\n '--auth', 'user:password',\n )\n updated_session = json.loads(self.session_path.read_text(encoding=UTF8))\n assert updated_session['auth']['type'] == 'test-saved'\n assert updated_session['auth']['raw_auth'] == \"user:password\"\n plugin_manager.unregister(Plugin)", "label": 0, "programming_language": "Python", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def test_filelike_http10(self):\n to_send = \"GET /filelike HTTP/1.0\\n\\n\"\n to_send = tobytes(to_send)\n\n self.connect()\n\n self.sock.send(to_send)\n fp = self.sock.makefile(\"rb\", 0)\n line, headers, response_body = read_http(fp)\n self.assertline(line, \"200\", \"OK\", \"HTTP/1.0\")\n cl = int(headers[\"content-length\"])\n self.assertEqual(cl, len(response_body))\n ct = headers[\"content-type\"]\n self.assertEqual(ct, \"image/jpeg\")\n self.assertTrue(b\"\\377\\330\\377\" in response_body)\n # connection has been closed\n self.send_check_error(to_send)\n self.assertRaises(ConnectionClosed, read_http, fp)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": "def feed_authorindex():\n shift = 0\n off = int(request.args.get(\"offset\") or 0)\n entries = calibre_db.session.query(func.upper(func.substr(db.Authors.sort, 1, 1)).label('id'))\\\n .join(db.books_authors_link).join(db.Books).filter(calibre_db.common_filters())\\\n .group_by(func.upper(func.substr(db.Authors.sort, 1, 1))).all()\n\n elements = []\n if off == 0:\n elements.append({'id': \"00\", 'name':_(\"All\")})\n shift = 1\n for entry in entries[\n off + shift - 1:\n int(off + int(config.config_books_per_page) - shift)]:\n elements.append({'id': entry.id, 'name': entry.id})\n\n pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,\n len(entries) + 1)\n return render_xml_template('feed.xml',\n letterelements=elements,\n folder='opds.feed_letter_author',\n pagination=pagination)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def sentences_victim(self, type, data = None, sRun = 1, column = 0):\n if sRun == 2:\n return self.sql_insert(self.prop_sentences_victim(type, data))\n elif sRun == 3:\n return self.sql_one_row(self.prop_sentences_victim(type, data), column)\n else:\n return self.sql_execute(self.prop_sentences_victim(type, data))", "label": 0, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def __init__(self, *, openapi: GeneratorData) -> None:\n self.openapi: GeneratorData = openapi\n self.env: Environment = Environment(loader=PackageLoader(__package__), trim_blocks=True, lstrip_blocks=True)\n\n self.project_name: str = self.project_name_override or f\"{openapi.title.replace(' ', '-').lower()}-client\"\n self.project_dir: Path = Path.cwd() / self.project_name\n\n self.package_name: str = self.package_name_override or self.project_name.replace(\"-\", \"_\")\n self.package_dir: Path = self.project_dir / self.package_name\n self.package_description: str = f\"A client library for accessing {self.openapi.title}\"\n self.version: str = openapi.version\n\n self.env.filters.update(self.TEMPLATE_FILTERS)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def read_template(self, filename: str) -> jinja2.Template:\n \"\"\"Load a template file from disk.\n\n This function will attempt to load the given template from the default Synapse\n template directory.\n\n Files read are treated as Jinja templates. The templates is not rendered yet\n and has autoescape enabled.\n\n Args:\n filename: A template filename to read.\n\n Raises:\n ConfigError: if the file's path is incorrect or otherwise cannot be read.\n\n Returns:\n A jinja2 template.\n \"\"\"\n return self.read_templates([filename])[0]", "label": 1, "programming_language": "Python", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " def test_keepalive_http11_explicit(self):\n # Explicitly set keep-alive\n data = \"Default: Keep me alive\"\n s = tobytes(\n \"GET / HTTP/1.1\\r\\n\"\n \"Connection: keep-alive\\r\\n\"\n \"Content-Length: %d\\r\\n\"\n \"\\r\\n\"\n \"%s\" % (len(data), data)\n )\n self.connect()\n self.sock.send(s)\n response = httplib.HTTPResponse(self.sock)\n response.begin()\n self.assertEqual(int(response.status), 200)\n self.assertTrue(response.getheader(\"connection\") != \"close\")", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " def testPeek(self):\n with ops.Graph().as_default() as G:\n with ops.device('/cpu:0'):\n x = array_ops.placeholder(dtypes.int32, name='x')\n pi = array_ops.placeholder(dtypes.int64)\n gi = array_ops.placeholder(dtypes.int64)\n p = array_ops.placeholder(dtypes.int32, name='p')\n with ops.device(test.gpu_device_name()):\n stager = data_flow_ops.MapStagingArea(\n [\n dtypes.int32,\n ], shapes=[[]])\n stage = stager.put(pi, [x], [0])\n peek = stager.peek(gi)\n size = stager.size()\n\n G.finalize()\n\n n = 10\n\n with self.session(graph=G) as sess:\n for i in range(n):\n sess.run(stage, feed_dict={x: i, pi: i})\n\n for i in range(n):\n self.assertTrue(sess.run(peek, feed_dict={gi: i})[0] == i)\n\n self.assertTrue(sess.run(size) == 10)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "vulnerable"} {"code": " def __init__(self, formats=None, content_types=None, datetime_formatting=None):\n self.supported_formats = []\n self.datetime_formatting = getattr(settings, 'TASTYPIE_DATETIME_FORMATTING', 'iso-8601')\n\n if formats is not None:\n self.formats = formats\n\n if content_types is not None:\n self.content_types = content_types\n\n if datetime_formatting is not None:\n self.datetime_formatting = datetime_formatting\n\n for format in self.formats:\n try:\n self.supported_formats.append(self.content_types[format])\n except KeyError:\n raise ImproperlyConfigured(\"Content type for specified type '%s' not found. Please provide it at either the class level or via the arguments.\" % format)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def check_xsrf_cookie(self):\n \"\"\"Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument.\n\n To prevent cross-site request forgery, we set an ``_xsrf``\n cookie and include the same value as a non-cookie\n field with all ``POST`` requests. If the two do not match, we\n reject the form submission as a potential forgery.\n\n The ``_xsrf`` value may be set as either a form field named ``_xsrf``\n or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken``\n (the latter is accepted for compatibility with Django).\n\n See http://en.wikipedia.org/wiki/Cross-site_request_forgery\n\n Prior to release 1.1.1, this check was ignored if the HTTP header\n ``X-Requested-With: XMLHTTPRequest`` was present. This exception\n has been shown to be insecure and has been removed. For more\n information please see\n http://www.djangoproject.com/weblog/2011/feb/08/security/\n http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails\n \"\"\"\n token = (self.get_argument(\"_xsrf\", None) or\n self.request.headers.get(\"X-Xsrftoken\") or\n self.request.headers.get(\"X-Csrftoken\"))\n if not token:\n raise HTTPError(403, \"'_xsrf' argument missing from POST\")\n if not _time_independent_equals(utf8(self.xsrf_token), utf8(token)):\n raise HTTPError(403, \"XSRF cookie does not match POST argument\")", "label": 0, "programming_language": "Python", "cwe_id": "CWE-203", "cwe_name": "Observable Discrepancy", "description": "The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.", "url": "https://cwe.mitre.org/data/definitions/203.html", "label_name": "vulnerable"} {"code": "def is_safe_filesystem_path_component(path):\n \"\"\"Checks if path is a single component of a local filesystem path\n and is safe to join\"\"\"\n if not path:\n return False\n drive, _ = os.path.splitdrive(path)\n if drive:\n return False\n head, _ = os.path.split(path)\n if head:\n return False\n if path in (os.curdir, os.pardir):\n return False\n return True", "label": 1, "programming_language": "Python", "cwe_id": "CWE-21", "cwe_name": "DEPRECATED: Pathname Traversal and Equivalence Errors", "description": "This category has been deprecated. It was originally used for organizing weaknesses involving file names, which enabled access to files outside of a restricted directory (path traversal) or to perform operations on files that would otherwise be restricted (path equivalence). Consider using either the File Handling Issues category (CWE-1219) or the class Use of Incorrectly-Resolved Name or Reference (CWE-706).", "url": "https://cwe.mitre.org/data/definitions/21.html", "label_name": "safe"} {"code": "def _inject_metadata_into_fs(metadata, fs, execute=None):\n metadata = dict([(m.key, m.value) for m in metadata])\n _inject_file_into_fs(fs, 'meta.js', jsonutils.dumps(metadata))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "def update_server_key(conf):\n \"\"\"\n Download the server's RSA key and store in the location\n specified in the configuration.\n :param conf: The consumer configuration object.\n :type conf: dict\n \"\"\"\n host = conf['server']['host']\n location = conf['server']['rsa_pub']\n url = 'https://%s/pulp/static/rsa_pub.key' % host\n try:\n os.makedirs(os.path.dirname(location))\n except OSError, e:\n if e.errno != errno.EEXIST:\n raise\n download(url, location)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": " def testLSTMBlockCellErrorHandling(self):\n forget_bias = 1\n cell_clip = 0\n use_peephole = False\n x = constant_op.constant(0.837607, shape=[28, 29], dtype=dtypes.float32)\n cs_prev = constant_op.constant(0, shape=[28, 17], dtype=dtypes.float32)\n h_prev = constant_op.constant(\n 0.592631638, shape=[28, 17], dtype=dtypes.float32)\n w = constant_op.constant(0.887386262, shape=[46, 68], dtype=dtypes.float32)\n wci = constant_op.constant(0, shape=[], dtype=dtypes.float32)\n wcf = constant_op.constant(0, shape=[17], dtype=dtypes.float32)\n wco = constant_op.constant(\n 0.592631638, shape=[28, 17], dtype=dtypes.float32)\n b = constant_op.constant(0.75259006, shape=[68], dtype=dtypes.float32)\n with self.assertRaises(errors_impl.InvalidArgumentError):\n self.evaluate(\n gen_rnn_ops.lstm_block_cell(\n x=x,\n cs_prev=cs_prev,\n h_prev=h_prev,\n w=w,\n wci=wci,\n wcf=wcf,\n wco=wco,\n b=b,\n forget_bias=forget_bias,\n cell_clip=cell_clip,\n use_peephole=use_peephole))", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def edit_all_cc_data(book_id, book, to_save):\n cc = calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()\n return edit_cc_data(book_id, book, to_save, cc)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def visit_Call(self, call):\n if call.func.id in INVALID_CALLS:\n raise Exception(\"invalid function: %s\" % call.func.id)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " def setUp(self):\n config = {\n \"general\": {\n \"ip.blacklist\": \"5.0.0.0/8\",\n \"ip.whitelist\": \"5.1.1.1\",\n },\n }\n\n self.sydent = make_sydent(test_config=config)\n\n self.reactor = self.sydent.reactor\n\n self.safe_domain, self.safe_ip = b\"safe.test\", b\"1.2.3.4\"\n self.unsafe_domain, self.unsafe_ip = b\"danger.test\", b\"5.6.7.8\"\n self.allowed_domain, self.allowed_ip = b\"allowed.test\", b\"5.1.1.1\"\n\n # Configure the reactor's DNS resolver.\n for (domain, ip) in (\n (self.safe_domain, self.safe_ip),\n (self.unsafe_domain, self.unsafe_ip),\n (self.allowed_domain, self.allowed_ip),\n ):\n self.reactor.lookups[domain.decode()] = ip.decode()\n self.reactor.lookups[ip.decode()] = ip.decode()\n\n self.ip_whitelist = self.sydent.ip_whitelist\n self.ip_blacklist = self.sydent.ip_blacklist", "label": 1, "programming_language": "Python", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def testColocation(self):\n gpu_dev = test.gpu_device_name()\n\n with ops.Graph().as_default() as g:\n with ops.device('/cpu:0'):\n x = array_ops.placeholder(dtypes.float32)\n v = 2. * (array_ops.zeros([128, 128]) + x)\n with ops.device(gpu_dev):\n stager = data_flow_ops.MapStagingArea([dtypes.float32])\n y = stager.put(1, [v], [0])\n expected_name = gpu_dev if 'gpu' not in gpu_dev else '/device:GPU:0'\n self.assertEqual(y.device, expected_name)\n with ops.device('/cpu:0'):\n _, x = stager.get(1)\n y = stager.peek(1)[0]\n _, z = stager.get()\n self.assertEqual(x[0].device, '/device:CPU:0')\n self.assertEqual(y.device, '/device:CPU:0')\n self.assertEqual(z[0].device, '/device:CPU:0')\n\n g.finalize()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "safe"} {"code": "def test_remote_static(app):\n \"\"\"Test endpoint that serves files as a logged user\"\"\"\n # GIVEN a file on disk\n file = \"../demo/ACC5963A1_lanes_1234_star_sorted_sj_filtered_sorted.bed.gz\"\n\n # GIVEN a running demo app\n with app.test_client() as client:\n # GIVEN that user is logged in\n client.get(url_for(\"auto_login\"))\n with client.session_transaction() as session:\n # GIVEN that resource file exists in user session\n session[\"igv_tracks\"] = [file]\n\n # THEN the resource should be available to the user\n resp = client.get(\n url_for(\n \"alignviewers.remote_static\",\n file=file,\n )\n )\n assert resp.status_code == 200", "label": 0, "programming_language": "Python", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " def testInputPreProcessErrorBadFormat(self):\n input_str = 'inputx=file[[v1]v2'\n with self.assertRaises(RuntimeError):\n saved_model_cli.preprocess_inputs_arg_string(input_str)\n input_str = 'inputx:file'\n with self.assertRaises(RuntimeError):\n saved_model_cli.preprocess_inputs_arg_string(input_str)\n input_str = 'inputx:np.zeros((5))'\n with self.assertRaises(RuntimeError):\n saved_model_cli.preprocess_input_exprs_arg_string(input_str)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " def __init__(self, config):\n os.umask(0077)\n self.config = config\n self.threads = []\n self.workers = []\n self.client_list = []\n self.node_list = []\n self.master = False\n self.retrieved = 0\n self.need_local_sudo = False\n if not self.config['list_options']:\n try:\n if not self.config['tmp_dir']:\n self.create_tmp_dir()\n self._setup_logging()\n self.log_debug('Executing %s' % ' '.join(s for s in sys.argv))\n self._load_clusters()\n self._parse_options()\n self.prep()\n except KeyboardInterrupt:\n self._exit('Exiting on user cancel', 130)\n else:\n self._load_clusters()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "safe"} {"code": " def testInvalidLength(self):\n x = [-4, -3, -2, -1, 0, 1, 2, 3]\n with self.assertRaisesRegex(errors.InvalidArgumentError,\n \"Source format must be of length 4 or 5\"):\n op = nn_ops.data_format_dim_map(\n x, src_format=\"12345678\", dst_format=\"87654321\")\n with test_util.use_gpu():\n self.evaluate(op)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " def test_module(self):\n body = [ast.Num(42)]\n x = ast.Module(body)\n self.assertEqual(x.body, body)", "label": 0, "programming_language": "Python", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " def test_confirmation_expired(self) -> None:\n email = self.nonreg_email(\"alice\")\n realm = get_realm(\"zulip\")\n inviter = self.example_user(\"iago\")\n prereg_user = PreregistrationUser.objects.create(\n email=email, referred_by=inviter, realm=realm\n )\n date_sent = timezone_now() - datetime.timedelta(weeks=3)\n with patch(\"confirmation.models.timezone_now\", return_value=date_sent):\n url = create_confirmation_link(prereg_user, Confirmation.USER_REGISTRATION)\n\n key = url.split(\"/\")[-1]\n confirmation_link_path = \"/\" + url.split(\"/\", 3)[3]\n # Both the confirmation link and submitting the key to the registration endpoint\n # directly will return the appropriate error.\n result = self.client_get(confirmation_link_path)\n self.assertEqual(result.status_code, 404)\n self.assert_in_response(\n \"Whoops. The confirmation link has expired or been deactivated.\", result\n )\n\n result = self.client_post(\"/accounts/register/\", {\"key\": key})\n self.assertEqual(result.status_code, 404)\n self.assert_in_response(\n \"Whoops. The confirmation link has expired or been deactivated.\", result\n )", "label": 1, "programming_language": "Python", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "safe"} {"code": " def _access_endpoint(self, endpoint, args, status_code, msg):\n \"\"\"\n Asserts that accessing the given `endpoint` gets a response of `status_code`.\n\n endpoint: string, endpoint for instructor dash API\n args: dict, kwargs for `reverse` call\n status_code: expected HTTP status code response\n msg: message to display if assertion fails.\n \"\"\"\n url = reverse(endpoint, kwargs={'course_id': self.course.id.to_deprecated_string()})\n if endpoint in ['send_email', 'students_update_enrollment', 'bulk_beta_modify_access']:\n response = self.client.post(url, args)\n else:\n response = self.client.get(url, args)\n self.assertEqual(\n response.status_code,\n status_code,\n msg=msg\n )", "label": 0, "programming_language": "Python", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": "def is_writable(dir):\n \"\"\"Determine whether a given directory is writable in a portable manner.\n\n Parameters\n ----------\n dir : str\n A string represeting a path to a directory on the filesystem.\n\n Returns\n -------\n res : bool\n True or False.\n \"\"\"\n if not os.path.isdir(dir):\n return False\n\n # Do NOT use a hardcoded name here due to the danger from race conditions\n # on NFS when multiple processes are accessing the same base directory in\n # parallel. We use both hostname and process id for the prefix in an\n # attempt to ensure that there can really be no name collisions (tempfile\n # appends 6 random chars to this prefix).\n prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid())\n try:\n tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir)\n except OSError:\n return False\n # The underlying file is destroyed upon closing the file object (under\n # *nix, it was unlinked at creation time)\n tmp.close()\n return True", "label": 1, "programming_language": "Python", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": " def test_get_header_lines_tabbed(self):\n result = self._callFUT(b\"slam\\r\\n\\tslim\")\n self.assertEqual(result, [b\"slam\\tslim\"])", "label": 1, "programming_language": "Python", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "def _inject_net_into_fs(net, fs, execute=None):\n \"\"\"Inject /etc/network/interfaces into the filesystem rooted at fs.\n\n net is the contents of /etc/network/interfaces.\n \"\"\"\n netdir = _join_and_check_path_within_fs(fs, 'etc', 'network')\n utils.execute('mkdir', '-p', netdir, run_as_root=True)\n utils.execute('chown', 'root:root', netdir, run_as_root=True)\n utils.execute('chmod', 755, netdir, run_as_root=True)\n\n netfile = os.path.join('etc', 'network', 'interfaces')\n _inject_file_into_fs(fs, netfile, net)", "label": 1, "programming_language": "Python", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def __init__(self, hs):\n self.server_name = hs.hostname\n self.client = hs.get_http_client()", "label": 0, "programming_language": "Python", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "vulnerable"} {"code": " def as_const(self, eval_ctx=None):\n eval_ctx = get_eval_context(self, eval_ctx)\n if eval_ctx.volatile or eval_ctx.environment.sandboxed:\n raise Impossible()\n obj = self.node.as_const(eval_ctx)\n\n # don't evaluate context functions\n args = [x.as_const(eval_ctx) for x in self.args]\n if isinstance(obj, _context_function_types):\n if getattr(obj, 'contextfunction', False):\n raise Impossible()\n elif getattr(obj, 'evalcontextfunction', False):\n args.insert(0, eval_ctx)\n elif getattr(obj, 'environmentfunction', False):\n args.insert(0, self.environment)\n\n kwargs = dict(x.as_const(eval_ctx) for x in self.kwargs)\n if self.dyn_args is not None:\n try:\n args.extend(self.dyn_args.as_const(eval_ctx))\n except Exception:\n raise Impossible()\n if self.dyn_kwargs is not None:\n try:\n kwargs.update(self.dyn_kwargs.as_const(eval_ctx))\n except Exception:\n raise Impossible()\n try:\n return obj(*args, **kwargs)\n except Exception:\n raise Impossible()", "label": 1, "programming_language": "Python", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": " public ECIESwithAESCBC()\n {\n super(new CBCBlockCipher(new AESFastEngine()), 16);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testGetBytesAndSetBytesWithFileChannel() throws IOException {\n File file = PlatformDependent.createTempFile(\"file-channel\", \".tmp\", null);\n RandomAccessFile randomAccessFile = null;\n try {\n randomAccessFile = new RandomAccessFile(file, \"rw\");\n FileChannel channel = randomAccessFile.getChannel();\n // channelPosition should never be changed\n long channelPosition = channel.position();\n\n byte[] bytes = {'a', 'b', 'c', 'd'};\n int len = bytes.length;\n ByteBuf buffer = newBuffer(len);\n buffer.resetReaderIndex();\n buffer.resetWriterIndex();\n buffer.writeBytes(bytes);\n\n int oldReaderIndex = buffer.readerIndex();\n assertEquals(len, buffer.getBytes(oldReaderIndex, channel, 10, len));\n assertEquals(oldReaderIndex, buffer.readerIndex());\n assertEquals(channelPosition, channel.position());\n\n ByteBuf buffer2 = newBuffer(len);\n buffer2.resetReaderIndex();\n buffer2.resetWriterIndex();\n int oldWriterIndex = buffer2.writerIndex();\n assertEquals(buffer2.setBytes(oldWriterIndex, channel, 10, len), len);\n assertEquals(channelPosition, channel.position());\n\n assertEquals(oldWriterIndex, buffer2.writerIndex());\n assertEquals('a', buffer2.getByte(oldWriterIndex));\n assertEquals('b', buffer2.getByte(oldWriterIndex + 1));\n assertEquals('c', buffer2.getByte(oldWriterIndex + 2));\n assertEquals('d', buffer2.getByte(oldWriterIndex + 3));\n\n buffer.release();\n buffer2.release();\n } finally {\n if (randomAccessFile != null) {\n randomAccessFile.close();\n }\n file.delete();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-378", "cwe_name": "Creation of Temporary File With Insecure Permissions", "description": "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.", "url": "https://cwe.mitre.org/data/definitions/378.html", "label_name": "safe"} {"code": " public static void endRequest() {\n final List result = CACHE.get();\n if (result != null) {\n CACHE.remove();\n for (final RequestScopedItem item : result) {\n item.invalidate();\n }\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": " public void removeHandler(String path) {\n getDispatchHandler().removeHandler(path);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": "\tpublic static String applySorting(String query, Sort sort, String alias) {\n\n\t\tAssert.hasText(query);\n\n\t\tif (null == sort || !sort.iterator().hasNext()) {\n\t\t\treturn query;\n\t\t}\n\n\t\tStringBuilder builder = new StringBuilder(query);\n\n\t\tif (!ORDER_BY.matcher(query).matches()) {\n\t\t\tbuilder.append(\" order by \");\n\t\t} else {\n\t\t\tbuilder.append(\", \");\n\t\t}\n\n\t\tSet aliases = getOuterJoinAliases(query);\n\n\t\tfor (Order order : sort) {\n\t\t\tbuilder.append(getOrderClause(aliases, alias, order)).append(\", \");\n\t\t}\n\n\t\tbuilder.delete(builder.length() - 2, builder.length());\n\n\t\treturn builder.toString();\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " private void verifyContentLength(Http2Stream stream, int data, boolean isEnd) throws Http2Exception {\n if (!VALIDATE_CONTENT_LENGTH) {\n return;\n }\n ContentLength contentLength = stream.getProperty(contentLengthKey);\n if (contentLength != null) {\n try {\n contentLength.increaseReceivedBytes(connection.isServer(), stream.id(), data, isEnd);\n } finally {\n if (isEnd) {\n stream.removeProperty(contentLengthKey);\n }\n }\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " protected void onSubmit()\n {\n super.onSubmit();\n csrfTokenHandler.onSubmit();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public void violationMessagesAreInterpolatedIfEscapingDisabled() {\n assertThat(ConstraintViolations.format(validator.validate(new EscapingDisabledExample()))).containsExactly(\n \" A2\",\n \" TEST\",\n \" value\",\n \"${'property'} value\",\n \"${'property'}[${'key'}] value\",\n \"${'property'}[1] value\"\n );\n assertThat(TestLoggerFactory.getAllLoggingEvents()).isEmpty();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public void shouldThrowExceptionForBadConnection() throws Exception {\n String url = \"http://not-exists\";\n HgCommand hgCommand = new HgCommand(null, null, null, null, null);\n\n assertThatThrownBy(() -> hgCommand.checkConnection(new UrlArgument(url)))\n .isExactlyInstanceOf(CommandLineException.class);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " private String stripComments(String theScript) {\n return BLOCK_COMMENT_STRIPPER.matcher(theScript).replaceAll(\"\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " public String compact() {\n return id.replaceAll(\"/\", \"-\").replaceAll(\"\\\\\\\\\", \"-\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void testBourneShellQuotingCharacters()\n throws Exception\n {\n // { ' ', '$', ';', '&', '|', '<', '>', '*', '?', '(', ')' };\n // test with values http://steve-parker.org/sh/bourne.shtml Appendix B - Meta-characters and Reserved Words\n Commandline commandline = new Commandline( newShell() );\n commandline.setExecutable( \"chmod\" );\n commandline.getShell().setQuotedArgumentsEnabled( true );\n commandline.createArg().setValue( \" \" );\n commandline.createArg().setValue( \"|\" );\n commandline.createArg().setValue( \"&&\" );\n commandline.createArg().setValue( \"||\" );\n commandline.createArg().setValue( \";\" );\n commandline.createArg().setValue( \";;\" );\n commandline.createArg().setValue( \"&\" );\n commandline.createArg().setValue( \"()\" );\n commandline.createArg().setValue( \"<\" );\n commandline.createArg().setValue( \"<<\" );\n commandline.createArg().setValue( \">\" );\n commandline.createArg().setValue( \">>\" );\n commandline.createArg().setValue( \"*\" );\n commandline.createArg().setValue( \"?\" );\n commandline.createArg().setValue( \"[\" );\n commandline.createArg().setValue( \"]\" );\n commandline.createArg().setValue( \"{\" );\n commandline.createArg().setValue( \"}\" );\n commandline.createArg().setValue( \"`\" );\n\n String[] lines = commandline.getShellCommandline();\n System.out.println( Arrays.asList( lines ) );\n\n assertEquals( \"/bin/sh\", lines[0] );\n assertEquals( \"-c\", lines[1] );\n assertEquals( \"'chmod' ' ' '|' '&&' '||' ';' ';;' '&' '()' '<' '<<' '>' '>>' '*' '?' '[' ']' '{' '}' '`'\",\n lines[2] );\n\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " public boolean isValid(Integer value, ConstraintValidatorContext context) {\n if (proxyManager.get(value) != null) {\n return true;\n }\n\n String errorMessage = String.format(\"No proxy server found for specified port %d\", value);\n LOG.warn(errorMessage);\n\n context.buildConstraintViolationWithTemplate(errorMessage).addPropertyNode(PARAM_NAME).addConstraintViolation();\n return false;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void translate(ServerEntityPositionRotationPacket packet, GeyserSession session) {\n Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());\n if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {\n entity = session.getPlayerEntity();\n }\n if (entity == null) return;\n\n entity.updatePositionAndRotation(session, packet.getMoveX(), packet.getMoveY(), packet.getMoveZ(), packet.getYaw(), packet.getPitch(), packet.isOnGround());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": "\tpublic Map> getCustomConfig(CourseEnvironment courseEnvironment){\n\t\tMap> defaultConf = new HashMap<>();\n\t\tVFSContainer base = (VFSContainer) courseEnvironment.getCourseBaseContainer().resolve(CourseLayoutHelper.LAYOUT_COURSE_SUBFOLDER);\n\t\tif (base == null) {\n\t\t\treturn defaultConf;\n\t\t}\n\t\tVFSContainer themeBase = (VFSContainer) base.resolve(\"/\" + CourseLayoutHelper.CONFIG_KEY_CUSTOM);\n\t\tif (themeBase == null) {\n\t\t\treturn defaultConf;\n\t\t}\n\t\tVFSLeaf configTarget = (VFSLeaf) themeBase.resolve(CUSTOM_CONFIG_XML);\n\t\tif (configTarget == null) {\n\t\t\treturn defaultConf;\n\t\t}\n\t\tXStream xStream = XStreamHelper.createXStreamInstance();\n\t\ttry(InputStream in=configTarget.getInputStream()) {\n\t\t\treturn (Map>) xStream.fromXML(in);\n\t\t} catch(IOException e) {\n\t\t\tlog.error(\"\", e);\n\t\t\treturn defaultConf;\n\t\t}\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " public static SAXReader getSafeSaxReader() throws Exception\n {\n SAXReader xmlReader = new SAXReader();\n xmlReader.setFeature(\"http://apache.org/xml/features/disallow-doctype-decl\", true);\n return xmlReader;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "\tpublic void reportJobCaches(byte[] cacheInstanceBytes) {\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tCollection cacheInstances = (Collection) SerializationUtils\n\t\t\t\t.deserialize(cacheInstanceBytes);\n\t\tjobManager.reportJobCaches(getJobToken(), cacheInstances);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public NettyHttpHeaders() {\n this.nettyHeaders = new DefaultHttpHeaders(false);\n this.conversionService = ConversionService.SHARED;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " public SVNAuthentication createSVNAuthentication(String kind) {\n if(kind.equals(ISVNAuthenticationManager.SSL))\n try {\n SVNSSLAuthentication authentication = new SVNSSLAuthentication(\n Base64.decode(certificate.getPlainText().toCharArray()),\n Scrambler.descramble(password), false);\n authentication.setCertificatePath(\"dummy\"); // TODO: remove this JENKINS-19175 workaround\n return authentication;\n } catch (IOException e) {\n throw new Error(e); // can't happen\n }\n else\n return null; // unexpected authentication type\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-255", "cwe_name": "Credentials Management Errors", "description": "Weaknesses in this category are related to the management of credentials.", "url": "https://cwe.mitre.org/data/definitions/255.html", "label_name": "vulnerable"} {"code": " public void create() throws Exception {\n final JettyServerFactory jettyServerFactory = mock(JettyServerFactory.class);\n final StaticFilesConfiguration staticFilesConfiguration = mock(StaticFilesConfiguration.class);\n final Routes routes = mock(Routes.class);\n\n when(jettyServerFactory.create(100,10,10000)).thenReturn(new Server());\n\n final EmbeddedJettyFactory embeddedJettyFactory = new EmbeddedJettyFactory(jettyServerFactory);\n embeddedServer = embeddedJettyFactory.create(routes, staticFilesConfiguration, false);\n\n embeddedServer.ignite(\"localhost\", 8080, null, 100,10,10000);\n\n verify(jettyServerFactory, times(1)).create(100,10,10000);\n verifyNoMoreInteractions(jettyServerFactory);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public void translate(ServerSpawnPaintingPacket packet, GeyserSession session) {\n Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());\n\n PaintingEntity entity = new PaintingEntity(packet.getEntityId(),\n session.getEntityCache().getNextEntityId().incrementAndGet(),\n position, PaintingType.getByPaintingType(packet.getPaintingType()), packet.getDirection().ordinal());\n\n session.getEntityCache().spawnEntity(entity);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public static @CheckForNull T find(Collection list, String className) {\n for (T d : list) {\n if(d.getClass().getName().equals(className))\n return d;\n }\n // Since we introduced Descriptor.getId(), it is a preferred method of identifying descriptor by a string.\n // To make that migration easier without breaking compatibility, let's also match up with the id.\n for (T d : list) {\n if(d.getId().equals(className))\n return d;\n }\n return null;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public HMACConfidentialKey(String id, int length) {\n super(id);\n this.length = length;\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "TEST(ProtocolSkipTest, SkipStop) {\n IOBufQueue queue;\n CompactProtocolWriter writer;\n writer.setOutput(&queue);\n writer.writeFieldStop();\n auto buf = queue.move();\n CompactProtocolReader reader;\n reader.setInput(buf.get());\n bool thrown = false;\n try {\n reader.skip(TType::T_STOP);\n } catch (const TProtocolException& ex) {\n EXPECT_EQ(TProtocolException::INVALID_DATA, ex.getType());\n thrown = true;\n }\n EXPECT_TRUE(thrown);\n}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "safe"} {"code": " public static String decodePath(String path) {\n if (path.indexOf('%') < 0) {\n // No need to decoded; not percent-encoded\n return path;\n }\n\n // Decode percent-encoded characters.\n // An invalid character is replaced with 0xFF, which will be replaced into '\ufffd' by UTF-8 decoder.\n final int len = path.length();\n try (TemporaryThreadLocals tempThreadLocals = TemporaryThreadLocals.acquire()) {\n final byte[] buf = tempThreadLocals.byteArray(len);\n int dstLen = 0;\n for (int i = 0; i < len; i++) {\n final char ch = path.charAt(i);\n if (ch != '%') {\n buf[dstLen++] = (byte) ((ch & 0xFF80) == 0 ? ch : 0xFF);\n continue;\n }\n\n // Decode a percent-encoded character.\n final int hexEnd = i + 3;\n if (hexEnd > len) {\n // '%' or '%x' (must be followed by two hexadigits)\n buf[dstLen++] = (byte) 0xFF;\n break;\n }\n\n final int digit1 = decodeHexNibble(path.charAt(++i));\n final int digit2 = decodeHexNibble(path.charAt(++i));\n if (digit1 < 0 || digit2 < 0) {\n // The first or second digit is not hexadecimal.\n buf[dstLen++] = (byte) 0xFF;\n } else {\n buf[dstLen++] = (byte) ((digit1 << 4) | digit2);\n }\n }\n\n return new String(buf, 0, dstLen, StandardCharsets.UTF_8);\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public TMap readMapBegin() throws TException {\n int size = readVarint32();\n byte keyAndValueType = size == 0 ? 0 : readByte();\n byte keyType = getTType((byte) (keyAndValueType >> 4));\n byte valueType = getTType((byte) (keyAndValueType & 0xf));\n if (size > 0) {\n ensureMapHasEnough(size, keyType, valueType);\n }\n return new TMap(keyType, valueType, size);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": " public void translate(AdventureSettingsPacket packet, GeyserSession session) {\n boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);\n if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) {\n // We should always be flying in spectator mode\n session.sendAdventureSettings();\n return;\n }\n\n session.setFlying(isFlying);\n ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(isFlying);\n session.sendDownstreamPacket(abilitiesPacket);\n\n if (isFlying && session.getPlayerEntity().getMetadata().getFlags().getFlag(EntityFlag.SWIMMING)) {\n // Bedrock can fly and swim at the same time? Make sure that can't happen\n session.setSwimming(false);\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public void testInvalidGroupIds() {\n testInvalidGroupId(\"JohnDoe\",true);\n testInvalidGroupId(\"Jane'Doe'\",true);\n testInvalidGroupId(\"John&Doe\",true);\n testInvalidGroupId(\"Jane\\\"\\\"Doe\",true);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public void engineInit(\n int opmode,\n Key key,\n SecureRandom random)\n throws InvalidKeyException\n {\n try\n {\n engineInit(opmode, key, (AlgorithmParameterSpec)null, random);\n }\n catch (InvalidAlgorithmParameterException e)\n {\n throw new IllegalArgumentException(\"can't handle supplied parameter spec\");\n }\n\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void preflightCheck() {\n String origin = \"http://bla.com\";\n String headers =\"X-Data: Test\";\n expect(backend.isOriginAllowed(origin,false)).andReturn(true);\n replay(backend);\n\n Map ret = handler.handleCorsPreflightRequest(origin, headers);\n assertEquals(ret.get(\"Access-Control-Allow-Origin\"),origin);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " boolean isClassValid(String requestedClassName) {\n if (whitelistClassNameCache.contains(requestedClassName)) {\n return true;\n }\n try {\n Class requestedClass = Class.forName(requestedClassName);\n for (Class baseClass : whitelistBaseClasses ) {\n if (baseClass.isAssignableFrom(requestedClass)) {\n whitelistClassNameCache.add(requestedClassName);\n return true;\n }\n }\n } catch (ClassNotFoundException e) {\n return false;\n }\n return false;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " public void translate(ContainerClosePacket packet, GeyserSession session) {\n byte windowId = packet.getId();\n\n //Client wants close confirmation\n session.sendUpstreamPacket(packet);\n session.setClosingInventory(false);\n\n if (windowId == -1 && session.getOpenInventory() instanceof MerchantContainer) {\n // 1.16.200 - window ID is always -1 sent from Bedrock\n windowId = (byte) session.getOpenInventory().getId();\n }\n\n Inventory openInventory = session.getOpenInventory();\n if (openInventory != null) {\n if (windowId == openInventory.getId()) {\n ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);\n session.sendDownstreamPacket(closeWindowPacket);\n InventoryUtils.closeInventory(session, windowId, false);\n } else if (openInventory.isPending()) {\n InventoryUtils.displayInventory(session, openInventory);\n openInventory.setPending(false);\n }\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public static void set(String s) {\n Secret.SECRET = s;\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public OldIESwithDESede()\n {\n super(new DESedeEngine());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public String post(TestWrapper wrapper)\n {\n return wrapper.getName();\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " private static Class lookup(String className)\n {\n try\n {\n Class def = DRBG.class.getClassLoader().loadClass(className);\n\n return def;\n }\n catch (Exception e)\n {\n return null;\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testQuoteWorkingDirectoryAndExecutable_WDPathWithSingleQuotes()\n {\n Shell sh = newShell();\n\n sh.setWorkingDirectory( \"/usr/local/'something else'\" );\n sh.setExecutable( \"chmod\" );\n\n String executable = StringUtils.join( sh.getShellCommandLine( new String[]{} ).iterator(), \" \" );\n\n assertEquals( \"/bin/sh -c cd \\\"/usr/local/\\'something else\\'\\\" && chmod\", executable );\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " public DocumentFactory getDocumentFactory() {\n if (factory == null) {\n factory = DocumentFactory.getInstance();\n }\n\n return factory;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " default Optional contentType() {\n return getFirst(HttpHeaders.CONTENT_TYPE, MediaType.class);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " void equal() {\n final PathAndQuery res = parse(\"/=?a=b=1\");\n assertThat(res).isNotNull();\n assertThat(res.path()).isEqualTo(\"/=\");\n assertThat(res.query()).isEqualTo(\"a=b=1\");\n\n // '%3D' in a query string should never be decoded into '='.\n final PathAndQuery res2 = parse(\"/%3D?a%3db=1\");\n assertThat(res2).isNotNull();\n assertThat(res2.path()).isEqualTo(\"/=\");\n assertThat(res2.query()).isEqualTo(\"a%3Db=1\");\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " private void updateSecureSessionFlag() {\n try {\n ServletContext context = Jenkins.getInstance().servletContext;\n Method m;\n try {\n m = context.getClass().getMethod(\"getSessionCookieConfig\");\n } catch (NoSuchMethodException x) { // 3.0+\n LOGGER.log(Level.FINE, \"Failed to set secure cookie flag\", x);\n return;\n }\n Object sessionCookieConfig = m.invoke(context);\n\n Class scc = Class.forName(\"javax.servlet.SessionCookieConfig\");\n Method setSecure = scc.getMethod(\"setSecure\", boolean.class);\n boolean v = fixNull(jenkinsUrl).startsWith(\"https\");\n setSecure.invoke(sessionCookieConfig, v);\n } catch (InvocationTargetException e) {\n if (e.getTargetException() instanceof IllegalStateException) {\n // servlet 3.0 spec seems to prohibit this from getting set at runtime,\n // though Winstone is happy to accept i. see JENKINS-25019\n return;\n }\n LOGGER.log(Level.WARNING, \"Failed to set secure cookie flag\", e);\n } catch (Exception e) {\n LOGGER.log(Level.WARNING, \"Failed to set secure cookie flag\", e);\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-254", "cwe_name": "7PK - Security Features", "description": "Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.", "url": "https://cwe.mitre.org/data/definitions/254.html", "label_name": "safe"} {"code": " public AuthenticationInfo loadAuthenticationInfo(JSONWebToken token) {\n Key key = getJWTKey();\n Jwt jwt;\n try {\n jwt = Jwts.parser().setSigningKey(key).parse(token.getPrincipal());\n } catch (JwtException e) {\n throw new AuthenticationException(e);\n }\n String credentials = legacyHashing ? token.getCredentials() : encryptPassword(token.getCredentials());\n Object principal = extractPrincipalFromWebToken(jwt);\n return new SimpleAuthenticationInfo(principal, credentials, getName());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " List newInstancesFromHeteroList(StaplerRequest req, Object formData,\n Collection> descriptors) throws FormException {\n\n List items = new ArrayList();\n\n if (formData!=null) {\n for (Object o : JSONArray.fromObject(formData)) {\n JSONObject jo = (JSONObject)o;\n String kind = jo.getString(\"kind\");\n Descriptor d = find(descriptors, kind);\n if (d != null) {\n items.add(d.newInstance(req, jo));\n }\n }\n }\n\n return items;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public ErrorHandler getErrorHandler() {\n return errorHandler;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": "\tpublic void testUpdateMapper_serializade_withExpirationDate() {\n\t\t//create a mapper\n\t\tString mapperId = UUID.randomUUID().toString();\n\t\tString sessionId = UUID.randomUUID().toString().substring(0, 32);\n\t\tPersistentMapper sMapper = new PersistentMapper(\"mapper-to-persist-until\");\n\t\tPersistedMapper pMapper = mapperDao.persistMapper(sessionId, mapperId, sMapper, 60000);\n\t\tAssert.assertNotNull(pMapper);\n\t\tdbInstance.commitAndCloseSession();\n\t\t\n\t\t//load the mapper\n\t\tPersistedMapper loadedMapper = mapperDao.loadByMapperId(mapperId);\n\t\tAssert.assertNotNull(loadedMapper);\n\t\tObject objReloaded = XStreamHelper.createXStreamInstance().fromXML(pMapper.getXmlConfiguration());\n\t\tAssert.assertTrue(objReloaded instanceof PersistentMapper);\n\t\tPersistentMapper sMapperReloaded = (PersistentMapper)objReloaded;\n\t\tAssert.assertEquals(\"mapper-to-persist-until\", sMapperReloaded.getKey());\n\t\tAssert.assertNotNull(loadedMapper.getExpirationDate());\n\t\t\n\t\t//update\n\t\tPersistentMapper sMapper2 = new PersistentMapper(\"mapper-to-update-until\");\n\t\tboolean updated = mapperDao.updateConfiguration(mapperId, sMapper2, 120000);\n\t\tAssert.assertTrue(updated);\n\t\tdbInstance.commitAndCloseSession();\n\t\t\n\t\t//load the updated mapper\n\t\tPersistedMapper loadedMapper2 = mapperDao.loadByMapperId(mapperId);\n\t\tAssert.assertNotNull(loadedMapper2);\n\t\tObject objReloaded2 = XStreamHelper.createXStreamInstance().fromXML(loadedMapper2.getXmlConfiguration());\n\t\tAssert.assertTrue(objReloaded2 instanceof PersistentMapper);\n\t\tPersistentMapper sMapperReloaded2 = (PersistentMapper)objReloaded2;\n\t\tAssert.assertEquals(\"mapper-to-update-until\", sMapperReloaded2.getKey());\n\t\tAssert.assertNotNull(loadedMapper2.getExpirationDate());\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " public PBEWithSHA256AESCBC256()\n {\n super(new CBCBlockCipher(new AESEngine()), PKCS12, SHA256, 256, 16);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": " public void translate(ServerPlayerAbilitiesPacket packet, GeyserSession session) {\n session.setCanFly(packet.isCanFly());\n session.setFlying(packet.isFlying());\n session.sendAdventureSettings();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public void validateFail3(ViolationCollector col) {\n col.addViolation(FAILED + \"3\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " protected void setDispatchHandler(DispatchHandler dispatchHandler) {\n this.dispatchHandler = dispatchHandler;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " public InputStream getResourceAsStream(String path) throws IOException {\n final URL rootResourceURL = classLoader.getResource(THEME_RESOURCES_RESOURCES);\n if (rootResourceURL == null) {\n return null;\n }\n final String rootPath = rootResourceURL.getPath();\n final URL resourceURL = classLoader.getResource(THEME_RESOURCES_RESOURCES + path);\n if(resourceURL == null || !resourceURL.getPath().startsWith(rootPath)) {\n return null;\n }\n else {\n return resourceURL.openConnection().getInputStream();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "\tpublic void testWhereWithStringFunction() {\n\t\tEntity from = from(Entity.class);\n\t\twhere(lower(from.getCode())).like().any(\"test\");\n\t\tQuery select = select(from);\n\t\tassertEquals(\"select entity_0 from Entity entity_0 where lower(entity_0.code) like :function_1\", select.getQuery());\n\t\tassertEquals(\"%test%\", select.getParameters().get(\"function_1\"));\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " function findLateSubscriptionSortedByPriority() {\n if (late_subscriptions.length === 0) {\n return null;\n }\n late_subscriptions.sort(compare_subscriptions);\n\n // istanbul ignore next\n if (doDebug) {\n debugLog(\n late_subscriptions\n .map(\n (s: Subscription) =>\n \"[ id = \" +\n s.id +\n \" prio=\" +\n s.priority +\n \" t=\" +\n s.timeToExpiration +\n \" ka=\" +\n s.timeToKeepAlive +\n \" m?=\" +\n s.hasUncollectedMonitoredItemNotifications +\n \" \" + \n SubscriptionState[s.state] +\n \" \" + s.messageSent + \n \"]\"\n )\n .join(\" \\n\")\n );\n }\n return late_subscriptions[late_subscriptions.length - 1];\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": " public List modificationsSince(Revision revision) {\n InMemoryStreamConsumer consumer = inMemoryConsumer();\n bombUnless(pull(consumer), \"Failed to run hg pull command: \" + consumer.getAllOutput());\n CommandLine hg = hg(\"log\",\n \"-r\", \"tip:\" + revision.getRevision(),\n \"-b\", branch,\n \"--style\", templatePath());\n return new HgModificationSplitter(execute(hg)).filterOutRevision(revision);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "\tprotected void runTeardown() {\n\t\tAssert.assertTrue(\"Socket connection is not allowed\", securityExceptionOccurred);\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "safe"} {"code": "\tprivate static IRegex getRegexConcat() {\n\t\treturn RegexConcat.build(CommandBinary.class.getName(), RegexLeaf.start(), //\n\t\t\t\tnew RegexOptional( //\n\t\t\t\t\t\tnew RegexConcat( //\n\t\t\t\t\t\t\t\tnew RegexLeaf(\"COMPACT\", \"(compact)\"), //\n\t\t\t\t\t\t\t\tRegexLeaf.spaceOneOrMore())), //\n\t\t\t\tnew RegexLeaf(\"binary\"), //\n\t\t\t\tRegexLeaf.spaceOneOrMore(), //\n\t\t\t\tnew RegexLeaf(\"FULL\", \"[%g]([^%g]+)[%g]\"), //\n\t\t\t\tRegexLeaf.spaceOneOrMore(), //\n\t\t\t\tnew RegexLeaf(\"as\"), //\n\t\t\t\tRegexLeaf.spaceOneOrMore(), //\n\t\t\t\tnew RegexLeaf(\"CODE\", \"([%pLN_.@]+)\"), RegexLeaf.end());\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " private String sendRequest(WebClient webClient, int sequence, boolean poison) throws FailingHttpStatusCodeException, MalformedURLException, IOException {\n final String path = getPath(\"getAndSet\", sequence, poison);\n return webClient.getPage(path).getWebResponse().getContentAsString().trim();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": " protected boolean isProbablePrime(BigInteger x, int iterations)\n {\n /*\n * Primes class for FIPS 186-4 C.3 primality checking\n */\n return !Primes.hasAnySmallFactors(x) && Primes.isMRProbablePrime(x, param.getRandom(), iterations);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-327", "cwe_name": "Use of a Broken or Risky Cryptographic Algorithm", "description": "The use of a broken or risky cryptographic algorithm is an unnecessary risk that may result in the exposure of sensitive information.", "url": "https://cwe.mitre.org/data/definitions/327.html", "label_name": "safe"} {"code": " public void canMixConvertedAndNormalValues() {\n final HttpHeadersBase headers = newEmptyHeaders();\n headers.add(\"name\", \"value\");\n headers.addInt(\"name\", 100);\n\n assertThat(headers.size()).isEqualTo(2);\n assertThat(headers.contains(\"name\")).isTrue();\n assertThat(headers.contains(\"name\", \"value\")).isTrue();\n assertThat(headers.containsInt(\"name\", 100)).isTrue();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public OldIES()\n {\n super(new OldIESEngine(new DHBasicAgreement(),\n new KDF2BytesGenerator(new SHA1Digest()),\n new HMac(new SHA1Digest())));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testMultiply2()\n {\n int COUNT = 100;\n ECFieldElement[] inputs = new ECFieldElement[COUNT];\n BigInteger[] INPUTS = new BigInteger[COUNT];\n\n for (int i = 0; i < inputs.length; ++i)\n {\n inputs[i] = generateMultiplyInput_Random();\n INPUTS[i] = inputs[i].toBigInteger();\n }\n\n for (int j = 0; j < inputs.length; ++j)\n {\n for (int k = 0; k < inputs.length; ++k)\n {\n BigInteger R = INPUTS[j].multiply(INPUTS[k]).mod(Q);\n\n ECFieldElement z = inputs[j].multiply(inputs[k]);\n BigInteger Z = z.toBigInteger();\n\n assertEquals(R, Z);\n }\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "safe"} {"code": " public static final void testClosedArray() {\n // Discovered by fuzzer with seed -Dfuzz.seed=df3b4778ce54d00a\n assertSanitized(\"-1742461140214282\", \"\\ufeff-01742461140214282]\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " if (vimIDClass != null)\n {\n vimIDConstructor = findConstructor(vimIDClass);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testPrivateKeyParsingSHA256()\n throws IOException, ClassNotFoundException\n {\n XMSSMTParameters params = new XMSSMTParameters(20, 10, new SHA256Digest());\n XMSSMT mt = new XMSSMT(params, new SecureRandom());\n mt.generateKeys();\n byte[] privateKey = mt.exportPrivateKey();\n byte[] publicKey = mt.exportPublicKey();\n\n mt.importState(privateKey, publicKey);\n\n assertTrue(Arrays.areEqual(privateKey, mt.exportPrivateKey()));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-470", "cwe_name": "Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')", "description": "The application uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.", "url": "https://cwe.mitre.org/data/definitions/470.html", "label_name": "vulnerable"} {"code": "\tprivate static ECPrivateKey generateECPrivateKey(final ECKey.Curve curve)\n\t\tthrows Exception {\n\t\t\n\t\tfinal ECParameterSpec ecParameterSpec = curve.toECParameterSpec();\n\t\t\n\t\tKeyPairGenerator generator = KeyPairGenerator.getInstance(\"EC\");\n\t\tgenerator.initialize(ecParameterSpec);\n\t\tKeyPair keyPair = generator.generateKeyPair();\n\t\t\n\t\treturn (ECPrivateKey) keyPair.getPrivate();\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " default boolean isKeepAlive() {\n return getFirst(CONNECTION, String.class).map(val -> val.equalsIgnoreCase(\"keep-alive\")).orElse(false);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public void addShouldIncreaseAndRemoveShouldDecreaseTheSize() {\n final HttpHeadersBase headers = newEmptyHeaders();\n assertThat(headers.size()).isEqualTo(0);\n headers.add(\"name1\", \"value1\", \"value2\");\n assertThat(headers.size()).isEqualTo(2);\n headers.add(\"name2\", \"value3\", \"value4\");\n assertThat(headers.size()).isEqualTo(4);\n headers.add(\"name3\", \"value5\");\n assertThat(headers.size()).isEqualTo(5);\n\n headers.remove(\"name3\");\n assertThat(headers.size()).isEqualTo(4);\n headers.remove(\"name1\");\n assertThat(headers.size()).isEqualTo(2);\n headers.remove(\"name2\");\n assertThat(headers.size()).isEqualTo(0);\n assertThat(headers.isEmpty()).isTrue();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tpublic void testMatchOperation() {\n\n\t\tJWKMatcher matcher = new JWKMatcher.Builder().keyOperation(KeyOperation.DECRYPT).build();\n\n\t\tassertTrue(matcher.matches(new RSAKey.Builder(new Base64URL(\"n\"), new Base64URL(\"e\")).keyID(\"1\")\n\t\t\t.keyOperations(new HashSet<>(Collections.singletonList(KeyOperation.DECRYPT))).build()));\n\t\tassertFalse(matcher.matches(new ECKey.Builder(ECKey.Curve.P_256, EC_P256_X, EC_P256_Y).keyID(\"2\").build()));\n\t\t\n\t\tassertEquals(\"key_ops=decrypt\", matcher.toString());\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " public UIComponent createComponent(FacesContext context, String componentType, String rendererType) {\n \n notNull(CONTEXT, context);\n notNull(COMPONENT_TYPE, componentType);\n \n return createComponentApplyAnnotations(context, componentType, rendererType, true);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " void canMixConvertedAndNormalValues() {\n final HttpHeadersBase headers = newEmptyHeaders();\n headers.add(\"name\", \"value\");\n headers.addInt(\"name\", 100);\n\n assertThat(headers.size()).isEqualTo(2);\n assertThat(headers.contains(\"name\")).isTrue();\n assertThat(headers.contains(\"name\", \"value\")).isTrue();\n assertThat(headers.containsInt(\"name\", 100)).isTrue();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public ApiTokenProperty newInstance(User user) {\n return new ApiTokenProperty(Util.getDigestOf(Jenkins.getInstance().getSecretKey() + \":\" + user.getId()));\n }", "label": 0, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " private String escapeString(final String string)\n {\n if (string == null || string.length() == 0) {\n return \"\\\"\\\"\";\n }\n char c = 0;\n int i;\n final int len = string.length();\n final StringBuilder sb = new StringBuilder(len + 4);\n String t;\n sb.append('\"');\n for (i = 0; i < len; i += 1) {\n c = string.charAt(i);\n switch (c) {\n case '\\\\':\n case '\"':\n sb.append('\\\\');\n sb.append(c);\n break;\n case '/':\n // if (b == '<') {\n sb.append('\\\\');\n // }\n sb.append(c);\n break;\n case '\\b':\n sb.append(\"\\\\b\");\n break;\n case '\\t':\n sb.append(\"\\\\t\");\n break;\n case '\\n':\n sb.append(\"\\\\n\");\n break;\n case '\\f':\n sb.append(\"\\\\f\");\n break;\n case '\\r':\n sb.append(\"\\\\r\");\n break;\n default:\n if (c < ' ') {\n t = \"000\" + Integer.toHexString(c);\n sb.append(\"\\\\u\" + t.substring(t.length() - 4));\n } else {\n if (escapeHtml == true) {\n switch (c) {\n case '<':\n sb.append(\"<\");\n break;\n case '>':\n sb.append(\">\");\n break;\n case '&':\n sb.append(\"&\");\n break;\n case '\"':\n sb.append(\""\");\n break;\n case '\\'':\n sb.append(\"'\");\n break;\n case '/':\n sb.append(\"/\");\n break;\n default:\n sb.append(c);\n }\n } else {\n sb.append(c);\n }\n }\n }\n }\n sb.append('\"');\n return sb.toString();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public void translate(ServerAdvancementsPacket packet, GeyserSession session) {\n AdvancementsCache advancementsCache = session.getAdvancementsCache();\n if (packet.isReset()) {\n advancementsCache.getStoredAdvancements().clear();\n advancementsCache.getStoredAdvancementProgress().clear();\n }\n\n // Removes removed advancements from player's stored advancements\n for (String removedAdvancement : packet.getRemovedAdvancements()) {\n advancementsCache.getStoredAdvancements().remove(removedAdvancement);\n }\n\n advancementsCache.getStoredAdvancementProgress().putAll(packet.getProgress());\n\n sendToolbarAdvancementUpdates(session, packet);\n\n // Adds advancements to the player's stored advancements when advancements are sent\n for (Advancement advancement : packet.getAdvancements()) {\n if (advancement.getDisplayData() != null && !advancement.getDisplayData().isHidden()) {\n GeyserAdvancement geyserAdvancement = GeyserAdvancement.from(advancement);\n advancementsCache.getStoredAdvancements().put(advancement.getId(), geyserAdvancement);\n } else {\n advancementsCache.getStoredAdvancements().remove(advancement.getId());\n }\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public void removingANameForASecondTimeShouldReturnFalse() {\n final HttpHeadersBase headers = newEmptyHeaders();\n headers.add(\"name1\", \"value1\");\n headers.add(\"name2\", \"value2\");\n assertThat(headers.remove(\"name2\")).isTrue();\n assertThat(headers.remove(\"name2\")).isFalse();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public Response authenticate(Document soapMessage) {\n try {\n return new PostBindingProtocol() {\n @Override\n protected String getBindingType(AuthnRequestType requestAbstractType) {\n return SamlProtocol.SAML_SOAP_BINDING;\n }\n\n @Override\n protected boolean isDestinationRequired() {\n return false;\n }\n\n @Override\n protected Response loginRequest(String relayState, AuthnRequestType requestAbstractType, ClientModel client) {\n // Do not allow ECP login when client does not support it\n if (!new SamlClient(client).allowECPFlow()) {\n logger.errorf(\"Client %s is not allowed to execute ECP flow\", client.getClientId());\n throw new RuntimeException(\"Client is not allowed to use ECP profile.\");\n }\n\n // force passive authentication when executing this profile\n requestAbstractType.setIsPassive(true);\n requestAbstractType.setDestination(session.getContext().getUri().getAbsolutePath());\n return super.loginRequest(relayState, requestAbstractType, client);\n }\n }.execute(Soap.toSamlHttpPostMessage(soapMessage), null, null, null);\n } catch (Exception e) {\n String reason = \"Some error occurred while processing the AuthnRequest.\";\n String detail = e.getMessage();\n\n if (detail == null) {\n detail = reason;\n }\n\n return Soap.createFault().reason(reason).detail(detail).build();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": " public IESCipher(OldIESEngine engine)\n {\n this.engine = engine;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testRenameTo() throws Exception {\n TestHttpData test = new TestHttpData(\"test\", UTF_8, 0);\n try {\n File tmpFile = PlatformDependent.createTempFile(UUID.randomUUID().toString(), \".tmp\", null);\n tmpFile.deleteOnExit();\n final int totalByteCount = 4096;\n byte[] bytes = new byte[totalByteCount];\n PlatformDependent.threadLocalRandom().nextBytes(bytes);\n ByteBuf content = Unpooled.wrappedBuffer(bytes);\n test.setContent(content);\n boolean succ = test.renameTo(tmpFile);\n assertTrue(succ);\n FileInputStream fis = new FileInputStream(tmpFile);\n try {\n byte[] buf = new byte[totalByteCount];\n int count = 0;\n int offset = 0;\n int size = totalByteCount;\n while ((count = fis.read(buf, offset, size)) > 0) {\n offset += count;\n size -= count;\n if (offset >= totalByteCount || size <= 0) {\n break;\n }\n }\n assertArrayEquals(bytes, buf);\n assertEquals(0, fis.available());\n } finally {\n fis.close();\n }\n } finally {\n //release the ByteBuf in AbstractMemoryHttpData\n test.delete();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-379", "cwe_name": "Creation of Temporary File in Directory with Insecure Permissions", "description": "The software creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file.", "url": "https://cwe.mitre.org/data/definitions/379.html", "label_name": "safe"} {"code": " public void testToString() {\n HttpHeadersBase headers = newEmptyHeaders();\n headers.add(\"name1\", \"value1\");\n headers.add(\"name1\", \"value2\");\n headers.add(\"name2\", \"value3\");\n assertThat(headers.toString()).isEqualTo(\"[name1=value1, name1=value2, name2=value3]\");\n\n headers = newEmptyHeaders();\n headers.add(\"name1\", \"value1\");\n headers.add(\"name2\", \"value2\");\n headers.add(\"name3\", \"value3\");\n assertThat(headers.toString()).isEqualTo(\"[name1=value1, name2=value2, name3=value3]\");\n\n headers = newEmptyHeaders();\n headers.add(\"name1\", \"value1\");\n assertThat(headers.toString()).isEqualTo(\"[name1=value1]\");\n\n headers = newEmptyHeaders();\n headers.endOfStream(true);\n headers.add(\"name1\", \"value1\");\n assertThat(headers.toString()).isEqualTo(\"[EOS, name1=value1]\");\n\n headers = newEmptyHeaders();\n assertThat(headers.toString()).isEqualTo(\"[]\");\n\n headers = newEmptyHeaders();\n headers.endOfStream(true);\n assertThat(headers.toString()).isEqualTo(\"[EOS]\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void testExternalParameterEntityNoExpand() throws Exception\r\n {\r\n ClientRequest request = new ClientRequest(\"http://localhost:8080/RESTEASY-1073-no-expand/test\");\r\n System.out.println(text);\r\n request.body(MediaType.APPLICATION_XML, text);\r\n ClientResponse response = request.post();\r\n Assert.assertEquals(200, response.getStatus());\r\n String entity = response.getEntity(String.class);\r\n System.out.println(\"Result: \" + entity);\r\n Assert.assertEquals(\"\", entity.trim());\r\n }\r", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " public TaskTreeForm(final TaskTreePage parentPage)\n {\n super(parentPage);\n csrfTokenHandler = new CsrfTokenHandler(this);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public void setSetContentFromFileExceptionally() throws Exception {\n final long maxSize = 4;\n DiskFileUpload f1 = new DiskFileUpload(\"file5\", \"file5\", \"application/json\", null, null, 0);\n f1.setMaxSize(maxSize);\n try {\n f1.setContent(Unpooled.wrappedBuffer(new byte[(int) maxSize]));\n File originalFile = f1.getFile();\n assertNotNull(originalFile);\n assertEquals(maxSize, originalFile.length());\n assertEquals(maxSize, f1.length());\n byte[] bytes = new byte[8];\n PlatformDependent.threadLocalRandom().nextBytes(bytes);\n File tmpFile = File.createTempFile(UUID.randomUUID().toString(), \".tmp\");\n tmpFile.deleteOnExit();\n FileOutputStream fos = new FileOutputStream(tmpFile);\n try {\n fos.write(bytes);\n fos.flush();\n } finally {\n fos.close();\n }\n try {\n f1.setContent(tmpFile);\n fail(\"should not reach here!\");\n } catch (IOException e) {\n assertNotNull(f1.getFile());\n assertEquals(originalFile, f1.getFile());\n assertEquals(maxSize, f1.length());\n }\n } finally {\n f1.delete();\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-378", "cwe_name": "Creation of Temporary File With Insecure Permissions", "description": "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.", "url": "https://cwe.mitre.org/data/definitions/378.html", "label_name": "vulnerable"} {"code": " protected PublicKey engineGeneratePublic(\n KeySpec keySpec)\n throws InvalidKeySpecException\n {\n if (keySpec instanceof DHPublicKeySpec)\n {\n return new BCDHPublicKey((DHPublicKeySpec)keySpec);\n }\n\n return super.engineGeneratePublic(keySpec);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public static File createTempFile(String prefix, String suffix, File directory) throws IOException {\n if (javaVersion() >= 7) {\n if (directory == null) {\n return Files.createTempFile(prefix, suffix).toFile();\n }\n return Files.createTempFile(directory.toPath(), prefix, suffix).toFile();\n }\n final File file;\n if (directory == null) {\n file = File.createTempFile(prefix, suffix);\n } else {\n file = File.createTempFile(prefix, suffix, directory);\n }\n\n // Try to adjust the perms, if this fails there is not much else we can do...\n if (!file.setReadable(false, false)) {\n throw new IOException(\"Failed to set permissions on temporary file \" + file);\n }\n if (!file.setReadable(true, true)) {\n throw new IOException(\"Failed to set permissions on temporary file \" + file);\n }\n return file;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-668", "cwe_name": "Exposure of Resource to Wrong Sphere", "description": "The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.", "url": "https://cwe.mitre.org/data/definitions/668.html", "label_name": "safe"} {"code": " public void translate(ServerEntityHeadLookPacket packet, GeyserSession session) {\n Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());\n if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {\n entity = session.getPlayerEntity();\n }\n\n if (entity == null) return;\n\n entity.updateHeadLookRotation(session, packet.getHeadYaw());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": "\tpublic int decryptWithAd(byte[] ad, byte[] ciphertext,\n\t\t\tint ciphertextOffset, byte[] plaintext, int plaintextOffset,\n\t\t\tint length) throws ShortBufferException, BadPaddingException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (length > space)\n\t\t\tthrow new ShortBufferException();\n\t\tif (plaintextOffset > plaintext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = plaintext.length - plaintextOffset;\n\t\tif (!haskey) {\n\t\t\t// The key is not set yet - return the ciphertext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (length < 16)\n\t\t\tNoise.throwBadTagException();\n\t\tint dataLen = length - 16;\n\t\tif (dataLen > space)\n\t\t\tthrow new ShortBufferException();\n\t\tsetup(ad);\n\t\tghash.update(ciphertext, ciphertextOffset, dataLen);\n\t\tghash.pad(ad != null ? ad.length : 0, dataLen);\n\t\tghash.finish(enciv, 0, 16);\n\t\tint temp = 0;\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\ttemp |= (hashKey[index] ^ enciv[index] ^ ciphertext[ciphertextOffset + dataLen + index]);\n\t\tif ((temp & 0xFF) != 0)\n\t\t\tNoise.throwBadTagException();\n\t\tencryptCTR(ciphertext, ciphertextOffset, plaintext, plaintextOffset, dataLen);\n\t\treturn dataLen;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "\tpublic void privateMsgInMuc(Conversation conversation, String nick) {\n\t\tswitchToConversation(conversation, null, false, nick, true);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " private boolean exractAndLoad(ArrayList errors, String version, String customPath, String resourcePath) {\n URL resource = classLoader.getResource(resourcePath);\n if( resource !=null ) {\n\n String libName = name + \"-\" + getBitModel();\n if( version !=null) {\n libName += \"-\" + version;\n }\n String []libNameParts = map(libName).split(\"\\\\.\");\n String prefix = libNameParts[0]+\"-\";\n String suffix = \".\"+libNameParts[1];\n\n if( customPath!=null ) {\n // Try to extract it to the custom path...\n File target = extract(errors, resource, prefix, suffix, file(customPath));\n if( target!=null ) {\n if( load(errors, target) ) {\n return true;\n }\n }\n }\n \n // Fall back to extracting to the tmp dir\n customPath = System.getProperty(\"java.io.tmpdir\");\n File target = extract(errors, resource, prefix, suffix, file(customPath));\n if( target!=null ) {\n if( load(errors, target) ) {\n return true;\n }\n }\n }\n return false;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " public void headersWithDifferentNamesAndValuesShouldNotBeEquivalent() {\n final HttpHeadersBase h1 = newEmptyHeaders();\n h1.set(\"name1\", \"value1\");\n final HttpHeadersBase h2 = newEmptyHeaders();\n h2.set(\"name2\", \"value2\");\n assertThat(h1).isNotEqualTo(h2);\n assertThat(h2).isNotEqualTo(h1);\n assertThat(h1).isEqualTo(h1);\n assertThat(h2).isEqualTo(h2);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void testHeaderNameStartsWithControlChar1f() {\n testHeaderNameStartsWithControlChar(0x1f);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " public void setExpirationTime(int expirationTime) {\r\n this.expirationTime = expirationTime;\r\n }\r", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "\tprivate boolean updateProfilePictureAndName(Profile authUser, User u) {\n\t\tboolean update = false;\n\t\tif (!StringUtils.equals(u.getPicture(), authUser.getPicture())\n\t\t\t\t&& !gravatarAvatarGenerator.isLink(authUser.getPicture())\n\t\t\t\t&& !CONF.avatarEditsEnabled()) {\n\t\t\tauthUser.setPicture(u.getPicture());\n\t\t\tupdate = true;\n\t\t}\n\t\tif (!CONF.nameEditsEnabled() &&\t!StringUtils.equals(u.getName(), authUser.getName())) {\n\t\t\tauthUser.setName(u.getName());\n\t\t\tupdate = true;\n\t\t}\n\t\tif (!StringUtils.equals(u.getName(), authUser.getOriginalName())) {\n\t\t\tauthUser.setOriginalName(u.getName());\n\t\t\tupdate = true;\n\t\t}\n\t\treturn update;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "\tList cleanForKeySlow(String key) {\n\t\tkey = StringUtils.trin(StringUtils.goLowerCase(key));\n\t\tkey = key.replaceAll(\"_|\\\\.|\\\\s\", \"\");\n\t\t// key = replaceSmart(key, \"partition\", \"package\");\n\t\tkey = replaceSmart(key, \"sequenceparticipant\", \"participant\");\n\t\tkey = replaceSmart(key, \"sequenceactor\", \"actor\");\n\t\tkey = key.replaceAll(\"activityarrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"objectarrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"classarrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"componentarrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"statearrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"usecasearrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"sequencearrow\", \"arrow\");\n\t\tkey = key.replaceAll(\"align$\", \"alignment\");\n\t\tfinal Matcher2 mm = stereoPattern.matcher(key);\n\t\tfinal List result = new ArrayList<>();\n\t\twhile (mm.find()) {\n\t\t\tfinal String s = mm.group(1);\n\t\t\tresult.add(key.replaceAll(stereoPatternString, \"\") + \"<<\" + s + \">>\");\n\t\t}\n\t\tif (result.size() == 0)\n\t\t\tresult.add(key);\n\n\t\treturn Collections.unmodifiableList(result);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " public String invokeServletAndReturnAsString(String url, XWikiContext xwikiContext)\n {\n\n HttpServletRequest servletRequest = xwikiContext.getRequest();\n HttpServletResponse servletResponse = xwikiContext.getResponse();\n\n try {\n return IncludeServletAsString.invokeServletAndReturnAsString(url, servletRequest, servletResponse);\n } catch (Exception e) {\n LOGGER.warn(\"Exception including url: \" + url, e);\n return \"Exception including \\\"\" + url + \"\\\", see logs for details.\";\n }\n\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": " public String getStringParameterSQL(String param) {\n // DASHBUILDE-113: SQL Injection on data set lookup filters\n String escapedParam = param.replaceAll(\"'\", \"''\");\n return \"'\" + escapedParam + \"'\";\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public void spliceToFile() throws Throwable {\n EventLoopGroup group = new EpollEventLoopGroup(1);\n File file = PlatformDependent.createTempFile(\"netty-splice\", null, null);\n file.deleteOnExit();\n\n SpliceHandler sh = new SpliceHandler(file);\n ServerBootstrap bs = new ServerBootstrap();\n bs.channel(EpollServerSocketChannel.class);\n bs.group(group).childHandler(sh);\n bs.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);\n Channel sc = bs.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel();\n\n Bootstrap cb = new Bootstrap();\n cb.group(group);\n cb.channel(EpollSocketChannel.class);\n cb.handler(new ChannelInboundHandlerAdapter());\n Channel cc = cb.connect(sc.localAddress()).syncUninterruptibly().channel();\n\n for (int i = 0; i < data.length;) {\n int length = Math.min(random.nextInt(1024 * 64), data.length - i);\n ByteBuf buf = Unpooled.wrappedBuffer(data, i, length);\n cc.writeAndFlush(buf);\n i += length;\n }\n\n while (sh.future2 == null || !sh.future2.isDone() || !sh.future.isDone()) {\n if (sh.exception.get() != null) {\n break;\n }\n try {\n Thread.sleep(50);\n } catch (InterruptedException e) {\n // Ignore.\n }\n }\n\n sc.close().sync();\n cc.close().sync();\n\n if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {\n throw sh.exception.get();\n }\n\n byte[] written = new byte[data.length];\n FileInputStream in = new FileInputStream(file);\n\n try {\n Assert.assertEquals(written.length, in.read(written));\n Assert.assertArrayEquals(data, written);\n } finally {\n in.close();\n group.shutdownGracefully();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-378", "cwe_name": "Creation of Temporary File With Insecure Permissions", "description": "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.", "url": "https://cwe.mitre.org/data/definitions/378.html", "label_name": "safe"} {"code": "\tpublic void createsUnsafeSortCorrectly() {\n\n\t\tJpaSort sort = JpaSort.unsafe(DESC, \"foo.bar\");\n\n\t\tassertThat(sort, hasItem(new Order(DESC, \"foo.bar\")));\n\t\tassertThat(sort.getOrderFor(\"foo.bar\"), is(instanceOf(JpaOrder.class)));\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public String getApiToken() {\n String p = apiToken.getPlainText();\n if (p.equals(Util.getDigestOf(Jenkins.getInstance().getSecretKey()+\":\"+user.getId()))) {\n // if the current token is the initial value created by pre SECURITY-49 Jenkins, we can't use that.\n // force using the newer value\n apiToken = Secret.fromString(p=API_KEY_SEED.mac(user.getId()));\n }\n return Util.getDigestOf(p);\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " protected ConfidentialKey(String id) {\n this.id = id;\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public void testInvalidCallbackGetNonStreaming() throws IOException, URISyntaxException, ParseException {\n checkInvalidCallback(false);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tstatic int sharedKeyLength(final JWEAlgorithm alg, final EncryptionMethod enc)\n\t\tthrows JOSEException {\n\n\t\tif (alg.equals(JWEAlgorithm.ECDH_ES)) {\n\n\t\t\tint length = enc.cekBitLength();\n\n\t\t\tif (length == 0) {\n\t\t\t\tthrow new JOSEException(\"Unsupported JWE encryption method \" + enc);\n\t\t\t}\n\n\t\t\treturn length;\n\n\t\t} else if (alg.equals(JWEAlgorithm.ECDH_ES_A128KW)) {\n\t\t\treturn 128;\n\t\t} else if (alg.equals(JWEAlgorithm.ECDH_ES_A192KW)) {\n\t\t\treturn 192;\n\t\t} else if (alg.equals(JWEAlgorithm.ECDH_ES_A256KW)) {\n\t\t\treturn 256;\n\t\t} else {\n\t\t\tthrow new JOSEException(AlgorithmSupportMessage.unsupportedJWEAlgorithm(\n\t\t\t\talg, ECDHCryptoProvider.SUPPORTED_ALGORITHMS));\n\t\t}\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " private Certificate toCertificate(KeyDescriptorType keyDescriptorType) {\n try {\n List keyData = keyDescriptorType.getKeyInfo().getContent();\n for (Object keyDatum : keyData) {\n if (keyDatum instanceof JAXBElement) {\n JAXBElement element = (JAXBElement) keyDatum;\n if (element.getDeclaredType() == X509DataType.class) {\n X509DataType cert = (X509DataType) element.getValue();\n List certData = cert.getX509IssuerSerialOrX509SKIOrX509SubjectName();\n for (Object certDatum : certData) {\n element = (JAXBElement) certDatum;\n if (element.getName().getLocalPart().equals(\"X509Certificate\")) {\n byte[] certBytes = (byte[]) element.getValue();\n CertificateFactory cf = CertificateFactory.getInstance(\"X.509\");\n return cf.generateCertificate(new ByteArrayInputStream(certBytes));\n }\n }\n }\n }\n }\n\n return null;\n } catch (CertificateException e) {\n throw new IllegalArgumentException(e);\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " public AjaxResult updateAvatar(@RequestParam(\"avatarfile\") MultipartFile file)\r\n {\r\n SysUser currentUser = getSysUser();\r\n try\r\n {\r\n if (!file.isEmpty())\r\n {\r\n String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);\r\n currentUser.setAvatar(avatar);\r\n if (userService.updateUserInfo(currentUser) > 0)\r\n {\r\n setSysUser(userService.selectUserById(currentUser.getUserId()));\r\n return success();\r\n }\r\n }\r\n return error();\r\n }\r\n catch (Exception e)\r\n {\r\n log.error(\"\u4fee\u6539\u5934\u50cf\u5931\u8d25\uff01\", e);\r\n return error(e.getMessage());\r\n }\r\n }\r", "label": 0, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "\tprivate void switchToConversation(Conversation conversation, String text, boolean asQuote, String nick, boolean pm) {\n\t\tIntent intent = new Intent(this, ConversationsActivity.class);\n\t\tintent.setAction(ConversationsActivity.ACTION_VIEW_CONVERSATION);\n\t\tintent.putExtra(ConversationsActivity.EXTRA_CONVERSATION, conversation.getUuid());\n\t\tif (text != null) {\n\t\t\tintent.putExtra(Intent.EXTRA_TEXT, text);\n\t\t\tif (asQuote) {\n\t\t\t\tintent.putExtra(ConversationsActivity.EXTRA_AS_QUOTE, true);\n\t\t\t}\n\t\t}\n\t\tif (nick != null) {\n\t\t\tintent.putExtra(ConversationsActivity.EXTRA_NICK, nick);\n\t\t\tintent.putExtra(ConversationsActivity.EXTRA_IS_PRIVATE_MESSAGE, pm);\n\t\t}\n\t\tintent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP);\n\t\tstartActivity(intent);\n\t\tfinish();\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "\tpublic XssHttpServletRequestWrapper(HttpServletRequest request) {\n\t\tsuper(request);\t\n\t\t\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "\tpublic void testSelectByUse() {\n\n\t\tJWKSelector selector = new JWKSelector(new JWKMatcher.Builder().keyUse(KeyUse.ENCRYPTION).build());\n\n\t\tList keyList = new ArrayList<>();\n\t\tkeyList.add(new RSAKey.Builder(new Base64URL(\"n\"), new Base64URL(\"e\")).keyID(\"1\").keyUse(KeyUse.ENCRYPTION).build());\n\t\tkeyList.add(new ECKey.Builder(ECKey.Curve.P_256, EC_P256_X, EC_P256_Y).keyID(\"2\").build());\n\n\t\tJWKSet jwkSet = new JWKSet(keyList);\n\n\t\tList matches = selector.select(jwkSet);\n\n\t\tRSAKey key1 = (RSAKey)matches.get(0);\n\t\tassertEquals(KeyType.RSA, key1.getKeyType());\n\t\tassertEquals(KeyUse.ENCRYPTION, key1.getKeyUse());\n\t\tassertEquals(\"1\", key1.getKeyID());\n\n\t\tassertEquals(1, matches.size());\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " public void testSetRequestMethod() {\n HttpURLConnection conn = createHttpUrlConnection(convertToUrl(TEST_URL), \"\", 0, \"\", \"\");\n Utils.setRequestMethod(conn, Utils.RequestMethod.POST);\n Assert.assertEquals(conn.getRequestMethod(), \"POST\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-306", "cwe_name": "Missing Authentication for Critical Function", "description": "The software does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.", "url": "https://cwe.mitre.org/data/definitions/306.html", "label_name": "vulnerable"} {"code": " public SAXParser newSAXParser() {\n final SAXParser ret;\n try {\n ret = new XercesJAXPSAXParser(this, features, validating, handleXInclude);\n } catch (final SAXException se) {\n // Translate to ParserConfigurationException\n throw new OXFException(se); // so we see a decent stack trace!\n }\n return ret;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public String getLegacyInstanceId() {\n return Util.getDigestOf(getSecretKey());\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public Document read(Reader reader, String systemId)\n throws DocumentException {\n InputSource source = new InputSource(reader);\n source.setSystemId(systemId);\n if (this.encoding != null) {\n source.setEncoding(this.encoding);\n }\n\n return read(source);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " protected void doPost( HttpServletRequest request,\n HttpServletResponse response ) throws ServletException, IOException {\n\n try {\n if ( request.getParameter( \"path\" ) != null ) {\n\n final URI uri = new URI( request.getParameter( \"path\" ) );\n\n if ( !validateAccess( uri, response ) ) {\n return;\n }\n\n writeFile( ioService.get( uri ), getFileItem( request ) );\n\n writeResponse( response, \"OK\" );\n } else if ( request.getParameter( \"folder\" ) != null ) {\n\n final URI uri = new URI( request.getParameter( \"folder\" ) + \"/\" + request.getParameter( \"fileName\" ) );\n\n if ( !validateAccess( uri, response ) ) {\n return;\n }\n\n writeFile(\n ioService.get( uri ),\n getFileItem( request ) );\n\n writeResponse( response, \"OK\" );\n }\n\n } catch ( FileUploadException e ) {\n logError( e );\n writeResponse( response, \"FAIL\" );\n } catch ( URISyntaxException e ) {\n logError( e );\n writeResponse( response, \"FAIL\" );\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public void setDefaultHandler(ElementHandler handler) {\n getDispatchHandler().setDefaultHandler(handler);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " public void derIntegerTest()\n throws Exception\n {\n try\n {\n new ASN1Integer(new byte[] { 0, 0, 0, 1});\n }\n catch (IllegalArgumentException e)\n {\n isTrue(\"wrong exc\", \"malformed integer\".equals(e.getMessage()));\n }\n\n try\n {\n new ASN1Integer(new byte[] {(byte)0xff, (byte)0x80, 0, 1});\n }\n catch (IllegalArgumentException e)\n {\n isTrue(\"wrong exc\", \"malformed integer\".equals(e.getMessage()));\n }\n\n try\n {\n new ASN1Enumerated(new byte[] { 0, 0, 0, 1});\n }\n catch (IllegalArgumentException e)\n {\n isTrue(\"wrong exc\", \"malformed enumerated\".equals(e.getMessage()));\n }\n\n try\n {\n new ASN1Enumerated(new byte[] {(byte)0xff, (byte)0x80, 0, 1});\n }\n catch (IllegalArgumentException e)\n {\n isTrue(\"wrong exc\", \"malformed enumerated\".equals(e.getMessage()));\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " void rawUnicode() {\n // 2- and 3-byte UTF-8\n final PathAndQuery res1 = parse(\"/\\u00A2?\\u20AC\"); // \u00a2 and \u20ac\n assertThat(res1).isNotNull();\n assertThat(res1.path()).isEqualTo(\"/%C2%A2\");\n assertThat(res1.query()).isEqualTo(\"%E2%82%AC\");\n\n // 4-byte UTF-8\n final PathAndQuery res2 = parse(\"/\\uD800\\uDF48\"); // \ud800\udf48\n assertThat(res2).isNotNull();\n assertThat(res2.path()).isEqualTo(\"/%F0%90%8D%88\");\n assertThat(res2.query()).isNull();\n\n // 5- and 6-byte forms are only theoretically possible, so we won't test them here.\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " private

    void translate0(GeyserSession session, PacketTranslator

    translator, P packet) {\n if (session.isClosed()) {\n return;\n }\n\n try {\n translator.translate(packet, session);\n } catch (Throwable ex) {\n GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog(\"geyser.network.translator.packet.failed\", packet.getClass().getSimpleName()), ex);\n ex.printStackTrace();\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public void translate(ServerEntityEffectPacket packet, GeyserSession session) {\n Entity entity;\n if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {\n entity = session.getPlayerEntity();\n session.getEffectCache().setEffect(packet.getEffect(), packet.getAmplifier());\n } else {\n entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());\n }\n if (entity == null)\n return;\n\n MobEffectPacket mobEffectPacket = new MobEffectPacket();\n mobEffectPacket.setAmplifier(packet.getAmplifier());\n mobEffectPacket.setDuration(packet.getDuration());\n mobEffectPacket.setEvent(MobEffectPacket.Event.ADD);\n mobEffectPacket.setRuntimeEntityId(entity.getGeyserId());\n mobEffectPacket.setParticles(packet.isShowParticles());\n mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect()));\n session.sendUpstreamPacket(mobEffectPacket);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public Operation.OperationResult executeFixedCostOperation(\n final MessageFrame frame, final EVM evm) {\n\n Bytes shiftAmount = frame.popStackItem();\n final Bytes value = leftPad(frame.popStackItem());\n final boolean negativeNumber = value.get(0) < 0;\n if (shiftAmount.size() > 4 && (shiftAmount = shiftAmount.trimLeadingZeros()).size() > 4) {\n frame.pushStackItem(negativeNumber ? ALL_BITS : UInt256.ZERO);\n } else {\n final int shiftAmountInt = shiftAmount.toInt();\n\n if (shiftAmountInt >= 256) {\n frame.pushStackItem(negativeNumber ? ALL_BITS : UInt256.ZERO);\n } else {\n // first perform standard shift right.\n Bytes result = value.shiftRight(shiftAmountInt);\n\n // if a negative number, carry through the sign.\n if (negativeNumber) {\n final Bytes32 significantBits = ALL_BITS.shiftLeft(256 - shiftAmountInt);\n result = result.or(significantBits);\n }\n frame.pushStackItem(result);\n }\n }\n return successResponse;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-681", "cwe_name": "Incorrect Conversion between Numeric Types", "description": "When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.", "url": "https://cwe.mitre.org/data/definitions/681.html", "label_name": "vulnerable"} {"code": " public static Secret decrypt(String data) {\n if(data==null) return null;\n try {\n byte[] in = Base64.decode(data.toCharArray());\n Secret s = tryDecrypt(KEY.decrypt(), in);\n if (s!=null) return s;\n\n // try our historical key for backward compatibility\n Cipher cipher = getCipher(\"AES\");\n cipher.init(Cipher.DECRYPT_MODE, getLegacyKey());\n return tryDecrypt(cipher, in);\n } catch (GeneralSecurityException e) {\n return null;\n } catch (UnsupportedEncodingException e) {\n throw new Error(e); // impossible\n } catch (IOException e) {\n return null;\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public ParserStateObjectInputStream(InputStream inputStream) throws IOException {\n super(inputStream);\n\n whitelist = new HashSet<>();\n whitelist.add(RemoteDaemonicParserState.class.getName());\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " private String extractOriginOrReferer(HttpExchange pExchange) {\n Headers headers = pExchange.getRequestHeaders();\n String origin = headers.getFirst(\"Origin\");\n if (origin == null) {\n origin = headers.getFirst(\"Referer\");\n }\n return origin != null ? origin.replaceAll(\"[\\\\n\\\\r]*\",\"\") : null;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public Document read(Reader reader) throws DocumentException {\n InputSource source = new InputSource(reader);\n if (this.encoding != null) {\n source.setEncoding(this.encoding);\n }\n\n return read(source);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": "\tpublic void renderHead(IHeaderResponse response) {\n\t\tsuper.renderHead(response);\n\t\tresponse.render(JavaScriptHeaderItem.forReference(new MarkdownResourceReference()));\n\t\t\n\t\tString encodedAttachmentSupport;\n\t\tif (getAttachmentSupport() != null) {\n\t\t\tencodedAttachmentSupport = Base64.encodeBase64String(SerializationUtils.serialize(getAttachmentSupport()));\n\t\t\tencodedAttachmentSupport = StringUtils.deleteWhitespace(encodedAttachmentSupport);\n\t\t\tencodedAttachmentSupport = StringEscapeUtils.escapeEcmaScript(encodedAttachmentSupport);\n\t\t\tencodedAttachmentSupport = \"'\" + encodedAttachmentSupport + \"'\";\n\t\t} else {\n\t\t\tencodedAttachmentSupport = \"undefined\";\n\t\t}\n\t\t\n\t\tString callback = ajaxBehavior.getCallbackFunction(explicit(\"action\"), explicit(\"param1\"), explicit(\"param2\"), \n\t\t\t\texplicit(\"param3\")).toString();\n\t\t\n\t\tString autosaveKey = getAutosaveKey();\n\t\tif (autosaveKey != null)\n\t\t\tautosaveKey = \"'\" + JavaScriptEscape.escapeJavaScript(autosaveKey) + \"'\";\n\t\telse\n\t\t\tautosaveKey = \"undefined\";\n\t\t\n\t\tString script = String.format(\"onedev.server.markdown.onDomReady('%s', %s, %d, %s, %d, %b, %b, '%s', %s);\", \n\t\t\t\tcontainer.getMarkupId(), \n\t\t\t\tcallback, \n\t\t\t\tATWHO_LIMIT, \n\t\t\t\tencodedAttachmentSupport, \n\t\t\t\tgetAttachmentSupport()!=null?getAttachmentSupport().getAttachmentMaxSize():0,\n\t\t\t\tgetUserMentionSupport() != null,\n\t\t\t\tgetReferenceSupport() != null, \n\t\t\t\tJavaScriptEscape.escapeJavaScript(ProjectNameValidator.PATTERN.pattern()),\n\t\t\t\tautosaveKey);\n\t\tresponse.render(OnDomReadyHeaderItem.forScript(script));\n\t\t\n\t\tscript = String.format(\"onedev.server.markdown.onLoad('%s');\", container.getMarkupId());\n\t\tresponse.render(OnLoadHeaderItem.forScript(script));\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "vulnerable"} {"code": " public void add(File fileToAdd) {\n String[] args = new String[]{\"add\", fileToAdd.getName()};\n CommandLine gitAdd = gitWd().withArgs(args);\n runOrBomb(gitAdd);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " public static int getStatusCode(HttpURLConnection conn) {\n try {\n return conn.getResponseCode();\n } catch (IOException e) {\n throw ErrorUtil\n .createCommandException(\"connection to the remote repository host failed: \" + e.getMessage());\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-306", "cwe_name": "Missing Authentication for Critical Function", "description": "The software does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.", "url": "https://cwe.mitre.org/data/definitions/306.html", "label_name": "vulnerable"} {"code": " public void subsetOfHeadersShouldNotBeEquivalent() {\n final HttpHeadersBase headers1 = newEmptyHeaders();\n headers1.add(\"name1\", \"value1\");\n headers1.add(\"name2\", \"value2\");\n final HttpHeadersBase headers2 = newEmptyHeaders();\n headers1.add(\"name1\", \"value1\");\n assertThat(headers1).isNotEqualTo(headers2);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": "\tpublic static byte[] computeLength(final byte[] aad)\n\t\tthrows IntegerOverflowException {\n\n\t\tfinal int bitLength = ByteUtils.safeBitLength(aad);\n\t\treturn ByteBuffer.allocate(8).putLong(bitLength).array();\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": " private void testSmallSecret()\n throws Exception\n {\n BigInteger p = new BigInteger(\"ff3b512a4cc0961fa625d6cbd9642c377ece46b8dbc3146a98e0567f944034b5e3a1406edb179a77cd2539bdb74dc819f0a74d486606e26e578ff52c5242a5ff\", 16);\n BigInteger g = new BigInteger(\"58a66667431136e99d86de8199eb650a21afc9de3dd4ef9da6dfe89c866e928698952d95e68b418becef26f23211572eebfcbf328809bdaf02bba3d24c74f8c0\", 16);\n\n DHPrivateKeySpec aPrivSpec = new DHPrivateKeySpec(\n new BigInteger(\"30a6ea4e2240a42867ad98bd3adbfd5b81aba48bd930f20a595983d807566f7cba4e766951efef2c6c0c1be3823f63d66e12c2a091d5ff3bbeb1ea6e335d072d\", 16), p, g);\n DHPublicKeySpec aPubSpec = new DHPublicKeySpec(\n new BigInteger(\"694dfea1bfc8897e2fcbfd88033ab34f4581892d7d5cc362dc056e3d43955accda12222bd651ca31c85f008a05dea914de68828dfd83a54a340fa84f3bbe6caf\", 16), p, g);\n\n DHPrivateKeySpec bPrivSpec = new DHPrivateKeySpec(\n new BigInteger(\"775b1e7e162190700e2212dd8e4aaacf8a2af92c9c108b81d5bf9a14548f494eaa86a6c4844b9512eb3e3f2f22ffec44c795c813edfea13f075b99bbdebb34bd\", 16), p, g);\n\n DHPublicKeySpec bPubSpec = new DHPublicKeySpec(\n new BigInteger(\"d8ddd4ff9246635eadbfa0bc2ef06d98a329b6e8cd2d1435d7b4921467570e697c9a9d3c172c684626a9d2b6b2fa0fc725d5b91f9a9625b717a4169bc714b064\", 16), p, g);\n\n KeyFactory kFact = KeyFactory.getInstance(\"DH\", \"BC\");\n\n byte[] secret = testTwoParty(\"DH\", 512, 0, new KeyPair(kFact.generatePublic(aPubSpec), kFact.generatePrivate(aPrivSpec)), new KeyPair(kFact.generatePublic(bPubSpec), kFact.generatePrivate(bPrivSpec)));\n\n if (secret.length != ((p.bitLength() + 7) / 8))\n {\n fail(\"short secret wrong length\");\n }\n\n if (!Arrays.areEqual(Hex.decode(\"00340d3309ddc86e99e2f0be4fc212837bfb5c59336b09b9e1aeb1884b72c8b485b56723d0bf1c1d37fc89a292fc1cface9125106f1df15f55f22e4f77c5879b\"), secret))\n {\n fail(\"short secret mismatch\");\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": " private void testExplicitWrapping(\n int size,\n int privateValueSize,\n BigInteger g,\n BigInteger p)\n throws Exception\n {\n DHParameterSpec dhParams = new DHParameterSpec(p, g, privateValueSize);\n\n KeyPairGenerator keyGen = KeyPairGenerator.getInstance(\"DH\", \"BC\");\n\n keyGen.initialize(dhParams);\n\n //\n // a side\n //\n KeyPair aKeyPair = keyGen.generateKeyPair();\n\n KeyAgreement aKeyAgree = KeyAgreement.getInstance(\"DH\", \"BC\");\n\n checkKeySize(privateValueSize, aKeyPair);\n\n aKeyAgree.init(aKeyPair.getPrivate());\n\n //\n // b side\n //\n KeyPair bKeyPair = keyGen.generateKeyPair();\n\n KeyAgreement bKeyAgree = KeyAgreement.getInstance(\"DH\", \"BC\");\n\n checkKeySize(privateValueSize, bKeyPair);\n\n bKeyAgree.init(bKeyPair.getPrivate());\n\n //\n // agreement\n //\n aKeyAgree.doPhase(bKeyPair.getPublic(), true);\n bKeyAgree.doPhase(aKeyPair.getPublic(), true);\n\n SecretKey k1 = aKeyAgree.generateSecret(PKCSObjectIdentifiers.id_alg_CMS3DESwrap.getId());\n SecretKey k2 = bKeyAgree.generateSecret(PKCSObjectIdentifiers.id_alg_CMS3DESwrap.getId());\n\n // TODO Compare k1 and k2?\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "\tpublic void setOriginalName(String originalName) {\n\t\tthis.originalName = originalName;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " public void translate(ServerDeclareTagsPacket packet, GeyserSession session) {\n session.getTagCache().loadPacket(packet);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public OldECIESwithDESedeCBC()\n {\n super(new CBCBlockCipher(new DESedeEngine()), 8);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void setCharacterStream() throws Exception {\n String exmplar = \"value\";\n SQLXML pgSQLXML = con.createSQLXML();\n Writer writer = pgSQLXML.setCharacterStream();\n writer.write(exmplar);\n PreparedStatement preparedStatement = con.prepareStatement(\"insert into xmltab values (?)\");\n preparedStatement.setSQLXML(1,pgSQLXML);\n preparedStatement.execute();\n\n Statement statement = con.createStatement();\n ResultSet rs = statement.executeQuery(\"select * from xmltab\");\n assertTrue(rs.next());\n SQLXML result = rs.getSQLXML(1);\n assertNotNull(result);\n assertEquals(exmplar, result.getString());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " protected void ensureContainerHasEnough(int size, byte type) {\n int minimumExpected = size * typeMinimumSize(type);\n ensureHasEnoughBytes(minimumExpected);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": " private static void testInvalidHeaders0(ByteBuf responseBuffer) {\n EmbeddedChannel channel = new EmbeddedChannel(new HttpResponseDecoder());\n assertTrue(channel.writeInbound(responseBuffer));\n HttpResponse response = channel.readInbound();\n assertThat(response.decoderResult().cause(), instanceOf(IllegalArgumentException.class));\n assertTrue(response.decoderResult().isFailure());\n assertFalse(channel.finish());\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " public void testInvalidUserId(final String userId, final boolean mustFail) {\n adminPage();\n findElementByLink(\"Configure Users, Groups and On-Call Roles\").click();\n findElementByLink(\"Configure Users\").click();\n findElementByLink(\"Add new user\").click();\n\n enterText(By.id(\"userID\"), userId);\n enterText(By.id(\"pass1\"), \"SmokeTestPassword\");\n enterText(By.id(\"pass2\"), \"SmokeTestPassword\");\n findElementByXpath(\"//button[@type='submit' and text()='OK']\").click();\n\n if (mustFail) {\n try {\n final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent());\n alert.dismiss();\n } catch (final Exception e) {\n LOG.debug(\"Got an exception waiting for a 'invalid user ID' alert.\", e);\n throw e;\n }\n } else {\n wait.until(ExpectedConditions.elementToBeClickable(By.name(\"finish\")));\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public void testPrivateKeyParsingSHA256()\n throws Exception\n {\n XMSSMTParameters params = new XMSSMTParameters(20, 10, new SHA256Digest());\n XMSSMT mt = new XMSSMT(params, new SecureRandom());\n mt.generateKeys();\n byte[] privateKey = mt.exportPrivateKey();\n byte[] publicKey = mt.exportPublicKey();\n\n mt.importState(privateKey, publicKey);\n\n assertTrue(Arrays.areEqual(privateKey, mt.exportPrivateKey()));\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " private void testHeaderNameStartsWithControlChar(int controlChar) {\n ByteBuf responseBuffer = Unpooled.buffer();\n responseBuffer.writeCharSequence(\"HTTP/1.1 200 OK\\r\\n\" +\n \"Host: netty.io\\r\\n\", CharsetUtil.US_ASCII);\n responseBuffer.writeByte(controlChar);\n responseBuffer.writeCharSequence(\"Transfer-Encoding: chunked\\r\\n\\r\\n\", CharsetUtil.US_ASCII);\n testInvalidHeaders0(responseBuffer);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "\tpublic PlayerAnalog(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact) {\n\t\tsuper(code, skinParam, ruler, compact);\n\t\tthis.suggestedHeight = 100;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " public void testEntryEquals() {\n final HttpHeadersBase nameValue = newEmptyHeaders();\n nameValue.add(\"name\", \"value\");\n final HttpHeadersBase nameValueCopy = newEmptyHeaders();\n nameValueCopy.add(\"name\", \"value\");\n final Map.Entry same1 = nameValue.iterator().next();\n final Map.Entry same2 = nameValueCopy.iterator().next();\n assertThat(same2).isEqualTo(same1);\n assertThat(same2.hashCode()).isEqualTo(same1.hashCode());\n\n final HttpHeadersBase name1Value = newEmptyHeaders();\n name1Value.add(\"name1\", \"value\");\n final HttpHeadersBase name2Value = newEmptyHeaders();\n name2Value.add(\"name2\", \"value\");\n final Map.Entry nameDifferent1 = name1Value.iterator().next();\n final Map.Entry nameDifferent2 = name2Value.iterator().next();\n assertThat(nameDifferent1).isNotEqualTo(nameDifferent2);\n assertThat(nameDifferent1.hashCode()).isNotEqualTo(nameDifferent2.hashCode());\n\n final HttpHeadersBase nameValue1 = newEmptyHeaders();\n nameValue1.add(\"name\", \"value1\");\n final HttpHeadersBase nameValue2 = newEmptyHeaders();\n nameValue2.add(\"name\", \"value2\");\n final Map.Entry valueDifferent1 = nameValue1.iterator().next();\n final Map.Entry valueDifferent2 = nameValue2.iterator().next();\n assertThat(valueDifferent1).isNotEqualTo(valueDifferent2);\n assertThat(valueDifferent1.hashCode()).isNotEqualTo(valueDifferent2.hashCode());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void deleteById(Integer id) {\n databaseTypeDao.selectOptionalById(id).ifPresent(data -> {\n if (DatabaseTypes.has(data.getDatabaseType())) {\n throw DomainErrors.MUST_NOT_MODIFY_SYSTEM_DEFAULT_DATABASE_TYPE.exception();\n }\n databaseTypeDao.deleteById(id);\n driverResources.delete(data.getDatabaseType());\n });\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " public void testSetContentFromFile() throws Exception {\n TestHttpData test = new TestHttpData(\"test\", UTF_8, 0);\n try {\n File tmpFile = PlatformDependent.createTempFile(UUID.randomUUID().toString(), \".tmp\", null);\n tmpFile.deleteOnExit();\n FileOutputStream fos = new FileOutputStream(tmpFile);\n byte[] bytes = new byte[4096];\n PlatformDependent.threadLocalRandom().nextBytes(bytes);\n try {\n fos.write(bytes);\n fos.flush();\n } finally {\n fos.close();\n }\n test.setContent(tmpFile);\n ByteBuf buf = test.getByteBuf();\n assertEquals(buf.readerIndex(), 0);\n assertEquals(buf.writerIndex(), bytes.length);\n assertArrayEquals(bytes, test.get());\n assertArrayEquals(bytes, ByteBufUtil.getBytes(buf));\n } finally {\n //release the ByteBuf\n test.delete();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-378", "cwe_name": "Creation of Temporary File With Insecure Permissions", "description": "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.", "url": "https://cwe.mitre.org/data/definitions/378.html", "label_name": "safe"} {"code": "\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " public static Object deserialize(byte[] data, Class clazz)\n throws IOException, ClassNotFoundException\n {\n ByteArrayInputStream in = new ByteArrayInputStream(data);\n ObjectInputStream is = new ObjectInputStream(in);\n Object obj = is.readObject();\n\n if (is.available() != 0)\n {\n throw new IOException(\"unexpected data found at end of ObjectInputStream\");\n }\n if (clazz.isInstance(obj))\n {\n return obj;\n }\n else\n {\n throw new IOException(\"unexpected class found in ObjectInputStream\");\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " ContentLength(long expected) {\n this.expected = expected;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": " public OldECIESwithDESede()\n {\n super(new DESedeEngine());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " callback: (request: PublishRequest, response: PublishResponse) => void;", "label": 0, "programming_language": "Java", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " public boolean checkMac(String message, String mac) {\n return mac(message).equals(mac);\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public KeyPair generateKeyPair()\n {\n if (!initialised)\n {\n DSAParametersGenerator pGen = new DSAParametersGenerator();\n\n pGen.init(strength, certainty, random);\n param = new DSAKeyGenerationParameters(random, pGen.generateParameters());\n engine.init(param);\n initialised = true;\n }\n\n AsymmetricCipherKeyPair pair = engine.generateKeyPair();\n DSAPublicKeyParameters pub = (DSAPublicKeyParameters)pair.getPublic();\n DSAPrivateKeyParameters priv = (DSAPrivateKeyParameters)pair.getPrivate();\n\n return new KeyPair(new BCDSAPublicKey(pub), new BCDSAPrivateKey(priv));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "\tpublic int decryptWithAd(byte[] ad, byte[] ciphertext,\n\t\t\tint ciphertextOffset, byte[] plaintext, int plaintextOffset,\n\t\t\tint length) throws ShortBufferException, BadPaddingException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (length > space)\n\t\t\tthrow new ShortBufferException();\n\t\tif (plaintextOffset > plaintext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = plaintext.length - plaintextOffset;\n\t\tif (!haskey) {\n\t\t\t// The key is not set yet - return the ciphertext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (length < 16)\n\t\t\tNoise.throwBadTagException();\n\t\tint dataLen = length - 16;\n\t\tif (dataLen > space)\n\t\t\tthrow new ShortBufferException();\n\t\tsetup(ad);\n\t\tpoly.update(ciphertext, ciphertextOffset, dataLen);\n\t\tfinish(ad, dataLen);\n\t\tint temp = 0;\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\ttemp |= (polyKey[index] ^ ciphertext[ciphertextOffset + dataLen + index]);\n\t\tif ((temp & 0xFF) != 0)\n\t\t\tNoise.throwBadTagException();\n\t\tencrypt(ciphertext, ciphertextOffset, plaintext, plaintextOffset, dataLen);\n\t\treturn dataLen;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " public IESwithDESedeCBC()\n {\n super(new IESEngine(new DHBasicAgreement(),\n new KDF2BytesGenerator(new SHA1Digest()),\n new HMac(new SHA1Digest()),\n new PaddedBufferedBlockCipher(new CBCBlockCipher(new DESedeEngine()))), 8);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": "\tvoid testPointWithoutExceptionWhitelisted() {\n\t\tJsonParser.Defaults.classMetadataName = \"__class\";\n\t\tJsonSerializer.Defaults.classMetadataName = \"__class\";\n\n\t\tJsonParsers.forEachParser(jsonParser -> {\n\t\t\tjsonParser.allowClass(\"*.Point?D*\");\n\t\t\tString json = new JsonSerializer().serialize(new Point2D.Float(1.0f, 2.0f));\n\t\t\tPoint2D.Float point = jsonParser.parse(json);\n\t\t\tassertEquals(1.0f, point.x, DELTA);\n\t\t\tassertEquals(2.0f, point.y, DELTA);\n\t\t\tjsonParser.allowAllClasses();\n\t\t});\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " public static void init(final InitialContext applicationContext) {\n synchronized (GeoTools.class) {\n context = applicationContext;\n }\n fireConfigurationChanged();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " protected void setUp() throws Exception {\n SecretHelper.set(TEST_KEY);\n super.setUp();\n monitor.setNeeded();\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "\tpublic int decryptWithAd(byte[] ad, byte[] ciphertext,\n\t\t\tint ciphertextOffset, byte[] plaintext, int plaintextOffset,\n\t\t\tint length) throws ShortBufferException, BadPaddingException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (length > space)\n\t\t\tthrow new ShortBufferException();\n\t\tif (plaintextOffset > plaintext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = plaintext.length - plaintextOffset;\n\t\tif (keySpec == null) {\n\t\t\t// The key is not set yet - return the ciphertext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (length < 16)\n\t\t\tNoise.throwBadTagException();\n\t\tint dataLen = length - 16;\n\t\tif (dataLen > space)\n\t\t\tthrow new ShortBufferException();\n\t\ttry {\n\t\t\tsetup(ad);\n\t\t} catch (InvalidKeyException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (InvalidAlgorithmParameterException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t\tghash.update(ciphertext, ciphertextOffset, dataLen);\n\t\tghash.pad(ad != null ? ad.length : 0, dataLen);\n\t\tghash.finish(iv, 0, 16);\n\t\tint temp = 0;\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\ttemp |= (hashKey[index] ^ iv[index] ^ ciphertext[ciphertextOffset + dataLen + index]);\n\t\tif ((temp & 0xFF) != 0)\n\t\t\tNoise.throwBadTagException();\n\t\ttry {\n\t\t\tint result = cipher.update(ciphertext, ciphertextOffset, dataLen, plaintext, plaintextOffset);\n\t\t\tcipher.doFinal(plaintext, plaintextOffset + result);\n\t\t} catch (IllegalBlockSizeException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (BadPaddingException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t\treturn dataLen;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " public boolean isStripWhitespaceText() {\n return stripWhitespaceText;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " public void setIgnoreComments(boolean ignoreComments) {\n this.ignoreComments = ignoreComments;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " void sharp() {\n final PathAndQuery res = PathAndQuery.parse(\"/#?a=b#1\");\n assertThat(res).isNotNull();\n assertThat(res.path()).isEqualTo(\"/#\");\n assertThat(res.query()).isEqualTo(\"a=b#1\");\n\n // '%23' in a query string should never be decoded into '#'.\n final PathAndQuery res2 = PathAndQuery.parse(\"/%23?a=b%231\");\n assertThat(res2).isNotNull();\n assertThat(res2.path()).isEqualTo(\"/#\");\n assertThat(res2.query()).isEqualTo(\"a=b%231\");\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n String encoding = request.getHeader(\"Accept-Encoding\");\n boolean supportsGzip = (encoding != null && encoding.toLowerCase().indexOf(\"gzip\") > -1);\n SessionTerminal st = (SessionTerminal) request.getSession(true).getAttribute(\"terminal\");\n if (st == null || st.isClosed()) {\n st = new SessionTerminal(getCommandProcessor(), getThreadIO());\n request.getSession().setAttribute(\"terminal\", st);\n }\n String str = request.getParameter(\"k\");\n String f = request.getParameter(\"f\");\n String dump = st.handle(str, f != null && f.length() > 0);\n if (dump != null) {\n if (supportsGzip) {\n response.setHeader(\"Content-Encoding\", \"gzip\");\n response.setHeader(\"Content-Type\", \"text/html\");\n try {\n GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());\n gzos.write(dump.getBytes());\n gzos.close();\n } catch (IOException ie) {\n LOG.info(\"Exception writing response: \", ie);\n }\n } else {\n response.getOutputStream().write(dump.getBytes());\n }\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": "\t\tpublic boolean isIgnoreCase() {\n\t\t\treturn super.isIgnoreCase() || ignoreCase;\n\t\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "\t\tpublic Sort withUnsafe(String... properties) {\n\n\t\t\tAssert.notEmpty(properties, \"Properties must not be empty!\");\n\t\t\tAssert.noNullElements(properties, \"Properties must not contain null values!\");\n\n\t\t\tList orders = new ArrayList();\n\t\t\tfor (String property : properties) {\n\t\t\t\torders.add(new JpaOrder(getDirection(), property, getNullHandling(), isIgnoreCase(), this.unsafe));\n\t\t\t}\n\t\t\treturn new Sort(orders);\n\t\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public Argument argumentType() {\n return Argument.of(Publisher.class);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "\tpublic ECDSAVerifier(final ECPublicKey publicKey, final Set defCritHeaders)\n\t\tthrows JOSEException {\n\n\t\tsuper(ECDSA.resolveAlgorithm(publicKey));\n\n\t\tthis.publicKey = publicKey;\n\t\t\n\t\tif (! ECChecks.isPointOnCurve(\n\t\t\tpublicKey,\n\t\t\tECKey.Curve.forJWSAlgoritm(supportedECDSAAlgorithm()).toECParameterSpec())) {\n\t\t\tthrow new JOSEException(\"Curve / public key parameters mismatch\");\n\t\t}\n\n\t\tcritPolicy.setDeferredCriticalHeaderParams(defCritHeaders);\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": "\tprotected SymbolContext getContextLegacy() {\n\t\tthrow new UnsupportedOperationException();\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " public void translate(ServerKeepAlivePacket packet, GeyserSession session) {\n if (!session.getConnector().getConfig().isForwardPlayerPing()) {\n return;\n }\n NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();\n latencyPacket.setFromServer(true);\n latencyPacket.setTimestamp(packet.getPingId() * 1000);\n session.sendUpstreamPacket(latencyPacket);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " public static void validateHeader(CharSequence value) {\n for (int i = 0;i < value.length();i++) {\n char c = value.charAt(i);\n if (c == '\\r' || c == '\\n') {\n throw new IllegalArgumentException(\"Illegal header character: \" + ((int)c));\n }\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " protected @CheckForNull byte[] load() throws IOException {\n return ConfidentialStore.get().load(this);\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " public void overridingSubClassExample() {\n assertThat(ConstraintViolations.format(validator.validate(new OverridingExample())))\n .isEmpty();\n assertThat(TestLoggerFactory.getAllLoggingEvents())\n .isEmpty();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public SVNSSHAuthentication createSVNAuthentication(String kind) throws SVNException {\n if(kind.equals(ISVNAuthenticationManager.SSH)) {\n try {\n Channel channel = Channel.current();\n String privateKey;\n if(channel!=null) {\n // remote\n privateKey = channel.call(new Callable() {\n /**\n * \n */\n private static final long serialVersionUID = -3088632649290496373L;\n\n public String call() throws IOException {\n return FileUtils.readFileToString(getKeyFile(),\"iso-8859-1\");\n }\n });\n } else {\n privateKey = FileUtils.readFileToString(getKeyFile(),\"iso-8859-1\");\n }\n return new SVNSSHAuthentication(userName, privateKey.toCharArray(), Scrambler.descramble(Secret.toString(passphrase)),-1,false);\n } catch (IOException e) {\n throw new SVNException(\n SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_UNAVAILABLE,\"Unable to load private key\").initCause(e));\n } catch (InterruptedException e) {\n throw new SVNException(\n SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_UNAVAILABLE,\"Unable to load private key\").initCause(e));\n }\n } else\n return null; // unknown\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-255", "cwe_name": "Credentials Management Errors", "description": "Weaknesses in this category are related to the management of credentials.", "url": "https://cwe.mitre.org/data/definitions/255.html", "label_name": "safe"} {"code": " private boolean extract(ArrayList errors, URL source, File target) {\n FileOutputStream os = null;\n InputStream is = null;\n boolean extracting = false;\n try {\n if (!target.exists() || isStale(source, target) ) {\n is = source.openStream();\n if (is != null) {\n byte[] buffer = new byte[4096];\n os = new FileOutputStream(target);\n extracting = true;\n int read;\n while ((read = is.read(buffer)) != -1) {\n os.write(buffer, 0, read);\n }\n os.close();\n is.close();\n chmod(\"755\", target);\n }\n }\n } catch (Throwable e) {\n try {\n if (os != null)\n os.close();\n } catch (IOException e1) {\n }\n try {\n if (is != null)\n is.close();\n } catch (IOException e1) {\n }\n if (extracting && target.exists())\n target.delete();\n errors.add(e.getMessage());\n return false;\n }\n return true;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": " public boolean isValid(Object value, ConstraintValidatorContext context) {\n if (value != null && StringUtils.isNotEmpty(String.valueOf(value))) {\n return true;\n }\n String errorMessage = String.format(\"Expected not empty value, got '%s'\", value);\n LOG.warn(errorMessage);\n\n context.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation();\n return false;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"code": " public void messageParametersExample() {\n assertThat(ConstraintViolations.format(validator.validate(new MessageParametersExample()))).containsExactly(\n \" Mixed value VALUE\",\n \" Nested ${'nested'}\",\n \" No parameter\",\n \" VALUE\",\n \" VALUE {unsetParameter}\",\n \" value}\",\n \" { value }\",\n \" {1+1}\",\n \" {value\",\n \"{property} VALUE\",\n \"{property}[1] VALUE\",\n \"{property}[{key}] VALUE\"\n );\n assertThat(TestLoggerFactory.getAllLoggingEvents()).isEmpty();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "\tpublic NotLikeCondition(Selector selector, Parameter parameter) {\n\t\tsuper(selector,parameter);\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "\tpublic void createsUnsafeSortWithMultiplePropertiesCorrectly() {\n\n\t\tJpaSort sort = JpaSort.unsafe(DESC, \"foo.bar\", \"spring.data\");\n\n\t\tassertThat(sort, hasItems(new Order(DESC, \"foo.bar\"), new Order(DESC, \"spring.data\")));\n\t\tassertThat(sort.getOrderFor(\"foo.bar\"), is(instanceOf(JpaOrder.class)));\n\t\tassertThat(sort.getOrderFor(\"spring.data\"), is(instanceOf(JpaOrder.class)));\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " public void spliceToFile() throws Throwable {\n EventLoopGroup group = new EpollEventLoopGroup(1);\n File file = File.createTempFile(\"netty-splice\", null);\n file.deleteOnExit();\n\n SpliceHandler sh = new SpliceHandler(file);\n ServerBootstrap bs = new ServerBootstrap();\n bs.channel(EpollServerSocketChannel.class);\n bs.group(group).childHandler(sh);\n bs.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);\n Channel sc = bs.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel();\n\n Bootstrap cb = new Bootstrap();\n cb.group(group);\n cb.channel(EpollSocketChannel.class);\n cb.handler(new ChannelInboundHandlerAdapter());\n Channel cc = cb.connect(sc.localAddress()).syncUninterruptibly().channel();\n\n for (int i = 0; i < data.length;) {\n int length = Math.min(random.nextInt(1024 * 64), data.length - i);\n ByteBuf buf = Unpooled.wrappedBuffer(data, i, length);\n cc.writeAndFlush(buf);\n i += length;\n }\n\n while (sh.future2 == null || !sh.future2.isDone() || !sh.future.isDone()) {\n if (sh.exception.get() != null) {\n break;\n }\n try {\n Thread.sleep(50);\n } catch (InterruptedException e) {\n // Ignore.\n }\n }\n\n sc.close().sync();\n cc.close().sync();\n\n if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {\n throw sh.exception.get();\n }\n\n byte[] written = new byte[data.length];\n FileInputStream in = new FileInputStream(file);\n\n try {\n Assert.assertEquals(written.length, in.read(written));\n Assert.assertArrayEquals(data, written);\n } finally {\n in.close();\n group.shutdownGracefully();\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-378", "cwe_name": "Creation of Temporary File With Insecure Permissions", "description": "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.", "url": "https://cwe.mitre.org/data/definitions/378.html", "label_name": "vulnerable"} {"code": " public OldIESwithCipher(BlockCipher baseCipher)\n {\n super(new OldIESEngine(new DHBasicAgreement(),\n new KDF2BytesGenerator(new SHA1Digest()),\n new HMac(new SHA1Digest()),\n new PaddedBufferedBlockCipher(baseCipher)));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "\tprotected void switchToConversation(Contact contact, String body) {\n\t\tConversation conversation = xmppConnectionService\n\t\t\t\t.findOrCreateConversation(contact.getAccount(),\n\t\t\t\t\t\tcontact.getJid(), false, true);\n\t\tswitchToConversation(conversation, body);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " void setHeadersShouldClearAndOverwrite() {\n final HttpHeadersBase headers1 = newEmptyHeaders();\n headers1.add(\"name\", \"value\");\n\n final HttpHeadersBase headers2 = newEmptyHeaders();\n headers2.add(\"name\", \"newvalue\");\n headers2.add(\"name1\", \"value1\");\n\n headers1.set(headers2);\n assertThat(headers2).isEqualTo(headers1);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public void testInvalidUserId(final String userId, final boolean mustFail) {\n adminPage();\n findElementByLink(\"Configure Users, Groups and On-Call Roles\").click();\n findElementByLink(\"Configure Users\").click();\n findElementByLink(\"Add new user\").click();\n\n enterText(By.id(\"userID\"), userId);\n enterText(By.id(\"pass1\"), \"SmokeTestPassword\");\n enterText(By.id(\"pass2\"), \"SmokeTestPassword\");\n findElementByXpath(\"//button[@type='submit' and text()='OK']\").click();\n\n if (mustFail) {\n try {\n final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent());\n alert.dismiss();\n } catch (final Exception e) {\n LOG.debug(\"Got an exception waiting for a 'invalid user ID' alert.\", e);\n throw e;\n }\n } else {\n wait.until(ExpectedConditions.elementToBeClickable(By.name(\"finish\")));\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public void testImportBadConsumerZip() throws Exception {\n PKIUtility pki = mock(PKIUtility.class);\n Importer i = new Importer(null, null, null, null, null, null, null,\n pki, config, null, null, null, i18n);\n\n Owner owner = mock(Owner.class);\n ConflictOverrides co = mock(ConflictOverrides.class);\n\n // Mock a passed signature check:\n when(pki.verifySHA256WithRSAHashWithUpstreamCACert(any(InputStream.class),\n any(byte [].class))).thenReturn(true);\n\n File archive = new File(\"/tmp/file.zip\");\n ZipOutputStream out = new ZipOutputStream(new FileOutputStream(archive));\n out.putNextEntry(new ZipEntry(\"signature\"));\n out.write(\"This is the placeholder for the signature file\".getBytes());\n File ceArchive = new File(\"/tmp/consumer_export.zip\");\n FileOutputStream fos = new FileOutputStream(ceArchive);\n fos.write(\"This is just a flat file\".getBytes());\n fos.close();\n addFileToArchive(out, ceArchive);\n out.close();\n\n try {\n i.loadExport(owner, archive, co);\n }\n catch (ImportExtractionException e) {\n System.out.println(e.getMessage());\n assertTrue(e.getMessage().contains(\n \"not a properly compressed file or is empty\"));\n return;\n }\n fail();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public AsciiString generateSessionId() {\n return AsciiString.cached(UUID.randomUUID().toString());\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-338", "cwe_name": "Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)", "description": "The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.", "url": "https://cwe.mitre.org/data/definitions/338.html", "label_name": "safe"} {"code": " public void setProperty(String name, Object value) throws SAXException {\n getXMLReader().setProperty(name, value);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " public static @CheckForNull Descriptor find(String className) {\n return find(Jenkins.getInstance().getExtensionList(Descriptor.class),className);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " protected DispatchHandler getDispatchHandler() {\n if (dispatchHandler == null) {\n dispatchHandler = new DispatchHandler();\n }\n\n return dispatchHandler;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": "\tprotected SymbolContext getContextLegacy() {\n\t\treturn new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5));\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " ASN1Integer(byte[] bytes, boolean clone)\n {\n if (bytes.length > 1)\n {\n if (bytes[0] == 0 && (bytes[1] & 0x80) == 0)\n {\n throw new IllegalArgumentException(\"malformed integer\");\n }\n if (bytes[0] == (byte)0xff && (bytes[1] & 0x80) != 0)\n {\n throw new IllegalArgumentException(\"malformed integer\");\n }\n }\n this.bytes = (clone) ? Arrays.clone(bytes) : bytes;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " public UserCause(User user, String message) {\n super(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(\n user!=null ? user.getId() : Jenkins.ANONYMOUS.getName(),\n message != null ? \" : \" + message : \"\"\n ));\n this.user = user;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "\tprotected void runTeardown() {\n\t\tAssert.assertTrue(\"Error during initialization\", messagedInitialization);\n\t\tAssert.assertTrue(\"HTTP connection is not allowed\", messagedAccessDenied);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": "\tpublic int encryptWithAd(byte[] ad, byte[] plaintext, int plaintextOffset,\n\t\t\tbyte[] ciphertext, int ciphertextOffset, int length)\n\t\t\tthrows ShortBufferException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (keySpec == null) {\n\t\t\t// The key is not set yet - return the plaintext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(plaintext, plaintextOffset, ciphertext, ciphertextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (space < 16 || length > (space - 16))\n\t\t\tthrow new ShortBufferException();\n\t\ttry {\n\t\t\tsetup(ad);\n\t\t\tint result = cipher.update(plaintext, plaintextOffset, length, ciphertext, ciphertextOffset);\n\t\t\tcipher.doFinal(ciphertext, ciphertextOffset + result);\n\t\t} catch (InvalidKeyException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (InvalidAlgorithmParameterException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (IllegalBlockSizeException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (BadPaddingException e) {\n\t\t\t// Shouldn't happen.\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t\tghash.update(ciphertext, ciphertextOffset, length);\n\t\tghash.pad(ad != null ? ad.length : 0, length);\n\t\tghash.finish(ciphertext, ciphertextOffset + length, 16);\n\t\tfor (int index = 0; index < 16; ++index)\n\t\t\tciphertext[ciphertextOffset + length + index] ^= hashKey[index];\n\t\treturn length + 16;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "\tpublic Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {\n\t\tMedia media = null;\n\t\tif (mediaObject instanceof EfficiencyStatement) {\n\t\t\tEfficiencyStatement statement = (EfficiencyStatement) mediaObject;\n\t\t\tString xml = myXStream.toXML(statement); \n\t\t\tmedia = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, null, 90, author);\n\t\t\tThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(),\n\t\t\t\t\tLoggingResourceable.wrap(media));\n\t\t}\n\t\treturn media;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " public Document read(Reader reader, String systemId)\n throws DocumentException {\n InputSource source = new InputSource(reader);\n source.setSystemId(systemId);\n if (this.encoding != null) {\n source.setEncoding(this.encoding);\n }\n\n return read(source);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " void testPseudoHeadersMustComeFirstWhenIterating() {\n final HttpHeadersBase headers = newHttp2Headers();\n verifyPseudoHeadersFirst(headers);\n verifyAllPseudoHeadersPresent(headers);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public boolean isMergeAdjacentText() {\n return mergeAdjacentText;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": "\tprivate void displayVerificationWarningDialog(final Contact contact, final Invite invite) {\n\t\tAlertDialog.Builder builder = new AlertDialog.Builder(this);\n\t\tbuilder.setTitle(R.string.verify_omemo_keys);\n\t\tView view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);\n\t\tfinal CheckBox isTrustedSource = view.findViewById(R.id.trusted_source);\n\t\tTextView warning = view.findViewById(R.id.warning);\n\t\twarning.setText(JidDialog.style(this, R.string.verifying_omemo_keys_trusted_source, contact.getJid().asBareJid().toEscapedString(), contact.getDisplayName()));\n\t\tbuilder.setView(view);\n\t\tbuilder.setPositiveButton(R.string.confirm, (dialog, which) -> {\n\t\t\tif (isTrustedSource.isChecked() && invite.hasFingerprints()) {\n\t\t\t\txmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());\n\t\t\t}\n\t\t\tswitchToConversation(contact, invite.getBody());\n\t\t});\n\t\tbuilder.setNegativeButton(R.string.cancel, (dialog, which) -> StartConversationActivity.this.finish());\n\t\tAlertDialog dialog = builder.create();\n\t\tdialog.setCanceledOnTouchOutside(false);\n\t\tdialog.setOnCancelListener(dialog1 -> StartConversationActivity.this.finish());\n\t\tdialog.show();\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " public void setValidation(boolean validation) {\n this.validating = validation;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "safe"} {"code": " @Test public void encodedPathParametersAndPathTraversal() {\n class Example {\n @GET(\"/foo/bar/{ping}/\") //\n Call method(@Path(value = \"ping\", encoded = true) String ping) {\n return null;\n }\n }\n\n assertMalformedRequest(Example.class, \".\");\n assertMalformedRequest(Example.class, \"%2E\");\n assertMalformedRequest(Example.class, \"%2e\");\n assertMalformedRequest(Example.class, \"..\");\n assertMalformedRequest(Example.class, \"%2E.\");\n assertMalformedRequest(Example.class, \"%2e.\");\n assertMalformedRequest(Example.class, \".%2E\");\n assertMalformedRequest(Example.class, \".%2e\");\n assertMalformedRequest(Example.class, \"%2E%2e\");\n assertMalformedRequest(Example.class, \"%2e%2E\");\n assertMalformedRequest(Example.class, \"./a\");\n assertMalformedRequest(Example.class, \"a/.\");\n assertMalformedRequest(Example.class, \"../a\");\n assertMalformedRequest(Example.class, \"a/..\");\n assertMalformedRequest(Example.class, \"a/../b\");\n assertMalformedRequest(Example.class, \"a/%2e%2E/b\");\n\n assertThat(buildRequest(Example.class, \"...\").url().encodedPath())\n .isEqualTo(\"/foo/bar/.../\");\n assertThat(buildRequest(Example.class, \"a..b\").url().encodedPath())\n .isEqualTo(\"/foo/bar/a..b/\");\n assertThat(buildRequest(Example.class, \"a..\").url().encodedPath())\n .isEqualTo(\"/foo/bar/a../\");\n assertThat(buildRequest(Example.class, \"a..b\").url().encodedPath())\n .isEqualTo(\"/foo/bar/a..b/\");\n assertThat(buildRequest(Example.class, \"..b\").url().encodedPath())\n .isEqualTo(\"/foo/bar/..b/\");\n assertThat(buildRequest(Example.class, \"..\\\\..\").url().encodedPath())\n .isEqualTo(\"/foo/bar/..%5C../\");\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "\tprivate static void checkCEKLength(final SecretKey cek, final EncryptionMethod enc)\n\t\tthrows KeyLengthException {\n\n\t\ttry {\n\t\t\tif (enc.cekBitLength() != ByteUtils.safeBitLength(cek.getEncoded())) {\n\t\t\t\tthrow new KeyLengthException(\"The Content Encryption Key (CEK) length for \" + enc + \" must be \" + enc.cekBitLength() + \" bits\");\n\t\t\t}\n\t\t} catch (IntegerOverflowException e) {\n\t\t\tthrow new KeyLengthException(\"The Content Encryption Key (CEK) is too long: \" + e.getMessage());\n\t\t}\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": " public void sendError(int sc, String msg) throws IOException {\n if (isIncluding()) {\n Logger.log(Logger.ERROR, Launcher.RESOURCES, \"IncludeResponse.Error\",\n new String[] { \"\" + sc, msg });\n return;\n }\n \n Logger.log(Logger.DEBUG, Launcher.RESOURCES,\n \"WinstoneResponse.SendingError\", new String[] { \"\" + sc, msg });\n\n if ((this.webAppConfig != null) && (this.req != null)) {\n \n RequestDispatcher rd = this.webAppConfig\n .getErrorDispatcherByCode(req.getRequestURI(), sc, msg, null);\n if (rd != null) {\n try {\n rd.forward(this.req, this);\n return;\n } catch (IllegalStateException err) {\n throw err;\n } catch (IOException err) {\n throw err;\n } catch (Throwable err) {\n Logger.log(Logger.WARNING, Launcher.RESOURCES,\n \"WinstoneResponse.ErrorInErrorPage\", new String[] {\n rd.getName(), sc + \"\" }, err);\n return;\n }\n }\n }\n // If we are here there was no webapp and/or no request object, so \n // show the default error page\n if (this.errorStatusCode == null) {\n this.statusCode = sc;\n }\n String output = Launcher.RESOURCES.getString(\"WinstoneResponse.ErrorPage\",\n new String[] { sc + \"\", (msg == null ? \"\" : msg), \"\",\n Launcher.RESOURCES.getString(\"ServerVersion\"),\n \"\" + new Date() });\n setContentLength(output.getBytes(getCharacterEncoding()).length);\n Writer out = getWriter();\n out.write(output);\n out.flush();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " public PBEWithSHA256AESCBC256()\n {\n super(new CBCBlockCipher(new AESFastEngine()), PKCS12, SHA256, 256, 16);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "\tpublic int encryptWithAd(byte[] ad, byte[] plaintext, int plaintextOffset,\n\t\t\tbyte[] ciphertext, int ciphertextOffset, int length) throws ShortBufferException {\n\t\tint space;\n\t\tif (ciphertextOffset > ciphertext.length)\n\t\t\tspace = 0;\n\t\telse\n\t\t\tspace = ciphertext.length - ciphertextOffset;\n\t\tif (!haskey) {\n\t\t\t// The key is not set yet - return the plaintext as-is.\n\t\t\tif (length > space)\n\t\t\t\tthrow new ShortBufferException();\n\t\t\tif (plaintext != ciphertext || plaintextOffset != ciphertextOffset)\n\t\t\t\tSystem.arraycopy(plaintext, plaintextOffset, ciphertext, ciphertextOffset, length);\n\t\t\treturn length;\n\t\t}\n\t\tif (space < 16 || length > (space - 16))\n\t\t\tthrow new ShortBufferException();\n\t\tsetup(ad);\n\t\tencrypt(plaintext, plaintextOffset, ciphertext, ciphertextOffset, length);\n\t\tpoly.update(ciphertext, ciphertextOffset, length);\n\t\tfinish(ad, length);\n\t\tSystem.arraycopy(polyKey, 0, ciphertext, ciphertextOffset + length, 16);\n\t\treturn length + 16;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " private CallbackHandler getCallbackHandler(\n @UnderInitialization(WrappedFactory.class) LibPQFactory this,\n Properties info) throws PSQLException {\n // Determine the callback handler\n CallbackHandler cbh;\n String sslpasswordcallback = PGProperty.SSL_PASSWORD_CALLBACK.get(info);\n if (sslpasswordcallback != null) {\n try {\n cbh = (CallbackHandler) ObjectFactory.instantiate(sslpasswordcallback, info, false, null);\n } catch (Exception e) {\n throw new PSQLException(\n GT.tr(\"The password callback class provided {0} could not be instantiated.\",\n sslpasswordcallback),\n PSQLState.CONNECTION_FAILURE, e);\n }\n } else {\n cbh = new ConsoleCallbackHandler(PGProperty.SSL_PASSWORD.get(info));\n }\n return cbh;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-665", "cwe_name": "Improper Initialization", "description": "The software does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.", "url": "https://cwe.mitre.org/data/definitions/665.html", "label_name": "vulnerable"} {"code": "\tprivate ECChecks() {}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": "\tpublic JsonParser allowAllClasses() {\n\t\tclassnameWhitelist = null;\n\t\treturn this;\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " public void checkAccess(String pHost, String pAddress, String pOrigin) {\n if (!backendManager.isRemoteAccessAllowed(pHost,pAddress)) {\n throw new SecurityException(\"No access from client \" + pAddress + \" allowed\");\n }\n if (pOrigin != null && !backendManager.isOriginAllowed(pOrigin,true)) {\n throw new SecurityException(\"Origin \" + pOrigin + \" is not allowed to call this agent\");\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\tprotected IBaseResource addCommonParams(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {\n\t\tfinal String serverId = theRequest.getServerIdWithDefault(myConfig);\n\t\tfinal String serverBase = theRequest.getServerBase(theServletRequest, myConfig);\n\t\tfinal String serverName = theRequest.getServerName(myConfig);\n\t\tfinal String apiKey = theRequest.getApiKey(theServletRequest, myConfig);\n\t\ttheModel.put(\"serverId\", sanitizeInput(serverId));\n\t\ttheModel.put(\"base\", sanitizeInput(serverBase));\n\t\ttheModel.put(\"baseName\", sanitizeInput(serverName));\n\t\ttheModel.put(\"apiKey\", sanitizeInput(apiKey));\n\t\ttheModel.put(\"resourceName\", sanitizeInput(defaultString(theRequest.getResource())));\n\t\ttheModel.put(\"encoding\", sanitizeInput(theRequest.getEncoding()));\n\t\ttheModel.put(\"pretty\", sanitizeInput(theRequest.getPretty()));\n\t\ttheModel.put(\"_summary\", sanitizeInput(theRequest.get_summary()));\n\t\ttheModel.put(\"serverEntries\", myConfig.getIdToServerName());\n\n\t\treturn loadAndAddConf(theServletRequest, theRequest, theModel);\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " public void checkClientIPAccess(String pHost, String pAddress) {\n if (!backendManager.isRemoteAccessAllowed(pHost,pAddress)) {\n throw new SecurityException(\"No access from client \" + pAddress + \" allowed\");\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public OldECIESwithCipher(BlockCipher baseCipher)\n {\n super(new OldIESEngine(new ECDHBasicAgreement(),\n new KDF2BytesGenerator(new SHA1Digest()),\n new HMac(new SHA1Digest()),\n new PaddedBufferedBlockCipher(baseCipher)));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " public void testSquare_CarryBug()\n {\n int COUNT = 100;\n\n for (int i = 0; i < COUNT; ++i)\n {\n ECFieldElement x = generateSquareInput_CarryBug();\n\n BigInteger X = x.toBigInteger();\n BigInteger R = X.multiply(X).mod(Q);\n\n ECFieldElement z = x.square();\n BigInteger Z = z.toBigInteger();\n\n assertEquals(R, Z);\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-19", "cwe_name": "Data Processing Errors", "description": "Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.", "url": "https://cwe.mitre.org/data/definitions/19.html", "label_name": "safe"} {"code": "\tpublic void testMatchTwoTypes() {\n\n\t\tJWKMatcher matcher = new JWKMatcher.Builder().keyTypes(KeyType.RSA, KeyType.EC).build();\n\n\t\tassertTrue(matcher.matches(new RSAKey.Builder(new Base64URL(\"n\"), new Base64URL(\"e\")).keyID(\"1\").build()));\n\t\tassertTrue(matcher.matches(new ECKey.Builder(ECKey.Curve.P_256, new Base64URL(\"x\"), new Base64URL(\"y\")).keyID(\"2\").build()));\n\t\t\n\t\tassertEquals(\"kty=[RSA, EC]\", matcher.toString());\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " public void simpleGetWithTextPlainMimeType() throws ServletException, IOException {\n checkMimeTypes(\"text/plain\", \"text/plain\");\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " private SearchResult lookupUser(String accountName) throws NamingException {\n InitialDirContext context = initContext();\n\n String searchString = searchFilter.replace(\":login\", accountName);\n\n SearchControls searchControls = new SearchControls();\n String[] attributeFilter = {idAttribute, nameAttribute, mailAttribute};\n searchControls.setReturningAttributes(attributeFilter);\n searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);\n\n NamingEnumeration results = context.search(searchBase, searchString, searchControls);\n\n SearchResult searchResult = null;\n if (results.hasMoreElements()) {\n searchResult = results.nextElement();\n if (results.hasMoreElements()) {\n LOGGER.warn(\"Matched multiple users for the accountName: \" + accountName);\n return null;\n }\n }\n\n return searchResult;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "vulnerable"} {"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": 0, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "vulnerable"} {"code": " public byte[] newIv(int length) {\n return ConfidentialStore.get().randomBytes(length);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-326", "cwe_name": "Inadequate Encryption Strength", "description": "The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.", "url": "https://cwe.mitre.org/data/definitions/326.html", "label_name": "safe"} {"code": " protected List readPropertySourceListFromFiles(String files) {\n List propertySources = new ArrayList<>();\n Collection propertySourceLoaders = getPropertySourceLoaders();\n Optional> filePathList = Optional.ofNullable(files)\n .filter(value -> !value.isEmpty())\n .map(value -> value.split(FILE_SEPARATOR))\n .map(Arrays::asList)\n .map(Collections::unmodifiableList);\n\n filePathList.ifPresent(list -> {\n if (!list.isEmpty()) {\n int order = AbstractPropertySourceLoader.DEFAULT_POSITION + 50;\n for (String filePath: list) {\n if (!propertySourceLoaders.isEmpty()) {\n String extension = NameUtils.extension(filePath);\n String fileName = NameUtils.filename(filePath);\n Optional propertySourceLoader = Optional.ofNullable(loaderByFormatMap.get(extension));\n if (propertySourceLoader.isPresent()) {\n if (LOG.isDebugEnabled()) {\n LOG.debug(\"Reading property sources from loader: {}\", propertySourceLoader);\n }\n Optional> properties = readPropertiesFromLoader(fileName, filePath, propertySourceLoader.get());\n if (properties.isPresent()) {\n propertySources.add(PropertySource.of(filePath, properties.get(), order));\n }\n order++;\n } else {\n throw new ConfigurationException(\"Unsupported properties file format: \" + fileName);\n }\n }\n }\n }\n });\n return propertySources;\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " void requestResetPasswordNoEmail() throws Exception\n {\n when(this.userManager.exists(this.userReference)).thenReturn(true);\n String exceptionMessage = \"User has no email address.\";\n when(this.localizationManager.getTranslationPlain(\"xe.admin.passwordReset.error.noEmail\"))\n .thenReturn(exceptionMessage);\n ResetPasswordException resetPasswordException = assertThrows(ResetPasswordException.class,\n () -> this.resetPasswordManager.requestResetPassword(this.userReference));\n assertEquals(exceptionMessage, resetPasswordException.getMessage());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-640", "cwe_name": "Weak Password Recovery Mechanism for Forgotten Password", "description": "The software contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak.", "url": "https://cwe.mitre.org/data/definitions/640.html", "label_name": "vulnerable"} {"code": " public void handle(HttpServletRequest request, final HttpServletResponse response)\n throws Exception\n {\n // We're sending an XML response, so set the response content type to text/xml\n response.setContentType(\"text/xml\");\n\n // Parse the incoming request as XML\n SAXReader xmlReader = XML.getSafeSaxReader();\n Document doc = xmlReader.read(request.getInputStream());\n Element env = doc.getRootElement();\n\n final List polls = unmarshalRequests(env);\n\n new ContextualHttpServletRequest(request)\n {\n @Override\n public void process() throws Exception\n { \n for (PollRequest req : polls)\n {\n req.poll();\n }\n \n // Package up the response\n marshalResponse(polls, response.getOutputStream()); \n }\n }.run();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " public void testInvalidGroupId(final String groupId, final boolean mustFail) {\n adminPage();\n findElementByLink(\"Configure Users, Groups and On-Call Roles\").click();\n findElementByLink(\"Configure Groups\").click();\n findElementByLink(\"Add new group\").click();\n\n enterText(By.id(\"groupName\"), groupId);\n enterText(By.id(\"groupComment\"), \"SmokeTestComment\");\n findElementByXpath(\"//button[@type='submit' and text()='OK']\").click();\n\n if (mustFail) {\n try {\n final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent());\n alert.dismiss();\n } catch (final Exception e) {\n LOG.debug(\"Got an exception waiting for a 'invalid group ID' alert.\", e);\n throw e;\n }\n } else {\n wait.until(ExpectedConditions.elementToBeClickable(By.name(\"finish\")));\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " void testAddSelf() {\n final HttpHeadersBase headers = newEmptyHeaders();\n assertThatThrownBy(() -> headers.add(headers)).isInstanceOf(IllegalArgumentException.class);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public void translate(LoginDisconnectPacket packet, GeyserSession session) {\n // The client doesn't manually get disconnected so we have to do it ourselves\n session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " void testContainsNameAndValue() {\n final HttpHeadersBase headers = newHttp2Headers();\n assertThat(headers.contains(\"name1\", \"value2\")).isTrue();\n assertThat(headers.contains(\"name1\", \"Value2\")).isFalse();\n assertThat(headers.contains(\"name2\", \"value3\")).isTrue();\n assertThat(headers.contains(\"name2\", \"Value3\")).isFalse();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": " public HgVersion version() {\n CommandLine hg = createCommandLine(\"hg\").withArgs(\"version\").withEncoding(\"utf-8\");\n String hgOut = execute(hg, new NamedProcessTag(\"hg version check\")).outputAsString();\n return HgVersion.parse(hgOut);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " public static Object deserialize(byte[] data)\n throws IOException, ClassNotFoundException\n {\n ByteArrayInputStream in = new ByteArrayInputStream(data);\n ObjectInputStream is = new ObjectInputStream(in);\n return is.readObject();\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-470", "cwe_name": "Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')", "description": "The application uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.", "url": "https://cwe.mitre.org/data/definitions/470.html", "label_name": "vulnerable"} {"code": " public void testFileRegionCountLargerThenFile(ServerBootstrap sb, Bootstrap cb) throws Throwable {\n File file = PlatformDependent.createTempFile(\"netty-\", \".tmp\", null);\n file.deleteOnExit();\n\n final FileOutputStream out = new FileOutputStream(file);\n out.write(data);\n out.close();\n\n sb.childHandler(new SimpleChannelInboundHandler() {\n @Override\n protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {\n // Just drop the message.\n }\n });\n cb.handler(new ChannelInboundHandlerAdapter());\n\n Channel sc = sb.bind().sync().channel();\n Channel cc = cb.connect(sc.localAddress()).sync().channel();\n\n // Request file region which is bigger then the underlying file.\n FileRegion region = new DefaultFileRegion(\n new RandomAccessFile(file, \"r\").getChannel(), 0, data.length + 1024);\n\n assertThat(cc.writeAndFlush(region).await().cause(), CoreMatchers.instanceOf(IOException.class));\n cc.close().sync();\n sc.close().sync();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-379", "cwe_name": "Creation of Temporary File in Directory with Insecure Permissions", "description": "The software creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file.", "url": "https://cwe.mitre.org/data/definitions/379.html", "label_name": "safe"} {"code": " public void initialize(\n int strength,\n SecureRandom random)\n {\n if (strength < 512 || strength > 4096 || ((strength < 1024) && strength % 64 != 0) || (strength >= 1024 && strength % 1024 != 0))\n {\n throw new InvalidParameterException(\"strength must be from 512 - 4096 and a multiple of 1024 above 1024\");\n }\n\n this.strength = strength;\n this.random = random;\n this.initialised = false;\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": " public static void execute(String url, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,\n String accessToken, String orgName, String moduleName, String version, Path baloPath) {\n initializeSsl();\n HttpURLConnection conn = createHttpUrlConnection(convertToUrl(url), proxyHost, proxyPort, proxyUsername,\n proxyPassword);\n conn.setInstanceFollowRedirects(false);\n setRequestMethod(conn, Utils.RequestMethod.POST);\n\n // Set headers\n conn.setRequestProperty(HttpHeaders.AUTHORIZATION, \"Bearer \" + accessToken);\n conn.setRequestProperty(PUSH_ORGANIZATION, orgName);\n conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM);\n\n conn.setDoOutput(true);\n conn.setChunkedStreamingMode(BUFFER_SIZE);\n\n try (DataOutputStream outputStream = new DataOutputStream(conn.getOutputStream())) {\n // Send balo content by 1 kb chunks\n byte[] buffer = new byte[BUFFER_SIZE];\n int count;\n try (ProgressBar progressBar = new ProgressBar(\n orgName + \"/\" + moduleName + \":\" + version + \" [project repo -> central]\",\n getTotalFileSizeInKB(baloPath), 1000, outStream, ProgressBarStyle.ASCII, \" KB\", 1);\n FileInputStream fis = new FileInputStream(baloPath.toFile())) {\n while ((count = fis.read(buffer)) > 0) {\n outputStream.write(buffer, 0, count);\n outputStream.flush();\n progressBar.stepBy((long) NO_OF_BYTES);\n }\n }\n } catch (IOException e) {\n throw ErrorUtil.createCommandException(\"error occurred while uploading balo to central: \" + e.getMessage());\n }\n\n handleResponse(conn, orgName, moduleName, version);\n Authenticator.setDefault(null);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-306", "cwe_name": "Missing Authentication for Critical Function", "description": "The software does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.", "url": "https://cwe.mitre.org/data/definitions/306.html", "label_name": "vulnerable"} {"code": " public ECIESwithDESede()\n {\n super(new DESedeEngine());\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "\tpublic static final Binder fromPath(Path path)\n\tthrows IOException {\t\n\t\ttry(InputStream inStream = Files.newInputStream(path)) {\n\t\t\treturn (Binder)myStream.fromXML(inStream);\n\t\t} catch (Exception e) {\n\t\t\tlog.error(\"Cannot import this map: \" + path, e);\n\t\t\treturn null;\n\t\t}\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n try {\n UserFactory.init();\n } catch (Throwable e) {\n throw new ServletException(\"AddNewUserServlet: Error initialising user factory.\" + e);\n }\n UserManager userFactory = UserFactory.getInstance();\n\n String userID = request.getParameter(\"userID\");\n\n if (userID != null && userID.matches(\".*[&<>\\\"`']+.*\")) {\n throw new ServletException(\"User ID must not contain any HTML markup.\");\n }\n\n String password = request.getParameter(\"pass1\");\n\n boolean hasUser = false;\n try {\n hasUser = userFactory.hasUser(userID);\n } catch (Throwable e) {\n throw new ServletException(\"can't determine if user \" + userID + \" already exists in users.xml.\", e);\n }\n\n if (hasUser) {\n RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(\"/admin/userGroupView/users/newUser.jsp?action=redo\");\n dispatcher.forward(request, response);\n } else {\n final Password pass = new Password();\n pass.setEncryptedPassword(UserFactory.getInstance().encryptedPassword(password, true));\n pass.setSalt(true);\n\n final User newUser = new User();\n newUser.setUserId(userID);\n newUser.setPassword(pass);\n\n final HttpSession userSession = request.getSession(false);\n userSession.setAttribute(\"user.modifyUser.jsp\", newUser);\n\n // forward the request for proper display\n RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(\"/admin/userGroupView/users/modifyUser.jsp\");\n dispatcher.forward(request, response);\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public Document read(InputStream in, String systemId)\n throws DocumentException {\n InputSource source = new InputSource(in);\n source.setSystemId(systemId);\n if (this.encoding != null) {\n source.setEncoding(this.encoding);\n }\n\n return read(source);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": " public SetupImportForm(final SetupPage parentPage)\n {\n super(parentPage, \"importform\");\n initUpload(Bytes.megabytes(100));\n csrfTokenHandler = new CsrfTokenHandler(this);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException, InterruptedException {\n StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);\n if (startTlsFeature != null) {\n if (startTlsFeature.required() && config.getSecurityMode() == SecurityMode.disabled) {\n notifyConnectionError(new SecurityRequiredByServerException());\n return;\n }\n\n if (config.getSecurityMode() != ConnectionConfiguration.SecurityMode.disabled) {\n sendNonza(new StartTls());\n }\n }\n // If TLS is required but the server doesn't offer it, disconnect\n // from the server and throw an error. First check if we've already negotiated TLS\n // and are secure, however (features get parsed a second time after TLS is established).\n if (!isSecureConnection() && startTlsFeature == null\n && getConfiguration().getSecurityMode() == SecurityMode.required) {\n throw new SecurityRequiredByClientException();\n }\n\n if (getSASLAuthentication().authenticationSuccessful()) {\n // If we have received features after the SASL has been successfully completed, then we\n // have also *maybe* received, as it is an optional feature, the compression feature\n // from the server.\n maybeCompressFeaturesReceived.reportSuccess();\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "vulnerable"} {"code": " public void addSynchronously(MediaPackage mediaPackage) throws SearchException, MediaPackageException,\n IllegalArgumentException, UnauthorizedException {\n if (mediaPackage == null) {\n throw new IllegalArgumentException(\"Unable to add a null mediapackage\");\n }\n logger.debug(\"Attempting to add mediapackage {} to search index\", mediaPackage.getIdentifier());\n AccessControlList acl = authorizationService.getActiveAcl(mediaPackage).getA();\n\n Date now = new Date();\n\n try {\n if (indexManager.add(mediaPackage, acl, now)) {\n logger.info(\"Added mediapackage `{}` to the search index, using ACL `{}`\", mediaPackage, acl);\n } else {\n logger.warn(\"Failed to add mediapackage {} to the search index\", mediaPackage.getIdentifier());\n }\n } catch (SolrServerException e) {\n throw new SearchException(e);\n }\n\n try {\n persistence.storeMediaPackage(mediaPackage, acl, now);\n } catch (SearchServiceDatabaseException e) {\n logger.error(\"Could not store media package to search database {}: {}\", mediaPackage.getIdentifier(), e);\n throw new SearchException(e);\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " public SpotProtocolDecoder(Protocol protocol) {\n super(protocol);\n try {\n documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();\n xPath = XPathFactory.newInstance().newXPath();\n messageExpression = xPath.compile(\"//messageList/message\");\n } catch (ParserConfigurationException | XPathExpressionException e) {\n throw new RuntimeException(e);\n }\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-611", "cwe_name": "Improper Restriction of XML External Entity Reference", "description": "The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.", "url": "https://cwe.mitre.org/data/definitions/611.html", "label_name": "vulnerable"} {"code": "\tprivate final HColor getBackColor(UmlDiagramType umlDiagramType, Style style) {\n\t\tif (EntityUtils.groupRoot(group))\n\t\t\treturn null;\n\n\t\tfinal HColor result = group.getColors().getColor(ColorType.BACK);\n\t\tif (result != null)\n\t\t\treturn result;\n\n\t\tfinal Stereotype stereo = group.getStereotype();\n\n\t\tif (UseStyle.useBetaStyle())\n\t\t\treturn style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());\n\n\t\tfinal USymbol sym = group.getUSymbol() == null ? USymbols.PACKAGE : group.getUSymbol();\n\t\tfinal ColorParam backparam = umlDiagramType == UmlDiagramType.ACTIVITY ? ColorParam.partitionBackground\n\t\t\t\t: sym.getColorParamBack();\n\t\tfinal HColor c1 = skinParam.getHtmlColor(backparam, stereo, false);\n\t\tif (c1 != null)\n\t\t\treturn c1;\n\n\t\tif (parentCluster == null)\n\t\t\treturn null;\n\n\t\treturn parentCluster.getBackColor(umlDiagramType, style);\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "\tpublic List getParameters() {\n\t\treturn Collections.emptyList();\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " @Test public void defaultValueKeptSecret() throws Exception {\n FreeStyleProject p = j.createFreeStyleProject();\n p.addProperty(new ParametersDefinitionProperty(new PasswordParameterDefinition(\"p\", \"s3cr3t\", \"\")));\n j.configRoundtrip(p);\n assertEquals(\"s3cr3t\", ((PasswordParameterDefinition) p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition(\"p\")).getDefaultValue());\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "safe"} {"code": " public void testDropTable() throws Exception {\n DataSet result = dataSetManager.lookupDataSet(\n DataSetLookupFactory.newDataSetLookupBuilder()\n .dataset(DataSetGroupTest.EXPENSE_REPORTS)\n .filter(COLUMN_EMPLOYEE, FilterFactory.equalsTo(\"David'; DROP TABLE 'EXPENSE_REPORTS; SELECT 'a' = 'a\"))\n .buildLookup());\n\n result = dataSetManager.lookupDataSet(\n DataSetLookupFactory.newDataSetLookupBuilder()\n .dataset(DataSetGroupTest.EXPENSE_REPORTS)\n .buildLookup());\n\n assertEquals(result.getRowCount(), 50);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " private HtmlButton getButton(HtmlForm form, int index) {\n return form.getHtmlElementsByTagName(\"button\").get(index);\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " private byte[] getOutput()\n throws BadPaddingException\n {\n try\n {\n byte[] bytes = bOut.toByteArray();\n\n return cipher.processBlock(bytes, 0, bytes.length);\n }\n catch (InvalidCipherTextException e)\n {\n throw new BadBlockException(\"unable to decrypt block\", e);\n }\n finally\n {\n bOut.reset();\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-361", "cwe_name": "7PK - Time and State", "description": "This category represents one of the phyla in the Seven Pernicious Kingdoms vulnerability classification. It includes weaknesses related to the improper management of time and state in an environment that supports simultaneous or near-simultaneous computation by multiple systems, processes, or threads. According to the authors of the Seven Pernicious Kingdoms, \"Distributed computation is about time and state. That is, in order for more than one component to communicate, state must be shared, and all that takes time. Most programmers anthropomorphize their work. They think about one thread of control carrying out the entire program in the same way they would if they had to do the job themselves. Modern computers, however, switch between tasks very quickly, and in multi-core, multi-CPU, or distributed systems, two events may take place at exactly the same time. Defects rush to fill the gap between the programmer's model of how a program executes and what happens in reality. These defects are related to unexpected interactions between threads, processes, time, and information. These interactions happen through shared state: semaphores, variables, the file system, and, basically, anything that can store information.\"", "url": "https://cwe.mitre.org/data/definitions/361.html", "label_name": "safe"} {"code": " public BourneShell()\n {\n this(false);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "\tpublic void archive(OLATResourceable ores, File exportDirectory) {\n\t\tObjectOutputStream out = null;\n\t\ttry {\n\t\t\tFile file = new File(exportDirectory, \"chat.xml\");\n\t\t\tWriter writer = new FileWriter(file);\n\t\t\tout = logXStream.createObjectOutputStream(writer);\n\t\t\t\n\t\t\tint counter = 0;\n\t\t\tList messages;\n\t\t\tdo {\n\t\t\t\tmessages = imDao.getMessages(ores, null, counter, BATCH_SIZE);\n\t\t\t\tfor(InstantMessage message:messages) {\n\t\t\t\t\tout.writeObject(message);\n\t\t\t\t}\n\t\t\t\tcounter += messages.size();\n\t\t\t} while(messages.size() == BATCH_SIZE);\n\t\t} catch (IOException e) {\n\t\t\tlog.error(\"\", e);\n\t\t} finally {\n\t\t\tIOUtils.closeQuietly(out);\n\t\t}\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": "\tpublic Controller getMediaController(UserRequest ureq, WindowControl wControl, Media media, MediaRenderingHints hints) {\n\t\tString statementXml = media.getContent();\n\t\tEfficiencyStatement statement = null;\n\t\tif(StringHelper.containsNonWhitespace(statementXml)) {\n\t\t\ttry {\n\t\t\t\tstatement = (EfficiencyStatement)myXStream.fromXML(statementXml);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlog.error(\"Cannot load efficiency statement from artefact\", e);\n\t\t\t}\n\t\t}\n\t\tCertificateAndEfficiencyStatementController ctrl = new CertificateAndEfficiencyStatementController(wControl, ureq, statement);\n\t\tctrl.disableMediaCollector();\n\t\treturn ctrl;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " private static String slowEncodePathToPercents(Bytes value) {\n final int length = value.length;\n final StringBuilder buf = new StringBuilder(length + value.numEncodedBytes() * 2);\n for (int i = 0; i < length; i++) {\n final int b = value.data[i] & 0xFF;\n\n if (value.isEncoded(i)) {\n buf.append(TO_PERCENT_ENCODED_CHARS[b]);\n continue;\n }\n\n buf.append((char) b);\n }\n\n return buf.toString();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "\tpublic void testSelectByType() {\n\n\t\tJWKSelector selector = new JWKSelector(new JWKMatcher.Builder().keyType(KeyType.RSA).build());\n\n\t\tList keyList = new ArrayList<>();\n\t\tkeyList.add(new RSAKey.Builder(new Base64URL(\"n\"), new Base64URL(\"e\")).keyID(\"1\").build());\n\t\tkeyList.add(new ECKey.Builder(ECKey.Curve.P_256, EC_P256_X, EC_P256_Y).keyID(\"2\").build());\n\n\t\tJWKSet jwkSet = new JWKSet(keyList);\n\n\t\tList matches = selector.select(jwkSet);\n\n\t\tRSAKey key1 = (RSAKey)matches.get(0);\n\t\tassertEquals(KeyType.RSA, key1.getKeyType());\n\t\tassertEquals(\"1\", key1.getKeyID());\n\n\t\tassertEquals(1, matches.size());\n\t}", "label": 1, "programming_language": "Java", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "safe"} {"code": " protected void sendResponse(HttpSession session, Subject subject, PrintWriter out) {\n\n Map answer = new HashMap();\n\n List principals = new ArrayList();\n\n for (Principal principal : subject.getPrincipals()) {\n Map data = new HashMap();\n data.put(\"type\", principal.getClass().getName());\n data.put(\"name\", principal.getName());\n principals.add(data);\n }\n\n List credentials = new ArrayList();\n for (Object credential : subject.getPublicCredentials()) {\n Map data = new HashMap();\n data.put(\"type\", credential.getClass().getName());\n data.put(\"credential\", credential);\n }\n\n answer.put(\"principals\", principals);\n answer.put(\"credentials\", credentials);\n\n ServletHelpers.writeObject(converters, options, out, answer);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": "\t public void doFilter(ServletRequest srequest, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {\n\n\t \t\tHttpServletRequest request = (HttpServletRequest) srequest;\n\t \t\tfilterChain.doFilter(new XssHttpServletRequestWrapper(request) {}, response);\n\n\t }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " void routingResult() throws URISyntaxException {\n final RoutingResultBuilder builder = RoutingResult.builder();\n final RoutingResult routingResult = builder.path(\"/foo\")\n .query(\"bar=baz\")\n .rawParam(\"qux\", \"quux\")\n .negotiatedResponseMediaType(MediaType.JSON_UTF_8)\n .build();\n assertThat(routingResult.isPresent()).isTrue();\n assertThat(routingResult.path()).isEqualTo(\"/foo\");\n assertThat(routingResult.query()).isEqualTo(\"bar=baz\");\n assertThat(routingResult.pathParams()).containsOnly(Maps.immutableEntry(\"qux\", \"quux\"));\n assertThat(routingResult.negotiatedResponseMediaType()).isSameAs(MediaType.JSON_UTF_8);\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "\tpublic static ResourceEvaluation evaluate(File file, String filename) {\n\t\tResourceEvaluation eval = new ResourceEvaluation();\n\t\ttry {\n\t\t\tImsManifestFileFilter visitor = new ImsManifestFileFilter();\n\t\t\tPath fPath = PathUtils.visit(file, filename, visitor);\n\t\t\tif(visitor.isValid()) {\n\t\t\t\tPath realManifestPath = visitor.getManifestPath();\n\t\t\t\tPath manifestPath = fPath.resolve(realManifestPath);\n\t\t\t\t\n\t\t\t\tRootSearcher rootSearcher = new RootSearcher();\n\t\t\t\tFiles.walkFileTree(fPath, rootSearcher);\n\t\t\t\tif(rootSearcher.foundRoot()) {\n\t\t\t\t\tmanifestPath = rootSearcher.getRoot().resolve(IMS_MANIFEST);\n\t\t\t\t} else {\n\t\t\t\t\tmanifestPath = fPath.resolve(IMS_MANIFEST);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tDocument doc = IMSLoader.loadIMSDocument(manifestPath);\n\t\t\t\tif(validateImsManifest(doc)) {\n\t\t\t\t\teval.setValid(true);\n\t\t\t\t} else {\n\t\t\t\t\teval.setValid(false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teval.setValid(false);\n\t\t\t}\n\t\t\tPathUtils.closeSubsequentFS(fPath);\n\t\t} catch (IOException | IllegalArgumentException e) {\n\t\t\tlog.error(\"\", e);\n\t\t\teval.setValid(false);\n\t\t}\n\t\treturn eval;\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " public void testInvalidUserId(final String userId, final boolean mustFail) {\n adminPage();\n findElementByLink(\"Configure Users, Groups and On-Call Roles\").click();\n findElementByLink(\"Configure Users\").click();\n findElementByLink(\"Add new user\").click();\n\n enterText(By.id(\"userID\"), userId);\n enterText(By.id(\"pass1\"), \"SmokeTestPassword\");\n enterText(By.id(\"pass2\"), \"SmokeTestPassword\");\n findElementByXpath(\"//button[@type='submit' and text()='OK']\").click();\n\n if (mustFail) {\n try {\n final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent());\n alert.dismiss();\n } catch (final Exception e) {\n LOG.debug(\"Got an exception waiting for a 'invalid user ID' alert.\", e);\n throw e;\n }\n } else {\n wait.until(ExpectedConditions.elementToBeClickable(By.name(\"finish\")));\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public BigInteger calculateAgreement(\n DHPublicKeyParameters pub,\n BigInteger message)\n {\n if (!pub.getParameters().equals(dhParams))\n {\n throw new IllegalArgumentException(\"Diffie-Hellman public key has wrong parameters.\");\n }\n\n BigInteger p = dhParams.getP();\n\n return message.modPow(key.getX(), p).multiply(pub.getY().modPow(privateValue, p)).mod(p);\n }", "label": 0, "programming_language": "Java", "cwe_id": "CWE-320", "cwe_name": "Key Management Errors", "description": "Weaknesses in this category are related to errors in the management of cryptographic keys.", "url": "https://cwe.mitre.org/data/definitions/320.html", "label_name": "vulnerable"} {"code": "\tpublic static boolean saveLinkList(HashMap portletMap){\n\t\tXStream xstream = XStreamHelper.createXStreamInstance();\n\t\txstream.alias(\"LinksPortlet\", Map.class);\n\t\txstream.alias(ELEM_LINK, PortletLink.class);\n\t\txstream.alias(ELEM_INSTITUTION, PortletInstitution.class);\n\t\txstream.aliasAttribute(PortletInstitution.class, ATTR_INSTITUTION_NAME, ATTR_INSTITUTION_NAME);\n\t\tString output = xstream.toXML(portletMap);\n\t\tXStreamHelper.writeObject(xstream, fxConfXStreamFile, portletMap);\n\t\treturn (output.length() != 0);\t\t\n\t}", "label": 0, "programming_language": "Java", "cwe_id": "CWE-91", "cwe_name": "XML Injection (aka Blind XPath Injection)", "description": "The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.", "url": "https://cwe.mitre.org/data/definitions/91.html", "label_name": "vulnerable"} {"code": " public void corsAccessCheck() {\n BackendManager backendManager = new BackendManager(config,log);\n assertTrue(backendManager.isOriginAllowed(\"http://bla.com\",false));\n backendManager.destroy();\n }", "label": 1, "programming_language": "Java", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " public static void scanOnReboot() throws InterruptedException, IOException, GeneralSecurityException {\n FileBoolean flag = new RekeySecretAdminMonitor().scanOnBoot;\n if (flag.isOn()) {\n flag.off();\n RekeyThread t = new RekeyThread();\n t.start();\n t.join();\n // block the boot until the rewrite process is complete\n // don't let the failure in RekeyThread block Jenkins boot.\n }\n }", "label": 1, "programming_language": "Java", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "void HeaderMapImpl::addCopy(const LowerCaseString& key, const std::string& value) {\n auto* entry = getExistingInline(key.get());\n if (entry != nullptr) {\n appendToHeader(entry->value(), value);\n return;\n }\n HeaderString new_key;\n new_key.setCopy(key.get().c_str(), key.get().size());\n HeaderString new_value;\n new_value.setCopy(value.c_str(), value.size());\n insertByKey(std::move(new_key), std::move(new_value));\n ASSERT(new_key.empty()); // NOLINT(bugprone-use-after-move)\n ASSERT(new_value.empty()); // NOLINT(bugprone-use-after-move)\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " void Compute(OpKernelContext* context) override {\n const Tensor& input_indices_in = context->input(0);\n const Tensor& input_shape_in = context->input(1);\n\n OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices_in.shape()),\n errors::InvalidArgument(\"Input must be a matrix.\"));\n OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape_in.shape()),\n errors::InvalidArgument(\"Input shape must be a vector.\"));\n OP_REQUIRES(context,\n input_indices_in.dim_size(1) == input_shape_in.dim_size(0),\n errors::InvalidArgument(\n \"Input tensor rank must match input shape length.\"));\n ReshapeSparseTensor(context, context->input(0), context->input(1),\n context->input(2), 0 /* output indices index */,\n 1 /* output shape index */);\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "bool MemoryManager::validate_user_read(const Process& process, VirtualAddress vaddr) const\n{\n auto* region = region_from_vaddr(process, vaddr);\n return region && region->is_readable();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "TfLiteStatus ResizeOutput(TfLiteContext* context, TfLiteNode* node) {\n TfLiteIntArray* output_shape = GetOutputShape(context, node);\n std::unique_ptr\n scoped_output_shape(output_shape, TfLiteIntArrayFree);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n // Tensorflow's Reshape allows one of the shape components to have the\n // special -1 value, meaning it will be calculated automatically based on the\n // input. Here we calculate what that dimension should be so that the number\n // of output elements in the same as the number of input elements.\n int num_input_elements = NumElements(input);\n\n int num_output_elements = 1;\n int stretch_dim = -1;\n for (int i = 0; i < output_shape->size; ++i) {\n int value = output_shape->data[i];\n if (value == -1) {\n TF_LITE_ENSURE_EQ(context, stretch_dim, -1);\n stretch_dim = i;\n } else {\n num_output_elements *= value;\n }\n }\n if (stretch_dim != -1) {\n output_shape->data[stretch_dim] = num_input_elements / num_output_elements;\n num_output_elements *= output_shape->data[stretch_dim];\n }\n\n TF_LITE_ENSURE_EQ(context, num_input_elements, num_output_elements);\n return context->ResizeTensor(context, output, scoped_output_shape.release());\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1,\n jas_matind_t r0, jas_matind_t c0, jas_matind_t r1, jas_matind_t c1)\n{\n\tjas_matind_t i;\n\n\tif (mat0->data_) {\n\t\tif (!(mat0->flags_ & JAS_MATRIX_REF)) {\n\t\t\tjas_free(mat0->data_);\n\t\t}\n\t\tmat0->data_ = 0;\n\t\tmat0->datasize_ = 0;\n\t}\n\tif (mat0->rows_) {\n\t\tjas_free(mat0->rows_);\n\t\tmat0->rows_ = 0;\n\t}\n\tmat0->flags_ |= JAS_MATRIX_REF;\n\tmat0->numrows_ = r1 - r0 + 1;\n\tmat0->numcols_ = c1 - c0 + 1;\n\tmat0->maxrows_ = mat0->numrows_;\n\tif (!(mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *)))) {\n\t\t/*\n\t\t\tThere is no way to indicate failure to the caller.\n\t\t\tSo, we have no choice but to abort.\n\t\t\tIdeally, this function should have a non-void return type.\n\t\t\tIn practice, a non-void return type probably would not help\n\t\t\tmuch anyways as the caller would just have to terminate anyways.\n\t\t*/\n\t\tabort();\n\t}\n\n\tfor (i = 0; i < mat0->numrows_; ++i) {\n\t\tmat0->rows_[i] = mat1->rows_[r0 + i] + c0;\n\t}\n\n\tmat0->xstart_ = mat1->xstart_ + c0;\n\tmat0->ystart_ = mat1->ystart_ + r0;\n\tmat0->xend_ = mat0->xstart_ + mat0->numcols_;\n\tmat0->yend_ = mat0->ystart_ + mat0->numrows_;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": " void Compute(OpKernelContext* ctx) override {\n const Tensor& handle = ctx->input(0);\n OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(handle.shape()),\n errors::InvalidArgument(\"`handle` must be scalar\"));\n const string& name = handle.scalar()();\n auto session_state = ctx->session_state();\n OP_REQUIRES(ctx, session_state != nullptr,\n errors::FailedPrecondition(\n \"DeleteSessionTensor called on null session state\"));\n OP_REQUIRES_OK(ctx, session_state->DeleteTensor(name));\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "void CoreUserInputHandler::putPrivmsg(const QString &target, const QString &message, std::function encodeFunc, Cipher *cipher)\n{\n QString cmd(\"PRIVMSG\");\n QByteArray targetEnc = serverEncode(target);\n\n std::function(QString &)> cmdGenerator = [&] (QString &splitMsg) -> QList {\n QByteArray splitMsgEnc = encodeFunc(target, splitMsg);\n\n#ifdef HAVE_QCA2\n if (cipher && !cipher->key().isEmpty() && !splitMsg.isEmpty()) {\n cipher->encrypt(splitMsgEnc);\n }\n#endif\n return QList() << targetEnc << splitMsgEnc;\n };\n\n putCmd(cmd, network()->splitMessage(cmd, message, cmdGenerator));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "CharString *Formattable::internalGetCharString(UErrorCode &status) {\n if(fDecimalStr == NULL) {\n if (fDecimalQuantity == NULL) {\n // No decimal number for the formattable yet. Which means the value was\n // set directly by the user as an int, int64 or double. If the value came\n // from parsing, or from the user setting a decimal number, fDecimalNum\n // would already be set.\n //\n LocalPointer dq(new DecimalQuantity(), status);\n if (U_FAILURE(status)) { return nullptr; }\n populateDecimalQuantity(*dq, status);\n if (U_FAILURE(status)) { return nullptr; }\n fDecimalQuantity = dq.orphan();\n }\n\n fDecimalStr = new CharString();\n if (fDecimalStr == NULL) {\n status = U_MEMORY_ALLOCATION_ERROR;\n return NULL;\n }\n // Older ICUs called uprv_decNumberToString here, which is not exactly the same as\n // DecimalQuantity::toScientificString(). The biggest difference is that uprv_decNumberToString does\n // not print scientific notation for magnitudes greater than -5 and smaller than some amount (+5?).\n if (fDecimalQuantity->isZero()) {\n fDecimalStr->append(\"0\", -1, status);\n } else if (std::abs(fDecimalQuantity->getMagnitude()) < 5) {\n fDecimalStr->appendInvariantChars(fDecimalQuantity->toPlainString(), status);\n } else {\n fDecimalStr->appendInvariantChars(fDecimalQuantity->toScientificString(), status);\n }\n }\n return fDecimalStr;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static inline bool isMountable(const RemoteFsDevice::Details &d)\n{\n return RemoteFsDevice::constSshfsProtocol==d.url.scheme() ||\n RemoteFsDevice::constSambaProtocol==d.url.scheme() || RemoteFsDevice::constSambaAvahiProtocol==d.url.scheme();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TEST_F(TestSPIFFEValidator, TestGetTrustBundleStore) {\n initialize();\n\n // No SAN\n auto cert = readCertFromFile(TestEnvironment::substitute(\n \"{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_cert.pem\"));\n EXPECT_FALSE(validator().getTrustBundleStore(cert.get()));\n\n // Non-SPIFFE SAN\n cert = readCertFromFile(TestEnvironment::substitute(\n \"{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/non_spiffe_san_cert.pem\"));\n EXPECT_FALSE(validator().getTrustBundleStore(cert.get()));\n\n // SPIFFE SAN\n cert = readCertFromFile(TestEnvironment::substitute(\n \"{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/spiffe_san_cert.pem\"));\n\n // Trust bundle not provided.\n EXPECT_FALSE(validator().getTrustBundleStore(cert.get()));\n\n // Trust bundle provided.\n validator().trustBundleStores().emplace(\"example.com\", X509StorePtr(X509_STORE_new()));\n EXPECT_TRUE(validator().getTrustBundleStore(cert.get()));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "static int decode_level3_header(LHAFileHeader **header, LHAInputStream *stream)\n{\n\tunsigned int header_len;\n\n\t// The first field at the start of a level 3 header is supposed to\n\t// indicate word size, with the idea being that the header format\n\t// can be extended beyond 32-bit words in the future. In practise,\n\t// nothing supports anything other than 32-bit (4 bytes), and neither\n\t// do we.\n\n\tif (lha_decode_uint16(&RAW_DATA(header, 0)) != 4) {\n\t\treturn 0;\n\t}\n\n\t// Read the full header.\n\n\tif (!extend_raw_data(header, stream,\n\t LEVEL_3_HEADER_LEN - RAW_DATA_LEN(header))) {\n\t\treturn 0;\n\t}\n\n\t// Read the header length field (including extended headers), and\n\t// extend to this full length. Because this is a 32-bit value,\n\t// we must place a sensible limit on the amount of data that will\n\t// be read, to avoid possibly allocating gigabytes of memory.\n\n\theader_len = lha_decode_uint32(&RAW_DATA(header, 24));\n\n\tif (header_len > LEVEL_3_MAX_HEADER_LEN) {\n\t\treturn 0;\n\t}\n\n\tif (!extend_raw_data(header, stream,\n\t header_len - RAW_DATA_LEN(header))) {\n\t\treturn 0;\n\t}\n\n\t// Compression method:\n\n\tmemcpy((*header)->compress_method, &RAW_DATA(header, 2), 5);\n\t(*header)->compress_method[5] = '\\0';\n\n\t// File lengths:\n\n\t(*header)->compressed_length = lha_decode_uint32(&RAW_DATA(header, 7));\n\t(*header)->length = lha_decode_uint32(&RAW_DATA(header, 11));\n\n\t// Unix-style timestamp.\n\n\t(*header)->timestamp = lha_decode_uint32(&RAW_DATA(header, 15));\n\n\t// CRC.\n\n\t(*header)->crc = lha_decode_uint16(&RAW_DATA(header, 21));\n\n\t// OS type:\n\n\t(*header)->os_type = RAW_DATA(header, 23);\n\n\tif (!decode_extended_headers(header, 28)) {\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "int64_t MemFile::readImpl(char *buffer, int64_t length) {\n assertx(m_len != -1);\n assertx(length > 0);\n assertx(m_cursor >= 0);\n int64_t remaining = m_len - m_cursor;\n if (remaining < length) length = remaining;\n if (length > 0) {\n memcpy(buffer, (const void *)(m_data + m_cursor), length);\n m_cursor += length;\n return length;\n }\n return 0;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "std::wstring CreateUniqueTempDirectory()\n{\n // We need to put downloaded updates into a directory of their own, because\n // if we put it in $TMP, some DLLs could be there and interfere with the\n // installer.\n //\n // This code creates a new randomized directory name and tries to create it;\n // this process is repeated if the directory already exists.\n wchar_t tmpdir[MAX_PATH+1];\n if ( GetTempPath(MAX_PATH+1, tmpdir) == 0 )\n throw Win32Exception(\"Cannot create temporary directory\");\n\n for ( ;; )\n {\n std::wstring dir(tmpdir);\n dir += L\"Update-\";\n\n UUID uuid;\n UuidCreate(&uuid);\n RPC_WSTR uuidStr;\n RPC_STATUS status = UuidToString(&uuid, &uuidStr);\n dir += reinterpret_cast(uuidStr);\n RpcStringFree(&uuidStr);\n\n if ( CreateDirectory(dir.c_str(), NULL) )\n return dir;\n else if ( GetLastError() != ERROR_ALREADY_EXISTS )\n throw Win32Exception(\"Cannot create temporary directory\");\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-426", "cwe_name": "Untrusted Search Path", "description": "The application searches for critical resources using an externally-supplied search path that can point to resources that are not under the application's direct control.", "url": "https://cwe.mitre.org/data/definitions/426.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE(context, NumInputs(node) == 1 || NumInputs(node) == 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n // Always postpone sizing string tensors, even if we could in principle\n // calculate their shapes now. String tensors don't benefit from having their\n // shapes precalculated because the actual memory can only be allocated after\n // we know all the content.\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n if (output->type != kTfLiteString) {\n if (NumInputs(node) == 1 ||\n IsConstantTensor(GetInput(context, node, kShapeTensor))) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n } else {\n SetTensorToDynamic(output);\n }\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int jas_matrix_resize(jas_matrix_t *matrix, int numrows, int numcols)\n{\n\tint size;\n\tint i;\n\n\tsize = numrows * numcols;\n\tif (size > matrix->datasize_ || numrows > matrix->maxrows_) {\n\t\treturn -1;\n\t}\n\n\tmatrix->numrows_ = numrows;\n\tmatrix->numcols_ = numcols;\n\n\tfor (i = 0; i < numrows; ++i) {\n\t\tmatrix->rows_[i] = &matrix->data_[numcols * i];\n\t}\n\n\treturn 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "folly::Optional dump_file(const char* name) {\n auto const path = folly::sformat(\"{}/{}\", RO::AdminDumpPath, name);\n\n // mkdir -p the directory prefix of `path`\n if (FileUtil::mkdir(path) != 0) return folly::none;\n\n // If remove fails because of a permissions issue, then we won't be\n // able to open the file for exclusive write below.\n remove(path.c_str());\n\n // Create the file, failing if it already exists. Doing so ensures\n // that we have write access to the file and that no other user does.\n auto const fd = open(path.c_str(), O_CREAT|O_EXCL|O_RDWR, 0666);\n if (fd < 0) return folly::none;\n\n return DumpFile{path, folly::File(fd, /*owns=*/true)};\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": "bool IsPadOpSupported(const TfLiteRegistration* registration,\n const TfLiteNode* node, TfLiteContext* context) {\n // padding is d x 2 tensor, where d is the dimension of input.\n const TfLiteTensor* padding;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &padding));\n if (!IsConstantTensor(padding)) {\n TF_LITE_KERNEL_LOG(context,\n \"%s: Only constant padding is supported for PAD.\",\n padding->name);\n return false;\n }\n if (padding->dims->data[0] != 4 || padding->dims->data[1] != 2) {\n TF_LITE_KERNEL_LOG(context, \"%s: Only 4D inputs are supported for PAD.\",\n padding->name);\n return false;\n }\n const int32_t* padding_data = GetTensorData(padding);\n if (!(padding_data[0] == 0 && padding_data[1] == 0)) {\n TF_LITE_KERNEL_LOG(\n context, \"%s: Padding for batch dimension is not supported in PAD.\",\n padding->name);\n return false;\n }\n\n if (!(padding_data[6] == 0 && padding_data[7] == 0)) {\n TF_LITE_KERNEL_LOG(\n context, \"%s: Padding for channel dimension is not supported in PAD.\",\n padding->name);\n return false;\n }\n return true;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms,\n int clrspc)\n{\n\tjas_image_t *image;\n\tuint_fast32_t rawsize;\n\tuint_fast32_t inmem;\n\tint cmptno;\n\tjas_image_cmptparm_t *cmptparm;\n\n\tif (!(image = jas_image_create0())) {\n\t\treturn 0;\n\t}\n\n\timage->clrspc_ = clrspc;\n\timage->maxcmpts_ = numcmpts;\n\timage->inmem_ = true;\n\n\t/* Allocate memory for the per-component information. */\n\tif (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,\n\t sizeof(jas_image_cmpt_t *)))) {\n\t\tjas_image_destroy(image);\n\t\treturn 0;\n\t}\n\t/* Initialize in case of failure. */\n\tfor (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {\n\t\timage->cmpts_[cmptno] = 0;\n\t}\n\n\t/* Compute the approximate raw size of the image. */\n\trawsize = 0;\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\trawsize += cmptparm->width * cmptparm->height *\n\t\t (cmptparm->prec + 7) / 8;\n\t}\n\t/* Decide whether to buffer the image data in memory, based on the\n\t raw size of the image. */\n\tinmem = (rawsize < JAS_IMAGE_INMEMTHRESH);\n\n\t/* Create the individual image components. */\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\tif (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,\n\t\t cmptparm->tly, cmptparm->hstep, cmptparm->vstep,\n\t\t cmptparm->width, cmptparm->height, cmptparm->prec,\n\t\t cmptparm->sgnd, inmem))) {\n\t\t\tjas_image_destroy(image);\n\t\t\treturn 0;\n\t\t}\n\t\t++image->numcmpts_;\n\t}\n\n\t/* Determine the bounding box for all of the components on the\n\t reference grid (i.e., the image area) */\n\tjas_image_setbbox(image);\n\n\treturn image;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus ResizeOutputTensors(TfLiteContext* context, TfLiteNode* node,\n const TfLiteTensor* axis,\n const TfLiteTensor* input, int num_splits) {\n int axis_value = GetTensorData(axis)[0];\n if (axis_value < 0) {\n axis_value += NumDimensions(input);\n }\n\n TF_LITE_ENSURE(context, axis_value >= 0);\n TF_LITE_ENSURE(context, axis_value < NumDimensions(input));\n\n const int input_size = SizeOfDimension(input, axis_value);\n TF_LITE_ENSURE_MSG(context, input_size % num_splits == 0,\n \"Not an even split\");\n const int slice_size = input_size / num_splits;\n\n for (int i = 0; i < NumOutputs(node); ++i) {\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output_dims->data[axis_value] = slice_size;\n TfLiteTensor* output = GetOutput(context, node, i);\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_dims));\n }\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* cond_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputConditionTensor,\n &cond_tensor));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (IsDynamicTensor(output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeOutputTensor(context, cond_tensor, output));\n }\n\n TfLiteIntArray* dims = cond_tensor->dims;\n if (dims->size == 0) {\n // Scalar tensors are not supported.\n TF_LITE_KERNEL_LOG(context, \"Where op requires condition w/ rank > 0\");\n return kTfLiteError;\n }\n\n reference_ops::SelectTrueCoords(GetTensorShape(cond_tensor),\n GetTensorData(cond_tensor),\n GetTensorData(output));\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "int HexOutStream::length()\n{\n return offset + ptr - start;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " void writeStats(Array& /*ret*/) override {\n fprintf(stderr, \"writeStats start\\n\");\n // RetSame: the return value is the same instance every time\n // HasThis: call has a this argument\n // AllSame: all returns were the same data even though args are different\n // MemberCount: number of different arg sets (including this)\n fprintf(stderr, \"Count Function MinSerLen MaxSerLen RetSame HasThis \"\n \"AllSame MemberCount\\n\");\n for (auto& me : m_memos) {\n if (me.second.m_ignore) continue;\n if (me.second.m_count == 1) continue;\n int min_ser_len = 999999999;\n int max_ser_len = 0;\n int count = 0;\n int member_count = 0;\n bool all_same = true;\n if (me.second.m_has_this) {\n bool any_multiple = false;\n auto& fr = me.second.m_member_memos.begin()->second.m_return_value;\n member_count = me.second.m_member_memos.size();\n for (auto& mme : me.second.m_member_memos) {\n if (mme.second.m_return_value != fr) all_same = false;\n count += mme.second.m_count;\n auto ser_len = mme.second.m_return_value.length();\n min_ser_len = std::min(min_ser_len, ser_len);\n max_ser_len = std::max(max_ser_len, ser_len);\n if (mme.second.m_count > 1) any_multiple = true;\n }\n if (!any_multiple && !all_same) continue;\n } else {\n min_ser_len = max_ser_len = me.second.m_return_value.length();\n count = me.second.m_count;\n all_same = me.second.m_ret_tv_same;\n }\n fprintf(stderr, \"%d %s %d %d %s %s %s %d\\n\",\n count, me.first.data(),\n min_ser_len, max_ser_len,\n me.second.m_ret_tv_same ? \" true\" : \"false\",\n me.second.m_has_this ? \" true\" : \"false\",\n all_same ? \" true\" : \"false\",\n member_count\n );\n }\n fprintf(stderr, \"writeStats end\\n\");\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int CommandData::IsProcessFile(FileHeader &FileHead,bool *ExactMatch,int MatchType,\n wchar *MatchedArg,uint MatchedArgSize)\n{\n if (MatchedArg!=NULL && MatchedArgSize>0)\n *MatchedArg=0;\n// if (wcslen(FileHead.FileName)>=NM)\n// return 0;\n bool Dir=FileHead.Dir;\n if (ExclCheck(FileHead.FileName,Dir,false,true))\n return 0;\n#ifndef SFX_MODULE\n if (TimeCheck(FileHead.mtime))\n return 0;\n if ((FileHead.FileAttr & ExclFileAttr)!=0 || InclAttrSet && (FileHead.FileAttr & InclFileAttr)==0)\n return 0;\n if (!Dir && SizeCheck(FileHead.UnpSize))\n return 0;\n#endif\n wchar *ArgName;\n FileArgs.Rewind();\n for (int StringCount=1;(ArgName=FileArgs.GetString())!=NULL;StringCount++)\n if (CmpName(ArgName,FileHead.FileName,MatchType))\n {\n if (ExactMatch!=NULL)\n *ExactMatch=wcsicompc(ArgName,FileHead.FileName)==0;\n if (MatchedArg!=NULL)\n wcsncpyz(MatchedArg,ArgName,MatchedArgSize);\n return StringCount;\n }\n return 0;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "MONGO_EXPORT int bson_append_code_n( bson *b, const char *name, const char *value, int len ) {\n return bson_append_string_base( b, name, value, len, BSON_CODE );\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 2);\n\n TF_LITE_ENSURE_TYPES_EQ(context, output->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n TF_LITE_ENSURE(context, params->spectrogram->Initialize(params->window_size,\n params->stride));\n const int64_t sample_count = input->dims->data[0];\n const int64_t length_minus_window = (sample_count - params->window_size);\n if (length_minus_window < 0) {\n params->output_height = 0;\n } else {\n params->output_height = 1 + (length_minus_window / params->stride);\n }\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(3);\n output_size->data[0] = input->dims->data[1];\n output_size->data[1] = params->output_height;\n output_size->data[2] = params->spectrogram->output_frequency_channels();\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n EvalAdd(context, node, params, data, input1, input2, output);\n } else if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16) {\n TF_LITE_ENSURE_OK(context,\n EvalAddQuantized(context, node, params, data,\n input1, input2, output));\n } else {\n TF_LITE_UNSUPPORTED_TYPE(context, output->type, \"Add\");\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "int PackLinuxElf64::canUnpack()\n{\n if (super::canUnpack()) {\n return true;\n }\n if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {\n PackLinuxElf64help1(fi);\n Elf64_Phdr const *phdr = phdri, *last_LOAD = nullptr;\n for (unsigned j = 0; j < e_phnum; ++phdr, ++j)\n if (Elf64_Phdr::PT_LOAD==get_te32(&phdr->p_type)) {\n last_LOAD = phdr;\n }\n if (!last_LOAD)\n return false;\n off_t offset = get_te64(&last_LOAD->p_offset);\n unsigned filesz = get_te64(&last_LOAD->p_filesz);\n fi->seek(filesz+offset, SEEK_SET);\n MemBuffer buf(32 + sizeof(overlay_offset));\n fi->readx(buf, buf.getSize());\n return PackUnix::find_overlay_offset(buf);\n }\n return false;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "TfLiteStatus PrepareSimple(TfLiteContext* context, TfLiteNode* node) {\n // Inputs Tensor (dtype depends on quantization):\n // [0] = Input\n // [1] = Axis\n const TfLiteTensor* input = GetInput(context, node, 0);\n\n // Outputs Tensor (dtype depends on quantization):\n // [0] = Output\n\n // Validate number of inputs and outputs\n TF_LITE_ENSURE_EQ(context, node->inputs->size, 2);\n TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n // Validate axis type\n const TfLiteTensor* axis = GetInput(context, node, 1);\n TF_LITE_ENSURE(context, axis != nullptr);\n TF_LITE_ENSURE_TYPES_EQ(context, axis->type, kTfLiteInt32);\n\n if (input->type == kTfLiteInt8) {\n OpData* data = static_cast(node->user_data);\n const TfLiteTensor* output = GetOutput(context, node, 0);\n const double real_multiplier = static_cast(input->params.scale) /\n static_cast(output->params.scale);\n QuantizeMultiplier(real_multiplier, &data->multiplier, &data->shift);\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "error_t tcpCheckSeqNum(Socket *socket, TcpHeader *segment, size_t length)\n{\n //Acceptability test for an incoming segment\n bool_t acceptable = FALSE;\n\n //Case where both segment length and receive window are zero\n if(!length && !socket->rcvWnd)\n {\n //Make sure that SEG.SEQ = RCV.NXT\n if(segment->seqNum == socket->rcvNxt)\n {\n acceptable = TRUE;\n }\n }\n //Case where segment length is zero and receive window is non zero\n else if(!length && socket->rcvWnd)\n {\n //Make sure that RCV.NXT <= SEG.SEQ < RCV.NXT+RCV.WND\n if(TCP_CMP_SEQ(segment->seqNum, socket->rcvNxt) >= 0 &&\n TCP_CMP_SEQ(segment->seqNum, socket->rcvNxt + socket->rcvWnd) < 0)\n {\n acceptable = TRUE;\n }\n }\n //Case where both segment length and receive window are non zero\n else if(length && socket->rcvWnd)\n {\n //Check whether RCV.NXT <= SEG.SEQ < RCV.NXT+RCV.WND\n if(TCP_CMP_SEQ(segment->seqNum, socket->rcvNxt) >= 0 &&\n TCP_CMP_SEQ(segment->seqNum, socket->rcvNxt + socket->rcvWnd) < 0)\n {\n acceptable = TRUE;\n }\n //or RCV.NXT <= SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND\n else if(TCP_CMP_SEQ(segment->seqNum + length - 1, socket->rcvNxt) >= 0 &&\n TCP_CMP_SEQ(segment->seqNum + length - 1, socket->rcvNxt + socket->rcvWnd) < 0)\n {\n acceptable = TRUE;\n }\n }\n\n //Non acceptable sequence number?\n if(!acceptable)\n {\n //Debug message\n TRACE_WARNING(\"Sequence number is not acceptable!\\r\\n\");\n\n //If an incoming segment is not acceptable, an acknowledgment\n //should be sent in reply (unless the RST bit is set)\n if(!(segment->flags & TCP_FLAG_RST))\n tcpSendSegment(socket, TCP_FLAG_ACK, socket->sndNxt, socket->rcvNxt, 0, FALSE);\n\n //Return status code\n return ERROR_FAILURE;\n }\n\n //Sequence number is acceptable\n return NO_ERROR;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TfLiteStatus PrepareMeanOrSum(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_OK(context, PrepareSimple(context, node));\n OpData* data = reinterpret_cast(node->user_data);\n\n // reduce_mean requires a buffer to store intermediate sum result.\n OpContext op_context(context, node);\n if (op_context.input->type == kTfLiteInt8 ||\n op_context.input->type == kTfLiteUInt8 ||\n op_context.input->type == kTfLiteInt16) {\n const double real_multiplier =\n static_cast(op_context.input->params.scale) /\n static_cast(op_context.output->params.scale);\n int exponent;\n QuantizeMultiplier(real_multiplier, &data->multiplier, &exponent);\n data->shift = exponent;\n }\n TfLiteTensor* temp_sum;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, /*index=*/2, &temp_sum));\n if (!IsConstantTensor(op_context.axis)) {\n SetTensorToDynamic(temp_sum);\n return kTfLiteOk;\n }\n temp_sum->allocation_type = kTfLiteArenaRw;\n return ResizeTempSum(context, &op_context, temp_sum);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "bool DNP3_Base::ParseAppLayer(Endpoint* endp)\n\t{\n\tbool orig = (endp == &orig_state);\n\tbinpac::DNP3::DNP3_Flow* flow = orig ? interp->upflow() : interp->downflow();\n\n\tu_char* data = endp->buffer + PSEUDO_TRANSPORT_INDEX; // The transport layer byte counts as app-layer it seems.\n\tint len = endp->pkt_length - 5;\n\n\t// DNP3 Packet : DNP3 Pseudo Link Layer | DNP3 Pseudo Transport Layer | DNP3 Pseudo Application Layer\n\t// DNP3 Serial Transport Layer data is always 1 byte.\n\t// Get FIN FIR seq field in transport header.\n\t// FIR indicate whether the following DNP3 Serial Application Layer is first chunk of bytes or not.\n\t// FIN indicate whether the following DNP3 Serial Application Layer is last chunk of bytes or not.\n\n\tint is_first = (endp->tpflags & 0x40) >> 6; // Initial chunk of data in this packet.\n\tint is_last = (endp->tpflags & 0x80) >> 7; // Last chunk of data in this packet.\n\n\tint transport = PSEUDO_TRANSPORT_LEN;\n\n\tint i = 0;\n\twhile ( len > 0 )\n\t\t{\n\t\tint n = min(len, 16);\n\n\t\t// Make sure chunk has a correct checksum.\n\t\tif ( ! CheckCRC(n, data, data + n, \"app_chunk\") )\n\t\t\treturn false;\n\n\t\tif ( data + n >= endp->buffer + endp->buffer_len )\n\t\t\t{\n\t\t\treporter->AnalyzerError(analyzer,\n\t\t\t \"dnp3 app layer parsing overflow %d - %d\",\n\t\t\t endp->buffer_len, n);\n\t\t\treturn false;\n\t\t\t}\n\n\t\t// Pass on to BinPAC.\n\t\tflow->flow_buffer()->BufferData(data + transport, data + n);\n\t\ttransport = 0;\n\n\t\tdata += n + 2;\n\t\tlen -= n;\n\t\t}\n\n\tif ( is_first )\n\t\tendp->encountered_first_chunk = true;\n\n\tif ( ! is_first && ! endp->encountered_first_chunk )\n\t\t{\n\t\t// We lost the first chunk.\n\t\tanalyzer->Weird(\"dnp3_first_application_layer_chunk_missing\");\n\t\treturn false;\n\t\t}\n\n\tif ( is_last )\n\t\t{\n\t\tflow->flow_buffer()->FinishBuffer();\n\t\tflow->FlowEOF();\n\t\tClearEndpointState(orig);\n\t\t}\n\n\treturn true;\n\t}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "TEST_CASE_METHOD(TestFixture, \"DKG AES encrypted secret shares test\", \"[dkg-aes-encr-sshares]\") {\n vector errMsg(BUF_LEN, 0);\n vector result(BUF_LEN, 0);\n\n int errStatus = 0;\n uint32_t encLen = 0;\n\n vector encryptedDKGSecret(BUF_LEN, 0);\n PRINT_SRC_LINE\n auto status = trustedGenDkgSecretAES(eid, &errStatus, errMsg.data(), encryptedDKGSecret.data(), &encLen, 2);\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n\n uint64_t enc_len = encLen;\n\n PRINT_SRC_LINE\n status = trustedSetEncryptedDkgPolyAES(eid, &errStatus, errMsg.data(), encryptedDKGSecret.data(), enc_len);\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n\n vector encrPRDHKey(BUF_LEN, 0);\n\n string pub_keyB = SAMPLE_PUBLIC_KEY_B;\n\n vector s_shareG2(BUF_LEN, 0);\n PRINT_SRC_LINE\n status = trustedGetEncryptedSecretShareAES(eid, &errStatus, errMsg.data(), encrPRDHKey.data(), &encLen,\n result.data(),\n s_shareG2.data(),\n (char *) pub_keyB.data(), 2, 2, 1);\n\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* filter = GetInput(context, node, kFilterTensor);\n const TfLiteTensor* bias =\n (NumInputs(node) == 3) ? GetInput(context, node, kBiasTensor) : nullptr;\n TFLITE_DCHECK_EQ(input_type, input->type);\n\n switch (input_type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n if (filter->type == kTfLiteFloat32) {\n return EvalFloat(context, node, params, data, input,\n filter, bias, output);\n } else if (filter->type == kTfLiteInt8) {\n return EvalHybridPerChannel(context, node, params, data,\n input, filter, bias, output);\n } else {\n TF_LITE_KERNEL_LOG(\n context, \"Type %s with filter type %s not currently supported.\",\n TfLiteTypeGetName(input->type), TfLiteTypeGetName(filter->type));\n return kTfLiteError;\n }\n break;\n case kTfLiteUInt8:\n return EvalQuantized(context, node, params, data, input,\n filter, bias, output);\n break;\n case kTfLiteInt8:\n return EvalQuantizedPerChannel(context, node, params, data,\n input, filter, bias, output);\n break;\n case kTfLiteInt16:\n return EvalQuantizedPerChannel16x8(params, data, input, filter, bias,\n output);\n break;\n default:\n context->ReportError(context, \"Type %d not currently supported.\",\n input->type);\n return kTfLiteError;\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " int64_t size() const {\n return m_str ? m_str->size() : 0;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)\n{\n int dy = y1 - y0;\n int adx = x1 - x0;\n int ady = abs(dy);\n int base;\n int x=x0,y=y0;\n int err = 0;\n int sy;\n\n#ifdef STB_VORBIS_DIVIDE_TABLE\n if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {\n if (dy < 0) {\n base = -integer_divide_table[ady][adx];\n sy = base-1;\n } else {\n base = integer_divide_table[ady][adx];\n sy = base+1;\n }\n } else {\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n }\n#else\n base = dy / adx;\n if (dy < 0)\n sy = base - 1;\n else\n sy = base+1;\n#endif\n ady -= abs(base) * adx;\n if (x1 > n) x1 = n;\n if (x < x1) {\n LINE_OP(output[x], inverse_db_table[y&255]);\n for (++x; x < x1; ++x) {\n err += ady;\n if (err >= adx) {\n err -= adx;\n y += sy;\n } else\n y += base;\n LINE_OP(output[x], inverse_db_table[y&255]);\n }\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n switch (output->type) {\n case kTfLiteInt32: {\n // TensorFlow does not support negative for int32.\n TF_LITE_ENSURE_OK(context, CheckValue(context, input2));\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n case kTfLiteFloat32: {\n PowImpl(input1, input2, output, data->requires_broadcast);\n break;\n }\n default: {\n context->ReportError(context, \"Unsupported data type: %d\", output->type);\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "\t\tauto Phase3() -> Local final {\n\t\t\treturn Boolean::New(Isolate::GetCurrent(), result);\n\t\t}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-913", "cwe_name": "Improper Control of Dynamically-Managed Code Resources", "description": "The software does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.", "url": "https://cwe.mitre.org/data/definitions/913.html", "label_name": "vulnerable"} {"code": "selaGetCombName(SELA *sela,\n l_int32 size,\n l_int32 direction)\n{\nchar *selname;\nchar combname[L_BUF_SIZE];\nl_int32 i, nsels, sx, sy, found;\nSEL *sel;\n\n PROCNAME(\"selaGetCombName\");\n\n if (!sela)\n return (char *)ERROR_PTR(\"sela not defined\", procName, NULL);\n if (direction != L_HORIZ && direction != L_VERT)\n return (char *)ERROR_PTR(\"invalid direction\", procName, NULL);\n\n /* Derive the comb name we're looking for */\n if (direction == L_HORIZ)\n snprintf(combname, L_BUF_SIZE, \"sel_comb_%dh\", size);\n else /* direction == L_VERT */\n snprintf(combname, L_BUF_SIZE, \"sel_comb_%dv\", size);\n\n found = FALSE;\n nsels = selaGetCount(sela);\n for (i = 0; i < nsels; i++) {\n sel = selaGetSel(sela, i);\n selGetParameters(sel, &sy, &sx, NULL, NULL);\n if (sy != 1 && sx != 1) /* 2-D; not a comb */\n continue;\n selname = selGetName(sel);\n if (!strcmp(selname, combname)) {\n found = TRUE;\n break;\n }\n }\n\n if (found)\n return stringNew(selname);\n else\n return (char *)ERROR_PTR(\"sel not found\", procName, NULL);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteIntArray* input_dims = input->dims;\n int input_dims_size = input_dims->size;\n TF_LITE_ENSURE(context, input_dims_size >= 1);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n // Resize the output tensor.\n TfLiteIntArray* output_shape = TfLiteIntArrayCreate(input_dims_size + 1);\n for (int i = 0; i < input_dims_size; i++) {\n output_shape->data[i] = input_dims->data[i];\n }\n // Last dimension in the output is the same as the last dimension in the\n // input.\n output_shape->data[input_dims_size] = input_dims->data[input_dims_size - 1];\n output->type = input->type;\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_shape));\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void AverageEvalQuantizedUint8(TfLiteContext* context, TfLiteNode* node,\n TfLitePoolParams* params, OpData* data,\n const TfLiteTensor* input,\n TfLiteTensor* output) {\n int32_t activation_min;\n int32_t activation_max;\n (void)CalculateActivationRangeQuantized(context, params->activation, output,\n &activation_min, &activation_max);\n#define TF_LITE_AVERAGE_POOL(type) \\\n tflite::PoolParams op_params; \\\n op_params.stride_height = params->stride_height; \\\n op_params.stride_width = params->stride_width; \\\n op_params.filter_height = params->filter_height; \\\n op_params.filter_width = params->filter_width; \\\n op_params.padding_values.height = data->padding.height; \\\n op_params.padding_values.width = data->padding.width; \\\n op_params.quantized_activation_min = activation_min; \\\n op_params.quantized_activation_max = activation_max; \\\n type::AveragePool(op_params, GetTensorShape(input), \\\n GetTensorData(input), GetTensorShape(output), \\\n GetTensorData(output))\n if (kernel_type == kReference) {\n TF_LITE_AVERAGE_POOL(reference_ops);\n } else {\n TF_LITE_AVERAGE_POOL(optimized_ops);\n }\n#undef TF_LITE_AVERAGE_POOL\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": "QString Helper::temporaryMountDevice(const QString &device, const QString &name, bool readonly)\n{\n QString mount_point = mountPoint(device);\n\n if (!mount_point.isEmpty())\n return mount_point;\n\n mount_point = \"%1/.%2/mount/%3\";\n const QStringList &tmp_paths = QStandardPaths::standardLocations(QStandardPaths::TempLocation);\n\n mount_point = mount_point.arg(tmp_paths.isEmpty() ? \"/tmp\" : tmp_paths.first()).arg(qApp->applicationName()).arg(name);\n\n if (!QDir::current().mkpath(mount_point)) {\n dCError(\"mkpath \\\"%s\\\" failed\", qPrintable(mount_point));\n\n return QString();\n }\n\n if (!mountDevice(device, mount_point, readonly)) {\n dCError(\"Mount the device \\\"%s\\\" to \\\"%s\\\" failed\", qPrintable(device), qPrintable(mount_point));\n\n return QString();\n }\n\n return mount_point;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "vulnerable"} {"code": "Variant HHVM_FUNCTION(apc_store,\n const Variant& key_or_array,\n const Variant& var /* = null */,\n int64_t ttl /* = 0 */) {\n if (!apcExtension::Enable) return Variant(false);\n\n if (key_or_array.isArray()) {\n Array valuesArr = key_or_array.toArray();\n\n for (ArrayIter iter(valuesArr); iter; ++iter) {\n Variant key = iter.first();\n if (!key.isString()) {\n throw_invalid_argument(\"apc key: (not a string)\");\n return Variant(false);\n }\n Variant v = iter.second();\n\n auto const& strKey = key.toCStrRef();\n if (isKeyInvalid(strKey)) {\n throw_invalid_argument(\"apc key: (contains invalid characters)\");\n return Variant(false);\n }\n apc_store().set(strKey, v, ttl);\n }\n return Variant(ArrayData::Create());\n }\n\n if (!key_or_array.isString()) {\n throw_invalid_argument(\"apc key: (not a string)\");\n return Variant(false);\n }\n String strKey = key_or_array.toString();\n\n if (isKeyInvalid(strKey)) {\n throw_invalid_argument(\"apc key: (contains invalid characters)\");\n return Variant(false);\n }\n apc_store().set(strKey, var, ttl);\n return Variant(true);\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " TfLiteRegistration CancelOpRegistration() {\n TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};\n\n // Set output size to the input size in CancelOp::Prepare(). Code exists to\n // have a framework in Prepare. The input and output tensors are not used.\n reg.prepare = [](TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* in_tensor = GetInput(context, node, 0);\n TfLiteTensor* out_tensor = GetOutput(context, node, 0);\n TfLiteIntArray* new_size = TfLiteIntArrayCopy(in_tensor->dims);\n return context->ResizeTensor(context, out_tensor, new_size);\n };\n\n reg.invoke = [](TfLiteContext* context, TfLiteNode* node) {\n cancellation_data_.is_cancelled = true;\n return kTfLiteOk;\n };\n return reg;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus EvalHashtableImport(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputResourceIdTensor,\n &input_resource_id_tensor));\n const int resource_id = input_resource_id_tensor->data.i32[0];\n\n const TfLiteTensor* key_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kKeyTensor, &key_tensor));\n const TfLiteTensor* value_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kValueTensor, &value_tensor));\n\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n auto& resources = subgraph->resources();\n auto* lookup = resource::GetHashtableResource(&resources, resource_id);\n TF_LITE_ENSURE(context, lookup != nullptr);\n TF_LITE_ENSURE_STATUS(\n lookup->CheckKeyAndValueTypes(context, key_tensor, value_tensor));\n // The hashtable resource will only be initialized once, attempting to\n // initialize it multiple times will be a no-op.\n auto result = lookup->Import(context, key_tensor, value_tensor);\n return result;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TEST_CASE_METHOD(TestFixture, \"DKG AES gen test\", \"[dkg-aes-gen]\") {\n vector encryptedDKGSecret(BUF_LEN, 0);\n vector errMsg(BUF_LEN, 0);\n\n int errStatus = 0;\n uint32_t encLen = 0;\n\n PRINT_SRC_LINE\n auto status = trustedGenDkgSecretAES(eid, &errStatus, errMsg.data(), encryptedDKGSecret.data(), &encLen, 32);\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n\n vector secret(BUF_LEN, 0);\n vector errMsg1(BUF_LEN, 0);\n\n status = trustedDecryptDkgSecretAES(eid, &errStatus, errMsg1.data(), encryptedDKGSecret.data(),\n encLen, (uint8_t *) secret.data());\n\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "static ssize_t _hostfs_read(oe_fd_t* desc, void* buf, size_t count)\n{\n ssize_t ret = -1;\n file_t* file = _cast_file(desc);\n\n if (!file)\n OE_RAISE_ERRNO(OE_EINVAL);\n\n /* Call the host to perform the read(). */\n if (oe_syscall_read_ocall(&ret, file->host_fd, buf, count) != OE_OK)\n OE_RAISE_ERRNO(OE_EINVAL);\n\ndone:\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " static TfLiteRegistration DelegateRegistration() {\n TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};\n\n reg.prepare = [](TfLiteContext* context, TfLiteNode* node) {\n // If tensors are resized, the runtime should propagate shapes\n // automatically if correct flag is set. Ensure values are correct.\n // Output 0 should be dynamic.\n TfLiteTensor* output0 = GetOutput(context, node, 0);\n TF_LITE_ENSURE(context, IsDynamicTensor(output0));\n // Output 1 has the same shape as input.\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output1 = GetOutput(context, node, 1);\n TF_LITE_ENSURE(context, input->dims->size == output1->dims->size);\n TF_LITE_ENSURE(context, input->dims->data[0] == output1->dims->data[0]);\n return kTfLiteOk;\n };\n\n return reg;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "String UTF16BEDecoder::to_utf8(const StringView& input)\n{\n StringBuilder builder(input.length() / 2);\n for (size_t i = 0; i < input.length(); i += 2) {\n u16 code_point = (input[i] << 8) | input[i + 1];\n builder.append_code_point(code_point);\n }\n return builder.to_string();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLitePackParams* data =\n reinterpret_cast(node->builtin_data);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n switch (output->type) {\n case kTfLiteFloat32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteUInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt8: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt16: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt32: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n case kTfLiteInt64: {\n return PackImpl(context, node, output, data->values_count,\n data->axis);\n }\n default: {\n context->ReportError(context, \"Type '%s' is not supported by pack.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n EvalMul(context, node, params, data, input1, input2, output);\n } else if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16) {\n TF_LITE_ENSURE_OK(\n context, EvalQuantized(context, node, params, data, input1,\n input2, output));\n } else {\n context->ReportError(context,\n \"Mul only supports FLOAT32, INT32 and quantized UINT8,\"\n \" INT8 and INT16 now, got %d.\",\n output->type);\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output_tensor != nullptr);\n TfLiteType output_type = output_tensor->type;\n\n switch (output_type) { // Already know in/outtypes are same.\n case kTfLiteFloat32:\n EvalUnquantized(context, node);\n break;\n case kTfLiteInt32:\n EvalUnquantized(context, node);\n break;\n case kTfLiteUInt8:\n EvalQuantizedUInt8(context, node);\n break;\n case kTfLiteInt8:\n EvalUnquantized(context, node);\n break;\n case kTfLiteInt64:\n EvalUnquantized(context, node);\n break;\n\n default:\n TF_LITE_KERNEL_LOG(\n context, \"Op Concatenation does not currently support Type '%s'.\",\n TfLiteTypeGetName(output_type));\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList,\n const char* Name,\n cmsUInt16Number PCS[3], cmsUInt16Number Colorant[cmsMAXCHANNELS])\n{\n cmsUInt32Number i;\n\n if (NamedColorList == NULL) return FALSE;\n\n if (NamedColorList ->nColors + 1 > NamedColorList ->Allocated) {\n if (!GrowNamedColorList(NamedColorList)) return FALSE;\n }\n\n for (i=0; i < NamedColorList ->ColorantCount; i++)\n NamedColorList ->List[NamedColorList ->nColors].DeviceColorant[i] = Colorant == NULL? 0 : Colorant[i];\n\n for (i=0; i < 3; i++)\n NamedColorList ->List[NamedColorList ->nColors].PCS[i] = PCS == NULL ? 0 : PCS[i];\n\n if (Name != NULL) {\n\n strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, cmsMAX_PATH-1);\n NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0;\n\n }\n else\n NamedColorList ->List[NamedColorList ->nColors].Name[0] = 0;\n\n\n NamedColorList ->nColors++;\n return TRUE;\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "int IniSection::Write (const YCPPath&p, const YCPValue&v, bool rewrite)\n{\n if (ip->isFlat ())\n\treturn setValueFlat (p, v);\n\n if (p->length() >= 1 && p->component_str (0) == \"all\")\n {\n\treturn setAll (p, v, 1);\n }\n\n if (p->length() < 2)\n {\n\ty2error (\"I do not know what to write to %s.\", p->toString().c_str());\n\treturn -1;\n }\n string s = p->component_str (0);\n if (s == \"v\" || s == \"value\")\n\treturn setValue (p, v, 0, 1);\n if (s == \"vc\" || s == \"value_comment\" || s == \"valuecomment\")\n return setValue (p, v, 1, 1);\n if (s == \"vt\" || s == \"value_type\" || s == \"valuetype\")\n return setValue (p, v, 2, 1);\n if (s == \"s\" || s == \"section\" || s == \"sc\" || s == \"section_comment\" || s == \"sectioncomment\")\n return setSectionProp (p, v, 0, 1);\n if (s == \"st\" || s == \"section_type\" || s == \"sectiontype\")\n return setSectionProp (p, v, rewrite? 1:2, 1);\n if (s == \"section_private\")\n return setSectionProp (p, v, 3, 1);\n\n return -1;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "void Triangle(double x1,double y1,double x2,double y2,double x3,double y3) {\n outpos +=\n sprintf(outpos,\"\\n %12.3f %12.3f m %12.3f %12.3f l %12.3f %12.3f l h\",x1,y1,x2,y2,x3,y3);\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "char *ReadInput(char *filename)\n{\n FILE *finput;\n long filesize, num;\n char *buffer;\n if ( ( finput = fopen(filename,\"r\") ) == 0 ) {\n fprintf(stderr,\"%s: Cannot open file %s\\n\",axohelp,filename);\n exit(1);\n }\n if ( ( fseek(finput,0,SEEK_END) != 0 )\n || ( ( filesize = ftell(finput) ) < 0 )\n || ( fseek(finput,0,SEEK_SET) != 0 ) ) {\n fprintf(stderr,\"%s: File error in file %s\\n\",axohelp,filename);\n exit(1);\n }\n if ( ( buffer = malloc((filesize+1)*sizeof(char)) ) == 0 ) {\n fprintf(stderr,\"%s: Error allocating %ld bytes of memory\",axohelp,filesize+1);\n exit(1);\n }\n/*\n Assume character in file is 1 byte, which is true for all cases\n we currently encounter.\n*/\n num = fread( buffer, 1, filesize, finput );\n if ( ferror(finput) ) {\n fprintf(stderr,\"%s: Error reading file %s\\n\",axohelp,filename);\n exit(1);\n }\n/*\n By definition, fread reads ALL the items specified, or it gets to\n end-of-file, or there is an error.\n It returns the actual number of items successfully read, which\n is less than the number given in the 3rd argument ONLY if a\n read error or end-of-file is encountered.\n We have already tested for an error.\n But num could legitimately be less than filesize, because of\n translation of CRLF to LF (on MSWindows with MSWindows text file).\n*/\n buffer[num] = 0;\n fclose(finput);\n return(buffer);\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "TEST_F(QuantizedConv2DTest, OddPaddingBatch) {\n const int stride = 2;\n TF_ASSERT_OK(NodeDefBuilder(\"quantized_conv_op\", \"QuantizedConv2D\")\n .Input(FakeInput(DT_QUINT8))\n .Input(FakeInput(DT_QUINT8))\n .Input(FakeInput(DT_FLOAT))\n .Input(FakeInput(DT_FLOAT))\n .Input(FakeInput(DT_FLOAT))\n .Input(FakeInput(DT_FLOAT))\n .Attr(\"out_type\", DataTypeToEnum::v())\n .Attr(\"strides\", {1, stride, stride, 1})\n .Attr(\"padding\", \"SAME\")\n .Finalize(node_def()));\n TF_ASSERT_OK(InitOp());\n\n const int depth = 1;\n const int image_width = 4;\n const int image_height = 4;\n const int image_batch_count = 3;\n AddInputFromArray(\n TensorShape({image_batch_count, image_height, image_width, depth}),\n {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});\n const int filter_size = 3;\n const int filter_count = 1;\n AddInputFromArray(\n TensorShape({filter_size, filter_size, depth, filter_count}),\n {1, 2, 3, 4, 5, 6, 7, 8, 9});\n AddInputFromArray(TensorShape({1}), {0});\n AddInputFromArray(TensorShape({1}), {255.0f});\n AddInputFromArray(TensorShape({1}), {0});\n AddInputFromArray(TensorShape({1}), {255.0f});\n\n TF_ASSERT_OK(RunOpKernel());\n const int expected_width = image_width / stride;\n const int expected_height = (image_height * filter_count) / stride;\n Tensor expected(DT_QINT32, TensorShape({image_batch_count, expected_height,\n expected_width, filter_count}));\n test::FillValues(&expected, {348, 252, 274, 175, //\n 348, 252, 274, 175, //\n 348, 252, 274, 175});\n test::ExpectTensorEqual(expected, *GetOutput(0));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n auto* data =\n reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 1);\n\n TF_LITE_ENSURE_EQ(context, input->type, kTfLiteInt16);\n output->type = kTfLiteInt32;\n if (data->out_float) {\n output->type = kTfLiteFloat32;\n }\n\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(2);\n int num_frames = 0;\n if (input->dims->data[0] >= data->state->window.size) {\n num_frames = (input->dims->data[0] - data->state->window.size) /\n data->state->window.step / data->frame_stride +\n 1;\n }\n output_size->data[0] = num_frames;\n output_size->data[1] = data->state->filterbank.num_channels *\n (1 + data->left_context + data->right_context);\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* axis = GetInput(context, node, 0);\n TF_LITE_ENSURE(context, axis != nullptr);\n\n // Dynamic output tensors are needed if axis tensor is not constant.\n // But Micro doesn't support dynamic memory allocation, so we only support\n // constant axis tensor for now.\n TF_LITE_ENSURE_MSG(context, IsConstantTensor(axis),\n \"Non constant axis tensor not supported\");\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static int bmp_dec_parseopts(char *optstr, bmp_dec_importopts_t *opts)\n{\n\tjas_tvparser_t *tvp;\n\n\topts->max_samples = 128 * JAS_MEBI;\n\n\tif (!(tvp = jas_tvparser_create(optstr ? optstr : \"\"))) {\n\t\treturn -1;\n\t}\n\n\twhile (!jas_tvparser_next(tvp)) {\n\t\tswitch (jas_taginfo_nonull(jas_taginfos_lookup(decopts,\n\t\t jas_tvparser_gettag(tvp)))->id) {\n\t\tcase OPT_MAXSIZE:\n\t\t\topts->max_samples = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tjas_eprintf(\"warning: ignoring invalid option %s\\n\",\n\t\t\t jas_tvparser_gettag(tvp));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tjas_tvparser_destroy(tvp);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)\n{\n\tstruct x86_emulate_ops *ops = ctxt->ops;\n\tu32 eax, ebx, ecx, edx;\n\n\t/*\n\t * syscall should always be enabled in longmode - so only become\n\t * vendor specific (cpuid) if other modes are active...\n\t */\n\tif (ctxt->mode == X86EMUL_MODE_PROT64)\n\t\treturn true;\n\n\teax = 0x00000000;\n\tecx = 0x00000000;\n\tif (ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx)) {\n\t\t/*\n\t\t * Intel (\"GenuineIntel\")\n\t\t * remark: Intel CPUs only support \"syscall\" in 64bit\n\t\t * longmode. Also an 64bit guest with a\n\t\t * 32bit compat-app running will #UD !! While this\n\t\t * behaviour can be fixed (by emulating) into AMD\n\t\t * response - CPUs of AMD can't behave like Intel.\n\t\t */\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx &&\n\t\t ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx &&\n\t\t edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx)\n\t\t\treturn false;\n\n\t\t/* AMD (\"AuthenticAMD\") */\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx &&\n\t\t ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx &&\n\t\t edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx)\n\t\t\treturn true;\n\n\t\t/* AMD (\"AMDisbetter!\") */\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx &&\n\t\t ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx &&\n\t\t edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx)\n\t\t\treturn true;\n\t}\n\n\t/* default: (not Intel, not AMD), apply Intel's stricter rules... */\n\treturn false;\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " void Compute(OpKernelContext* ctx) override {\n const Tensor& sorted_inputs_t = ctx->input(0);\n const Tensor& values_t = ctx->input(1);\n\n // inputs must be at least a matrix\n OP_REQUIRES(\n ctx, sorted_inputs_t.shape().dims() >= 2,\n errors::InvalidArgument(\"sorted input argument must be a matrix\"));\n // must have same batch dim_size for both\n OP_REQUIRES(ctx, sorted_inputs_t.dim_size(0) == values_t.dim_size(0),\n Status(error::INVALID_ARGUMENT,\n \"Leading dim_size of both tensors must match.\"));\n\n // this is required because we do indexing in int32 on the GPU\n OP_REQUIRES(ctx, values_t.NumElements() < std::numeric_limits::max(),\n Status(error::INVALID_ARGUMENT,\n \"values tensor size must less than INT_MAX\"));\n\n Tensor* output_t;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, values_t.shape(), &output_t));\n\n if (output_t->dtype() == DT_INT32) {\n OP_REQUIRES(ctx,\n FastBoundsCheck(sorted_inputs_t.dim_size(1),\n std::numeric_limits::max()),\n errors::InvalidArgument(\"trailing dim_size must less than \"\n \"INT_MAX for int32 output type, was \",\n sorted_inputs_t.dim_size(1)));\n }\n\n auto output = output_t->template flat();\n const auto sorted_inputs = sorted_inputs_t.template flat();\n const auto values = values_t.template flat();\n OP_REQUIRES_OK(\n ctx, functor::LowerBoundFunctor::Compute(\n ctx, sorted_inputs, values, sorted_inputs_t.dim_size(0),\n sorted_inputs_t.dim_size(1), values_t.dim_size(1), &output));\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "HexOutStream::HexOutStream(OutStream& os, int buflen)\n: out_stream(os), offset(0), bufSize(buflen ? buflen : DEFAULT_BUF_LEN)\n{\n if (bufSize % 2)\n bufSize--;\n ptr = start = new U8[bufSize];\n end = start + bufSize;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "int Archive::Read(void *Data,size_t Size)\n{\n size_t Result;\n if (QOpen.Read(Data,Size,Result))\n return (int)Result;\n return File::Read(Data,Size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n // TODO(ahentz): these two checks would make the new implementation\n // incompatible with some existing models, where params is not specified. It\n // is OK not to have them because toco would have set input and output types\n // to match the parameters.\n // auto* params = reinterpret_cast(node->builtin_data);\n // TF_LITE_ENSURE_EQ(context, input->type, params->in_data_type);\n // TF_LITE_ENSURE_EQ(context, output->type, params->out_data_type);\n\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " Status ValidateInputs(const CSRSparseMatrix& sparse_matrix,\n const Tensor& permutation_indices, int* batch_size,\n int64* num_rows) {\n if (sparse_matrix.dtype() != DataTypeToEnum::value)\n return errors::InvalidArgument(\n \"Asked for a CSRSparseMatrix of type \",\n DataTypeString(DataTypeToEnum::value),\n \" but saw dtype: \", DataTypeString(sparse_matrix.dtype()));\n\n const Tensor& dense_shape = sparse_matrix.dense_shape();\n const int rank = dense_shape.dim_size(0);\n if (rank < 2 || rank > 3)\n return errors::InvalidArgument(\"sparse matrix must have rank 2 or 3; \",\n \"but dense_shape has size \", rank);\n const int row_dim = (rank == 2) ? 0 : 1;\n auto dense_shape_vec = dense_shape.vec();\n *num_rows = dense_shape_vec(row_dim);\n const int64 num_cols = dense_shape_vec(row_dim + 1);\n if (*num_rows != num_cols)\n return errors::InvalidArgument(\n \"sparse matrix must be square; got: \", *num_rows, \" != \", num_cols);\n const TensorShape& perm_shape = permutation_indices.shape();\n if (perm_shape.dims() + 1 != rank)\n return errors::InvalidArgument(\n \"sparse matrix must have the same rank as permutation; got: \", rank,\n \" != \", perm_shape.dims(), \" + 1.\");\n if (perm_shape.dim_size(rank - 2) != *num_rows)\n return errors::InvalidArgument(\n \"permutation must have the same number of elements in each batch \"\n \"as the number of rows in sparse matrix; got: \",\n perm_shape.dim_size(rank - 2), \" != \", *num_rows);\n\n *batch_size = sparse_matrix.batch_size();\n if (*batch_size > 1) {\n if (perm_shape.dim_size(0) != *batch_size)\n return errors::InvalidArgument(\n \"permutation must have the same batch size \"\n \"as sparse matrix; got: \",\n perm_shape.dim_size(0), \" != \", *batch_size);\n }\n\n return Status::OK();\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "void Rectangle(double x,double y,double w,double h) {\n sprintf(outputbuffer,\"\\n %12.3f %12.3f %12.3f %12.3f re\",x,y,w,h);\n sendClean(outputbuffer);\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "TEST(SegmentSumOpModelTest, TestFailIfSegmentsAreNotConsecutive) {\n SegmentSumOpModel model({TensorType_INT32, {3, 2}},\n {TensorType_INT32, {3}});\n model.PopulateTensor(model.data(), {1, 2, 3, 4, 5, 6});\n model.PopulateTensor(model.segment_ids(), {0, 3, 5});\n ASSERT_EQ(model.InvokeUnchecked(), kTfLiteError);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "inline bool SegmentReader::amplifiedRead(WordCount virtualAmount) {\n return readLimiter->canRead(virtualAmount, arena);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": "bool RequestParser::OnHeadersEnd() {\n bool matched = view_matcher_(request_->method(), request_->url().path(),\n &stream_);\n\n if (!matched) {\n LOG_WARN(\"No view matches the request: %s %s\", request_->method().c_str(),\n request_->url().path().c_str());\n }\n\n return matched;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "inline void AveragePool(const uint8* input_data, const Dims<4>& input_dims,\n int stride_width, int stride_height, int pad_width,\n int pad_height, int filter_width, int filter_height,\n int32 output_activation_min,\n int32 output_activation_max, uint8* output_data,\n const Dims<4>& output_dims) {\n tflite::PoolParams params;\n params.stride_height = stride_height;\n params.stride_width = stride_width;\n params.filter_height = filter_height;\n params.filter_width = filter_width;\n params.padding_values.height = pad_height;\n params.padding_values.width = pad_width;\n params.quantized_activation_min = output_activation_min;\n params.quantized_activation_max = output_activation_max;\n AveragePool(params, DimsToShape(input_dims), input_data,\n DimsToShape(output_dims), output_data);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": " Status BuildInputArgIndex(const OpDef::ArgDef& arg_def, AttrSlice attr_values,\n const FunctionDef::ArgAttrs* arg_attrs,\n bool ints_on_device,\n int64_t resource_arg_unique_id) {\n bool is_type_list;\n DataTypeVector dtypes;\n TF_RETURN_IF_ERROR(\n ArgNumType(attr_values, arg_def, &is_type_list, &dtypes));\n if (dtypes.size() < size_t{1}) {\n return errors::Internal(\"Expected a list of at least one dtype\");\n }\n int arg_index = result_.nodes.size();\n TF_RETURN_IF_ERROR(\n AddItem(arg_def.name(), {true, arg_index, 0, is_type_list, dtypes}));\n // Creates dtypes.size() nodes in the graph.\n for (size_t i = 0; i < dtypes.size(); ++i) {\n TF_RETURN_IF_ERROR(AddItem(strings::StrCat(arg_def.name(), \":\", i),\n {true, arg_index, 0, false, {dtypes[i]}}));\n DCHECK_EQ(arg_index, result_.nodes.size());\n string name = arg_def.name();\n if (dtypes.size() > 1) {\n strings::StrAppend(&name, \"_\", i);\n }\n NodeDef* gnode = AddNode(name);\n if (ints_on_device && dtypes[i] == DataType::DT_INT32) {\n gnode->set_op(FunctionLibraryDefinition::kDeviceArgOp);\n } else {\n gnode->set_op(FunctionLibraryDefinition::kArgOp);\n }\n DataType dtype = arg_def.is_ref() ? MakeRefType(dtypes[i]) : dtypes[i];\n AddAttr(\"T\", dtype, gnode);\n AddAttr(\"index\", arg_index, gnode);\n if (resource_arg_unique_id >= 0) {\n AddAttr(\"_resource_arg_unique_id\", resource_arg_unique_id, gnode);\n }\n if (arg_attrs) {\n for (const auto& arg_attr : arg_attrs->attr()) {\n AddAttr(arg_attr.first, arg_attr.second, gnode->mutable_attr());\n }\n }\n result_.arg_types.push_back(dtypes[i]);\n ++arg_index;\n }\n return Status::OK();\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "vulnerable"} {"code": "void AllocateDataSet(cmsIT8* it8)\n{\n TABLE* t = GetTable(it8);\n\n if (t -> Data) return; // Already allocated\n\n t-> nSamples = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_FIELDS\"));\n t-> nPatches = atoi(cmsIT8GetProperty(it8, \"NUMBER_OF_SETS\"));\n\n if (t -> nSamples < 0 || t->nSamples > 0x7ffe || t->nPatches < 0 || t->nPatches > 0x7ffe)\n {\n SynError(it8, \"AllocateDataSet: too much data\");\n }\n else {\n t->Data = (char**)AllocChunk(it8, ((cmsUInt32Number)t->nSamples + 1) * ((cmsUInt32Number)t->nPatches + 1) * sizeof(char*));\n if (t->Data == NULL) {\n\n SynError(it8, \"AllocateDataSet: Unable to allocate data array\");\n }\n }\n\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "inline typename V::VectorType FBUnserializer::unserializeVector() {\n p_ += CODE_SIZE;\n\n typename V::VectorType ret = V::createVector();\n\n size_t code = nextCode();\n while (code != FB_SERIALIZE_STOP) {\n V::vectorAppend(ret, unserializeThing());\n code = nextCode();\n }\n p_ += CODE_SIZE;\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "vulnerable"} {"code": "TfLiteStatus LogSoftmaxPrepare(TfLiteContext* context, TfLiteNode* node) {\n LogSoftmaxOpData* data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n if (input->type == kTfLiteUInt8 || input->type == kTfLiteInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.scale, 16.0 / 256);\n static const double kBeta = 1.0;\n if (input->type == kTfLiteUInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.zero_point, 255);\n data->params.table = data->f_table;\n optimized_ops::PopulateSoftmaxLookupTable(&data->params,\n input->params.scale, kBeta);\n data->params.zero_point = output->params.zero_point;\n data->params.scale = output->params.scale;\n }\n if (input->type == kTfLiteInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.zero_point, 127);\n static const int kScaledDiffIntegerBits = 5;\n tflite::PreprocessLogSoftmaxScalingExp(\n kBeta, input->params.scale, kScaledDiffIntegerBits,\n &data->input_multiplier, &data->input_left_shift,\n &data->reverse_scaling_divisor, &data->reverse_scaling_right_shift);\n data->reverse_scaling_right_shift *= -1;\n data->diff_min =\n -1.0 * tflite::CalculateInputRadius(kScaledDiffIntegerBits,\n data->input_left_shift);\n }\n }\n\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(input1, input2, output,\n requires_broadcast);\n break;\n default:\n context->ReportError(context,\n \"Does not support type %d, requires float|int|uint8\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus PrepareHashtableImport(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 0);\n\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputResourceIdTensor,\n &input_resource_id_tensor));\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1);\n\n const TfLiteTensor* key_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kKeyTensor, &key_tensor));\n const TfLiteTensor* value_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kValueTensor, &value_tensor));\n TF_LITE_ENSURE(context, (key_tensor->type == kTfLiteInt64 &&\n value_tensor->type == kTfLiteString) ||\n (key_tensor->type == kTfLiteString &&\n value_tensor->type == kTfLiteInt64));\n // TODO(b/144731295): Tensorflow lookup ops support 1-D vector in storing\n // values.\n TF_LITE_ENSURE(context, HaveSameShapes(key_tensor, value_tensor));\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void ServerSecurityFeature::collectOptions(std::shared_ptr options) {\n options->addOption(\"--server.harden\",\n \"lock down REST APIs that reveal version information or server \"\n \"internals for non-admin users\",\n new BooleanParameter(&_hardenedRestApi))\n .setIntroducedIn(30500);\n\n options->addOption(\"--foxx.api\", \"enables Foxx management REST APIs\",\n new BooleanParameter(&_enableFoxxApi),\n arangodb::options::makeFlags(\n arangodb::options::Flags::DefaultNoComponents,\n arangodb::options::Flags::OnCoordinator,\n arangodb::options::Flags::OnSingle))\n .setIntroducedIn(30500);\n options->addOption(\"--foxx.store\", \"enables Foxx store in web interface\",\n new BooleanParameter(&_enableFoxxStore),\n arangodb::options::makeFlags(\n arangodb::options::Flags::DefaultNoComponents,\n arangodb::options::Flags::OnCoordinator,\n arangodb::options::Flags::OnSingle))\n .setIntroducedIn(30500);\n\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "static INLINE BOOL zgfx_GetBits(ZGFX_CONTEXT* _zgfx, UINT32 _nbits)\n{\n\tif (!_zgfx)\n\t\treturn FALSE;\n\n\twhile (_zgfx->cBitsCurrent < _nbits)\n\t{\n\t\t_zgfx->BitsCurrent <<= 8;\n\n\t\tif (_zgfx->pbInputCurrent < _zgfx->pbInputEnd)\n\t\t\t_zgfx->BitsCurrent += *(_zgfx->pbInputCurrent)++;\n\n\t\t_zgfx->cBitsCurrent += 8;\n\t}\n\n\t_zgfx->cBitsRemaining -= _nbits;\n\t_zgfx->cBitsCurrent -= _nbits;\n\t_zgfx->bits = _zgfx->BitsCurrent >> _zgfx->cBitsCurrent;\n\t_zgfx->BitsCurrent &= ((1 << _zgfx->cBitsCurrent) - 1);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " void Init(void)\n {\n for(int i = 0;i < 18;i++) {\n X[i].Init();\n M[i].Init();\n }\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "TfLiteStatus ReluEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n const ReluOpData* data = reinterpret_cast(node->user_data);\n switch (input->type) {\n case kTfLiteFloat32: {\n optimized_ops::Relu(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } break;\n // TODO(renjieliu): We may revisit the quantization calculation logic,\n // the unbounded upper limit is actually hard to quantize.\n case kTfLiteUInt8: {\n QuantizedReluX(0.0f, std::numeric_limits::infinity(),\n input, output, data);\n } break;\n case kTfLiteInt8: {\n QuantizedReluX(0.0f, std::numeric_limits::infinity(),\n input, output, data);\n } break;\n default:\n TF_LITE_KERNEL_LOG(\n context, \"Only float32 & int8/uint8 is supported currently, got %s.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(input1, input2, output,\n requires_broadcast);\n break;\n default:\n context->ReportError(context,\n \"Does not support type %d, requires float|int|uint8\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " bool isPrivate() const { return is_private; }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 2);\n\n const TfLiteTensor* lookup = GetInput(context, node, 0);\n TF_LITE_ENSURE_EQ(context, NumDimensions(lookup), 1);\n TF_LITE_ENSURE_EQ(context, lookup->type, kTfLiteInt32);\n\n const TfLiteTensor* key = GetInput(context, node, 1);\n TF_LITE_ENSURE_EQ(context, NumDimensions(key), 1);\n TF_LITE_ENSURE_EQ(context, key->type, kTfLiteInt32);\n\n const TfLiteTensor* value = GetInput(context, node, 2);\n TF_LITE_ENSURE(context, NumDimensions(value) >= 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(key, 0),\n SizeOfDimension(value, 0));\n if (value->type == kTfLiteString) {\n TF_LITE_ENSURE_EQ(context, NumDimensions(value), 1);\n }\n\n TfLiteTensor* hits = GetOutput(context, node, 1);\n TF_LITE_ENSURE_EQ(context, hits->type, kTfLiteUInt8);\n TfLiteIntArray* hitSize = TfLiteIntArrayCreate(1);\n hitSize->data[0] = SizeOfDimension(lookup, 0);\n\n TfLiteTensor* output = GetOutput(context, node, 0);\n TF_LITE_ENSURE_EQ(context, value->type, output->type);\n\n TfLiteStatus status = kTfLiteOk;\n if (output->type != kTfLiteString) {\n TfLiteIntArray* outputSize = TfLiteIntArrayCreate(NumDimensions(value));\n outputSize->data[0] = SizeOfDimension(lookup, 0);\n for (int i = 1; i < NumDimensions(value); i++) {\n outputSize->data[i] = SizeOfDimension(value, i);\n }\n status = context->ResizeTensor(context, output, outputSize);\n }\n if (context->ResizeTensor(context, hits, hitSize) != kTfLiteOk) {\n status = kTfLiteError;\n }\n return status;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static int em_loop(struct x86_emulate_ctxt *ctxt)\n{\n\tregister_address_increment(ctxt, reg_rmw(ctxt, VCPU_REGS_RCX), -1);\n\tif ((address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) != 0) &&\n\t (ctxt->b == 0xe2 || test_cc(ctxt->b ^ 0x5, ctxt->eflags)))\n\t\tjmp_rel(ctxt, ctxt->src.val);\n\n\treturn X86EMUL_CONTINUE;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 4);\n\n auto data_type = output->type;\n TF_LITE_ENSURE(context,\n data_type == kTfLiteFloat32 || data_type == kTfLiteUInt8 ||\n data_type == kTfLiteInt8 || data_type == kTfLiteInt32 ||\n data_type == kTfLiteInt64);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n const int block_size = params->block_size;\n const int input_height = input->dims->data[1];\n const int input_width = input->dims->data[2];\n int output_height = input_height / block_size;\n int output_width = input_width / block_size;\n\n TF_LITE_ENSURE_EQ(context, input_height, output_height * block_size);\n TF_LITE_ENSURE_EQ(context, input_width, output_width * block_size);\n\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(4);\n output_size->data[0] = input->dims->data[0];\n output_size->data[1] = output_height;\n output_size->data[2] = output_width;\n output_size->data[3] = input->dims->data[3] * block_size * block_size;\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TEST_P(SslSPIFFECertValidatorIntegrationTest, ServerRsaSPIFFEValidatorSANNotMatch) {\n auto typed_conf = new envoy::config::core::v3::TypedExtensionConfig();\n TestUtility::loadFromYaml(TestEnvironment::substitute(R\"EOF(\nname: envoy.tls.cert_validator.spiffe\ntyped_config:\n \"@type\": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig\n trust_domains:\n - name: lyft.com\n trust_bundle:\n filename: \"{{ test_rundir }}/test/config/integration/certs/cacert.pem\"\n )EOF\"),\n *typed_conf);\n custom_validator_config_ = typed_conf;\n\n envoy::type::matcher::v3::StringMatcher matcher;\n matcher.set_prefix(\"spiffe://example.com/\");\n // The cert has \"DNS.1 = lyft.com\" but SPIFFE validator must ignore SAN types other than URI.\n matcher.set_prefix(\"www.lyft.com\");\n san_matchers_ = {matcher};\n initialize();\n auto conn = makeSslClientConnection({});\n if (tls_version_ == envoy::extensions::transport_sockets::tls::v3::TlsParameters::TLSv1_2) {\n auto codec = makeRawHttpConnection(std::move(conn), absl::nullopt);\n EXPECT_FALSE(codec->connected());\n } else {\n auto codec = makeHttpConnection(std::move(conn));\n ASSERT_TRUE(codec->waitForDisconnect());\n codec->close();\n }\n checkVerifyErrorCouter(1);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "std::shared_ptr getTestDBC() {\n auto dbc = SQLiteDBManager::getUnique();\n char* err = nullptr;\n std::vector queries = {\n \"CREATE TABLE test_table (username varchar(30) primary key, age int)\",\n \"INSERT INTO test_table VALUES (\\\"mike\\\", 23)\",\n \"INSERT INTO test_table VALUES (\\\"matt\\\", 24)\"};\n\n for (auto q : queries) {\n sqlite3_exec(dbc->db(), q.c_str(), nullptr, nullptr, &err);\n if (err != nullptr) {\n throw std::domain_error(std::string(\"Cannot create testing DBC's db: \") +\n err);\n }\n }\n\n return dbc;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": "static int _hostsock_getsockname(\n oe_fd_t* sock_,\n struct oe_sockaddr* addr,\n oe_socklen_t* addrlen)\n{\n int ret = -1;\n sock_t* sock = _cast_sock(sock_);\n oe_socklen_t addrlen_in = 0;\n\n oe_errno = 0;\n\n if (!sock)\n OE_RAISE_ERRNO(OE_EINVAL);\n\n if (addrlen)\n addrlen_in = *addrlen;\n\n if (oe_syscall_getsockname_ocall(\n &ret,\n sock->host_fd,\n (struct oe_sockaddr*)addr,\n addrlen_in,\n addrlen) != OE_OK)\n {\n OE_RAISE_ERRNO(OE_EINVAL);\n }\n\ndone:\n\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " int length() const {\n return m_str ? m_str->size() : 0;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "R_API RBinJavaAttrInfo *r_bin_java_annotation_default_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = NULL;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr && sz >= offset) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_ANNOTATION_DEFAULT_ATTR;\n\t\tattr->info.annotation_default_attr.default_value = r_bin_java_element_value_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\tif (attr->info.annotation_default_attr.default_value) {\n\t\t\toffset += attr->info.annotation_default_attr.default_value->size;\n\t\t}\n\t}\n\tr_bin_java_print_annotation_default_attr_summary (attr);\n\treturn attr;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "TfLiteStatus LeakyReluPrepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n LeakyReluOpData* data = reinterpret_cast(node->user_data);\n\n if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16) {\n const auto* params =\n reinterpret_cast(node->builtin_data);\n\n double alpha_multiplier =\n input->params.scale * params->alpha / output->params.scale;\n QuantizeMultiplier(alpha_multiplier, &data->output_multiplier_alpha,\n &data->output_shift_alpha);\n double identity_multiplier = input->params.scale / output->params.scale;\n QuantizeMultiplier(identity_multiplier, &data->output_multiplier_identity,\n &data->output_shift_identity);\n }\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "folly::Optional ReadRecordLayer::readEvent(\n folly::IOBufQueue& socketBuf) {\n if (!unparsedHandshakeData_.empty()) {\n auto param = decodeHandshakeMessage(unparsedHandshakeData_);\n if (param) {\n VLOG(8) << \"Received handshake message \"\n << toString(boost::apply_visitor(EventVisitor(), *param));\n return param;\n }\n }\n\n while (true) {\n // Read one record. We read one record at a time since records could cause\n // a change in the record layer.\n auto message = read(socketBuf);\n if (!message) {\n return folly::none;\n }\n\n if (!unparsedHandshakeData_.empty() &&\n message->type != ContentType::handshake) {\n throw std::runtime_error(\"spliced handshake data\");\n }\n\n switch (message->type) {\n case ContentType::alert: {\n auto alert = decode(std::move(message->fragment));\n if (alert.description == AlertDescription::close_notify) {\n return Param(CloseNotify(socketBuf.move()));\n } else {\n return Param(std::move(alert));\n }\n }\n case ContentType::handshake: {\n unparsedHandshakeData_.append(std::move(message->fragment));\n auto param = decodeHandshakeMessage(unparsedHandshakeData_);\n if (param) {\n VLOG(8) << \"Received handshake message \"\n << toString(boost::apply_visitor(EventVisitor(), *param));\n return param;\n } else {\n // If we read handshake data but didn't have enough to get a full\n // message we immediately try to read another record.\n // TODO: add limits on number of records we buffer\n continue;\n }\n }\n case ContentType::application_data:\n return Param(AppData(std::move(message->fragment)));\n default:\n throw std::runtime_error(\"unknown content type\");\n }\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "TfLiteStatus AverageEval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n TfLiteTensor* output = GetOutput(context, node, 0);\n const TfLiteTensor* input = GetInput(context, node, 0);\n switch (input->type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n AverageEvalFloat(context, node, params, data, input, output);\n break;\n case kTfLiteUInt8:\n AverageEvalQuantizedUint8(context, node, params, data, input,\n output);\n break;\n case kTfLiteInt8:\n AverageEvalQuantizedInt8(context, node, params, data, input,\n output);\n break;\n case kTfLiteInt16:\n AverageEvalQuantizedInt16(context, node, params, data, input,\n output);\n break;\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int oe_iov_sync(\n const struct oe_iovec* iov,\n int iovcnt,\n const void* buf_,\n size_t buf_size)\n{\n struct oe_iovec* buf = (struct oe_iovec*)buf_;\n int ret = -1;\n int i;\n size_t n;\n\n /* Reject invalid parameters. */\n if (iovcnt < 0 || (iovcnt > 0 && !iov))\n goto done;\n\n /* Synchronize the data. */\n for (i = 0, n = buf_size; i < iovcnt; i++)\n {\n if (buf[i].iov_len != iov[i].iov_len)\n goto done;\n\n if (buf[i].iov_len)\n {\n if (buf[i].iov_base && !iov[i].iov_base)\n goto done;\n\n if (!buf[i].iov_base && iov[i].iov_base)\n goto done;\n\n if (!buf[i].iov_base)\n continue;\n\n /* Fail if buffer data is exhausted. */\n if (n < buf[i].iov_len)\n goto done;\n\n /* Sync the base data for this element. */\n {\n /* Note: buf[i].iov_base is an offset here (not a pointer). */\n uint8_t* src = (uint8_t*)buf[i].iov_base + (uint64_t)buf;\n size_t src_size = buf[i].iov_len;\n uint8_t* dest = (uint8_t*)iov[i].iov_base;\n size_t dest_size = iov[i].iov_len;\n\n if (src_size != dest_size)\n goto done;\n\n if (src < (uint8_t*)buf || src > (uint8_t*)buf + buf_size)\n goto done;\n\n if (oe_memcpy_s(dest, dest_size, src, src_size) != OE_OK)\n goto done;\n }\n }\n\n n -= buf[i].iov_len;\n }\n\n ret = 0;\n\ndone:\n\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "TEST_F(SQLiteUtilTests, test_column_type_determination) {\n // Correct identification of text and ints\n testTypesExpected(\"select path, inode from file where path like '%'\",\n TypeMap({{\"path\", TEXT_TYPE}, {\"inode\", INTEGER_TYPE}}));\n // Correctly treating BLOBs as text\n testTypesExpected(\"select CAST(seconds AS BLOB) as seconds FROM time\",\n TypeMap({{\"seconds\", TEXT_TYPE}}));\n // Correctly treating ints cast as double as doubles\n testTypesExpected(\"select CAST(seconds AS DOUBLE) as seconds FROM time\",\n TypeMap({{\"seconds\", DOUBLE_TYPE}}));\n // Correctly treating bools as ints\n testTypesExpected(\"select CAST(seconds AS BOOLEAN) as seconds FROM time\",\n TypeMap({{\"seconds\", INTEGER_TYPE}}));\n // Correctly recognizing values from columns declared double as double, even\n // if they happen to have integer value. And also test multi-statement\n // queries.\n testTypesExpected(\n \"CREATE TABLE test_types_table (username varchar(30) primary key, age \"\n \"double);INSERT INTO test_types_table VALUES (\\\"mike\\\", 23); SELECT age \"\n \"from test_types_table\",\n TypeMap({{\"age\", DOUBLE_TYPE}}));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " void Compute(OpKernelContext* ctx) override {\n const Tensor& handle = ctx->input(0);\n const string& name = handle.scalar()();\n Tensor val;\n OP_REQUIRES_OK(ctx, ctx->session_state()->GetTensor(name, &val));\n ctx->set_output(0, val);\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "jas_image_t *jas_image_create0()\n{\n\tjas_image_t *image;\n\n\tif (!(image = jas_malloc(sizeof(jas_image_t)))) {\n\t\treturn 0;\n\t}\n\n\timage->tlx_ = 0;\n\timage->tly_ = 0;\n\timage->brx_ = 0;\n\timage->bry_ = 0;\n\timage->clrspc_ = JAS_CLRSPC_UNKNOWN;\n\timage->numcmpts_ = 0;\n\timage->maxcmpts_ = 0;\n\timage->cmpts_ = 0;\n\timage->inmem_ = true;\n\timage->cmprof_ = 0;\n\n\treturn image;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output_values;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputValues, &output_values));\n TfLiteTensor* output_indexes;\n TF_LITE_ENSURE_OK(\n context, GetOutputSafe(context, node, kOutputIndexes, &output_indexes));\n if (IsDynamicTensor(output_values)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n }\n const TfLiteTensor* top_k;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTopK, &top_k));\n const int32 k = top_k->data.i32[0];\n // The tensor can have more than 2 dimensions or even be a vector, the code\n // anyway calls the internal dimension as row;\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const int32 row_size = input->dims->data[input->dims->size - 1];\n int32 num_rows = 1;\n for (int i = 0; i < input->dims->size - 1; ++i) {\n num_rows *= input->dims->data[i];\n }\n switch (output_values->type) {\n case kTfLiteFloat32:\n TopK(row_size, num_rows, GetTensorData(input), k,\n output_indexes->data.i32, GetTensorData(output_values));\n break;\n case kTfLiteUInt8:\n TopK(row_size, num_rows, input->data.uint8, k, output_indexes->data.i32,\n output_values->data.uint8);\n break;\n case kTfLiteInt8:\n TopK(row_size, num_rows, input->data.int8, k, output_indexes->data.i32,\n output_values->data.int8);\n break;\n case kTfLiteInt32:\n TopK(row_size, num_rows, input->data.i32, k, output_indexes->data.i32,\n output_values->data.i32);\n break;\n case kTfLiteInt64:\n TopK(row_size, num_rows, input->data.i64, k, output_indexes->data.i32,\n output_values->data.i64);\n break;\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s is currently not supported by TopK.\",\n TfLiteTypeGetName(output_values->type));\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static NO_INLINE JsVar *jspGetNamedFieldInParents(JsVar *object, const char* name, bool returnName) {\n // Now look in prototypes\n JsVar * child = jspeiFindChildFromStringInParents(object, name);\n\n /* Check for builtins via separate function\n * This way we save on RAM for built-ins because everything comes out of program code */\n if (!child) {\n child = jswFindBuiltInFunction(object, name);\n }\n\n /* We didn't get here if we found a child in the object itself, so\n * if we're here then we probably have the wrong name - so for example\n * with `a.b = c;` could end up setting `a.prototype.b` (bug #360)\n *\n * Also we might have got a built-in, which wouldn't have a name on it\n * anyway - so in both cases, strip the name if it is there, and create\n * a new name that references the object we actually requested the\n * member from..\n */\n if (child && returnName) {\n // Get rid of existing name\n if (jsvIsName(child)) {\n JsVar *t = jsvGetValueOfName(child);\n jsvUnLock(child);\n child = t;\n }\n // create a new name\n JsVar *nameVar = jsvNewFromString(name);\n JsVar *newChild = jsvCreateNewChild(object, nameVar, child);\n jsvUnLock2(nameVar, child);\n child = newChild;\n }\n\n // If not found and is the prototype, create it\n if (!child) {\n if (jsvIsFunction(object) && strcmp(name, JSPARSE_PROTOTYPE_VAR)==0) {\n // prototype is supposed to be an object\n JsVar *proto = jsvNewObject();\n // make sure it has a 'constructor' variable that points to the object it was part of\n jsvObjectSetChild(proto, JSPARSE_CONSTRUCTOR_VAR, object);\n child = jsvAddNamedChild(object, proto, JSPARSE_PROTOTYPE_VAR);\n jspEnsureIsPrototype(object, child);\n jsvUnLock(proto);\n } else if (strcmp(name, JSPARSE_INHERITS_VAR)==0) {\n const char *objName = jswGetBasicObjectName(object);\n if (objName) {\n child = jspNewPrototype(objName);\n }\n }\n }\n\n return child;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "jas_matrix_t *jas_matrix_create(int numrows, int numcols)\n{\n\tjas_matrix_t *matrix;\n\tint i;\n\tsize_t size;\n\n\tmatrix = 0;\n\n\tif (numrows < 0 || numcols < 0) {\n\t\tgoto error;\n\t}\n\n\tif (!(matrix = jas_malloc(sizeof(jas_matrix_t)))) {\n\t\tgoto error;\n\t}\n\tmatrix->flags_ = 0;\n\tmatrix->numrows_ = numrows;\n\tmatrix->numcols_ = numcols;\n\tmatrix->rows_ = 0;\n\tmatrix->maxrows_ = numrows;\n\tmatrix->data_ = 0;\n\tmatrix->datasize_ = 0;\n\n\t// matrix->datasize_ = numrows * numcols;\n\tif (!jas_safe_size_mul(numrows, numcols, &size)) {\n\t\tgoto error;\n\t}\n\tmatrix->datasize_ = size;\n\n\tif (matrix->maxrows_ > 0) {\n\t\tif (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,\n\t\t sizeof(jas_seqent_t *)))) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tif (matrix->datasize_ > 0) {\n\t\tif (!(matrix->data_ = jas_alloc2(matrix->datasize_,\n\t\t sizeof(jas_seqent_t)))) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tfor (i = 0; i < numrows; ++i) {\n\t\tmatrix->rows_[i] = &matrix->data_[i * matrix->numcols_];\n\t}\n\n\tfor (i = 0; i < matrix->datasize_; ++i) {\n\t\tmatrix->data_[i] = 0;\n\t}\n\n\tmatrix->xstart_ = 0;\n\tmatrix->ystart_ = 0;\n\tmatrix->xend_ = matrix->numcols_;\n\tmatrix->yend_ = matrix->numrows_;\n\n\treturn matrix;\n\nerror:\n\tif (matrix) {\n\t\tjas_matrix_destroy(matrix);\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TFLITE_DCHECK(node->user_data != nullptr);\n TFLITE_DCHECK(node->builtin_data != nullptr);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n TF_LITE_ENSURE(context, input1 != nullptr);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TF_LITE_ENSURE(context, input2 != nullptr);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output != nullptr);\n\n OpData* data = static_cast(node->user_data);\n auto* params = reinterpret_cast(node->builtin_data);\n\n TF_LITE_ENSURE_STATUS(\n CalculateOpData(context, params, input1, input2, output, data));\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "PackLinuxElf64::elf_find_dynamic(unsigned int key) const\n{\n Elf64_Dyn const *dynp= dynseg;\n if (dynp)\n for (; (unsigned)((char const *)dynp - (char const *)dynseg) < sz_dynseg\n && Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) {\n upx_uint64_t const t= elf_get_offset_from_address(get_te64(&dynp->d_val));\n if (t) {\n return &((unsigned char const *)file_image)[(size_t)t];\n }\n break;\n }\n return 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "static const char* ConvertOneFloat(PyObject* v, T* out) {\n if (PyErr_Occurred()) {\n return nullptr;\n }\n if (TF_PREDICT_TRUE(PyFloat_Check(v))) {\n const double as_double = PyFloat_AS_DOUBLE(v);\n *out = static_cast(as_double);\n // Check for overflow\n if (TF_PREDICT_FALSE(sizeof(T) < sizeof(double) && std::isinf(*out) &&\n std::isfinite(as_double))) {\n return ErrorOutOfRangeDouble;\n }\n return nullptr;\n }\n#if PY_MAJOR_VERSION < 3\n if (PyInt_Check(v)) {\n *out = PyInt_AS_LONG(v);\n return nullptr;\n }\n#endif\n if (PyLong_Check(v)) {\n *out = PyLong_AsDouble(v);\n if (PyErr_Occurred()) return ErrorOutOfRangeDouble;\n return nullptr;\n }\n if (PyIsInstance(v, &PyFloatingArrType_Type)) { // NumPy float types\n Safe_PyObjectPtr as_float = make_safe(PyNumber_Float(v));\n if (PyErr_Occurred()) {\n return nullptr;\n }\n return ConvertOneFloat(as_float.get(), out);\n }\n if (PyIsInstance(v, &PyIntegerArrType_Type)) { // NumPy integers\n#if PY_MAJOR_VERSION < 3\n Safe_PyObjectPtr as_int = make_safe(PyNumber_Int(v));\n#else\n Safe_PyObjectPtr as_int = make_safe(PyNumber_Long(v));\n#endif\n if (PyErr_Occurred()) {\n return nullptr;\n }\n return ConvertOneFloat(as_int.get(), out);\n }\n return ErrorMixedTypes;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n output->type = kTfLiteInt32;\n\n // By design, the input shape is always known at the time of Prepare, even\n // if the preceding op that generates |input| is dynamic. Thus, we can\n // always compute the rank immediately, without waiting for Eval.\n SetTensorToPersistentRo(output);\n\n // Rank produces a 0-D int32 Tensor representing the rank of input.\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(0);\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_size));\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(output), 0);\n\n // Immediately propagate the known rank to the output tensor. This allows\n // downstream ops that rely on the value to use it during prepare.\n if (output->type == kTfLiteInt32) {\n int32_t* output_data = GetTensorData(output);\n *output_data = NumDimensions(input);\n } else {\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "optional ARN::parse(const string& s, bool wildcards) {\n static const char str_wild[] = \"arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)\";\n static const regex rx_wild(str_wild,\n\t\t\t\t sizeof(str_wild) - 1,\n\t\t\t\t ECMAScript | optimize);\n static const char str_no_wild[]\n = \"arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)\";\n static const regex rx_no_wild(str_no_wild,\n\t\t\t\tsizeof(str_no_wild) - 1,\n\t\t\t\tECMAScript | optimize);\n\n smatch match;\n\n if ((s == \"*\") && wildcards) {\n return ARN(Partition::wildcard, Service::wildcard, \"*\", \"*\", \"*\");\n } else if (regex_match(s, match, wildcards ? rx_wild : rx_no_wild)) {\n if (match.size() != 6) {\n return boost::none;\n }\n\n ARN a;\n {\n auto p = to_partition(match[1], wildcards);\n if (!p)\n\treturn none;\n\n a.partition = *p;\n }\n {\n auto s = to_service(match[2], wildcards);\n if (!s) {\n\treturn none;\n }\n a.service = *s;\n }\n\n a.region = match[3];\n a.account = match[4];\n a.resource = match[5];\n\n return a;\n }\n return none;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-617", "cwe_name": "Reachable Assertion", "description": "The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.", "url": "https://cwe.mitre.org/data/definitions/617.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n static const int kOutputUniqueTensor = 0;\n static const int kOutputIndexTensor = 1;\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 2);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output_unique_tensor;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputUniqueTensor,\n &output_unique_tensor));\n TfLiteTensor* output_index_tensor;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputIndexTensor,\n &output_index_tensor));\n\n // The op only supports 1D input.\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 1);\n TfLiteIntArray* output_index_shape = TfLiteIntArrayCopy(input->dims);\n // The unique values are determined during evaluation, so we don't know yet\n // the size of the output tensor.\n SetTensorToDynamic(output_unique_tensor);\n return context->ResizeTensor(context, output_index_tensor,\n output_index_shape);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "void IOBuf::allocExtBuffer(\n std::size_t minCapacity,\n uint8_t** bufReturn,\n SharedInfo** infoReturn,\n std::size_t* capacityReturn) {\n if (minCapacity > kMaxIOBufSize) {\n throw_exception();\n }\n\n size_t mallocSize = goodExtBufferSize(minCapacity);\n auto buf = static_cast(checkedMalloc(mallocSize));\n initExtBuffer(buf, mallocSize, infoReturn, capacityReturn);\n\n // the userData and the freeFn are nullptr here\n // just store the mallocSize in userData\n (*infoReturn)->userData = reinterpret_cast(mallocSize);\n if (io_buf_alloc_cb) {\n io_buf_alloc_cb(buf, mallocSize);\n }\n\n *bufReturn = buf;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " req::ptr doc() const { return m_node->doc(); }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n\n switch (input->type) {\n case kTfLiteFloat32:\n return EvalImpl(context, node);\n case kTfLiteUInt8:\n return EvalImpl(context, node);\n case kTfLiteInt8:\n return EvalImpl(context, node);\n case kTfLiteInt16:\n return EvalImpl(context, node);\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n const int num_elements = NumElements(input);\n TF_LITE_ENSURE_EQ(context, num_elements, NumElements(output));\n switch (input->type) {\n case kTfLiteInt64:\n return copyToTensor(context, input->data.i64, output, num_elements);\n case kTfLiteInt32:\n return copyToTensor(context, input->data.i32, output, num_elements);\n case kTfLiteUInt8:\n return copyToTensor(context, input->data.uint8, output, num_elements);\n case kTfLiteFloat32:\n return copyToTensor(context, GetTensorData(input), output,\n num_elements);\n case kTfLiteBool:\n return copyToTensor(context, input->data.b, output, num_elements);\n case kTfLiteComplex64:\n return copyToTensor(\n context, reinterpret_cast*>(input->data.c64),\n output, num_elements);\n default:\n // Unsupported type.\n TF_LITE_UNSUPPORTED_TYPE(context, input->type, \"Cast\");\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus ResizeOutputTensor(TfLiteContext* context,\n const TfLiteTensor* data,\n const TfLiteTensor* segment_ids,\n TfLiteTensor* output) {\n int max_index = -1;\n const int segment_id_size = segment_ids->dims->data[0];\n if (segment_id_size > 0) {\n max_index = segment_ids->data.i32[segment_id_size - 1];\n }\n const int data_rank = NumDimensions(data);\n TfLiteIntArray* output_shape = TfLiteIntArrayCreate(NumDimensions(data));\n output_shape->data[0] = max_index + 1;\n for (int i = 1; i < data_rank; ++i) {\n output_shape->data[i] = data->dims->data[i];\n }\n return context->ResizeTensor(context, output, output_shape);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Resize(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n TF_LITE_ENSURE(context, NumInputs(node) == 2 || NumInputs(node) == 3);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* hash = GetInput(context, node, 0);\n TF_LITE_ENSURE_EQ(context, NumDimensions(hash), 2);\n // Support up to 32 bits.\n TF_LITE_ENSURE(context, SizeOfDimension(hash, 1) <= 32);\n\n const TfLiteTensor* input = GetInput(context, node, 1);\n TF_LITE_ENSURE(context, NumDimensions(input) >= 1);\n\n if (NumInputs(node) == 3) {\n const TfLiteTensor* weight = GetInput(context, node, 2);\n TF_LITE_ENSURE_EQ(context, NumDimensions(weight), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(weight, 0),\n SizeOfDimension(input, 0));\n }\n\n TfLiteTensor* output = GetOutput(context, node, 0);\n TfLiteIntArray* outputSize = TfLiteIntArrayCreate(1);\n switch (params->type) {\n case kTfLiteLshProjectionSparse:\n outputSize->data[0] = SizeOfDimension(hash, 0);\n break;\n case kTfLiteLshProjectionDense:\n outputSize->data[0] = SizeOfDimension(hash, 0) * SizeOfDimension(hash, 1);\n break;\n default:\n return kTfLiteError;\n }\n return context->ResizeTensor(context, output, outputSize);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* cond_tensor =\n GetInput(context, node, kInputConditionTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (cond_tensor->type != kTfLiteBool) {\n context->ReportError(context,\n \"Condition tensor must be of type bool, but saw '%s'.\",\n TfLiteTypeGetName(cond_tensor->type));\n return kTfLiteError;\n }\n\n // As output will be a 2D tensor of indices, use int64 to be consistent with\n // tensorflow.\n output->type = kTfLiteInt64;\n\n // Exit early if cond is a non-const tensor. Set output tensor to dynamic so\n // output size can be determined in Eval.\n if (!IsConstantTensor(cond_tensor)) {\n SetTensorToDynamic(output);\n return kTfLiteOk;\n }\n return ResizeOutputTensor(context, cond_tensor, output);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "DSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,\n RandomNumberGenerator& rng)\n {\n const BigInt& q = m_group.get_q();\n\n BigInt m(msg, msg_len, q.bits());\n\n while(m >= q)\n m -= q;\n\n#if defined(BOTAN_HAS_RFC6979_GENERATOR)\n BOTAN_UNUSED(rng);\n const BigInt k = generate_rfc6979_nonce(m_x, q, m, m_rfc6979_hash);\n#else\n const BigInt k = BigInt::random_integer(rng, 1, q);\n#endif\n\n const BigInt k_inv = inverse_mod(k, q);\n\n const BigInt r = m_mod_q.reduce(m_group.power_g_p(k));\n\n /*\n * Blind the input message and compute x*r+m as (x*r*b + m*b)/b\n */\n m_b = m_mod_q.square(m_b);\n m_b_inv = m_mod_q.square(m_b_inv);\n\n m = m_mod_q.multiply(m_b, m);\n const BigInt xr = m_mod_q.multiply(m_mod_q.multiply(m_x, m_b), r);\n\n const BigInt s = m_mod_q.multiply(m_b_inv, m_mod_q.multiply(k_inv, xr + m));\n\n // With overwhelming probability, a bug rather than actual zero r/s\n if(r.is_zero() || s.is_zero())\n throw Internal_Error(\"Computed zero r/s during DSA signature\");\n\n return BigInt::encode_fixed_length_int_pair(r, s, q.bytes());\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static int em_grp45(struct x86_emulate_ctxt *ctxt)\n{\n\tint rc = X86EMUL_CONTINUE;\n\n\tswitch (ctxt->modrm_reg) {\n\tcase 2: /* call near abs */ {\n\t\tlong int old_eip;\n\t\told_eip = ctxt->_eip;\n\t\trc = assign_eip_near(ctxt, ctxt->src.val);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tbreak;\n\t\tctxt->src.val = old_eip;\n\t\trc = em_push(ctxt);\n\t\tbreak;\n\t}\n\tcase 4: /* jmp abs */\n\t\trc = assign_eip_near(ctxt, ctxt->src.val);\n\t\tbreak;\n\tcase 5: /* jmp far */\n\t\trc = em_jmp_far(ctxt);\n\t\tbreak;\n\tcase 6:\t/* push */\n\t\trc = em_push(ctxt);\n\t\tbreak;\n\t}\n\treturn rc;\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "void BlockCodec::runPull()\n{\n\tAFframecount framesToRead = m_outChunk->frameCount;\n\tAFframecount framesRead = 0;\n\n\tassert(framesToRead % m_framesPerPacket == 0);\n\tint blockCount = framesToRead / m_framesPerPacket;\n\n\t// Read the compressed data.\n\tssize_t bytesRead = read(m_inChunk->buffer, m_bytesPerPacket * blockCount);\n\tint blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0;\n\n\t// Decompress into m_outChunk.\n\tfor (int i=0; i(m_inChunk->buffer) + i * m_bytesPerPacket,\n\t\t\tstatic_cast(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0)\n\t\t\tbreak;\n\n\t\tframesRead += m_framesPerPacket;\n\t}\n\n\tm_track->nextfframe += framesRead;\n\n\tassert(tell() == m_track->fpos_next_frame);\n\n\tif (framesRead < framesToRead)\n\t\treportReadError(framesRead, framesToRead);\n\n\tm_outChunk->frameCount = framesRead;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "void DCR_CLASS dcr_cam_xyz_coeff (DCRAW* p, double cam_xyz[4][3])\r\n{\r\n\tdouble cam_rgb[4][3], inverse[4][3], num;\r\n\tint i, j, k;\r\n\r\n\tfor (i=0; i < p->colors; i++)\t\t/* Multiply out XYZ colorspace */\r\n\t\tfor (j=0; j < 3; j++)\r\n\t\t\tfor (cam_rgb[i][j] = k=0; k < 3; k++)\r\n\t\t\t\tcam_rgb[i][j] += cam_xyz[i][k] * xyz_rgb[k][j];\r\n\r\n\tfor (i=0; i < p->colors; i++) {\t\t/* Normalize cam_rgb so that */\r\n\t\tfor (num=j=0; j < 3; j++)\t\t/* cam_rgb * (1,1,1) is (1,1,1,1) */\r\n\t\t\tnum += cam_rgb[i][j];\r\n\t\tfor (j=0; j < 3; j++)\r\n\t\t\tcam_rgb[i][j] /= num;\r\n\t\tp->pre_mul[i] = 1 / (float)num;\r\n\t}\r\n\tdcr_pseudoinverse (cam_rgb, inverse, p->colors);\r\n\tfor (p->raw_color = i=0; i < 3; i++)\r\n\t\tfor (j=0; j < p->colors; j++)\r\n\t\t\tp->rgb_cam[i][j] = (float)inverse[j][i];\r\n}\r", "label": 0, "programming_language": "C++", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "\tCmdResult Handle (const std::vector& parameters, User *user)\n\t{\n\t\t/* Only allow AUTHENTICATE on unregistered clients */\n\t\tif (user->registered != REG_ALL)\n\t\t{\n\t\t\tif (!cap.ext.get(user))\n\t\t\t\treturn CMD_FAILURE;\n\n\t\t\tif (parameters[0].find(' ') != std::string::npos || parameters[0][0] == ':')\n\t\t\t\treturn CMD_FAILURE;\n\n\t\t\tSaslAuthenticator *sasl = authExt.get(user);\n\t\t\tif (!sasl)\n\t\t\t\tauthExt.set(user, new SaslAuthenticator(user, parameters[0]));\n\t\t\telse if (sasl->SendClientMessage(parameters) == false)\t// IAL abort extension --nenolod\n\t\t\t{\n\t\t\t\tsasl->AnnounceState();\n\t\t\t\tauthExt.unset(user);\n\t\t\t}\n\t\t}\n\t\treturn CMD_FAILURE;\n\t}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "void carray2Hex(const unsigned char *d, uint64_t _len, char *_hexArray,\n uint64_t _hexArrayLen) {\n\n CHECK_STATE(d);\n CHECK_STATE(_hexArray);\n\n char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n CHECK_STATE(_hexArrayLen > 2 * _len);\n\n for (int j = 0; j < _len; j++) {\n _hexArray[j * 2] = hexval[((d[j] >> 4) & 0xF)];\n _hexArray[j * 2 + 1] = hexval[(d[j]) & 0x0F];\n }\n\n _hexArray[_len * 2] = 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " inline void skip(int bytes) {\n while (bytes > 0) {\n int n = check(1, bytes);\n ptr += n;\n bytes -= n;\n }\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " State()\n : remote_complete_(false), local_complete_(false), has_1xx_headers_(false),\n created_filter_chain_(false), is_head_request_(false), is_grpc_request_(false),\n non_100_response_headers_encoded_(false), under_on_local_reply_(false),\n decoder_filter_chain_aborted_(false), encoder_filter_chain_aborted_(false),\n saw_downstream_reset_(false) {}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "Status CreateTempFile(Env* env, float value, uint64 size, string* filename) {\n const string dir = testing::TmpDir();\n *filename = io::JoinPath(dir, strings::StrCat(\"file_\", value));\n std::unique_ptr file;\n TF_RETURN_IF_ERROR(env->NewWritableFile(*filename, &file));\n for (uint64 i = 0; i < size; ++i) {\n StringPiece sp(static_cast(static_cast(&value)),\n sizeof(value));\n TF_RETURN_IF_ERROR(file->Append(sp));\n }\n TF_RETURN_IF_ERROR(file->Close());\n return Status::OK();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " int GetU16BE (int nPos, bool *pbSuccess)\n {\n //*pbSuccess = true;\n\n if ( nPos < 0 || nPos + 1 >= m_nLen)\n {\n *pbSuccess = false;\n return 0;\n }\n int nRes = m_sFile[ nPos ];\n nRes = (nRes << 8) + m_sFile[ nPos + 1 ];\n return nRes;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " TfLiteRegistration CopyOpRegistration() {\n TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};\n\n reg.prepare = [](TfLiteContext* context, TfLiteNode* node) {\n // Set output size to input size\n const TfLiteTensor* tensor0;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &tensor0));\n TfLiteTensor* tensor1;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &tensor1));\n TfLiteIntArray* newSize = TfLiteIntArrayCopy(tensor0->dims);\n return context->ResizeTensor(context, tensor1, newSize);\n };\n\n reg.invoke = [](TfLiteContext* context, TfLiteNode* node) {\n CallReporting* call_reporting =\n static_cast(node->builtin_data);\n // Copy input data to output data.\n const TfLiteTensor* a0;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &a0));\n TfLiteTensor* a1;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &a1));\n int num = a0->dims->data[0];\n for (int i = 0; i < num; i++) {\n a1->data.f[i] = a0->data.f[i];\n }\n call_reporting->Record();\n return kTfLiteOk;\n };\n return reg;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static inline bool isMountable(const RemoteFsDevice::Details &d)\n{\n return RemoteFsDevice::constSshfsProtocol==d.url.scheme() ||\n RemoteFsDevice::constSambaProtocol==d.url.scheme() || RemoteFsDevice::constSambaAvahiProtocol==d.url.scheme();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " private static boolean matches( final Collection patterns,\n final URI uri ) {\n for ( final String pattern : patterns ) {\n if ( matcher.match( pattern, uri.toString() ) ) {\n return true;\n }\n }\n return false;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "void RemoteFsDevice::serviceRemoved(const QString &name)\n{\n if (name==details.serviceName && constSambaAvahiProtocol==details.url.scheme()) {\n sub=tr(\"Not Available\");\n updateStatus();\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "int PackLinuxElf32::canUnpack()\n{\n if (super::canUnpack()) {\n return true;\n }\n if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {\n PackLinuxElf32help1(fi);\n }\n return false;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": " explicit HashContext(const HashContext* ctx) {\n assert(ctx->ops);\n assert(ctx->ops->context_size >= 0);\n ops = ctx->ops;\n context = malloc(ops->context_size);\n ops->hash_copy(context, ctx->context);\n options = ctx->options;\n key = ctx->key ? strdup(ctx->key) : nullptr;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n EvalAdd(context, node, params, data, input1, input2, output);\n } else if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16) {\n TF_LITE_ENSURE_OK(context,\n EvalAddQuantized(context, node, params, data,\n input1, input2, output));\n } else {\n TF_LITE_UNSUPPORTED_TYPE(context, output->type, \"Add\");\n }\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " const String& setSize(int len) {\n assertx(m_str);\n m_str->setSize(len);\n return *this;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "\tModuleSilence()\n\t\t: CTCTags::EventListener(this)\n\t\t, cmd(this)\n\t{\n\t}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "safe"} {"code": "R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (!sz) {\n\t\treturn NULL;\n\t}\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_FILE_ATTR;\n\t// if (buffer + offset > buffer + sz) return NULL;\n\tattr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->size = offset;\n\t// IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\treturn attr;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-805", "cwe_name": "Buffer Access with Incorrect Length Value", "description": "The software uses a sequential operation to read or write a buffer, but it uses an incorrect length value that causes it to access memory that is outside of the bounds of the buffer.", "url": "https://cwe.mitre.org/data/definitions/805.html", "label_name": "vulnerable"} {"code": " bool read(ReadonlyBytes buffer)\n {\n auto fields_size = sizeof(LocalFileHeader) - (sizeof(u8*) * 3);\n if (buffer.size() < fields_size)\n return false;\n if (memcmp(buffer.data(), local_file_header_signature, sizeof(local_file_header_signature)) != 0)\n return false;\n memcpy(reinterpret_cast(&minimum_version), buffer.data() + sizeof(local_file_header_signature), fields_size);\n name = buffer.data() + sizeof(local_file_header_signature) + fields_size;\n extra_data = name + name_length;\n compressed_data = extra_data + extra_data_length;\n return true;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "static inline ulong encode_twos_comp(long n, int prec)\n{\n\tulong result;\n\tassert(prec >= 2);\n\tjas_eprintf(\"warning: support for signed data is untested\\n\");\n\t// NOTE: Is this correct?\n\tif (n < 0) {\n\t\tresult = -n;\n\t\tresult = (result ^ 0xffffffffUL) + 1;\n\t\tresult &= (1 << prec) - 1;\n\t} else {\n\t\tresult = n;\n\t}\n\treturn result;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " bool load_face(Face & face, unsigned int options)\n {\n#ifdef GRAPHITE2_TELEMETRY\n telemetry::category _misc_cat(face.tele.misc);\n#endif\n Face::Table silf(face, Tag::Silf, 0x00050000);\n if (silf) options &= ~gr_face_dumbRendering;\n else if (!(options & gr_face_dumbRendering))\n return false;\n\n if (!face.readGlyphs(options))\n return false;\n\n if (silf)\n {\n if (!face.readFeatures() || !face.readGraphite(silf))\n {\n#if !defined GRAPHITE2_NTRACING\n if (global_log)\n {\n *global_log << json::object\n << \"type\" << \"fontload\"\n << \"failure\" << face.error()\n << \"context\" << face.error_context()\n << json::close;\n }\n#endif\n return false;\n }\n else\n return true;\n }\n else\n return options & gr_face_dumbRendering;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n if (output->type == kTfLiteFloat32) {\n EvalAddN(context, node);\n } else if (output->type == kTfLiteInt32) {\n EvalAddN(context, node);\n } else {\n context->ReportError(context,\n \"AddN only supports FLOAT32|INT32 now, got %s.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void CLASS panasonic_load_raw()\n{\n int row, col, i, j, sh = 0, pred[2], nonz[2];\n\n pana_bits(0);\n for (row = 0; row < height; row++)\n {\n#ifdef LIBRAW_LIBRARY_BUILD\n checkCancel();\n#endif\n for (col = 0; col < raw_width; col++)\n {\n if ((i = col % 14) == 0)\n pred[0] = pred[1] = nonz[0] = nonz[1] = 0;\n if (i % 3 == 2)\n sh = 4 >> (3 - pana_bits(2));\n if (nonz[i & 1])\n {\n if ((j = pana_bits(8)))\n {\n if ((pred[i & 1] -= 0x80 << sh) < 0 || sh == 4)\n pred[i & 1] &= ~((~0u) << sh);\n pred[i & 1] += j << sh;\n }\n }\n else if ((nonz[i & 1] = pana_bits(8)) || i > 11)\n pred[i & 1] = nonz[i & 1] << 4 | pana_bits(4);\n if ((RAW(row, col) = pred[col & 1]) > 4098 && col < width)\n derror();\n }\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "static inline bool isMountable(const RemoteFsDevice::Details &d)\n{\n return RemoteFsDevice::constSshfsProtocol==d.url.scheme();\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "R_API RBinJavaVerificationObj *r_bin_java_verification_info_from_type(RBinJavaObj *bin, R_BIN_JAVA_STACKMAP_TYPE type, ut32 value) {\n\tRBinJavaVerificationObj *se = R_NEW0 (RBinJavaVerificationObj);\n\tif (se) {\n\t\tse->tag = type;\n\t\tif (se->tag == R_BIN_JAVA_STACKMAP_OBJECT) {\n\t\t\tse->info.obj_val_cp_idx = (ut16) value;\n\t\t} else if (se->tag == R_BIN_JAVA_STACKMAP_UNINIT) {\n\t\t\tse->info.uninit_offset = (ut16) value;\n\t\t}\n\t}\n\treturn se;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": " void Compute(OpKernelContext* ctx) override {\n // This call processes inputs 1 and 2 to write output 0.\n ReshapeOp::Compute(ctx);\n if (!ctx->status().ok()) {\n return;\n }\n\n const auto& input_min_float_tensor = ctx->input(2);\n const auto& input_min_float_shape = input_min_float_tensor.shape();\n OP_REQUIRES(ctx,\n TensorShapeUtils::IsScalar(input_min_float_shape) ||\n (TensorShapeUtils::IsVector(input_min_float_shape) &&\n (input_min_float_shape.dim_size(0) == 1)),\n errors::InvalidArgument(\n \"input_min must be a scalar or a vector of 1 element\"));\n const float input_min_float = input_min_float_tensor.flat()(0);\n const auto& input_max_float_tensor = ctx->input(3);\n const auto& input_max_float_shape = input_max_float_tensor.shape();\n OP_REQUIRES(ctx,\n TensorShapeUtils::IsScalar(input_max_float_shape) ||\n (TensorShapeUtils::IsVector(input_max_float_shape) &&\n (input_max_float_shape.dim_size(0) == 1)),\n errors::InvalidArgument(\n \"input_max must be a scalar or a vector of 1 element\"));\n const float input_max_float = input_max_float_tensor.flat()(0);\n\n Tensor* output_min = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(1, TensorShape({}), &output_min));\n output_min->flat()(0) = input_min_float;\n\n Tensor* output_max = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(2, TensorShape({}), &output_max));\n output_max->flat()(0) = input_max_float;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void RemoteFsDevice::serviceRemoved(const QString &name)\n{\n if (name==details.serviceName && constSambaAvahiProtocol==details.url.scheme()) {\n sub=tr(\"Not Available\");\n updateStatus();\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "MONGO_EXPORT void *bson_malloc( int size ) {\n void *p;\n p = bson_malloc_func( size );\n bson_fatal_msg( !!p, \"malloc() failed\" );\n return p;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "R_API RBinJavaAttrInfo *r_bin_java_source_debug_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 6;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_DEBUG_EXTENTSION_ATTR;\n\tif (attr->length == 0) {\n\t\teprintf (\"r_bin_java_source_debug_attr_new: Attempting to allocate 0 bytes for debug_extension.\\n\");\n\t\tattr->info.debug_extensions.debug_extension = NULL;\n\t\treturn attr;\n\t} else if ((attr->length + offset) > sz) {\n\t\teprintf (\"r_bin_java_source_debug_attr_new: Expected %d byte(s) got %\"\n\t\t\tPFMT64d \" bytes for debug_extension.\\n\", attr->length, (offset + sz));\n\t}\n\tattr->info.debug_extensions.debug_extension = (ut8 *) malloc (attr->length);\n\tif (attr->info.debug_extensions.debug_extension && (attr->length > (sz - offset))) {\n\t\tmemcpy (attr->info.debug_extensions.debug_extension, buffer + offset, sz - offset);\n\t} else if (attr->info.debug_extensions.debug_extension) {\n\t\tmemcpy (attr->info.debug_extensions.debug_extension, buffer + offset, attr->length);\n\t} else {\n\t\teprintf (\"r_bin_java_source_debug_attr_new: Unable to allocate the data for the debug_extension.\\n\");\n\t}\n\toffset += attr->length;\n\tattr->size = offset;\n\treturn attr;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "TfLiteStatus PrepareHashtableImport(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 0);\n\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputResourceIdTensor);\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1);\n\n const TfLiteTensor* key_tensor = GetInput(context, node, kKeyTensor);\n const TfLiteTensor* value_tensor = GetInput(context, node, kValueTensor);\n TF_LITE_ENSURE(context, (key_tensor->type == kTfLiteInt64 &&\n value_tensor->type == kTfLiteString) ||\n (key_tensor->type == kTfLiteString &&\n value_tensor->type == kTfLiteInt64));\n // TODO(b/144731295): Tensorflow lookup ops support 1-D vector in storing\n // values.\n TF_LITE_ENSURE(context, HaveSameShapes(key_tensor, value_tensor));\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": " ~SubgraphGuard() {\n // If tht original status was OK, recover the boolean flag.\n if (status_ == kTfLiteOk) {\n *is_subgraph_in_use_ = false;\n }\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n int32_t* out_buf = GetOutput(context, node, 0)->data.i32;\n const TfLiteTensor* hash = GetInput(context, node, 0);\n const TfLiteTensor* input = GetInput(context, node, 1);\n const TfLiteTensor* weight =\n NumInputs(node) == 2 ? nullptr : GetInput(context, node, 2);\n\n switch (params->type) {\n case kTfLiteLshProjectionDense:\n DenseLshProjection(hash, input, weight, out_buf);\n break;\n case kTfLiteLshProjectionSparse:\n SparseLshProjection(hash, input, weight, out_buf);\n break;\n default:\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "\t\tGetRunner(\n\t\t\tconst ReferenceHandle& that,\n\t\t\tLocal key_handle,\n\t\t\tMaybeLocal maybe_options,\n\t\t\tbool inherit\n\t\t) :\n\t\t\t\tcontext{that.context},\n\t\t\t\treference{that.reference},\n\t\t\t\toptions{maybe_options, inherit ?\n\t\t\t\t\tTransferOptions::Type::DeepReference : TransferOptions::Type::Reference},\n\t\t\t\tinherit{inherit} {\n\t\t\tthat.CheckDisposed();\n\t\t\tkey = ExternalCopy::CopyIfPrimitive(key_handle);\n\t\t\tif (!key) {\n\t\t\t\tthrow RuntimeTypeError(\"Invalid `key`\");\n\t\t\t}\n\t\t}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-913", "cwe_name": "Improper Control of Dynamically-Managed Code Resources", "description": "The software does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.", "url": "https://cwe.mitre.org/data/definitions/913.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n switch (input1->type) {\n case kTfLiteInt32: {\n return EvalImpl(context, data->requires_broadcast, input1,\n input2, output);\n }\n case kTfLiteInt64: {\n return EvalImpl(context, data->requires_broadcast, input1,\n input2, output);\n }\n case kTfLiteFloat32: {\n return EvalImpl(context, data->requires_broadcast, input1, input2,\n output);\n }\n default: {\n context->ReportError(context, \"Type '%s' is not supported by floor_mod.\",\n TfLiteTypeGetName(input1->type));\n return kTfLiteError;\n }\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* cond_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputConditionTensor,\n &cond_tensor));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (cond_tensor->type != kTfLiteBool) {\n context->ReportError(context,\n \"Condition tensor must be of type bool, but saw '%s'.\",\n TfLiteTypeGetName(cond_tensor->type));\n return kTfLiteError;\n }\n\n // As output will be a 2D tensor of indices, use int64 to be consistent with\n // tensorflow.\n output->type = kTfLiteInt64;\n\n // Exit early if cond is a non-const tensor. Set output tensor to dynamic so\n // output size can be determined in Eval.\n if (!IsConstantTensor(cond_tensor)) {\n SetTensorToDynamic(output);\n return kTfLiteOk;\n }\n return ResizeOutputTensor(context, cond_tensor, output);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "jas_matrix_t *jas_matrix_create(int numrows, int numcols)\n{\n\tjas_matrix_t *matrix;\n\tint i;\n\tsize_t size;\n\n\tmatrix = 0;\n\n\tif (numrows < 0 || numcols < 0) {\n\t\tgoto error;\n\t}\n\n\tif (!(matrix = jas_malloc(sizeof(jas_matrix_t)))) {\n\t\tgoto error;\n\t}\n\tmatrix->flags_ = 0;\n\tmatrix->numrows_ = numrows;\n\tmatrix->numcols_ = numcols;\n\tmatrix->rows_ = 0;\n\tmatrix->maxrows_ = numrows;\n\tmatrix->data_ = 0;\n\tmatrix->datasize_ = 0;\n\n\t// matrix->datasize_ = numrows * numcols;\n\tif (!jas_safe_size_mul(numrows, numcols, &size)) {\n\t\tgoto error;\n\t}\n\tmatrix->datasize_ = size;\n\n\tif (matrix->maxrows_ > 0) {\n\t\tif (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,\n\t\t sizeof(jas_seqent_t *)))) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tif (matrix->datasize_ > 0) {\n\t\tif (!(matrix->data_ = jas_alloc2(matrix->datasize_,\n\t\t sizeof(jas_seqent_t)))) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tfor (i = 0; i < numrows; ++i) {\n\t\tmatrix->rows_[i] = &matrix->data_[i * matrix->numcols_];\n\t}\n\n\tfor (i = 0; i < matrix->datasize_; ++i) {\n\t\tmatrix->data_[i] = 0;\n\t}\n\n\tmatrix->xstart_ = 0;\n\tmatrix->ystart_ = 0;\n\tmatrix->xend_ = matrix->numcols_;\n\tmatrix->yend_ = matrix->numrows_;\n\n\treturn matrix;\n\nerror:\n\tif (matrix) {\n\t\tjas_matrix_destroy(matrix);\n\t}\n\treturn 0;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = static_cast(node->user_data);\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n\n // TODO(b/128934713): Add support for fixed-point per-channel quantization.\n // Currently this only support affine per-layer quantization.\n TF_LITE_ENSURE_EQ(context, output->quantization.type,\n kTfLiteAffineQuantization);\n const auto* affine_quantization =\n static_cast(output->quantization.params);\n TF_LITE_ENSURE(context, affine_quantization);\n TF_LITE_ENSURE(context, affine_quantization->scale);\n TF_LITE_ENSURE(context, affine_quantization->scale->size == 1);\n\n if (input->type == kTfLiteFloat32) {\n // Quantize use case.\n TF_LITE_ENSURE(context, output->type == kTfLiteUInt8 ||\n output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16);\n } else {\n // Requantize use case.\n if (input->type == kTfLiteInt16) {\n TF_LITE_ENSURE(\n context, output->type == kTfLiteInt8 || output->type == kTfLiteInt16);\n } else {\n TF_LITE_ENSURE(context,\n input->type == kTfLiteInt8 || input->type == kTfLiteUInt8);\n TF_LITE_ENSURE(\n context, output->type == kTfLiteUInt8 || output->type == kTfLiteInt8);\n }\n const double effective_output_scale =\n static_cast(input->params.scale) /\n static_cast(output->params.scale);\n QuantizeMultiplier(effective_output_scale, &data->output_multiplier,\n &data->output_shift);\n }\n\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " friend H AbslHashValue(H h, const TensorKey& k) {\n const uint8* d = static_cast(k.data());\n size_t s = k.AllocatedBytes();\n std::vector vec;\n vec.reserve(s);\n for (int i = 0; i < s; i++) {\n vec.push_back(d[i]);\n }\n return H::combine(std::move(h), s);\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (!sz || sz == UT64_MAX) {\n\t\treturn NULL;\n\t}\n#if 0\n\t/// XXX this breaks tests\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n#endif\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_FILE_ATTR;\n\t\tattr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tattr->size = offset;\n\t\t// IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\t}\n\treturn attr;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-788", "cwe_name": "Access of Memory Location After End of Buffer", "description": "The software reads or writes to a buffer using an index or pointer that references a memory location after the end of the buffer.", "url": "https://cwe.mitre.org/data/definitions/788.html", "label_name": "safe"} {"code": "static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)\n{\n\tUINT32 Length;\n\tUINT64 Offset;\n\trdpPrintJob* printjob = NULL;\n\tUINT error = CHANNEL_RC_OK;\n\tvoid* ptr;\n\n\tif (Stream_GetRemainingLength(irp->input) < 32)\n\t\treturn ERROR_INVALID_DATA;\n\tStream_Read_UINT32(irp->input, Length);\n\tStream_Read_UINT64(irp->input, Offset);\n\tStream_Seek(irp->input, 20); /* Padding */\n\tptr = Stream_Pointer(irp->input);\n\tif (!Stream_SafeSeek(irp->input, Length))\n\t\treturn ERROR_INVALID_DATA;\n\tif (printer_dev->printer)\n\t\tprintjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId);\n\n\tif (!printjob)\n\t{\n\t\tirp->IoStatus = STATUS_UNSUCCESSFUL;\n\t\tLength = 0;\n\t}\n\telse\n\t{\n\t\terror = printjob->Write(printjob, ptr, Length);\n\t}\n\n\tif (error)\n\t{\n\t\tWLog_ERR(TAG, \"printjob->Write failed with error %\" PRIu32 \"!\", error);\n\t\treturn error;\n\t}\n\n\tStream_Write_UINT32(irp->output, Length);\n\tStream_Write_UINT8(irp->output, 0); /* Padding */\n\treturn irp->Complete(irp);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus GetIntermediatesSafe(const TfLiteContext* context,\n const TfLiteNode* node, int index,\n TfLiteTensor** tensor) {\n int tensor_index;\n TF_LITE_ENSURE_OK(context, ValidateTensorIndexingSafe(\n context, index, node->intermediates->size,\n node->intermediates->data, &tensor_index));\n *tensor = GetTensorAtIndex(context, tensor_index);\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TEST_F(CheckAuthTest, TestNoOpenId) {\n EXPECT_CALL(*raw_request_, FindHeader(\"x-goog-iap-jwt-assertion\", _))\n .WillOnce(Invoke([](const std::string &, std::string *token) {\n *token = \"\";\n return false;\n }));\n EXPECT_CALL(*raw_request_, FindHeader(kAuthHeader, _))\n .WillOnce(Invoke([](const std::string &, std::string *token) {\n *token = std::string(kBearer) + std::string(kTokenIssuer2);\n return true;\n }));\n EXPECT_CALL(*raw_request_, SetAuthToken(kTokenIssuer2)).Times(1);\n EXPECT_CALL(*raw_env_, DoRunHTTPRequest(_))\n .WillOnce(Invoke([](HTTPRequest *req) {\n EXPECT_EQ(req->url(), kIssuer2PubkeyUrl);\n std::string body(kPubkey);\n std::map empty;\n req->OnComplete(Status::OK, std::move(empty), std::move(body));\n }));\n EXPECT_CALL(*raw_request_,\n AddHeaderToBackend(kEndpointApiUserInfo, kUserInfo_kSub_kIss2))\n .WillOnce(Return(utils::Status::OK));\n\n CheckAuth(context_, [](Status status) { ASSERT_TRUE(status.ok()); });\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-290", "cwe_name": "Authentication Bypass by Spoofing", "description": "This attack-focused weakness is caused by improperly implemented authentication schemes that are subject to spoofing attacks.", "url": "https://cwe.mitre.org/data/definitions/290.html", "label_name": "vulnerable"} {"code": "inline bool loadModule(const char* filename, IR::Module& outModule)\n{\n\t// Read the specified file into an array.\n\tstd::vector fileBytes;\n\tif(!loadFile(filename, fileBytes)) { return false; }\n\n\t// If the file starts with the WASM binary magic number, load it as a binary irModule.\n\tif(fileBytes.size() >= 4 && *(U32*)fileBytes.data() == 0x6d736100)\n\t{ return loadBinaryModule(fileBytes.data(), fileBytes.size(), outModule); }\n\telse\n\t{\n\t\t// Make sure the WAST file is null terminated.\n\t\tfileBytes.push_back(0);\n\n\t\t// Load it as a text irModule.\n\t\tstd::vector parseErrors;\n\t\tif(!WAST::parseModule(\n\t\t\t (const char*)fileBytes.data(), fileBytes.size(), outModule, parseErrors))\n\t\t{\n\t\t\tLog::printf(Log::error, \"Error parsing WebAssembly text file:\\n\");\n\t\t\treportParseErrors(filename, parseErrors);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteIntArray* input_dims = input->dims;\n int input_dims_size = input_dims->size;\n TF_LITE_ENSURE(context, input_dims_size >= 1);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n // Resize the output tensor.\n TfLiteIntArray* output_shape = TfLiteIntArrayCreate(input_dims_size + 1);\n for (int i = 0; i < input_dims_size; i++) {\n output_shape->data[i] = input_dims->data[i];\n }\n // Last dimension in the output is the same as the last dimension in the\n // input.\n output_shape->data[input_dims_size] = input_dims->data[input_dims_size - 1];\n output->type = input->type;\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_shape));\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "\tboost::int64_t lazy_entry::int_value() const\n\t{\n\t\tTORRENT_ASSERT(m_type == int_t);\n\t\tboost::int64_t val = 0;\n\t\tbool negative = false;\n\t\tif (*m_data.start == '-') negative = true;\n\t\tparse_int(negative?m_data.start+1:m_data.start, m_data.start + m_size, 'e', val);\n\t\tif (negative) val = -val;\n\t\treturn val;\n\t}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": " void readStructEnd() {\n lastFieldId_ = nestedStructFieldIds_.back();\n nestedStructFieldIds_.pop_back();\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "vulnerable"} {"code": "R_API ut64 r_bin_java_element_pair_calc_size(RBinJavaElementValuePair *evp) {\n\tut64 sz = 2;\n\tif (evp && evp->value) {\n\t\t// evp->element_name_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\t// evp->value = r_bin_java_element_value_new (bin, offset+2);\n\t\tsz += r_bin_java_element_value_calc_size (evp->value);\n\t}\n\treturn sz;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-788", "cwe_name": "Access of Memory Location After End of Buffer", "description": "The software reads or writes to a buffer using an index or pointer that references a memory location after the end of the buffer.", "url": "https://cwe.mitre.org/data/definitions/788.html", "label_name": "safe"} {"code": " int64_t length() const {\n return m_str ? m_str->size() : 0;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void RemoteDevicePropertiesWidget::checkSaveable()\n{\n RemoteFsDevice::Details det=details();\n modified=det!=orig;\n saveable=!det.isEmpty();\n if (saveable && Type_SambaAvahi==type->itemData(type->currentIndex()).toInt()) {\n saveable=!smbAvahiName->text().trimmed().isEmpty();\n }\n emit updated();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static Variant HHVM_FUNCTION(bcdiv, const String& left, const String& right,\n int64_t scale /* = -1 */) {\n scale = adjust_scale(scale);\n bc_num first, second, result;\n bc_init_num(&first);\n bc_init_num(&second);\n bc_init_num(&result);\n SCOPE_EXIT {\n bc_free_num(&first);\n bc_free_num(&second);\n bc_free_num(&result);\n };\n php_str2num(&first, (char*)left.data());\n php_str2num(&second, (char*)right.data());\n if (bc_divide(first, second, &result, scale) == -1) {\n raise_warning(\"Division by zero\");\n return init_null();\n }\n String ret(bc_num2str(result), AttachString);\n return ret;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "int jsi_PstateSetFile(jsi_Pstate *ps, Jsi_Channel fp, int skipbang)\n{\n jsi_Lexer *l = ps->lexer;\n jsi_PstateClear(ps);\n l->ltype = LT_FILE;\n l->d.fp = fp;\n Jsi_Rewind(ps->interp, fp);\n if (skipbang) {\n char buf[1000];\n if (Jsi_Gets(ps->interp, fp, buf, 1000) && (buf[0] != '#' || buf[1] != '!')) {\n Jsi_Rewind(ps->interp, fp);\n }\n }\n \n return JSI_OK;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": "void PCRECache::dump(folly::File& file) {\n switch (m_kind) {\n case CacheKind::Static:\n for (auto& it : *m_staticCache) {\n folly::writeFull(file.fd(), it.first->data(), it.first->size());\n folly::writeFull(file.fd(), \"\\n\", 1);\n }\n break;\n case CacheKind::Lru:\n case CacheKind::Scalable:\n {\n std::vector keys;\n if (m_kind == CacheKind::Lru) {\n m_lruCache->snapshotKeys(keys);\n } else {\n m_scalableCache->snapshotKeys(keys);\n }\n for (auto& key: keys) {\n folly::writeFull(file.fd(), key.data(), key.size());\n folly::writeFull(file.fd(), \"\\n\", 1);\n }\n }\n break;\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " int64_t length() const {\n return m_str ? m_str->size() : 0;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "void BezierOval(double w, double h, char *action)\n{\n char *outpos = outputbuffer;\n outpos +=\n sprintf(outpos,\" %12.3f 0 m %12.3f %12.3f %12.3f %12.3f 0 %12.3f c\\n\",-w,-w,h*BzK,-w*BzK,h,h);\n outpos +=\n sprintf(outpos,\" %12.3f %12.3f %12.3f %12.3f %12.3f 0 c\\n\",w*BzK,h,w,h*BzK,w);\n outpos +=\n sprintf(outpos,\" %12.3f %12.3f %12.3f %12.3f 0 %12.3f c\\n\",w,-h*BzK,w*BzK,-h,-h);\n outpos +=\n sprintf(outpos,\" %12.3f %12.3f %12.3f %12.3f %12.3f 0 c %s\\n\",-w*BzK,-h,-w,-h*BzK,-w,action);\n sendClean(outputbuffer);\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "TfLiteStatus PrepareHashtableSize(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputResourceIdTensor);\n TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32);\n TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1);\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1);\n\n TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output_tensor != nullptr);\n TF_LITE_ENSURE_EQ(context, output_tensor->type, kTfLiteInt64);\n TfLiteIntArray* outputSize = TfLiteIntArrayCreate(1);\n outputSize->data[0] = 1;\n return context->ResizeTensor(context, output_tensor, outputSize);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "CSecurityTLS::~CSecurityTLS()\n{\n shutdown(true);\n\n if (fis)\n delete fis;\n if (fos)\n delete fos;\n\n delete[] cafile;\n delete[] crlfile;\n\n gnutls_global_deinit();\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* fft_length;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kFftLengthTensor, &fft_length));\n const int32_t* fft_length_data = GetTensorData(fft_length);\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (output->type != kTfLiteComplex64) {\n context->ReportError(context,\n \"Type '%s' for output is not supported by rfft2d.\",\n TfLiteTypeGetName(output->type));\n return kTfLiteError;\n }\n\n // Resize the output tensor if the fft_length tensor is not constant.\n // Otherwise, check if the output shape is correct.\n if (!IsConstantTensor(fft_length)) {\n TF_LITE_ENSURE_STATUS(ResizeOutputandTemporaryTensors(context, node));\n } else {\n int num_dims_output = NumDimensions(output);\n const RuntimeShape output_shape = GetTensorShape(output);\n TF_LITE_ENSURE_EQ(context, num_dims_output, NumDimensions(input));\n TF_LITE_ENSURE(context, num_dims_output >= 2);\n TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 2),\n fft_length_data[0]);\n TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 1),\n fft_length_data[1] / 2 + 1);\n }\n\n return Rfft2dHelper(context, node);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "inline void StringData::setSize(int64_t len) {\n assertx(!isImmutable() && !hasMultipleRefs());\n assertx(len >= 0 && len <= capacity());\n mutableData()[len] = 0;\n m_lenAndHash = len;\n assertx(m_hash == 0);\n assertx(checkSane());\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static INLINE BOOL ntlm_av_pair_get_id(const NTLM_AV_PAIR* pAvPair, size_t size, UINT16* pair)\n{\n\tUINT16 AvId;\n\tif (!pAvPair || !pair)\n\t\treturn FALSE;\n\n\tif (size < sizeof(NTLM_AV_PAIR))\n\t\treturn FALSE;\n\n\tData_Read_UINT16(&pAvPair->AvId, AvId);\n\n\t*pair = AvId;\n\treturn TRUE;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus CalculateArithmeticOpData(TfLiteContext* context, TfLiteNode* node,\n OpData* data) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TF_LITE_ENSURE(context, input != nullptr);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output != nullptr);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n if (input->type == kTfLiteInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.zero_point,\n std::numeric_limits::min());\n\n static constexpr int kInputIntegerBits = 4;\n const double input_real_multiplier =\n static_cast(input->params.scale) *\n static_cast(1 << (31 - kInputIntegerBits));\n\n data->input_zero_point = input->params.zero_point;\n\n const double q = std::frexp(input_real_multiplier, &data->input_left_shift);\n data->input_multiplier = static_cast(TfLiteRound(q * (1ll << 31)));\n\n data->input_range_radius =\n CalculateInputRadius(kInputIntegerBits, data->input_left_shift, 31);\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "Variant HHVM_FUNCTION(mcrypt_get_block_size, const String& cipher,\n const String& mode) {\n MCRYPT td = mcrypt_module_open((char*)cipher.data(),\n (char*)MCG(algorithms_dir).data(),\n (char*)mode.data(),\n (char*)MCG(modes_dir).data());\n if (td == MCRYPT_FAILED) {\n MCRYPT_OPEN_MODULE_FAILED(\"mcrypt_get_block_size\");\n return false;\n }\n\n int64_t ret = mcrypt_enc_get_block_size(td);\n mcrypt_module_close(td);\n return ret;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "safe"} {"code": "void MoveTo(double x1,double y1) {\n sprintf(outputbuffer,\"\\n %12.3f %12.3f m\",x1,y1);\n sendClean(outputbuffer);\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "void CtcpParser::query(CoreNetwork *net, const QString &bufname, const QString &ctcpTag, const QString &message)\n{\n QString cmd(\"PRIVMSG\");\n\n std::function(QString &)> cmdGenerator = [&] (QString &splitMsg) -> QList {\n return QList() << net->serverEncode(bufname) << lowLevelQuote(pack(net->serverEncode(ctcpTag), net->userEncode(bufname, splitMsg)));\n };\n\n net->putCmd(cmd, net->splitMessage(cmd, message, cmdGenerator));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "MONGO_EXPORT int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ) {\n bson_iterator next = *elem;\n int size;\n\n bson_iterator_next( &next );\n size = next.cur - elem->cur;\n\n if ( name_or_null == NULL ) {\n if( bson_ensure_space( b, size ) == BSON_ERROR )\n return BSON_ERROR;\n bson_append( b, elem->cur, size );\n }\n else {\n int data_size = size - 2 - strlen( bson_iterator_key( elem ) );\n bson_append_estart( b, elem->cur[0], name_or_null, data_size );\n bson_append( b, bson_iterator_value( elem ), data_size );\n }\n\n return BSON_OK;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TcpOption *tcpGetOption(TcpHeader *segment, uint8_t kind)\n{\n size_t length;\n uint_t i;\n TcpOption *option;\n\n //Make sure the TCP header is valid\n if(segment->dataOffset < 5)\n return NULL;\n\n //Compute the length of the options field\n length = segment->dataOffset * 4 - sizeof(TcpHeader);\n\n //Point to the very first option\n i = 0;\n\n //Parse TCP options\n while(i < length)\n {\n //Point to the current option\n option = (TcpOption *) (segment->options + i);\n\n //NOP option detected?\n if(option->kind == TCP_OPTION_NOP)\n {\n i++;\n continue;\n }\n //END option detected?\n if(option->kind == TCP_OPTION_END)\n break;\n //Check option length\n if((i + 1) >= length || (i + option->length) > length)\n break;\n\n //Current option kind match the specified one?\n if(option->kind == kind)\n return option;\n\n //Jump to next the next option\n i += option->length;\n }\n\n //Specified option code not found\n return NULL;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "int TLSInStream::pos()\n{\n return offset + ptr - start;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "bounded_iostream::bounded_iostream(Sirikata::DecoderWriter *w,\n const std::function &size_callback,\n const Sirikata::JpegAllocator &alloc) \n : parent(w), err(Sirikata::JpegError::nil()) {\n this->size_callback = size_callback;\n buffer_position = 0;\n byte_position = 0;\n byte_bound = 0x7FFFFFFF;\n num_bytes_attempted_to_write = 0;\n set_bound(0);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-1187", "cwe_name": "DEPRECATED: Use of Uninitialized Resource", "description": "This entry has been deprecated because it was a duplicate of CWE-908. All content has been transferred to CWE-908.", "url": "https://cwe.mitre.org/data/definitions/1187.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n // Reinterprete the opaque data provided by user.\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n\n const TfLiteType type = input1->type;\n if (type != kTfLiteInt32 && type != kTfLiteFloat32 && type != kTfLiteInt64) {\n context->ReportError(context, \"Type '%s' is not supported by floor_mod.\",\n TfLiteTypeGetName(type));\n return kTfLiteError;\n }\n output->type = type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "\tbool is_digit(char c) { return c >= '0' && c <= '9'; }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "TfLiteStatus GreaterEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n default:\n context->ReportError(context,\n \"Does not support type %d, requires float|int|uint8\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "RemoteFsDevice::Details RemoteDevicePropertiesWidget::details()\n{\n int t=type->itemData(type->currentIndex()).toInt();\n RemoteFsDevice::Details det;\n\n det.name=name->text().trimmed();\n switch (t) {\n case Type_SshFs: {\n det.url.setHost(sshHost->text().trimmed());\n det.url.setUserName(sshUser->text().trimmed());\n det.url.setPath(sshFolder->text().trimmed());\n det.url.setPort(sshPort->value());\n det.url.setScheme(RemoteFsDevice::constSshfsProtocol);\n det.extraOptions=sshExtra->text().trimmed();\n break;\n }\n case Type_File: {\n QString path=fileFolder->text().trimmed();\n if (path.isEmpty()) {\n path=\"/\";\n }\n det.url.setPath(path);\n det.url.setScheme(RemoteFsDevice::constFileProtocol);\n break;\n }\n\n }\n return det;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "char *Hub::inflate(char *data, size_t &length) {\n dynamicInflationBuffer.clear();\n\n inflationStream.next_in = (Bytef *) data;\n inflationStream.avail_in = length;\n\n int err;\n do {\n inflationStream.next_out = (Bytef *) inflationBuffer;\n inflationStream.avail_out = LARGE_BUFFER_SIZE;\n err = ::inflate(&inflationStream, Z_FINISH);\n if (!inflationStream.avail_in) {\n break;\n }\n\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n } while (err == Z_BUF_ERROR && dynamicInflationBuffer.length() <= INFLATE_LESS_THAN_ROUGHLY);\n\n inflateReset(&inflationStream);\n\n if ((err != Z_BUF_ERROR && err != Z_OK) || dynamicInflationBuffer.length() > INFLATE_LESS_THAN_ROUGHLY) {\n length = 0;\n return nullptr;\n }\n\n if (dynamicInflationBuffer.length()) {\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n\n length = dynamicInflationBuffer.length();\n return (char *) dynamicInflationBuffer.data();\n }\n\n length = LARGE_BUFFER_SIZE - inflationStream.avail_out;\n return inflationBuffer;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "void FormatConverter::InitSparseToDenseConverter(\n std::vector shape, std::vector traversal_order,\n std::vector format, std::vector dense_size,\n std::vector> segments,\n std::vector> indices, std::vector block_map) {\n dense_shape_ = std::move(shape);\n traversal_order_ = std::move(traversal_order);\n block_map_ = std::move(block_map);\n format_ = std::move(format);\n\n dense_size_ = 1;\n for (int i = 0; i < dense_shape_.size(); i++) {\n dense_size_ *= dense_shape_[i];\n }\n\n dim_metadata_.resize(2 * format_.size());\n for (int i = 0; i < format_.size(); i++) {\n if (format_[i] == kTfLiteDimDense) {\n dim_metadata_[2 * i] = {dense_size[i]};\n } else {\n dim_metadata_[2 * i] = std::move(segments[i]);\n dim_metadata_[2 * i + 1] = std::move(indices[i]);\n }\n }\n\n int original_rank = dense_shape_.size();\n int block_dim = 0;\n\n blocked_shape_.resize(original_rank);\n block_size_.resize(block_map_.size());\n for (int i = 0; i < original_rank; i++) {\n if (block_dim < block_map_.size() && block_map_[block_dim] == i) {\n if (original_rank + block_dim < traversal_order_.size()) {\n int orig_dim = traversal_order_[original_rank + block_dim];\n block_size_[block_dim] = dense_size[orig_dim];\n blocked_shape_[i] = dense_shape_[i] / dense_size[orig_dim];\n block_dim++;\n }\n } else {\n blocked_shape_[i] = dense_shape_[i];\n }\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n output->type = input->type;\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims);\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_fw_xfer32 kfw32;\n\tstruct mpt_fw_xfer kfw;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\n\tif (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))\n\t\treturn -EFAULT;\n\n\t/* Verify intended MPT adapter */\n\tiocnumX = kfw32.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mptfwxfer_ioctl @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mptfwxfer_ioctl() called\\n\",\n\t iocp->name));\n\tkfw.iocnum = iocnum;\n\tkfw.fwlen = kfw32.fwlen;\n\tkfw.bufp = compat_ptr(kfw32.bufp);\n\n\tret = mptctl_do_fw_download(iocp, kfw.bufp, kfw.fwlen);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-362", "cwe_name": "Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')", "description": "The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.", "url": "https://cwe.mitre.org/data/definitions/362.html", "label_name": "safe"} {"code": "inline TfLiteTensor* GetMutableInput(const TfLiteContext* context,\n const TfLiteNode* node, int index) {\n if (index >= 0 && index < node->inputs->size) {\n const int tensor_index = node->inputs->data[index];\n if (tensor_index != kTfLiteOptionalTensor) {\n if (context->tensors != nullptr) {\n return &context->tensors[tensor_index];\n } else {\n return context->GetTensor(context, tensor_index);\n }\n }\n }\n return nullptr;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "R_API RBinJavaVerificationObj *r_bin_java_verification_info_from_type(RBinJavaObj *bin, R_BIN_JAVA_STACKMAP_TYPE type, ut32 value) {\n\tRBinJavaVerificationObj *se = R_NEW0 (RBinJavaVerificationObj);\n\tif (!se) {\n\t\treturn NULL;\n\t}\n\tse->tag = type;\n\tif (se->tag == R_BIN_JAVA_STACKMAP_OBJECT) {\n\t\tse->info.obj_val_cp_idx = (ut16) value;\n\t} else if (se->tag == R_BIN_JAVA_STACKMAP_UNINIT) {\n\t\t/*if (bin->offset_sz == 4) {\n\t\tse->info.uninit_offset = value;\n\t\t} else {\n\t\tse->info.uninit_offset = (ut16) value;\n\t\t}*/\n\t\tse->info.uninit_offset = (ut16) value;\n\t}\n\treturn se;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-805", "cwe_name": "Buffer Access with Incorrect Length Value", "description": "The software uses a sequential operation to read or write a buffer, but it uses an incorrect length value that causes it to access memory that is outside of the bounds of the buffer.", "url": "https://cwe.mitre.org/data/definitions/805.html", "label_name": "vulnerable"} {"code": " friend bool operator==(const TensorKey& t1, const TensorKey& t2) {\n if (t1.dtype() != t2.dtype() || t1.shape() != t2.shape()) {\n return false;\n }\n if (DataTypeCanUseMemcpy(t1.dtype())) {\n return t1.tensor_data() == t2.tensor_data();\n } else if (t1.dtype() == DT_STRING) {\n const auto s1 = t1.unaligned_flat();\n const auto s2 = t2.unaligned_flat();\n for (int64_t i = 0, n = t1.NumElements(); i < n; ++i) {\n if (TF_PREDICT_FALSE(s1(i) != s2(i))) {\n return false;\n }\n }\n return true;\n } else {\n DCHECK(false) << \"Unimplemented dtype \" << DataTypeString(t1.dtype())\n << std::endl;\n }\n return false;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "String StringUtil::Crypt(const String& input, const char *salt /* = \"\" */) {\n if (salt && salt[0] == '\\0') {\n raise_notice(\"crypt(): No salt parameter was specified.\"\n \" You must use a randomly generated salt and a strong\"\n \" hash function to produce a secure hash.\");\n }\n return String(string_crypt(input.c_str(), salt), AttachString);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " Status CalculateOutputIndex(OpKernelContext* context, int dimension,\n const vector& parent_output_index,\n INDEX_TYPE output_index_multiplier,\n INDEX_TYPE output_size,\n vector* result) {\n const RowPartitionTensor row_partition_tensor =\n GetRowPartitionTensor(context, dimension);\n auto partition_type = GetRowPartitionTypeByDimension(dimension);\n switch (partition_type) {\n case RowPartitionType::VALUE_ROWIDS:\n CalculateOutputIndexValueRowID(\n context, row_partition_tensor, parent_output_index,\n output_index_multiplier, output_size, result);\n return tensorflow::Status::OK();\n case RowPartitionType::ROW_SPLITS:\n if (row_partition_tensor.size() - 1 > parent_output_index.size()) {\n return errors::InvalidArgument(\n \"Row partition size is greater than output size: \",\n row_partition_tensor.size() - 1, \" > \",\n parent_output_index.size());\n }\n CalculateOutputIndexRowSplit(\n context, row_partition_tensor, parent_output_index,\n output_index_multiplier, output_size, result);\n return tensorflow::Status::OK();\n default:\n return errors::InvalidArgument(\n \"Unsupported partition type:\",\n RowPartitionTypeToString(partition_type));\n }\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-131", "cwe_name": "Incorrect Calculation of Buffer Size", "description": "The software does not correctly calculate the size to be used when allocating a buffer, which could lead to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/131.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 2);\n\n TF_LITE_ENSURE_TYPES_EQ(context, output->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n TF_LITE_ENSURE(context, params->spectrogram->Initialize(params->window_size,\n params->stride));\n const int64_t sample_count = input->dims->data[0];\n const int64_t length_minus_window = (sample_count - params->window_size);\n if (length_minus_window < 0) {\n params->output_height = 0;\n } else {\n params->output_height = 1 + (length_minus_window / params->stride);\n }\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(3);\n output_size->data[0] = input->dims->data[1];\n output_size->data[1] = params->output_height;\n output_size->data[2] = params->spectrogram->output_frequency_channels();\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const CTCBeamSearchDecoderParams* option =\n reinterpret_cast(node->user_data);\n const int top_paths = option->top_paths;\n TF_LITE_ENSURE(context, option->beam_width >= top_paths);\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n // The outputs should be top_paths * 3 + 1.\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 3 * top_paths + 1);\n\n const TfLiteTensor* inputs = GetInput(context, node, kInputsTensor);\n TF_LITE_ENSURE_EQ(context, NumDimensions(inputs), 3);\n // TensorFlow only supports float.\n TF_LITE_ENSURE_EQ(context, inputs->type, kTfLiteFloat32);\n const int batch_size = SizeOfDimension(inputs, 1);\n\n const TfLiteTensor* sequence_length =\n GetInput(context, node, kSequenceLengthTensor);\n TF_LITE_ENSURE_EQ(context, NumDimensions(sequence_length), 1);\n TF_LITE_ENSURE_EQ(context, NumElements(sequence_length), batch_size);\n // TensorFlow only supports int32.\n TF_LITE_ENSURE_EQ(context, sequence_length->type, kTfLiteInt32);\n\n // Resize decoded outputs.\n // Do not resize indices & values cause we don't know the values yet.\n for (int i = 0; i < top_paths; ++i) {\n TfLiteTensor* indices = GetOutput(context, node, i);\n SetTensorToDynamic(indices);\n TfLiteTensor* values = GetOutput(context, node, i + top_paths);\n SetTensorToDynamic(values);\n TfLiteTensor* output_shape = GetOutput(context, node, i + 2 * top_paths);\n SetTensorToDynamic(output_shape);\n }\n\n // Resize log probability outputs.\n TfLiteTensor* log_probability_output =\n GetOutput(context, node, top_paths * 3);\n TfLiteIntArray* log_probability_output_shape_array = TfLiteIntArrayCreate(2);\n log_probability_output_shape_array->data[0] = batch_size;\n log_probability_output_shape_array->data[1] = top_paths;\n return context->ResizeTensor(context, log_probability_output,\n log_probability_output_shape_array);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *portno, int get_err, zend_string **err)\n{\n\tchar *colon;\n\tchar *host = NULL;\n\n#ifdef HAVE_IPV6\n\tchar *p;\n\n\tif (*(str) == '[' && str_len > 1) {\n\t\t/* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */\n\t\tp = memchr(str + 1, ']', str_len - 2);\n\t\tif (!p || *(p + 1) != ':') {\n\t\t\tif (get_err) {\n\t\t\t\t*err = strpprintf(0, \"Failed to parse IPv6 address \\\"%s\\\"\", str);\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\t\t*portno = atoi(p + 2);\n\t\treturn estrndup(str + 1, p - str - 1);\n\t}\n#endif\n\tif (str_len) {\n\t\tcolon = memchr(str, ':', str_len - 1);\n\t} else {\n\t\tcolon = NULL;\n\t}\n\tif (colon) {\n\t\t*portno = atoi(colon + 1);\n\t\thost = estrndup(str, colon - str);\n\t} else {\n\t\tif (get_err) {\n\t\t\t*err = strpprintf(0, \"Failed to parse address \\\"%s\\\"\", str);\n\t\t}\n\t\treturn NULL;\n\t}\n\n\treturn host;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " size_t operator()(const ArrayOrObject data) const {\n return data.toOpaque();\n }", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "PROCESS_THREAD(snmp_process, ev, data)\n{\n PROCESS_BEGIN();\n\n /* new connection with remote host */\n snmp_udp_conn = udp_new(NULL, 0, NULL);\n udp_bind(snmp_udp_conn, SNMP_SERVER_PORT);\n LOG_DBG(\"Listening on port %u\\n\", uip_ntohs(snmp_udp_conn->lport));\n\n while(1) {\n PROCESS_YIELD();\n\n if(ev == tcpip_event) {\n if(uip_newdata()) {\n snmp_process_data();\n }\n }\n } /* while (1) */\n\n PROCESS_END();\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus ResizeOutput(TfLiteContext* context, TfLiteNode* node) {\n TfLiteIntArray* output_shape = GetOutputShape(context, node);\n std::unique_ptr\n scoped_output_shape(output_shape, TfLiteIntArrayFree);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n // Tensorflow's Reshape allows one of the shape components to have the\n // special -1 value, meaning it will be calculated automatically based on the\n // input. Here we calculate what that dimension should be so that the number\n // of output elements in the same as the number of input elements.\n int num_input_elements = NumElements(input);\n\n int num_output_elements = 1;\n int stretch_dim = -1;\n for (int i = 0; i < output_shape->size; ++i) {\n int value = output_shape->data[i];\n if (value == -1) {\n TF_LITE_ENSURE_EQ(context, stretch_dim, -1);\n stretch_dim = i;\n } else {\n num_output_elements *= value;\n }\n }\n if (stretch_dim != -1) {\n output_shape->data[stretch_dim] = num_input_elements / num_output_elements;\n num_output_elements *= output_shape->data[stretch_dim];\n }\n\n TF_LITE_ENSURE_EQ(context, num_input_elements, num_output_elements);\n return context->ResizeTensor(context, output, scoped_output_shape.release());\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* dims;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kDimsTensor, &dims));\n const TfLiteTensor* value;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kValueTensor, &value));\n\n // Make sure the 1st input tensor is 1-D.\n TF_LITE_ENSURE_EQ(context, NumDimensions(dims), 1);\n\n // Make sure the 1st input tensor is int32 or int64.\n const auto dtype = dims->type;\n TF_LITE_ENSURE(context, dtype == kTfLiteInt32 || dtype == kTfLiteInt64);\n\n // Make sure the 2nd input tensor is a scalar.\n TF_LITE_ENSURE_EQ(context, NumDimensions(value), 0);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n output->type = value->type;\n\n if (IsConstantTensor(dims)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, dims, output));\n } else {\n SetTensorToDynamic(output);\n }\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output_tensor != nullptr);\n TfLiteType output_type = output_tensor->type;\n\n switch (output_type) { // Already know in/outtypes are same.\n case kTfLiteFloat32:\n EvalUnquantized(context, node);\n break;\n case kTfLiteInt32:\n EvalUnquantized(context, node);\n break;\n case kTfLiteUInt8:\n EvalQuantizedUInt8(context, node);\n break;\n case kTfLiteInt8:\n EvalUnquantized(context, node);\n break;\n case kTfLiteInt64:\n EvalUnquantized(context, node);\n break;\n\n default:\n TF_LITE_KERNEL_LOG(\n context, \"Op Concatenation does not currently support Type '%s'.\",\n TfLiteTypeGetName(output_type));\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus ReshapeOutput(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TF_LITE_ENSURE(context, input != nullptr);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE(context, output != nullptr);\n // Tensorflow's Reshape allows one of the shape components to have the\n // special -1 value, meaning it will be calculated automatically based on the\n // input. Here we calculate what that dimension should be so that the number\n // of output elements in the same as the number of input elements.\n int num_input_elements = NumElements(input);\n TfLiteIntArray* output_shape = output->dims;\n\n if (NumInputs(node) == 1 && // Legacy scalar supported with params.\n output_shape->size == 1 && output_shape->data[0] == 0) {\n // Legacy tflite models use a shape parameter of [0] to indicate scalars,\n // so adjust accordingly. TODO(b/111614235): Allow zero-sized buffers during\n // toco conversion.\n output_shape->size = 0;\n }\n\n int num_output_elements = 1;\n int stretch_dim = -1;\n for (int i = 0; i < output_shape->size; ++i) {\n int value = output_shape->data[i];\n if (value == -1) {\n TF_LITE_ENSURE_EQ(context, stretch_dim, -1);\n stretch_dim = i;\n } else {\n num_output_elements *= value;\n }\n }\n if (stretch_dim != -1) {\n output_shape->data[stretch_dim] = num_input_elements / num_output_elements;\n num_output_elements *= output_shape->data[stretch_dim];\n }\n\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n TF_LITE_ENSURE_EQ(context, num_input_elements, num_output_elements);\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "\tvoid initialize(const string &path, bool owner) {\n\t\tTRACE_POINT();\n\t\tthis->path = path;\n\t\tthis->owner = owner;\n\t\t\n\t\t/* Create the server instance directory. We only need to write to this\n\t\t * directory for these reasons:\n\t\t * 1. Initial population of structure files (structure_version.txt, instance.pid).\n\t\t * 2. Creating/removing a generation directory.\n\t\t * 3. Removing the entire server instance directory (after all\n\t\t * generations are removed).\n\t\t *\n\t\t * 1 and 2 are done by the helper server during initialization and before lowering\n\t\t * privilege. 3 is done during helper server shutdown by a cleanup process that's\n\t\t * running as the same user the helper server was running as before privilege\n\t\t * lowering.\n\t\t * Therefore, we make the directory only writable by the user the helper server\n\t\t * was running as before privilege is lowered. Everybody else has read and execute\n\t\t * rights though, because we want admin tools to be able to list the available\n\t\t * generations no matter what user they're running as.\n\t\t */\n\t\tif (owner) {\n\t\t\tswitch (getFileType(path)) {\n\t\t\tcase FT_NONEXISTANT:\n\t\t\t\tcreateDirectory(path);\n\t\t\t\tbreak;\n\t\t\tcase FT_DIRECTORY:\n\t\t\t\tremoveDirTree(path);\n\t\t\t\tcreateDirectory(path);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow RuntimeException(\"'\" + path + \"' already exists, and is not a directory\");\n\t\t\t}\n\t\t} else if (getFileType(path) != FT_DIRECTORY) {\n\t\t\tthrow RuntimeException(\"Server instance directory '\" + path +\n\t\t\t\t\"' does not exist\");\n\t\t}\n\t}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-59", "cwe_name": "Improper Link Resolution Before File Access ('Link Following')", "description": "The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.", "url": "https://cwe.mitre.org/data/definitions/59.html", "label_name": "safe"} {"code": "TfLiteStatus ResizeOutputTensors(TfLiteContext* context, TfLiteNode* node,\n const TfLiteTensor* axis,\n const TfLiteTensor* input, int num_splits) {\n int axis_value = GetTensorData(axis)[0];\n if (axis_value < 0) {\n axis_value += NumDimensions(input);\n }\n\n TF_LITE_ENSURE(context, axis_value >= 0);\n TF_LITE_ENSURE(context, axis_value < NumDimensions(input));\n\n const int input_size = SizeOfDimension(input, axis_value);\n TF_LITE_ENSURE_MSG(context, input_size % num_splits == 0,\n \"Not an even split\");\n const int slice_size = input_size / num_splits;\n\n for (int i = 0; i < NumOutputs(node); ++i) {\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output_dims->data[axis_value] = slice_size;\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, i, &output));\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_dims));\n }\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " int Bind(const Node& node, int max_retry) override {\n receiver_ = zmq_socket(context_, ZMQ_ROUTER);\n CHECK(receiver_ != NULL)\n << \"create receiver socket failed: \" << zmq_strerror(errno);\n int local = GetEnv(\"DMLC_LOCAL\", 0);\n std::string hostname = node.hostname.empty() ? \"*\" : node.hostname;\n std::string addr = local ? \"ipc:///tmp/\" : \"tcp://\" + hostname + \":\";\n int port = node.port;\n unsigned seed = static_cast(time(NULL)+port);\n for (int i = 0; i < max_retry+1; ++i) {\n auto address = addr + std::to_string(port);\n if (zmq_bind(receiver_, address.c_str()) == 0) break;\n if (i == max_retry) {\n port = -1;\n } else {\n port = 10000 + rand_r(&seed) % 40000;\n }\n }\n return port;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static int StreamTcpTest10 (void)\n{\n Packet *p = SCMalloc(SIZE_OF_PACKET);\n FAIL_IF(unlikely(p == NULL));\n Flow f;\n ThreadVars tv;\n StreamTcpThread stt;\n TCPHdr tcph;\n uint8_t payload[4];\n memset(p, 0, SIZE_OF_PACKET);\n PacketQueue pq;\n memset(&pq,0,sizeof(PacketQueue));\n memset (&f, 0, sizeof(Flow));\n memset(&tv, 0, sizeof (ThreadVars));\n memset(&stt, 0, sizeof (StreamTcpThread));\n memset(&tcph, 0, sizeof (TCPHdr));\n FLOW_INITIALIZE(&f);\n p->flow = &f;\n\n StreamTcpUTInit(&stt.ra_ctx);\n stream_config.async_oneside = TRUE;\n\n tcph.th_win = htons(5480);\n tcph.th_seq = htonl(10);\n tcph.th_ack = htonl(11);\n tcph.th_flags = TH_SYN;\n p->tcph = &tcph;\n\n FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1);\n\n p->tcph->th_seq = htonl(11);\n p->tcph->th_ack = htonl(11);\n p->tcph->th_flags = TH_ACK;\n p->flowflags = FLOW_PKT_TOSERVER;\n\n FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1);\n\n p->tcph->th_seq = htonl(11);\n p->tcph->th_ack = htonl(11);\n p->tcph->th_flags = TH_ACK|TH_PUSH;\n p->flowflags = FLOW_PKT_TOSERVER;\n\n StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/\n p->payload = payload;\n p->payload_len = 3;\n\n FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1);\n\n p->tcph->th_seq = htonl(6);\n p->tcph->th_ack = htonl(11);\n p->tcph->th_flags = TH_ACK|TH_PUSH;\n p->flowflags = FLOW_PKT_TOSERVER;\n\n StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/\n p->payload = payload;\n p->payload_len = 3;\n\n FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1);\n\n FAIL_IF(((TcpSession *)(p->flow->protoctx))->state != TCP_ESTABLISHED);\n\n FAIL_IF(! (((TcpSession *)(p->flow->protoctx))->flags & STREAMTCP_FLAG_ASYNC));\n\n FAIL_IF(((TcpSession *)(p->flow->protoctx))->client.last_ack != 6 &&\n ((TcpSession *)(p->flow->protoctx))->server.next_seq != 11);\n\n StreamTcpSessionClear(p->flow->protoctx);\n\n SCFree(p);\n FLOW_DESTROY(&f);\n StreamTcpUTDeinit(stt.ra_ctx);\n PASS;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-436", "cwe_name": "Interpretation Conflict", "description": "Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.", "url": "https://cwe.mitre.org/data/definitions/436.html", "label_name": "vulnerable"} {"code": "TEST_P(SslSPIFFECertValidatorIntegrationTest, ServerRsaSPIFFEValidatorSANMatch) {\n auto typed_conf = new envoy::config::core::v3::TypedExtensionConfig();\n TestUtility::loadFromYaml(TestEnvironment::substitute(R\"EOF(\nname: envoy.tls.cert_validator.spiffe\ntyped_config:\n \"@type\": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig\n trust_domains:\n - name: lyft.com\n trust_bundle:\n filename: \"{{ test_rundir }}/test/config/integration/certs/cacert.pem\"\n )EOF\"),\n *typed_conf);\n custom_validator_config_ = typed_conf;\n\n envoy::type::matcher::v3::StringMatcher matcher;\n matcher.set_prefix(\"spiffe://lyft.com/\");\n san_matchers_ = {matcher};\n\n ConnectionCreationFunction creator = [&]() -> Network::ClientConnectionPtr {\n return makeSslClientConnection({});\n };\n testRouterRequestAndResponseWithBody(1024, 512, false, false, &creator);\n checkVerifyErrorCouter(0);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "vulnerable"} {"code": "void KPasswordDlg::keyPressed( QKeyEvent *e )\n{\n static bool waitForAuthentication = false;\n if (!waitForAuthentication) {\n\tswitch ( e->key() )\n\t{\n\t\tcase Key_Backspace:\n\t\t\t{\n\t\t\t\tint len = password.length();\n\t\t\t\tif ( len ) {\n\t\t\t\t\tpassword.truncate( len - 1 );\n\t\t\t\t\tif( stars )\n\t\t\t\t\t\tshowStars();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase Key_Return:\n timer.stop();\n\t\t\twaitForAuthentication = true;\n\t\t\tif ( tryPassword() )\n\t\t\t\temit passOk();\n\t\t\telse\n\t\t\t{\n\t\t\t\tlabel->setText( glocale->translate(\"Failed\") );\n\t\t\t\tpassword = \"\";\n\t\t\t\ttimerMode = 1;\n\t\t\t\ttimer.start( 1500, TRUE );\n\t\t\t}\n\t\t\twaitForAuthentication = false;\n\t\t\tbreak;\n\n\t\tcase Key_Escape:\n\t\t\temit passCancel();\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tif ( password.length() < MAX_PASSWORD_LENGTH )\n\t\t\t{\n\t\t\t\tpassword += (char)e->ascii();\n\t\t\t\tif( stars )\n\t\t\t\t\tshowStars();\n\t\t\t\ttimer.changeInterval( 10000 );\n\t\t\t}\n\t}\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "static BOOL ntlm_av_pair_get_next_offset(const NTLM_AV_PAIR* pAvPair, size_t size, size_t* pOffset)\n{\n\tsize_t avLen;\n\tif (!pOffset)\n\t\treturn FALSE;\n\n\tif (!ntlm_av_pair_get_len(pAvPair, size, &avLen))\n\t\treturn FALSE;\n\t*pOffset = avLen + sizeof(NTLM_AV_PAIR);\n\treturn TRUE;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "int HexInStream::pos() {\n return offset + ptr - start;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* start = GetInput(context, node, kStartTensor);\n const TfLiteTensor* limit = GetInput(context, node, kLimitTensor);\n const TfLiteTensor* delta = GetInput(context, node, kDeltaTensor);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (IsDynamicTensor(output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeOutput(context, start, limit, delta, output));\n }\n\n switch (output->type) {\n case kTfLiteInt32: {\n EvalImpl(start, delta, output);\n break;\n }\n case kTfLiteFloat32: {\n EvalImpl(start, delta, output);\n break;\n }\n default: {\n context->ReportError(context, \"Unsupported data type: %d\", output->type);\n return kTfLiteError;\n }\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void pb_controller::play_file(const std::string& file) {\n\tstd::string cmdline;\n\tstd::string player = cfg->get_configvalue(\"player\");\n\tif (player == \"\")\n\t\treturn;\n\tcmdline.append(player);\n\tcmdline.append(\" \\\"\");\n\tcmdline.append(utils::replace_all(file,\"\\\"\", \"\\\\\\\"\"));\n\tcmdline.append(\"\\\"\");\n\tstfl::reset();\n\tutils::run_interactively(cmdline, \"pb_controller::play_file\");\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": "static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *portno, int get_err, zend_string **err)\n{\n\tchar *colon;\n\tchar *host = NULL;\n\n#ifdef HAVE_IPV6\n\tif (*(str) == '[' && str_len > 1) {\n\t\t/* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */\n\t\tchar *p = memchr(str + 1, ']', str_len - 2), *e = NULL;\n\t\tif (!p || *(p + 1) != ':') {\n\t\t\tif (get_err) {\n\t\t\t\t*err = strpprintf(0, \"Failed to parse IPv6 address \\\"%s\\\"\", str);\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\t\t*portno = strtol(p + 2, &e, 10);\n\t\tif (e && *e) {\n\t\t\tif (get_err) {\n\t\t\t\t*err = strpprintf(0, \"Failed to parse address \\\"%s\\\"\", str);\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\t\treturn estrndup(str + 1, p - str - 1);\n\t}\n#endif\n\n\tif (str_len) {\n\t\tcolon = memchr(str, ':', str_len - 1);\n\t} else {\n\t\tcolon = NULL;\n\t}\n\n\tif (colon) {\n\t\tchar *e = NULL;\n\t\t*portno = strtol(colon + 1, &e, 10);\n\t\tif (!e || !*e) {\n\t\t\treturn estrndup(str, colon - str);\n\t\t}\n\t}\n\n\tif (get_err) {\n\t\t*err = strpprintf(0, \"Failed to parse address \\\"%s\\\"\", str);\n\t}\n\treturn NULL;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "inline typename V::VectorType FBUnserializer::unserializeList() {\n p_ += CODE_SIZE;\n\n // the list size is written so we can reserve it in the vector\n // in future. Skip past it for now.\n unserializeInt64();\n\n typename V::VectorType ret = V::createVector();\n\n size_t code = nextCode();\n while (code != FB_SERIALIZE_STOP) {\n V::vectorAppend(ret, unserializeThing());\n code = nextCode();\n }\n p_ += CODE_SIZE;\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-674", "cwe_name": "Uncontrolled Recursion", "description": "The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.", "url": "https://cwe.mitre.org/data/definitions/674.html", "label_name": "vulnerable"} {"code": "void ZlibInStream::deinit()\n{\n assert(zs != NULL);\n removeUnderlying();\n inflateEnd(zs);\n delete zs;\n zs = NULL;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-672", "cwe_name": "Operation on a Resource after Expiration or Release", "description": "The software uses, accesses, or otherwise operates on a resource after that resource has been expired, released, or revoked.", "url": "https://cwe.mitre.org/data/definitions/672.html", "label_name": "vulnerable"} {"code": "void RemoteFsDevice::serviceAdded(const QString &name)\n{\n if (name==details.serviceName && constSambaAvahiProtocol==details.url.scheme()) {\n sub=tr(\"Available\");\n updateStatus();\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* axis = GetInput(context, node, kAxis);\n // Make sure the axis is only 1 dimension.\n TF_LITE_ENSURE_EQ(context, NumElements(axis), 1);\n // Make sure the axis is only either int32 or int64.\n TF_LITE_ENSURE(context,\n axis->type == kTfLiteInt32 || axis->type == kTfLiteInt64);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n auto* params = reinterpret_cast(node->builtin_data);\n switch (params->output_type) {\n case kTfLiteInt32:\n output->type = kTfLiteInt32;\n break;\n case kTfLiteInt64:\n output->type = kTfLiteInt64;\n break;\n default:\n context->ReportError(context, \"Unknown index output data type: %d\",\n params->output_type);\n return kTfLiteError;\n }\n\n // Check conditions for different types.\n switch (input->type) {\n case kTfLiteFloat32:\n case kTfLiteUInt8:\n case kTfLiteInt8:\n case kTfLiteInt32:\n break;\n\n default:\n context->ReportError(\n context,\n \"Unknown input type: %d, only float32 and int types are supported\",\n input->type);\n return kTfLiteError;\n }\n\n TF_LITE_ENSURE(context, NumDimensions(input) >= 1);\n\n if (IsConstantTensor(axis)) {\n TF_LITE_ENSURE_STATUS(ResizeOutput(context, input, axis, output));\n } else {\n SetTensorToDynamic(output);\n }\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "int64_t MemFile::readImpl(char *buffer, int64_t length) {\n assertx(m_len != -1);\n assertx(length > 0);\n int64_t remaining = m_len - m_cursor;\n if (remaining < length) length = remaining;\n if (length > 0) {\n memcpy(buffer, (const void *)(m_data + m_cursor), length);\n }\n m_cursor += length;\n return length;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "void ecall_non_oblivious_aggregate_step1(\n uint8_t *agg_op, size_t agg_op_length,\n uint8_t *input_rows, size_t input_rows_length,\n uint8_t **first_row, size_t *first_row_length,\n uint8_t **last_group, size_t *last_group_length,\n uint8_t **last_row, size_t *last_row_length) {\n // Guard against operating on arbitrary enclave memory\n assert(sgx_is_outside_enclave(input_rows, input_rows_length) == 1);\n sgx_lfence();\n\n try {\n non_oblivious_aggregate_step1(\n agg_op, agg_op_length,\n input_rows, input_rows_length,\n first_row, first_row_length,\n last_group, last_group_length,\n last_row, last_row_length);\n } catch (const std::runtime_error &e) {\n ocall_throw(e.what());\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "void FilterManager::maybeEndDecode(bool end_stream) {\n ASSERT(!state_.remote_complete_);\n state_.remote_complete_ = end_stream;\n if (end_stream) {\n stream_info_.downstreamTiming().onLastDownstreamRxByteReceived(dispatcher().timeSource());\n ENVOY_STREAM_LOG(debug, \"request end stream\", *this);\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": "QStringList JlCompress::extractDir(QuaZip &zip, const QString &dir)\n{\n if(!zip.open(QuaZip::mdUnzip)) {\n return QStringList();\n }\n\n QDir directory(dir);\n QStringList extracted;\n if (!zip.goToFirstFile()) {\n return QStringList();\n }\n do {\n QString name = zip.getCurrentFileName();\n QString absFilePath = directory.absoluteFilePath(name);\n if (!extractFile(&zip, \"\", absFilePath)) {\n removeFile(extracted);\n return QStringList();\n }\n extracted.append(absFilePath);\n } while (zip.goToNextFile());\n\n // Chiudo il file zip\n zip.close();\n if(zip.getZipError()!=0) {\n removeFile(extracted);\n return QStringList();\n }\n\n return extracted;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "bool logToUSDT(const Array& bt) {\n std::lock_guard lock(usdt_mutex);\n\n memset(&bt_slab, 0, sizeof(bt_slab));\n\n int i = 0;\n IterateVNoInc(\n bt.get(),\n [&](TypedValue tv) -> bool {\n\n if (i >= strobelight::kMaxStackframes) {\n return true;\n }\n\n assertx(isArrayLikeType(type(tv)));\n ArrayData* bt_frame = val(tv).parr;\n strobelight::backtrace_frame_t* frame = &bt_slab.frames[i];\n\n auto const line = bt_frame->get(s_line.get());\n if (line.is_init()) {\n assertx(isIntType(type(line)));\n frame->line = val(line).num;\n }\n\n auto const file_name = bt_frame->get(s_file.get());\n if (file_name.is_init()) {\n assertx(isStringType(type(file_name)));\n strncpy(frame->file_name,\n val(file_name).pstr->data(),\n std::min(val(file_name).pstr->size(), strobelight::kFileNameMax));\n frame->file_name[strobelight::kFileNameMax - 1] = '\\0';\n }\n\n auto const class_name = bt_frame->get(s_class.get());\n if (class_name.is_init()) {\n assertx(isStringType(type(class_name)));\n strncpy(frame->class_name,\n val(class_name).pstr->data(),\n std::min(val(class_name).pstr->size(), strobelight::kClassNameMax));\n frame->class_name[strobelight::kClassNameMax - 1] = '\\0';\n }\n\n auto const function_name = bt_frame->get(s_function.get());\n if (function_name.is_init()) {\n assertx(isStringType(type(function_name)));\n strncpy(frame->function,\n val(function_name).pstr->data(),\n std::min(val(function_name).pstr->size(),\n strobelight::kFunctionMax));\n frame->function[strobelight::kFunctionMax - 1] = '\\0';\n }\n\n i++;\n return false;\n }\n );\n bt_slab.len = i;\n\n // Allow BPF to read the now-formatted stacktrace\n FOLLY_SDT_WITH_SEMAPHORE(hhvm, hhvm_stack, &bt_slab);\n\n return true;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void Con_Dump_f( void ) {\n\tint l, x, i;\n\tshort *line;\n\tfileHandle_t f;\n\tint\t\tbufferlen;\n\tchar\t*buffer;\n\tchar\tfilename[MAX_QPATH];\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"usage: condump \\n\" );\n\t\treturn;\n\t}\n\n\tQ_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );\n\tCOM_DefaultExtension( filename, sizeof( filename ), \".txt\" );\n\n\tif (!COM_CompareExtension(filename, \".txt\"))\n\t{\n\t\tCom_Printf(\"Con_Dump_f: Only the \\\".txt\\\" extension is supported by this command!\\n\");\n\t\treturn;\n\t}\n\n\tf = FS_FOpenFileWrite( filename );\n\tif ( !f ) {\n\t\tCom_Printf (\"ERROR: couldn't open %s.\\n\", filename);\n\t\treturn;\n\t}\n\n\tCom_Printf (\"Dumped console text to %s.\\n\", filename );\n\n\t// skip empty lines\n\tfor ( l = con.current - con.totallines + 1 ; l <= con.current ; l++ )\n\t{\n\t\tline = con.text + ( l % con.totallines ) * con.linewidth;\n\t\tfor ( x = 0 ; x < con.linewidth ; x++ )\n\t\t\tif ( ( line[x] & 0xff ) != ' ' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif ( x != con.linewidth ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n#ifdef _WIN32\n\tbufferlen = con.linewidth + 3 * sizeof ( char );\n#else\n\tbufferlen = con.linewidth + 2 * sizeof ( char );\n#endif\n\n\tbuffer = Hunk_AllocateTempMemory( bufferlen );\n\n\t// write the remaining lines\n\tbuffer[bufferlen-1] = 0;\n\tfor ( ; l <= con.current ; l++ )\n\t{\n\t\tline = con.text + ( l % con.totallines ) * con.linewidth;\n\t\tfor ( i = 0; i < con.linewidth; i++ )\n\t\t\tbuffer[i] = line[i] & 0xff;\n\t\tfor ( x = con.linewidth - 1 ; x >= 0 ; x-- )\n\t\t{\n\t\t\tif ( buffer[x] == ' ' ) {\n\t\t\t\tbuffer[x] = 0;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n#ifdef _WIN32\n\t\tQ_strcat(buffer, bufferlen, \"\\r\\n\");\n#else\n\t\tQ_strcat(buffer, bufferlen, \"\\n\");\n#endif\n\t\tFS_Write( buffer, strlen( buffer ), f );\n\t}\n\n\tHunk_FreeTempMemory( buffer );\n\tFS_FCloseFile( f );\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "Variant HHVM_FUNCTION(mcrypt_generic_init, const Resource& td,\n const String& key,\n const String& iv) {\n auto pm = get_valid_mcrypt_resource(td);\n if (!pm) {\n return false;\n }\n\n int max_key_size = mcrypt_enc_get_key_size(pm->m_td);\n int iv_size = mcrypt_enc_get_iv_size(pm->m_td);\n\n if (key.empty()) {\n raise_warning(\"Key size is 0\");\n }\n\n unsigned char *key_s = (unsigned char *)malloc(key.size());\n memset(key_s, 0, key.size());\n\n unsigned char *iv_s = (unsigned char *)malloc(iv_size + 1);\n memset(iv_s, 0, iv_size + 1);\n\n int key_size;\n if (key.size() > max_key_size) {\n raise_warning(\"Key size too large; supplied length: %ld, max: %d\",\n key.size(), max_key_size);\n key_size = max_key_size;\n } else {\n key_size = key.size();\n }\n memcpy(key_s, key.data(), key.size());\n\n if (iv.size() != iv_size) {\n raise_warning(\"Iv size incorrect; supplied length: %ld, needed: %d\",\n iv.size(), iv_size);\n }\n memcpy(iv_s, iv.data(), std::min(iv_size, iv.size()));\n\n mcrypt_generic_deinit(pm->m_td);\n int result = mcrypt_generic_init(pm->m_td, key_s, key_size, iv_s);\n\n /* If this function fails, close the mcrypt module to prevent crashes\n * when further functions want to access this resource */\n if (result < 0) {\n pm->close();\n switch (result) {\n case -3:\n raise_warning(\"Key length incorrect\");\n break;\n case -4:\n raise_warning(\"Memory allocation error\");\n break;\n case -1:\n default:\n raise_warning(\"Unknown error\");\n break;\n }\n } else {\n pm->m_init = true;\n }\n\n free(iv_s);\n free(key_s);\n return result;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n\n OpContext op_context(context, node);\n\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), op_context.params->num_splits);\n\n auto input_type = op_context.input->type;\n TF_LITE_ENSURE(context,\n input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8 ||\n input_type == kTfLiteInt8 || input_type == kTfLiteInt16 ||\n input_type == kTfLiteInt32);\n for (int i = 0; i < NumOutputs(node); ++i) {\n TfLiteTensor* tensor;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, i, &tensor));\n tensor->type = input_type;\n }\n\n // If we know the contents of the 'axis' tensor, resize all outputs.\n // Otherwise, wait until Eval().\n if (IsConstantTensor(op_context.axis)) {\n return ResizeOutputTensors(context, node, op_context.axis, op_context.input,\n op_context.params->num_splits);\n } else {\n return UseDynamicOutputTensors(context, node);\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " void Compute(OpKernelContext* ctx) override {\n const Tensor& in0 = ctx->input(0);\n const Tensor& in1 = ctx->input(1);\n OP_REQUIRES(\n ctx, in0.NumElements() == in1.NumElements(),\n errors::InvalidArgument(\"The two arguments to a cwise op must have \"\n \"same number of elements, got \",\n in0.NumElements(), \" and \", in1.NumElements()));\n auto in0_flat = in0.flat();\n auto in1_flat = in1.flat();\n const Device& eigen_device = ctx->eigen_device();\n\n Tensor* out = nullptr;\n if (std::is_same::value) {\n OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n {0, 1}, 0, in0.shape(), &out));\n } else {\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, in0.shape(), &out));\n }\n auto out_flat = out->flat();\n functor::SimpleBinaryFunctor()(eigen_device, out_flat,\n in0_flat, in1_flat);\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n output->type = input2->type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "FontData::FontData(FontData* data, int32_t offset) {\n Init(data->array_);\n Bound(data->bound_offset_ + offset,\n (data->bound_length_ == GROWABLE_SIZE)\n ? GROWABLE_SIZE : data->bound_length_ - offset);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-189", "cwe_name": "Numeric Errors", "description": "Weaknesses in this category are related to improper calculation or conversion of numbers.", "url": "https://cwe.mitre.org/data/definitions/189.html", "label_name": "vulnerable"} {"code": "TypedValue HHVM_FUNCTION(substr_compare,\n const String& main_str,\n const String& str,\n int offset,\n int length /* = INT_MAX */,\n bool case_insensitivity /* = false */) {\n int s1_len = main_str.size();\n int s2_len = str.size();\n\n if (length <= 0) {\n raise_warning(\"The length must be greater than zero\");\n return make_tv(false);\n }\n\n if (offset < 0) {\n offset = s1_len + offset;\n if (offset < 0) offset = 0;\n }\n\n if (offset >= s1_len) {\n raise_warning(\"The start position cannot exceed initial string length\");\n return make_tv(false);\n }\n\n auto const cmp_len = std::min(s1_len - offset, std::min(s2_len, length));\n\n auto const ret = [&] {\n const char *s1 = main_str.data();\n if (case_insensitivity) {\n return bstrcasecmp(s1 + offset, cmp_len, str.data(), cmp_len);\n }\n return string_ncmp(s1 + offset, str.data(), cmp_len);\n }();\n if (ret == 0) {\n auto const m1 = std::min(s1_len - offset, length);\n auto const m2 = std::min(s2_len, length);\n if (m1 > m2) return tvReturn(1);\n if (m1 < m2) return tvReturn(-1);\n return tvReturn(0);\n }\n return tvReturn(ret);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "boost::optional SaplingNotePlaintext::decrypt(\n const SaplingEncCiphertext &ciphertext,\n const uint256 &ivk,\n const uint256 &epk,\n const uint256 &cmu\n)\n{\n auto pt = AttemptSaplingEncDecryption(ciphertext, ivk, epk);\n if (!pt) {\n return boost::none;\n }\n\n // Deserialize from the plaintext\n CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);\n ss << pt.get();\n\n SaplingNotePlaintext ret;\n ss >> ret;\n\n assert(ss.size() == 0);\n\n uint256 pk_d;\n if (!librustzcash_ivk_to_pkd(ivk.begin(), ret.d.data(), pk_d.begin())) {\n return boost::none;\n }\n\n uint256 cmu_expected;\n if (!librustzcash_sapling_compute_cm(\n ret.d.data(),\n pk_d.begin(),\n ret.value(),\n ret.rcm.begin(),\n cmu_expected.begin()\n ))\n {\n return boost::none;\n }\n\n if (cmu_expected != cmu) {\n return boost::none;\n }\n\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx,\n int_fast32_t tly, int_fast32_t hstep, int_fast32_t vstep,\n int_fast32_t width, int_fast32_t height, uint_fast16_t depth, bool sgnd,\n uint_fast32_t inmem)\n{\n\tjas_image_cmpt_t *cmpt;\n\tsize_t size;\n\n\tcmpt = 0;\n\tif (width < 0 || height < 0 || hstep <= 0 || vstep <= 0) {\n\t\tgoto error;\n\t}\n\tif (!jas_safe_intfast32_add(tlx, width, 0) ||\n\t !jas_safe_intfast32_add(tly, height, 0)) {\n\t\tgoto error;\n\t}\n\n\tif (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) {\n\t\tgoto error;\n\t}\n\n\tcmpt->type_ = JAS_IMAGE_CT_UNKNOWN;\n\tcmpt->tlx_ = tlx;\n\tcmpt->tly_ = tly;\n\tcmpt->hstep_ = hstep;\n\tcmpt->vstep_ = vstep;\n\tcmpt->width_ = width;\n\tcmpt->height_ = height;\n\tcmpt->prec_ = depth;\n\tcmpt->sgnd_ = sgnd;\n\tcmpt->stream_ = 0;\n\tcmpt->cps_ = (depth + 7) / 8;\n\n\t// Compute the number of samples in the image component, while protecting\n\t// against overflow.\n\t// size = cmpt->width_ * cmpt->height_ * cmpt->cps_;\n\tif (!jas_safe_size_mul(cmpt->width_, cmpt->height_, &size) ||\n\t !jas_safe_size_mul(size, cmpt->cps_, &size)) {\n\t\tgoto error;\n\t}\n\tcmpt->stream_ = (inmem) ? jas_stream_memopen2(0, size) :\n\t jas_stream_tmpfile();\n\tif (!cmpt->stream_) {\n\t\tgoto error;\n\t}\n\n\t/* Zero the component data. This isn't necessary, but it is\n\tconvenient for debugging purposes. */\n\t/* Note: conversion of size - 1 to long can overflow */\n\tif (size > 0) {\n\t\tif (size - 1 > LONG_MAX) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jas_stream_seek(cmpt->stream_, size - 1, SEEK_SET) < 0 ||\n\t\t jas_stream_putc(cmpt->stream_, 0) == EOF ||\n\t\t jas_stream_seek(cmpt->stream_, 0, SEEK_SET) < 0) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\treturn cmpt;\n\nerror:\n\tif (cmpt) {\n\t\tjas_image_cmpt_destroy(cmpt);\n\t}\n\treturn 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "Status OpLevelCostEstimator::PredictAvgPool(const OpContext& op_context,\n NodeCosts* node_costs) const {\n bool found_unknown_shapes = false;\n const auto& op_info = op_context.op_info;\n // x: op_info.inputs(0)\n TF_ASSIGN_OR_RETURN(ConvolutionDimensions dims,\n OpDimensionsFromInputs(op_info.inputs(0).shape(), op_info,\n &found_unknown_shapes));\n\n // kx * ky - 1 additions and 1 multiplication per output.\n int64_t ops = dims.batch * dims.ox * dims.oy * dims.oz * dims.kx * dims.ky;\n node_costs->num_compute_ops = ops;\n\n int64_t input_size;\n if (dims.ky >= dims.sy) {\n input_size = CalculateTensorSize(op_info.inputs(0), &found_unknown_shapes);\n } else { // dims.ky < dims.sy\n // vertical stride is larger than vertical kernel; assuming row-major\n // format, skip unnecessary rows (or read every kx rows per sy rows, as the\n // others are not used for output).\n const auto data_size = DataTypeSize(BaseType(op_info.inputs(0).dtype()));\n input_size = data_size * dims.batch * dims.ix * dims.ky * dims.oy * dims.iz;\n }\n node_costs->num_input_bytes_accessed = {input_size};\n\n const int64_t output_size =\n CalculateOutputSize(op_info, &found_unknown_shapes);\n node_costs->num_output_bytes_accessed = {output_size};\n node_costs->max_memory = output_size;\n\n if (found_unknown_shapes) {\n node_costs->inaccurate = true;\n node_costs->num_nodes_with_unknown_shapes = 1;\n }\n return Status::OK();\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-369", "cwe_name": "Divide By Zero", "description": "The product divides a value by zero.", "url": "https://cwe.mitre.org/data/definitions/369.html", "label_name": "safe"} {"code": "TEST_F(EncryptedRecordTest, TestAllPaddingHandshake) {\n addToQueue(\"17030100050123456789\");\n EXPECT_CALL(*readAead_, _decrypt(_, _, 0))\n .WillOnce(Invoke([](std::unique_ptr& buf, const IOBuf*, uint64_t) {\n expectSame(buf, \"0123456789\");\n return getBuf(\"16000000\");\n }));\n EXPECT_NO_THROW(read_.read(queue_));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node,\n std::function func,\n TfLiteType expected_type) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, expected_type);\n const int64_t num_elements = NumElements(input);\n const T* in_data = GetTensorData(input);\n T* out_data = GetTensorData(output);\n for (int64_t i = 0; i < num_elements; ++i) {\n out_data[i] = func(in_data[i]);\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void OneHotComputeImpl(const OneHotContext& op_context) {\n // prefix_dim_size == # of elements before the axis\n // depth == # of elements per axis\n // suffix_dim_size == # of elements after the axis\n int prefix_dim_size = 1;\n for (int i = 0; i < op_context.axis; ++i) {\n prefix_dim_size *= op_context.indices->dims->data[i];\n }\n if (prefix_dim_size == 0) {\n // If indices tensor is degenerate, return a degenerate tensor, just like\n // TensorFlow does.\n return;\n }\n const int suffix_dim_size = NumElements(op_context.indices) / prefix_dim_size;\n const int depth = *op_context.depth->data.i32;\n\n const T on_value = *GetTensorData(op_context.on_value);\n const T off_value = *GetTensorData(op_context.off_value);\n\n // View the indices as a matrix of size:\n // prefix_dim_size x suffix_dim_size\n // View the output as a matrix of size:\n // prefix_dim_size x depth x suffix_dim_size\n // Then the output is:\n // output(i, j, k) == (indices(i, k) == j) ? on : off\n T* output = GetTensorData(op_context.output);\n const TI* indices = GetTensorData(op_context.indices);\n for (int i = 0; i < prefix_dim_size; ++i) {\n for (int j = 0; j < depth; ++j) {\n for (int k = 0; k < suffix_dim_size; ++k, ++output) {\n *output = static_cast(indices[i * suffix_dim_size + k]) == j\n ? on_value\n : off_value;\n }\n }\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-369", "cwe_name": "Divide By Zero", "description": "The product divides a value by zero.", "url": "https://cwe.mitre.org/data/definitions/369.html", "label_name": "safe"} {"code": " friend bool operator==(const TensorKey& t1, const TensorKey& t2) {\n if (t1.dtype() != t2.dtype() || t1.shape() != t2.shape()) {\n return false;\n }\n if (DataTypeCanUseMemcpy(t1.dtype())) {\n return t1.tensor_data() == t2.tensor_data();\n } else if (t1.dtype() == DT_STRING) {\n const auto s1 = t1.unaligned_flat();\n const auto s2 = t2.unaligned_flat();\n for (int64_t i = 0, n = t1.NumElements(); i < n; ++i) {\n if (TF_PREDICT_FALSE(s1(i) != s2(i))) {\n return false;\n }\n }\n return true;\n } else {\n DCHECK(false) << \"Unimplemented dtype \" << DataTypeString(t1.dtype())\n << std::endl;\n }\n return false;\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-122", "cwe_name": "Heap-based Buffer Overflow", "description": "A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().", "url": "https://cwe.mitre.org/data/definitions/122.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n\n const TfLiteType type = input1->type;\n if (type != kTfLiteInt32 && type != kTfLiteFloat32) {\n TF_LITE_KERNEL_LOG(context, \"Unsupported data type %s.\",\n TfLiteTypeGetName(type));\n return kTfLiteError;\n }\n output->type = type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "int MSADPCM::decodeBlock(const uint8_t *encoded, int16_t *decoded)\n{\n\tms_adpcm_state decoderState[2];\n\tms_adpcm_state *state[2];\n\n\tint channelCount = m_track->f.channelCount;\n\n\t// Calculate the number of bytes needed for decoded data.\n\tint outputLength = m_framesPerPacket * sizeof (int16_t) * channelCount;\n\n\tstate[0] = &decoderState[0];\n\tif (channelCount == 2)\n\t\tstate[1] = &decoderState[1];\n\telse\n\t\tstate[1] = &decoderState[0];\n\n\t// Initialize block predictor.\n\tfor (int i=0; ipredictorIndex = *encoded++;\n\t\tassert(state[i]->predictorIndex < m_numCoefficients);\n\t}\n\n\t// Initialize delta.\n\tfor (int i=0; idelta = (encoded[1]<<8) | encoded[0];\n\t\tencoded += sizeof (uint16_t);\n\t}\n\n\t// Initialize first two samples.\n\tfor (int i=0; isample1 = (encoded[1]<<8) | encoded[0];\n\t\tencoded += sizeof (uint16_t);\n\t}\n\n\tfor (int i=0; isample2 = (encoded[1]<<8) | encoded[0];\n\t\tencoded += sizeof (uint16_t);\n\t}\n\n\tconst int16_t *coefficient[2] =\n\t{\n\t\tm_coefficients[state[0]->predictorIndex],\n\t\tm_coefficients[state[1]->predictorIndex]\n\t};\n\n\tfor (int i=0; isample2;\n\n\tfor (int i=0; isample1;\n\n\t/*\n\t\tThe first two samples have already been 'decoded' in\n\t\tthe block header.\n\t*/\n\tint samplesRemaining = (m_framesPerPacket - 2) * m_track->f.channelCount;\n\n\twhile (samplesRemaining > 0)\n\t{\n\t\tuint8_t code;\n\t\tint16_t newSample;\n\n\t\tcode = *encoded >> 4;\n\t\tnewSample = decodeSample(*state[0], code, coefficient[0]);\n\t\t*decoded++ = newSample;\n\n\t\tcode = *encoded & 0x0f;\n\t\tnewSample = decodeSample(*state[1], code, coefficient[1]);\n\t\t*decoded++ = newSample;\n\n\t\tencoded++;\n\t\tsamplesRemaining -= 2;\n\t}\n\n\treturn outputLength;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node,\n std::function func,\n TfLiteType expected_type) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, expected_type);\n const int64_t num_elements = NumElements(input);\n const T* in_data = GetTensorData(input);\n T* out_data = GetTensorData(output);\n for (int64_t i = 0; i < num_elements; ++i) {\n out_data[i] = func(in_data[i]);\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "int Dispatcher::getparam( size_t N, int defaultval )\n{\n int ret = defaultval;\n if ( !parsed ) {\n parse_params();\n }\n\n if ( parsed_params.size() > N ) {\n ret = parsed_params[ N ];\n }\n\n if ( ret > PARAM_MAX ) {\n ret = defaultval;\n }\n\n if ( ret < 1 ) ret = defaultval;\n\n return ret;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-399", "cwe_name": "Resource Management Errors", "description": "Weaknesses in this category are related to improper management of system resources.", "url": "https://cwe.mitre.org/data/definitions/399.html", "label_name": "safe"} {"code": "void Context::onDownstreamConnectionClose(PeerType peer_type) {\n if (wasm_->onDownstreamConnectionClose_) {\n wasm_->onDownstreamConnectionClose_(this, id_, static_cast(peer_type));\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "vulnerable"} {"code": "BigInt EC_Group::square_mod_order(const BigInt& x) const\n {\n return data().square_mod_order(x);\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " private static boolean matches( final Collection patterns,\n final Path path ) {\n return matches( patterns, path.toUri() );\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": "int jas_seq2d_output(jas_matrix_t *matrix, FILE *out)\n{\n#define MAXLINELEN\t80\n\tjas_matind_t i;\n\tjas_matind_t j;\n\tjas_seqent_t x;\n\tchar buf[MAXLINELEN + 1];\n\tchar sbuf[MAXLINELEN + 1];\n\tint n;\n\n\tfprintf(out, \"%\"PRIiFAST32\" %\"PRIiFAST32\"\\n\", jas_seq2d_xstart(matrix),\n\t jas_seq2d_ystart(matrix));\n\tfprintf(out, \"%\"PRIiFAST32\" %\"PRIiFAST32\"\\n\", jas_matrix_numcols(matrix),\n\t jas_matrix_numrows(matrix));\n\n\tbuf[0] = '\\0';\n\tfor (i = 0; i < jas_matrix_numrows(matrix); ++i) {\n\t\tfor (j = 0; j < jas_matrix_numcols(matrix); ++j) {\n\t\t\tx = jas_matrix_get(matrix, i, j);\n\t\t\tsprintf(sbuf, \"%s%4ld\", (strlen(buf) > 0) ? \" \" : \"\",\n\t\t\t JAS_CAST(long, x));\n\t\t\tn = JAS_CAST(int, strlen(buf));\n\t\t\tif (n + JAS_CAST(int, strlen(sbuf)) > MAXLINELEN) {\n\t\t\t\tfputs(buf, out);\n\t\t\t\tfputs(\"\\n\", out);\n\t\t\t\tbuf[0] = '\\0';\n\t\t\t}\n\t\t\tstrcat(buf, sbuf);\n\t\t\tif (j == jas_matrix_numcols(matrix) - 1) {\n\t\t\t\tfputs(buf, out);\n\t\t\t\tfputs(\"\\n\", out);\n\t\t\t\tbuf[0] = '\\0';\n\t\t\t}\n\t\t}\n\t}\n\tfputs(buf, out);\n\n\treturn 0;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " void Compute(OpKernelContext* context) override {\n const Tensor& input = context->input(0);\n // If input is provided, check to make sure the first dimension is valid.\n if (input.dims() > 0) {\n OP_REQUIRES(\n context, input.dim_size(0) != 0,\n errors::InvalidArgument(\"Invalid input first dimension. Found 0.\"));\n }\n const Tensor& dims = context->input(1);\n\n if (TensorShapeUtils::IsScalar(input.shape())) {\n context->set_output(0, input);\n } else {\n const int input_dims = input.dims();\n OP_REQUIRES(context, TensorShapeUtils::IsVector(dims.shape()),\n errors::InvalidArgument(\"'dims' must be 1-dimension, not \",\n dims.dims()));\n\n OP_REQUIRES(\n context, input_dims == dims.dim_size(0),\n errors::InvalidArgument(\n \"'dims' must have the same number of values as 'input' has \"\n \"dimensions. 'input' has \",\n input_dims, \"'dims' has \", dims.dim_size(0), \" values\"));\n OP_REQUIRES(context, input_dims <= 8,\n errors::Unimplemented(\n \"reverse is not implemented for tensors of rank > 8.\"));\n\n Tensor* output = nullptr;\n OP_REQUIRES_OK(context,\n context->allocate_output(0, input.shape(), &output));\n\n#define HANDLE_REVERSE(NDIMS) \\\n case NDIMS: \\\n HandleReverseCase(context, dims.vec(), output); \\\n return;\n\n switch (input_dims) {\n HANDLE_REVERSE(0);\n HANDLE_REVERSE(1);\n HANDLE_REVERSE(2);\n HANDLE_REVERSE(3);\n HANDLE_REVERSE(4);\n HANDLE_REVERSE(5);\n HANDLE_REVERSE(6);\n HANDLE_REVERSE(7);\n HANDLE_REVERSE(8);\n }\n#undef HANDLE_REVERSE\n }\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-369", "cwe_name": "Divide By Zero", "description": "The product divides a value by zero.", "url": "https://cwe.mitre.org/data/definitions/369.html", "label_name": "safe"} {"code": "void ftoa_bounded_extra(JsVarFloat val,char *str, size_t len, int radix, int fractionalDigits) {\n assert(len>9); // in case if strcpy\n const JsVarFloat stopAtError = 0.0000001;\n if (isnan(val)) strcpy(str,\"NaN\");\n else if (!isfinite(val)) {\n if (val<0) strcpy(str,\"-Infinity\");\n else strcpy(str,\"Infinity\");\n } else {\n if (val<0) {\n if (--len <= 0) { *str=0; return; } // bounds check\n *(str++) = '-';\n val = -val;\n }\n\n // what if we're really close to an integer? Just use that...\n if (((JsVarInt)(val+stopAtError)) == (1+(JsVarInt)val))\n val = (JsVarFloat)(1+(JsVarInt)val);\n\n JsVarFloat d = 1;\n while (d*radix <= val) d*=radix;\n while (d >= 1) {\n int v = (int)(val / d);\n val -= v*d;\n if (--len <= 0) { *str=0; return; } // bounds check\n *(str++) = itoch(v);\n d /= radix;\n }\n#ifndef USE_NO_FLOATS\n if (((fractionalDigits<0) && val>0) || fractionalDigits>0) {\n bool hasPt = false;\n val*=radix;\n while (((fractionalDigits<0) && (fractionalDigits>-12) && (val > stopAtError)) || (fractionalDigits > 0)) {\n int v = (int)(val+((fractionalDigits==1) ? 0.4 : 0.00000001) );\n val = (val-v)*radix;\n\tif (v==radix) v=radix-1;\n if (!hasPt) {\t\n\t hasPt = true;\n if (--len <= 0) { *str=0; return; } // bounds check\n *(str++)='.';\n }\n if (--len <= 0) { *str=0; return; } // bounds check\n *(str++)=itoch(v);\n fractionalDigits--;\n }\n }\n#endif\n\n *(str++)=0;\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "int pnm_validate(jas_stream_t *in)\n{\n\tuchar buf[2];\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= 2);\n\n\t/* Read the first two characters that constitute the signature. */\n\tif ((n = jas_stream_read(in, buf, 2)) < 0) {\n\t\treturn -1;\n\t}\n\t/* Put these characters back to the stream. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\t/* Did we read enough data? */\n\tif (n < 2) {\n\t\treturn -1;\n\t}\n\t/* Is this the correct signature for a PNM file? */\n\tif (buf[0] == 'P' && isdigit(buf[1])) {\n\t\treturn 0;\n\t}\n\treturn -1;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " explicit ReverseSequenceOp(OpKernelConstruction* context)\n : OpKernel(context) {\n OP_REQUIRES_OK(context, context->GetAttr(\"batch_dim\", &batch_dim_));\n OP_REQUIRES_OK(context, context->GetAttr(\"seq_dim\", &seq_dim_));\n OP_REQUIRES(context, batch_dim_ >= 0,\n errors::InvalidArgument(\"Invalid batch_dim \", batch_dim_));\n OP_REQUIRES(context, seq_dim_ >= 0,\n errors::InvalidArgument(\"Invalid seq_dim \", seq_dim_));\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "safe"} {"code": "selReadStream(FILE *fp)\n{\nchar *selname;\nchar linebuf[L_BUF_SIZE];\nl_int32 sy, sx, cy, cx, i, j, version, ignore;\nSEL *sel;\n\n PROCNAME(\"selReadStream\");\n\n if (!fp)\n return (SEL *)ERROR_PTR(\"stream not defined\", procName, NULL);\n\n if (fscanf(fp, \" Sel Version %d\\n\", &version) != 1)\n return (SEL *)ERROR_PTR(\"not a sel file\", procName, NULL);\n if (version != SEL_VERSION_NUMBER)\n return (SEL *)ERROR_PTR(\"invalid sel version\", procName, NULL);\n\n if (fgets(linebuf, L_BUF_SIZE, fp) == NULL)\n return (SEL *)ERROR_PTR(\"error reading into linebuf\", procName, NULL);\n selname = stringNew(linebuf);\n sscanf(linebuf, \" ------ %s ------\", selname);\n\n if (fscanf(fp, \" sy = %d, sx = %d, cy = %d, cx = %d\\n\",\n &sy, &sx, &cy, &cx) != 4) {\n LEPT_FREE(selname);\n return (SEL *)ERROR_PTR(\"dimensions not read\", procName, NULL);\n }\n\n if ((sel = selCreate(sy, sx, selname)) == NULL) {\n LEPT_FREE(selname);\n return (SEL *)ERROR_PTR(\"sel not made\", procName, NULL);\n }\n selSetOrigin(sel, cy, cx);\n\n for (i = 0; i < sy; i++) {\n ignore = fscanf(fp, \" \");\n for (j = 0; j < sx; j++)\n ignore = fscanf(fp, \"%1d\", &sel->data[i][j]);\n ignore = fscanf(fp, \"\\n\");\n }\n ignore = fscanf(fp, \"\\n\");\n\n LEPT_FREE(selname);\n return sel;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (!sz || sz == UT64_MAX) {\n\t\treturn NULL;\n\t}\n#if 0\n\t/// XXX this breaks tests\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n#endif\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_FILE_ATTR;\n\t\tattr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tattr->size = offset;\n\t\t// IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\t}\n\treturn attr;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "safe"} {"code": "TfLiteStatus LeakyReluPrepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n LeakyReluOpData* data = reinterpret_cast(node->user_data);\n\n if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16) {\n const auto* params =\n reinterpret_cast(node->builtin_data);\n\n double alpha_multiplier =\n input->params.scale * params->alpha / output->params.scale;\n QuantizeMultiplier(alpha_multiplier, &data->output_multiplier_alpha,\n &data->output_shift_alpha);\n double identity_multiplier = input->params.scale / output->params.scale;\n QuantizeMultiplier(identity_multiplier, &data->output_multiplier_identity,\n &data->output_shift_identity);\n }\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "bool ContentSettingsObserver::AllowScript(bool enabled_per_settings) {\n if (!enabled_per_settings)\n return false;\n if (IsScriptDisabledForPreview(render_frame()))\n return false;\n if (is_interstitial_page_)\n return true;\n\n blink::WebLocalFrame* frame = render_frame()->GetWebFrame();\n const auto it = cached_script_permissions_.find(frame);\n if (it != cached_script_permissions_.end())\n return it->second;\n\n // Evaluate the content setting rules before\n // IsWhitelistedForContentSettings(); if there is only the default rule\n // allowing all scripts, it's quicker this way.\n bool allow = true;\n if (content_setting_rules_) {\n ContentSetting setting = GetContentSettingFromRules(\n content_setting_rules_->script_rules, frame,\n url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL());\n allow = setting != CONTENT_SETTING_BLOCK;\n }\n allow = allow || IsWhitelistedForContentSettings();\n\n cached_script_permissions_[frame] = allow;\n return allow;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TEST(TensorSliceReaderTest, InvalidTensorSlice) {\n const string fname =\n io::JoinPath(testing::TmpDir(), \"invalid_slice_checkpoint\");\n TensorSliceWriter writer(fname, CreateTableTensorSliceBuilder);\n const int32 data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n TF_CHECK_OK(writer.Add(\"test\", TensorShape({4, 5}),\n TensorSlice::ParseOrDie(\"0,2:-\"), data));\n TF_CHECK_OK(writer.Finish());\n\n MutateSavedTensorSlices(fname, [](SavedTensorSlices sts) {\n if (sts.has_meta()) {\n for (auto& tensor : *sts.mutable_meta()->mutable_tensor()) {\n tensor.mutable_slice(0)->mutable_extent(0)->set_length(-10);\n }\n }\n return sts.SerializeAsString();\n });\n\n TensorSliceReader reader(fname, OpenTableTensorSliceReader);\n // The negative exent length should cause loading to fail.\n EXPECT_FALSE(reader.status().ok());\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32);\n output->type = input->type;\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims);\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n output->type = input->type;\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": " BigInt multiply_mod_order(const BigInt& x, const BigInt& y, const BigInt& z) const\n {\n return m_mod_order.multiply(m_mod_order.multiply(x, y), z);\n }", "label": 1, "programming_language": "C++", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": "static ssize_t _hostsock_sendmsg(\n oe_fd_t* sock_,\n const struct oe_msghdr* msg,\n int flags)\n{\n ssize_t ret = -1;\n sock_t* sock = _cast_sock(sock_);\n void* buf = NULL;\n size_t buf_size = 0;\n\n oe_errno = 0;\n\n /* Check the parameters. */\n if (!sock || !msg || (msg->msg_iovlen && !msg->msg_iov))\n OE_RAISE_ERRNO(OE_EINVAL);\n\n /* Flatten the IO vector into contiguous heap memory. */\n if (oe_iov_pack(msg->msg_iov, (int)msg->msg_iovlen, &buf, &buf_size) != 0)\n OE_RAISE_ERRNO(OE_ENOMEM);\n\n /* Call the host. */\n if (oe_syscall_sendmsg_ocall(\n &ret,\n sock->host_fd,\n msg->msg_name,\n msg->msg_namelen,\n buf,\n msg->msg_iovlen,\n buf_size,\n msg->msg_control,\n msg->msg_controllen,\n flags) != OE_OK)\n {\n OE_RAISE_ERRNO(OE_EINVAL);\n }\n\ndone:\n\n if (buf)\n oe_free(buf);\n\n return ret;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 5);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* ids;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &ids));\n TF_LITE_ENSURE_EQ(context, NumDimensions(ids), 1);\n TF_LITE_ENSURE_EQ(context, ids->type, kTfLiteInt32);\n\n const TfLiteTensor* indices;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &indices));\n TF_LITE_ENSURE_EQ(context, NumDimensions(indices), 2);\n TF_LITE_ENSURE_EQ(context, indices->type, kTfLiteInt32);\n\n const TfLiteTensor* shape;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 2, &shape));\n TF_LITE_ENSURE_EQ(context, NumDimensions(shape), 1);\n TF_LITE_ENSURE_EQ(context, shape->type, kTfLiteInt32);\n\n const TfLiteTensor* weights;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 3, &weights));\n TF_LITE_ENSURE_EQ(context, NumDimensions(weights), 1);\n TF_LITE_ENSURE_EQ(context, weights->type, kTfLiteFloat32);\n\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(indices, 0),\n SizeOfDimension(ids, 0));\n TF_LITE_ENSURE_EQ(context, SizeOfDimension(indices, 0),\n SizeOfDimension(weights, 0));\n\n const TfLiteTensor* value;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 4, &value));\n TF_LITE_ENSURE(context, NumDimensions(value) >= 2);\n\n // Mark the output as a dynamic tensor.\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, output->type, kTfLiteFloat32);\n output->allocation_type = kTfLiteDynamic;\n\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": " RectangleRequest(const struct RectangleRequest &req)\n : Explicit()\n {\n // Not nice, but this is really faster and simpler\n memcpy(this,&req,sizeof(struct RectangleRequest));\n // Not linked in any way if this is new.\n rr_pNext = NULL;\n }", "label": 0, "programming_language": "C++", "cwe_id": "CWE-119", "cwe_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer", "description": "The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.", "url": "https://cwe.mitre.org/data/definitions/119.html", "label_name": "vulnerable"} {"code": "TfLiteStatus LogSoftmaxPrepare(TfLiteContext* context, TfLiteNode* node) {\n LogSoftmaxOpData* data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n if (input->type == kTfLiteUInt8 || input->type == kTfLiteInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.scale, 16.0 / 256);\n static const double kBeta = 1.0;\n if (input->type == kTfLiteUInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.zero_point, 255);\n data->params.table = data->f_table;\n optimized_ops::PopulateSoftmaxLookupTable(&data->params,\n input->params.scale, kBeta);\n data->params.zero_point = output->params.zero_point;\n data->params.scale = output->params.scale;\n }\n if (input->type == kTfLiteInt8) {\n TF_LITE_ENSURE_EQ(context, output->params.zero_point, 127);\n static const int kScaledDiffIntegerBits = 5;\n tflite::PreprocessLogSoftmaxScalingExp(\n kBeta, input->params.scale, kScaledDiffIntegerBits,\n &data->input_multiplier, &data->input_left_shift,\n &data->reverse_scaling_divisor, &data->reverse_scaling_right_shift);\n data->reverse_scaling_right_shift *= -1;\n data->diff_min =\n -1.0 * tflite::CalculateInputRadius(kScaledDiffIntegerBits,\n data->input_left_shift);\n }\n }\n\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* start;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kStartTensor, &start));\n const TfLiteTensor* limit;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kLimitTensor, &limit));\n const TfLiteTensor* delta;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kDeltaTensor, &delta));\n // Make sure all the inputs are scalars.\n TF_LITE_ENSURE_EQ(context, NumDimensions(start), 0);\n TF_LITE_ENSURE_EQ(context, NumDimensions(limit), 0);\n TF_LITE_ENSURE_EQ(context, NumDimensions(delta), 0);\n\n // Currently only supports int32 and float.\n // TODO(b/117912892): Support quantization as well.\n const auto dtype = start->type;\n if (dtype != kTfLiteFloat32 && dtype != kTfLiteInt32) {\n context->ReportError(context, \"Unknown index output data type: %s\",\n TfLiteTypeGetName(dtype));\n return kTfLiteError;\n }\n\n TF_LITE_ENSURE_TYPES_EQ(context, limit->type, dtype);\n TF_LITE_ENSURE_TYPES_EQ(context, delta->type, dtype);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n output->type = dtype;\n\n if (IsConstantTensor(start) && IsConstantTensor(limit) &&\n IsConstantTensor(delta)) {\n return ResizeOutput(context, start, limit, delta, output);\n }\n\n SetTensorToDynamic(output);\n return kTfLiteOk;\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);\n\n OpContext op_context(context, node);\n\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), op_context.params->num_splits);\n\n auto input_type = op_context.input->type;\n TF_LITE_ENSURE(context,\n input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8 ||\n input_type == kTfLiteInt16 || input_type == kTfLiteInt32 ||\n input_type == kTfLiteInt64 || input_type == kTfLiteInt8);\n for (int i = 0; i < NumOutputs(node); ++i) {\n GetOutput(context, node, i)->type = input_type;\n }\n\n auto size_splits = op_context.size_splits;\n TF_LITE_ENSURE_EQ(context, NumDimensions(size_splits), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), NumElements(size_splits));\n\n // If we know the contents of the 'size_splits' tensor and the 'axis' tensor,\n // resize all outputs. Otherwise, wait until Eval().\n if (IsConstantTensor(op_context.size_splits) &&\n IsConstantTensor(op_context.axis)) {\n return ResizeOutputTensors(context, node, op_context.input,\n op_context.size_splits, op_context.axis);\n } else {\n return UseDynamicOutputTensors(context, node);\n }\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TEST_P(Http2CodecImplTest, TestLargeRequestHeadersAtLimitAccepted) {\n uint32_t codec_limit_kb = 64;\n max_request_headers_kb_ = codec_limit_kb;\n initialize();\n\n TestHeaderMapImpl request_headers;\n HttpTestUtility::addDefaultHeaders(request_headers);\n std::string key = \"big\";\n uint32_t head_room = 77;\n uint32_t long_string_length =\n codec_limit_kb * 1024 - request_headers.byteSize() - key.length() - head_room;\n std::string long_string = std::string(long_string_length, 'q');\n request_headers.addCopy(key, long_string);\n\n // The amount of data sent to the codec is not equivalent to the size of the\n // request headers that Envoy computes, as the codec limits based on the\n // entire http2 frame. The exact head room needed (76) was found through iteration.\n ASSERT_EQ(request_headers.byteSize() + head_room, codec_limit_kb * 1024);\n\n EXPECT_CALL(request_decoder_, decodeHeaders_(_, _));\n request_encoder_->encodeHeaders(request_headers, true);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "static int em_syscall(struct x86_emulate_ctxt *ctxt)\n{\n\tstruct x86_emulate_ops *ops = ctxt->ops;\n\tstruct desc_struct cs, ss;\n\tu64 msr_data;\n\tu16 cs_sel, ss_sel;\n\tu64 efer = 0;\n\n\t/* syscall is not available in real mode */\n\tif (ctxt->mode == X86EMUL_MODE_REAL ||\n\t ctxt->mode == X86EMUL_MODE_VM86)\n\t\treturn emulate_ud(ctxt);\n\n\tif (!(em_syscall_is_enabled(ctxt)))\n\t\treturn emulate_ud(ctxt);\n\n\tops->get_msr(ctxt, MSR_EFER, &efer);\n\tsetup_syscalls_segments(ctxt, &cs, &ss);\n\n\tif (!(efer & EFER_SCE))\n\t\treturn emulate_ud(ctxt);\n\n\tops->get_msr(ctxt, MSR_STAR, &msr_data);\n\tmsr_data >>= 32;\n\tcs_sel = (u16)(msr_data & 0xfffc);\n\tss_sel = (u16)(msr_data + 8);\n\n\tif (efer & EFER_LMA) {\n\t\tcs.d = 0;\n\t\tcs.l = 1;\n\t}\n\tops->set_segment(ctxt, cs_sel, &cs, 0, VCPU_SREG_CS);\n\tops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS);\n\n\tctxt->regs[VCPU_REGS_RCX] = ctxt->_eip;\n\tif (efer & EFER_LMA) {\n#ifdef CONFIG_X86_64\n\t\tctxt->regs[VCPU_REGS_R11] = ctxt->eflags & ~EFLG_RF;\n\n\t\tops->get_msr(ctxt,\n\t\t\t ctxt->mode == X86EMUL_MODE_PROT64 ?\n\t\t\t MSR_LSTAR : MSR_CSTAR, &msr_data);\n\t\tctxt->_eip = msr_data;\n\n\t\tops->get_msr(ctxt, MSR_SYSCALL_MASK, &msr_data);\n\t\tctxt->eflags &= ~(msr_data | EFLG_RF);\n#endif\n\t} else {\n\t\t/* legacy mode */\n\t\tops->get_msr(ctxt, MSR_STAR, &msr_data);\n\t\tctxt->_eip = (u32)msr_data;\n\n\t\tctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF);\n\t}\n\n\treturn X86EMUL_CONTINUE;\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "TfLiteStatus MockCustom::Invoke(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = tflite::GetInput(context, node, 0);\n const int32_t* input_data = input->data.i32;\n const TfLiteTensor* weight = tflite::GetInput(context, node, 1);\n const uint8_t* weight_data = weight->data.uint8;\n TfLiteTensor* output = GetOutput(context, node, 0);\n int32_t* output_data = output->data.i32;\n output_data[0] =\n 0; // Catch output tensor sharing memory with an input tensor\n output_data[0] = input_data[0] + weight_data[0];\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "void Archive::Seek(int64 Offset,int Method)\n{\n if (!QOpen.Seek(Offset,Method))\n File::Seek(Offset,Method);\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteIntArray* input_dims = input->dims;\n int input_dims_size = input_dims->size;\n TF_LITE_ENSURE(context, input_dims_size >= 1);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n // Resize the output tensor.\n TfLiteIntArray* output_shape = TfLiteIntArrayCreate(input_dims_size + 1);\n for (int i = 0; i < input_dims_size; i++) {\n output_shape->data[i] = input_dims->data[i];\n }\n // Last dimension in the output is the same as the last dimension in the\n // input.\n output_shape->data[input_dims_size] = input_dims->data[input_dims_size - 1];\n output->type = input->type;\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_shape));\n\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = static_cast(node->user_data);\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n\n // TODO(b/128934713): Add support for fixed-point per-channel quantization.\n // Currently this only support affine per-layer quantization.\n TF_LITE_ENSURE_EQ(context, output->quantization.type,\n kTfLiteAffineQuantization);\n const auto* affine_quantization =\n static_cast(output->quantization.params);\n TF_LITE_ENSURE(context, affine_quantization);\n TF_LITE_ENSURE(context, affine_quantization->scale);\n TF_LITE_ENSURE(context, affine_quantization->scale->size == 1);\n\n if (input->type == kTfLiteFloat32) {\n // Quantize use case.\n TF_LITE_ENSURE(context, output->type == kTfLiteUInt8 ||\n output->type == kTfLiteInt8 ||\n output->type == kTfLiteInt16);\n } else {\n // Requantize use case.\n if (input->type == kTfLiteInt16) {\n TF_LITE_ENSURE(\n context, output->type == kTfLiteInt8 || output->type == kTfLiteInt16);\n } else {\n TF_LITE_ENSURE(context,\n input->type == kTfLiteInt8 || input->type == kTfLiteUInt8);\n TF_LITE_ENSURE(\n context, output->type == kTfLiteUInt8 || output->type == kTfLiteInt8);\n }\n const double effective_output_scale =\n static_cast(input->params.scale) /\n static_cast(output->params.scale);\n QuantizeMultiplier(effective_output_scale, &data->output_multiplier,\n &data->output_shift);\n }\n\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "TfLiteStatus EqualEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteBool:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteString:\n ComparisonString(reference_ops::StringRefEqualFn, input1, input2, output,\n requires_broadcast);\n break;\n default:\n context->ReportError(\n context,\n \"Does not support type %d, requires bool|float|int|uint8|string\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": " explicit UnravelIndexOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n // Reinterprete the opaque data provided by user.\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n\n const TfLiteType type = input1->type;\n if (type != kTfLiteInt32 && type != kTfLiteFloat32 && type != kTfLiteInt64) {\n context->ReportError(context, \"Type '%s' is not supported by floor_mod.\",\n TfLiteTypeGetName(type));\n return kTfLiteError;\n }\n output->type = type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "inline void StringData::setSize(int len) {\n assertx(!isImmutable() && !hasMultipleRefs());\n assertx(len >= 0 && len <= capacity());\n mutableData()[len] = 0;\n m_lenAndHash = len;\n assertx(m_hash == 0);\n assertx(checkSane());\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "vulnerable"} {"code": "TfLiteStatus GenericPrepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n if (!is_supported_type(input->type)) {\n TF_LITE_UNSUPPORTED_TYPE(context, input->type, op_name);\n }\n return context->ResizeTensor(context, output,\n TfLiteIntArrayCopy(input->dims));\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-787", "cwe_name": "Out-of-bounds Write", "description": "The software writes data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/787.html", "label_name": "safe"} {"code": "static void php_array_replace_recursive(PointerSet &seen, bool check,\n Array &arr1, const Array& arr2) {\n if (arr1.get() == arr2.get()) {\n // This is an optimization, but it also avoids an assert in\n // setWithRef (Variant::setWithRef asserts that its source\n // and destination are not the same).\n // If the arrays are self recursive, this does change the behavior\n // slightly - it skips the \"recursion detected\" warning.\n return;\n }\n\n if (check && !seen.insert((void*)arr1.get()).second) {\n raise_warning(\"array_replace_recursive(): recursion detected\");\n return;\n }\n\n for (ArrayIter iter(arr2); iter; ++iter) {\n Variant key = iter.first();\n const Variant& value = iter.secondRef();\n if (arr1.exists(key, true) && value.isArray()) {\n Variant &v = arr1.lvalAt(key, AccessFlags::Key);\n if (v.isArray()) {\n Array subarr1 = v.toArray();\n const ArrNR& arr_value = value.toArrNR();\n php_array_replace_recursive(seen, couldRecur(v, subarr1.get()),\n subarr1, arr_value);\n v = subarr1;\n } else {\n arr1.set(key, value, true);\n }\n } else {\n arr1.setWithRef(key, value, true);\n }\n }\n\n if (check) {\n seen.erase((void*)arr1.get());\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* cond_tensor =\n GetInput(context, node, kInputConditionTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (IsDynamicTensor(output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeOutputTensor(context, cond_tensor, output));\n }\n\n TfLiteIntArray* dims = cond_tensor->dims;\n if (dims->size == 0) {\n // Scalar tensors are not supported.\n TF_LITE_KERNEL_LOG(context, \"Where op requires condition w/ rank > 0\");\n return kTfLiteError;\n }\n\n reference_ops::SelectTrueCoords(GetTensorShape(cond_tensor),\n GetTensorData(cond_tensor),\n GetTensorData(output));\n return kTfLiteOk;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "vulnerable"} {"code": "\tvoid verifyDirectoryPermissions(const string &path) {\n\t\tTRACE_POINT();\n\t\tstruct stat buf;\n\n\t\tif (stat(path.c_str(), &buf) == -1) {\n\t\t\tint e = errno;\n\t\t\tthrow FileSystemException(\"Cannot stat() \" + path, e, path);\n\t\t} else if (buf.st_mode != (S_IFDIR | parseModeString(\"u=rwx,g=rx,o=rx\"))) {\n\t\t\tthrow RuntimeException(\"Tried to reuse existing server instance directory \" +\n\t\t\t\tpath + \", but it has wrong permissions\");\n\t\t} else if (buf.st_uid != geteuid() || buf.st_gid != getegid()) {\n\t\t\t/* The server instance directory is always created by the Watchdog. Its UID/GID never\n\t\t\t * changes because:\n\t\t\t * 1. Disabling user switching only lowers the privilege of the HelperAgent.\n\t\t\t * 2. For the UID/GID to change, the web server must be completely restarted\n\t\t\t * (not just graceful reload) so that the control process can change its UID/GID.\n\t\t\t * This causes the PID to change, so that an entirely new server instance\n\t\t\t * directory is created.\n\t\t\t */\n\t\t\tthrow RuntimeException(\"Tried to reuse existing server instance directory \" +\n\t\t\t\tpath + \", but it has wrong owner and group\");\n\t\t}\n\t}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "void jas_matrix_asl(jas_matrix_t *matrix, int n)\n{\n\tint i;\n\tint j;\n\tjas_seqent_t *rowstart;\n\tint rowstep;\n\tjas_seqent_t *data;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t rowstart += rowstep) {\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t ++data) {\n\t\t\t\t//*data <<= n;\n\t\t\t\t*data = jas_seqent_asl(*data, n);\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "static int sessionCookieDirective(MaState *state, cchar *key, cchar *value)\n{\n char *options, *option, *ovalue, *tok;\n\n if (!maTokenize(state, value, \"%*\", &options)) {\n return MPR_ERR_BAD_SYNTAX;\n }\n if (smatch(options, \"disable\")) {\n httpSetAuthSession(state->route->auth, 0);\n return 0;\n } else if (smatch(options, \"enable\")) {\n httpSetAuthSession(state->route->auth, 1);\n return 0;\n }\n for (option = maGetNextArg(options, &tok); option; option = maGetNextArg(tok, &tok)) {\n option = stok(option, \" =\\t,\", &ovalue);\n ovalue = strim(ovalue, \"\\\"'\", MPR_TRIM_BOTH);\n if (!ovalue || *ovalue == '\\0') continue;\n if (smatch(option, \"visible\")) {\n httpSetRouteSessionVisibility(state->route, scaselessmatch(ovalue, \"visible\"));\n } else if (smatch(option, \"name\")) {\n httpSetRouteCookie(state->route, ovalue);\n\n } else {\n mprLog(\"error appweb config\", 0, \"Unknown SessionCookie option %s\", option);\n return MPR_ERR_BAD_SYNTAX;\n }\n }\n return 0;\n}", "label": 0, "programming_language": "C++", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": "void FormatConverter::Populate(const T* src_data, std::vector indices,\n int level, int prev_idx, int* src_data_ptr,\n T* dest_data) {\n if (level == indices.size()) {\n int orig_rank = dense_shape_.size();\n std::vector orig_idx;\n orig_idx.resize(orig_rank);\n int i = 0;\n for (; i < orig_idx.size(); i++) {\n int orig_dim = traversal_order_[i];\n orig_idx[orig_dim] = indices[i];\n }\n\n for (; i < indices.size(); i++) {\n const int block_idx = traversal_order_[i] - orig_rank;\n const int orig_dim = block_map_[block_idx];\n orig_idx[orig_dim] =\n orig_idx[orig_dim] * block_size_[block_idx] + indices[i];\n }\n\n dest_data[GetFlattenedIndex(orig_idx, dense_shape_)] =\n src_data[*src_data_ptr];\n\n *src_data_ptr = *src_data_ptr + 1;\n return;\n }\n\n const int metadata_idx = 2 * level;\n const int shape_of_level = dim_metadata_[metadata_idx][0];\n if (format_[level] == kTfLiteDimDense) {\n for (int i = 0; i < shape_of_level; i++) {\n indices[level] = i;\n Populate(src_data, indices, level + 1, prev_idx * shape_of_level + i,\n src_data_ptr, dest_data);\n }\n } else if (prev_idx + 1 < dim_metadata_[metadata_idx].size()) {\n const auto& array_segments = dim_metadata_[metadata_idx];\n const auto& array_indices = dim_metadata_[metadata_idx + 1];\n for (int i = array_segments[prev_idx]; i < array_segments[prev_idx + 1];\n i++) {\n if (i < array_indices.size() && level < indices.size()) {\n indices[level] = array_indices[i];\n Populate(src_data, indices, level + 1, i, src_data_ptr, dest_data);\n }\n }\n }\n}", "label": 1, "programming_language": "C++", "cwe_id": "CWE-125", "cwe_name": "Out-of-bounds Read", "description": "The software reads data past the end, or before the beginning, of the intended buffer.", "url": "https://cwe.mitre.org/data/definitions/125.html", "label_name": "safe"} {"code": "static Jsi_RC jsi_BitfieldToValue(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value **outValue,\n Jsi_DString *outStr, void *record, Jsi_Wide flags)\n{\n Jsi_csgset *bsget = spec->init.OPT_BITS;\n Jsi_Interp *d = interp;\n int idx = spec->idx;\n uchar *data = (uchar*)record;\n int64_t inum;\n Jsi_OptionSpec* enumSpec = (typeof(enumSpec))spec->data;\n\n if (!d || !bsget || idx<0) \n return Jsi_LogBug(\"invalid bitfield\");\n Jsi_RC rc = (*bsget)(interp, data, &inum, spec, idx, 0);\n if (rc != JSI_OK)\n return JSI_ERROR;\n\n if (enumSpec) {\n struct numStruct { int64_t numVal; } nval = { inum };\n Jsi_OptionSpec eSpec[] = {\n JSI_OPT(CUSTOM, struct numStruct, numVal, .help=spec->help, .flags=JSI_OPT_ENUM_SPEC, .custom=Jsi_Opt_SwitchEnum,\n .data=(void*)enumSpec, .info=0, .tname=spec->tname, .value=0, .bits=0, .boffset=8*sizeof(int64_t) ), //TODO: extra\n JSI_OPT_END(struct numStruct)\n };\n if (JSI_OK != jsi_EnumToValue(interp, eSpec, outValue, outStr, (void*)&nval, flags))\n return JSI_ERROR;\n } else if (outStr) {\n char obuf[100];\n snprintf(obuf, sizeof(obuf), \"%\" PRId64, inum);\n Jsi_DSAppend(outStr, obuf, NULL);\n } else {\n Jsi_Number num = (Jsi_Number)inum;\n Jsi_ValueMakeNumber(interp, outValue, num);\n }\n return JSI_OK;\n}", "label": 0, "programming_language": "C++", "cwe_id": "CWE-120", "cwe_name": "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')", "description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.", "url": "https://cwe.mitre.org/data/definitions/120.html", "label_name": "vulnerable"} {"code": " def self.trim_by_capacity(user_id, mail_account_id, capacity_mb)\n\n# FEATURE_MAIL_STRICT_CAPACITY >>>\n=begin\n# max_size = capacity_mb * 1024 * 1024\n# cur_size = MailAccount.get_using_size(mail_account_id)\n#\n# if cur_size > max_size\n# over_size = cur_size - max_size\n# emails = []\n#\n# # First, empty Trashbox\n# user = User.find(user_id)\n# trashbox = MailFolder.get_for(user, mail_account_id, MailFolder::XTYPE_TRASH)\n# trash_nodes = [trashbox.id.to_s]\n# trash_nodes += MailFolder.get_childs(trash_nodes.first, true, false)\n# con = \"mail_folder_id in (#{trash_nodes.join(',')})\"\n# emails = Email.where(con).order('updated_at ASC').to_a\n# emails.each do |email|\n# next if email.size.nil?\n#\n# email.destroy\n# over_size -= email.size\n# break if over_size <= 0\n# end\n#\n# # Now, remove others\n# if over_size > 0\n# emails = Email.where(\"mail_account_id=#{mail_account_id}\").order('updated_at ASC').to_a\n# emails.each do |email|\n# next if email.size.nil?\n#\n# email.destroy\n# over_size -= email.size\n# break if over_size <= 0\n# end\n# end\n# end\n=end\n# FEATURE_MAIL_STRICT_CAPACITY <<<\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def initialize(hosts, options)\n @options = {\n down_interval: 30,\n refresh_interval: 300\n }.merge(options)\n\n @seeds = hosts\n @nodes = hosts.map { |host| Node.new(host) }\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def get_group_users\n Log.add_info(request, params.inspect)\n\n @group_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @group_id = params[:thetisBoxSelKeeper].split(':').last\n elsif !params[:group_id].nil? and !params[:group_id].empty?\n @group_id = params[:group_id]\n end\n\n submit_url = url_for(:controller => 'send_mails', :action => 'get_group_users')\n render(:partial => 'common/select_users', :layout => false, :locals => {:target_attr => :email, :submit_url => submit_url})\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def format_text(text, wrap, indent=0)\n result = []\n work = clean_text(text)\n\n while work.length > wrap do\n if work =~ /^(.{0,#{wrap}})[ \\n]/ then\n result << $1.rstrip\n work.slice!(0, $&.length)\n else\n result << work.slice!(0, wrap)\n end\n end\n\n result << work if work.length.nonzero?\n result.join(\"\\n\").gsub(/^/, \" \" * indent)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def edit_page\n\n # Saved contents of Login User\n begin\n @research = Research.where(\"user_id=#{@login_user.id}\").first\n rescue\n end\n if @research.nil?\n @research = Research.new\n else\n # Already accepted?\n if !@research.status.nil? and @research.status != 0\n render(:action => 'show_receipt')\n return\n end\n end\n\n # Specifying page\n @page = '01'\n unless params[:page].nil? or params[:page].empty?\n @page = params[:page]\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"should should include the IndirectionHooks module in its indirection\" do\n Puppet::FileServing::Metadata.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " it \"stores the options provided\" do\n session.options.should eq(options)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def self.up\n add_column :items, :source_id, :integer\n\n add_column :addresses, :groups, :text\n add_column :addresses, :teams, :text\n\n add_column :workflows, :groups, :text\n\n add_column :users, :figure, :string\n add_column :groups, :xtype, :string\n\n add_column :teams, :req_to_del_at, :datetime\n change_table :teams do |t|\n t.timestamps\n end\n\n teams = Team.all\n unless teams.nil?\n teams.each do |team|\n begin\n item = Item.find(team.item_id)\n rescue\n end\n next if item.nil?\n\n attrs = ActionController::Parameters.new({created_at: item.created_at, updated_at: item.updated_at})\n attrs.permit!\n team.update_attributes(attrs)\n end\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"returns false\" do\n indexes.drop(other: 1).should be_false\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def new(options = {})\n session = with(options)\n session.cluster.reconnect\n\n if block_given?\n yield session\n else\n session\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def update\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n SqlHelper.validate_token([params[:groups], params[:teams]])\n\n @equipment = Equipment.find(params[:id])\n\n if params[:groups].blank?\n params[:equipment][:groups] = nil\n else\n params[:equipment][:groups] = '|' + params[:groups].join('|') + '|'\n end\n\n if params[:teams].blank?\n params[:equipment][:teams] = nil\n else\n params[:equipment][:teams] = '|' + params[:teams].join('|') + '|'\n end\n\n if @equipment.update_attributes(params.require(:equipment).permit(Equipment::PERMIT_BASE))\n flash[:notice] = t('msg.update_success')\n list\n render(:action => 'list')\n else\n render(:controller => 'equipment', :action => 'edit', :id => params[:id])\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def search(request)\n get_terminus(request).search(request)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def target_uri?(target)\n ::Asciidoctor::Helpers.uriish?(target)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " it \"requires an account with mail\" do\n user = FactoryGirl.create(:user)\n get :index, {}, set_session_user.merge(:user => user.id)\n assert_response :redirect\n assert_redirected_to edit_user_path(user)\n assert_equal \"An email address is required, please update your account details\", flash[:error]\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " def collect\n @stats = Hash.new { |hash, key| hash[key] = [] }\n yield\n @stats\n ensure\n @stats = nil\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def annotate(path, identifier=nil)\n p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))\n blame = Annotate.new\n hg 'rhannotate', '-ncu', \"-r#{CGI.escape(hgrev(identifier))}\", '--', hgtarget(p) do |io|\n io.each_line do |line|\n line.force_encoding('ASCII-8BIT')\n next unless line =~ %r{^([^:]+)\\s(\\d+)\\s([0-9a-f]+):\\s(.*)$}\n r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3,\n :identifier => $3)\n blame.add_line($4.rstrip, r)\n end\n end\n blame\n rescue HgCommandAborted\n # means not found or cannot be annotated\n Annotate.new\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " def move\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n @mail_folder = MailFolder.find(params[:id])\n\n if params[:thetisBoxSelKeeper].blank?\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n return\n end\n\n parent_id = params[:thetisBoxSelKeeper].split(':').last\n SqlHelper.validate_token([parent_id])\n\n if parent_id == '0' # '0' for ROOT\n flash[:notice] = 'ERROR:' + t('mail_folder.root_cannot_have_folders')\n else\n # Check if specified parent is not one of subfolders.\n childs = MailFolder.get_childs(@mail_folder.id, true, false)\n if childs.include?(parent_id) or (@mail_folder.id == parent_id.to_i)\n flash[:notice] = 'ERROR:' + t('folder.cannot_be_parent')\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n return\n end\n\n @mail_folder.parent_id = parent_id\n @mail_folder.xorder = nil\n @mail_folder.save\n\n flash[:notice] = t('msg.move_success')\n end\n\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def update(change, flags = nil)\n session.with(consistency: :strong) do |session|\n session.context.update operation.database,\n operation.collection,\n operation.selector,\n change,\n flags: flags\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def get_group_users\n Log.add_info(request, params.inspect)\n\n @group_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @group_id = params[:thetisBoxSelKeeper].split(':').last\n elsif !params[:group_id].nil? and !params[:group_id].empty?\n @group_id = params[:group_id]\n end\n\n @users = Group.get_users @group_id\n\n render(:partial => 'ajax_select_users', :layout => false)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def distinct(key)\n result = collection.database.command(\n distinct: collection.name,\n key: key.to_s,\n query: selector\n )\n\n result[\"values\"]\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def self.get_for(user, mail_account_id, xtype)\n\n return nil if user.nil? or mail_account_id.blank?\n\n if user.kind_of?(User)\n user_id = user.id\n else\n user_id = user.to_s\n end\n\n SqlHelper.validate_token([user_id, mail_account_id, xtype])\n\n con = []\n con << \"(user_id=#{user_id})\"\n con << \"(mail_account_id=#{mail_account_id})\"\n con << \"(xtype='#{xtype}')\"\n\n return MailFolder.where(con.join(' and ')).first\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "def get_node_attributes(session, cib_dom=nil)\n unless cib_dom\n cib_dom = get_cib_dom(session)\n return {} unless cib_dom\n end\n node_attrs = {}\n cib_dom.elements.each(\n '/cib/configuration/nodes/node/instance_attributes/nvpair'\n ) { |e|\n node = e.parent.parent.attributes['uname']\n node_attrs[node] ||= []\n node_attrs[node] << {\n :id => e.attributes['id'],\n :key => e.attributes['name'],\n :value => e.attributes['value']\n }\n }\n node_attrs.each { |_, val| val.sort_by! { |obj| obj[:key] }}\n return node_attrs\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def accepted_ally_link(uniqueid, data)\n notification = t(\n 'notifications.ally.accepted',\n name: data[:user]\n )\n link = \"/profile?uid=#{data[:uid]}\"\n notification_link(uniqueid, link, notification)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " it \"should allow yaml\" do\n @klass.format :yaml\n @klass.default_options[:format].should == :yaml\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " def next\n @mutex.lock\n begin\n counter = @counter = (@counter + 1) % 0xFFFFFF\n ensure\n @mutex.unlock rescue nil\n end\n\n generate(Time.new.to_i, counter)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def set_auth_users\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n @folder = Folder.find(params[:id])\n\n if Folder.check_user_auth(@folder.id, @login_user, 'w', true)\n\n read_users = []\n write_users = []\n users_auth = params[:users_auth]\n unless users_auth.nil?\n users_auth.each do |auth_param|\n user_id = auth_param.split(':').first\n auths = auth_param.split(':').last.split('+')\n if auths.include?('r')\n read_users << user_id\n end\n if auths.include?('w')\n write_users << user_id\n end\n end\n end\n\n user_id = @folder.get_my_folder_owner\n if !user_id.nil? and (!read_users.include?(user_id.to_s) or !write_users.include?(user_id.to_s))\n flash[:notice] = 'ERROR:' + t('folder.my_folder_without_auth_owner')\n else\n @folder.set_read_users(read_users)\n @folder.set_write_users(write_users)\n\n @folder.save\n\n flash[:notice] = t('msg.register_success')\n end\n else\n flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify')\n end\n\n @group_id = params[:group_id]\n SqlHelper.validate_token([@group_id])\n\n if @group_id.blank?\n @users = []\n else\n @users = Group.get_users(@group_id)\n end\n render(:partial => 'ajax_auth_users', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n render(:partial => 'ajax_auth_users', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def initialize_copy(_)\n @context = Context.new(self)\n @options = @options.dup\n\n if defined? @current_database\n remove_instance_variable :@current_database\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def show\n respond_to do |format|\n format.html\n format.json { render json: @application }\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-862", "cwe_name": "Missing Authorization", "description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/862.html", "label_name": "vulnerable"} {"code": " it \"executes a count command\" do\n database.should_receive(:command).with(\n count: collection.name,\n query: selector\n ).and_return(\"n\" => 4)\n\n query.count\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def check_member\n\n return if params[:id].nil? or params[:id].empty? or @login_user.nil?\n\n if Item.find(params[:id]).user_id != @login_user.id\n Log.add_check(request, '[check_member]'+request.to_s)\n\n flash[:notice] = t('team.need_to_be_member')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def drop\n command dropDatabase: 1\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def demote\n @primary = false\n @secondary = true\n\n hiccup\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def remote_address\n socket_address\n rescue Exception\n log_error\n nil\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def sanitize_key(key)\n case key\n when Symbol then \"--#{key.to_s.tr(\"_\", \"-\")}\"\n else key\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " it \"updates all records matching selector with change\" do\n query.should_receive(:update).with(change, [:multi])\n query.update_all change\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it \"drops all indexes for the collection\" do\n indexes[name: 1].should be_nil\n indexes[age: -1].should be_nil\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def self.on_desktop?(user, xtype, target_id)\n\n return false if user.nil? or xtype.nil? or target_id.nil?\n\n SqlHelper.validate_token([xtype, target_id])\n\n con = \"(user_id=#{user.id}) and (xtype='#{xtype}') and (target_id=#{target_id})\"\n\n begin\n toy = Toy.where(con).first\n rescue => evar\n Log.add_error(nil, evar)\n end\n\n return (!toy.nil?)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def test_put\n uri = URI('http://localhost:6470/makeme')\n req = Net::HTTP::Put.new(uri)\n # Set the headers the way we want them.\n req['Accept-Encoding'] = '*'\n req['Accept'] = 'application/json'\n req['User-Agent'] = 'Ruby'\n req.body = 'hello'\n \n res = Net::HTTP.start(uri.hostname, uri.port) { |h|\n h.request(req)\n }\n assert_equal(Net::HTTPCreated, res.class)\n assert_equal('hello', res.body)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "vulnerable"} {"code": " it \"returns the value from the block\" do\n session.with { :value }.should eq :value\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def name\n FIELD_NAME_MAP[@name.to_s.downcase] || @name\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-93", "cwe_name": "Improper Neutralization of CRLF Sequences ('CRLF Injection')", "description": "The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.", "url": "https://cwe.mitre.org/data/definitions/93.html", "label_name": "vulnerable"} {"code": " it \"sanitizes Pathname param value\" do\n cl = subject.build(\"true\", nil => [Pathname.new(\"/usr/bin/ruby\")])\n expect(cl).to eq \"true /usr/bin/ruby\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " def current_user\n User.unscoped.except_hidden.find_by_login(self.user)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " it \"with Pathname command\" do\n cl = subject.build(Pathname.new(\"/usr/bin/ruby\"))\n expect(cl).to eq \"/usr/bin/ruby\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " it 'should verify a standard RS256 token' do\n domain = 'example.org'\n sub = 'abc123'\n payload = {\n sub: sub,\n exp: future_timecode,\n iss: \"https://#{domain}/\",\n iat: past_timecode,\n aud: client_id,\n kid: jwks_kid\n }\n token = make_rs256_token(payload)\n verified_token = make_jwt_validator(opt_domain: domain).verify(token)\n expect(verified_token['sub']).to eq(sub)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " def create_event(comment)\n Event.create! do |event|\n event.bug_id = comment.bug_id\n event.kind = 'comment'\n event.data = {'comment_id' => comment.id}\n event.user_id = comment.user_id\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def set_package_kind_from_commit( commit )\n check_write_access!\n private_set_package_kind( nil, commit )\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-275", "cwe_name": "Permission Issues", "description": "Weaknesses in this category are related to improper assignment or handling of permissions.", "url": "https://cwe.mitre.org/data/definitions/275.html", "label_name": "safe"} {"code": " def index\n valid_http_methods :get, :post, :put\n\n # for permission check\n if params[:package] and not [\"_repository\", \"_jobhistory\"].include?(params[:package])\n pkg = DbPackage.get_by_project_and_name( params[:project], params[:package], use_source=false )\n else\n prj = DbProject.get_by_name params[:project]\n end\n\n pass_to_backend \n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def deliver!(mail)\n envelope_from = mail.return_path || mail.sender || mail.from_addrs.first\n return_path = \"-f \\\"#{envelope_from.to_s.gsub('\"', '\\\"')}\\\"\" if envelope_from\n\n arguments = [settings[:arguments], return_path].compact.join(\" \")\n\n Sendmail.call(settings[:location], arguments, mail.destinations.collect(&:shellescape).join(\" \"), mail)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " it \"returns false\" do\n session.should_not be_safe\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def refresh(nodes_to_refresh = @nodes)\n refreshed_nodes = []\n seen = {}\n\n # Set up a recursive lambda function for refreshing a node and it's peers.\n refresh_node = ->(node) do\n return if seen[node]\n seen[node] = true\n\n # Add the node to the global list of known nodes.\n @nodes << node unless @nodes.include?(node)\n\n begin\n node.refresh\n\n # This node is good, so add it to the list of nodes to return.\n refreshed_nodes << node unless refreshed_nodes.include?(node)\n\n # Now refresh any newly discovered peer nodes.\n (node.peers - @nodes).each &refresh_node\n rescue Errors::ConnectionFailure\n # We couldn't connect to the node, so don't do anything with it.\n end\n end\n\n nodes_to_refresh.each &refresh_node\n refreshed_nodes.to_a\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def self.get_account_roots_for(user)\n\n return nil if user.nil?\n\n if user.kind_of?(User)\n user_id = user.id\n else\n user_id = user.to_s\n end\n\n SqlHelper.validate_token([user_id])\n\n con = []\n con << \"(user_id=#{user_id})\"\n con << \"(xtype='#{MailFolder::XTYPE_ACCOUNT_ROOT}')\"\n\n order_by = 'xorder ASC, id ASC'\n\n return MailFolder.where(con.join(' and ')).order(order_by).to_a\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def mode\n 0644\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " it \"executes the operation on a slave node\" do\n session.should_receive(:socket_for).with(:read).\n and_return(socket)\n socket.should_receive(:execute).with(operation)\n\n session.execute(operation)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def test_erb_escape\n string = [192, 60].pack('CC')\n expected = 192.chr + \"<\"\n assert_equal expected, ERB::Util.html_escape(string)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " it \"returns nothing\" do\n socket.stub(connect: false)\n\n cluster.sync_server(server).should be_empty\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def self.get_childs(folder_id, conditions, recursive, admin, ret_obj)\n\n SqlHelper.validate_token([folder_id])\n arr = []\n\n if recursive\n\n folder_tree = Folder.get_tree(Hash.new, conditions, folder_id, admin)\n return [] if folder_tree.nil?\n\n folder_tree.each do |parent_id, childs|\n if ret_obj\n arr |= childs\n else\n childs.each do |folder|\n folder_id = folder.id.to_s\n arr << folder_id unless arr.include?(folder_id)\n end\n end\n end\n\n else\n\n con = Marshal.load(Marshal.dump(conditions))\n if con.nil?\n con = ''\n else\n con << ' and '\n end\n con << \"parent_id=#{folder_id}\"\n\n unless admin\n con << \" and (xtype is null or not (xtype='#{Folder::XTYPE_SYSTEM}'))\"\n end\n\n folders = Folder.where(con).order('xorder ASC').to_a\n if ret_obj\n arr = folders\n else\n folders.each do |folder|\n arr << folder.id.to_s\n end\n end\n end\n\n return arr\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.loginByPassword(session, username, password)\n if validUser(username, password)\n session[:username] = username\n success, groups = getUsersGroups(username)\n session[:usergroups] = success ? groups : []\n return true\n end\n return false\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def self.get_tree(klass, tree, conditions, node_id, order_by)\n\n SqlHelper.validate_token([node_id])\n if conditions.nil?\n con = ''\n else\n con = Marshal.load(Marshal.dump(conditions)) + ' and '\n end\n con << \"(parent_id=#{node_id})\"\n\n tree[node_id] = klass.where(con).order(order_by).to_a\n\n tree[node_id].each do |node|\n tree = klass.get_tree(tree, conditions, node.id.to_s)\n end\n\n return tree\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def initialize(seeds, direct = false)\n @seeds = seeds\n @direct = direct\n\n @servers = []\n @dynamic_seeds = []\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " it \"article alone should be password protected\" do\n get :redirect, params: { from: from_param }\n expect(response.body).to have_selector('input[id=\"article_password\"]', count: 1)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " it \"changes the $orderby\" do\n query.sort(a: 1)\n query.sort(a: 2)\n query.operation.selector.should eq(\n \"$query\" => selector,\n \"$orderby\" => { a: 2 }\n )\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " it \"returns nothing\" do\n socket.stub(connect: false)\n\n cluster.sync_server(server).should be_empty\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def request(args = {})\n args = {\n :key => 'key',\n :node => 'host.domain.com',\n :ip => '10.1.1.1',\n :authenticated => true\n }.merge(args)\n ['test', :find, args[:key], args]\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": " def insert(documents)\n documents = [documents] unless documents.is_a? Array\n insert = Protocol::Insert.new(database.name, name, documents)\n\n database.session.with(consistency: :strong) do |session|\n session.execute insert\n end\n\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def self.loginByToken(session, cookies)\n if username = validToken(cookies[\"token\"])\n if SUPERUSER == username\n if cookies['CIB_user'] and cookies['CIB_user'].strip != ''\n session[:username] = cookies['CIB_user']\n if cookies['CIB_user_groups'] and cookies['CIB_user_groups'].strip != ''\n session[:usergroups] = cookieUserDecode(\n cookies['CIB_user_groups']\n ).split(nil)\n else\n session[:usergroups] = []\n end\n else\n session[:username] = SUPERUSER\n session[:usergroups] = []\n end\n return true\n else\n session[:username] = username\n success, groups = getUsersGroups(username)\n session[:usergroups] = success ? groups : []\n return true\n end\n end\n return false\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def clean_text(text)\n text.gsub(/[\\u0000-\\u0008\\u000b-\\u000c\\u000e-\\u001F\\u007f]/, \".\".freeze)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " def self.save_value(user_id, category, key, value)\n\n SqlHelper.validate_token([user_id, category, key])\n\n con = []\n con << \"(user_id=#{user_id.to_i})\"\n con << \"(category='#{category}')\"\n con << \"(xkey='#{key}')\"\n\n setting = Setting.where(con.join(' and ')).first\n\n if value.nil?\n unless setting.nil?\n setting.destroy\n end\n else\n if setting.nil?\n setting = Setting.new\n setting.user_id = user_id\n setting.category = category\n setting.xkey = key\n setting.xvalue = value\n setting.save!\n else\n setting.update_attribute(:xvalue, value)\n end\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.validate_token(tokens, extra_chars=nil)\n\n if extra_chars.nil?\n extra_chars = ''\n else\n extra_chars = Regexp.escape(extra_chars.join())\n end\n regexp = Regexp.new(\"^[ ]*[a-zA-Z0-9_.@\\\\-#{extra_chars}]+[ ]*$\")\n\n [tokens].flatten.each do |token|\n next if token.blank?\n\n if token.to_s.match(regexp).nil?\n raise(\"[ERROR] SqlHelper.validate_token failed: #{token}\")\n end\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def accept\n to_io.accept\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def process(operation, &callback)\n if Threaded.executing? :pipeline\n queue.push [operation, callback]\n else\n flush([[operation, callback]])\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def update_pref\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n desktop = Desktop.get_for(@login_user, true)\n\n params[:desktop].delete(:user_id)\n\n desktop.update_attributes(params.require(:desktop).permit(Desktop::PERMIT_BASE))\n\n params.delete(:desktop)\n\n show\n render(:action => 'show')\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"instructs the cluster to reconnect\" do\n session.stub(with: new_session)\n new_session.cluster.should_receive(:reconnect)\n session.new(new_options)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def initialize(set)\n @set = set\n @primary = false\n @secondary = false\n\n server = TCPServer.new 0\n @host = Socket.gethostname\n @port = server.addr[1]\n server.close\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def next\n now = Time.new.to_i\n\n counter = @mutex.synchronize do\n last_timestamp, @last_timestamp = @last_timestamp, now\n\n if last_timestamp == now\n @counter += 1\n else\n @counter = 0\n end\n end\n\n generate(now, counter)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it 'should handle yaml automatically' do\n yaml = \"books: \\n book: \\n name: Foo Bar!\\n id: \\\"1234\\\"\\n\"\n @request.options[:format] = :yaml\n @request.send(:parse_response, yaml).should == {'books' => {'book' => {'id' => '1234', 'name' => 'Foo Bar!'}}}\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " def initialize(nodes = 3)\n @nodes = nodes.times.map { Node.new(self) }\n @manager = ConnectionManager.new(@nodes)\n @mongo = TCPSocket.new \"127.0.0.1\", 27017\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def add_group( group, role )\n check_write_access!\n\n unless role.kind_of? Role\n role = Role.get_by_title(role)\n end\n if role.global\n #only nonglobal roles may be set in a project\n raise SaveError, \"tried to set global role '#{role_title}' for group '#{group}' in project '#{self.name}'\"\n end\n\n unless group.kind_of? Group\n group = Group.find_by_title(group)\n end\n\n logger.debug \"adding group: #{group.title}, #{role.title}\"\n ProjectGroupRoleRelationship.create(\n :project => self,\n :group => group,\n :role => role )\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-275", "cwe_name": "Permission Issues", "description": "Weaknesses in this category are related to improper assignment or handling of permissions.", "url": "https://cwe.mitre.org/data/definitions/275.html", "label_name": "safe"} {"code": " def get_users\n if params[:action] == 'get_users'\n Log.add_info(request, params.inspect)\n end\n\n @group_id = params[:id]\n SqlHelper.validate_token([@group_id])\n\n=begin\n# @users = Group.get_users(params[:id])\n=end\n\n# FEATURE_PAGING_IN_TREE >>>\n con = ['User.id > 0']\n\n unless @group_id.nil?\n if @group_id == '0'\n con << \"((groups like '%|0|%') or (groups is null))\"\n else\n con << SqlHelper.get_sql_like([:groups], \"|#{@group_id}|\")\n end\n end\n\n unless params[:keyword].blank?\n key_array = params[:keyword].split(nil)\n key_array.each do |key| \n con << SqlHelper.get_sql_like([:name, :email, :fullname, :address, :organization, :tel1, :tel2, :tel3, :fax, :url, :postalcode, :title], key)\n end\n end\n\n where = ''\n unless con.empty?\n where = ' where ' + con.join(' and ')\n end\n\n order_by = nil\n @sort_col = params[:sort_col]\n @sort_type = params[:sort_type]\n\n if @sort_col.blank? or @sort_type.blank?\n @sort_col = 'OfficialTitle.xorder'\n @sort_type = 'ASC'\n end\n\n SqlHelper.validate_token([@sort_col, @sort_type])\n order_by = @sort_col + ' ' + @sort_type\n\n if @sort_col == 'OfficialTitle.xorder'\n order_by = '(OfficialTitle.xorder is null) ' + @sort_type + ', ' + order_by\n else\n order_by << ', (OfficialTitle.xorder is null) ASC, OfficialTitle.xorder ASC'\n end\n if @sort_col != 'name'\n order_by << ', name ASC'\n end\n\n sql = 'select distinct User.* from (users User left join user_titles UserTitle on User.id=UserTitle.user_id)'\n sql << ' left join official_titles OfficialTitle on UserTitle.official_title_id=OfficialTitle.id'\n\n sql << where + ' order by ' + order_by\n\n @user_pages, @users, @total_num = paginate_by_sql(User, sql, 50)\n# FEATURE_PAGING_IN_TREE <<<\n\n session[:group_id] = @group_id\n session[:group_option] = 'user'\n\n render(:partial => 'ajax_group_users', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def update\n Log.add_info(request, params.inspect)\n\n @equipment = Equipment.find(params[:id])\n\n if (params[:groups].nil? or params[:groups].empty?)\n params[:equipment][:groups] = nil\n else\n params[:equipment][:groups] = '|' + params[:groups].join('|') + '|'\n end\n\n if (params[:teams].nil? or params[:teams].empty?)\n params[:equipment][:teams] = nil\n else\n params[:equipment][:teams] = '|' + params[:teams].join('|') + '|'\n end\n\n if @equipment.update_attributes(params.require(:equipment).permit(Equipment::PERMIT_BASE))\n flash[:notice] = t('msg.update_success')\n list\n render(:action => 'list')\n else\n render(:controller => 'equipment', :action => 'edit', :id => params[:id])\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def index\n respond_to do |format|\n format.json do\n dir = params[:dir]\n dir = 'DESC' unless SORT_DIRECTIONS.include?(dir.try(:upcase))\n\n @occurrences = @bug.occurrences.order(\"occurred_at #{dir}\").limit(50)\n\n last = params[:last].present? ? @bug.occurrences.find_by_number(params[:last]) : nil\n @occurrences = @occurrences.where(infinite_scroll_clause('occurred_at', dir, last, 'occurrences.number')) if last\n\n render json: decorate(@occurrences)\n end\n format.atom { @occurrences = @bug.occurrences.order('occurred_at DESC').limit(100) } # index.atom.builder\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "safe"} {"code": " it \"fails when user is suspended\" do\n user.update!(\n suspended_till: 2.days.from_now,\n suspended_at: Time.zone.now\n )\n\n get \"/session/email-login/#{email_token.token}\"\n\n expect(response.status).to eq(200)\n\n expect(CGI.unescapeHTML(response.body)).to include(I18n.t(\"login.suspended\",\n date: I18n.l(user.suspended_till, format: :date_only)\n ))\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " def destroy_title\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n title = params[:title]\n\n titles = User.get_config_titles\n unless titles.nil?\n titles.delete(title)\n User.save_config_titles titles\n end\n\n User.update_xorder(title, User::XORDER_MAX)\n idx = 0\n unless titles.nil?\n titles.each do |title|\n User.update_xorder(title, idx)\n idx += 1\n end\n end\n\n render(:partial => 'ajax_title', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def stack(name)\n Thread.current[\"[moped]:#{name}-stack\"] ||= []\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def simple_query(query)\n query.limit = -1\n\n query(query).documents.first\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def check_import(mode, address_names) #, address_emails\n\n err_msgs = []\n\n # Existing Addresss\n unless self.id.nil? or self.id == 0 or self.id == ''\n if mode == 'add'\n err_msgs << I18n.t('address.import.dont_specify_id')\n else\n begin\n org_address = Address.find(self.id)\n rescue\n end\n if org_address.nil?\n err_msgs << I18n.t('address.import.not_found')\n end\n end\n end\n\n # Requierd\n if self.name.nil? or self.name.empty?\n err_msgs << Address.human_attribute_name('name') + I18n.t('msg.is_required')\n end\n\n # Groups\n unless self.groups.nil? or self.groups.empty?\n\n if (/^|([0-9]+|)+$/ =~ self.groups) == 0\n\n self.get_groups_a.each do |group_id|\n begin\n group = Group.find(group_id)\n rescue => evar\n group = nil\n end\n if group.nil?\n err_msgs << I18n.t('address.import.not_valid_groups') + ': '+group_id.to_s\n break\n end\n end\n else\n err_msgs << I18n.t('address.import.invalid_groups_format')\n end\n end\n\n # Teams\n unless self.teams.nil? or self.teams.empty?\n\n if (/^|([0-9]+|)+$/ =~ self.teams) == 0\n\n self.get_teams_a.each do |team_id|\n begin\n team = Team.find(team_id)\n rescue => evar\n team = nil\n end\n if team.nil?\n err_msgs << I18n.t('address.import.not_valid_teams') + ': '+team_id.to_s\n break\n end\n end\n\n else\n err_msgs << I18n.t('address.import.invalid_teams_format')\n end\n end\n\n return err_msgs\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def install_location filename, destination_dir # :nodoc:\n raise Gem::Package::PathError.new(filename, destination_dir) if\n filename.start_with? '/'\n\n destination_dir = File.realpath destination_dir if\n File.respond_to? :realpath\n destination_dir = File.expand_path destination_dir\n\n destination = File.join destination_dir, filename\n destination = File.expand_path destination\n\n raise Gem::Package::PathError.new(destination, destination_dir) unless\n destination.start_with? destination_dir + '/'\n\n destination.untaint\n destination\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " def known_addresses\n [].tap do |addresses|\n addresses.concat seeds\n addresses.concat dynamic_seeds\n addresses.concat servers.map { |server| server.address }\n end.uniq\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def pre_install_checks\n verify_gem_home options[:unpack]\n\n ensure_loadable_spec\n\n verify_spec_name\n\n if options[:install_as_default]\n Gem.ensure_default_gem_subdirectories gem_home\n else\n Gem.ensure_gem_subdirectories gem_home\n end\n\n return true if @force\n\n ensure_required_ruby_version_met\n ensure_required_rubygems_version_met\n ensure_dependencies_met unless @ignore_dependencies\n\n true\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " it \"should choose :rest when the Settings name isn't 'puppet'\" do\n @request.stubs(:protocol).returns \"puppet\"\n @request.stubs(:server).returns \"foo\"\n Puppet.settings.stubs(:value).with(:name).returns \"foo\"\n @object.select_terminus(@request).should == :rest\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " def query(database, collection, selector, options = {})\n operation = Protocol::Query.new(database, collection, selector, options)\n\n process operation do |reply|\n if reply.flags.include? :query_failure\n raise Errors::QueryFailure.new(operation, reply.documents.first)\n end\n\n reply\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def to_s\n @@string_format % data\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def test_update_valid\n Domain.any_instance.stubs(:valid?).returns(true)\n put :update, {:id => Domain.first.to_param, :domain => {:name => Domain.first.name }}, set_session_user\n assert_redirected_to domains_url\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "def cluster_start(params, request, session)\n if params[:name]\n code, response = send_request_with_token(\n session, params[:name], 'cluster_start', true\n )\n else\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n $logger.info \"Starting Daemons\"\n output = `#{PCS} cluster start`\n $logger.debug output\n return output\n end\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def needs_refresh?(time)\n !@refreshed_at || @refreshed_at < time\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def test_pre_install_checks_malicious_name\n spec = util_spec '../malicious', '1'\n def spec.full_name # so the spec is buildable\n \"malicious-1\"\n end\n def spec.validate; end\n\n util_build_gem spec\n\n gem = File.join(@gemhome, 'cache', spec.file_name)\n\n use_ui @ui do\n @installer = Gem::Installer.at gem\n e = assert_raises Gem::InstallError do\n @installer.pre_install_checks\n end\n assert_equal '# has an invalid name', e.message\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def self.get_carried_over(user_id, year)\n\n SqlHelper.validate_token([user_id, year])\n\n yaml = ApplicationHelper.get_config_yaml\n unless yaml[:timecard].nil?\n paidhld_carry_over = yaml[:timecard]['paidhld_carry_over']\n end\n\n return 0 if paidhld_carry_over.nil? or paidhld_carry_over.empty? or paidhld_carry_over == PaidHoliday::CARRY_OVER_NONE\n\n begin\n con = \"(user_id=#{user_id.to_i}) and (year < #{year.to_i})\"\n paidhlds = PaidHoliday.where(con).order('year ASC').to_a\n rescue\n end\n return 0 if paidhlds.nil? or paidhlds.empty?\n\n sum = 0\n year_begins_from, month_begins_at = TimecardsHelper.get_fiscal_params\n\n if paidhld_carry_over == PaidHoliday::CARRY_OVER_1_YEAR\n\n last_carried_out = 0\n\n for y in paidhlds.first.year .. year - 1\n paidhld = paidhlds.find { |hld| hld.year == y }\n given_num = (paidhld.nil?)?0:paidhld.num\n\n start_date, end_date = TimecardsHelper.get_year_span(y, year_begins_from, month_begins_at)\n applied_paid_hlds = Timecard.applied_paid_hlds(user_id, start_date, end_date)\n\n if applied_paid_hlds >= last_carried_out\n last_carried_out = given_num - (applied_paid_hlds - last_carried_out)\n else\n last_carried_out = given_num\n end\n end\n\n return last_carried_out\n\n elsif paidhld_carry_over == PaidHoliday::CARRY_OVER_NO_EXPIRATION\n\n paidhlds.each do |paidhld|\n sum += paidhld.num\n end\n\n start_date, dummy = TimecardsHelper.get_year_span(paidhlds.first.year, year_begins_from, month_begins_at)\n dummy, end_date = TimecardsHelper.get_year_span(year - 1, year_begins_from, month_begins_at)\n applied_paid_hlds = Timecard.applied_paid_hlds(user_id, start_date, end_date)\n\n return (sum - applied_paid_hlds)\n else\n return 0\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def send_password\n Log.add_info(request, params.inspect)\n\n mail_addr = params[:thetisBoxEdit]\n begin\n users = User.where(email: mail_addr).to_a\n rescue => evar\n end\n\n if users.nil? or users.empty?\n Log.add_error(request, evar)\n flash[:notice] = 'ERROR:' + t('email.address_not_found')\n else\n user_passwords_h = {}\n users.each do |user|\n newpass = UsersHelper.generate_password\n user.update_attribute(:pass_md5, UsersHelper.generate_digest_pass(user.name, newpass))\n\n user_passwords_h[user] = newpass\n end\n\n NoticeMailer.password(user_passwords_h, ApplicationHelper.root_url(request)).deliver;\n flash[:notice] = t('email.sent')\n end\n\n render(:controller => 'login', :action => 'index')\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def redirect_back_or_default(default, options={})\n back_url = params[:back_url].to_s\n if back_url.present? && valid_url = validate_back_url(back_url)\n redirect_to(valid_url)\n return\n elsif options[:referer]\n redirect_to_referer_or default\n return\n end\n redirect_to default\n false\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "safe"} {"code": " it 'should return an x5c key' do\n expect(jwt_validator.jwks_key(:x5c, jwks_kid).length).to eq(1)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-347", "cwe_name": "Improper Verification of Cryptographic Signature", "description": "The software does not verify, or incorrectly verifies, the cryptographic signature for data.", "url": "https://cwe.mitre.org/data/definitions/347.html", "label_name": "vulnerable"} {"code": " def current_database\n return @current_database if defined? @current_database\n\n if database = options[:database]\n set_current_database(database)\n else\n raise \"No database set for session. Call #use or #with before accessing the database\"\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "def wizard_submit(params, request, session)\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n wizard = PCSDWizard.getWizard(params[\"wizard\"])\n if wizard != nil\n return erb wizard.process_responses(params)\n else\n return \"Error finding Wizard - #{params[\"wizard\"]}\"\n end\n\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def group_link(uniqueid, data)\n notification = t(\n \"notifications.group.#{data[:type]}\",\n name: data[:user],\n group_name: data[:group]\n )\n link = \"/groups/#{data[:group_id]}\"\n notification_link(uniqueid, link, notification)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " it \"unmemoizes the current database\" do\n db = session.current_database\n session.with(new_options) do |new_session|\n new_session.current_database.should_not eql db\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def users\n Log.add_info(request, params.inspect)\n\n @item = Item.find(params[:item_id])\n\n con = []\n\n unless params[:keyword].blank?\n key_array = params[:keyword].split(nil)\n key_array.each do |key| \n con << SqlHelper.get_sql_like([:name, :email, :fullname, :address, :organization], key)\n end\n end\n\n @group_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @group_id = params[:thetisBoxSelKeeper].split(':').last\n elsif !params[:group_id].blank?\n @group_id = params[:group_id]\n end\n SqlHelper.validate_token([@group_id])\n\n unless @group_id.nil?\n con << SqlHelper.get_sql_like([:groups], \"|#{@group_id}|\")\n end\n\n include_comment = false\n\n filter_status = params[:filter_status]\n SqlHelper.validate_token([filter_status])\n\n unless filter_status.blank?\n case filter_status\n when ZeptairDistHelper::STATUS_REPLIED\n con << \"((Comment.item_id=#{@item.id}) and (Comment.xtype='#{Comment::XTYPE_DIST_ACK}') and (Comment.user_id=User.id))\"\n include_comment = true\n when ZeptairDistHelper::STATUS_COMPLETE\n ack_msg = ZeptairDistHelper.completed_ack_message(@item.id)\n con << \"((Comment.item_id=#{@item.id}) and (Comment.xtype='#{Comment::XTYPE_DIST_ACK}') and (Comment.user_id=User.id) and (Comment.message='#{ack_msg}'))\"\n include_comment = true\n when ZeptairDistHelper::STATUS_NO_REPLY\n comments = Comment.where(\"((Comment.item_id=#{@item.id}) and (Comment.xtype='#{Comment::XTYPE_DIST_ACK}'))\").to_a\n except_users = []\n unless comments.nil?\n comments.each do |comment|\n except_users << comment.user_id\n end\n end\n unless except_users.empty?\n con << '(User.id not in (' + except_users.join(',') + '))'\n end\n else\n ;\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def titleize(key)\n key.to_s.gsub('_', ' ').gsub(/\\b('?[a-z])/) { $1.capitalize }\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": " it \"does not change the original session's options\" do\n original_options = options.dup\n session.with(new_options) do |new_session|\n session.options.should eql original_options\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def get_group_users\n Log.add_info(request, params.inspect)\n\n @group_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @group_id = params[:thetisBoxSelKeeper].split(':').last\n elsif !params[:group_id].blank?\n @group_id = params[:group_id]\n end\n SqlHelper.validate_token([@group_id])\n\n @users = Group.get_users(@group_id)\n\n render(:partial => 'ajax_select_users', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def do_execute\n Log.add_info(request, params.inspect)\n\n mail_account = MailAccount.find(params[:mail_account_id])\n mail_folder = MailFolder.find(params[:mail_folder_id])\n\n if mail_account.user_id != @login_user.id \\\n or mail_folder.user_id != @login_user.id\n render(:text => t('msg.need_to_be_owner'))\n return\n end\n\n mail_filters = MailFilter.get_for(mail_account.id, true, MailFilter::TRIGGER_MANUAL)\n emails = MailFolder.get_mails(mail_folder.id, mail_folder.user_id)\n\n filter_next = true\n emails.each do |email|\n mail_filters.each do |filter|\n filter_next = filter.execute(email)\n break unless filter_next\n end\n break unless filter_next\n end\n\n render(:text => '')\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.get_for_group(group_id, category=nil)\n\n SqlHelper.validate_token([group_id, category])\n\n con = []\n con << \"(group_id=#{group_id})\"\n con << \"(category='#{category}')\" unless category.nil?\n\n settings = Setting.where(con.join(' and ')).to_a\n\n return nil if settings.nil? or settings.empty?\n\n hash = Hash.new\n\n settings.each do |setting|\n hash[setting.xkey] = setting.xvalue\n end\n\n return hash\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def load_file(filename)\n Gem.load_yaml\n\n yaml_errors = [ArgumentError]\n yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)\n\n return {} unless filename and File.exist? filename\n\n begin\n content = Gem::SafeYAML.load(File.read(filename))\n unless content.kind_of? Hash\n warn \"Failed to load #{filename} because it doesn't contain valid YAML hash\"\n return {}\n end\n return content\n rescue *yaml_errors => e\n warn \"Failed to load #{filename}, #{e}\"\n rescue Errno::EACCES\n warn \"Failed to load #{filename} due to permissions problem.\"\n end\n\n {}\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " it \"should choose :rest when a server is specified\" do\n @request.stubs(:protocol).returns \"puppet\"\n @request.expects(:server).returns \"foo\"\n @object.select_terminus(@request).should == :rest\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " it \"removes the first matching document\" do\n users.insert(documents)\n users.find(scope: scope).remove\n users.find(scope: scope).count.should eq 1\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def self.get_for_user(user)\n\n return [] if user.nil?\n\n toys = Toy.where(\"user_id=#{user.id}\").to_a\n deleted_ary = []\n\n return [] if toys.nil?\n\n toys.each do |toy|\n case toy.xtype\n when Toy::XTYPE_ITEM\n item = Item.find_by_id(toy.target_id)\n if item.nil?\n deleted_ary << toy\n next\n end\n Toy.copy(toy, item)\n\n when Toy::XTYPE_COMMENT\n comment = Comment.find_by_id(toy.target_id)\n if comment.nil?\n deleted_ary << toy\n next\n end\n Toy.copy(toy, comment)\n\n when Toy::XTYPE_WORKFLOW\n workflow = Workflow.find_by_id(toy.target_id)\n if workflow.nil?\n deleted_ary << toy\n next\n end\n Toy.copy(toy, workflow)\n\n when Toy::XTYPE_SCHEDULE\n schedule = Schedule.find_by_id(toy.target_id)\n if schedule.nil?\n deleted_ary << toy\n next\n end\n Toy.copy(toy, schedule)\n\n when Toy::XTYPE_FOLDER\n folder = Folder.find_by_id(toy.target_id)\n if folder.nil?\n deleted_ary << toy\n next\n end\n Toy.copy(toy, folder)\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "def node_unstandby(params, request, session)\n if params[:name]\n code, response = send_request_with_token(\n session, params[:name], 'node_unstandby', true, {\"node\"=>params[:name]}\n )\n # data={\"node\"=>params[:name]} for backward compatibility with older versions of pcs/pcsd\n else\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n $logger.info \"Unstandby Node\"\n stdout, stderr, retval = run_cmd(session, PCS, \"cluster\", \"unstandby\")\n return stdout\n end\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def test_update_invalid\n Subnet.any_instance.stubs(:valid?).returns(false)\n subnet_id = @model\n put :update, {:id => subnet_id, :subnet => {:network => nil}}, set_session_user\n assert_template 'edit'\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def search(request)\n get_terminus(request).search(request)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def update_break\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n unless params[:user_id].nil?\n @selected_user = User.find(params[:user_id])\n\n if @selected_user.id != @login_user.id and !@login_user.admin?(User::AUTH_TIMECARD)\n Log.add_check(request, '[User::AUTH_TIMECARD]'+request.to_s)\n redirect_to(:controller => 'frames', :action => 'http_error', :id => '401')\n return\n end\n end\n\n @timecard = Timecard.find(params[:id])\n\n @date = Date.parse params[:date]\n start_dt = UtilDateTime.new(@date.year, @date.month, @date.day, params[:start_hour].to_i, params[:start_min].to_i)\n end_dt = UtilDateTime.new(@date.year, @date.month, @date.day, params[:end_hour].to_i, params[:end_min].to_i)\n\n if start_dt == end_dt\n flash[:notice] = 'ERROR:' + t('timecard.break_without_span')\n render(:partial => 'ajax_update_break', :layout => false)\n return\n end\n\n org_start_t = start_dt.to_time\n org_end_t = end_dt.to_time\n\n if org_end_t < org_start_t\n end_dt += 1\n else\n if (@timecard.end.nil? or @timecard.start.day != @timecard.end.day) and org_end_t <= @timecard.start\n start_dt += 1\n end_dt += 1\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def replica_set_configured?\n ENV[\"MONGOHQ_REPL_PASS\"]\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Item.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_ITEM) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"inserts the documents\" do\n session.should_receive(:execute).with do |insert|\n insert.documents.should eq [{a: 1}, {b: 2}]\n end\n collection.insert([{a: 1}, {b: 2}])\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it \"returns a hex string representation of the id\" do\n Moped::BSON::ObjectId.from_data(bytes).to_s.should eq \"4e4d66343b39b68407000001\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def show\n if params[:action] == 'show'\n Log.add_info(request, params.inspect)\n end\n\n begin\n @mail_filter = MailFilter.find(params[:id])\n rescue => evar\n end\n if @mail_filter.nil?\n render(:text => 'ERROR:' + t('msg.already_deleted', :name => MailFilter.model_name.human))\n return\n else\n if @mail_filter.mail_account.user_id != @login_user.id\n render(:text => 'ERROR:' + t('msg.need_to_be_owner'))\n return\n end\n end\n render(:action => 'show', :layout => (!request.xhr?))\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def test_AES_crush\n 500.times do\n assert_nothing_raised(\"[Bug #2768]\") do\n # it caused OpenSSL SEGV by uninitialized key\n OpenSSL::Cipher::AES128.new(\"ECB\").update \".\" * 17\n end\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-326", "cwe_name": "Inadequate Encryption Strength", "description": "The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.", "url": "https://cwe.mitre.org/data/definitions/326.html", "label_name": "vulnerable"} {"code": " def initialize_copy(_)\n @context = Context.new(self)\n @options = @options.dup\n\n if defined? @current_database\n remove_instance_variable :@current_database\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def move\n Log.add_info(request, params.inspect)\n\n unless params[:thetisBoxSelKeeper].nil?\n folder_id = params[:thetisBoxSelKeeper].split(':').last\n SqlHelper.validate_token([folder_id])\n\n workflow = Workflow.find(params[:id])\n\n workflow.item.update_attribute(:folder_id, folder_id)\n\n flash[:notice] = t('msg.move_success')\n end\n\n my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)\n\n sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)\n @workflows = Workflow.find_by_sql(sql)\n\n render(:partial => 'ajax_workflow', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n\n flash[:notice] = 'ERROR:' + evar.to_s[0, 64]\n render(:partial => 'ajax_workflow', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def bulk_unread_topic_ids\n topic_query = TopicQuery.new(current_user)\n\n if inbox = params[:private_message_inbox]\n filter = private_message_filter(topic_query, inbox)\n topic_query.options[:limit] = false\n\n topic_query\n .filter_private_messages_unread(current_user, filter)\n .distinct(false)\n .pluck(:id)\n else\n topics = TopicQuery.unread_filter(topic_query.joined_topic_user, staff: guardian.is_staff?).listable_topics\n topics = TopicQuery.tracked_filter(topics, current_user.id) if params[:tracked].to_s == \"true\"\n\n if params[:category_id]\n if params[:include_subcategories]\n topics = topics.where(<<~SQL, category_id: params[:category_id])\n category_id in (select id FROM categories WHERE parent_category_id = :category_id) OR\n category_id = :category_id\n SQL\n else\n topics = topics.where('category_id = ?', params[:category_id])\n end\n end\n\n if params[:tag_name].present?\n topics = topics.joins(:tags).where(\"tags.name\": params[:tag_name])\n end\n\n topics.pluck(:id)\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " def move\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n unless params[:thetisBoxSelKeeper].nil?\n folder_id = params[:thetisBoxSelKeeper].split(':').last\n SqlHelper.validate_token([folder_id])\n\n workflow = Workflow.find(params[:id])\n\n workflow.item.update_attribute(:folder_id, folder_id)\n\n flash[:notice] = t('msg.move_success')\n end\n\n my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)\n\n sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)\n @workflows = Workflow.find_by_sql(sql)\n\n render(:partial => 'ajax_workflow', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n\n flash[:notice] = 'ERROR:' + evar.to_s[0, 64]\n render(:partial => 'ajax_workflow', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def mode\n 0400\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " it \"queries a secondary node\" do\n stats = Support::Stats.collect do\n session.with(consistency: :eventual)[:users].find(scope: scope).entries\n end\n\n stats[:secondary].grep(Moped::Protocol::Query).count.should eq 1\n stats[:primary].should be_empty\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def destroy\n current_user.invalidate_all_sessions!\n super\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": " def setup_user(operation, type = \"\", search = nil, user = :one)\n @one = users(user)\n as_admin do\n permission = Permission.find_by_name(\"#{operation}_#{type}\") ||\n FactoryGirl.create(:permission, :name => \"#{operation}_#{type}\")\n filter = FactoryGirl.build(:filter, :search => search)\n filter.permissions = [ permission ]\n role = Role.where(:name => \"#{operation}_#{type}\").first_or_create\n role.filters = [ filter ]\n role.save!\n filter.role = role\n filter.save!\n @one.roles << role\n yield(@one) if block_given?\n @one.save!\n end\n User.current = @one\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " it 'does not log in with incorrect backup code' do\n post \"/session/email-login/#{email_token.token}\", params: {\n second_factor_token: \"0000\",\n second_factor_method: UserSecondFactor.methods[:backup_codes]\n }\n\n expect(response.status).to eq(200)\n expect(CGI.unescapeHTML(response.body)).to include(I18n.t(\n \"login.invalid_second_factor_code\"\n ))\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " def test_update_invalid\n AuthSourceLdap.any_instance.stubs(:valid?).returns(false)\n put :update, {:id => AuthSourceLdap.unscoped.first, :auth_source_ldap => {:name => AuthSourceLdap.unscoped.first.name} }, set_session_user\n assert_template 'edit'\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " it \"yields all indexes on the collection\" do\n indexes.to_a.should eq \\\n session[:\"system.indexes\"].find(ns: \"moped_test.users\").to_a\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def update\n @campaign.update(campaign_params)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def initialize\n # Generate and cache 3 bytes of identifying information from the current\n # machine.\n @machine_id = Digest::MD5.digest(Socket.gethostname).unpack(\"C3\")\n\n @mutex = Mutex.new\n @last_timestamp = nil\n @counter = 0\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it 'is possible to return hash errors in jsonapi format' do\n get '/'\n expect(['{\"error\":\"rain!\",\"detail\":\"missing widget\"}',\n '{\"detail\":\"missing widget\",\"error\":\"rain!\"}']).to include(last_response.body)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " def delete_image\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n begin\n image = Image.find(params[:image_id])\n\n @item = Item.find(image.item_id)\n\n unless @item.check_user_auth(@login_user, 'w', true)\n raise t('msg.need_to_be_owner')\n end\n\n image.destroy\n\n @item.update_attribute(:updated_at, Time.now)\n\n rescue => evar\n Log.add_error(request, evar)\n end\n\n render(:partial => 'ajax_item_image', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def list\n if params[:action] == 'list'\n Log.add_info(request, params.inspect)\n end\n\n @folder_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @folder_id = params[:thetisBoxSelKeeper].split(':').last\n\n if !@folder_id.nil? and @folder_id.index('+') == 0\n @folder_id[0, 1] = ''\n end\n elsif params[:folder_id].blank?\n else\n @folder_id = params[:folder_id]\n end\n SqlHelper.validate_token([@folder_id])\n\n unless @folder_id.nil?\n session[:folder_id] = @folder_id\n\n unless Folder.check_user_auth(@folder_id, @login_user, 'r', true)\n flash[:notice] = 'ERROR:' + t('folder.need_auth_to_read')\n end\n end\n\n# Copy to FEATURE_PAGING_IN_TREE >>>\n @sort_col = params[:sort_col]\n @sort_type = params[:sort_type]\n\n if @sort_col.blank? or @sort_type.blank?\n @sort_col, @sort_type = FoldersHelper.get_sort_params(@folder_id)\n end\n\n folder_ids = nil\n add_con = nil\n\n if @folder_id.nil? and params[:find_in] != Item::FOLDER_ALL\n add_con = \"(Item.folder_id != 0) and (Folder.disp_ctrl like '%|#{Folder::DISPCTRL_BBS_TOP}|%')\"\n else\n case params[:find_in]\n when Item::FOLDER_ALL\n ;\n when Item::FOLDER_CURRENT\n folder_ids = [@folder_id]\n when Item::FOLDER_LOWER\n folder_ids = Folder.get_childs(@folder_id, nil, true, false, false)\n folder_ids.unshift(@folder_id)\n else\n folder_ids = [@folder_id]\n end\n unless folder_ids.nil?\n delete_ary = []\n folder_ids.each do |folder_id|\n unless Folder.check_user_auth(folder_id, @login_user, 'r', true)\n delete_ary << folder_id\n end\n end\n folder_ids -= delete_ary unless delete_ary.empty?\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.getUsersGroups(username)\n stdout, stderr, retval = run_cmd(\n getSuperuserSession, \"id\", \"-Gn\", username\n )\n if retval != 0\n $logger.info(\n \"Unable to determine groups of user '#{username}': #{stderr.join(' ').strip}\"\n )\n return [false, []]\n end\n return [true, stdout.join(' ').split(nil)]\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " it 'should authenticate user and delete token' do\n user = Fabricate(:user)\n\n get \"/session/current.json\"\n expect(response.status).to eq(404)\n\n token = SecureRandom.hex\n $redis.setex \"otp_#{token}\", 10.minutes, user.username\n\n get \"/session/otp/#{token}\"\n\n expect(response.status).to eq(302)\n expect(response).to redirect_to(\"/\")\n expect($redis.get(\"otp_#{token}\")).to eq(nil)\n\n get \"/session/current.json\"\n expect(response.status).to eq(200)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " def update_header_menu\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n @yaml = ApplicationHelper.get_config_yaml\n\n @yaml[:general]['header_menus'] = [] if @yaml[:general]['header_menus'].nil?\n\n entry = [params[:header_menu]['name'], params[:header_menu]['target'], params[:header_menu]['url']]\n\n unless @yaml[:general]['header_menus'].nil?\n if params[:org_name].nil? or params[:org_name] != entry[0]\n @yaml[:general]['header_menus'].each do |header_menu|\n if header_menu[0] == entry[0]\n flash[:notice] = 'ERROR:' + t('msg.menu_duplicated')\n render(:partial => 'ajax_header_menu', :layout => false)\n return\n end\n end\n end\n end\n\n idx = nil\n unless params[:org_name].nil? or @yaml[:general]['header_menus'].nil?\n i = 0\n @yaml[:general]['header_menus'].each do |header_menu|\n if header_menu[0] == params[:org_name]\n idx = i\n break\n end\n i += 1\n end\n end\n\n if idx.nil?\n @yaml[:general]['header_menus'] << entry\n else\n @yaml[:general]['header_menus'][idx] = entry\n end\n\n ApplicationHelper.save_config_yaml(@yaml)\n\n render(:partial => 'ajax_header_menu', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "def create_cluster(params, request, session)\n if not allowed_for_superuser(session)\n return 403, 'Permission denied'\n end\n if set_corosync_conf(params, request, session)\n cluster_start(params, request, session)\n else\n return \"Failed\"\n end\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " it \"delegates to #with\" do\n session.should_receive(:with).with(new_options).and_return(new_session)\n session.new(new_options)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def set_workflow\n Log.add_info(request, params.inspect)\n\n @item = Item.find(params[:id])\n\n orders_hash = params.dup\n orders_hash.reject! { |key, value|\n key.index(/order-/) != 0\n }\n orders_hash.sort_by { |key, value|\n key.split('-').last.to_i\n }\n\n orders = []\n orders_hash.each do |key, value|\n\n orders << '|' + value.split(',').join('|') + '|'\n end\n @item.workflow.update_attribute(:users, orders.join(','))\n\n render(:partial => 'ajax_item_workflow', :layout => false)\n\n rescue => evar\n Log.add_error(request, evar)\n\n render(:partial => 'ajax_item_workflow', :layout => false)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def legal?(string)\n /\\A\\h{24}\\Z/ === string.to_s\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def next\n now = Time.new.to_i\n\n counter = @mutex.synchronize do\n last_timestamp, @last_timestamp = @last_timestamp, now\n\n if last_timestamp == now\n @counter += 1\n else\n @counter = 0\n end\n end\n\n generate(now, counter)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def connected?\n !!@sock\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def add_toy\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n if @login_user.nil?\n render(:text => '0')\n return\n end\n\n toy = Toy.new\n\n toy.user_id = @login_user.id\n toy.xtype = params[:xtype]\n toy.target_id = params[:target_id].to_i\n toy.x, toy.y = DesktopsHelper.find_empty_block(@login_user)\n toy.save!\n\n render(:text => toy.id.to_s)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"executes the operation on a slave node\" do\n session.should_receive(:socket_for).with(:read).\n and_return(socket)\n socket.should_receive(:execute).with(operation)\n\n session.execute(operation)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it \"sanitizes crazy params\" do\n cl = subject.build_command_line(\"true\", modified_params)\n expect(cl).to eq \"true --user bob --pass P@\\\\$sw0\\\\^\\\\&\\\\ \\\\|\\\\<\\\\>/-\\\\+\\\\*d\\\\% --db --desc=Some\\\\ Description --symkey --symkey-dash pkg1 some\\\\ pkg --pool 123 --pool 456\"\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " def edit\n load_object\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " it 'authenticates successfuly' do\n basic_authorize 'a', 'b'\n\n get '/'\n\n assert_equal 200, last_response.status\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": " def self.load_yaml\n return if @yaml_loaded\n return unless defined?(gem)\n\n test_syck = ENV['TEST_SYCK']\n\n # Only Ruby 1.8 and 1.9 have syck\n test_syck = false unless /^1\\./ =~ RUBY_VERSION\n\n unless test_syck\n begin\n gem 'psych', '>= 2.0.0'\n rescue Gem::LoadError\n # It's OK if the user does not have the psych gem installed. We will\n # attempt to require the stdlib version\n end\n\n begin\n # Try requiring the gem version *or* stdlib version of psych.\n require 'psych'\n rescue ::LoadError\n # If we can't load psych, thats fine, go on.\n else\n # If 'yaml' has already been required, then we have to\n # be sure to switch it over to the newly loaded psych.\n if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != \"psych\"\n YAML::ENGINE.yamler = \"psych\"\n end\n\n require 'rubygems/psych_additions'\n require 'rubygems/psych_tree'\n end\n end\n\n require 'yaml'\n require 'rubygems/safe_yaml'\n\n # If we're supposed to be using syck, then we may have to force\n # activate it via the YAML::ENGINE API.\n if test_syck and defined?(YAML::ENGINE)\n YAML::ENGINE.yamler = \"syck\" unless YAML::ENGINE.syck?\n end\n\n # Now that we're sure some kind of yaml library is loaded, pull\n # in our hack to deal with Syck's DefaultKey ugliness.\n require 'rubygems/syck_hack'\n\n @yaml_loaded = true\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-502", "cwe_name": "Deserialization of Untrusted Data", "description": "The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.", "url": "https://cwe.mitre.org/data/definitions/502.html", "label_name": "safe"} {"code": " it \"returns a hex string representation of the id\" do\n Moped::BSON::ObjectId.new(bytes).to_s.should eq \"4e4d66343b39b68407000001\"\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " it 'should return the right response for a single option' do\n DiscoursePoll::Poll.vote(\n user,\n post.id,\n DiscoursePoll::DEFAULT_POLL_NAME,\n [option_a, option_b]\n )\n\n get \"/polls/voters.json\", params: {\n post_id: post.id,\n poll_name: DiscoursePoll::DEFAULT_POLL_NAME,\n option_id: option_b\n }\n\n expect(response.status).to eq(200)\n\n poll = response.parsed_body[\"voters\"]\n\n expect(poll[option_a]).to eq(nil)\n\n option = poll[option_b]\n\n expect(option.length).to eq(1)\n expect(option.first[\"id\"]).to eq(user.id)\n expect(option.first[\"username\"]).to eq(user.username)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " def self.get_my_folder(user_id)\n\n return Folder.where(\"(owner_id=#{user_id}) and (xtype='#{Folder::XTYPE_USER}')\").first\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def status_reply\n reply = Moped::Protocol::Reply.new\n reply.count = 1\n reply.documents = [status]\n reply\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " it \"drops the index\" do\n indexes.create name: 1\n indexes.drop(name: 1).should be_true\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def self.get_from_name(user_name)\n\n SqlHelper.validate_token([user_name])\n\n begin\n user = User.where(\"name='#{user_name}'\").first\n rescue => evar\n Log.add_error(nil, evar)\n end\n\n return user\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def escape_entry(entry)\n entry.gsub(/(\\*|\\[|\\]|\\{|\\}|\\?)/, \"\\\\\\\\\\\\1\")\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " it \"can set password\" do\n user = InviteRedeemer.new(invite: invite, email: invite.email, username: username, name: name, password: password).redeem\n expect(user).to have_password\n expect(user.confirm_password?(password)).to eq(true)\n expect(user.approved).to eq(true)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " def self.update_for(user_id, fiscal_year, num)\n\n if num <= 0\n PaidHoliday.destroy_all(['user_id=? and year=?', user_id, fiscal_year])\n return\n end\n\n paid_holiday = PaidHoliday.get_for(user_id, fiscal_year)\n\n if paid_holiday.nil?\n paid_holiday = PaidHoliday.new\n paid_holiday.user_id = user_id\n paid_holiday.year = fiscal_year\n paid_holiday.num = num\n paid_holiday.save!\n else\n paid_holiday.update_attribute(:num, num)\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"to json\" do\n expect(user.to_json).to eql([user.name].to_json)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "safe"} {"code": " def deliver!(mail)\n envelope_from = mail.return_path || mail.sender || mail.from_addrs.first\n return_path = \"-f \" + '\"' + envelope_from.escape_for_shell + '\"' if envelope_from\n\n arguments = [settings[:arguments], return_path].compact.join(\" \")\n\n self.class.call(settings[:location], arguments, mail.destinations.collect(&:shellescape).join(\" \"), mail)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def connect\n connection.connect ip_address, port, timeout\n @down_at = nil\n\n refresh\n rescue Timeout::Error\n raise Errors::ConnectionFailure, \"Timed out connection to Mongo on #{address}\"\n rescue Errno::ECONNREFUSED\n raise Errors::ConnectionFailure, \"Could not connect to Mongo on #{address}\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " it \"handles Symbol keys with underscore\" do\n cl = subject.build(\"true\", :abc_def => \"ghi\")\n expect(cl).to eq \"true --abc-def ghi\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " it \"should reject non-whitelist extensions even if a valid extension is present\" do\n @request.stubs(:request_extensions).returns [{ \"oid\" => \"peach\",\n \"value\" => \"meh\",\n \"critical\" => false },\n { \"oid\" => \"subjectAltName\",\n \"value\" => \"DNS:foo\",\n \"critical\" => true }]\n expect { @ca.check_internal_signing_policies(@name, @request, false) }.to raise_error(\n Puppet::SSL::CertificateAuthority::CertificateSigningError,\n /request extensions that are not permitted/\n )\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def add_statistics_group\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n current_id = params[:current_id]\n\n unless params[:thetisBoxSelKeeper].nil?\n group_id = params[:thetisBoxSelKeeper].split(':').last\n end\n SqlHelper.validate_token([current_id, group_id])\n\n if group_id.blank?\n @group_ids = Research.get_statistics_groups\n render(:partial => 'ajax_statistics_groups', :layout => false)\n return\n end\n\n unless current_id.blank?\n Research.delete_statistics_group(current_id)\n end\n\n @group_ids = Research.add_statistics_group(group_id)\n\n render(:partial => 'ajax_statistics_groups', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.get_next_revision(user_id, source_id)\n\n SqlHelper.validate_token([user_id, source_id])\n\n copied_items = Item.where(\"user_id=#{user_id} and source_id=#{source_id}\").order('created_at DESC').to_a\n\n rev = 0\n copied_items.each do |item|\n rev_ary = item.title.scan(/[#](\\d\\d\\d)$/)\n next if rev_ary.nil?\n\n rev = rev_ary.first.to_a.first.to_i\n break\n end\n\n return ('#' + sprintf('%03d', rev+1))\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"adds the node to the master set\" do\n cluster.sync_server server\n cluster.primaries.should include server\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " it \"creates a hostgroup with a parent parameter\" do\n post :create, {\"hostgroup\" => {\"name\"=>\"test_it\", \"parent_id\" => @base.id, :realm_id => realms(:myrealm).id,\n :group_parameters_attributes => {\"0\" => {:name => \"x\", :value =>\"overridden\", :_destroy => \"\"}}}}, set_session_user\n assert_redirected_to hostgroups_url\n hostgroup = Hostgroup.where(:name => \"test_it\").last\n assert_equal \"overridden\", hostgroup.parameters[\"x\"]\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " def destroy\n Log.add_info(request, params.inspect)\n\n begin\n OfficialTitle.destroy(params[:id])\n rescue => evar\n Log.add_error(nil, evar)\n end\n\n @group_id = params[:group_id]\n\n if @group_id.nil? or @group_id.empty?\n @group_id = '0' # '0' for ROOT\n end\n\n render(:partial => 'groups/ajax_group_official_titles', :layout => false)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"raises an AuthenticationFailure exception\" do\n session.login \"invalid-user\", \"invalid-password\"\n\n lambda do\n session.command(ping: 1)\n end.should raise_exception(Moped::Errors::AuthenticationFailure)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " it \"should pass the provided CSR as the CSR\" do\n Puppet::SSL::CertificateFactory.expects(:build).with do |*args|\n args[1].should == @request\n end.returns \"my real cert\"\n @ca.sign(@name, :ca, @request)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "safe"} {"code": " def timeline\n state = params[:state].to_s\n if %w(Collapsed Expanded).include?(state)\n if (model_type = params[:type].to_s).present?\n if %w(comment email).include?(model_type)\n model = model_type.camelize.constantize\n item = model.find(params[:id])\n item.update_attribute(:state, state)\n end\n else\n comments, emails = params[:id].split(\"+\")\n Comment.where(:id => comments.split(',')).update_all(:state => state) unless comments.blank?\n Email.where(:id => emails.split(',')).update_all(:state => state) unless emails.blank?\n end\n end\n\n render :nothing => true\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"syncs the cluster\" do\n cluster.should_receive(:sync) do\n cluster.servers << server\n end\n cluster.socket_for :write\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def merge(server)\n previous = servers.find { |other| other == server }\n primary = server.primary?\n secondary = server.secondary?\n\n if previous\n previous.merge(server)\n else\n servers << server\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " it \"returns a session\" do\n session.with(new_options).should be_a Moped::Session\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "def get_cman_version()\n begin\n stdout, stderror, retval = run_cmd(\n PCSAuth.getSuperuserSession, CMAN_TOOL, \"-V\"\n )\n rescue\n stdout = []\n end\n if retval == 0\n match = /(\\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": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def unfolded_header\n @unfolded_header ||= unfold(raw_source)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-93", "cwe_name": "Improper Neutralization of CRLF Sequences ('CRLF Injection')", "description": "The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.", "url": "https://cwe.mitre.org/data/definitions/93.html", "label_name": "vulnerable"} {"code": " def update(database, collection, selector, change, options = {})\n process Protocol::Update.new(database, collection, selector, change, options)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def new\n\n @item = Item.new\n if params[:folder_id].nil? or params[:folder_id].empty?\n my_folder = @login_user.get_my_folder\n if my_folder.nil?\n @item.folder_id = 0\n else\n @item.folder_id = my_folder.id\n end\n else\n @item.folder_id = params[:folder_id].to_i\n end\n @item.xtype= Item::XTYPE_INFO\n @item.layout = 'C'\n\n render(:action => 'edit')\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " it \"marks the node as down\" do\n node.ensure_connected {} rescue nil\n node.should be_down\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " it \"with Pathname command and params\" do\n cl = subject.build_command_line(Pathname.new(\"/usr/bin/ruby\"), \"-v\" => nil)\n expect(cl).to eq \"/usr/bin/ruby -v\"\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " def test_destroy\n domain = Domain.first\n domain.hosts.clear\n domain.hostgroups.clear\n domain.subnets.clear\n delete :destroy, {:id => domain}, set_session_user\n assert_redirected_to domains_url\n assert !Domain.exists?(domain.id)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " def save_conf\n Log.add_info(request, '') # Not to show passwords.\n\n return unless request.post?\n\n unless @login_user.nil?\n\n if @login_user.paintmail.nil?\n paintmail = Paintmail.new(params.require(:paintmail).permit(Paintmail::PERMIT_BASE))\n paintmail.user_id = @login_user.id\n paintmail.save\n else\n @login_user.paintmail.update_attributes(params.require(:paintmail).permit(Paintmail::PERMIT_BASE))\n end\n end\n\n render(:text => '')\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"runs the command on the current database\" do\n session.with(database: \"moped_test_2\") do |session|\n session.command(dbStats: 1)[\"db\"].should eq \"moped_test_2\"\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " it \"does not remove multiple '../' at the beginning\" do\n expect(File.cleanpath('../../A/B')).to eq '../../A/B'\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": " def quote_column_name(name) #:nodoc:\n @quoted_column_names[name] ||= \"`#{name.to_s.gsub('`', '``')}`\"\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def self.get_my_folder(user_id)\n\n SqlHelper.validate_token([user_id])\n return Folder.where(\"(owner_id=#{user_id.to_i}) and (xtype='#{Folder::XTYPE_USER}')\").first\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "def update_cluster_settings(params, request, session)\n properties = params['config']\n to_update = []\n current = getAllSettings(session)\n\n # We need to be able to set cluster properties also from older version GUI.\n # This code handles proper processing of checkboxes.\n # === backward compatibility layer start ===\n params['hidden'].each { |prop, val|\n next if prop == 'hidden_input'\n unless properties.include?(prop)\n properties[prop] = val\n to_update << prop\n end\n }\n # === backward compatibility layer end ===\n\n properties.each { |prop, val|\n val.strip!\n if not current.include?(prop) and val != '' # add\n to_update << prop\n elsif current.include?(prop) and val == '' # remove\n to_update << prop\n elsif current.include?(prop) and current[prop] != val # update\n to_update << prop\n end\n }\n\n if to_update.count { |x| x.downcase == 'enable-acl' } > 0\n if not allowed_for_local_cluster(session, Permissions::GRANT)\n return 403, 'Permission denied'\n end\n end\n if to_update.count { |x| x.downcase != 'enable-acl' } > 0\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n end\n\n if to_update.empty?\n $logger.info('No properties to update')\n else\n cmd_args = []\n to_update.each { |prop|\n cmd_args << \"#{prop.downcase}=#{properties[prop]}\"\n }\n stdout, stderr, retval = run_cmd(session, PCS, 'property', 'set', *cmd_args)\n if retval != 0\n return [400, stderr.join('').gsub(', (use --force to override)', '')]\n end\n end\n return [200, \"Update Successful\"]\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " it 'fails when local logins is disabled' do\n SiteSetting.enable_local_logins = false\n\n get \"/session/email-login/#{email_token.token}\"\n\n expect(response.status).to eq(500)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": " def initialize_copy(_)\n @connection = nil\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def apply(operations)\n operations.inject(self) do |builder, (name, argument)|\n if argument == true || argument == nil\n builder.send(name)\n elsif argument.is_a?(Array)\n builder.send(name, *argument)\n elsif argument.is_a?(Hash)\n builder.send(name, **argument)\n else\n builder.send(name, argument)\n end\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " def test_jail_instances_should_have_limited_methods\n expected = [\"class\", \"inspect\", \"method_missing\", \"methods\", \"respond_to?\", \"respond_to_missing?\", \"to_jail\", \"to_s\", \"instance_variable_get\"]\n expected.delete('respond_to_missing?') if RUBY_VERSION > '1.9.3' # respond_to_missing? is private in rubies above 1.9.3\n objects.each do |object|\n assert_equal expected.sort, reject_pretty_methods(object.to_jail.methods.map(&:to_s).sort)\n end\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " it \"sets the query operation's skip field\" do\n query.skip(5)\n query.operation.skip.should eq 5\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def close_clients_for(server)\n Moped.logger.debug \"replica_set: closing open clients on #{server.port}\"\n\n @clients.reject! do |client|\n port = client.addr(false)[1]\n\n if port == server.port\n client.close\n true\n else\n false\n end\n end\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def self.get_for(user_id, date_s)\n\n SqlHelper.validate_token([user_id, date_s])\n begin\n con = \"(user_id=#{user_id}) and (date='#{date_s}')\"\n return Timecard.where(con).first\n rescue\n end\n return nil\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def get_group_users\n Log.add_info(request, params.inspect)\n\n @group_id = nil\n if !params[:thetisBoxSelKeeper].nil?\n @group_id = params[:thetisBoxSelKeeper].split(':').last\n elsif !params[:group_id].blank?\n @group_id = params[:group_id]\n end\n SqlHelper.validate_token([@group_id])\n\n submit_url = url_for(:controller => 'desktop', :action => 'get_group_users')\n render(:partial => 'common/select_users', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url})\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def quote_column_name(name) #:nodoc:\n %Q(\"#{name.to_s.gsub('\"', '\"\"')}\")", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"upserts the record matching selector with change\" do\n query.should_receive(:update).with(change, [:upsert])\n query.upsert change\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " def edit\n Log.add_info(request, params.inspect)\n\n @group_id = params[:group_id]\n official_title_id = params[:id]\n SqlHelper.validate_token([@group_id, official_title_id])\n\n unless official_title_id.blank?\n @official_title = OfficialTitle.find(official_title_id)\n end\n\n render(:partial => 'ajax_official_title_form', :layout => (!request.xhr?))\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " it \"should use the rest terminus when the 'puppet' URI scheme is used and a host name is present\" do\n uri = \"puppet://myhost/fakemod/my/file\"\n\n # It appears that the mocking somehow interferes with the caching subsystem.\n # This mock somehow causes another terminus to get generated.\n term = @indirection.terminus(:rest)\n @indirection.stubs(:terminus).with(:rest).returns term\n term.expects(:find)\n @indirection.find(uri)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " it \"should reject a wildcard subjectAltName\" do\n @request.stubs(:subject_alt_names).returns ['DNS:foo', 'DNS:*.bar']\n expect { @ca.sign(@name, true) }.to raise_error(\n Puppet::SSL::CertificateAuthority::CertificateSigningError,\n /subjectAltName contains a wildcard/\n )\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-264", "cwe_name": "Permissions, Privileges, and Access Controls", "description": "Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.", "url": "https://cwe.mitre.org/data/definitions/264.html", "label_name": "vulnerable"} {"code": " it \"should redeem the invite if invited by staff\" do\n SiteSetting.must_approve_users = true\n inviter = invite.invited_by\n inviter.admin = true\n user = invite_redeemer.redeem\n invite.reload\n\n expect(user.name).to eq(name)\n expect(user.username).to eq(username)\n expect(user.invited_by).to eq(inviter)\n expect(inviter.notifications.count).to eq(1)\n expect(user.approved).to eq(true)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " def authorized?(request)\n origin_host = request.get_header(\"HTTP_HOST\")\n forwarded_host = request.x_forwarded_host&.split(/,\\s?/)&.last\n\n @permissions.allows?(origin_host) && (forwarded_host.blank? || @permissions.allows?(forwarded_host))\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-601", "cwe_name": "URL Redirection to Untrusted Site ('Open Redirect')", "description": "A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.", "url": "https://cwe.mitre.org/data/definitions/601.html", "label_name": "safe"} {"code": " def self.from(stream)\n header = stream.read 512\n empty = (header == \"\\0\" * 512)\n\n fields = header.unpack UNPACK_FORMAT\n\n new :name => fields.shift,\n :mode => fields.shift.oct,\n :uid => fields.shift.oct,\n :gid => fields.shift.oct,\n :size => fields.shift.oct,\n :mtime => fields.shift.oct,\n :checksum => fields.shift.oct,\n :typeflag => fields.shift,\n :linkname => fields.shift,\n :magic => fields.shift,\n :version => fields.shift.oct,\n :uname => fields.shift,\n :gname => fields.shift,\n :devmajor => fields.shift.oct,\n :devminor => fields.shift.oct,\n :prefix => fields.shift,\n\n :empty => empty\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-835", "cwe_name": "Loop with Unreachable Exit Condition ('Infinite Loop')", "description": "The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.", "url": "https://cwe.mitre.org/data/definitions/835.html", "label_name": "vulnerable"} {"code": " def logging(operations)\n instrument_start = (logger = Moped.logger) && logger.debug? && Time.new\n yield\n ensure\n log_operations(logger, operations, Time.new - instrument_start) if instrument_start && !$!\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def drop\n command dropDatabase: 1\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": " def down!\n @down_at = Time.new\n\n disconnect\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "safe"} {"code": " def distinct(key)\n result = collection.database.command(\n distinct: collection.name,\n key: key.to_s,\n query: selector\n )\n\n result[\"values\"]\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": " def delete_attachment\n Log.add_info(request, '') # Not to show passwords.\n\n return unless request.post?\n\n target_user = nil\n\n user_id = params[:user_id]\n zeptair_id = params[:zeptair_id]\n attachment_id = params[:attachment_id]\n SqlHelper.validate_token([user_id, zeptair_id, attachment_id])\n\n unless user_id.blank?\n if @login_user.admin?(User::AUTH_ZEPTAIR) or @login_user.id.to_s == user_id.to_s\n target_user = User.find(user_id)\n end\n end\n\n unless zeptair_id.blank?\n\n target_user = User.where(\"zeptair_id=#{zeptair_id}\").first\n\n unless @login_user.admin?(User::AUTH_ZEPTAIR) or @login_user.id == target_user.id\n target_user = nil\n end\n end\n\n if target_user.nil?\n if attachment_id.blank?\n query\n unless @post_items.nil?\n @post_items.each do |post_item|\n post_item.attachments_without_content.each do |attach|\n attach.destroy\n end\n post_item.update_attribute(:updated_at, Time.now)\n end\n end\n\n else\n attach = Attachment.find(attachment_id)\n\n item = Item.find(attach.item_id)\n\n if !@login_user.admin?(User::AUTH_ZEPTAIR) and item.user_id != @login_user.id\n raise t('msg.need_to_be_owner')\n end\n\n if item.xtype != Item::XTYPE_ZEPTAIR_POST\n raise t('msg.system_error')\n end\n\n attach.destroy\n\n item.update_attribute(:updated_at, Time.now)\n end\n else\n\n post_item = ZeptairPostHelper.get_item_for(target_user)\n post_item.attachments_without_content.each do |attach|\n attach.destroy\n end\n post_item.update_attribute(:updated_at, Time.now)\n end\n\n render(:text => t('msg.delete_success'))\n\n rescue => evar\n Log.add_error(request, evar)\n render(:text => 'ERROR:' + t('msg.system_error'))\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def initialize(locale, key, options = nil)\n @key, @locale, @options = key, locale, options.dup || {}\n options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) }\n end\n\n def html_message\n key = CGI.escape_html titleize(keys.last)\n path = CGI.escape_html keys.join('.')\n %(#{key})\n end\n\n def keys\n @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys|\n keys << 'no key' if keys.size < 2\n end\n end\n\n def message\n \"translation missing: #{keys.join('.')}\"\n end\n alias :to_s :message\n\n def to_exception\n MissingTranslationData.new(locale, key, options)\n end\n\n protected\n\n # TODO : remove when #html_message is removed\n def titleize(key)\n key.to_s.gsub('_', ' ').gsub(/\\b('?[a-z])/) { $1.capitalize }\n end\n end\n\n include Base\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "def node_restart(params, request, session)\n if params[:name]\n code, response = send_request_with_token(\n session, params[:name], 'node_restart', true\n )\n else\n if not allowed_for_local_cluster(session, Permissions::WRITE)\n return 403, 'Permission denied'\n end\n $logger.info \"Restarting Node\"\n output = `/sbin/reboot`\n $logger.debug output\n return output\n end\nend", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-384", "cwe_name": "Session Fixation", "description": "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.", "url": "https://cwe.mitre.org/data/definitions/384.html", "label_name": "vulnerable"} {"code": " def seed\n # Authorisation is disabled usually when run from a rake db:* task\n User.current = FactoryGirl.build(:user, :admin => true)\n load File.expand_path('../../../../db/seeds.rb', __FILE__)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": " def build_actions(actions, guardian, args)\n return unless pending?\n\n if guardian.can_approve?(target) || args[:approved_by_invite]\n actions.add(:approve_user) do |a|\n a.icon = 'user-plus'\n a.label = \"reviewables.actions.approve_user.title\"\n end\n end\n\n delete_user_actions(actions, require_reject_reason: !is_a_suspect_user?)\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " def save\n Log.add_info(request, params.inspect)\n\n return unless request.post?\n\n unless params[:attach_file].nil?\n attach_attrs = { :file => params[:attach_file] }\n params.delete(:attach_file)\n end\n\n @mail_account = MailAccount.find(params[:mail_account_id])\n if @mail_account.user_id != @login_user.id\n flash[:notice] = 'ERROR:' + t('msg.need_to_be_owner')\n render(:partial => 'common/flash_notice', :layout => false)\n return\n end\n\n @email = SendMailsHelper.get_mail_to_send(@login_user, @mail_account, params)\n\n begin\n @email.save!\n\n unless attach_attrs.nil?\n attach_attrs[:email_id] = @email.id\n attach_attrs[:xorder] = 0\n @email.mail_attachments << MailAttachment.create(attach_attrs)\n @email.save! # To recalcurate size\n end\n\n if THETIS_MAIL_LIMIT_NUM_PER_ACCOUNT > 0\n Email.trim(@login_user.id, @mail_account.id, THETIS_MAIL_LIMIT_NUM_PER_ACCOUNT)\n end\n if THETIS_MAIL_CAPACITY_MB_PER_ACCOUNT > 0\n Email.trim_by_capacity(@login_user.id, @mail_account.id, @mail_account.get_capacity_mb)\n end\n # flash[:notice] = t('msg.save_success')\n rescue => evar\n logger.fatal(evar.to_s)\n if evar.to_s.starts_with?('ERROR:')\n flash[:notice] = evar.to_s\n else\n flash[:notice] = 'ERROR:' + t('msg.system_error') + '
    ' + evar.to_s\n end\n end\n\n render(:partial => 'ajax_mail_content', :layout => false)\n end", "label": 1, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": " def check_import(mode, address_names) #, address_emails\n\n err_msgs = []\n\n # Existing Addresss\n unless self.id.nil? or self.id == 0 or self.id == ''\n if mode == 'add'\n err_msgs << I18n.t('address.import.dont_specify_id')\n else\n begin\n org_address = Address.find(self.id)\n rescue\n end\n if org_address.nil?\n err_msgs << I18n.t('address.import.not_found')\n end\n end\n end\n\n # Requierd\n if self.name.nil? or self.name.empty?\n err_msgs << Address.human_attribute_name('name') + I18n.t('msg.is_required')\n end\n\n # Groups\n unless self.groups.nil? or self.groups.empty?\n\n if (/^|([0-9]+|)+$/ =~ self.groups) == 0\n\n self.get_groups_a.each do |group_id|\n group = Group.find_by_id(group_id)\n if group.nil?\n err_msgs << I18n.t('address.import.not_valid_groups') + ': '+group_id.to_s\n break\n end\n end\n else\n err_msgs << I18n.t('address.import.invalid_groups_format')\n end\n end\n\n # Teams\n unless self.teams.nil? or self.teams.empty?\n\n if (/^|([0-9]+|)+$/ =~ self.teams) == 0\n\n self.get_teams_a.each do |team_id|\n team = Team.find_by_id(team_id)\n if team.nil?\n err_msgs << I18n.t('address.import.not_valid_teams') + ': '+team_id.to_s\n break\n end\n end\n\n else\n err_msgs << I18n.t('address.import.invalid_teams_format')\n end\n end\n\n return err_msgs\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": " def dup\n session = super\n session.instance_variable_set :@options, options.dup\n\n if defined? @current_database\n session.send(:remove_instance_variable, :@current_database)\n end\n\n session\n end", "label": 0, "programming_language": "Ruby", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "\t\taction := args[2].(func(child argoappv1.ResourceNode, appName string) bool)\n\t\tappName := \"\"\n\t\tif res, ok := data.namespacedResources[key]; ok {\n\t\t\tappName = res.AppName\n\t\t}\n\t\t_ = action(argoappv1.ResourceNode{ResourceRef: argoappv1.ResourceRef{Kind: key.Kind, Group: key.Group, Namespace: key.Namespace, Name: key.Name}}, appName)\n\t}).Return(nil)", "label": 1, "programming_language": "Go", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "func getUids() (int, int, int) {\n\tvar ruid, euid, suid C.uid_t\n\tC.getresuid(&ruid, &euid, &suid)\n\treturn int(ruid), int(euid), int(suid)\n}", "label": 1, "programming_language": "Go", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "func (*DeleteLeaderboardRecordRequest) Descriptor() ([]byte, []int) {\n\treturn file_console_proto_rawDescGZIP(), []int{20}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (m *Aproto3) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowProto3\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Aproto3: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Aproto3: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field B\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowProto3\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthProto3\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthProto3\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.B = string(dAtA[iNdEx:postIndex])\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipProto3(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthProto3\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthProto3\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (m *OneofTest) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowIssue322\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: OneofTest: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: OneofTest: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field I\", wireType)\n\t\t\t}\n\t\t\tvar v int32\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowIssue322\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= int32(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Union = &OneofTest_I{v}\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipIssue322(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue322\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue322\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (m *MockAuthorizeRequester) SetSession(arg0 fosite.Session) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SetSession\", arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockAuthorizeCodeStrategyMockRecorder) AuthorizeCodeSignature(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AuthorizeCodeSignature\", reflect.TypeOf((*MockAuthorizeCodeStrategy)(nil).AuthorizeCodeSignature), arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (a *Actions) UpdateProject(updater func(project *v1alpha1.AppProject)) *Actions {\n\tproj, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Get(context.TODO(), a.context.name, v1.GetOptions{})\n\trequire.NoError(a.context.t, err)\n\tupdater(proj)\n\t_, err = fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Update(context.TODO(), proj, v1.UpdateOptions{})\n\trequire.NoError(a.context.t, err)\n\treturn a\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "func (c *Client) Update() (data.TargetFiles, error) {\n\tif err := c.UpdateRoots(); err != nil {\n\t\tif _, ok := err.(verify.ErrExpired); ok {\n\t\t\t// For backward compatibility, we wrap the ErrExpired inside\n\t\t\t// ErrDecodeFailed.\n\t\t\treturn nil, ErrDecodeFailed{\"root.json\", err}\n\t\t}\n\t\treturn nil, err\n\t}\n\n\t// Get timestamp.json, extract snapshot.json file meta and save the\n\t// timestamp.json locally\n\ttimestampJSON, err := c.downloadMetaUnsafe(\"timestamp.json\", defaultTimestampDownloadLimit)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsnapshotMeta, err := c.decodeTimestamp(timestampJSON)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := c.local.SetMeta(\"timestamp.json\", timestampJSON); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get snapshot.json, then extract file metas.\n\t// root.json meta should not be stored in the snapshot, if it is,\n\t// the root will be checked, re-downloaded\n\tsnapshotJSON, err := c.downloadMetaFromTimestamp(\"snapshot.json\", snapshotMeta)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsnapshotMetas, err := c.decodeSnapshot(snapshotJSON)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Save the snapshot.json\n\tif err := c.local.SetMeta(\"snapshot.json\", snapshotJSON); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// If we don't have the targets.json, download it, determine updated\n\t// targets and save targets.json in local storage\n\tvar updatedTargets data.TargetFiles\n\ttargetsMeta := snapshotMetas[\"targets.json\"]\n\tif !c.hasMetaFromSnapshot(\"targets.json\", targetsMeta) {\n\t\ttargetsJSON, err := c.downloadMetaFromSnapshot(\"targets.json\", targetsMeta)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tupdatedTargets, err = c.decodeTargets(targetsJSON)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := c.local.SetMeta(\"targets.json\", targetsJSON); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn updatedTargets, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-354", "cwe_name": "Improper Validation of Integrity Check Value", "description": "The software does not validate or incorrectly validates the integrity check values or \"checksums\" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission.", "url": "https://cwe.mitre.org/data/definitions/354.html", "label_name": "vulnerable"} {"code": "func (mr *MockAuthorizeRequesterMockRecorder) SetSession(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetSession\", reflect.TypeOf((*MockAuthorizeRequester)(nil).SetSession), arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func TestToFromBig(t *testing.T) {\n\tfor i, test := range toFromBigTests {\n\t\tn, _ := new(big.Int).SetString(test, 16)\n\t\tvar x p224FieldElement\n\t\tp224FromBig(&x, n)\n\t\tm := p224ToBig(&x)\n\t\tif n.Cmp(m) != 0 {\n\t\t\tt.Errorf(\"#%d: %x != %x\", i, n, m)\n\t\t}\n\t\tq := p224AlternativeToBig(&x)\n\t\tif n.Cmp(q) != 0 {\n\t\t\tt.Errorf(\"#%d: %x != %x (alternative)\", i, n, m)\n\t\t}\n\t}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-682", "cwe_name": "Incorrect Calculation", "description": "The software performs a calculation that generates incorrect or unintended results that are later used in security-critical decisions or resource management.", "url": "https://cwe.mitre.org/data/definitions/682.html", "label_name": "vulnerable"} {"code": "func TestDetectDuplicates(t *testing.T) {\n\tplugs := []*Plugin{\n\t\tmockPlugin(\"foo\"),\n\t\tmockPlugin(\"bar\"),\n\t}\n\tif err := detectDuplicates(plugs); err != nil {\n\t\tt.Error(\"no duplicates in the first set\")\n\t}\n\tplugs = append(plugs, mockPlugin(\"foo\"))\n\tif err := detectDuplicates(plugs); err == nil {\n\t\tt.Error(\"duplicates in the second set\")\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-74", "cwe_name": "Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')", "description": "The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/74.html", "label_name": "safe"} {"code": "func TestReadRequest_Bad(t *testing.T) {\n\tfor _, tt := range badRequestTests {\n\t\tgot, err := ReadRequest(bufio.NewReader(bytes.NewReader(tt.req)))\n\t\tif err == nil {\n\t\t\tall, err := ioutil.ReadAll(got.Body)\n\t\t\tt.Errorf(\"%s: got unexpected request = %#v\\n Body = %q, %v\", tt.name, got, all, err)\n\t\t}\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "func (m *MockResourceOwnerPasswordCredentialsGrantStorage) DeleteRefreshTokenSession(arg0 context.Context, arg1 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"DeleteRefreshTokenSession\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockRequesterMockRecorder) SetRequestedScopes(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetRequestedScopes\", reflect.TypeOf((*MockRequester)(nil).SetRequestedScopes), arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockAccessTokenStrategyMockRecorder) ValidateAccessToken(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ValidateAccessToken\", reflect.TypeOf((*MockAccessTokenStrategy)(nil).ValidateAccessToken), arg0, arg1, arg2)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockAuthorizeRequesterMockRecorder) GetGrantedScopes() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetGrantedScopes\", reflect.TypeOf((*MockAuthorizeRequester)(nil).GetGrantedScopes))\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func TestRedactURL(t *testing.T) {\n\tcases := []struct {\n\t\tname string\n\t\turl *url.URL\n\t\twant string\n\t}{\n\t\t{\n\t\t\tname: \"non-blank Password\",\n\t\t\turl: &url.URL{\n\t\t\t\tScheme: \"http\",\n\t\t\t\tHost: \"host.tld\",\n\t\t\t\tPath: \"this:that\",\n\t\t\t\tUser: url.UserPassword(\"user\", \"password\"),\n\t\t\t},\n\t\t\twant: \"http://user:xxxxx@host.tld/this:that\",\n\t\t},\n\t\t{\n\t\t\tname: \"blank Password\",\n\t\t\turl: &url.URL{\n\t\t\t\tScheme: \"http\",\n\t\t\t\tHost: \"host.tld\",\n\t\t\t\tPath: \"this:that\",\n\t\t\t\tUser: url.User(\"user\"),\n\t\t\t},\n\t\t\twant: \"http://user@host.tld/this:that\",\n\t\t},\n\t\t{\n\t\t\tname: \"nil User\",\n\t\t\turl: &url.URL{\n\t\t\t\tScheme: \"http\",\n\t\t\t\tHost: \"host.tld\",\n\t\t\t\tPath: \"this:that\",\n\t\t\t\tUser: url.UserPassword(\"\", \"password\"),\n\t\t\t},\n\t\t\twant: \"http://:xxxxx@host.tld/this:that\",\n\t\t},\n\t\t{\n\t\t\tname: \"blank Username, blank Password\",\n\t\t\turl: &url.URL{\n\t\t\t\tScheme: \"http\",\n\t\t\t\tHost: \"host.tld\",\n\t\t\t\tPath: \"this:that\",\n\t\t\t},\n\t\t\twant: \"http://host.tld/this:that\",\n\t\t},\n\t\t{\n\t\t\tname: \"empty URL\",\n\t\t\turl: &url.URL{},\n\t\t\twant: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"nil URL\",\n\t\t\turl: nil,\n\t\t\twant: \"\",\n\t\t},\n\t}\n\n\tfor _, tt := range cases {\n\t\tt := t\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tif g, w := RedactURL(tt.url), tt.want; g != w {\n\t\t\t\tt.Fatalf(\"got: %q\\nwant: %q\", g, w)\n\t\t\t}\n\t\t})\n\t}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-532", "cwe_name": "Insertion of Sensitive Information into Log File", "description": "Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.", "url": "https://cwe.mitre.org/data/definitions/532.html", "label_name": "vulnerable"} {"code": "func reqBytes(req string) []byte {\n\treturn []byte(strings.Replace(strings.TrimSpace(req), \"\\n\", \"\\r\\n\", -1) + \"\\r\\n\\r\\n\")\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-444", "cwe_name": "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')", "description": "The product acts as an intermediary HTTP agent\n (such as a proxy or firewall) in the data flow between two\n entities such as a client and server, but it does not\n interpret malformed HTTP requests or responses in ways that\n are consistent with how the messages will be processed by\n those entities that are at the ultimate destination.", "url": "https://cwe.mitre.org/data/definitions/444.html", "label_name": "safe"} {"code": "func (x *RuntimeInfo_ModuleInfo) ProtoReflect() protoreflect.Message {\n\tmi := &file_console_proto_msgTypes[50]\n\tif protoimpl.UnsafeEnabled && x != nil {\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tif ms.LoadMessageInfo() == nil {\n\t\t\tms.StoreMessageInfo(mi)\n\t\t}\n\t\treturn ms\n\t}\n\treturn mi.MessageOf(x)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (x *DeleteLeaderboardRecordRequest) Reset() {\n\t*x = DeleteLeaderboardRecordRequest{}\n\tif protoimpl.UnsafeEnabled {\n\t\tmi := &file_console_proto_msgTypes[20]\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tms.StoreMessageInfo(mi)\n\t}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func Test_buildRouteConfiguration(t *testing.T) {\n\tb := New(\"local-grpc\", \"local-http\", nil, nil)\n\tvirtualHosts := make([]*envoy_config_route_v3.VirtualHost, 10)\n\trouteConfig, err := b.buildRouteConfiguration(\"test-route-configuration\", virtualHosts)\n\trequire.NoError(t, err)\n\tassert.Equal(t, \"test-route-configuration\", routeConfig.GetName())\n\tassert.Equal(t, virtualHosts, routeConfig.GetVirtualHosts())\n\tassert.False(t, routeConfig.GetValidateClusters().GetValue())\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-200", "cwe_name": "Exposure of Sensitive Information to an Unauthorized Actor", "description": "The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.", "url": "https://cwe.mitre.org/data/definitions/200.html", "label_name": "vulnerable"} {"code": "func (m *MockTokenRevocationStorage) CreateAccessTokenSession(arg0 context.Context, arg1 string, arg2 fosite.Requester) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CreateAccessTokenSession\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (m *ContainsNestedMap) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowTheproto3\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: ContainsNestedMap: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: ContainsNestedMap: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipTheproto3(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthTheproto3\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthTheproto3\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (x *WriteStorageObjectRequest) ProtoReflect() protoreflect.Message {\n\tmi := &file_console_proto_msgTypes[44]\n\tif protoimpl.UnsafeEnabled && x != nil {\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tif ms.LoadMessageInfo() == nil {\n\t\t\tms.StoreMessageInfo(mi)\n\t\t}\n\t\treturn ms\n\t}\n\treturn mi.MessageOf(x)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func TestP256Mult(t *testing.T) {\n\tp256 := P256()\n\tp256Generic := p256.Params()\n\n\tfor i, e := range p224BaseMultTests {\n\t\tx, _ := new(big.Int).SetString(e.x, 16)\n\t\ty, _ := new(big.Int).SetString(e.y, 16)\n\t\tk, _ := new(big.Int).SetString(e.k, 10)\n\n\t\txx, yy := p256.ScalarMult(x, y, k.Bytes())\n\t\txx2, yy2 := p256Generic.ScalarMult(x, y, k.Bytes())\n\t\tif xx.Cmp(xx2) != 0 || yy.Cmp(yy2) != 0 {\n\t\t\tt.Errorf(\"#%d: got (%x, %x), want (%x, %x)\", i, xx, yy, xx2, yy2)\n\t\t}\n\t\tif testing.Short() && i > 5 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i, e := range p256MultTests {\n\t\tx, _ := new(big.Int).SetString(e.xIn, 16)\n\t\ty, _ := new(big.Int).SetString(e.yIn, 16)\n\t\tk, _ := new(big.Int).SetString(e.k, 16)\n\t\texpectedX, _ := new(big.Int).SetString(e.xOut, 16)\n\t\texpectedY, _ := new(big.Int).SetString(e.yOut, 16)\n\n\t\txx, yy := p256.ScalarMult(x, y, k.Bytes())\n\t\tif xx.Cmp(expectedX) != 0 || yy.Cmp(expectedY) != 0 {\n\t\t\tt.Errorf(\"#%d: got (%x, %x), want (%x, %x)\", i, xx, yy, expectedX, expectedY)\n\t\t}\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-682", "cwe_name": "Incorrect Calculation", "description": "The software performs a calculation that generates incorrect or unintended results that are later used in security-critical decisions or resource management.", "url": "https://cwe.mitre.org/data/definitions/682.html", "label_name": "safe"} {"code": "func (AppModule) ConsensusVersion() uint64 { return 1 }", "label": 0, "programming_language": "Go", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "vulnerable"} {"code": "func (s *ConsoleServer) Authenticate(ctx context.Context, in *console.AuthenticateRequest) (*console.ConsoleSession, error) {\n\trole := console.UserRole_USER_ROLE_UNKNOWN\n\tvar uname string\n\tvar email string\n\tswitch in.Username {\n\tcase s.config.GetConsole().Username:\n\t\tif in.Password == s.config.GetConsole().Password {\n\t\t\trole = console.UserRole_USER_ROLE_ADMIN\n\t\t\tuname = in.Username\n\t\t}\n\tdefault:\n\t\tvar err error\n\t\tuname, email, role, err = s.lookupConsoleUser(ctx, in.Username, in.Password)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif role == console.UserRole_USER_ROLE_UNKNOWN {\n\t\treturn nil, status.Error(codes.Unauthenticated, \"Invalid credentials.\")\n\t}\n\n\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, &ConsoleTokenClaims{\n\t\tExpiresAt: time.Now().UTC().Add(time.Duration(s.config.GetConsole().TokenExpirySec) * time.Second).Unix(),\n\t\tUsername: uname,\n\t\tEmail: email,\n\t\tRole: role,\n\t\tCookie: s.cookie,\n\t})\n\tkey := []byte(s.config.GetConsole().SigningKey)\n\tsignedToken, _ := token.SignedString(key)\n\treturn &console.ConsoleSession{Token: signedToken}, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "\t\tpatches.forEach(patch => {\n\t\t\tconst {path, op} = patch\n\n\t\t\tlet base: any = draft\n\t\t\tfor (let i = 0; i < path.length - 1; i++) {\n\t\t\t\tconst parentType = getArchtype(base)\n\t\t\t\tconst p = path[i]\n\t\t\t\t// See #738, avoid prototype pollution\n\t\t\t\tif (\n\t\t\t\t\t(parentType === Archtype.Object || parentType === Archtype.Array) &&\n\t\t\t\t\t(p === \"__proto__\" || p === \"constructor\")\n\t\t\t\t)\n\t\t\t\t\tdie(24)\n\t\t\t\tif (typeof base === \"function\" && p === \"prototype\") die(24)\n\t\t\t\tbase = get(base, p)\n\t\t\t\tif (typeof base !== \"object\") die(15, path.join(\"/\"))\n\t\t\t}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-843", "cwe_name": "Access of Resource Using Incompatible Type ('Type Confusion')", "description": "The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.", "url": "https://cwe.mitre.org/data/definitions/843.html", "label_name": "vulnerable"} {"code": "func (mr *MockAuthorizeCodeStrategyMockRecorder) GenerateAuthorizeCode(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GenerateAuthorizeCode\", reflect.TypeOf((*MockAuthorizeCodeStrategy)(nil).GenerateAuthorizeCode), arg0, arg1)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockAccessTokenStorageMockRecorder) CreateAccessTokenSession(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"CreateAccessTokenSession\", reflect.TypeOf((*MockAccessTokenStorage)(nil).CreateAccessTokenSession), arg0, arg1, arg2)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func getClaimsFromToken(token string) (map[string]interface{}, error) {", "label": 1, "programming_language": "Go", "cwe_id": "CWE-285", "cwe_name": "Improper Authorization", "description": "The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/285.html", "label_name": "safe"} {"code": "func (m *Wilson) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowCastvalue\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Wilson: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Wilson: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Int64\", wireType)\n\t\t\t}\n\t\t\tvar v int64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowCastvalue\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= int64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Int64 = &v\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipCastvalue(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthCastvalue\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthCastvalue\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (mr *MockResourceOwnerPasswordCredentialsGrantStorageMockRecorder) GetAccessTokenSession(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetAccessTokenSession\", reflect.TypeOf((*MockResourceOwnerPasswordCredentialsGrantStorage)(nil).GetAccessTokenSession), arg0, arg1, arg2)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (f *flight4TestMockFlightConn) handleQueuedPackets(context.Context) error { return nil }", "label": 1, "programming_language": "Go", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "safe"} {"code": "func newContainerInit(t initType, pipe *os.File, consoleSocket *os.File, fifoFd, logFd int, mountFds []int) (initer, error) {\n\tvar config *initConfig\n\tif err := json.NewDecoder(pipe).Decode(&config); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := populateProcessEnvironment(config.Env); err != nil {\n\t\treturn nil, err\n\t}\n\tswitch t {\n\tcase initSetns:\n\t\t// mountFds must be nil in this case. We don't mount while doing runc exec.\n\t\tif mountFds != nil {\n\t\t\treturn nil, errors.New(\"mountFds must be nil. Can't mount while doing runc exec.\")\n\t\t}\n\n\t\treturn &linuxSetnsInit{\n\t\t\tpipe: pipe,\n\t\t\tconsoleSocket: consoleSocket,\n\t\t\tconfig: config,\n\t\t\tlogFd: logFd,\n\t\t}, nil\n\tcase initStandard:\n\t\treturn &linuxStandardInit{\n\t\t\tpipe: pipe,\n\t\t\tconsoleSocket: consoleSocket,\n\t\t\tparentPid: unix.Getppid(),\n\t\t\tconfig: config,\n\t\t\tfifoFd: fifoFd,\n\t\t\tlogFd: logFd,\n\t\t\tmountFds: mountFds,\n\t\t}, nil\n\t}\n\treturn nil, fmt.Errorf(\"unknown init type %q\", t)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "func (m *MockAccessResponder) SetExtra(arg0 string, arg1 interface{}) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SetExtra\", arg0, arg1)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (x *DeleteGroupUserRequest) ProtoReflect() protoreflect.Message {\n\tmi := &file_console_proto_msgTypes[18]\n\tif protoimpl.UnsafeEnabled && x != nil {\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tif ms.LoadMessageInfo() == nil {\n\t\t\tms.StoreMessageInfo(mi)\n\t\t}\n\t\treturn ms\n\t}\n\treturn mi.MessageOf(x)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (m *FloatingPoint) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowMapsproto2\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: FloatingPoint: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: FloatingPoint: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 1 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field F\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tif (iNdEx + 8) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tv = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))\n\t\t\tiNdEx += 8\n\t\t\tv2 := float64(math.Float64frombits(v))\n\t\t\tm.F = &v2\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipMapsproto2(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthMapsproto2\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthMapsproto2\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (f *Fosite) WriteAccessResponse(rw http.ResponseWriter, requester AccessRequester, responder AccessResponder) {\n\trw.Header().Set(\"Cache-Control\", \"no-store\")\n\trw.Header().Set(\"Pragma\", \"no-cache\")\n\n\tjs, err := json.Marshal(responder.ToMap())\n\tif err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trw.Header().Set(\"Content-Type\", \"application/json;charset=UTF-8\")\n\n\trw.WriteHeader(http.StatusOK)\n\trw.Write(js)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "func NewReader(src io.Reader, size int64, md5Hex, sha256Hex string) (*Reader, error) {\n\tif _, ok := src.(*Reader); ok {\n\t\treturn nil, errNestedReader\n\t}\n\n\tsha256sum, err := hex.DecodeString(sha256Hex)\n\tif err != nil {\n\t\treturn nil, SHA256Mismatch{}\n\t}\n\n\tmd5sum, err := hex.DecodeString(md5Hex)\n\tif err != nil {\n\t\treturn nil, BadDigest{}\n\t}\n\n\tvar sha256Hash hash.Hash\n\tif len(sha256sum) != 0 {\n\t\tsha256Hash = sha256.New()\n\t}\n\tif size >= 0 {\n\t\tsrc = io.LimitReader(src, size)\n\t}\n\treturn &Reader{\n\t\tmd5sum: md5sum,\n\t\tsha256sum: sha256sum,\n\t\tsrc: src,\n\t\tsize: size,\n\t\tmd5Hash: md5.New(),\n\t\tsha256Hash: sha256Hash,\n\t}, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-774", "cwe_name": "Allocation of File Descriptors or Handles Without Limits or Throttling", "description": "The software allocates file descriptors or handles on behalf of an actor without imposing any restrictions on how many descriptors can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/774.html", "label_name": "safe"} {"code": "func TestClientAuthNone(t *testing.T) {\n\tuser := \"testuser\"\n\tserverConfig := &ServerConfig{\n\t\tNoClientAuth: true,\n\t}\n\tserverConfig.AddHostKey(testSigners[\"rsa\"])\n\n\tclientConfig := &ClientConfig{\n\t\tUser: user,\n\t\tHostKeyCallback: InsecureIgnoreHostKey(),\n\t}\n\n\tc1, c2, err := netPipe()\n\tif err != nil {\n\t\tt.Fatalf(\"netPipe: %v\", err)\n\t}\n\tdefer c1.Close()\n\tdefer c2.Close()\n\n\tgo NewClientConn(c2, \"\", clientConfig)\n\tserverConn, err := newServer(c1, serverConfig)\n\tif err != nil {\n\t\tt.Fatalf(\"newServer: %v\", err)\n\t}\n\tif serverConn.User() != user {\n\t\tt.Fatalf(\"server: got %q, want %q\", serverConn.User(), user)\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "func migrationsSqlShared11Sql() (*asset, error) {\n\tbytes, err := migrationsSqlShared11SqlBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := bindataFileInfo{name: \"migrations/sql/shared/11.sql\", size: 363, mode: os.FileMode(420), modTime: time.Unix(1585817202, 0)}\n\ta := &asset{bytes: bytes, info: info}\n\treturn a, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-294", "cwe_name": "Authentication Bypass by Capture-replay", "description": "A capture-replay flaw exists when the design of the software makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).", "url": "https://cwe.mitre.org/data/definitions/294.html", "label_name": "safe"} {"code": "static bool anal_fcn_data (RCore *core, const char *input) {\n\tRAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_ANY);\n\tif (fcn) {\n\t\tint i;\n\t\tbool gap = false;\n\t\tut64 gap_addr = UT64_MAX;\n\t\tut32 fcn_size = r_anal_function_size_from_entry (fcn);\n\t\tchar *bitmap = calloc (1, fcn_size);\n\t\tif (bitmap) {\n\t\t\tRAnalBlock *b;\n\t\t\tRListIter *iter;\n\t\t\tr_list_foreach (fcn->bbs, iter, b) {\n\t\t\t\tint f = b->addr - fcn->addr;\n\t\t\t\tint t = R_MIN (f + b->size, fcn_size);\n\t\t\t\tif (f >= 0) {\n\t\t\t\t\twhile (f < t) {\n\t\t\t\t\t\tbitmap[f++] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (i = 0; i < fcn_size; i++) {\n\t\t\tut64 here = fcn->addr + i;\n\t\t\tif (bitmap && bitmap[i]) {\n\t\t\t\tif (gap) {\n\t\t\t\t\tr_cons_printf (\"Cd %d @ 0x%08\"PFMT64x\"\\n\", here - gap_addr, gap_addr);\n\t\t\t\t\tgap = false;\n\t\t\t\t}\n\t\t\t\tgap_addr = UT64_MAX;\n\t\t\t} else {\n\t\t\t\tif (!gap) {\n\t\t\t\t\tgap = true;\n\t\t\t\t\tgap_addr = here;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (gap) {\n\t\t\tr_cons_printf (\"Cd %d @ 0x%08\"PFMT64x\"\\n\", fcn->addr + fcn_size - gap_addr, gap_addr);\n\t\t}\n\t\tfree (bitmap);\n\t\treturn true;\n\t}\n\treturn false;\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-908", "cwe_name": "Use of Uninitialized Resource", "description": "The software uses or accesses a resource that has not been initialized.", "url": "https://cwe.mitre.org/data/definitions/908.html", "label_name": "safe"} {"code": "func (svc *Service) ModifyGlobalScheduledQueries(ctx context.Context, id uint, query fleet.ScheduledQueryPayload) (*fleet.ScheduledQuery, error) {\n\tif err := svc.authz.Authorize(ctx, &fleet.Pack{}, fleet.ActionWrite); err != nil {\n\t\treturn nil, err\n\t}\n\n\tgp, err := svc.ds.EnsureGlobalPack(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tquery.PackID = ptr.Uint(gp.ID)\n\n\treturn svc.ModifyScheduledQuery(ctx, id, query)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": "func (m *Subby) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowOne\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Subby: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Subby: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Sub\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.Sub = string(dAtA[iNdEx:postIndex])\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipOne(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func MkdirSecure(pth string) (err error) {\n\terr = os.MkdirAll(pth, 0755)\n\tif err != nil {\n\t\terr = &errortypes.WriteError{\n\t\t\terrors.Wrap(err, \"utils: Failed to create directory\"),\n\t\t}\n\t\treturn\n\t}\n\n\terr = acl.Apply(\n\t\tpth,\n\t\ttrue,\n\t\tfalse,\n\t\tacl.GrantName(windows.GENERIC_ALL, \"CREATOR OWNER\"),\n\t\tacl.GrantName(windows.GENERIC_ALL, \"SYSTEM\"),\n\t\tacl.GrantName(windows.GENERIC_ALL, \"Administrators\"),\n\t)\n\tif err != nil {\n\t\terr = &errortypes.WriteError{\n\t\t\terrors.Wrap(err, \"utils: Failed to acl directory\"),\n\t\t}\n\t\treturn\n\t}\n\n\treturn\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "vulnerable"} {"code": "func (m *MockCoreStrategy) AuthorizeCodeSignature(arg0 string) string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AuthorizeCodeSignature\", arg0)\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func validateWebhook(actor *db.User, l macaron.Locale, w *db.Webhook) (field, msg string, ok bool) {\n\tif !actor.IsAdmin {\n\t\t// \ud83d\udea8 SECURITY: Local addresses must not be allowed by non-admins to prevent SSRF,\n\t\t// see https://github.com/gogs/gogs/issues/5366 for details.\n\t\tpayloadURL, err := url.Parse(w.URL)\n\t\tif err != nil {\n\t\t\treturn \"PayloadURL\", l.Tr(\"repo.settings.webhook.err_cannot_parse_payload_url\", err), false\n\t\t}\n\n\t\tif netutil.IsLocalHostname(payloadURL.Hostname(), conf.Security.LocalNetworkAllowlist) {\n\t\t\treturn \"PayloadURL\", l.Tr(\"repo.settings.webhook.err_cannot_use_local_addresses\"), false\n\t\t}\n\t}\n\n\treturn \"\", \"\", true\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "func migrationsSqlCockroach10Sql() (*asset, error) {\n\tbytes, err := migrationsSqlCockroach10SqlBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := bindataFileInfo{name: \"migrations/sql/cockroach/10.sql\", size: 173, mode: os.FileMode(420), modTime: time.Unix(1585815362, 0)}\n\ta := &asset{bytes: bytes, info: info}\n\treturn a, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-294", "cwe_name": "Authentication Bypass by Capture-replay", "description": "A capture-replay flaw exists when the design of the software makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).", "url": "https://cwe.mitre.org/data/definitions/294.html", "label_name": "safe"} {"code": "func (mr *MockAccessRequesterMockRecorder) GetRequestedAudience() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetRequestedAudience\", reflect.TypeOf((*MockAccessRequester)(nil).GetRequestedAudience))\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (*Provider) Render(ctx *provider.Context, config, data string) string {\n\tunsafe := blackfriday.Run([]byte(data))\n\n\tsafe := bluemonday.UGCPolicy().SanitizeBytes(unsafe)\n\n\treturn string(safe)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "func padBuffer(buffer []byte, blockSize int) []byte {\n\tmissing := blockSize - (len(buffer) % blockSize)\n\tret, out := resize(buffer, uint64(len(buffer))+uint64(missing))\n\tpadding := bytes.Repeat([]byte{byte(missing)}, missing)\n\tcopy(out, padding)\n\treturn ret\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "func (m *NestedDefinition_NestedMessage_NestedNestedMsg) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: NestedNestedMsg: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: NestedNestedMsg: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 10:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field NestedNestedField1\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\ts := string(dAtA[iNdEx:postIndex])\n\t\t\tm.NestedNestedField1 = &s\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipThetest(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (m *MockAccessResponder) SetTokenType(arg0 string) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SetTokenType\", arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func TestCheckValid(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tobjLayer, fsDir, err := prepareFS()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer os.RemoveAll(fsDir)\n\tif err = newTestConfig(globalMinioDefaultRegion, objLayer); err != nil {\n\t\tt.Fatalf(\"unable initialize config file, %s\", err)\n\t}\n\n\tnewAllSubsystems()\n\n\tinitConfigSubsystem(ctx, objLayer)\n\n\tglobalIAMSys.Init(ctx, objLayer, globalEtcdClient, globalNotificationSys, 2*time.Second)\n\n\treq, err := newTestRequest(http.MethodGet, \"http://example.com:9000/bucket/object\", 0, nil)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif err = signRequestV4(req, globalActiveCred.AccessKey, globalActiveCred.SecretKey); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t_, owner, s3Err := checkKeyValid(req, globalActiveCred.AccessKey)\n\tif s3Err != ErrNone {\n\t\tt.Fatalf(\"Unexpected failure with %v\", errorCodes.ToAPIErr(s3Err))\n\t}\n\n\tif !owner {\n\t\tt.Fatalf(\"Expected owner to be 'true', found %t\", owner)\n\t}\n\n\t_, _, s3Err = checkKeyValid(req, \"does-not-exist\")\n\tif s3Err != ErrInvalidAccessKeyID {\n\t\tt.Fatalf(\"Expected error 'ErrInvalidAccessKeyID', found %v\", s3Err)\n\t}\n\n\tucreds, err := auth.CreateCredentials(\"myuser1\", \"mypassword1\")\n\tif err != nil {\n\t\tt.Fatalf(\"unable create credential, %s\", err)\n\t}\n\n\tglobalIAMSys.CreateUser(ctx, ucreds.AccessKey, madmin.AddOrUpdateUserReq{\n\t\tSecretKey: ucreds.SecretKey,\n\t\tStatus: madmin.AccountEnabled,\n\t})\n\n\t_, owner, s3Err = checkKeyValid(req, ucreds.AccessKey)\n\tif s3Err != ErrNone {\n\t\tt.Fatalf(\"Unexpected failure with %v\", errorCodes.ToAPIErr(s3Err))\n\t}\n\n\tif owner {\n\t\tt.Fatalf(\"Expected owner to be 'false', found %t\", owner)\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "func (svc *Service) GetGlobalScheduledQueries(ctx context.Context, opts fleet.ListOptions) ([]*fleet.ScheduledQuery, error) {\n\tif err := svc.authz.Authorize(ctx, &fleet.Pack{}, fleet.ActionRead); err != nil {\n\t\treturn nil, err\n\t}\n\n\tgp, err := svc.ds.EnsureGlobalPack(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn svc.ds.ListScheduledQueriesInPackWithStats(ctx, gp.ID, opts)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": "func CleanSQL(t *testing.T, db *sqlx.DB) {\n\tt.Logf(\"Cleaning up database: %s\", db.DriverName())\n\tfor _, tb := range []string{\n\t\t\"hydra_oauth2_access\",\n\t\t\"hydra_oauth2_refresh\",\n\t\t\"hydra_oauth2_code\",\n\t\t\"hydra_oauth2_oidc\",\n\t\t\"hydra_oauth2_pkce\",\n\t\t\"hydra_oauth2_consent_request_handled\",\n\t\t\"hydra_oauth2_consent_request\",\n\t\t\"hydra_oauth2_authentication_request_handled\",\n\t\t\"hydra_oauth2_authentication_request\",\n\t\t\"hydra_oauth2_authentication_session\",\n\t\t\"hydra_oauth2_obfuscated_authentication_session\",\n\t\t\"hydra_oauth2_logout_request\",\n\t\t\"hydra_oauth2_jti_blacklist\",\n\t\t\"hydra_jwk\",\n\t\t\"hydra_client\",\n\t\t// Migrations\n\t\t\"hydra_oauth2_authentication_consent_migration\",\n\t\t\"hydra_client_migration\",\n\t\t\"hydra_oauth2_migration\",\n\t\t\"hydra_jwk_migration\",\n\t} {\n\t\tif _, err := db.Exec(\"DROP TABLE IF EXISTS \" + tb); err != nil {\n\t\t\tt.Logf(`Unable to clean up table \"%s\": %s`, tb, err)\n\t\t}\n\t}\n\tt.Logf(\"Successfully cleaned up database: %s\", db.DriverName())\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-294", "cwe_name": "Authentication Bypass by Capture-replay", "description": "A capture-replay flaw exists when the design of the software makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).", "url": "https://cwe.mitre.org/data/definitions/294.html", "label_name": "safe"} {"code": "func (mr *MockAccessTokenStorageMockRecorder) GetAccessTokenSession(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetAccessTokenSession\", reflect.TypeOf((*MockAccessTokenStorage)(nil).GetAccessTokenSession), arg0, arg1, arg2)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (mr *MockAccessRequesterMockRecorder) GetGrantTypes() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetGrantTypes\", reflect.TypeOf((*MockAccessRequester)(nil).GetGrantTypes))\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (m *MockAccessRequester) GrantScope(arg0 string) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"GrantScope\", arg0)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (p *BinaryProtocol) ReadBinary() ([]byte, error) {\n\tsize, e := p.ReadI32()\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\tif size < 0 {\n\t\treturn nil, invalidDataLength\n\t}\n\tif uint64(size) > p.trans.RemainingBytes() || p.trans.RemainingBytes() == UnknownRemaining {\n\t\treturn nil, invalidDataLength\n\t}\n\n\tisize := int(size)\n\tbuf := make([]byte, isize)\n\t_, err := io.ReadFull(p.trans, buf)\n\treturn buf, NewProtocolException(err)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": "func (f MigrateRepo) ParseRemoteAddr(user *db.User) (string, error) {\n\tremoteAddr := strings.TrimSpace(f.CloneAddr)\n\n\t// Remote address can be HTTP/HTTPS/Git URL or local path.\n\tif strings.HasPrefix(remoteAddr, \"http://\") ||\n\t\tstrings.HasPrefix(remoteAddr, \"https://\") ||\n\t\tstrings.HasPrefix(remoteAddr, \"git://\") {\n\t\tu, err := url.Parse(remoteAddr)\n\t\tif err != nil {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsURLError: true}\n\t\t}\n\n\t\tif netutil.IsLocalHostname(u.Hostname(), conf.Security.LocalNetworkAllowlist) {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsURLError: true}\n\t\t}\n\n\t\tif len(f.AuthUsername)+len(f.AuthPassword) > 0 {\n\t\t\tu.User = url.UserPassword(f.AuthUsername, f.AuthPassword)\n\t\t}\n\t\t// To prevent CRLF injection in git protocol, see https://github.com/gogs/gogs/issues/6413\n\t\tif u.Scheme == \"git\" && (strings.Contains(remoteAddr, \"%0d\") || strings.Contains(remoteAddr, \"%0a\")) {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsURLError: true}\n\t\t}\n\t\tremoteAddr = u.String()\n\t} else if !user.CanImportLocal() {\n\t\treturn \"\", db.ErrInvalidCloneAddr{IsPermissionDenied: true}\n\t} else if !com.IsDir(remoteAddr) {\n\t\treturn \"\", db.ErrInvalidCloneAddr{IsInvalidPath: true}\n\t}\n\n\treturn remoteAddr, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": "\tclusterInfo.IterateHierarchy(key, func(resource *clustercache.Resource, namespaceResources map[kube.ResourceKey]*clustercache.Resource) bool {\n\t\treturn action(asResourceNode(resource), getApp(resource, namespaceResources))\n\t})", "label": 1, "programming_language": "Go", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "safe"} {"code": "func SanitizePath(path string) string {\n\treturn strings.TrimLeft(path, \"./\")\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "func (mr *MockTokenRevocationStorageMockRecorder) DeleteRefreshTokenSession(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DeleteRefreshTokenSession\", reflect.TypeOf((*MockTokenRevocationStorage)(nil).DeleteRefreshTokenSession), arg0, arg1)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (p *BinaryProtocol) ReadSetBegin() (elemType Type, size int, err error) {\n\tb, e := p.ReadByte()\n\tif e != nil {\n\t\terr = NewProtocolException(e)\n\t\treturn\n\t}\n\telemType = Type(b)\n\tsize32, e := p.ReadI32()\n\tif e != nil {\n\t\terr = NewProtocolException(e)\n\t\treturn\n\t}\n\tif size32 < 0 {\n\t\terr = invalidDataLength\n\t\treturn\n\t}\n\tif uint64(size32) > p.trans.RemainingBytes() || p.trans.RemainingBytes() == UnknownRemaining {\n\t\terr = invalidDataLength\n\t\treturn\n\t}\n\tsize = int(size32)\n\treturn elemType, size, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": "func (m *MockResourceOwnerPasswordCredentialsGrantStorage) GetRefreshTokenSession(arg0 context.Context, arg1 string, arg2 fosite.Session) (fosite.Requester, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRefreshTokenSession\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(fosite.Requester)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (m *CustomDash) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: CustomDash: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: CustomDash: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Value\", wireType)\n\t\t\t}\n\t\t\tvar byteLen int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tbyteLen |= int(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif byteLen < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tpostIndex := iNdEx + byteLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tvar v github_com_gogo_protobuf_test_custom_dash_type.Bytes\n\t\t\tm.Value = &v\n\t\t\tif err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipThetest(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func GetIssues(uid, rid, pid, mid int64, page int, isClosed bool, labelIds, sortType string) ([]Issue, error) {\n\tsess := x.Limit(20, (page-1)*20)\n\n\tif rid > 0 {\n\t\tsess.Where(\"repo_id=?\", rid).And(\"is_closed=?\", isClosed)\n\t} else {\n\t\tsess.Where(\"is_closed=?\", isClosed)\n\t}\n\n\tif uid > 0 {\n\t\tsess.And(\"assignee_id=?\", uid)\n\t} else if pid > 0 {\n\t\tsess.And(\"poster_id=?\", pid)\n\t}\n\n\tif mid > 0 {\n\t\tsess.And(\"milestone_id=?\", mid)\n\t}\n\n\tif len(labelIds) > 0 {\n\t\tfor _, label := range strings.Split(labelIds, \",\") {\n\t\t\tsess.And(\"label_ids like '%$\" + label + \"|%'\")\n\t\t}\n\t}\n\n\tswitch sortType {\n\tcase \"oldest\":\n\t\tsess.Asc(\"created\")\n\tcase \"recentupdate\":\n\t\tsess.Desc(\"updated\")\n\tcase \"leastupdate\":\n\t\tsess.Asc(\"updated\")\n\tcase \"mostcomment\":\n\t\tsess.Desc(\"num_comments\")\n\tcase \"leastcomment\":\n\t\tsess.Asc(\"num_comments\")\n\tcase \"priority\":\n\t\tsess.Desc(\"priority\")\n\tdefault:\n\t\tsess.Desc(\"created\")\n\t}\n\n\tvar issues []Issue\n\terr := sess.Find(&issues)\n\treturn issues, err\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "vulnerable"} {"code": "func NewFositeMemoryStore(\n\tr InternalRegistry,\n\tc Configuration,\n) *FositeMemoryStore {\n\treturn &FositeMemoryStore{\n\t\tAuthorizeCodes: make(map[string]authorizeCode),\n\t\tIDSessions: make(map[string]fosite.Requester),\n\t\tAccessTokens: make(map[string]fosite.Requester),\n\t\tPKCES: make(map[string]fosite.Requester),\n\t\tRefreshTokens: make(map[string]fosite.Requester),\n\t\tBlacklistedJTIs: make(map[string]time.Time),\n\n\t\tc: c,\n\t\tr: r,\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-294", "cwe_name": "Authentication Bypass by Capture-replay", "description": "A capture-replay flaw exists when the design of the software makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).", "url": "https://cwe.mitre.org/data/definitions/294.html", "label_name": "safe"} {"code": "func CreatePayloadFromItems(items []types.MessageItem, title string, colors [types.MessageLevelCount]uint, omitted int) (WebhookPayload, error) {\n\n\tmetaCount := 1\n\tif omitted < 1 && len(title) < 1 {\n\t\tmetaCount = 0\n\t}\n\titemCount := util.Min(9, len(items))\n\n\tembeds := make([]embedItem, metaCount, itemCount+metaCount)\n\n\tfor _, item := range items {\n\n\t\tcolor := uint(0)\n\t\tif item.Level >= types.Unknown && int(item.Level) < len(colors) {\n\t\t\tcolor = colors[item.Level]\n\t\t}\n\n\t\tei := embedItem{\n\t\t\tContent: item.Text,\n\t\t\tColor: color,\n\t\t}\n\n\t\tif item.Level != types.Unknown {\n\t\t\tei.Footer = &embedFooter{\n\t\t\t\tText: item.Level.String(),\n\t\t\t}\n\t\t}\n\n\t\tif !item.Timestamp.IsZero() {\n\t\t\tei.Timestamp = item.Timestamp.UTC().Format(time.RFC3339)\n\t\t}\n\n\t\tembeds = append(embeds, ei)\n\t}\n\n\tembeds[0].Title = title\n\tif omitted > 0 {\n\t\tembeds[0].Footer = &embedFooter{\n\t\t\tText: fmt.Sprintf(\"... (%v character(s) where omitted)\", omitted),\n\t\t}\n\t}\n\n\treturn WebhookPayload{\n\t\tEmbeds: embeds,\n\t}, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": "func TestInitialAllocationListBinaryProtocol(t *testing.T) {\n\tvar m MyTestStruct\n\td := NewDeserializer()\n\tf := NewBinaryProtocolFactoryDefault()\n\td.Protocol = f.GetProtocol(d.Transport)\n\t// attempts to allocate a list with 1.8B elements for a 20 byte message\n\tdata := []byte(\"\\n\\x10\\rO\\t6\\x03\\n\\n\\n\\x10\\x0f\\n\\tslice\\x00\")\n\terr := d.Read(&m, data)\n\tif err == nil {\n\t\tt.Fatalf(\"Parsed invalid message correctly\")\n\t} else if !strings.Contains(err.Error(), \"Invalid data length\") {\n\t\tt.Fatalf(\"Failed for reason besides Invalid data length\")\n\t}\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "safe"} {"code": "func (m *Unrecognized) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Unrecognized: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Unrecognized: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field1\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowThetest\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\ts := string(dAtA[iNdEx:postIndex])\n\t\t\tm.Field1 = &s\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipThetest(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthThetest\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) {\n\tpluginID := web.Params(c.Req)[\":pluginId\"]\n\tplugin, exists := hs.pluginStore.Plugin(c.Req.Context(), pluginID)\n\tif !exists {\n\t\tc.JsonApiErr(404, \"Plugin not found\", nil)\n\t\treturn\n\t}\n\n\trequestedFile := filepath.Clean(web.Params(c.Req)[\"*\"])\n\tpluginFilePath := filepath.Join(plugin.PluginDir, requestedFile)\n\n\tif !plugin.IncludedInSignature(requestedFile) {\n\t\ths.log.Warn(\"Access to requested plugin file will be forbidden in upcoming Grafana versions as the file \"+\n\t\t\t\"is not included in the plugin signature\", \"file\", requestedFile)\n\t}\n\n\t// It's safe to ignore gosec warning G304 since we already clean the requested file path and subsequently\n\t// use this with a prefix of the plugin's directory, which is set during plugin loading\n\t// nolint:gosec\n\tf, err := os.Open(pluginFilePath)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\tc.JsonApiErr(404, \"Plugin file not found\", err)\n\t\t\treturn\n\t\t}\n\t\tc.JsonApiErr(500, \"Could not open plugin file\", err)\n\t\treturn\n\t}\n\tdefer func() {\n\t\tif err := f.Close(); err != nil {\n\t\t\ths.log.Error(\"Failed to close file\", \"err\", err)\n\t\t}\n\t}()\n\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\tc.JsonApiErr(500, \"Plugin file exists but could not open\", err)\n\t\treturn\n\t}\n\n\tif hs.Cfg.Env == setting.Dev {\n\t\tc.Resp.Header().Set(\"Cache-Control\", \"max-age=0, must-revalidate, no-cache\")\n\t} else {\n\t\tc.Resp.Header().Set(\"Cache-Control\", \"public, max-age=3600\")\n\t}\n\n\thttp.ServeContent(c.Resp, c.Req, pluginFilePath, fi.ModTime(), f)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "vulnerable"} {"code": "func (m *MockAccessRequester) GetRequestedScopes() fosite.Arguments {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRequestedScopes\")\n\tret0, _ := ret[0].(fosite.Arguments)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func Skip(self Protocol, fieldType Type, maxDepth int) (err error) {\n\n\tif maxDepth <= 0 {\n\t\treturn NewProtocolExceptionWithType(DEPTH_LIMIT, errors.New(\"Depth limit exceeded\"))\n\t}\n\n\tswitch fieldType {\n\tcase STOP:\n\t\treturn\n\tcase BOOL:\n\t\t_, err = self.ReadBool()\n\t\treturn\n\tcase BYTE:\n\t\t_, err = self.ReadByte()\n\t\treturn\n\tcase I16:\n\t\t_, err = self.ReadI16()\n\t\treturn\n\tcase I32:\n\t\t_, err = self.ReadI32()\n\t\treturn\n\tcase I64:\n\t\t_, err = self.ReadI64()\n\t\treturn\n\tcase DOUBLE:\n\t\t_, err = self.ReadDouble()\n\t\treturn\n\tcase FLOAT:\n\t\t_, err = self.ReadFloat()\n\t\treturn\n\tcase STRING:\n\t\t_, err = self.ReadString()\n\t\treturn\n\tcase STRUCT:\n\t\tif _, err = self.ReadStructBegin(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor {\n\t\t\t_, typeId, _, _ := self.ReadFieldBegin()\n\t\t\tif typeId == STOP {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\terr := Skip(self, typeId, maxDepth-1)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tself.ReadFieldEnd()\n\t\t}\n\t\treturn self.ReadStructEnd()\n\tcase MAP:\n\t\tkeyType, valueType, size, err := self.ReadMapBegin()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i := 0; i < size; i++ {\n\t\t\terr := Skip(self, keyType, maxDepth-1)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tself.Skip(valueType)\n\t\t}\n\t\treturn self.ReadMapEnd()\n\tcase SET:\n\t\telemType, size, err := self.ReadSetBegin()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i := 0; i < size; i++ {\n\t\t\terr := Skip(self, elemType, maxDepth-1)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn self.ReadSetEnd()\n\tcase LIST:\n\t\telemType, size, err := self.ReadListBegin()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i := 0; i < size; i++ {\n\t\t\terr := Skip(self, elemType, maxDepth-1)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn self.ReadListEnd()\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-755", "cwe_name": "Improper Handling of Exceptional Conditions", "description": "The software does not handle or incorrectly handles an exceptional condition.", "url": "https://cwe.mitre.org/data/definitions/755.html", "label_name": "vulnerable"} {"code": "func (m *MockHasher) Compare(arg0 context.Context, arg1, arg2 []byte) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Compare\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (s *ConsoleServer) Authenticate(ctx context.Context, in *console.AuthenticateRequest) (*console.ConsoleSession, error) {\n\trole := console.UserRole_USER_ROLE_UNKNOWN\n\tvar uname string\n\tvar email string\n\tvar id uuid.UUID\n\tswitch in.Username {\n\tcase s.config.GetConsole().Username:\n\t\tif in.Password == s.config.GetConsole().Password {\n\t\t\trole = console.UserRole_USER_ROLE_ADMIN\n\t\t\tuname = in.Username\n\t\t\tid = uuid.Nil\n\t\t}\n\tdefault:\n\t\tvar err error\n\t\tid, uname, email, role, err = s.lookupConsoleUser(ctx, in.Username, in.Password)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif role == console.UserRole_USER_ROLE_UNKNOWN {\n\t\treturn nil, status.Error(codes.Unauthenticated, \"Invalid credentials.\")\n\t}\n\n\texp := time.Now().UTC().Add(time.Duration(s.config.GetConsole().TokenExpirySec) * time.Second).Unix()\n\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, &ConsoleTokenClaims{\n\t\tExpiresAt: exp,\n\t\tID: id.String(),\n\t\tUsername: uname,\n\t\tEmail: email,\n\t\tRole: role,\n\t\tCookie: s.cookie,\n\t})\n\tkey := []byte(s.config.GetConsole().SigningKey)\n\tsignedToken, _ := token.SignedString(key)\n\n\ts.consoleSessionCache.Add(id, exp, signedToken, 0, \"\")\n\treturn &console.ConsoleSession{Token: signedToken}, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-307", "cwe_name": "Improper Restriction of Excessive Authentication Attempts", "description": "The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks.", "url": "https://cwe.mitre.org/data/definitions/307.html", "label_name": "vulnerable"} {"code": "func (x *ListGroupsRequest) ProtoReflect() protoreflect.Message {\n\tmi := &file_console_proto_msgTypes[27]\n\tif protoimpl.UnsafeEnabled && x != nil {\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tif ms.LoadMessageInfo() == nil {\n\t\t\tms.StoreMessageInfo(mi)\n\t\t}\n\t\treturn ms\n\t}\n\treturn mi.MessageOf(x)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (m *Foo) Unmarshal(dAtA []byte) error {\n\tvar hasFields [1]uint64\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowProto\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Foo: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Foo: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Bar\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowProto\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Bar = &v\n\t\t\thasFields[0] |= uint64(0x00000001)\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipProto(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthProto\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthProto\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\tif hasFields[0]&uint64(0x00000001) == 0 {\n\t\treturn github_com_gogo_protobuf_proto.NewRequiredNotSetError(\"bar\")\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": " return { name: sanitized, address: this.getReturnAddress() };\n },", "label": 1, "programming_language": "Go", "cwe_id": "CWE-287", "cwe_name": "Improper Authentication", "description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.", "url": "https://cwe.mitre.org/data/definitions/287.html", "label_name": "safe"} {"code": "func (*LeaderboardList) Descriptor() ([]byte, []int) {\n\treturn file_console_proto_rawDescGZIP(), []int{24}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (f MigrateRepo) ParseRemoteAddr(user *db.User) (string, error) {\n\tremoteAddr := strings.TrimSpace(f.CloneAddr)\n\n\t// Remote address can be HTTP/HTTPS/Git URL or local path.\n\tif strings.HasPrefix(remoteAddr, \"http://\") ||\n\t\tstrings.HasPrefix(remoteAddr, \"https://\") ||\n\t\tstrings.HasPrefix(remoteAddr, \"git://\") {\n\t\tu, err := url.Parse(remoteAddr)\n\t\tif err != nil {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsURLError: true}\n\t\t}\n\n\t\tif netutil.IsBlockedLocalHostname(u.Hostname(), conf.Security.LocalNetworkAllowlist) {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsBlockedLocalAddress: true}\n\t\t}\n\n\t\tif len(f.AuthUsername)+len(f.AuthPassword) > 0 {\n\t\t\tu.User = url.UserPassword(f.AuthUsername, f.AuthPassword)\n\t\t}\n\t\t// To prevent CRLF injection in git protocol, see https://github.com/gogs/gogs/issues/6413\n\t\tif u.Scheme == \"git\" && (strings.Contains(remoteAddr, \"%0d\") || strings.Contains(remoteAddr, \"%0a\")) {\n\t\t\treturn \"\", db.ErrInvalidCloneAddr{IsURLError: true}\n\t\t}\n\t\tremoteAddr = u.String()\n\t} else if !user.CanImportLocal() {\n\t\treturn \"\", db.ErrInvalidCloneAddr{IsPermissionDenied: true}\n\t} else if !com.IsDir(remoteAddr) {\n\t\treturn \"\", db.ErrInvalidCloneAddr{IsInvalidPath: true}\n\t}\n\n\treturn remoteAddr, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "func (r *siteResolver) UsageStatistics(ctx context.Context, args *struct {\n\tDays *int32\n\tWeeks *int32\n\tMonths *int32\n}) (*siteUsageStatisticsResolver, error) {\n\tif err := backend.CheckCurrentUserIsSiteAdmin(ctx, r.db); err != nil {\n\t\treturn nil, err\n\t}\n\n\topt := &usagestatsdeprecated.SiteUsageStatisticsOptions{}\n\tif args.Days != nil {\n\t\td := int(*args.Days)\n\t\topt.DayPeriods = &d\n\t}\n\tif args.Weeks != nil {\n\t\tw := int(*args.Weeks)\n\t\topt.WeekPeriods = &w\n\t}\n\tif args.Months != nil {\n\t\tm := int(*args.Months)\n\t\topt.MonthPeriods = &m\n\t}\n\tactivity, err := usagestatsdeprecated.GetSiteUsageStatistics(opt)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &siteUsageStatisticsResolver{activity}, nil\n}", "label": 1, "programming_language": "Go", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "func (mr *MockAuthorizeRequesterMockRecorder) GetID() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetID\", reflect.TypeOf((*MockAuthorizeRequester)(nil).GetID))\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (p *CompactProtocol) ReadString() (value string, err error) {\n\tlength, e := p.readVarint32()\n\tif e != nil {\n\t\treturn \"\", NewProtocolException(e)\n\t}\n\tif length < 0 {\n\t\treturn \"\", invalidDataLength\n\t}\n\tif uint64(length) > p.trans.RemainingBytes() {\n\t\treturn \"\", invalidDataLength\n\t}\n\n\tif length == 0 {\n\t\treturn \"\", nil\n\t}\n\tvar buf []byte\n\tif length <= int32(len(p.rBuffer)) {\n\t\tbuf = p.rBuffer[0:length]\n\t} else {\n\t\tbuf = make([]byte, length)\n\t}\n\t_, e = io.ReadFull(p.trans, buf)\n\treturn string(buf), NewProtocolException(e)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "func (x *StorageCollectionsList) Reset() {\n\t*x = StorageCollectionsList{}\n\tif protoimpl.UnsafeEnabled {\n\t\tmi := &file_console_proto_msgTypes[34]\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tms.StoreMessageInfo(mi)\n\t}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (x *UpdateAccountRequest) ProtoReflect() protoreflect.Message {\n\tmi := &file_console_proto_msgTypes[36]\n\tif protoimpl.UnsafeEnabled && x != nil {\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tif ms.LoadMessageInfo() == nil {\n\t\t\tms.StoreMessageInfo(mi)\n\t\t}\n\t\treturn ms\n\t}\n\treturn mi.MessageOf(x)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (mr *MockCoreStorageMockRecorder) DeleteRefreshTokenSession(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DeleteRefreshTokenSession\", reflect.TypeOf((*MockCoreStorage)(nil).DeleteRefreshTokenSession), arg0, arg1)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (*CallApiEndpointRequest) Descriptor() ([]byte, []int) {\n\treturn file_console_proto_rawDescGZIP(), []int{12}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func checkAuth(ctx context.Context, config Config, auth string) (context.Context, bool) {\n\tconst basicPrefix = \"Basic \"\n\tconst bearerPrefix = \"Bearer \"\n\n\tif strings.HasPrefix(auth, basicPrefix) {\n\t\t// Basic authentication.\n\t\tusername, password, ok := parseBasicAuth(auth)\n\t\tif !ok {\n\t\t\treturn ctx, false\n\t\t}\n\n\t\tif username != config.GetConsole().Username || password != config.GetConsole().Password {\n\t\t\t// Username and/or password do not match.\n\t\t\treturn ctx, false\n\t\t}\n\n\t\tctx = context.WithValue(context.WithValue(context.WithValue(ctx, ctxConsoleRoleKey{}, console.UserRole_USER_ROLE_ADMIN), ctxConsoleUsernameKey{}, username), ctxConsoleEmailKey{}, \"\")\n\t\t// Basic authentication successful.\n\t\treturn ctx, true\n\t} else if strings.HasPrefix(auth, bearerPrefix) {\n\t\t// Bearer token authentication.\n\t\ttoken, err := jwt.Parse(auth[len(bearerPrefix):], func(token *jwt.Token) (interface{}, error) {\n\t\t\tif s, ok := token.Method.(*jwt.SigningMethodHMAC); !ok || s.Hash != crypto.SHA256 {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected signing method: %v\", token.Header[\"alg\"])\n\t\t\t}\n\t\t\treturn []byte(config.GetConsole().SigningKey), nil\n\t\t})\n\t\tif err != nil {\n\t\t\t// Token verification failed.\n\t\t\treturn ctx, false\n\t\t}\n\t\tuname, email, role, exp, ok := parseConsoleToken([]byte(config.GetConsole().SigningKey), auth[len(bearerPrefix):])\n\t\tif !ok || !token.Valid {\n\t\t\t// The token or its claims are invalid.\n\t\t\treturn ctx, false\n\t\t}\n\t\tif !ok {\n\t\t\t// Expiry time claim is invalid.\n\t\t\treturn ctx, false\n\t\t}\n\t\tif exp <= time.Now().UTC().Unix() {\n\t\t\t// Token expired.\n\t\t\treturn ctx, false\n\t\t}\n\n\t\tctx = context.WithValue(context.WithValue(context.WithValue(ctx, ctxConsoleRoleKey{}, role), ctxConsoleUsernameKey{}, uname), ctxConsoleEmailKey{}, email)\n\n\t\treturn ctx, true\n\t}\n\n\treturn ctx, false\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (p *HTTPClient) closeResponse() error {\n\tvar err error\n\tif p.response != nil && p.response.Body != nil {\n\t\t// The docs specify that if keepalive is enabled and the response body is not\n\t\t// read to completion the connection will never be returned to the pool and\n\t\t// reused. Errors are being ignored here because if the connection is invalid\n\t\t// and this fails for some reason, the Close() method will do any remaining\n\t\t// cleanup.\n\t\tio.Copy(ioutil.Discard, p.response.Body)\n\n\t\terr = p.response.Body.Close()\n\t}\n\n\tp.response = nil\n\treturn err\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-770", "cwe_name": "Allocation of Resources Without Limits or Throttling", "description": "The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/770.html", "label_name": "vulnerable"} {"code": "func isReqAuthenticated(r *http.Request, region string) (s3Error APIErrorCode) {\n\tif r == nil {\n\t\treturn ErrInternalError\n\t}\n\n\tif errCode := reqSignatureV4Verify(r, region); errCode != ErrNone {\n\t\treturn errCode\n\t}\n\n\tpayload, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlogger.LogIf(context.Background(), err)\n\t\treturn ErrInternalError\n\t}\n\n\t// Populate back the payload.\n\tr.Body = ioutil.NopCloser(bytes.NewReader(payload))\n\n\t// Verify Content-Md5, if payload is set.\n\tif clntMD5B64, ok := r.Header[\"Content-Md5\"]; ok {\n\t\tif clntMD5B64[0] == \"\" {\n\t\t\treturn ErrInvalidDigest\n\t\t}\n\t\tmd5Sum, err := base64.StdEncoding.Strict().DecodeString(clntMD5B64[0])\n\t\tif err != nil {\n\t\t\treturn ErrInvalidDigest\n\t\t}\n\t\tif !bytes.Equal(md5Sum, getMD5Sum(payload)) {\n\t\t\treturn ErrBadDigest\n\t\t}\n\t}\n\n\tif skipContentSha256Cksum(r) {\n\t\treturn ErrNone\n\t}\n\n\t// Verify that X-Amz-Content-Sha256 Header == sha256(payload)\n\t// If X-Amz-Content-Sha256 header is not sent then we don't calculate/verify sha256(payload)\n\tsumHex, ok := r.Header[\"X-Amz-Content-Sha256\"]\n\tif isRequestPresignedSignatureV4(r) {\n\t\tsumHex, ok = r.URL.Query()[\"X-Amz-Content-Sha256\"]\n\t}\n\tif ok {\n\t\tif sumHex[0] == \"\" {\n\t\t\treturn ErrContentSHA256Mismatch\n\t\t}\n\t\tsum, err := hex.DecodeString(sumHex[0])\n\t\tif err != nil {\n\t\t\treturn ErrContentSHA256Mismatch\n\t\t}\n\t\tif !bytes.Equal(sum, getSHA256Sum(payload)) {\n\t\t\treturn ErrContentSHA256Mismatch\n\t\t}\n\t}\n\treturn ErrNone\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-774", "cwe_name": "Allocation of File Descriptors or Handles Without Limits or Throttling", "description": "The software allocates file descriptors or handles on behalf of an actor without imposing any restrictions on how many descriptors can be allocated, in violation of the intended security policy for that actor.", "url": "https://cwe.mitre.org/data/definitions/774.html", "label_name": "vulnerable"} {"code": "func FilterSQLInject(key string) string {\n\tkey = strings.TrimSpace(key)\n\tkey = strings.Split(key, \" \")[0]\n\tkey = strings.Replace(key, \",\", \"\", -1)\n\treturn key\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-89", "cwe_name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')", "description": "The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/89.html", "label_name": "safe"} {"code": "func (m *MockClient) GetRedirectURIs() []string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRedirectURIs\")\n\tret0, _ := ret[0].([]string)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func createDefaultConfigFileIfNotExists() error {\n\tdefaultFilePath := GetDefaultConfigFilePath()\n\tif isExists(defaultFilePath) {\n\t\treturn nil\n\t}\n\tfolderPath := filepath.Dir(defaultFilePath)\n\tif !isExists(folderPath) {\n\t\terr := os.Mkdir(folderPath, folderPermission)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tf, err := os.Create(defaultFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn f.Close()\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-276", "cwe_name": "Incorrect Default Permissions", "description": "During installation, installed file permissions are set to allow anyone to modify those files.", "url": "https://cwe.mitre.org/data/definitions/276.html", "label_name": "vulnerable"} {"code": "func (svc Service) CountSoftware(ctx context.Context, opt fleet.SoftwareListOptions) (int, error) {\n\tif err := svc.authz.Authorize(ctx, &fleet.Software{}, fleet.ActionRead); err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn svc.ds.CountSoftware(ctx, opt)\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": "func (*Config_Warning) Descriptor() ([]byte, []int) {\n\treturn file_console_proto_rawDescGZIP(), []int{14, 0}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "func (c *linuxContainer) newSetnsProcess(p *Process, cmd *exec.Cmd, messageSockPair, logFilePair filePair) (*setnsProcess, error) {\n\tcmd.Env = append(cmd.Env, \"_LIBCONTAINER_INITTYPE=\"+string(initSetns))\n\tstate, err := c.currentState()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get container state: %w\", err)\n\t}\n\t// for setns process, we don't have to set cloneflags as the process namespaces\n\t// will only be set via setns syscall\n\tdata, err := c.bootstrapData(0, state.NamespacePaths)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tproc := &setnsProcess{\n\t\tcmd: cmd,\n\t\tcgroupPaths: state.CgroupPaths,\n\t\trootlessCgroups: c.config.RootlessCgroups,\n\t\tintelRdtPath: state.IntelRdtPath,\n\t\tmessageSockPair: messageSockPair,\n\t\tlogFilePair: logFilePair,\n\t\tmanager: c.cgroupManager,\n\t\tconfig: c.newInitConfig(p),\n\t\tprocess: p,\n\t\tbootstrapData: data,\n\t\tinitProcessPid: state.InitProcessPid,\n\t}\n\tif len(p.SubCgroupPaths) > 0 {\n\t\tif add, ok := p.SubCgroupPaths[\"\"]; ok {\n\t\t\t// cgroup v1: using the same path for all controllers.\n\t\t\t// cgroup v2: the only possible way.\n\t\t\tfor k := range proc.cgroupPaths {\n\t\t\t\tproc.cgroupPaths[k] = path.Join(proc.cgroupPaths[k], add)\n\t\t\t}\n\t\t\t// cgroup v2: do not try to join init process's cgroup\n\t\t\t// as a fallback (see (*setnsProcess).start).\n\t\t\tproc.initProcessPid = 0\n\t\t} else {\n\t\t\t// Per-controller paths.\n\t\t\tfor ctrl, add := range p.SubCgroupPaths {\n\t\t\t\tif val, ok := proc.cgroupPaths[ctrl]; ok {\n\t\t\t\t\tproc.cgroupPaths[ctrl] = path.Join(val, add)\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unknown controller %s in SubCgroupPaths\", ctrl)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn proc, nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "vulnerable"} {"code": "func (m *Bar8) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowIssue530\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Bar8: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Bar8: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Bars1\", wireType)\n\t\t\t}\n\t\t\tvar msglen int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowIssue530\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tmsglen |= int(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif msglen < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue530\n\t\t\t}\n\t\t\tpostIndex := iNdEx + msglen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue530\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.Bars1 = append(m.Bars1, Bar9{})\n\t\t\tif err := m.Bars1[len(m.Bars1)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipIssue530(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue530\n\t\t\t}\n\t\t\tif (iNdEx + skippy) < 0 {\n\t\t\t\treturn ErrInvalidLengthIssue530\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-129", "cwe_name": "Improper Validation of Array Index", "description": "The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.", "url": "https://cwe.mitre.org/data/definitions/129.html", "label_name": "vulnerable"} {"code": "func (mr *MockCoreStorageMockRecorder) InvalidateAuthorizeCodeSession(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"InvalidateAuthorizeCodeSession\", reflect.TypeOf((*MockCoreStorage)(nil).InvalidateAuthorizeCodeSession), arg0, arg1)\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (g Grant) ValidateBasic() error {\n\tif g.Expiration.Unix() < time.Now().Unix() {\n\t\treturn sdkerrors.Wrap(ErrInvalidExpirationTime, \"Time can't be in the past\")\n\t}\n\n\tav := g.Authorization.GetCachedValue()\n\ta, ok := av.(Authorization)\n\tif !ok {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidType, \"expected %T, got %T\", (Authorization)(nil), av)\n\t}\n\treturn a.ValidateBasic()\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-754", "cwe_name": "Improper Check for Unusual or Exceptional Conditions", "description": "The software does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the software.", "url": "https://cwe.mitre.org/data/definitions/754.html", "label_name": "vulnerable"} {"code": "func resize(in []byte, n uint64) (head, tail []byte) {\n\tif uint64(cap(in)) >= n {\n\t\thead = in[:n]\n\t} else {\n\t\thead = make([]byte, n)\n\t\tcopy(head, in)\n\t}\n\n\ttail = head[len(in):]\n\treturn\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-190", "cwe_name": "Integer Overflow or Wraparound", "description": "The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.", "url": "https://cwe.mitre.org/data/definitions/190.html", "label_name": "safe"} {"code": "func (m *MockAuthorizeRequester) Sanitize(arg0 []string) fosite.Requester {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Sanitize\", arg0)\n\tret0, _ := ret[0].(fosite.Requester)\n\treturn ret0\n}", "label": 1, "programming_language": "Go", "cwe_id": "CWE-345", "cwe_name": "Insufficient Verification of Data Authenticity", "description": "The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.", "url": "https://cwe.mitre.org/data/definitions/345.html", "label_name": "safe"} {"code": "func (x *ConsoleSession) Reset() {\n\t*x = ConsoleSession{}\n\tif protoimpl.UnsafeEnabled {\n\t\tmi := &file_console_proto_msgTypes[15]\n\t\tms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))\n\t\tms.StoreMessageInfo(mi)\n\t}\n}", "label": 0, "programming_language": "Go", "cwe_id": "CWE-613", "cwe_name": "Insufficient Session Expiration", "description": "According to WASC, \"Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.\"", "url": "https://cwe.mitre.org/data/definitions/613.html", "label_name": "vulnerable"} {"code": "export function ffprobe(file: string): Promise {\n return new Promise((resolve, reject) => {\n if (!file) throw new Error('no file provided')\n\n stat(file, (err, stats) => {\n if (err) throw err\n\n exec('ffprobe -v quiet -print_format json -show_format -show_streams ' + file, (error, stdout, stderr) => {\n if (error) return reject(error)\n if (!stdout) return reject(new Error(\"can't probe file \" + file))\n\n let ffprobed: IFfprobe\n\n try {\n ffprobed = JSON.parse(stdout)\n } catch (err) {\n return reject(err)\n }\n\n for (let i = 0; i < ffprobed.streams.length; i++) {\n if (ffprobed.streams[i].codec_type === 'video') ffprobed.video = ffprobed.streams[i] as IVideoStream\n if (ffprobed.streams[i].codec_type === 'audio' && ffprobed.streams[i].channels)\n ffprobed.audio = ffprobed.streams[i] as IAudioStream\n }\n resolve(ffprobed)\n })\n })\n })\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "vulnerable"} {"code": " throw new Error(`Email(s) (${failed.join(\", \")}) could not be sent`)\n }\n },", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " updateOidcSettings(configuration) {\n checkAdminAuthentication(this)\n ServiceConfiguration.configurations.remove({\n service: 'oidc',\n })\n ServiceConfiguration.configurations.insert(configuration)\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-285", "cwe_name": "Improper Authorization", "description": "The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.", "url": "https://cwe.mitre.org/data/definitions/285.html", "label_name": "vulnerable"} {"code": " let getNftParentId = async (tokenIdHex: string) => {\n let txnhex = (await asyncSlpValidator.getRawTransactions([tokenIdHex]))[0];\n let tx = Primatives.Transaction.parseFromBuffer(Buffer.from(txnhex, 'hex'));\n let nftBurnTxnHex = (await asyncSlpValidator.getRawTransactions([tx.inputs[0].previousTxHash]))[0];\n let nftBurnTxn = Primatives.Transaction.parseFromBuffer(Buffer.from(nftBurnTxnHex, 'hex'));\n let slp = new Slp(this.BITBOX);\n let nftBurnSlp = slp.parseSlpOutputScript(Buffer.from(nftBurnTxn.outputs[0].scriptPubKey));\n if (nftBurnSlp.transactionType === SlpTransactionType.GENESIS) {\n return tx.inputs[0].previousTxHash;\n }\n else {\n return nftBurnSlp.tokenIdHex;\n }\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "vulnerable"} {"code": "TEST_F(AsStringGraphTest, FloatDefault) {\n TF_ASSERT_OK(Init(DT_FLOAT));\n\n AddInputFromArray(TensorShape({4}), {-42, 0, 3.14159, 42});\n TF_ASSERT_OK(RunOpKernel());\n Tensor expected(allocator(), DT_STRING, TensorShape({4}));\n test::FillValues(\n &expected, {\"-42.000000\", \"0.000000\", \"3.141590\", \"42.000000\"});\n test::ExpectTensorEqual(expected, *GetOutput(0));\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": " wsHandler: (conn, req) => {\n conn.write(req.url)\n conn.end()\n }", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "export function fetchRemote(remote: string, cwd: string) {\n const results = git([\"fetch\", remote], { cwd });\n\n if (!results.success) {\n throw gitError(`Cannot fetch remote: ${remote}`);\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-77", "cwe_name": "Improper Neutralization of Special Elements used in a Command ('Command Injection')", "description": "The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/77.html", "label_name": "vulnerable"} {"code": " isValidUser(username, password) {\n const user = users.find(user => user.username === username);\n if (!user) return false;\n return user.password === password;\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "const pushVal = (obj, path, val, options = {}) => {\n\tif (obj === undefined || obj === null || path === undefined) {\n\t\treturn obj;\n\t}\n\t\n\t// Clean the path\n\tpath = clean(path);\n\t\n\tconst pathParts = split(path);\n\tconst part = pathParts.shift();\n\n\tif (part === \"__proto__\") return obj;\n\n\tif (pathParts.length) {\n\t\t// Generate the path part in the object if it does not already exist\n\t\tobj[part] = decouple(obj[part], options) || {};\n\t\t\n\t\t// Recurse\n\t\tpushVal(obj[part], pathParts.join(\".\"), val, options);\n\t} else if (part) {\n\t\t// We have found the target array, push the value\n\t\tobj[part] = decouple(obj[part], options) || [];\n\t\t\n\t\tif (!(obj[part] instanceof Array)) {\n\t\t\tthrow(\"Cannot push to a path whose leaf node is not an array!\");\n\t\t}\n\t\t\n\t\tobj[part].push(val);\n\t} else {\n\t\t// We have found the target array, push the value\n\t\tobj = decouple(obj, options) || [];\n\t\t\n\t\tif (!(obj instanceof Array)) {\n\t\t\tthrow(\"Cannot push to a path whose leaf node is not an array!\");\n\t\t}\n\t\t\n\t\tobj.push(val);\n\t}\n\t\n\treturn decouple(obj, options);\n};", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": " async sendWelcomeEmail(to: string, name: string, invitationtoken: string) {\n const subject = 'Welcome to ToolJet';\n const inviteUrl = `${this.TOOLJET_HOST}/invitations/${invitationtoken}`;\n const html = `\n \n \n \n \n \n \n

    Hi ${name || ''},

    \n \n Please use the link below to set up your account and get started.\n \n
    \n ${inviteUrl}\n
    \n

    \n Welcome aboard,
    \n ToolJet Team\n

    \n \n \n `;\n\n await this.sendEmail(to, subject, html);\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " text(notificationName, data) {\n const username = formatUsername(data.display_username);\n\n let description;\n if (data.topic_title) {\n description = `${data.topic_title}`;\n } else {\n description = this.description(data);\n }\n\n return I18n.t(data.message, { description, username });\n },", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " get: path => {\n useCount++;\n expect(path).toEqual('somepath');\n },", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "export function html(m, keyPath, ...args) {\n const html = str(m, keyPath, ...args);\n\n return html ? React.createElement('span', { dangerouslySetInnerHTML: { __html: html } }) : null;\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "function set(target, path, val) {\n \"use strict\";\n try {\n return add(target, path, val);\n } catch(ex) {\n console.error(ex);\n return;\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": "function ssrfSafeHttp(originalHttpCall, db, method, url, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = undefined;\n }\n if (!options) options = {};\n\n if (options.npmRequestOptions && options.npmRequestOptions.proxy) {\n // Request already specifies a different proxy.\n return originalHttpCall(method, url, options, callback);\n }\n\n const safe = ssrfSafeLookupOrProxy(db, url);\n\n if (safe.proxy) {\n if (!options.npmRequestOptions) options.npmRequestOptions = {};\n options.npmRequestOptions.proxy = safe.proxy;\n return originalHttpCall(method, url, options, callback);\n } else {\n const safe = ssrfSafeLookup(db, url);\n if (!options.headers) options.headers = {};\n options.headers.host = safe.host;\n options.servername = safe.host.split(\":\")[0];\n return originalHttpCall(method, safe.url, options, callback);\n }\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": " 'X-Parse-Session-Token': session.getSessionToken(),\n },\n },\n });\n\n const sessionToken = result.data.viewer.sessionToken;\n const { objectId, userFoo: resultFoo } = result.data.viewer.user;\n expect(objectId).toEqual(user.id);\n expect(sessionToken).toBeDefined();\n expect(resultFoo).toEqual(null);\n });", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "const parseIni = (iniData: string): ParsedIniData => {\n const map: ParsedIniData = {};\n let currentSection: string | undefined;\n for (let line of iniData.split(/\\r?\\n/)) {\n line = line.split(/(^|\\s)[;#]/)[0]; // remove comments\n const section = line.match(/^\\s*\\[([^\\[\\]]+)]\\s*$/);\n if (section) {\n currentSection = section[1];\n if (profileNameBlockList.includes(currentSection)) {\n throw new Error(`Found invalid profile name \"${currentSection}\"`);\n }\n } else if (currentSection) {\n const item = line.match(/^\\s*(.+?)\\s*=\\s*(.+?)\\s*$/);\n if (item) {\n map[currentSection] = map[currentSection] || {};\n map[currentSection][item[1]] = item[2];\n }\n }\n }\n\n return map;\n};", "label": 1, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "async function bootstrap() {\n const app = await NestFactory.create(AppModule);\n app.useWebSocketAdapter(new WsAdapter(app));\n\n // swagger setting\n const options = new DocumentBuilder()\n .setTitle('ptarmigan REST-API')\n .setDescription('Lightning Network implementation ptarmigan REST-API')\n .addBearerAuth('Authorization', 'header')\n .setVersion('0.2')\n .build();\n const document = SwaggerModule.createDocument(app, options);\n SwaggerModule.setup('api', app, document);\n\n const config = ConfigService;\n Logger.log('ptarmdRpcPort: ' + config.get('ptarmigan.ptarmdRpcPort'));\n Logger.log('ptarmdHost: + ' + config.get('ptarmigan.ptarmdHost'));\n Logger.log('bitcoindRpcPort: ' + config.get('ptarmigan.bitcoindRpcPort'));\n Logger.log('bitcoindHost: ' + config.get('ptarmigan.bitcoindHost'));\n Logger.log('bitcoindHost: ' + config.get('ptarmigan.apiToken'));\n\n await app.listen(3000);\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-295", "cwe_name": "Improper Certificate Validation", "description": "The software does not validate, or incorrectly validates, a certificate.", "url": "https://cwe.mitre.org/data/definitions/295.html", "label_name": "safe"} {"code": "module.exports = function (key) {\n key = normalizeKey(key.split('@').pop());\n return normalized[key] || false;\n};", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "safe"} {"code": "export function initSidebar(): void {\n const errorCountEl = document.getElementById(\"error-count\");\n if (errorCountEl instanceof HTMLLIElement) {\n errorCount.subscribe((errorCount_val) => {\n errorCountEl.classList.toggle(\"hidden\", errorCount_val === 0);\n const span = errorCountEl.querySelector(\"span\");\n if (span) {\n span.innerHTML = `${errorCount_val}`;\n }\n });\n }\n\n const asideButton = document.getElementById(\"aside-button\");\n if (asideButton instanceof HTMLButtonElement) {\n asideButton.addEventListener(\"click\", () => {\n document.querySelector(\"aside\")?.classList.toggle(\"active\");\n asideButton.classList.toggle(\"active\");\n });\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "TEST_F(AsStringGraphTest, FloatScientific) {\n TF_ASSERT_OK(Init(DT_FLOAT, /*fill=*/\"\", /*width=*/-1, /*precision=*/-1,\n /*scientific=*/true));\n\n AddInputFromArray(TensorShape({4}), {-42, 0, 3.14159, 42});\n TF_ASSERT_OK(RunOpKernel());\n Tensor expected(allocator(), DT_STRING, TensorShape({4}));\n test::FillValues(&expected, {\"-4.200000e+01\", \"0.000000e+00\",\n \"3.141590e+00\", \"4.200000e+01\"});\n test::ExpectTensorEqual(expected, *GetOutput(0));\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": " resetPassword(req) {\n const config = req.config;\n\n if (!config) {\n this.invalidRequest();\n }\n\n if (!config.publicServerURL) {\n return this.missingPublicServerURL();\n }\n\n const { username, new_password, token: rawToken } = req.body;\n const token =\n rawToken && typeof rawToken !== 'string' ? rawToken.toString() : rawToken;\n\n if ((!username || !token || !new_password) && req.xhr === false) {\n return this.invalidLink(req);\n }\n\n if (!username) {\n throw new Parse.Error(Parse.Error.USERNAME_MISSING, 'Missing username');\n }\n\n if (!token) {\n throw new Parse.Error(Parse.Error.OTHER_CAUSE, 'Missing token');\n }\n\n if (!new_password) {\n throw new Parse.Error(Parse.Error.PASSWORD_MISSING, 'Missing password');\n }\n\n return config.userController\n .updatePassword(username, token, new_password)\n .then(\n () => {\n return Promise.resolve({\n success: true,\n });\n },\n err => {\n return Promise.resolve({\n success: false,\n err,\n });\n }\n )\n .then(result => {\n const params = qs.stringify({\n username: username,\n token: token,\n id: config.applicationId,\n error: result.err,\n app: config.appName,\n });\n\n if (req.xhr) {\n if (result.success) {\n return Promise.resolve({\n status: 200,\n response: 'Password successfully reset',\n });\n }\n if (result.err) {\n throw new Parse.Error(Parse.Error.OTHER_CAUSE, `${result.err}`);\n }\n }\n\n const encodedUsername = encodeURIComponent(username);\n const location = result.success\n ? `${config.passwordResetSuccessURL}?username=${encodedUsername}`\n : `${config.choosePasswordURL}?${params}`;\n\n return Promise.resolve({\n status: 302,\n location,\n });\n });\n }", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "function setCachedRendererFunction (id: RendererFunctionId, wc: electron.WebContents, frameId: [number, number], value: CallIntoRenderer) {\n // eslint-disable-next-line no-undef\n const wr = new WeakRef(value);\n const mapKey = id[0] + '~' + id[1];\n rendererFunctionCache.set(mapKey, wr);\n finalizationRegistry.register(value, {\n id,\n webContents: wc,\n frameId\n } as FinalizerInfo);\n return value;\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-668", "cwe_name": "Exposure of Resource to Wrong Sphere", "description": "The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.", "url": "https://cwe.mitre.org/data/definitions/668.html", "label_name": "safe"} {"code": "function bufferCopy(src, dest, srcStart, srcEnd, destStart) {\n if (!destStart)\n destStart = 0;\n if (srcEnd > src.length)\n srcEnd = src.length;\n let nb = srcEnd - srcStart;\n const destLeft = (dest.length - destStart);\n if (nb > destLeft)\n nb = destLeft;\n dest.set(new Uint8Array(src.buffer, src.byteOffset + srcStart, nb),\n destStart);\n return nb;\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": ") => {\n const { info, config } = context;\n if (!info || !info.sessionToken) {\n throw new Parse.Error(\n Parse.Error.INVALID_SESSION_TOKEN,\n 'Invalid session token'\n );\n }\n const sessionToken = info.sessionToken;\n const selectedFields = getFieldNames(queryInfo)\n .filter(field => field.startsWith(keysPrefix))\n .map(field => field.replace(keysPrefix, ''));\n\n const keysAndInclude = extractKeysAndInclude(selectedFields);\n const { keys } = keysAndInclude;\n let { include } = keysAndInclude;\n\n if (userId && !keys && !include) {\n return {\n sessionToken,\n };\n } else if (keys && !include) {\n include = 'user';\n }\n\n if (userId) {\n // We need to re create the auth context\n // to avoid security breach if userId is provided\n context.auth = new Auth({\n config,\n isMaster: context.auth.isMaster,\n user: { id: userId },\n });\n }\n\n const options = {};\n if (keys) {\n options.keys = keys\n .split(',')\n .map(key => `${key}`)\n .join(',');\n }\n if (include) {\n options.include = include\n .split(',')\n .map(included => `${included}`)\n .join(',');\n }\n\n const response = await rest.find(\n config,\n context.auth,\n '_User',\n // Get the user it self from auth object\n { objectId: context.auth.user.id },\n options,\n info.clientVersion,\n info.context\n );\n if (!response.results || response.results.length == 0) {\n throw new Parse.Error(\n Parse.Error.INVALID_SESSION_TOKEN,\n 'Invalid session token'\n );\n } else {\n const user = response.results[0];\n return {\n sessionToken,\n user,\n };\n }\n};", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": " Object.keys(data).forEach((key) => {\n obj.set(key, deserializer(data[key], baseType) as T);\n });", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": " constructor(options: PacketAssemblerOptions) {\n super();\n this._stack = [];\n this.expectedLength = 0;\n this.currentLength = 0;\n this.readMessageFunc = options.readMessageFunc;\n this.minimumSizeInBytes = options.minimumSizeInBytes || 8;\n assert(typeof this.readMessageFunc === \"function\", \"packet assembler requires a readMessageFunc\");\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": "const mapPolls = () => {\n const poll = Polls.findOne({});\n if (!poll) {\n return { pollExists: false };\n }\n\n const { answers } = poll;\n let stackOptions = false;\n\n answers.map((obj) => {\n if (stackOptions) return obj;\n if (obj.key.length > MAX_CHAR_LENGTH) {\n stackOptions = true;\n }\n return obj;\n });\n\n const amIRequester = poll.requester !== 'userId';\n\n return {\n poll: {\n answers: poll.answers,\n pollId: poll.id,\n stackOptions,\n },\n pollExists: true,\n amIRequester,\n handleVote(pollId, answerId) {\n makeCall('publishVote', pollId, answerId.id);\n },\n };\n};", "label": 0, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "vulnerable"} {"code": " }) => Awaitable\n /**\n * By default, we are generating a random verification token.\n * You can make it predictable or modify it as you like with this method.\n * @example\n * ```js\n * Providers.Email({\n * async generateVerificationToken() {\n * return \"ABC123\"\n * }\n * })\n * ```\n * [Documentation](https://next-auth.js.org/providers/email#customising-the-verification-token)\n */\n generateVerificationToken?: () => Awaitable", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " type: new GraphQLNonNull(parseGraphQLSchema.viewerType),\n async resolve(_source, _args, context, queryInfo) {\n try {\n const { config, info } = context;\n return await getUserFromSessionToken(\n config,\n info,\n queryInfo,\n 'user.',\n false\n );\n } catch (e) {\n parseGraphQLSchema.handleError(e);\n }\n },\n },\n true,\n true\n );\n};", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " public static IESParameterSpec guessParameterSpec(BufferedBlockCipher iesBlockCipher)\n {\n if (iesBlockCipher == null)\n {\n return new IESParameterSpec(null, null, 128);\n }\n else\n {\n BlockCipher underlyingCipher = iesBlockCipher.getUnderlyingCipher();\n\n if (underlyingCipher.getAlgorithmName().equals(\"DES\") ||\n underlyingCipher.getAlgorithmName().equals(\"RC2\") ||\n underlyingCipher.getAlgorithmName().equals(\"RC5-32\") ||\n underlyingCipher.getAlgorithmName().equals(\"RC5-64\"))\n {\n return new IESParameterSpec(null, null, 64, 64);\n }\n else if (underlyingCipher.getAlgorithmName().equals(\"SKIPJACK\"))\n {\n return new IESParameterSpec(null, null, 80, 80);\n }\n else if (underlyingCipher.getAlgorithmName().equals(\"GOST28147\"))\n {\n return new IESParameterSpec(null, null, 256, 256);\n }\n\n return new IESParameterSpec(null, null, 128, 128);\n }\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": "const getValue = (target, prop) => {\n if (prop === 'Math') return Math;\n const { expressions, data } = target;\n if (!expressions.has(prop)) return data.get(prop);\n const expression = expressions.get(prop);\n return expression();\n};", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-94", "cwe_name": "Improper Control of Generation of Code ('Code Injection')", "description": "The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.", "url": "https://cwe.mitre.org/data/definitions/94.html", "label_name": "vulnerable"} {"code": "async function apiCommand(command: string, parameters: {} = {}): Promise {\n const url = \"/api\"\n const method = \"POST\"\n const headers = { \"Content-Type\": \"application/json\" }\n const data: ApiRequest = { command, parameters }\n\n const res = await axios.request>({ url, method, headers, data })\n\n if (res.data.errors) {\n throw res.data.errors\n }\n\n if (res.data.result === undefined) {\n throw new Error(\"Empty response from server\")\n }\n\n return res.data.result\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-306", "cwe_name": "Missing Authentication for Critical Function", "description": "The software does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.", "url": "https://cwe.mitre.org/data/definitions/306.html", "label_name": "vulnerable"} {"code": " return txt.replace(/[&<>]/gm, (str) => {\n if (str === \"&\") return \"&\";\n if (str === \"<\") return \"<\";\n if (str === \">\") return \">\";\n });", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "export function escapeCommentText(value: string): string {\n return value.replace(END_COMMENT, END_COMMENT_ESCAPED);\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " getPublicPEM: function getPublicPEM() {\n return this[SYM_PUB_PEM];\n },", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function skipFields(buf, nfields) {\n const bufLen = buf.length;\n let pos = (buf._pos || 0);\n for (let i = 0; i < nfields; ++i) {\n const left = (bufLen - pos);\n if (pos >= bufLen || left < 4)\n return false;\n const len = readUInt32BE(buf, pos);\n if (left < 4 + len)\n return false;\n pos += 4 + len;\n }\n buf._pos = pos;\n return true;\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " }\n\n actionItems() {\n let composing = new PrivateComposing(this.user);\n\n const items = new ItemList();\n\n if (app.session.user && app.forum.attribute('canStartPrivateDiscussion')) {\n items.add('start_private', composing.component());\n }\n", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-269", "cwe_name": "Improper Privilege Management", "description": "The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.", "url": "https://cwe.mitre.org/data/definitions/269.html", "label_name": "vulnerable"} {"code": " 'X-Parse-Session-Token': user1.getSessionToken(),\n },\n },\n });\n\n let foundGraphQLClassReadPreference = false;\n let foundUserClassReadPreference = false;\n databaseAdapter.database.serverConfig.cursor.calls\n .all()\n .forEach((call) => {\n if (\n call.args[0].ns.collection.indexOf('GraphQLClass') >= 0\n ) {\n foundGraphQLClassReadPreference = true;\n expect(call.args[0].options.readPreference.mode).toBe(\n ReadPreference.PRIMARY\n );\n } else if (\n call.args[0].ns.collection.indexOf('_User') >= 0\n ) {\n foundUserClassReadPreference = true;\n expect(call.args[0].options.readPreference.mode).toBe(\n ReadPreference.PRIMARY\n );\n }\n });\n\n expect(foundGraphQLClassReadPreference).toBe(true);\n expect(foundUserClassReadPreference).toBe(true);\n } catch (e) {\n handleError(e);\n }\n });", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "vulnerable"} {"code": " render() {},", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": " stitchSchemas({ subschemas: [autoSchema] }),\n });\n\n parseGraphQLServer.applyGraphQL(expressApp);\n await new Promise(resolve =>\n httpServer.listen({ port: 13377 }, resolve)\n );\n const httpLink = createUploadLink({\n uri: 'http://localhost:13377/graphql',\n fetch,\n headers,\n });\n apolloClient = new ApolloClient({\n link: httpLink,\n cache: new InMemoryCache(),\n defaultOptions: {\n query: {\n fetchPolicy: 'no-cache',\n },\n },\n });\n });\n\n afterAll(async () => {\n await httpServer.close();\n });\n\n it('can resolve a query', async () => {\n const result = await apolloClient.query({\n query: gql`\n query Health {\n health\n }\n `,\n });\n expect(result.data.health).toEqual(true);\n });\n });", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": " userId: projectUsers.findOne().users.find((elem) => elem._id === entry._id.userId)?.profile?.name,", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "export function setDeepProperty(obj: {[key: string]: any}, propertyPath: string, value: any): void {\n\tif (!obj) {\n\t\tthrow new Error(\"Invalid object\");\n\t}\n\tif (!propertyPath) {\n\t\tthrow new Error(\"Invalid property path\");\n\t}\n\n\tconst pathParts = splitPath(propertyPath);\n\tconst pathPartsLen = pathParts.length;\n\n\tfor (let i = 0; i < pathPartsLen - 1; i++) {\n\t\tconst pathPart = pathParts[i];\n\n\t\tif (!(pathPart in obj)) {\n\t\t\tsetProp(obj, pathPart, {});\n\t\t}\n\t\tobj = getProp(obj, pathPart);\n\t}\n\n\tsetProp(obj, pathParts[pathPartsLen - 1], value);\n\treturn;\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "safe"} {"code": " event.reply = (...args: any[]) => {\n event.sender.sendToFrame(event.frameId, ...args);\n };", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-668", "cwe_name": "Exposure of Resource to Wrong Sphere", "description": "The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.", "url": "https://cwe.mitre.org/data/definitions/668.html", "label_name": "vulnerable"} {"code": "module.exports = function(url, options) {\n return fetch(url, options);\n};", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-88", "cwe_name": "Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')", "description": "The software constructs a string for a command to executed by a separate component\nin another control sphere, but it does not properly delimit the\nintended arguments, options, or switches within that command string.", "url": "https://cwe.mitre.org/data/definitions/88.html", "label_name": "vulnerable"} {"code": "function monkeyPatchHttp(db, HTTP) {\n const original = HTTP.call.bind(HTTP);\n HTTP.call = ssrfSafeHttp.bind(this, original, db);\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "function oneOf(expected, thing) {\n assert(typeof thing === 'string', '`thing` has to be of type string');\n if (Array.isArray(expected)) {\n const len = expected.length;\n assert(len > 0, 'At least one expected value needs to be specified');\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or `\n + expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n }\n return `of ${thing} ${expected[0]}`;\n }\n return `of ${thing} ${String(expected)}`;\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "function ssrfSafeLookupOrProxy(db, url) {\n // If there is an HTTP proxy, then it will have to do the work of blacklisting IPs, because it's\n // the proxy that does the DNS lookup.\n const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;\n const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;\n\n if (httpProxy && url.startsWith(\"http:\")) {\n return { proxy: httpProxy };\n } else if (httpsProxy && url.startsWith(\"https:\")) {\n return { proxy: httpsProxy };\n } else {\n return ssrfSafeLookup(db, url);\n }\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "safe"} {"code": "module.exports = function generate() {\n var spec = {}\n , key;\n\n spec.protocol = get('protocol');\n spec.slashes = true;\n \n spec.hostname = get('hostname');\n spec.pathname = get('pathname');\n\n if (yep()) spec.port = get('port');\n if (yep()) spec.query = '?'+ get('query');\n if (yep()) spec.hash = '#'+ get('hash');\n if (yep()) {\n spec.username = get('username');\n spec.password = get('password');\n }\n\n spec.host = spec.port ? spec.hostname + ':' + spec.port : spec.hostname;\n\n for (key in combinations) {\n url[key] = '';\n }\n\n for (key in spec) {\n url[key] = spec[key];\n }\n\n spec.href = url.toString();\n return spec;\n};", "label": 1, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": "TEST_F(AsStringGraphTest, Complex) {\n TF_ASSERT_OK(Init(DT_COMPLEX64, /*fill=*/\"\", /*width=*/5, /*precision=*/2));\n\n AddInputFromArray(TensorShape({3}), {{-4, 2}, {0}, {3.14159, -1}});\n TF_ASSERT_OK(RunOpKernel());\n Tensor expected(allocator(), DT_STRING, TensorShape({3}));\n test::FillValues(\n &expected, {\"(-4.00, 2.00)\", \"( 0.00, 0.00)\", \"( 3.14,-1.00)\"});\n test::ExpectTensorEqual(expected, *GetOutput(0));\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-134", "cwe_name": "Use of Externally-Controlled Format String", "description": "The software uses a function that accepts a format string as an argument, but the format string originates from an external source.", "url": "https://cwe.mitre.org/data/definitions/134.html", "label_name": "safe"} {"code": " async sendOrganizationUserWelcomeEmail(\n to: string,\n name: string,\n sender: string,\n invitationtoken: string,\n organisationName: string\n ) {\n const subject = 'Welcome to ToolJet';\n const inviteUrl = `${this.TOOLJET_HOST}/organization-invitations/${invitationtoken}`;\n const html = `\n \n \n \n \n \n \n

    Hi ${name || ''},

    \n
    \n \n ${sender} has invited you to use ToolJet workspace ${organisationName}. Use the link below to set up your account and get started.\n \n
    \n ${inviteUrl}\n
    \n
    \n

    \n Welcome aboard,
    \n ToolJet Team\n

    \n \n \n `;\n\n await this.sendEmail(to, subject, html);\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-Other", "cwe_name": "Other", "description": "NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.", "url": "https://nvd.nist.gov/vuln/categories", "label_name": "vulnerable"} {"code": " constructor (\n private sanitizer: DomSanitizer,\n private serverService: ServerService\n ) {\n this.bytesPipe = new BytesPipe()\n this.maxSizeText = $localize`max size`\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "vulnerable"} {"code": "export function verify_multi_chunk_message(packets: any[]) {\n\n const messageBuilder = new MessageBuilder({});\n messageBuilder.setSecurity(MessageSecurityMode.None, SecurityPolicy.None);\n\n messageBuilder.on(\"full_message_body\", (fullMessageBody: Buffer) => {\n console.log(\"full_message_body received:\");\n analyseExtensionObject(fullMessageBody, 0, 0);\n });\n messageBuilder.on(\"start_chunk\", (info) => {\n console.log(\" starting new chunk \", info.messageHeader);\n });\n\n messageBuilder.on(\"chunk\", (messageChunk) => {\n console.log(messageHeaderToString(messageChunk));\n });\n\n let totalLength = 0;\n packets.forEach((packet) => {\n if (packet instanceof Array) {\n packet = Buffer.from(packet);\n }\n totalLength += packet.length;\n // console.log(sprintf(\" adding packet size : %5d l=%d\", packet.length, totalLength));\n messageBuilder.feed(packet);\n });\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-400", "cwe_name": "Uncontrolled Resource Consumption", "description": "The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.", "url": "https://cwe.mitre.org/data/definitions/400.html", "label_name": "vulnerable"} {"code": " const cb = (err) => {\n if (err) {\n return Logger.error(`Removing responded user from Polls collection: ${err}`);\n }\n\n Logger.info(`Removed responded user=${requesterUserId} from poll (meetingId: ${meetingId}, `\n + `pollId: ${pollId}!)`);\n\n return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);\n };", "label": 1, "programming_language": "TypeScript", "cwe_id": "NVD-CWE-noinfo", "cwe_name": null, "description": null, "url": null, "label_name": "safe"} {"code": " ops.slice(1).forEach((opitem) => {\n if (opitem.opcode > this.BITBOX.Script.opcodes.OP_16) {\n throw Error(\"Non-push opcode\");\n }\n if (opitem.opcode > this.BITBOX.Script.opcodes.OP_PUSHDATA4) {\n if (opitem.opcode === 80) {\n throw Error('Non-push opcode');\n }\n if (!allow_op_number) {\n throw Error('OP_1NEGATE to OP_16 not allowed');\n }\n if (opitem.opcode === this.BITBOX.Script.opcodes.OP_1NEGATE) {\n opitem.data = Buffer.from([0x81]);\n }\n else { // OP_1 - OP_16\n opitem.data = Buffer.from([opitem.opcode - 80]);\n }\n }\n if (opitem.opcode === this.BITBOX.Script.opcodes.OP_0 && !allow_op_0) {\n throw Error(\"OP_0 not allowed\");\n }\n chunks.push(opitem.data);\n });", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-20", "cwe_name": "Improper Input Validation", "description": "The product receives input or data, but it does\n not validate or incorrectly validates that the input has the\n properties that are required to process the data safely and\n correctly.", "url": "https://cwe.mitre.org/data/definitions/20.html", "label_name": "safe"} {"code": "function parseComplexParam(queryParams: Object, keys: Object, value: any): void {\n let currentParams = queryParams;\n let keysLastIndex = keys.length - 1;\n for (let j = 0; j <= keysLastIndex; j++) {\n let key = keys[j] === '' ? currentParams.length : keys[j];\n if (j < keysLastIndex) {\n // The value has to be an array or a false value\n // It can happen that the value is no array if the key was repeated with traditional style like `list=1&list[]=2`\n let prevValue = !currentParams[key] || typeof currentParams[key] === 'object' ? currentParams[key] : [currentParams[key]];\n currentParams = currentParams[key] = prevValue || (isNaN(keys[j + 1]) ? {} : []);\n } else {\n currentParams = currentParams[key] = value;\n }\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": "TEST_F(NgramKernelTest, TestNoTokens) {\n MakeOp(\"|\", {3}, \"L\", \"R\", -1, false);\n // Batch items are:\n // 0:\n // 1: \"a\"\n AddInputFromArray(TensorShape({1}), {\"a\"});\n AddInputFromArray(TensorShape({3}), {0, 0, 1});\n TF_ASSERT_OK(RunOpKernel());\n\n std::vector expected_values(\n {\"L|L|R\", \"L|R|R\", // no input in first split\n \"L|L|a\", \"L|a|R\", \"a|R|R\"}); // second split\n std::vector expected_splits({0, 2, 5});\n\n assert_string_equal(expected_values, *GetOutput(0));\n assert_int64_equal(expected_splits, *GetOutput(1));\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-476", "cwe_name": "NULL Pointer Dereference", "description": "A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.", "url": "https://cwe.mitre.org/data/definitions/476.html", "label_name": "safe"} {"code": "module.exports = (env) => {\n const toReplace = Object.keys(env).filter((envVar) => {\n // https://github.com/semantic-release/semantic-release/issues/1558\n if (envVar === 'GOPRIVATE') {\n return false;\n }\n\n return /token|password|credential|secret|private/i.test(envVar) && size(env[envVar].trim()) >= SECRET_MIN_SIZE;\n });\n\n const regexp = new RegExp(toReplace.map((envVar) => escapeRegExp(env[envVar])).join('|'), 'g');\n return (output) =>\n output && isString(output) && toReplace.length > 0 ? output.toString().replace(regexp, SECRET_REPLACEMENT) : output;\n};", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-116", "cwe_name": "Improper Encoding or Escaping of Output", "description": "The software prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.", "url": "https://cwe.mitre.org/data/definitions/116.html", "label_name": "vulnerable"} {"code": "function has(target, path) {\n \"use strict\";\n try {\n var test = reduce(target, path);\n if ( typeof test !== \"undefined\") {\n return true;\n }\n return false;\n } catch(ex) {\n console.error(ex);\n return;\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-915", "cwe_name": "Improperly Controlled Modification of Dynamically-Determined Object Attributes", "description": "The software receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.", "url": "https://cwe.mitre.org/data/definitions/915.html", "label_name": "vulnerable"} {"code": " privPEM = genOpenSSLECDSAPriv(oid, ecpub, ecpriv);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n }\n\n const privComment = readString(data, data._pos, true);\n if (privComment === undefined)\n return new Error('Malformed OpenSSH private key');\n\n keys.push(\n new OpenSSH_Private(type, privComment, privPEM, pubPEM, pubSSH, algo,\n decrypted)\n );\n }", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": " 'X-Parse-Session-Token': user5.getSessionToken(),\n })\n ).data.find.edges.map(object => object.node.someField)\n ).toEqual(['someValue3']);\n });", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-863", "cwe_name": "Incorrect Authorization", "description": "The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.", "url": "https://cwe.mitre.org/data/definitions/863.html", "label_name": "safe"} {"code": "\t\tcsrfTag: await createCsrfTag(ctx),\n\t};\n\tview.cssFiles = ['index/upgrade'];\n\treturn view;\n});", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-352", "cwe_name": "Cross-Site Request Forgery (CSRF)", "description": "The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.", "url": "https://cwe.mitre.org/data/definitions/352.html", "label_name": "safe"} {"code": " function copyAndExtractDriver(buf)\n {\n var file = fs.openSync( INSTALLER_FILE, 'w');\n var len = fs.writeSync( file, buf, 0, buf.length, 0 );\n if( len != buf.length ) \n {\n console.log( \"Error writing IBM ODBC and CLI Driver to a file\" );\n process.exit(1);\n }\n fs.closeSync( file );\n if(platform == 'win32') \n {\n readStream = fs.createReadStream(INSTALLER_FILE);\n writeStream = fstream.Writer(DOWNLOAD_DIR);\n\n readStream.pipe(unzip.Parse()).pipe(writeStream);\n console.log('Download and extraction of DB2 ODBC ' +\n 'CLI Driver completed successfully ...');\n console.log(license_agreement);\n } \n else \n {\n var targz = require('targz');\n var compress = targz.decompress({src: INSTALLER_FILE, dest: \"DOWNLOAD_DIR\"}, function(err){\n if(err) {\n console.log(err);\n process.exit(1);\n }\n else {\n console.log('Download and extraction of DB2 ODBC ' +\n 'CLI Driver completed successfully ...');\n console.log(license_agreement);\n IBM_DB_HOME = path.resolve(DOWNLOAD_DIR, 'clidriver');\n process.env.IBM_DB_HOME = IBM_DB_HOME.replace(/\\s/g,'\\\\ ');\n buildBinary(true);\n removeWinBuildArchive();\n }\n\t });\n }\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-310", "cwe_name": "Cryptographic Issues", "description": "Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.", "url": "https://cwe.mitre.org/data/definitions/310.html", "label_name": "vulnerable"} {"code": " closeSocket() {\n if (this.dataSocket) {\n const socket = this.dataSocket;\n this.dataSocket.end(() => socket.destroy());\n this.dataSocket = null;\n }\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-918", "cwe_name": "Server-Side Request Forgery (SSRF)", "description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "url": "https://cwe.mitre.org/data/definitions/918.html", "label_name": "vulnerable"} {"code": " void addPathParam(String name, String value, boolean encoded) {\n if (relativeUrl == null) {\n // The relative URL is cleared when the first query parameter is set.\n throw new AssertionError();\n }\n String replacement = canonicalizeForPath(value, encoded);\n String newRelativeUrl = relativeUrl.replace(\"{\" + name + \"}\", replacement);\n if (PATH_TRAVERSAL.matcher(newRelativeUrl).matches()) {\n throw new IllegalArgumentException(\n \"@Path parameters shouldn't perform path traversal ('.' or '..'): \" + value);\n }\n relativeUrl = newRelativeUrl;\n }", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-22", "cwe_name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", "description": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.", "url": "https://cwe.mitre.org/data/definitions/22.html", "label_name": "safe"} {"code": " other_senders_count: Math.max(0, all_senders.length - MAX_AVATAR),\n other_sender_names_html,\n muted,\n topic_muted,\n participated: topic_data.participated,\n full_last_msg_date_time: full_datetime,\n };\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-79", "cwe_name": "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')", "description": "The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.", "url": "https://cwe.mitre.org/data/definitions/79.html", "label_name": "safe"} {"code": "function genOpenSSLRSAPub(n, e) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption\n // algorithm parameters (RSA has none)\n asnWriter.writeNull();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.startSequence();\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"} {"code": "export function protocolInit(): void {\n // get all args except `hidden` as it'd mean the app would not get focused\n // XXX: passing args to protocol handlers only works on Windows, so unpackaged deep-linking\n // --profile/--profile-dir are passed via the SEARCH_PARAM var in the callback url\n const args = process.argv.slice(1).filter(arg => arg !== \"--hidden\" && arg !== \"-hidden\");\n if (app.isPackaged) {\n app.setAsDefaultProtocolClient('element', process.execPath, args);\n } else if (process.platform === 'win32') { // on Mac/Linux this would just cause the electron binary to open\n // special handler for running without being packaged, e.g `electron .` by passing our app path to electron\n app.setAsDefaultProtocolClient('element', process.execPath, [app.getAppPath(), ...args]);\n }\n\n if (process.platform === 'darwin') {\n // Protocol handler for macos\n app.on('open-url', function(ev, url) {\n ev.preventDefault();\n processUrl(url);\n });\n } else {\n // Protocol handler for win32/Linux\n app.on('second-instance', (ev, commandLine) => {\n const url = commandLine[commandLine.length - 1];\n if (!url.startsWith(PROTOCOL)) return;\n processUrl(url);\n });\n }\n}", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-416", "cwe_name": "Use After Free", "description": "Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.", "url": "https://cwe.mitre.org/data/definitions/416.html", "label_name": "vulnerable"} {"code": " getUrl() {\n return `http://localhost:${this.port}`\n }", "label": 0, "programming_language": "TypeScript", "cwe_id": "CWE-306", "cwe_name": "Missing Authentication for Critical Function", "description": "The software does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.", "url": "https://cwe.mitre.org/data/definitions/306.html", "label_name": "vulnerable"} {"code": " : new GenericDecipherNative(config));\n }\n }", "label": 1, "programming_language": "TypeScript", "cwe_id": "CWE-78", "cwe_name": "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')", "description": "The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.", "url": "https://cwe.mitre.org/data/definitions/78.html", "label_name": "safe"}