prompt
stringclasses 1
value | completions
listlengths 2
1.33k
| labels
listlengths 2
1.33k
| source
stringclasses 1
value | other_info
dict | index
int64 0
719
| cwe
stringclasses 9
values | language
stringclasses 6
values |
|---|---|---|---|---|---|---|---|
Determine whether the {function_name} code is vulnerable or not.
|
[
"long dd_get_item_size(struct dump_dir *dd, const char *name)\n{",
"",
" long size = -1;\n char *iname = concat_path_file(dd->dd_dirname, name);\n struct stat statbuf;",
" if (lstat(iname, &statbuf) == 0 && S_ISREG(statbuf.st_mode))\n size = statbuf.st_size;\n else\n {\n if (errno == ENOENT)\n size = 0;\n else\n perror_msg(\"Can't get size of file '%s'\", iname);\n }",
" free(iname);",
" return size;\n}"
] |
[
1,
0,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 196,
"char_start": 67,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot get item size. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_get_item_size",
"line_changes": {
"added": [
{
"char_end": 103,
"char_start": 63,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 3
},
{
"char_end": 191,
"char_start": 103,
"line": " error_msg_and_die(\"Cannot get item size. '%s' is not a valid file name\", name);\n",
"line_no": 4
},
{
"char_end": 192,
"char_start": 191,
"line": "\n",
"line_no": 5
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 0
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"long dd_get_item_size(struct dump_dir *dd, const char *name)\n{",
" if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot get item size. '%s' is not a valid file name\", name);\n",
" long size = -1;\n char *iname = concat_path_file(dd->dd_dirname, name);\n struct stat statbuf;",
" if (lstat(iname, &statbuf) == 0 && S_ISREG(statbuf.st_mode))\n size = statbuf.st_size;\n else\n {\n if (errno == ENOENT)\n size = 0;\n else\n perror_msg(\"Can't get size of file '%s'\", iname);\n }",
" free(iname);",
" return size;\n}"
] |
[
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 196,
"char_start": 67,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot get item size. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_get_item_size",
"line_changes": {
"added": [
{
"char_end": 103,
"char_start": 63,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 3
},
{
"char_end": 191,
"char_start": 103,
"line": " error_msg_and_die(\"Cannot get item size. '%s' is not a valid file name\", name);\n",
"line_no": 4
},
{
"char_end": 192,
"char_start": 191,
"line": "\n",
"line_no": 5
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 0
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def zmi_page_request(self, *args, **kwargs):\r\n request = self.REQUEST\r\n RESPONSE = request.RESPONSE\r\n SESSION = request.SESSION\r\n self._zmi_page_request()\r\n RESPONSE.setHeader('Expires',DateTime(request['ZMI_TIME']-10000).toZone('GMT+1').rfc822())\r\n RESPONSE.setHeader('Cache-Control', 'no-cache')\r\n RESPONSE.setHeader('Pragma', 'no-cache')\r\n RESPONSE.setHeader('Content-Type', 'text/html;charset=%s'%request['ZMS_CHARSET'])\r\n if not request.get( 'preview'):\r\n request.set( 'preview','preview')\r\n langs = self.getLanguages(request)\r\n if request.get('lang') not in langs:\r\n request.set('lang',langs[0])\r\n if request.get('manage_lang') not in self.getLocale().get_manage_langs():\r\n request.set('manage_lang',self.get_manage_lang())\r\n if not request.get('manage_tabs_message'):\r\n request.set( 'manage_tabs_message',self.getConfProperty('ZMS.manage_tabs_message',''))\r\n # manage_system\r\n if request.form.has_key('zmi-manage-system'):\r\n request.SESSION.set('zmi-manage-system',int(request.get('zmi-manage-system')))\r\n # avoid declarative urls\r\n physical_path = self.getPhysicalPath()\r\n path_to_handle = request['URL0'][len(request['BASE0']):].split('/')\r\n path = path_to_handle[:-1]\r",
" if len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r",
" for i in range(len(path)):\r\n if path[:-(i+1)] != physical_path[:-(i+1)]:\r\n path[:-(i+1)] = physical_path[:-(i+1)]\r\n new_path = path+[path_to_handle[-1]]\r\n if path_to_handle != new_path:\r\n request.RESPONSE.redirect('/'.join(new_path))"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1363,
"char_start": 1322,
"chars": "self.getDocumentElement().id in path and "
}
],
"deleted": []
},
"commit_link": "github.com/zms-publishing/zms4/commit/3f28620d475220dfdb06f79787158ac50727c61a",
"file_name": "ZMSItem.py",
"func_name": "zmi_page_request",
"line_changes": {
"added": [
{
"char_end": 1436,
"char_start": 1313,
"line": " if self.getDocumentElement().id in path and len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 1395,
"char_start": 1313,
"line": " if len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r\n",
"line_no": 26
}
]
},
"vul_type": "cwe-022"
}
| 1
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def zmi_page_request(self, *args, **kwargs):\r\n request = self.REQUEST\r\n RESPONSE = request.RESPONSE\r\n SESSION = request.SESSION\r\n self._zmi_page_request()\r\n RESPONSE.setHeader('Expires',DateTime(request['ZMI_TIME']-10000).toZone('GMT+1').rfc822())\r\n RESPONSE.setHeader('Cache-Control', 'no-cache')\r\n RESPONSE.setHeader('Pragma', 'no-cache')\r\n RESPONSE.setHeader('Content-Type', 'text/html;charset=%s'%request['ZMS_CHARSET'])\r\n if not request.get( 'preview'):\r\n request.set( 'preview','preview')\r\n langs = self.getLanguages(request)\r\n if request.get('lang') not in langs:\r\n request.set('lang',langs[0])\r\n if request.get('manage_lang') not in self.getLocale().get_manage_langs():\r\n request.set('manage_lang',self.get_manage_lang())\r\n if not request.get('manage_tabs_message'):\r\n request.set( 'manage_tabs_message',self.getConfProperty('ZMS.manage_tabs_message',''))\r\n # manage_system\r\n if request.form.has_key('zmi-manage-system'):\r\n request.SESSION.set('zmi-manage-system',int(request.get('zmi-manage-system')))\r\n # avoid declarative urls\r\n physical_path = self.getPhysicalPath()\r\n path_to_handle = request['URL0'][len(request['BASE0']):].split('/')\r\n path = path_to_handle[:-1]\r",
" if self.getDocumentElement().id in path and len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r",
" for i in range(len(path)):\r\n if path[:-(i+1)] != physical_path[:-(i+1)]:\r\n path[:-(i+1)] = physical_path[:-(i+1)]\r\n new_path = path+[path_to_handle[-1]]\r\n if path_to_handle != new_path:\r\n request.RESPONSE.redirect('/'.join(new_path))"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1363,
"char_start": 1322,
"chars": "self.getDocumentElement().id in path and "
}
],
"deleted": []
},
"commit_link": "github.com/zms-publishing/zms4/commit/3f28620d475220dfdb06f79787158ac50727c61a",
"file_name": "ZMSItem.py",
"func_name": "zmi_page_request",
"line_changes": {
"added": [
{
"char_end": 1436,
"char_start": 1313,
"line": " if self.getDocumentElement().id in path and len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 1395,
"char_start": 1313,
"line": " if len(filter(lambda x:x.find('.')>0 or x.startswith('manage_'),path))==0:\r\n",
"line_no": 26
}
]
},
"vul_type": "cwe-022"
}
| 1
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{",
" return snprintf(dest, destlen, \"%s.hcache\", path);",
"}"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 81,
"char_start": 79,
"chars": "in"
},
{
"char_end": 85,
"char_start": 82,
"chars": " co"
},
{
"char_end": 90,
"char_start": 87,
"chars": "t ="
},
{
"char_end": 387,
"char_start": 133,
"chars": ";\n\n /* Strip out any directories in the path */\n char *first = strchr(dest, '/');\n char *last = strrchr(dest, '/');\n if (first && last && (last > first))\n {\n memmove(first, last, strlen(last) + 1);\n count -= (last - first);\n }\n\n return count"
}
],
"deleted": [
{
"char_end": 81,
"char_start": 79,
"chars": "re"
},
{
"char_end": 84,
"char_start": 83,
"chars": "r"
}
]
},
"commit_link": "github.com/neomutt/neomutt/commit/9bfab35522301794483f8f9ed60820bdec9be59e",
"file_name": "newsrc.c",
"func_name": "nntp_hcache_namer",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 77,
"line": " int count = snprintf(dest, destlen, \"%s.hcache\", path);\n",
"line_no": 3
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 4
},
{
"char_end": 182,
"char_start": 136,
"line": " /* Strip out any directories in the path */\n",
"line_no": 5
},
{
"char_end": 217,
"char_start": 182,
"line": " char *first = strchr(dest, '/');\n",
"line_no": 6
},
{
"char_end": 252,
"char_start": 217,
"line": " char *last = strrchr(dest, '/');\n",
"line_no": 7
},
{
"char_end": 291,
"char_start": 252,
"line": " if (first && last && (last > first))\n",
"line_no": 8
},
{
"char_end": 295,
"char_start": 291,
"line": " {\n",
"line_no": 9
},
{
"char_end": 339,
"char_start": 295,
"line": " memmove(first, last, strlen(last) + 1);\n",
"line_no": 10
},
{
"char_end": 368,
"char_start": 339,
"line": " count -= (last - first);\n",
"line_no": 11
},
{
"char_end": 372,
"char_start": 368,
"line": " }\n",
"line_no": 12
},
{
"char_end": 373,
"char_start": 372,
"line": "\n",
"line_no": 13
},
{
"char_end": 389,
"char_start": 373,
"line": " return count;\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 130,
"char_start": 77,
"line": " return snprintf(dest, destlen, \"%s.hcache\", path);\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 2
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{",
" int count = snprintf(dest, destlen, \"%s.hcache\", path);",
" /* Strip out any directories in the path */\n char *first = strchr(dest, '/');\n char *last = strrchr(dest, '/');\n if (first && last && (last > first))\n {\n memmove(first, last, strlen(last) + 1);\n count -= (last - first);\n }",
" return count;",
"}"
] |
[
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 81,
"char_start": 79,
"chars": "in"
},
{
"char_end": 85,
"char_start": 82,
"chars": " co"
},
{
"char_end": 90,
"char_start": 87,
"chars": "t ="
},
{
"char_end": 387,
"char_start": 133,
"chars": ";\n\n /* Strip out any directories in the path */\n char *first = strchr(dest, '/');\n char *last = strrchr(dest, '/');\n if (first && last && (last > first))\n {\n memmove(first, last, strlen(last) + 1);\n count -= (last - first);\n }\n\n return count"
}
],
"deleted": [
{
"char_end": 81,
"char_start": 79,
"chars": "re"
},
{
"char_end": 84,
"char_start": 83,
"chars": "r"
}
]
},
"commit_link": "github.com/neomutt/neomutt/commit/9bfab35522301794483f8f9ed60820bdec9be59e",
"file_name": "newsrc.c",
"func_name": "nntp_hcache_namer",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 77,
"line": " int count = snprintf(dest, destlen, \"%s.hcache\", path);\n",
"line_no": 3
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 4
},
{
"char_end": 182,
"char_start": 136,
"line": " /* Strip out any directories in the path */\n",
"line_no": 5
},
{
"char_end": 217,
"char_start": 182,
"line": " char *first = strchr(dest, '/');\n",
"line_no": 6
},
{
"char_end": 252,
"char_start": 217,
"line": " char *last = strrchr(dest, '/');\n",
"line_no": 7
},
{
"char_end": 291,
"char_start": 252,
"line": " if (first && last && (last > first))\n",
"line_no": 8
},
{
"char_end": 295,
"char_start": 291,
"line": " {\n",
"line_no": 9
},
{
"char_end": 339,
"char_start": 295,
"line": " memmove(first, last, strlen(last) + 1);\n",
"line_no": 10
},
{
"char_end": 368,
"char_start": 339,
"line": " count -= (last - first);\n",
"line_no": 11
},
{
"char_end": 372,
"char_start": 368,
"line": " }\n",
"line_no": 12
},
{
"char_end": 373,
"char_start": 372,
"line": "\n",
"line_no": 13
},
{
"char_end": 389,
"char_start": 373,
"line": " return count;\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 130,
"char_start": 77,
"line": " return snprintf(dest, destlen, \"%s.hcache\", path);\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 2
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"std::string TarFileReader::extract(const string &_path) {\n if (_path.empty()) THROW(\"path cannot be empty\");\n if (!hasMore()) THROW(\"No more tar files\");",
" string path = _path;",
" if (SystemUtilities::isDirectory(path)) path += \"/\" + getFilename();",
"\n LOG_DEBUG(5, \"Extracting: \" << path);\n",
" return extract(*SystemUtilities::oopen(path));",
"}"
] |
[
1,
1,
0,
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 228,
"char_start": 222,
"chars": "{\n "
},
{
"char_end": 544,
"char_start": 260,
"chars": " // Check that path is under the target directory\n string a = SystemUtilities::getCanonicalPath(_path);\n string b = SystemUtilities::getCanonicalPath(path);\n if (!String::startsWith(b, a))\n THROW(\"Tar path points outside of the extraction directory: \" << path);\n }\n\n "
},
{
"char_end": 652,
"char_start": 585,
"chars": "switch (getType()) {\n case NORMAL_FILE: case CONTIGUOUS_FILE:\n "
},
{
"char_end": 851,
"char_start": 696,
"chars": ");\n case DIRECTORY: SystemUtilities::ensureDirectory(path); break;\n default: THROW(\"Unsupported tar file type \" << getType());\n }\n\n return getFilename("
}
],
"deleted": []
},
"commit_link": "github.com/CauldronDevelopmentLLC/cbang/commit/1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7",
"file_name": "src/cbang/tar/TarFileReader.cpp",
"func_name": "TarFileReader::extract",
"line_changes": {
"added": [
{
"char_end": 224,
"char_start": 180,
"line": " if (SystemUtilities::isDirectory(path)) {\n",
"line_no": 6
},
{
"char_end": 257,
"char_start": 224,
"line": " path += \"/\" + getFilename();\n",
"line_no": 7
},
{
"char_end": 258,
"char_start": 257,
"line": "\n",
"line_no": 8
},
{
"char_end": 368,
"char_start": 311,
"line": " string a = SystemUtilities::getCanonicalPath(_path);\n",
"line_no": 10
},
{
"char_end": 424,
"char_start": 368,
"line": " string b = SystemUtilities::getCanonicalPath(path);\n",
"line_no": 11
},
{
"char_end": 459,
"char_start": 424,
"line": " if (!String::startsWith(b, a))\n",
"line_no": 12
},
{
"char_end": 537,
"char_start": 459,
"line": " THROW(\"Tar path points outside of the extraction directory: \" << path);\n",
"line_no": 13
},
{
"char_end": 541,
"char_start": 537,
"line": " }\n",
"line_no": 14
},
{
"char_end": 606,
"char_start": 583,
"line": " switch (getType()) {\n",
"line_no": 18
},
{
"char_end": 648,
"char_start": 606,
"line": " case NORMAL_FILE: case CONTIGUOUS_FILE:\n",
"line_no": 19
},
{
"char_end": 699,
"char_start": 648,
"line": " return extract(*SystemUtilities::oopen(path));\n",
"line_no": 20
},
{
"char_end": 764,
"char_start": 699,
"line": " case DIRECTORY: SystemUtilities::ensureDirectory(path); break;\n",
"line_no": 21
},
{
"char_end": 825,
"char_start": 764,
"line": " default: THROW(\"Unsupported tar file type \" << getType());\n",
"line_no": 22
},
{
"char_end": 829,
"char_start": 825,
"line": " }\n",
"line_no": 23
},
{
"char_end": 830,
"char_start": 829,
"line": "\n",
"line_no": 24
},
{
"char_end": 854,
"char_start": 830,
"line": " return getFilename();\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 251,
"char_start": 180,
"line": " if (SystemUtilities::isDirectory(path)) path += \"/\" + getFilename();\n",
"line_no": 6
},
{
"char_end": 342,
"char_start": 293,
"line": " return extract(*SystemUtilities::oopen(path));\n",
"line_no": 10
}
]
},
"vul_type": "cwe-022"
}
| 3
|
cwe-022
|
cpp
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"std::string TarFileReader::extract(const string &_path) {\n if (_path.empty()) THROW(\"path cannot be empty\");\n if (!hasMore()) THROW(\"No more tar files\");",
" string path = _path;",
" if (SystemUtilities::isDirectory(path)) {\n path += \"/\" + getFilename();",
" // Check that path is under the target directory\n string a = SystemUtilities::getCanonicalPath(_path);\n string b = SystemUtilities::getCanonicalPath(path);\n if (!String::startsWith(b, a))\n THROW(\"Tar path points outside of the extraction directory: \" << path);\n }",
"\n LOG_DEBUG(5, \"Extracting: \" << path);\n",
" switch (getType()) {\n case NORMAL_FILE: case CONTIGUOUS_FILE:\n return extract(*SystemUtilities::oopen(path));\n case DIRECTORY: SystemUtilities::ensureDirectory(path); break;\n default: THROW(\"Unsupported tar file type \" << getType());\n }",
" return getFilename();",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 228,
"char_start": 222,
"chars": "{\n "
},
{
"char_end": 544,
"char_start": 260,
"chars": " // Check that path is under the target directory\n string a = SystemUtilities::getCanonicalPath(_path);\n string b = SystemUtilities::getCanonicalPath(path);\n if (!String::startsWith(b, a))\n THROW(\"Tar path points outside of the extraction directory: \" << path);\n }\n\n "
},
{
"char_end": 652,
"char_start": 585,
"chars": "switch (getType()) {\n case NORMAL_FILE: case CONTIGUOUS_FILE:\n "
},
{
"char_end": 851,
"char_start": 696,
"chars": ");\n case DIRECTORY: SystemUtilities::ensureDirectory(path); break;\n default: THROW(\"Unsupported tar file type \" << getType());\n }\n\n return getFilename("
}
],
"deleted": []
},
"commit_link": "github.com/CauldronDevelopmentLLC/cbang/commit/1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7",
"file_name": "src/cbang/tar/TarFileReader.cpp",
"func_name": "TarFileReader::extract",
"line_changes": {
"added": [
{
"char_end": 224,
"char_start": 180,
"line": " if (SystemUtilities::isDirectory(path)) {\n",
"line_no": 6
},
{
"char_end": 257,
"char_start": 224,
"line": " path += \"/\" + getFilename();\n",
"line_no": 7
},
{
"char_end": 258,
"char_start": 257,
"line": "\n",
"line_no": 8
},
{
"char_end": 368,
"char_start": 311,
"line": " string a = SystemUtilities::getCanonicalPath(_path);\n",
"line_no": 10
},
{
"char_end": 424,
"char_start": 368,
"line": " string b = SystemUtilities::getCanonicalPath(path);\n",
"line_no": 11
},
{
"char_end": 459,
"char_start": 424,
"line": " if (!String::startsWith(b, a))\n",
"line_no": 12
},
{
"char_end": 537,
"char_start": 459,
"line": " THROW(\"Tar path points outside of the extraction directory: \" << path);\n",
"line_no": 13
},
{
"char_end": 541,
"char_start": 537,
"line": " }\n",
"line_no": 14
},
{
"char_end": 606,
"char_start": 583,
"line": " switch (getType()) {\n",
"line_no": 18
},
{
"char_end": 648,
"char_start": 606,
"line": " case NORMAL_FILE: case CONTIGUOUS_FILE:\n",
"line_no": 19
},
{
"char_end": 699,
"char_start": 648,
"line": " return extract(*SystemUtilities::oopen(path));\n",
"line_no": 20
},
{
"char_end": 764,
"char_start": 699,
"line": " case DIRECTORY: SystemUtilities::ensureDirectory(path); break;\n",
"line_no": 21
},
{
"char_end": 825,
"char_start": 764,
"line": " default: THROW(\"Unsupported tar file type \" << getType());\n",
"line_no": 22
},
{
"char_end": 829,
"char_start": 825,
"line": " }\n",
"line_no": 23
},
{
"char_end": 830,
"char_start": 829,
"line": "\n",
"line_no": 24
},
{
"char_end": 854,
"char_start": 830,
"line": " return getFilename();\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 251,
"char_start": 180,
"line": " if (SystemUtilities::isDirectory(path)) path += \"/\" + getFilename();\n",
"line_no": 6
},
{
"char_end": 342,
"char_start": 293,
"line": " return extract(*SystemUtilities::oopen(path));\n",
"line_no": 10
}
]
},
"vul_type": "cwe-022"
}
| 3
|
cwe-022
|
cpp
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"static void handle_method_call(GDBusConnection *connection,\n const gchar *caller,\n const gchar *object_path,\n const gchar *interface_name,\n const gchar *method_name,\n GVariant *parameters,\n GDBusMethodInvocation *invocation,\n gpointer user_data)\n{\n reset_timeout();",
" uid_t caller_uid;\n GVariant *response;",
" caller_uid = get_caller_uid(connection, invocation, caller);",
" log_notice(\"caller_uid:%ld method:'%s'\", (long)caller_uid, method_name);",
" if (caller_uid == (uid_t) -1)\n return;",
" if (g_strcmp0(method_name, \"NewProblem\") == 0)\n {\n char *error = NULL;\n char *problem_id = handle_new_problem(g_variant_get_child_value(parameters, 0), caller_uid, &error);\n if (!problem_id)\n {\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n free(error);\n return;\n }\n /* else */\n response = g_variant_new(\"(s)\", problem_id);\n g_dbus_method_invocation_return_value(invocation, response);\n free(problem_id);",
" return;\n }",
" if (g_strcmp0(method_name, \"GetProblems\") == 0)\n {\n GList *dirs = get_problem_dirs_for_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n //I was told that g_dbus_method frees the response\n //g_variant_unref(response);\n return;\n }",
" if (g_strcmp0(method_name, \"GetAllProblems\") == 0)\n {\n /*\n - so, we have UID,\n - if it's 0, then we don't have to check anything and just return all directories\n - if uid != 0 then we want to ask for authorization\n */\n if (caller_uid != 0)\n {\n if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") == PolkitYes)\n caller_uid = 0;\n }",
" GList * dirs = get_problem_dirs_for_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);",
" list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"GetForeignProblems\") == 0)\n {\n GList * dirs = get_problem_dirs_not_accessible_by_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"ChownProblemDir\") == 0)\n {\n const gchar *problem_dir;\n g_variant_get(parameters, \"(&s)\", &problem_dir);\n log_notice(\"problem_dir:'%s'\", problem_dir);",
" if (!allowed_problem_dir(problem_dir))\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int dir_fd = dd_openfd(problem_dir);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int ddstat = fdump_dir_stat_for_uid(dir_fd, caller_uid);\n if (ddstat < 0)\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"requested directory does not exist '%s'\", problem_dir);\n }\n else\n {\n perror_msg(\"can't get stat of '%s'\", problem_dir);\n }",
" return_InvalidProblemDir_error(invocation, problem_dir);",
" close(dir_fd);\n return;\n }",
" if (ddstat & DD_STAT_OWNED_BY_UID)\n { //caller seems to be in group with access to this dir, so no action needed\n log_notice(\"caller has access to the requested directory %s\", problem_dir);\n g_dbus_method_invocation_return_value(invocation, NULL);\n close(dir_fd);\n return;\n }",
" if ((ddstat & DD_STAT_ACCESSIBLE_BY_UID) == 0 &&\n polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n {\n log_notice(\"not authorized\");\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.AuthFailure\",\n _(\"Not Authorized\"));\n close(dir_fd);\n return;\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, problem_dir, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);\n if (!dd)\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int chown_res = dd_chown(dd, caller_uid);\n if (chown_res != 0)\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.ChownError\",\n _(\"Chowning directory failed. Check system logs for more details.\"));\n else\n g_dbus_method_invocation_return_value(invocation, NULL);",
" dd_close(dd);\n return;\n }",
" if (g_strcmp0(method_name, \"GetInfo\") == 0)\n {\n /* Parameter tuple is (sas) */",
"\t/* Get 1st param - problem dir name */\n const gchar *problem_dir;\n g_variant_get_child(parameters, 0, \"&s\", &problem_dir);\n log_notice(\"problem_dir:'%s'\", problem_dir);",
" if (!allowed_problem_dir(problem_dir))\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int dir_fd = dd_openfd(problem_dir);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" if (!fdump_dir_accessible_by_uid(dir_fd, caller_uid))\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"Requested directory does not exist '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n close(dir_fd);\n return;\n }",
" if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n {\n log_notice(\"not authorized\");\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.AuthFailure\",\n _(\"Not Authorized\"));\n close(dir_fd);\n return;\n }\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, problem_dir, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);\n if (!dd)\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
"\t/* Get 2nd param - vector of element names */\n GVariant *array = g_variant_get_child_value(parameters, 1);\n GList *elements = string_list_from_variant(array);\n g_variant_unref(array);",
" GVariantBuilder *builder = NULL;\n for (GList *l = elements; l; l = l->next)\n {\n const char *element_name = (const char*)l->data;\n char *value = dd_load_text_ext(dd, element_name, 0\n | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE\n | DD_FAIL_QUIETLY_ENOENT\n | DD_FAIL_QUIETLY_EACCES);\n log_notice(\"element '%s' %s\", element_name, value ? \"fetched\" : \"not found\");\n if (value)\n {\n if (!builder)\n builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);",
" /* g_variant_builder_add makes a copy. No need to xstrdup here */\n g_variant_builder_add(builder, \"{ss}\", element_name, value);\n free(value);\n }\n }\n list_free_with_free(elements);\n dd_close(dd);\n /* It is OK to call g_variant_new(\"(a{ss})\", NULL) because */\n /* G_VARIANT_TYPE_TUPLE allows NULL value */\n GVariant *response = g_variant_new(\"(a{ss})\", builder);",
" if (builder)\n g_variant_builder_unref(builder);",
" log_info(\"GetInfo: returning value for '%s'\", problem_dir);\n g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"SetElement\") == 0)\n {\n const char *problem_id;\n const char *element;\n const char *value;",
" g_variant_get(parameters, \"(&s&s&s)\", &problem_id, &element, &value);\n",
"",
" if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name of '%s'\", element, problem_id);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);",
" free(error);\n return;\n }",
" struct dump_dir *dd = open_directory_for_modification_of_element(\n invocation, caller_uid, problem_id, element);\n if (!dd)\n /* Already logged from open_directory_for_modification_of_element() */\n return;",
" /* Is it good idea to make it static? Is it possible to change the max size while a single run? */\n const double max_dir_size = g_settings_nMaxCrashReportsSize * (1024 * 1024);\n const long item_size = dd_get_item_size(dd, element);\n if (item_size < 0)\n {\n log_notice(\"Can't get size of '%s/%s'\", problem_id, element);\n char *error = xasprintf(_(\"Can't get size of '%s'\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n return;\n }",
" const double requested_size = (double)strlen(value) - item_size;\n /* Don't want to check the size limit in case of reducing of size */\n if (requested_size > 0\n && requested_size > (max_dir_size - get_dirsize(g_settings_dump_location)))\n {\n log_notice(\"No problem space left in '%s' (requested Bytes %f)\", problem_id, requested_size);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n _(\"No problem space left\"));\n }\n else\n {\n dd_save_text(dd, element, value);\n g_dbus_method_invocation_return_value(invocation, NULL);\n }",
" dd_close(dd);",
" return;\n }",
" if (g_strcmp0(method_name, \"DeleteElement\") == 0)\n {\n const char *problem_id;\n const char *element;",
" g_variant_get(parameters, \"(&s&s)\", &problem_id, &element);",
"",
"\n if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name of '%s'\", element, problem_id);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);",
" free(error);\n return;\n }",
" struct dump_dir *dd = open_directory_for_modification_of_element(\n invocation, caller_uid, problem_id, element);\n if (!dd)\n /* Already logged from open_directory_for_modification_of_element() */\n return;",
" const int res = dd_delete_item(dd, element);\n dd_close(dd);",
" if (res != 0)\n {\n log_notice(\"Can't delete the element '%s' from the problem directory '%s'\", element, problem_id);\n char *error = xasprintf(_(\"Can't delete the element '%s' from the problem directory '%s'\"), element, problem_id);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n free(error);\n return;\n }",
"\n g_dbus_method_invocation_return_value(invocation, NULL);\n return;\n }",
" if (g_strcmp0(method_name, \"DeleteProblem\") == 0)\n {\n /* Dbus parameters are always tuples.\n * In this case, it's (as) - a tuple of one element (array of strings).\n * Need to fetch the array:\n */\n GVariant *array = g_variant_get_child_value(parameters, 0);\n GList *problem_dirs = string_list_from_variant(array);\n g_variant_unref(array);",
" for (GList *l = problem_dirs; l; l = l->next)\n {\n const char *dir_name = (const char*)l->data;\n log_notice(\"dir_name:'%s'\", dir_name);\n if (!allowed_problem_dir(dir_name))\n {\n return_InvalidProblemDir_error(invocation, dir_name);\n goto ret;\n }\n }",
" for (GList *l = problem_dirs; l; l = l->next)\n {\n const char *dir_name = (const char*)l->data;",
" int dir_fd = dd_openfd(dir_name);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", dir_name);\n return_InvalidProblemDir_error(invocation, dir_name);\n return;\n }",
" if (!fdump_dir_accessible_by_uid(dir_fd, caller_uid))\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"Requested directory does not exist '%s'\", dir_name);\n close(dir_fd);\n continue;\n }",
" if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n { // if user didn't provide correct credentials, just move to the next dir\n close(dir_fd);\n continue;\n }\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, dir_name, /*flags:*/ 0);\n if (dd)\n {\n if (dd_delete(dd) != 0)\n {\n error_msg(\"Failed to delete problem directory '%s'\", dir_name);\n dd_close(dd);\n }\n }\n }",
" g_dbus_method_invocation_return_value(invocation, NULL);\n ret:\n list_free_with_free(problem_dirs);\n return;\n }",
" if (g_strcmp0(method_name, \"FindProblemByElementInTimeRange\") == 0)\n {\n const gchar *element;\n const gchar *value;\n glong timestamp_from;\n glong timestamp_to;\n gboolean all;",
" g_variant_get_child(parameters, 0, \"&s\", &element);\n g_variant_get_child(parameters, 1, \"&s\", &value);\n g_variant_get_child(parameters, 2, \"x\", ×tamp_from);\n g_variant_get_child(parameters, 3, \"x\", ×tamp_to);\n g_variant_get_child(parameters, 4, \"b\", &all);\n",
"",
" if (all && polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") == PolkitYes)\n caller_uid = 0;",
" GList *dirs = get_problem_dirs_for_element_in_time(caller_uid, element, value, timestamp_from,\n timestamp_to);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"Quit\") == 0)\n {\n g_dbus_method_invocation_return_value(invocation, NULL);\n g_main_loop_quit(loop);\n return;\n }\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 9241,
"char_start": 9086,
"chars": "allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }\n\n if (!"
},
{
"char_end": 11867,
"char_start": 11712,
"chars": "\n\n if (!allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }"
},
{
"char_end": 16546,
"char_start": 16068,
"chars": "\n\n if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name\", element);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);\n\n free(error);\n return;\n }"
}
],
"deleted": []
},
"commit_link": "github.com/abrt/abrt/commit/7a47f57975be0d285a2f20758e4572dca6d9cdd3",
"file_name": "src/dbus/abrt-dbus.c",
"func_name": "handle_method_call",
"line_changes": {
"added": [
{
"char_end": 9119,
"char_start": 9073,
"line": " if (!allowed_problem_dir(problem_id))\n",
"line_no": 259
},
{
"char_end": 9129,
"char_start": 9119,
"line": " {\n",
"line_no": 260
},
{
"char_end": 9197,
"char_start": 9129,
"line": " return_InvalidProblemDir_error(invocation, problem_id);\n",
"line_no": 261
},
{
"char_end": 9217,
"char_start": 9197,
"line": " return;\n",
"line_no": 262
},
{
"char_end": 9227,
"char_start": 9217,
"line": " }\n",
"line_no": 263
},
{
"char_end": 9228,
"char_start": 9227,
"line": "\n",
"line_no": 264
},
{
"char_end": 11760,
"char_start": 11714,
"line": " if (!allowed_problem_dir(problem_id))\n",
"line_no": 324
},
{
"char_end": 11770,
"char_start": 11760,
"line": " {\n",
"line_no": 325
},
{
"char_end": 11838,
"char_start": 11770,
"line": " return_InvalidProblemDir_error(invocation, problem_id);\n",
"line_no": 326
},
{
"char_end": 11858,
"char_start": 11838,
"line": " return;\n",
"line_no": 327
},
{
"char_end": 11868,
"char_start": 11858,
"line": " }\n",
"line_no": 328
},
{
"char_end": 11869,
"char_start": 11868,
"line": "\n",
"line_no": 329
},
{
"char_end": 16117,
"char_start": 16070,
"line": " if (!str_is_correct_filename(element))\n",
"line_no": 447
},
{
"char_end": 16127,
"char_start": 16117,
"line": " {\n",
"line_no": 448
},
{
"char_end": 16196,
"char_start": 16127,
"line": " log_notice(\"'%s' is not a valid element name\", element);\n",
"line_no": 449
},
{
"char_end": 16281,
"char_start": 16196,
"line": " char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n",
"line_no": 450
},
{
"char_end": 16348,
"char_start": 16281,
"line": " g_dbus_method_invocation_return_dbus_error(invocation,\n",
"line_no": 451
},
{
"char_end": 16437,
"char_start": 16348,
"line": " \"org.freedesktop.problems.InvalidElement\",\n",
"line_no": 452
},
{
"char_end": 16491,
"char_start": 16437,
"line": " error);\n",
"line_no": 453
},
{
"char_end": 16492,
"char_start": 16491,
"line": "\n",
"line_no": 454
},
{
"char_end": 16517,
"char_start": 16492,
"line": " free(error);\n",
"line_no": 455
},
{
"char_end": 16537,
"char_start": 16517,
"line": " return;\n",
"line_no": 456
},
{
"char_end": 16547,
"char_start": 16537,
"line": " }\n",
"line_no": 457
},
{
"char_end": 16548,
"char_start": 16547,
"line": "\n",
"line_no": 458
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 4
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"static void handle_method_call(GDBusConnection *connection,\n const gchar *caller,\n const gchar *object_path,\n const gchar *interface_name,\n const gchar *method_name,\n GVariant *parameters,\n GDBusMethodInvocation *invocation,\n gpointer user_data)\n{\n reset_timeout();",
" uid_t caller_uid;\n GVariant *response;",
" caller_uid = get_caller_uid(connection, invocation, caller);",
" log_notice(\"caller_uid:%ld method:'%s'\", (long)caller_uid, method_name);",
" if (caller_uid == (uid_t) -1)\n return;",
" if (g_strcmp0(method_name, \"NewProblem\") == 0)\n {\n char *error = NULL;\n char *problem_id = handle_new_problem(g_variant_get_child_value(parameters, 0), caller_uid, &error);\n if (!problem_id)\n {\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n free(error);\n return;\n }\n /* else */\n response = g_variant_new(\"(s)\", problem_id);\n g_dbus_method_invocation_return_value(invocation, response);\n free(problem_id);",
" return;\n }",
" if (g_strcmp0(method_name, \"GetProblems\") == 0)\n {\n GList *dirs = get_problem_dirs_for_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n //I was told that g_dbus_method frees the response\n //g_variant_unref(response);\n return;\n }",
" if (g_strcmp0(method_name, \"GetAllProblems\") == 0)\n {\n /*\n - so, we have UID,\n - if it's 0, then we don't have to check anything and just return all directories\n - if uid != 0 then we want to ask for authorization\n */\n if (caller_uid != 0)\n {\n if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") == PolkitYes)\n caller_uid = 0;\n }",
" GList * dirs = get_problem_dirs_for_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);",
" list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"GetForeignProblems\") == 0)\n {\n GList * dirs = get_problem_dirs_not_accessible_by_uid(caller_uid, g_settings_dump_location);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"ChownProblemDir\") == 0)\n {\n const gchar *problem_dir;\n g_variant_get(parameters, \"(&s)\", &problem_dir);\n log_notice(\"problem_dir:'%s'\", problem_dir);",
" if (!allowed_problem_dir(problem_dir))\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int dir_fd = dd_openfd(problem_dir);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int ddstat = fdump_dir_stat_for_uid(dir_fd, caller_uid);\n if (ddstat < 0)\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"requested directory does not exist '%s'\", problem_dir);\n }\n else\n {\n perror_msg(\"can't get stat of '%s'\", problem_dir);\n }",
" return_InvalidProblemDir_error(invocation, problem_dir);",
" close(dir_fd);\n return;\n }",
" if (ddstat & DD_STAT_OWNED_BY_UID)\n { //caller seems to be in group with access to this dir, so no action needed\n log_notice(\"caller has access to the requested directory %s\", problem_dir);\n g_dbus_method_invocation_return_value(invocation, NULL);\n close(dir_fd);\n return;\n }",
" if ((ddstat & DD_STAT_ACCESSIBLE_BY_UID) == 0 &&\n polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n {\n log_notice(\"not authorized\");\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.AuthFailure\",\n _(\"Not Authorized\"));\n close(dir_fd);\n return;\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, problem_dir, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);\n if (!dd)\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int chown_res = dd_chown(dd, caller_uid);\n if (chown_res != 0)\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.ChownError\",\n _(\"Chowning directory failed. Check system logs for more details.\"));\n else\n g_dbus_method_invocation_return_value(invocation, NULL);",
" dd_close(dd);\n return;\n }",
" if (g_strcmp0(method_name, \"GetInfo\") == 0)\n {\n /* Parameter tuple is (sas) */",
"\t/* Get 1st param - problem dir name */\n const gchar *problem_dir;\n g_variant_get_child(parameters, 0, \"&s\", &problem_dir);\n log_notice(\"problem_dir:'%s'\", problem_dir);",
" if (!allowed_problem_dir(problem_dir))\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" int dir_fd = dd_openfd(problem_dir);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
" if (!fdump_dir_accessible_by_uid(dir_fd, caller_uid))\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"Requested directory does not exist '%s'\", problem_dir);\n return_InvalidProblemDir_error(invocation, problem_dir);\n close(dir_fd);\n return;\n }",
" if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n {\n log_notice(\"not authorized\");\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.AuthFailure\",\n _(\"Not Authorized\"));\n close(dir_fd);\n return;\n }\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, problem_dir, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES);\n if (!dd)\n {\n return_InvalidProblemDir_error(invocation, problem_dir);\n return;\n }",
"\t/* Get 2nd param - vector of element names */\n GVariant *array = g_variant_get_child_value(parameters, 1);\n GList *elements = string_list_from_variant(array);\n g_variant_unref(array);",
" GVariantBuilder *builder = NULL;\n for (GList *l = elements; l; l = l->next)\n {\n const char *element_name = (const char*)l->data;\n char *value = dd_load_text_ext(dd, element_name, 0\n | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE\n | DD_FAIL_QUIETLY_ENOENT\n | DD_FAIL_QUIETLY_EACCES);\n log_notice(\"element '%s' %s\", element_name, value ? \"fetched\" : \"not found\");\n if (value)\n {\n if (!builder)\n builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);",
" /* g_variant_builder_add makes a copy. No need to xstrdup here */\n g_variant_builder_add(builder, \"{ss}\", element_name, value);\n free(value);\n }\n }\n list_free_with_free(elements);\n dd_close(dd);\n /* It is OK to call g_variant_new(\"(a{ss})\", NULL) because */\n /* G_VARIANT_TYPE_TUPLE allows NULL value */\n GVariant *response = g_variant_new(\"(a{ss})\", builder);",
" if (builder)\n g_variant_builder_unref(builder);",
" log_info(\"GetInfo: returning value for '%s'\", problem_dir);\n g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"SetElement\") == 0)\n {\n const char *problem_id;\n const char *element;\n const char *value;",
" g_variant_get(parameters, \"(&s&s&s)\", &problem_id, &element, &value);\n",
" if (!allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }\n",
" if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name of '%s'\", element, problem_id);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);",
" free(error);\n return;\n }",
" struct dump_dir *dd = open_directory_for_modification_of_element(\n invocation, caller_uid, problem_id, element);\n if (!dd)\n /* Already logged from open_directory_for_modification_of_element() */\n return;",
" /* Is it good idea to make it static? Is it possible to change the max size while a single run? */\n const double max_dir_size = g_settings_nMaxCrashReportsSize * (1024 * 1024);\n const long item_size = dd_get_item_size(dd, element);\n if (item_size < 0)\n {\n log_notice(\"Can't get size of '%s/%s'\", problem_id, element);\n char *error = xasprintf(_(\"Can't get size of '%s'\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n return;\n }",
" const double requested_size = (double)strlen(value) - item_size;\n /* Don't want to check the size limit in case of reducing of size */\n if (requested_size > 0\n && requested_size > (max_dir_size - get_dirsize(g_settings_dump_location)))\n {\n log_notice(\"No problem space left in '%s' (requested Bytes %f)\", problem_id, requested_size);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n _(\"No problem space left\"));\n }\n else\n {\n dd_save_text(dd, element, value);\n g_dbus_method_invocation_return_value(invocation, NULL);\n }",
" dd_close(dd);",
" return;\n }",
" if (g_strcmp0(method_name, \"DeleteElement\") == 0)\n {\n const char *problem_id;\n const char *element;",
" g_variant_get(parameters, \"(&s&s)\", &problem_id, &element);",
"\n if (!allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }",
"\n if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name of '%s'\", element, problem_id);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);",
" free(error);\n return;\n }",
" struct dump_dir *dd = open_directory_for_modification_of_element(\n invocation, caller_uid, problem_id, element);\n if (!dd)\n /* Already logged from open_directory_for_modification_of_element() */\n return;",
" const int res = dd_delete_item(dd, element);\n dd_close(dd);",
" if (res != 0)\n {\n log_notice(\"Can't delete the element '%s' from the problem directory '%s'\", element, problem_id);\n char *error = xasprintf(_(\"Can't delete the element '%s' from the problem directory '%s'\"), element, problem_id);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.Failure\",\n error);\n free(error);\n return;\n }",
"\n g_dbus_method_invocation_return_value(invocation, NULL);\n return;\n }",
" if (g_strcmp0(method_name, \"DeleteProblem\") == 0)\n {\n /* Dbus parameters are always tuples.\n * In this case, it's (as) - a tuple of one element (array of strings).\n * Need to fetch the array:\n */\n GVariant *array = g_variant_get_child_value(parameters, 0);\n GList *problem_dirs = string_list_from_variant(array);\n g_variant_unref(array);",
" for (GList *l = problem_dirs; l; l = l->next)\n {\n const char *dir_name = (const char*)l->data;\n log_notice(\"dir_name:'%s'\", dir_name);\n if (!allowed_problem_dir(dir_name))\n {\n return_InvalidProblemDir_error(invocation, dir_name);\n goto ret;\n }\n }",
" for (GList *l = problem_dirs; l; l = l->next)\n {\n const char *dir_name = (const char*)l->data;",
" int dir_fd = dd_openfd(dir_name);\n if (dir_fd < 0)\n {\n perror_msg(\"can't open problem directory '%s'\", dir_name);\n return_InvalidProblemDir_error(invocation, dir_name);\n return;\n }",
" if (!fdump_dir_accessible_by_uid(dir_fd, caller_uid))\n {\n if (errno == ENOTDIR)\n {\n log_notice(\"Requested directory does not exist '%s'\", dir_name);\n close(dir_fd);\n continue;\n }",
" if (polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") != PolkitYes)\n { // if user didn't provide correct credentials, just move to the next dir\n close(dir_fd);\n continue;\n }\n }",
" struct dump_dir *dd = dd_fdopendir(dir_fd, dir_name, /*flags:*/ 0);\n if (dd)\n {\n if (dd_delete(dd) != 0)\n {\n error_msg(\"Failed to delete problem directory '%s'\", dir_name);\n dd_close(dd);\n }\n }\n }",
" g_dbus_method_invocation_return_value(invocation, NULL);\n ret:\n list_free_with_free(problem_dirs);\n return;\n }",
" if (g_strcmp0(method_name, \"FindProblemByElementInTimeRange\") == 0)\n {\n const gchar *element;\n const gchar *value;\n glong timestamp_from;\n glong timestamp_to;\n gboolean all;",
" g_variant_get_child(parameters, 0, \"&s\", &element);\n g_variant_get_child(parameters, 1, \"&s\", &value);\n g_variant_get_child(parameters, 2, \"x\", ×tamp_from);\n g_variant_get_child(parameters, 3, \"x\", ×tamp_to);\n g_variant_get_child(parameters, 4, \"b\", &all);\n",
" if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name\", element);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);",
" free(error);\n return;\n }\n",
" if (all && polkit_check_authorization_dname(caller, \"org.freedesktop.problems.getall\") == PolkitYes)\n caller_uid = 0;",
" GList *dirs = get_problem_dirs_for_element_in_time(caller_uid, element, value, timestamp_from,\n timestamp_to);\n response = variant_from_string_list(dirs);\n list_free_with_free(dirs);",
" g_dbus_method_invocation_return_value(invocation, response);\n return;\n }",
" if (g_strcmp0(method_name, \"Quit\") == 0)\n {\n g_dbus_method_invocation_return_value(invocation, NULL);\n g_main_loop_quit(loop);\n return;\n }\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 9241,
"char_start": 9086,
"chars": "allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }\n\n if (!"
},
{
"char_end": 11867,
"char_start": 11712,
"chars": "\n\n if (!allowed_problem_dir(problem_id))\n {\n return_InvalidProblemDir_error(invocation, problem_id);\n return;\n }"
},
{
"char_end": 16546,
"char_start": 16068,
"chars": "\n\n if (!str_is_correct_filename(element))\n {\n log_notice(\"'%s' is not a valid element name\", element);\n char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n g_dbus_method_invocation_return_dbus_error(invocation,\n \"org.freedesktop.problems.InvalidElement\",\n error);\n\n free(error);\n return;\n }"
}
],
"deleted": []
},
"commit_link": "github.com/abrt/abrt/commit/7a47f57975be0d285a2f20758e4572dca6d9cdd3",
"file_name": "src/dbus/abrt-dbus.c",
"func_name": "handle_method_call",
"line_changes": {
"added": [
{
"char_end": 9119,
"char_start": 9073,
"line": " if (!allowed_problem_dir(problem_id))\n",
"line_no": 259
},
{
"char_end": 9129,
"char_start": 9119,
"line": " {\n",
"line_no": 260
},
{
"char_end": 9197,
"char_start": 9129,
"line": " return_InvalidProblemDir_error(invocation, problem_id);\n",
"line_no": 261
},
{
"char_end": 9217,
"char_start": 9197,
"line": " return;\n",
"line_no": 262
},
{
"char_end": 9227,
"char_start": 9217,
"line": " }\n",
"line_no": 263
},
{
"char_end": 9228,
"char_start": 9227,
"line": "\n",
"line_no": 264
},
{
"char_end": 11760,
"char_start": 11714,
"line": " if (!allowed_problem_dir(problem_id))\n",
"line_no": 324
},
{
"char_end": 11770,
"char_start": 11760,
"line": " {\n",
"line_no": 325
},
{
"char_end": 11838,
"char_start": 11770,
"line": " return_InvalidProblemDir_error(invocation, problem_id);\n",
"line_no": 326
},
{
"char_end": 11858,
"char_start": 11838,
"line": " return;\n",
"line_no": 327
},
{
"char_end": 11868,
"char_start": 11858,
"line": " }\n",
"line_no": 328
},
{
"char_end": 11869,
"char_start": 11868,
"line": "\n",
"line_no": 329
},
{
"char_end": 16117,
"char_start": 16070,
"line": " if (!str_is_correct_filename(element))\n",
"line_no": 447
},
{
"char_end": 16127,
"char_start": 16117,
"line": " {\n",
"line_no": 448
},
{
"char_end": 16196,
"char_start": 16127,
"line": " log_notice(\"'%s' is not a valid element name\", element);\n",
"line_no": 449
},
{
"char_end": 16281,
"char_start": 16196,
"line": " char *error = xasprintf(_(\"'%s' is not a valid element name\"), element);\n",
"line_no": 450
},
{
"char_end": 16348,
"char_start": 16281,
"line": " g_dbus_method_invocation_return_dbus_error(invocation,\n",
"line_no": 451
},
{
"char_end": 16437,
"char_start": 16348,
"line": " \"org.freedesktop.problems.InvalidElement\",\n",
"line_no": 452
},
{
"char_end": 16491,
"char_start": 16437,
"line": " error);\n",
"line_no": 453
},
{
"char_end": 16492,
"char_start": 16491,
"line": "\n",
"line_no": 454
},
{
"char_end": 16517,
"char_start": 16492,
"line": " free(error);\n",
"line_no": 455
},
{
"char_end": 16537,
"char_start": 16517,
"line": " return;\n",
"line_no": 456
},
{
"char_end": 16547,
"char_start": 16537,
"line": " }\n",
"line_no": 457
},
{
"char_end": 16548,
"char_start": 16547,
"line": "\n",
"line_no": 458
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 4
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def _inject_file_into_fs(fs, path, contents):\n absolute_path = os.path.join(fs, path.lstrip('/'))",
" parent_dir = os.path.dirname(absolute_path)\n utils.execute('mkdir', '-p', parent_dir, run_as_root=True)",
" utils.execute('tee', absolute_path, process_input=contents,\n run_as_root=True)"
] |
[
0,
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 57,
"char_start": 43,
"chars": ", append=False"
},
{
"char_end": 82,
"char_start": 80,
"chars": "_j"
},
{
"char_end": 96,
"char_start": 83,
"chars": "in_and_check_"
},
{
"char_end": 105,
"char_start": 100,
"chars": "_with"
},
{
"char_end": 110,
"char_start": 107,
"chars": "_fs"
},
{
"char_end": 134,
"char_start": 133,
"chars": "\n"
},
{
"char_end": 246,
"char_start": 245,
"chars": "\n"
},
{
"char_end": 264,
"char_start": 250,
"chars": "args = []\n "
},
{
"char_end": 286,
"char_start": 265,
"chars": "f append:\n arg"
},
{
"char_end": 291,
"char_start": 288,
"chars": "app"
},
{
"char_end": 294,
"char_start": 292,
"chars": "nd"
},
{
"char_end": 298,
"char_start": 296,
"chars": "-a"
},
{
"char_end": 304,
"char_start": 299,
"chars": ")\n "
},
{
"char_end": 318,
"char_start": 306,
"chars": "rgs.append(a"
},
{
"char_end": 333,
"char_start": 330,
"chars": ")\n\n"
},
{
"char_end": 351,
"char_start": 334,
"chars": " kwargs = dict("
},
{
"char_end": 435,
"char_start": 392,
"chars": "\n\n utils.execute('tee', *args, **kwargs)"
}
],
"deleted": [
{
"char_end": 69,
"char_start": 67,
"chars": "s."
},
{
"char_end": 76,
"char_start": 73,
"chars": ".jo"
},
{
"char_end": 218,
"char_start": 216,
"chars": "ut"
},
{
"char_end": 220,
"char_start": 219,
"chars": "l"
},
{
"char_end": 224,
"char_start": 222,
"chars": "ex"
},
{
"char_end": 229,
"char_start": 225,
"chars": "cute"
},
{
"char_end": 234,
"char_start": 231,
"chars": "tee"
},
{
"char_end": 236,
"char_start": 235,
"chars": ","
},
{
"char_end": 251,
"char_start": 250,
"chars": ","
},
{
"char_end": 285,
"char_start": 275,
"chars": "\n "
}
]
},
"commit_link": "github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7",
"file_name": "nova/virt/disk/api.py",
"func_name": "_inject_file_into_fs",
"line_changes": {
"added": [
{
"char_end": 60,
"char_start": 0,
"line": "def _inject_file_into_fs(fs, path, contents, append=False):\n",
"line_no": 1
},
{
"char_end": 133,
"char_start": 60,
"line": " absolute_path = _join_and_check_path_within_fs(fs, path.lstrip('/'))\n",
"line_no": 2
},
{
"char_end": 134,
"char_start": 133,
"line": "\n",
"line_no": 3
},
{
"char_end": 246,
"char_start": 245,
"line": "\n",
"line_no": 6
},
{
"char_end": 260,
"char_start": 246,
"line": " args = []\n",
"line_no": 7
},
{
"char_end": 275,
"char_start": 260,
"line": " if append:\n",
"line_no": 8
},
{
"char_end": 301,
"char_start": 275,
"line": " args.append('-a')\n",
"line_no": 9
},
{
"char_end": 332,
"char_start": 301,
"line": " args.append(absolute_path)\n",
"line_no": 10
},
{
"char_end": 333,
"char_start": 332,
"line": "\n",
"line_no": 11
},
{
"char_end": 393,
"char_start": 333,
"line": " kwargs = dict(process_input=contents, run_as_root=True)\n",
"line_no": 12
},
{
"char_end": 394,
"char_start": 393,
"line": "\n",
"line_no": 13
},
{
"char_end": 435,
"char_start": 394,
"line": " utils.execute('tee', *args, **kwargs)\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 276,
"char_start": 212,
"line": " utils.execute('tee', absolute_path, process_input=contents,\n",
"line_no": 5
},
{
"char_end": 303,
"char_start": 276,
"line": " run_as_root=True)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-022"
}
| 5
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def _inject_file_into_fs(fs, path, contents, append=False):\n absolute_path = _join_and_check_path_within_fs(fs, path.lstrip('/'))\n",
" parent_dir = os.path.dirname(absolute_path)\n utils.execute('mkdir', '-p', parent_dir, run_as_root=True)",
"\n args = []\n if append:\n args.append('-a')\n args.append(absolute_path)",
" kwargs = dict(process_input=contents, run_as_root=True)",
" utils.execute('tee', *args, **kwargs)"
] |
[
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 57,
"char_start": 43,
"chars": ", append=False"
},
{
"char_end": 82,
"char_start": 80,
"chars": "_j"
},
{
"char_end": 96,
"char_start": 83,
"chars": "in_and_check_"
},
{
"char_end": 105,
"char_start": 100,
"chars": "_with"
},
{
"char_end": 110,
"char_start": 107,
"chars": "_fs"
},
{
"char_end": 134,
"char_start": 133,
"chars": "\n"
},
{
"char_end": 246,
"char_start": 245,
"chars": "\n"
},
{
"char_end": 264,
"char_start": 250,
"chars": "args = []\n "
},
{
"char_end": 286,
"char_start": 265,
"chars": "f append:\n arg"
},
{
"char_end": 291,
"char_start": 288,
"chars": "app"
},
{
"char_end": 294,
"char_start": 292,
"chars": "nd"
},
{
"char_end": 298,
"char_start": 296,
"chars": "-a"
},
{
"char_end": 304,
"char_start": 299,
"chars": ")\n "
},
{
"char_end": 318,
"char_start": 306,
"chars": "rgs.append(a"
},
{
"char_end": 333,
"char_start": 330,
"chars": ")\n\n"
},
{
"char_end": 351,
"char_start": 334,
"chars": " kwargs = dict("
},
{
"char_end": 435,
"char_start": 392,
"chars": "\n\n utils.execute('tee', *args, **kwargs)"
}
],
"deleted": [
{
"char_end": 69,
"char_start": 67,
"chars": "s."
},
{
"char_end": 76,
"char_start": 73,
"chars": ".jo"
},
{
"char_end": 218,
"char_start": 216,
"chars": "ut"
},
{
"char_end": 220,
"char_start": 219,
"chars": "l"
},
{
"char_end": 224,
"char_start": 222,
"chars": "ex"
},
{
"char_end": 229,
"char_start": 225,
"chars": "cute"
},
{
"char_end": 234,
"char_start": 231,
"chars": "tee"
},
{
"char_end": 236,
"char_start": 235,
"chars": ","
},
{
"char_end": 251,
"char_start": 250,
"chars": ","
},
{
"char_end": 285,
"char_start": 275,
"chars": "\n "
}
]
},
"commit_link": "github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7",
"file_name": "nova/virt/disk/api.py",
"func_name": "_inject_file_into_fs",
"line_changes": {
"added": [
{
"char_end": 60,
"char_start": 0,
"line": "def _inject_file_into_fs(fs, path, contents, append=False):\n",
"line_no": 1
},
{
"char_end": 133,
"char_start": 60,
"line": " absolute_path = _join_and_check_path_within_fs(fs, path.lstrip('/'))\n",
"line_no": 2
},
{
"char_end": 134,
"char_start": 133,
"line": "\n",
"line_no": 3
},
{
"char_end": 246,
"char_start": 245,
"line": "\n",
"line_no": 6
},
{
"char_end": 260,
"char_start": 246,
"line": " args = []\n",
"line_no": 7
},
{
"char_end": 275,
"char_start": 260,
"line": " if append:\n",
"line_no": 8
},
{
"char_end": 301,
"char_start": 275,
"line": " args.append('-a')\n",
"line_no": 9
},
{
"char_end": 332,
"char_start": 301,
"line": " args.append(absolute_path)\n",
"line_no": 10
},
{
"char_end": 333,
"char_start": 332,
"line": "\n",
"line_no": 11
},
{
"char_end": 393,
"char_start": 333,
"line": " kwargs = dict(process_input=contents, run_as_root=True)\n",
"line_no": 12
},
{
"char_end": 394,
"char_start": 393,
"line": "\n",
"line_no": 13
},
{
"char_end": 435,
"char_start": 394,
"line": " utils.execute('tee', *args, **kwargs)\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 276,
"char_start": 212,
"line": " utils.execute('tee', absolute_path, process_input=contents,\n",
"line_no": 5
},
{
"char_end": 303,
"char_start": 276,
"line": " run_as_root=True)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-022"
}
| 5
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"set_interface_var(const char *iface,\n\t\t const char *var, const char *name,\n\t\t uint32_t val)\n{\n\tFILE *fp;\n\tchar spath[64+IFNAMSIZ];\t/* XXX: magic constant */\n\tif (snprintf(spath, sizeof(spath), var, iface) >= sizeof(spath))",
"",
"\t\treturn -1;",
"\tif (access(spath, F_OK) != 0)\n\t\treturn -1;",
"\tfp = fopen(spath, \"w\");\n\tif (!fp) {\n\t\tif (name)\n\t\t\tflog(LOG_ERR, \"failed to set %s (%u) for %s: %s\",\n\t\t\t name, val, iface, strerror(errno));\n\t\treturn -1;\n\t}\n\tfprintf(fp, \"%u\", val);\n\tfclose(fp);",
"\treturn 0;\n}"
] |
[
1,
0,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 325,
"char_start": 240,
"chars": "/* No path traversal */\n\tif (strstr(name, \"..\") || strchr(name, '/'))\n\t\treturn -1;\n\n\t"
}
],
"deleted": []
},
"commit_link": "github.com/reubenhwk/radvd/commit/92e22ca23e52066da2258df8c76a2dca8a428bcc",
"file_name": "device-linux.c",
"func_name": "set_interface_var",
"line_changes": {
"added": [
{
"char_end": 264,
"char_start": 239,
"line": "\t/* No path traversal */\n",
"line_no": 10
},
{
"char_end": 310,
"char_start": 264,
"line": "\tif (strstr(name, \"..\") || strchr(name, '/'))\n",
"line_no": 11
},
{
"char_end": 323,
"char_start": 310,
"line": "\t\treturn -1;\n",
"line_no": 12
},
{
"char_end": 324,
"char_start": 323,
"line": "\n",
"line_no": 13
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 6
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"set_interface_var(const char *iface,\n\t\t const char *var, const char *name,\n\t\t uint32_t val)\n{\n\tFILE *fp;\n\tchar spath[64+IFNAMSIZ];\t/* XXX: magic constant */\n\tif (snprintf(spath, sizeof(spath), var, iface) >= sizeof(spath))",
"\t\treturn -1;",
"\t/* No path traversal */\n\tif (strstr(name, \"..\") || strchr(name, '/'))",
"\t\treturn -1;",
"\tif (access(spath, F_OK) != 0)\n\t\treturn -1;",
"\tfp = fopen(spath, \"w\");\n\tif (!fp) {\n\t\tif (name)\n\t\t\tflog(LOG_ERR, \"failed to set %s (%u) for %s: %s\",\n\t\t\t name, val, iface, strerror(errno));\n\t\treturn -1;\n\t}\n\tfprintf(fp, \"%u\", val);\n\tfclose(fp);",
"\treturn 0;\n}"
] |
[
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 325,
"char_start": 240,
"chars": "/* No path traversal */\n\tif (strstr(name, \"..\") || strchr(name, '/'))\n\t\treturn -1;\n\n\t"
}
],
"deleted": []
},
"commit_link": "github.com/reubenhwk/radvd/commit/92e22ca23e52066da2258df8c76a2dca8a428bcc",
"file_name": "device-linux.c",
"func_name": "set_interface_var",
"line_changes": {
"added": [
{
"char_end": 264,
"char_start": 239,
"line": "\t/* No path traversal */\n",
"line_no": 10
},
{
"char_end": 310,
"char_start": 264,
"line": "\tif (strstr(name, \"..\") || strchr(name, '/'))\n",
"line_no": 11
},
{
"char_end": 323,
"char_start": 310,
"line": "\t\treturn -1;\n",
"line_no": 12
},
{
"char_end": 324,
"char_start": 323,
"line": "\n",
"line_no": 13
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 6
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def cut(self, key):\n try:",
" self.etcd.delete(os.path.join(self.namespace, key))",
" except etcd.EtcdKeyNotFound:\n return False\n except etcd.EtcdException as err:\n log_error(\"Error removing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to cut key')\n return True"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 72,
"char_start": 71,
"chars": "_"
},
{
"char_end": 79,
"char_start": 73,
"chars": "bsolut"
},
{
"char_end": 82,
"char_start": 80,
"chars": "_k"
},
{
"char_end": 85,
"char_start": 83,
"chars": "y("
}
],
"deleted": [
{
"char_end": 79,
"char_start": 66,
"chars": "os.path.join("
},
{
"char_end": 85,
"char_start": 84,
"chars": "n"
},
{
"char_end": 88,
"char_start": 86,
"chars": "me"
},
{
"char_end": 92,
"char_start": 89,
"chars": "pac"
},
{
"char_end": 95,
"char_start": 93,
"chars": ", "
}
]
},
"commit_link": "github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4",
"file_name": "custodia/store/etcdstore.py",
"func_name": "cut",
"line_changes": {
"added": [
{
"char_end": 91,
"char_start": 37,
"line": " self.etcd.delete(self._absolute_key(key))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 101,
"char_start": 37,
"line": " self.etcd.delete(os.path.join(self.namespace, key))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 7
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def cut(self, key):\n try:",
" self.etcd.delete(self._absolute_key(key))",
" except etcd.EtcdKeyNotFound:\n return False\n except etcd.EtcdException as err:\n log_error(\"Error removing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to cut key')\n return True"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 72,
"char_start": 71,
"chars": "_"
},
{
"char_end": 79,
"char_start": 73,
"chars": "bsolut"
},
{
"char_end": 82,
"char_start": 80,
"chars": "_k"
},
{
"char_end": 85,
"char_start": 83,
"chars": "y("
}
],
"deleted": [
{
"char_end": 79,
"char_start": 66,
"chars": "os.path.join("
},
{
"char_end": 85,
"char_start": 84,
"chars": "n"
},
{
"char_end": 88,
"char_start": 86,
"chars": "me"
},
{
"char_end": 92,
"char_start": 89,
"chars": "pac"
},
{
"char_end": 95,
"char_start": 93,
"chars": ", "
}
]
},
"commit_link": "github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4",
"file_name": "custodia/store/etcdstore.py",
"func_name": "cut",
"line_changes": {
"added": [
{
"char_end": 91,
"char_start": 37,
"line": " self.etcd.delete(self._absolute_key(key))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 101,
"char_start": 37,
"line": " self.etcd.delete(os.path.join(self.namespace, key))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 7
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"wiki_handle_http_request(HttpRequest *req)\n{\n HttpResponse *res = http_response_new(req);\n char *page = http_request_get_path_info(req); \n char *command = http_request_get_query_string(req); \n char *wikitext = \"\";",
" util_dehttpize(page); \t/* remove any encoding on the requested\n\t\t\t\t page name. */",
" if (!strcmp(page, \"/\"))\n {\n if (access(\"WikiHome\", R_OK) != 0)\n\twiki_redirect(res, \"/WikiHome?create\");\n page = \"/WikiHome\";\n }",
" if (!strcmp(page, \"/styles.css\"))\n {\n /* Return CSS page */\n http_response_set_content_type(res, \"text/css\");\n http_response_printf(res, \"%s\", CssData);\n http_response_send(res);\n exit(0);\n }",
" if (!strcmp(page, \"/favicon.ico\"))\n {\n /* Return favicon */\n http_response_set_content_type(res, \"image/ico\");\n http_response_set_data(res, FaviconData, FaviconDataLen);\n http_response_send(res);\n exit(0);\n }",
"\n page = page + 1; \t\t/* skip slash */",
" if (!strncmp(page, \"api/\", 4))\n {\n char *p;",
" page += 4; \n for (p=page; *p != '\\0'; p++)\n\tif (*p=='?') { *p ='\\0'; break; }\n \n wiki_handle_rest_call(req, res, page); \n exit(0);\n }",
" /* A little safety. issue a malformed request for any paths,\n * There shouldn't need to be any..\n */",
" if (strchr(page, '/'))",
" {\n http_response_set_status(res, 404, \"Not Found\");\n http_response_printf(res, \"<html><body>404 Not Found</body></html>\\n\");\n http_response_send(res);\n exit(0);\n }",
" if (!strcmp(page, \"Changes\"))\n {\n wiki_show_changes_page(res);\n }\n else if (!strcmp(page, \"ChangesRss\"))\n {\n wiki_show_changes_page_rss(res);\n }\n else if (!strcmp(page, \"Search\"))\n {\n wiki_show_search_results_page(res, http_request_param_get(req, \"expr\"));\n }\n else if (!strcmp(page, \"Create\"))\n {\n if ( (wikitext = http_request_param_get(req, \"title\")) != NULL)\n\t{\n\t /* create page and redirect */\n\t wiki_redirect(res, http_request_param_get(req, \"title\"));\n\t}\n else\n\t{\n\t /* show create page form */\n\t wiki_show_create_page(res);\n\t}\n }\n else\n {\n /* TODO: dont blindly write wikitext data to disk */\n if ( (wikitext = http_request_param_get(req, \"wikitext\")) != NULL)\n\t{\n\t file_write(page, wikitext);\t \n\t}",
" if (access(page, R_OK) == 0) \t/* page exists */\n\t{\n\t wikitext = file_read(page);\n\t \n\t if (!strcmp(command, \"edit\"))\n\t {\n\t /* print edit page */\n\t wiki_show_edit_page(res, wikitext, page);\n\t }\n\t else\n\t {\n\t wiki_show_page(res, wikitext, page);\n\t }\n\t}\n else\n\t{\n\t if (!strcmp(command, \"create\"))\n\t {\n\t wiki_show_edit_page(res, NULL, page);\n\t }\n\t else\n\t {\n\t char buf[1024];\n\t snprintf(buf, 1024, \"%s?create\", page);\n\t wiki_redirect(res, buf);\n\t }\n\t}\n }",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1368,
"char_start": 1356,
"chars": "!page_name_i"
},
{
"char_end": 1374,
"char_start": 1369,
"chars": "_good"
}
],
"deleted": [
{
"char_end": 1362,
"char_start": 1357,
"chars": "trchr"
},
{
"char_end": 1372,
"char_start": 1367,
"chars": ", '/'"
}
]
},
"commit_link": "github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea",
"file_name": "src/wiki.c",
"func_name": "wiki_handle_http_request",
"line_changes": {
"added": [
{
"char_end": 1382,
"char_start": 1350,
"line": " if (!page_name_is_good(page))\n",
"line_no": 54
}
],
"deleted": [
{
"char_end": 1375,
"char_start": 1350,
"line": " if (strchr(page, '/'))\n",
"line_no": 54
}
]
},
"vul_type": "cwe-022"
}
| 8
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"wiki_handle_http_request(HttpRequest *req)\n{\n HttpResponse *res = http_response_new(req);\n char *page = http_request_get_path_info(req); \n char *command = http_request_get_query_string(req); \n char *wikitext = \"\";",
" util_dehttpize(page); \t/* remove any encoding on the requested\n\t\t\t\t page name. */",
" if (!strcmp(page, \"/\"))\n {\n if (access(\"WikiHome\", R_OK) != 0)\n\twiki_redirect(res, \"/WikiHome?create\");\n page = \"/WikiHome\";\n }",
" if (!strcmp(page, \"/styles.css\"))\n {\n /* Return CSS page */\n http_response_set_content_type(res, \"text/css\");\n http_response_printf(res, \"%s\", CssData);\n http_response_send(res);\n exit(0);\n }",
" if (!strcmp(page, \"/favicon.ico\"))\n {\n /* Return favicon */\n http_response_set_content_type(res, \"image/ico\");\n http_response_set_data(res, FaviconData, FaviconDataLen);\n http_response_send(res);\n exit(0);\n }",
"\n page = page + 1; \t\t/* skip slash */",
" if (!strncmp(page, \"api/\", 4))\n {\n char *p;",
" page += 4; \n for (p=page; *p != '\\0'; p++)\n\tif (*p=='?') { *p ='\\0'; break; }\n \n wiki_handle_rest_call(req, res, page); \n exit(0);\n }",
" /* A little safety. issue a malformed request for any paths,\n * There shouldn't need to be any..\n */",
" if (!page_name_is_good(page))",
" {\n http_response_set_status(res, 404, \"Not Found\");\n http_response_printf(res, \"<html><body>404 Not Found</body></html>\\n\");\n http_response_send(res);\n exit(0);\n }",
" if (!strcmp(page, \"Changes\"))\n {\n wiki_show_changes_page(res);\n }\n else if (!strcmp(page, \"ChangesRss\"))\n {\n wiki_show_changes_page_rss(res);\n }\n else if (!strcmp(page, \"Search\"))\n {\n wiki_show_search_results_page(res, http_request_param_get(req, \"expr\"));\n }\n else if (!strcmp(page, \"Create\"))\n {\n if ( (wikitext = http_request_param_get(req, \"title\")) != NULL)\n\t{\n\t /* create page and redirect */\n\t wiki_redirect(res, http_request_param_get(req, \"title\"));\n\t}\n else\n\t{\n\t /* show create page form */\n\t wiki_show_create_page(res);\n\t}\n }\n else\n {\n /* TODO: dont blindly write wikitext data to disk */\n if ( (wikitext = http_request_param_get(req, \"wikitext\")) != NULL)\n\t{\n\t file_write(page, wikitext);\t \n\t}",
" if (access(page, R_OK) == 0) \t/* page exists */\n\t{\n\t wikitext = file_read(page);\n\t \n\t if (!strcmp(command, \"edit\"))\n\t {\n\t /* print edit page */\n\t wiki_show_edit_page(res, wikitext, page);\n\t }\n\t else\n\t {\n\t wiki_show_page(res, wikitext, page);\n\t }\n\t}\n else\n\t{\n\t if (!strcmp(command, \"create\"))\n\t {\n\t wiki_show_edit_page(res, NULL, page);\n\t }\n\t else\n\t {\n\t char buf[1024];\n\t snprintf(buf, 1024, \"%s?create\", page);\n\t wiki_redirect(res, buf);\n\t }\n\t}\n }",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1368,
"char_start": 1356,
"chars": "!page_name_i"
},
{
"char_end": 1374,
"char_start": 1369,
"chars": "_good"
}
],
"deleted": [
{
"char_end": 1362,
"char_start": 1357,
"chars": "trchr"
},
{
"char_end": 1372,
"char_start": 1367,
"chars": ", '/'"
}
]
},
"commit_link": "github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea",
"file_name": "src/wiki.c",
"func_name": "wiki_handle_http_request",
"line_changes": {
"added": [
{
"char_end": 1382,
"char_start": 1350,
"line": " if (!page_name_is_good(page))\n",
"line_no": 54
}
],
"deleted": [
{
"char_end": 1375,
"char_start": 1350,
"line": " if (strchr(page, '/'))\n",
"line_no": 54
}
]
},
"vul_type": "cwe-022"
}
| 8
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def candidate_paths_for_url(self, url):\n for root, prefix in self.directories:\n if url.startswith(prefix):",
" yield os.path.join(root, url[len(prefix):])"
] |
[
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 151,
"char_start": 145,
"chars": "path ="
},
{
"char_end": 283,
"char_start": 189,
"chars": "\n if os.path.commonprefix((root, path)) == root:\n yield path"
}
],
"deleted": [
{
"char_end": 150,
"char_start": 145,
"chars": "yield"
}
]
},
"commit_link": "github.com/evansd/whitenoise/commit/4d8a3ab1e97d7ddb18b3fa8b4909c92bad5529c6",
"file_name": "whitenoise/base.py",
"func_name": "candidate_paths_for_url",
"line_changes": {
"added": [
{
"char_end": 190,
"char_start": 129,
"line": " path = os.path.join(root, url[len(prefix):])\n",
"line_no": 4
},
{
"char_end": 253,
"char_start": 190,
"line": " if os.path.commonprefix((root, path)) == root:\n",
"line_no": 5
},
{
"char_end": 283,
"char_start": 253,
"line": " yield path\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 188,
"char_start": 129,
"line": " yield os.path.join(root, url[len(prefix):])\n",
"line_no": 4
}
]
},
"vul_type": "cwe-022"
}
| 9
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def candidate_paths_for_url(self, url):\n for root, prefix in self.directories:\n if url.startswith(prefix):",
" path = os.path.join(root, url[len(prefix):])\n if os.path.commonprefix((root, path)) == root:\n yield path"
] |
[
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 151,
"char_start": 145,
"chars": "path ="
},
{
"char_end": 283,
"char_start": 189,
"chars": "\n if os.path.commonprefix((root, path)) == root:\n yield path"
}
],
"deleted": [
{
"char_end": 150,
"char_start": 145,
"chars": "yield"
}
]
},
"commit_link": "github.com/evansd/whitenoise/commit/4d8a3ab1e97d7ddb18b3fa8b4909c92bad5529c6",
"file_name": "whitenoise/base.py",
"func_name": "candidate_paths_for_url",
"line_changes": {
"added": [
{
"char_end": 190,
"char_start": 129,
"line": " path = os.path.join(root, url[len(prefix):])\n",
"line_no": 4
},
{
"char_end": 253,
"char_start": 190,
"line": " if os.path.commonprefix((root, path)) == root:\n",
"line_no": 5
},
{
"char_end": 283,
"char_start": 253,
"line": " yield path\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 188,
"char_start": 129,
"line": " yield os.path.join(root, url[len(prefix):])\n",
"line_no": 4
}
]
},
"vul_type": "cwe-022"
}
| 9
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def updateKey(client):\n\t\"\"\"Updates the contents of a key that already exists in our system.\n\tReturns an error if the specified key doesn't exist for the specified user.\n\t\"\"\"\n\tglobal NOT_FOUND\n\tglobal CREATED",
"\tvalidateClient(client)",
"",
"\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\tvalidateNewKeyData(token_data)",
"",
"\n\t# Use 'w' flag to replace existing key file with the new key data\n\tif os.path.isfile('keys/%s/%s.key' % (client, token_data['name'])):\n\t\twith open('keys/%s/%s.key' % (client, token_data['name']), 'w') as f:\n\t\t\tf.write(token_data['key'])\n\telse:\n\t\traise FoxlockError(NOT_FOUND, \"Key '%s' not found\" % token_data['name'])",
"\treturn 'Key successfully updated', CREATED"
] |
[
1,
1,
0,
1,
0,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 406,
"char_start": 369,
"chars": ")\n\tvalidateKeyName(token_data['name']"
}
],
"deleted": [
{
"char_end": 234,
"char_start": 233,
"chars": "\n"
}
]
},
"commit_link": "github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833",
"file_name": "impl.py",
"func_name": "updateKey",
"line_changes": {
"added": [
{
"char_end": 408,
"char_start": 371,
"line": "\tvalidateKeyName(token_data['name'])\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 234,
"char_start": 233,
"line": "\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 10
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def updateKey(client):\n\t\"\"\"Updates the contents of a key that already exists in our system.\n\tReturns an error if the specified key doesn't exist for the specified user.\n\t\"\"\"\n\tglobal NOT_FOUND\n\tglobal CREATED",
"\tvalidateClient(client)",
"",
"\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\tvalidateNewKeyData(token_data)",
"\tvalidateKeyName(token_data['name'])",
"\n\t# Use 'w' flag to replace existing key file with the new key data\n\tif os.path.isfile('keys/%s/%s.key' % (client, token_data['name'])):\n\t\twith open('keys/%s/%s.key' % (client, token_data['name']), 'w') as f:\n\t\t\tf.write(token_data['key'])\n\telse:\n\t\traise FoxlockError(NOT_FOUND, \"Key '%s' not found\" % token_data['name'])",
"\treturn 'Key successfully updated', CREATED"
] |
[
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 406,
"char_start": 369,
"chars": ")\n\tvalidateKeyName(token_data['name']"
}
],
"deleted": [
{
"char_end": 234,
"char_start": 233,
"chars": "\n"
}
]
},
"commit_link": "github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833",
"file_name": "impl.py",
"func_name": "updateKey",
"line_changes": {
"added": [
{
"char_end": 408,
"char_start": 371,
"line": "\tvalidateKeyName(token_data['name'])\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 234,
"char_start": 233,
"line": "\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 10
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def create_basename_core(basename):\n try:\n basename = basename.casefold()\n except Exception:\n basename = basename.lower()\n",
" basename = basename.replace(' ', '-')",
" basename = re.sub(r'<[^>]*>', r'', basename)\n basename = re.sub(r'[^a-z0-9\\-]', r'', basename)\n basename = re.sub(r'\\-\\-', r'-', basename)\n basename = urllib.parse.quote_plus(basename)",
" return basename"
] |
[
1,
0,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 159,
"char_start": 158,
"chars": "r"
},
{
"char_end": 164,
"char_start": 161,
"chars": "sub"
},
{
"char_end": 166,
"char_start": 165,
"chars": "r"
},
{
"char_end": 168,
"char_start": 167,
"chars": "["
},
{
"char_end": 173,
"char_start": 169,
"chars": "\\./]"
},
{
"char_end": 177,
"char_start": 176,
"chars": "r"
},
{
"char_end": 190,
"char_start": 180,
"chars": ", basename"
}
],
"deleted": [
{
"char_end": 165,
"char_start": 158,
"chars": "basenam"
},
{
"char_end": 175,
"char_start": 168,
"chars": "eplace("
}
]
},
"commit_link": "github.com/syegulalp/mercury/commit/3f7c7442fa49aec37577dbdb47ce11a848e7bd03",
"file_name": "MeTal/core/utils.py",
"func_name": "create_basename_core",
"line_changes": {
"added": [
{
"char_end": 192,
"char_start": 143,
"line": " basename = re.sub(r'[ \\./]', r'-', basename)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 185,
"char_start": 143,
"line": " basename = basename.replace(' ', '-')\n",
"line_no": 7
}
]
},
"vul_type": "cwe-022"
}
| 11
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def create_basename_core(basename):\n try:\n basename = basename.casefold()\n except Exception:\n basename = basename.lower()\n",
" basename = re.sub(r'[ \\./]', r'-', basename)",
" basename = re.sub(r'<[^>]*>', r'', basename)\n basename = re.sub(r'[^a-z0-9\\-]', r'', basename)\n basename = re.sub(r'\\-\\-', r'-', basename)\n basename = urllib.parse.quote_plus(basename)",
" return basename"
] |
[
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 159,
"char_start": 158,
"chars": "r"
},
{
"char_end": 164,
"char_start": 161,
"chars": "sub"
},
{
"char_end": 166,
"char_start": 165,
"chars": "r"
},
{
"char_end": 168,
"char_start": 167,
"chars": "["
},
{
"char_end": 173,
"char_start": 169,
"chars": "\\./]"
},
{
"char_end": 177,
"char_start": 176,
"chars": "r"
},
{
"char_end": 190,
"char_start": 180,
"chars": ", basename"
}
],
"deleted": [
{
"char_end": 165,
"char_start": 158,
"chars": "basenam"
},
{
"char_end": 175,
"char_start": 168,
"chars": "eplace("
}
]
},
"commit_link": "github.com/syegulalp/mercury/commit/3f7c7442fa49aec37577dbdb47ce11a848e7bd03",
"file_name": "MeTal/core/utils.py",
"func_name": "create_basename_core",
"line_changes": {
"added": [
{
"char_end": 192,
"char_start": 143,
"line": " basename = re.sub(r'[ \\./]', r'-', basename)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 185,
"char_start": 143,
"line": " basename = basename.replace(' ', '-')\n",
"line_no": 7
}
]
},
"vul_type": "cwe-022"
}
| 11
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def get(self, key):\n try:",
" result = self.etcd.get(os.path.join(self.namespace, key))",
" except etcd.EtcdException as err:\n log_error(\"Error fetching key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to get key')\n return result.value"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 78,
"char_start": 77,
"chars": "_"
},
{
"char_end": 85,
"char_start": 79,
"chars": "bsolut"
},
{
"char_end": 88,
"char_start": 86,
"chars": "_k"
},
{
"char_end": 91,
"char_start": 89,
"chars": "y("
}
],
"deleted": [
{
"char_end": 85,
"char_start": 72,
"chars": "os.path.join("
},
{
"char_end": 91,
"char_start": 90,
"chars": "n"
},
{
"char_end": 94,
"char_start": 92,
"chars": "me"
},
{
"char_end": 98,
"char_start": 95,
"chars": "pac"
},
{
"char_end": 101,
"char_start": 99,
"chars": ", "
}
]
},
"commit_link": "github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4",
"file_name": "custodia/store/etcdstore.py",
"func_name": "get",
"line_changes": {
"added": [
{
"char_end": 97,
"char_start": 37,
"line": " result = self.etcd.get(self._absolute_key(key))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 107,
"char_start": 37,
"line": " result = self.etcd.get(os.path.join(self.namespace, key))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 12
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def get(self, key):\n try:",
" result = self.etcd.get(self._absolute_key(key))",
" except etcd.EtcdException as err:\n log_error(\"Error fetching key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to get key')\n return result.value"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 78,
"char_start": 77,
"chars": "_"
},
{
"char_end": 85,
"char_start": 79,
"chars": "bsolut"
},
{
"char_end": 88,
"char_start": 86,
"chars": "_k"
},
{
"char_end": 91,
"char_start": 89,
"chars": "y("
}
],
"deleted": [
{
"char_end": 85,
"char_start": 72,
"chars": "os.path.join("
},
{
"char_end": 91,
"char_start": 90,
"chars": "n"
},
{
"char_end": 94,
"char_start": 92,
"chars": "me"
},
{
"char_end": 98,
"char_start": 95,
"chars": "pac"
},
{
"char_end": 101,
"char_start": 99,
"chars": ", "
}
]
},
"commit_link": "github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4",
"file_name": "custodia/store/etcdstore.py",
"func_name": "get",
"line_changes": {
"added": [
{
"char_end": 97,
"char_start": 37,
"line": " result = self.etcd.get(self._absolute_key(key))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 107,
"char_start": 37,
"line": " result = self.etcd.get(os.path.join(self.namespace, key))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-022"
}
| 12
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"PHYSICALPATH_FUNC(mod_alias_physical_handler) {\n\tplugin_data *p = p_d;\n\tint uri_len, basedir_len;\n\tchar *uri_ptr;\n\tsize_t k;",
"\tif (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON;",
"\tmod_alias_patch_connection(srv, con, p);",
"\t/* not to include the tailing slash */\n\tbasedir_len = buffer_string_length(con->physical.basedir);\n\tif ('/' == con->physical.basedir->ptr[basedir_len-1]) --basedir_len;\n\turi_len = buffer_string_length(con->physical.path) - basedir_len;\n\turi_ptr = con->physical.path->ptr + basedir_len;",
"\tfor (k = 0; k < p->conf.alias->used; k++) {\n\t\tdata_string *ds = (data_string *)p->conf.alias->data[k];\n\t\tint alias_len = buffer_string_length(ds->key);",
"\t\tif (alias_len > uri_len) continue;\n\t\tif (buffer_is_empty(ds->key)) continue;",
"\t\tif (0 == (con->conf.force_lowercase_filenames ?\n\t\t\t\t\tstrncasecmp(uri_ptr, ds->key->ptr, alias_len) :\n\t\t\t\t\tstrncmp(uri_ptr, ds->key->ptr, alias_len))) {\n\t\t\t/* matched */\n",
"",
"\t\t\tbuffer_copy_buffer(con->physical.basedir, ds->value);\n\t\t\tbuffer_copy_buffer(srv->tmp_buf, ds->value);\n\t\t\tbuffer_append_string(srv->tmp_buf, uri_ptr + alias_len);\n\t\t\tbuffer_copy_buffer(con->physical.path, srv->tmp_buf);",
"\t\t\treturn HANDLER_GO_ON;\n\t\t}\n\t}",
"\t/* not found */\n\treturn HANDLER_GO_ON;\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1449,
"char_start": 931,
"chars": "/* check for path traversal in url-path following alias if key\n\t\t\t * does not end in slash, but replacement value ends in slash */\n\t\t\tif (uri_ptr[alias_len] == '.') {\n\t\t\t\tchar *s = uri_ptr + alias_len + 1;\n\t\t\t\tif (*s == '.') ++s;\n\t\t\t\tif (*s == '/' || *s == '\\0') {\n\t\t\t\t\tsize_t vlen = buffer_string_length(ds->value);\n\t\t\t\t\tif (0 != alias_len && ds->key->ptr[alias_len-1] != '/'\n\t\t\t\t\t && 0 != vlen && ds->value->ptr[vlen-1] == '/') {\n\t\t\t\t\t\tcon->http_status = 403;\n\t\t\t\t\t\treturn HANDLER_FINISHED;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t"
}
],
"deleted": []
},
"commit_link": "github.com/lighttpd/lighttpd1.4/commit/2105dae0f9d7a964375ce681e53cb165375f84c1",
"file_name": "src/mod_alias.c",
"func_name": "PHYSICALPATH_FUNC",
"line_changes": {
"added": [
{
"char_end": 994,
"char_start": 928,
"line": "\t\t\t/* check for path traversal in url-path following alias if key\n",
"line_no": 29
},
{
"char_end": 1062,
"char_start": 994,
"line": "\t\t\t * does not end in slash, but replacement value ends in slash */\n",
"line_no": 30
},
{
"char_end": 1098,
"char_start": 1062,
"line": "\t\t\tif (uri_ptr[alias_len] == '.') {\n",
"line_no": 31
},
{
"char_end": 1137,
"char_start": 1098,
"line": "\t\t\t\tchar *s = uri_ptr + alias_len + 1;\n",
"line_no": 32
},
{
"char_end": 1161,
"char_start": 1137,
"line": "\t\t\t\tif (*s == '.') ++s;\n",
"line_no": 33
},
{
"char_end": 1196,
"char_start": 1161,
"line": "\t\t\t\tif (*s == '/' || *s == '\\0') {\n",
"line_no": 34
},
{
"char_end": 1248,
"char_start": 1196,
"line": "\t\t\t\t\tsize_t vlen = buffer_string_length(ds->value);\n",
"line_no": 35
},
{
"char_end": 1308,
"char_start": 1248,
"line": "\t\t\t\t\tif (0 != alias_len && ds->key->ptr[alias_len-1] != '/'\n",
"line_no": 36
},
{
"char_end": 1366,
"char_start": 1308,
"line": "\t\t\t\t\t && 0 != vlen && ds->value->ptr[vlen-1] == '/') {\n",
"line_no": 37
},
{
"char_end": 1396,
"char_start": 1366,
"line": "\t\t\t\t\t\tcon->http_status = 403;\n",
"line_no": 38
},
{
"char_end": 1427,
"char_start": 1396,
"line": "\t\t\t\t\t\treturn HANDLER_FINISHED;\n",
"line_no": 39
},
{
"char_end": 1434,
"char_start": 1427,
"line": "\t\t\t\t\t}\n",
"line_no": 40
},
{
"char_end": 1440,
"char_start": 1434,
"line": "\t\t\t\t}\n",
"line_no": 41
},
{
"char_end": 1445,
"char_start": 1440,
"line": "\t\t\t}\n",
"line_no": 42
},
{
"char_end": 1446,
"char_start": 1445,
"line": "\n",
"line_no": 43
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 13
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"PHYSICALPATH_FUNC(mod_alias_physical_handler) {\n\tplugin_data *p = p_d;\n\tint uri_len, basedir_len;\n\tchar *uri_ptr;\n\tsize_t k;",
"\tif (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON;",
"\tmod_alias_patch_connection(srv, con, p);",
"\t/* not to include the tailing slash */\n\tbasedir_len = buffer_string_length(con->physical.basedir);\n\tif ('/' == con->physical.basedir->ptr[basedir_len-1]) --basedir_len;\n\turi_len = buffer_string_length(con->physical.path) - basedir_len;\n\turi_ptr = con->physical.path->ptr + basedir_len;",
"\tfor (k = 0; k < p->conf.alias->used; k++) {\n\t\tdata_string *ds = (data_string *)p->conf.alias->data[k];\n\t\tint alias_len = buffer_string_length(ds->key);",
"\t\tif (alias_len > uri_len) continue;\n\t\tif (buffer_is_empty(ds->key)) continue;",
"\t\tif (0 == (con->conf.force_lowercase_filenames ?\n\t\t\t\t\tstrncasecmp(uri_ptr, ds->key->ptr, alias_len) :\n\t\t\t\t\tstrncmp(uri_ptr, ds->key->ptr, alias_len))) {\n\t\t\t/* matched */\n",
"\t\t\t/* check for path traversal in url-path following alias if key\n\t\t\t * does not end in slash, but replacement value ends in slash */\n\t\t\tif (uri_ptr[alias_len] == '.') {\n\t\t\t\tchar *s = uri_ptr + alias_len + 1;\n\t\t\t\tif (*s == '.') ++s;\n\t\t\t\tif (*s == '/' || *s == '\\0') {\n\t\t\t\t\tsize_t vlen = buffer_string_length(ds->value);\n\t\t\t\t\tif (0 != alias_len && ds->key->ptr[alias_len-1] != '/'\n\t\t\t\t\t && 0 != vlen && ds->value->ptr[vlen-1] == '/') {\n\t\t\t\t\t\tcon->http_status = 403;\n\t\t\t\t\t\treturn HANDLER_FINISHED;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n",
"\t\t\tbuffer_copy_buffer(con->physical.basedir, ds->value);\n\t\t\tbuffer_copy_buffer(srv->tmp_buf, ds->value);\n\t\t\tbuffer_append_string(srv->tmp_buf, uri_ptr + alias_len);\n\t\t\tbuffer_copy_buffer(con->physical.path, srv->tmp_buf);",
"\t\t\treturn HANDLER_GO_ON;\n\t\t}\n\t}",
"\t/* not found */\n\treturn HANDLER_GO_ON;\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1449,
"char_start": 931,
"chars": "/* check for path traversal in url-path following alias if key\n\t\t\t * does not end in slash, but replacement value ends in slash */\n\t\t\tif (uri_ptr[alias_len] == '.') {\n\t\t\t\tchar *s = uri_ptr + alias_len + 1;\n\t\t\t\tif (*s == '.') ++s;\n\t\t\t\tif (*s == '/' || *s == '\\0') {\n\t\t\t\t\tsize_t vlen = buffer_string_length(ds->value);\n\t\t\t\t\tif (0 != alias_len && ds->key->ptr[alias_len-1] != '/'\n\t\t\t\t\t && 0 != vlen && ds->value->ptr[vlen-1] == '/') {\n\t\t\t\t\t\tcon->http_status = 403;\n\t\t\t\t\t\treturn HANDLER_FINISHED;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t"
}
],
"deleted": []
},
"commit_link": "github.com/lighttpd/lighttpd1.4/commit/2105dae0f9d7a964375ce681e53cb165375f84c1",
"file_name": "src/mod_alias.c",
"func_name": "PHYSICALPATH_FUNC",
"line_changes": {
"added": [
{
"char_end": 994,
"char_start": 928,
"line": "\t\t\t/* check for path traversal in url-path following alias if key\n",
"line_no": 29
},
{
"char_end": 1062,
"char_start": 994,
"line": "\t\t\t * does not end in slash, but replacement value ends in slash */\n",
"line_no": 30
},
{
"char_end": 1098,
"char_start": 1062,
"line": "\t\t\tif (uri_ptr[alias_len] == '.') {\n",
"line_no": 31
},
{
"char_end": 1137,
"char_start": 1098,
"line": "\t\t\t\tchar *s = uri_ptr + alias_len + 1;\n",
"line_no": 32
},
{
"char_end": 1161,
"char_start": 1137,
"line": "\t\t\t\tif (*s == '.') ++s;\n",
"line_no": 33
},
{
"char_end": 1196,
"char_start": 1161,
"line": "\t\t\t\tif (*s == '/' || *s == '\\0') {\n",
"line_no": 34
},
{
"char_end": 1248,
"char_start": 1196,
"line": "\t\t\t\t\tsize_t vlen = buffer_string_length(ds->value);\n",
"line_no": 35
},
{
"char_end": 1308,
"char_start": 1248,
"line": "\t\t\t\t\tif (0 != alias_len && ds->key->ptr[alias_len-1] != '/'\n",
"line_no": 36
},
{
"char_end": 1366,
"char_start": 1308,
"line": "\t\t\t\t\t && 0 != vlen && ds->value->ptr[vlen-1] == '/') {\n",
"line_no": 37
},
{
"char_end": 1396,
"char_start": 1366,
"line": "\t\t\t\t\t\tcon->http_status = 403;\n",
"line_no": 38
},
{
"char_end": 1427,
"char_start": 1396,
"line": "\t\t\t\t\t\treturn HANDLER_FINISHED;\n",
"line_no": 39
},
{
"char_end": 1434,
"char_start": 1427,
"line": "\t\t\t\t\t}\n",
"line_no": 40
},
{
"char_end": 1440,
"char_start": 1434,
"line": "\t\t\t\t}\n",
"line_no": 41
},
{
"char_end": 1445,
"char_start": 1440,
"line": "\t\t\t}\n",
"line_no": 42
},
{
"char_end": 1446,
"char_start": 1445,
"line": "\n",
"line_no": 43
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 13
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def download_check_files(self, filelist):\n # only admins and allowed users may download\n if not cherrypy.session['admin']:\n uo = self.useroptions.forUser(self.getUserId())\n if not uo.getOptionValue('media.may_download'):\n return 'not_permitted'\n # make sure nobody tries to escape from basedir\n for f in filelist:",
" if '/../' in f:",
" return 'invalid_file'\n # make sure all files are smaller than maximum download size\n size_limit = cherry.config['media.maximum_download_size']\n try:\n if self.model.file_size_within_limit(filelist, size_limit):\n return 'ok'\n else:\n return 'too_big'\n except OSError as e: # use OSError for python2 compatibility\n return str(e)"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 455,
"char_start": 395,
"chars": "# don't allow to traverse up in the file system\n "
},
{
"char_end": 625,
"char_start": 469,
"chars": " or f.startswith('../'):\n return 'invalid_file'\n # CVE-2015-8309: do not allow absolute file paths\n if os.path.isabs(f)"
}
],
"deleted": []
},
"commit_link": "github.com/devsnd/cherrymusic/commit/62dec34a1ea0741400dd6b6c660d303dcd651e86",
"file_name": "cherrymusicserver/httphandler.py",
"func_name": "download_check_files",
"line_changes": {
"added": [
{
"char_end": 494,
"char_start": 443,
"line": " if '/../' in f or f.startswith('../'):\n",
"line_no": 10
},
{
"char_end": 532,
"char_start": 494,
"line": " return 'invalid_file'\n",
"line_no": 11
},
{
"char_end": 627,
"char_start": 594,
"line": " if os.path.isabs(f):\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 411,
"char_start": 383,
"line": " if '/../' in f:\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 14
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def download_check_files(self, filelist):\n # only admins and allowed users may download\n if not cherrypy.session['admin']:\n uo = self.useroptions.forUser(self.getUserId())\n if not uo.getOptionValue('media.may_download'):\n return 'not_permitted'\n # make sure nobody tries to escape from basedir\n for f in filelist:",
" # don't allow to traverse up in the file system\n if '/../' in f or f.startswith('../'):\n return 'invalid_file'\n # CVE-2015-8309: do not allow absolute file paths\n if os.path.isabs(f):",
" return 'invalid_file'\n # make sure all files are smaller than maximum download size\n size_limit = cherry.config['media.maximum_download_size']\n try:\n if self.model.file_size_within_limit(filelist, size_limit):\n return 'ok'\n else:\n return 'too_big'\n except OSError as e: # use OSError for python2 compatibility\n return str(e)"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 455,
"char_start": 395,
"chars": "# don't allow to traverse up in the file system\n "
},
{
"char_end": 625,
"char_start": 469,
"chars": " or f.startswith('../'):\n return 'invalid_file'\n # CVE-2015-8309: do not allow absolute file paths\n if os.path.isabs(f)"
}
],
"deleted": []
},
"commit_link": "github.com/devsnd/cherrymusic/commit/62dec34a1ea0741400dd6b6c660d303dcd651e86",
"file_name": "cherrymusicserver/httphandler.py",
"func_name": "download_check_files",
"line_changes": {
"added": [
{
"char_end": 494,
"char_start": 443,
"line": " if '/../' in f or f.startswith('../'):\n",
"line_no": 10
},
{
"char_end": 532,
"char_start": 494,
"line": " return 'invalid_file'\n",
"line_no": 11
},
{
"char_end": 627,
"char_start": 594,
"line": " if os.path.isabs(f):\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 411,
"char_start": 383,
"line": " if '/../' in f:\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 14
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def get_files(self, submit_id, password=None, astree=False):\n \"\"\"\n Returns files from a submitted analysis.\n @param password: The password to unlock container archives with\n @param astree: sflock option; determines the format in which the files are returned\n @return: A tree of files\n \"\"\"\n submit = Database().view_submit(submit_id)\n files, duplicates = [], []",
" for data in submit.data[\"data\"]:\n if data[\"type\"] == \"file\":\n filename = Storage.get_filename_from_path(data[\"data\"])",
" filepath = os.path.join(submit.tmp_path, data[\"data\"])\n filedata = open(filepath, \"rb\").read()",
"\n unpacked = sflock.unpack(",
" filepath=filename, contents=filedata,\n password=password, duplicates=duplicates",
" )",
" if astree:",
" unpacked = unpacked.astree()",
"\n files.append(unpacked)\n elif data[\"type\"] == \"url\":\n files.append({\n \"filename\": data[\"data\"],\n \"filepath\": \"\",\n \"relapath\": \"\",\n \"selected\": True,\n \"size\": 0,\n \"type\": \"url\",\n \"package\": \"ie\",\n \"extrpath\": [],\n \"duplicate\": False,\n \"children\": [],\n \"mime\": \"text/html\",\n \"finger\": {\n \"magic_human\": \"url\",\n \"magic\": \"url\"\n }\n })\n else:\n raise RuntimeError(\n \"Unknown data entry type: %s\" % data[\"type\"]\n )\n",
" return {\n \"files\": files,\n \"path\": submit.tmp_path,\n }"
] |
[
1,
1,
0,
1,
0,
1,
1,
0,
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 638,
"char_start": 637,
"chars": "m"
},
{
"char_end": 718,
"char_start": 717,
"chars": "p"
},
{
"char_end": 721,
"char_start": 720,
"chars": "h"
},
{
"char_end": 870,
"char_start": 857,
"chars": "sanitize=True"
}
],
"deleted": [
{
"char_end": 661,
"char_start": 631,
"chars": "data[\"data\"])\n "
},
{
"char_end": 675,
"char_start": 665,
"chars": "data = ope"
},
{
"char_end": 682,
"char_start": 676,
"chars": "(filep"
},
{
"char_end": 694,
"char_start": 683,
"chars": "th, \"rb\").r"
},
{
"char_end": 698,
"char_start": 695,
"chars": "ad("
},
{
"char_end": 796,
"char_start": 776,
"chars": "name, contents=filed"
},
{
"char_end": 799,
"char_start": 798,
"chars": "a"
},
{
"char_end": 820,
"char_start": 800,
"chars": "\n "
},
{
"char_end": 1806,
"char_start": 1791,
"chars": "{\n \""
},
{
"char_end": 1867,
"char_start": 1811,
"chars": "\": files,\n \"path\": submit.tmp_path,\n }"
}
]
},
"commit_link": "github.com/cuckoosandbox/cuckoo/commit/168cabf86730d56b7fa319278bf0f0034052666a",
"file_name": "cuckoo/core/submit.py",
"func_name": "get_files",
"line_changes": {
"added": [
{
"char_end": 641,
"char_start": 574,
"line": " filepath = os.path.join(submit.tmp_path, filename)\n",
"line_no": 14
},
{
"char_end": 764,
"char_start": 684,
"line": " filepath=filepath, password=password, duplicates=duplicates\n",
"line_no": 17
},
{
"char_end": 872,
"char_start": 810,
"line": " unpacked = unpacked.astree(sanitize=True)\n",
"line_no": 21
},
{
"char_end": 1711,
"char_start": 1691,
"line": " return files\n",
"line_no": 47
}
],
"deleted": [
{
"char_end": 645,
"char_start": 574,
"line": " filepath = os.path.join(submit.tmp_path, data[\"data\"])\n",
"line_no": 14
},
{
"char_end": 700,
"char_start": 645,
"line": " filedata = open(filepath, \"rb\").read()\n",
"line_no": 15
},
{
"char_end": 801,
"char_start": 743,
"line": " filepath=filename, contents=filedata,\n",
"line_no": 18
},
{
"char_end": 862,
"char_start": 801,
"line": " password=password, duplicates=duplicates\n",
"line_no": 19
},
{
"char_end": 957,
"char_start": 908,
"line": " unpacked = unpacked.astree()\n",
"line_no": 23
},
{
"char_end": 1793,
"char_start": 1776,
"line": " return {\n",
"line_no": 49
},
{
"char_end": 1821,
"char_start": 1793,
"line": " \"files\": files,\n",
"line_no": 50
},
{
"char_end": 1858,
"char_start": 1821,
"line": " \"path\": submit.tmp_path,\n",
"line_no": 51
},
{
"char_end": 1867,
"char_start": 1858,
"line": " }\n",
"line_no": 52
}
]
},
"vul_type": "cwe-022"
}
| 15
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def get_files(self, submit_id, password=None, astree=False):\n \"\"\"\n Returns files from a submitted analysis.\n @param password: The password to unlock container archives with\n @param astree: sflock option; determines the format in which the files are returned\n @return: A tree of files\n \"\"\"\n submit = Database().view_submit(submit_id)\n files, duplicates = [], []",
" for data in submit.data[\"data\"]:\n if data[\"type\"] == \"file\":\n filename = Storage.get_filename_from_path(data[\"data\"])",
" filepath = os.path.join(submit.tmp_path, filename)",
"\n unpacked = sflock.unpack(",
" filepath=filepath, password=password, duplicates=duplicates",
" )",
" if astree:",
" unpacked = unpacked.astree(sanitize=True)",
"\n files.append(unpacked)\n elif data[\"type\"] == \"url\":\n files.append({\n \"filename\": data[\"data\"],\n \"filepath\": \"\",\n \"relapath\": \"\",\n \"selected\": True,\n \"size\": 0,\n \"type\": \"url\",\n \"package\": \"ie\",\n \"extrpath\": [],\n \"duplicate\": False,\n \"children\": [],\n \"mime\": \"text/html\",\n \"finger\": {\n \"magic_human\": \"url\",\n \"magic\": \"url\"\n }\n })\n else:\n raise RuntimeError(\n \"Unknown data entry type: %s\" % data[\"type\"]\n )\n",
" return files"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 638,
"char_start": 637,
"chars": "m"
},
{
"char_end": 718,
"char_start": 717,
"chars": "p"
},
{
"char_end": 721,
"char_start": 720,
"chars": "h"
},
{
"char_end": 870,
"char_start": 857,
"chars": "sanitize=True"
}
],
"deleted": [
{
"char_end": 661,
"char_start": 631,
"chars": "data[\"data\"])\n "
},
{
"char_end": 675,
"char_start": 665,
"chars": "data = ope"
},
{
"char_end": 682,
"char_start": 676,
"chars": "(filep"
},
{
"char_end": 694,
"char_start": 683,
"chars": "th, \"rb\").r"
},
{
"char_end": 698,
"char_start": 695,
"chars": "ad("
},
{
"char_end": 796,
"char_start": 776,
"chars": "name, contents=filed"
},
{
"char_end": 799,
"char_start": 798,
"chars": "a"
},
{
"char_end": 820,
"char_start": 800,
"chars": "\n "
},
{
"char_end": 1806,
"char_start": 1791,
"chars": "{\n \""
},
{
"char_end": 1867,
"char_start": 1811,
"chars": "\": files,\n \"path\": submit.tmp_path,\n }"
}
]
},
"commit_link": "github.com/cuckoosandbox/cuckoo/commit/168cabf86730d56b7fa319278bf0f0034052666a",
"file_name": "cuckoo/core/submit.py",
"func_name": "get_files",
"line_changes": {
"added": [
{
"char_end": 641,
"char_start": 574,
"line": " filepath = os.path.join(submit.tmp_path, filename)\n",
"line_no": 14
},
{
"char_end": 764,
"char_start": 684,
"line": " filepath=filepath, password=password, duplicates=duplicates\n",
"line_no": 17
},
{
"char_end": 872,
"char_start": 810,
"line": " unpacked = unpacked.astree(sanitize=True)\n",
"line_no": 21
},
{
"char_end": 1711,
"char_start": 1691,
"line": " return files\n",
"line_no": 47
}
],
"deleted": [
{
"char_end": 645,
"char_start": 574,
"line": " filepath = os.path.join(submit.tmp_path, data[\"data\"])\n",
"line_no": 14
},
{
"char_end": 700,
"char_start": 645,
"line": " filedata = open(filepath, \"rb\").read()\n",
"line_no": 15
},
{
"char_end": 801,
"char_start": 743,
"line": " filepath=filename, contents=filedata,\n",
"line_no": 18
},
{
"char_end": 862,
"char_start": 801,
"line": " password=password, duplicates=duplicates\n",
"line_no": 19
},
{
"char_end": 957,
"char_start": 908,
"line": " unpacked = unpacked.astree()\n",
"line_no": 23
},
{
"char_end": 1793,
"char_start": 1776,
"line": " return {\n",
"line_no": 49
},
{
"char_end": 1821,
"char_start": 1793,
"line": " \"files\": files,\n",
"line_no": 50
},
{
"char_end": 1858,
"char_start": 1821,
"line": " \"path\": submit.tmp_path,\n",
"line_no": 51
},
{
"char_end": 1867,
"char_start": 1858,
"line": " }\n",
"line_no": 52
}
]
},
"vul_type": "cwe-022"
}
| 15
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def handle(self, keepalive=True, initial_timeout=None):\n # we are requested to skip processing and keep the previous values\n if self.skip:\n return self.response.handle()",
" # default to no keepalive in case something happens while even trying ensure we have a request\n self.keepalive = False",
" self.headers = HTTPHeaders()",
" # if initial_timeout is set, only wait that long for the initial request line\n if initial_timeout:\n self.connection.settimeout(initial_timeout)\n else:\n self.connection.settimeout(self.timeout)",
" # get request line\n try:\n # ignore empty lines waiting on request\n request = '\\r\\n'\n while request == '\\r\\n':\n request = self.rfile.readline(max_line_size + 1).decode(http_encoding)\n # if read hits timeout or has some other error, ignore the request\n except Exception:\n return True",
" # ignore empty requests\n if not request:\n return True",
" # we have a request, go back to normal timeout\n if initial_timeout:\n self.connection.settimeout(self.timeout)",
" # remove \\r\\n from the end\n self.request_line = request[:-2]",
" # set some reasonable defaults in case the worst happens and we need to tell the client\n self.method = ''\n self.resource = '/'",
" try:\n # HTTP Status 414\n if len(request) > max_line_size:\n raise HTTPError(414)",
" # HTTP Status 400\n if request[-2:] != '\\r\\n':\n raise HTTPError(400)",
" # try the request line and error out if can't parse it\n try:",
" self.method, self.resource, self.request_http = self.request_line.split()",
" # HTTP Status 400\n except ValueError:\n raise HTTPError(400)",
" # HTTP Status 505\n if self.request_http != http_version:\n raise HTTPError(505)",
" # read and parse request headers\n while True:\n line = self.rfile.readline(max_line_size + 1).decode(http_encoding)",
" # hit end of headers\n if line == '\\r\\n':\n break",
" self.headers.add(line)",
" # if we are requested to close the connection after we finish, do so\n if self.headers.get('Connection') == 'close':\n self.keepalive = False\n # else since we are sure we have a request and have read all of the request data, keepalive for more later (if allowed)\n else:\n self.keepalive = keepalive",
" # find a matching regex to handle the request with\n for regex, handler in self.server.routes.items():\n match = regex.match(self.resource)\n if match:\n # create a dictionary of groups\n groups = match.groupdict()\n values = groups.values()",
" for idx, group in enumerate(match.groups()):\n if group not in values:\n groups[idx] = group",
" # create handler\n self.handler = handler(self, self.response, groups)\n break\n # HTTP Status 404\n # if loop is not broken (handler is not found), raise a 404\n else:\n raise HTTPError(404)\n # use DummyHandler so the error is raised again when ready for response\n except Exception as error:\n self.handler = DummyHandler(self, self.response, (), error)\n finally:\n # we finished listening and handling early errors and so let a response class now finish up the job of talking\n return self.response.handle()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1890,
"char_start": 1827,
"chars": ")\n self.resource = urllib.parse.unquote(resource"
}
],
"deleted": [
{
"char_end": 1778,
"char_start": 1773,
"chars": "self."
}
]
},
"commit_link": "github.com/fkmclane/python-fooster-web/commit/80202a6d3788ad1212a162d19785c600025e6aa4",
"file_name": "fooster/web/web.py",
"func_name": "handle",
"line_changes": {
"added": [
{
"char_end": 1829,
"char_start": 1744,
"line": " self.method, resource, self.request_http = self.request_line.split()\n",
"line_no": 53
},
{
"char_end": 1892,
"char_start": 1829,
"line": " self.resource = urllib.parse.unquote(resource)\n",
"line_no": 54
}
],
"deleted": [
{
"char_end": 1834,
"char_start": 1744,
"line": " self.method, self.resource, self.request_http = self.request_line.split()\n",
"line_no": 53
}
]
},
"vul_type": "cwe-022"
}
| 16
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def handle(self, keepalive=True, initial_timeout=None):\n # we are requested to skip processing and keep the previous values\n if self.skip:\n return self.response.handle()",
" # default to no keepalive in case something happens while even trying ensure we have a request\n self.keepalive = False",
" self.headers = HTTPHeaders()",
" # if initial_timeout is set, only wait that long for the initial request line\n if initial_timeout:\n self.connection.settimeout(initial_timeout)\n else:\n self.connection.settimeout(self.timeout)",
" # get request line\n try:\n # ignore empty lines waiting on request\n request = '\\r\\n'\n while request == '\\r\\n':\n request = self.rfile.readline(max_line_size + 1).decode(http_encoding)\n # if read hits timeout or has some other error, ignore the request\n except Exception:\n return True",
" # ignore empty requests\n if not request:\n return True",
" # we have a request, go back to normal timeout\n if initial_timeout:\n self.connection.settimeout(self.timeout)",
" # remove \\r\\n from the end\n self.request_line = request[:-2]",
" # set some reasonable defaults in case the worst happens and we need to tell the client\n self.method = ''\n self.resource = '/'",
" try:\n # HTTP Status 414\n if len(request) > max_line_size:\n raise HTTPError(414)",
" # HTTP Status 400\n if request[-2:] != '\\r\\n':\n raise HTTPError(400)",
" # try the request line and error out if can't parse it\n try:",
" self.method, resource, self.request_http = self.request_line.split()\n self.resource = urllib.parse.unquote(resource)",
" # HTTP Status 400\n except ValueError:\n raise HTTPError(400)",
" # HTTP Status 505\n if self.request_http != http_version:\n raise HTTPError(505)",
" # read and parse request headers\n while True:\n line = self.rfile.readline(max_line_size + 1).decode(http_encoding)",
" # hit end of headers\n if line == '\\r\\n':\n break",
" self.headers.add(line)",
" # if we are requested to close the connection after we finish, do so\n if self.headers.get('Connection') == 'close':\n self.keepalive = False\n # else since we are sure we have a request and have read all of the request data, keepalive for more later (if allowed)\n else:\n self.keepalive = keepalive",
" # find a matching regex to handle the request with\n for regex, handler in self.server.routes.items():\n match = regex.match(self.resource)\n if match:\n # create a dictionary of groups\n groups = match.groupdict()\n values = groups.values()",
" for idx, group in enumerate(match.groups()):\n if group not in values:\n groups[idx] = group",
" # create handler\n self.handler = handler(self, self.response, groups)\n break\n # HTTP Status 404\n # if loop is not broken (handler is not found), raise a 404\n else:\n raise HTTPError(404)\n # use DummyHandler so the error is raised again when ready for response\n except Exception as error:\n self.handler = DummyHandler(self, self.response, (), error)\n finally:\n # we finished listening and handling early errors and so let a response class now finish up the job of talking\n return self.response.handle()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1890,
"char_start": 1827,
"chars": ")\n self.resource = urllib.parse.unquote(resource"
}
],
"deleted": [
{
"char_end": 1778,
"char_start": 1773,
"chars": "self."
}
]
},
"commit_link": "github.com/fkmclane/python-fooster-web/commit/80202a6d3788ad1212a162d19785c600025e6aa4",
"file_name": "fooster/web/web.py",
"func_name": "handle",
"line_changes": {
"added": [
{
"char_end": 1829,
"char_start": 1744,
"line": " self.method, resource, self.request_http = self.request_line.split()\n",
"line_no": 53
},
{
"char_end": 1892,
"char_start": 1829,
"line": " self.resource = urllib.parse.unquote(resource)\n",
"line_no": 54
}
],
"deleted": [
{
"char_end": 1834,
"char_start": 1744,
"line": " self.method, self.resource, self.request_http = self.request_line.split()\n",
"line_no": 53
}
]
},
"vul_type": "cwe-022"
}
| 16
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"int dd_delete_item(struct dump_dir *dd, const char *name)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */",
"",
"\n char *path = concat_path_file(dd->dd_dirname, name);\n int res = unlink(path);",
" if (res < 0)\n {\n if (errno == ENOENT)\n errno = res = 0;\n else\n perror_msg(\"Can't delete file '%s'\", path);\n }",
" free(path);\n return res;\n}"
] |
[
1,
0,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 276,
"char_start": 149,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot delete item. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_delete_item",
"line_changes": {
"added": [
{
"char_end": 185,
"char_start": 145,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 271,
"char_start": 185,
"line": " error_msg_and_die(\"Cannot delete item. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 272,
"char_start": 271,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 17
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"int dd_delete_item(struct dump_dir *dd, const char *name)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */",
"\n if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot delete item. '%s' is not a valid file name\", name);",
"\n char *path = concat_path_file(dd->dd_dirname, name);\n int res = unlink(path);",
" if (res < 0)\n {\n if (errno == ENOENT)\n errno = res = 0;\n else\n perror_msg(\"Can't delete file '%s'\", path);\n }",
" free(path);\n return res;\n}"
] |
[
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 276,
"char_start": 149,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot delete item. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_delete_item",
"line_changes": {
"added": [
{
"char_end": 185,
"char_start": 145,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 271,
"char_start": 185,
"line": " error_msg_and_die(\"Cannot delete item. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 272,
"char_start": 271,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 17
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def render(self, request):\n\t\taction = \"download\"\n\t\tif \"action\" in request.args:\n\t\t\taction = request.args[\"action\"][0]",
"\t\tif \"file\" in request.args:",
"\t\t\tfilename = request.args[\"file\"][0].decode('utf-8', 'ignore').encode('utf-8')\n\t\t\tfilename = re.sub(\"^/+\", \"/\", os.path.realpath(filename))",
"\n\t\t\tif not os.path.exists(filename):\n\t\t\t\treturn \"File '%s' not found\" % (filename)",
"\t\t\tif action == \"stream\":\n\t\t\t\tname = \"stream\"\n\t\t\t\tif \"name\" in request.args:\n\t\t\t\t\tname = request.args[\"name\"][0]",
"\t\t\t\tport = config.OpenWebif.port.value\n\t\t\t\tproto = 'http'\n\t\t\t\tif request.isSecure():\n\t\t\t\t\tport = config.OpenWebif.https_port.value\n\t\t\t\t\tproto = 'https'\n\t\t\t\tourhost = request.getHeader('host')\n\t\t\t\tm = re.match('.+\\:(\\d+)$', ourhost)\n\t\t\t\tif m is not None:\n\t\t\t\t\tport = m.group(1)",
"\t\t\t\tresponse = \"#EXTM3U\\n#EXTVLCOPT--http-reconnect=true\\n#EXTINF:-1,%s\\n%s://%s:%s/file?action=download&file=%s\" % (name, proto, request.getRequestHostname(), port, quote(filename))\n\t\t\t\trequest.setHeader(\"Content-Disposition\", 'attachment;filename=\"%s.m3u\"' % name)\n\t\t\t\trequest.setHeader(\"Content-Type\", \"application/x-mpegurl\")\n\t\t\t\treturn response\n\t\t\telif action == \"delete\":\n\t\t\t\trequest.setResponseCode(http.OK)\n\t\t\t\treturn \"TODO: DELETE FILE: %s\" % (filename)\n\t\t\telif action == \"download\":\n\t\t\t\trequest.setHeader(\"Content-Disposition\", \"attachment;filename=\\\"%s\\\"\" % (filename.split('/')[-1]))\n\t\t\t\trfile = static.File(filename, defaultType = \"application/octet-stream\")\n\t\t\t\treturn rfile.render(request)\n\t\t\telse: \n\t\t\t\treturn \"wrong action parameter\"",
"\t\tif \"dir\" in request.args:\n\t\t\tpath = request.args[\"dir\"][0]\n\t\t\tpattern = '*'\n\t\t\tdata = []\n\t\t\tif \"pattern\" in request.args:\n\t\t\t\tpattern = request.args[\"pattern\"][0]\n\t\t\tdirectories = []\n\t\t\tfiles = []\n\t\t\tif fileExists(path):\n\t\t\t\ttry:\n\t\t\t\t\tfiles = glob.glob(path+'/'+pattern)\n\t\t\t\texcept:\n\t\t\t\t\tfiles = []\n\t\t\t\tfiles.sort()\n\t\t\t\ttmpfiles = files[:]\n\t\t\t\tfor x in tmpfiles:\n\t\t\t\t\tif os.path.isdir(x):\n\t\t\t\t\t\tdirectories.append(x + '/')\n\t\t\t\t\t\tfiles.remove(x)\n\t\t\t\tdata.append({\"result\": True,\"dirs\": directories,\"files\": files})\n\t\t\telse:\n\t\t\t\tdata.append({\"result\": False,\"message\": \"path %s not exits\" % (path)})\n\t\t\trequest.setHeader(\"content-type\", \"application/json; charset=utf-8\")\n\t\t\treturn json.dumps(data, indent=2)"
] |
[
1,
1,
0,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 183,
"char_start": 163,
"chars": "lenient_force_utf_8("
},
{
"char_end": 238,
"char_start": 222,
"chars": "sanitise_filenam"
},
{
"char_end": 240,
"char_start": 239,
"chars": "_"
},
{
"char_end": 247,
"char_start": 241,
"chars": "lashes"
}
],
"deleted": [
{
"char_end": 227,
"char_start": 186,
"chars": ".decode('utf-8', 'ignore').encode('utf-8'"
},
{
"char_end": 244,
"char_start": 243,
"chars": "r"
},
{
"char_end": 246,
"char_start": 245,
"chars": "."
},
{
"char_end": 249,
"char_start": 247,
"chars": "ub"
},
{
"char_end": 262,
"char_start": 250,
"chars": "\"^/+\", \"/\", "
}
]
},
"commit_link": "github.com/E2OpenPlugins/e2openplugin-OpenWebif/commit/a846b7664eda3a4c51a452e00638cf7337dc2013",
"file_name": "plugin/controllers/file.py",
"func_name": "render",
"line_changes": {
"added": [
{
"char_end": 208,
"char_start": 149,
"line": "\t\t\tfilename = lenient_force_utf_8(request.args[\"file\"][0])\n",
"line_no": 7
},
{
"char_end": 276,
"char_start": 208,
"line": "\t\t\tfilename = sanitise_filename_slashes(os.path.realpath(filename))\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 229,
"char_start": 149,
"line": "\t\t\tfilename = request.args[\"file\"][0].decode('utf-8', 'ignore').encode('utf-8')\n",
"line_no": 7
},
{
"char_end": 290,
"char_start": 229,
"line": "\t\t\tfilename = re.sub(\"^/+\", \"/\", os.path.realpath(filename))\n",
"line_no": 8
}
]
},
"vul_type": "cwe-022"
}
| 18
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def render(self, request):\n\t\taction = \"download\"\n\t\tif \"action\" in request.args:\n\t\t\taction = request.args[\"action\"][0]",
"\t\tif \"file\" in request.args:",
"\t\t\tfilename = lenient_force_utf_8(request.args[\"file\"][0])\n\t\t\tfilename = sanitise_filename_slashes(os.path.realpath(filename))",
"\n\t\t\tif not os.path.exists(filename):\n\t\t\t\treturn \"File '%s' not found\" % (filename)",
"\t\t\tif action == \"stream\":\n\t\t\t\tname = \"stream\"\n\t\t\t\tif \"name\" in request.args:\n\t\t\t\t\tname = request.args[\"name\"][0]",
"\t\t\t\tport = config.OpenWebif.port.value\n\t\t\t\tproto = 'http'\n\t\t\t\tif request.isSecure():\n\t\t\t\t\tport = config.OpenWebif.https_port.value\n\t\t\t\t\tproto = 'https'\n\t\t\t\tourhost = request.getHeader('host')\n\t\t\t\tm = re.match('.+\\:(\\d+)$', ourhost)\n\t\t\t\tif m is not None:\n\t\t\t\t\tport = m.group(1)",
"\t\t\t\tresponse = \"#EXTM3U\\n#EXTVLCOPT--http-reconnect=true\\n#EXTINF:-1,%s\\n%s://%s:%s/file?action=download&file=%s\" % (name, proto, request.getRequestHostname(), port, quote(filename))\n\t\t\t\trequest.setHeader(\"Content-Disposition\", 'attachment;filename=\"%s.m3u\"' % name)\n\t\t\t\trequest.setHeader(\"Content-Type\", \"application/x-mpegurl\")\n\t\t\t\treturn response\n\t\t\telif action == \"delete\":\n\t\t\t\trequest.setResponseCode(http.OK)\n\t\t\t\treturn \"TODO: DELETE FILE: %s\" % (filename)\n\t\t\telif action == \"download\":\n\t\t\t\trequest.setHeader(\"Content-Disposition\", \"attachment;filename=\\\"%s\\\"\" % (filename.split('/')[-1]))\n\t\t\t\trfile = static.File(filename, defaultType = \"application/octet-stream\")\n\t\t\t\treturn rfile.render(request)\n\t\t\telse: \n\t\t\t\treturn \"wrong action parameter\"",
"\t\tif \"dir\" in request.args:\n\t\t\tpath = request.args[\"dir\"][0]\n\t\t\tpattern = '*'\n\t\t\tdata = []\n\t\t\tif \"pattern\" in request.args:\n\t\t\t\tpattern = request.args[\"pattern\"][0]\n\t\t\tdirectories = []\n\t\t\tfiles = []\n\t\t\tif fileExists(path):\n\t\t\t\ttry:\n\t\t\t\t\tfiles = glob.glob(path+'/'+pattern)\n\t\t\t\texcept:\n\t\t\t\t\tfiles = []\n\t\t\t\tfiles.sort()\n\t\t\t\ttmpfiles = files[:]\n\t\t\t\tfor x in tmpfiles:\n\t\t\t\t\tif os.path.isdir(x):\n\t\t\t\t\t\tdirectories.append(x + '/')\n\t\t\t\t\t\tfiles.remove(x)\n\t\t\t\tdata.append({\"result\": True,\"dirs\": directories,\"files\": files})\n\t\t\telse:\n\t\t\t\tdata.append({\"result\": False,\"message\": \"path %s not exits\" % (path)})\n\t\t\trequest.setHeader(\"content-type\", \"application/json; charset=utf-8\")\n\t\t\treturn json.dumps(data, indent=2)"
] |
[
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 183,
"char_start": 163,
"chars": "lenient_force_utf_8("
},
{
"char_end": 238,
"char_start": 222,
"chars": "sanitise_filenam"
},
{
"char_end": 240,
"char_start": 239,
"chars": "_"
},
{
"char_end": 247,
"char_start": 241,
"chars": "lashes"
}
],
"deleted": [
{
"char_end": 227,
"char_start": 186,
"chars": ".decode('utf-8', 'ignore').encode('utf-8'"
},
{
"char_end": 244,
"char_start": 243,
"chars": "r"
},
{
"char_end": 246,
"char_start": 245,
"chars": "."
},
{
"char_end": 249,
"char_start": 247,
"chars": "ub"
},
{
"char_end": 262,
"char_start": 250,
"chars": "\"^/+\", \"/\", "
}
]
},
"commit_link": "github.com/E2OpenPlugins/e2openplugin-OpenWebif/commit/a846b7664eda3a4c51a452e00638cf7337dc2013",
"file_name": "plugin/controllers/file.py",
"func_name": "render",
"line_changes": {
"added": [
{
"char_end": 208,
"char_start": 149,
"line": "\t\t\tfilename = lenient_force_utf_8(request.args[\"file\"][0])\n",
"line_no": 7
},
{
"char_end": 276,
"char_start": 208,
"line": "\t\t\tfilename = sanitise_filename_slashes(os.path.realpath(filename))\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 229,
"char_start": 149,
"line": "\t\t\tfilename = request.args[\"file\"][0].decode('utf-8', 'ignore').encode('utf-8')\n",
"line_no": 7
},
{
"char_end": 290,
"char_start": 229,
"line": "\t\t\tfilename = re.sub(\"^/+\", \"/\", os.path.realpath(filename))\n",
"line_no": 8
}
]
},
"vul_type": "cwe-022"
}
| 18
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def _inject_net_into_fs(net, fs, execute=None):\n \"\"\"Inject /etc/network/interfaces into the filesystem rooted at fs.",
" net is the contents of /etc/network/interfaces.\n \"\"\"",
" netdir = os.path.join(os.path.join(fs, 'etc'), 'network')",
" 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)",
" netfile = os.path.join(netdir, 'interfaces')\n utils.execute('tee', netfile, process_input=net, run_as_root=True)"
] |
[
1,
1,
0,
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 196,
"char_start": 194,
"chars": "_j"
},
{
"char_end": 210,
"char_start": 197,
"chars": "in_and_check_"
},
{
"char_end": 216,
"char_start": 214,
"chars": "_w"
},
{
"char_end": 224,
"char_start": 221,
"chars": "_fs"
},
{
"char_end": 431,
"char_start": 430,
"chars": "\n"
},
{
"char_end": 466,
"char_start": 458,
"chars": "'etc', '"
},
{
"char_end": 471,
"char_start": 469,
"chars": "wo"
},
{
"char_end": 474,
"char_start": 472,
"chars": "k'"
},
{
"char_end": 495,
"char_start": 494,
"chars": "_"
},
{
"char_end": 498,
"char_start": 496,
"chars": "nj"
},
{
"char_end": 505,
"char_start": 501,
"chars": "_fil"
},
{
"char_end": 509,
"char_start": 506,
"chars": "_in"
},
{
"char_end": 517,
"char_start": 510,
"chars": "o_fs(fs"
}
],
"deleted": [
{
"char_end": 202,
"char_start": 194,
"chars": "os.path."
},
{
"char_end": 210,
"char_start": 206,
"chars": "(os."
},
{
"char_end": 217,
"char_start": 214,
"chars": ".jo"
},
{
"char_end": 230,
"char_start": 229,
"chars": ")"
},
{
"char_end": 458,
"char_start": 456,
"chars": "di"
},
{
"char_end": 480,
"char_start": 479,
"chars": "u"
},
{
"char_end": 485,
"char_start": 483,
"chars": "s."
},
{
"char_end": 490,
"char_start": 486,
"chars": "xecu"
},
{
"char_end": 492,
"char_start": 491,
"chars": "e"
},
{
"char_end": 498,
"char_start": 493,
"chars": "'tee'"
},
{
"char_end": 523,
"char_start": 509,
"chars": "process_input="
},
{
"char_end": 544,
"char_start": 526,
"chars": ", run_as_root=True"
}
]
},
"commit_link": "github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7",
"file_name": "nova/virt/disk/api.py",
"func_name": "_inject_net_into_fs",
"line_changes": {
"added": [
{
"char_end": 247,
"char_start": 181,
"line": " netdir = _join_and_check_path_within_fs(fs, 'etc', 'network')\n",
"line_no": 6
},
{
"char_end": 431,
"char_start": 430,
"line": "\n",
"line_no": 10
},
{
"char_end": 490,
"char_start": 431,
"line": " netfile = os.path.join('etc', 'network', 'interfaces')\n",
"line_no": 11
},
{
"char_end": 532,
"char_start": 490,
"line": " _inject_file_into_fs(fs, netfile, net)\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 243,
"char_start": 181,
"line": " netdir = os.path.join(os.path.join(fs, 'etc'), 'network')\n",
"line_no": 6
},
{
"char_end": 475,
"char_start": 426,
"line": " netfile = os.path.join(netdir, 'interfaces')\n",
"line_no": 10
},
{
"char_end": 545,
"char_start": 475,
"line": " utils.execute('tee', netfile, process_input=net, run_as_root=True)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-022"
}
| 19
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def _inject_net_into_fs(net, fs, execute=None):\n \"\"\"Inject /etc/network/interfaces into the filesystem rooted at fs.",
" net is the contents of /etc/network/interfaces.\n \"\"\"",
" netdir = _join_and_check_path_within_fs(fs, 'etc', 'network')",
" 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 netfile = os.path.join('etc', 'network', 'interfaces')\n _inject_file_into_fs(fs, netfile, net)"
] |
[
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 196,
"char_start": 194,
"chars": "_j"
},
{
"char_end": 210,
"char_start": 197,
"chars": "in_and_check_"
},
{
"char_end": 216,
"char_start": 214,
"chars": "_w"
},
{
"char_end": 224,
"char_start": 221,
"chars": "_fs"
},
{
"char_end": 431,
"char_start": 430,
"chars": "\n"
},
{
"char_end": 466,
"char_start": 458,
"chars": "'etc', '"
},
{
"char_end": 471,
"char_start": 469,
"chars": "wo"
},
{
"char_end": 474,
"char_start": 472,
"chars": "k'"
},
{
"char_end": 495,
"char_start": 494,
"chars": "_"
},
{
"char_end": 498,
"char_start": 496,
"chars": "nj"
},
{
"char_end": 505,
"char_start": 501,
"chars": "_fil"
},
{
"char_end": 509,
"char_start": 506,
"chars": "_in"
},
{
"char_end": 517,
"char_start": 510,
"chars": "o_fs(fs"
}
],
"deleted": [
{
"char_end": 202,
"char_start": 194,
"chars": "os.path."
},
{
"char_end": 210,
"char_start": 206,
"chars": "(os."
},
{
"char_end": 217,
"char_start": 214,
"chars": ".jo"
},
{
"char_end": 230,
"char_start": 229,
"chars": ")"
},
{
"char_end": 458,
"char_start": 456,
"chars": "di"
},
{
"char_end": 480,
"char_start": 479,
"chars": "u"
},
{
"char_end": 485,
"char_start": 483,
"chars": "s."
},
{
"char_end": 490,
"char_start": 486,
"chars": "xecu"
},
{
"char_end": 492,
"char_start": 491,
"chars": "e"
},
{
"char_end": 498,
"char_start": 493,
"chars": "'tee'"
},
{
"char_end": 523,
"char_start": 509,
"chars": "process_input="
},
{
"char_end": 544,
"char_start": 526,
"chars": ", run_as_root=True"
}
]
},
"commit_link": "github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7",
"file_name": "nova/virt/disk/api.py",
"func_name": "_inject_net_into_fs",
"line_changes": {
"added": [
{
"char_end": 247,
"char_start": 181,
"line": " netdir = _join_and_check_path_within_fs(fs, 'etc', 'network')\n",
"line_no": 6
},
{
"char_end": 431,
"char_start": 430,
"line": "\n",
"line_no": 10
},
{
"char_end": 490,
"char_start": 431,
"line": " netfile = os.path.join('etc', 'network', 'interfaces')\n",
"line_no": 11
},
{
"char_end": 532,
"char_start": 490,
"line": " _inject_file_into_fs(fs, netfile, net)\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 243,
"char_start": 181,
"line": " netdir = os.path.join(os.path.join(fs, 'etc'), 'network')\n",
"line_no": 6
},
{
"char_end": 475,
"char_start": 426,
"line": " netfile = os.path.join(netdir, 'interfaces')\n",
"line_no": 10
},
{
"char_end": 545,
"char_start": 475,
"line": " utils.execute('tee', netfile, process_input=net, run_as_root=True)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-022"
}
| 19
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def canonicalize(self):\n \"\"\"::",
" path = path.canonicalize()\n",
" Canonicalize path. ::",
"\n # \"/foo/baz\"\n Pyjo.Path.new('/foo/./bar/../baz').canonicalize()",
" # \"/../baz\"\n Pyjo.Path.new('/foo/../bar/../../baz').canonicalize()",
"",
" \"\"\"\n parts = self.parts\n i = 0\n while i < len(parts):",
" if parts[i] == '.' or parts[i] == '':",
" parts.pop(i)\n elif i < 1 or parts[i] != '..' or parts[i - 1] == '..':\n i += 1\n else:\n i -= 1\n parts.pop(i)\n parts.pop(i)",
" if not parts:\n self.trailing_slash = False",
" return self"
] |
[
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 124,
"char_start": 108,
"chars": " by resolving ``"
},
{
"char_end": 171,
"char_start": 125,
"chars": "`` and ``..``, in addition ``...`` will be\n "
},
{
"char_end": 232,
"char_start": 172,
"chars": " treated as ``.`` to protect from path traversal attacks."
},
{
"char_end": 494,
"char_start": 411,
"chars": "\n\n # \"/foo/bar\"\n Pyjo.Path.new('/foo/.../bar').canonicalize()"
},
{
"char_end": 624,
"char_start": 606,
"chars": "' or parts[i] == '"
},
{
"char_end": 646,
"char_start": 643,
"chars": "..."
}
],
"deleted": [
{
"char_end": 112,
"char_start": 110,
"chars": "::"
}
]
},
"commit_link": "github.com/dex4er/Pyjoyment/commit/e4b115bc80c41615b2133091af3a74ee5d995c2e",
"file_name": "Pyjo/Path.py",
"func_name": "canonicalize",
"line_changes": {
"added": [
{
"char_end": 168,
"char_start": 83,
"line": " Canonicalize path by resolving ``.`` and ``..``, in addition ``...`` will be\n",
"line_no": 6
},
{
"char_end": 233,
"char_start": 168,
"line": " treated as ``.`` to protect from path traversal attacks.\n",
"line_no": 7
},
{
"char_end": 413,
"char_start": 412,
"line": "\n",
"line_no": 14
},
{
"char_end": 495,
"char_start": 438,
"line": " Pyjo.Path.new('/foo/.../bar').canonicalize()\n",
"line_no": 16
},
{
"char_end": 649,
"char_start": 578,
"line": " if parts[i] == '' or parts[i] == '.' or parts[i] == '...':\n",
"line_no": 21
}
],
"deleted": [
{
"char_end": 113,
"char_start": 83,
"line": " Canonicalize path. ::\n",
"line_no": 6
},
{
"char_end": 425,
"char_start": 375,
"line": " if parts[i] == '.' or parts[i] == '':\n",
"line_no": 17
}
]
},
"vul_type": "cwe-022"
}
| 20
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def canonicalize(self):\n \"\"\"::",
" path = path.canonicalize()\n",
" Canonicalize path by resolving ``.`` and ``..``, in addition ``...`` will be\n treated as ``.`` to protect from path traversal attacks.",
"\n # \"/foo/baz\"\n Pyjo.Path.new('/foo/./bar/../baz').canonicalize()",
" # \"/../baz\"\n Pyjo.Path.new('/foo/../bar/../../baz').canonicalize()",
"\n # \"/foo/bar\"\n Pyjo.Path.new('/foo/.../bar').canonicalize()",
" \"\"\"\n parts = self.parts\n i = 0\n while i < len(parts):",
" if parts[i] == '' or parts[i] == '.' or parts[i] == '...':",
" parts.pop(i)\n elif i < 1 or parts[i] != '..' or parts[i - 1] == '..':\n i += 1\n else:\n i -= 1\n parts.pop(i)\n parts.pop(i)",
" if not parts:\n self.trailing_slash = False",
" return self"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 124,
"char_start": 108,
"chars": " by resolving ``"
},
{
"char_end": 171,
"char_start": 125,
"chars": "`` and ``..``, in addition ``...`` will be\n "
},
{
"char_end": 232,
"char_start": 172,
"chars": " treated as ``.`` to protect from path traversal attacks."
},
{
"char_end": 494,
"char_start": 411,
"chars": "\n\n # \"/foo/bar\"\n Pyjo.Path.new('/foo/.../bar').canonicalize()"
},
{
"char_end": 624,
"char_start": 606,
"chars": "' or parts[i] == '"
},
{
"char_end": 646,
"char_start": 643,
"chars": "..."
}
],
"deleted": [
{
"char_end": 112,
"char_start": 110,
"chars": "::"
}
]
},
"commit_link": "github.com/dex4er/Pyjoyment/commit/e4b115bc80c41615b2133091af3a74ee5d995c2e",
"file_name": "Pyjo/Path.py",
"func_name": "canonicalize",
"line_changes": {
"added": [
{
"char_end": 168,
"char_start": 83,
"line": " Canonicalize path by resolving ``.`` and ``..``, in addition ``...`` will be\n",
"line_no": 6
},
{
"char_end": 233,
"char_start": 168,
"line": " treated as ``.`` to protect from path traversal attacks.\n",
"line_no": 7
},
{
"char_end": 413,
"char_start": 412,
"line": "\n",
"line_no": 14
},
{
"char_end": 495,
"char_start": 438,
"line": " Pyjo.Path.new('/foo/.../bar').canonicalize()\n",
"line_no": 16
},
{
"char_end": 649,
"char_start": 578,
"line": " if parts[i] == '' or parts[i] == '.' or parts[i] == '...':\n",
"line_no": 21
}
],
"deleted": [
{
"char_end": 113,
"char_start": 83,
"line": " Canonicalize path. ::\n",
"line_no": 6
},
{
"char_end": 425,
"char_start": 375,
"line": " if parts[i] == '.' or parts[i] == '':\n",
"line_no": 17
}
]
},
"vul_type": "cwe-022"
}
| 20
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"CString CWebSock::GetSkinPath(const CString& sSkinName) {",
" CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkinName;",
"\n if (!CFile::IsDir(sRet)) {",
" sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkinName;",
"\n if (!CFile::IsDir(sRet)) {",
" sRet = CString(_SKINDIR_) + \"/\" + sSkinName;",
" }\n }",
" return sRet + \"/\";\n}"
] |
[
1,
0,
1,
0,
1,
0,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 140,
"char_start": 62,
"chars": "const CString sSkin = sSkinName.Replace_n(\"/\", \"_\").Replace_n(\".\", \"_\");\n\n "
}
],
"deleted": [
{
"char_end": 128,
"char_start": 124,
"chars": "Name"
},
{
"char_end": 228,
"char_start": 224,
"chars": "Name"
},
{
"char_end": 321,
"char_start": 317,
"chars": "Name"
}
]
},
"commit_link": "github.com/znc/znc/commit/a4a5aeeb17d32937d8c7d743dae9a4cc755ce773",
"file_name": "src/WebModules.cpp",
"func_name": "CWebSock::GetSkinPath",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 58,
"line": " const CString sSkin = sSkinName.Replace_n(\"/\", \"_\").Replace_n(\".\", \"_\");\n",
"line_no": 2
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 136,
"line": " CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkin;\n",
"line_no": 4
},
{
"char_end": 300,
"char_start": 236,
"line": " sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkin;\n",
"line_no": 7
},
{
"char_end": 389,
"char_start": 336,
"line": " sRet = CString(_SKINDIR_) + \"/\" + sSkin;\n",
"line_no": 10
}
],
"deleted": [
{
"char_end": 130,
"char_start": 58,
"line": " CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkinName;\n",
"line_no": 2
},
{
"char_end": 230,
"char_start": 162,
"line": " sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkinName;\n",
"line_no": 5
},
{
"char_end": 323,
"char_start": 266,
"line": " sRet = CString(_SKINDIR_) + \"/\" + sSkinName;\n",
"line_no": 8
}
]
},
"vul_type": "cwe-022"
}
| 21
|
cwe-022
|
cpp
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"CString CWebSock::GetSkinPath(const CString& sSkinName) {",
" const CString sSkin = sSkinName.Replace_n(\"/\", \"_\").Replace_n(\".\", \"_\");",
" CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkin;",
"\n if (!CFile::IsDir(sRet)) {",
" sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkin;",
"\n if (!CFile::IsDir(sRet)) {",
" sRet = CString(_SKINDIR_) + \"/\" + sSkin;",
" }\n }",
" return sRet + \"/\";\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 140,
"char_start": 62,
"chars": "const CString sSkin = sSkinName.Replace_n(\"/\", \"_\").Replace_n(\".\", \"_\");\n\n "
}
],
"deleted": [
{
"char_end": 128,
"char_start": 124,
"chars": "Name"
},
{
"char_end": 228,
"char_start": 224,
"chars": "Name"
},
{
"char_end": 321,
"char_start": 317,
"chars": "Name"
}
]
},
"commit_link": "github.com/znc/znc/commit/a4a5aeeb17d32937d8c7d743dae9a4cc755ce773",
"file_name": "src/WebModules.cpp",
"func_name": "CWebSock::GetSkinPath",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 58,
"line": " const CString sSkin = sSkinName.Replace_n(\"/\", \"_\").Replace_n(\".\", \"_\");\n",
"line_no": 2
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 136,
"line": " CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkin;\n",
"line_no": 4
},
{
"char_end": 300,
"char_start": 236,
"line": " sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkin;\n",
"line_no": 7
},
{
"char_end": 389,
"char_start": 336,
"line": " sRet = CString(_SKINDIR_) + \"/\" + sSkin;\n",
"line_no": 10
}
],
"deleted": [
{
"char_end": 130,
"char_start": 58,
"line": " CString sRet = CZNC::Get().GetZNCPath() + \"/webskins/\" + sSkinName;\n",
"line_no": 2
},
{
"char_end": 230,
"char_start": 162,
"line": " sRet = CZNC::Get().GetCurPath() + \"/webskins/\" + sSkinName;\n",
"line_no": 5
},
{
"char_end": 323,
"char_start": 266,
"line": " sRet = CString(_SKINDIR_) + \"/\" + sSkinName;\n",
"line_no": 8
}
]
},
"vul_type": "cwe-022"
}
| 21
|
cwe-022
|
cpp
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def addKey(client):\n\t\"\"\"Adds a new key with the specified name and contents.\n\tReturns an error if a key with the specified name already exists.\n\t\"\"\"\n\tglobal BAD_REQUEST\n\tglobal CREATED",
"\tvalidateClient(client)",
"",
"\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\tvalidateNewKeyData(token_data)",
"",
"\n\t# Use 'x' flag so we can throw an error if a key with this name already exists\n\ttry:\n\t\twith open('keys/%s/%s.key' % (client, token_data['name']), 'x') as f:\n\t\t\tf.write(token_data['key'])\n\texcept FileExistsError:\n\t\traise FoxlockError(BAD_REQUEST, \"Key '%s' already exists\" % token_data['name'])",
"\treturn 'Key successfully created', CREATED"
] |
[
1,
1,
0,
1,
0,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 383,
"char_start": 346,
"chars": ")\n\tvalidateKeyName(token_data['name']"
}
],
"deleted": [
{
"char_end": 211,
"char_start": 210,
"chars": "\n"
}
]
},
"commit_link": "github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833",
"file_name": "impl.py",
"func_name": "addKey",
"line_changes": {
"added": [
{
"char_end": 385,
"char_start": 348,
"line": "\tvalidateKeyName(token_data['name'])\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 211,
"char_start": 210,
"line": "\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 22
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def addKey(client):\n\t\"\"\"Adds a new key with the specified name and contents.\n\tReturns an error if a key with the specified name already exists.\n\t\"\"\"\n\tglobal BAD_REQUEST\n\tglobal CREATED",
"\tvalidateClient(client)",
"",
"\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\tvalidateNewKeyData(token_data)",
"\tvalidateKeyName(token_data['name'])",
"\n\t# Use 'x' flag so we can throw an error if a key with this name already exists\n\ttry:\n\t\twith open('keys/%s/%s.key' % (client, token_data['name']), 'x') as f:\n\t\t\tf.write(token_data['key'])\n\texcept FileExistsError:\n\t\traise FoxlockError(BAD_REQUEST, \"Key '%s' already exists\" % token_data['name'])",
"\treturn 'Key successfully created', CREATED"
] |
[
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 383,
"char_start": 346,
"chars": ")\n\tvalidateKeyName(token_data['name']"
}
],
"deleted": [
{
"char_end": 211,
"char_start": 210,
"chars": "\n"
}
]
},
"commit_link": "github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833",
"file_name": "impl.py",
"func_name": "addKey",
"line_changes": {
"added": [
{
"char_end": 385,
"char_start": 348,
"line": "\tvalidateKeyName(token_data['name'])\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 211,
"char_start": 210,
"line": "\n",
"line_no": 9
}
]
},
"vul_type": "cwe-022"
}
| 22
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"void dd_save_text(struct dump_dir *dd, const char *name, const char *data)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n",
"",
" char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 291,
"char_start": 166,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_save_text",
"line_changes": {
"added": [
{
"char_end": 202,
"char_start": 162,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 286,
"char_start": 202,
"line": " error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 287,
"char_start": 286,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 23
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"void dd_save_text(struct dump_dir *dd, const char *name, const char *data)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n",
" if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n",
" char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 291,
"char_start": 166,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_save_text",
"line_changes": {
"added": [
{
"char_end": 202,
"char_start": 162,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 286,
"char_start": 202,
"line": " error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 287,
"char_start": 286,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 23
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def misc_file_checks(self):",
" print_header(\"MISC FILE CHECKS\")",
" #\n # Check for recommended and mandatory files\n #",
" filenames = (\"manifest.json\", \"LICENSE\", \"README.md\",\n \"scripts/install\", \"scripts/remove\",\n \"scripts/upgrade\",\n \"scripts/backup\", \"scripts/restore\")\n non_mandatory = (\"script/backup\", \"script/restore\")",
" for filename in filenames:\n if file_exists(self.path + \"/\" + filename):\n continue\n elif filename in non_mandatory:\n print_warning(\"Consider adding a file %s\" % filename)\n else:\n print_error(\"File %s is mandatory\" % filename)",
" #\n # Deprecated php-fpm.ini thing\n #",
" if file_exists(self.path + \"/conf/php-fpm.ini\"):\n print_warning(\n \"Using a separate php-fpm.ini file is deprecated. \"\n \"Please merge your php-fpm directives directly in the pool file. \"\n \"(c.f. https://github.com/YunoHost-Apps/nextcloud_ynh/issues/138 )\"\n )",
" #",
" # Deprecated usage of 'add_header' in nginx conf",
" #",
" for filename in os.listdir(self.path + \"/conf\"):",
" if not os.path.isfile(self.path + \"/conf/\" + filename):",
" continue",
"",
" content = open(self.path + \"/conf/\" + filename).read()\n if \"location\" in content and \"add_header\" in content:\n print_warning(\n \"Do not use 'add_header' in the nginx conf. Use 'more_set_headers' instead. \"\n \"(See https://www.peterbe.com/plog/be-very-careful-with-your-add_header-in-nginx \"\n \"and https://github.com/openresty/headers-more-nginx-module#more_set_headers )\"\n )",
""
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1184,
"char_start": 1153,
"chars": "Analyze nginx conf\n # - "
},
{
"char_end": 1292,
"char_start": 1240,
"chars": " - Spot path traversal issue vulnerability\n #"
},
{
"char_end": 1437,
"char_start": 1363,
"chars": "# Ignore subdirs or filename not containing nginx in the name\n "
},
{
"char_end": 1518,
"char_start": 1491,
"chars": " or \"nginx\" not in filename"
},
{
"char_end": 1606,
"char_start": 1544,
"chars": "\n\n #\n # 'add_header' usage\n #"
},
{
"char_end": 3888,
"char_start": 2089,
"chars": "\n\n #\n # Path traversal issues\n #\n lines = open(self.path + \"/conf/\" + filename).readlines()\n lines = [line.strip() for line in lines if not line.strip().startswith(\"#\")]\n # Let's find the first location line\n location_line = None\n path_traversal_vulnerable = False\n lines_iter = lines.__iter__()\n for line in lines_iter:\n if line.startswith(\"location\"):\n location_line = line\n break\n # Look at the next lines for an 'alias' directive\n if location_line is not None:\n for line in lines_iter:\n if line.startswith(\"location\"):\n # Entering a new location block ... abort here\n # and assume there's no alias block later...\n break\n if line.startswith(\"alias\"):\n # We should definitely check for path traversal issue\n # Does the location target ends with / ?\n target = location_line.split()[-2]\n if not target.endswith(\"/\"):\n path_traversal_vulnerable = True\n break\n if path_traversal_vulnerable:\n print_warning(\n \"The nginx configuration appears vulnerable to path traversal as explained in \"\n \"https://www.acunetix.com/vulnerabilities/web/path-traversal-via-misconfigured-nginx-alias/\\n\"\n \"To fix it, look at the first lines of the nginx conf of the example app : \"\n \"https://github.com/YunoHost/example_ynh/blob/master/conf/nginx.conf\"\n )"
}
],
"deleted": []
},
"commit_link": "github.com/YunoHost/package_linter/commit/f6e98894cfe841aedaa7efd590937f0255193913",
"file_name": "package_linter.py",
"func_name": "misc_file_checks",
"line_changes": {
"added": [
{
"char_end": 1520,
"char_start": 1425,
"line": " if not os.path.isfile(self.path + \"/conf/\" + filename) or \"nginx\" not in filename:\n",
"line_no": 42
},
{
"char_end": 1546,
"char_start": 1545,
"line": "\n",
"line_no": 44
}
],
"deleted": [
{
"char_end": 1336,
"char_start": 1268,
"line": " if not os.path.isfile(self.path + \"/conf/\" + filename):\n",
"line_no": 39
}
]
},
"vul_type": "cwe-022"
}
| 24
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def misc_file_checks(self):",
" print_header(\"MISC FILE CHECKS\")",
" #\n # Check for recommended and mandatory files\n #",
" filenames = (\"manifest.json\", \"LICENSE\", \"README.md\",\n \"scripts/install\", \"scripts/remove\",\n \"scripts/upgrade\",\n \"scripts/backup\", \"scripts/restore\")\n non_mandatory = (\"script/backup\", \"script/restore\")",
" for filename in filenames:\n if file_exists(self.path + \"/\" + filename):\n continue\n elif filename in non_mandatory:\n print_warning(\"Consider adding a file %s\" % filename)\n else:\n print_error(\"File %s is mandatory\" % filename)",
" #\n # Deprecated php-fpm.ini thing\n #",
" if file_exists(self.path + \"/conf/php-fpm.ini\"):\n print_warning(\n \"Using a separate php-fpm.ini file is deprecated. \"\n \"Please merge your php-fpm directives directly in the pool file. \"\n \"(c.f. https://github.com/YunoHost-Apps/nextcloud_ynh/issues/138 )\"\n )",
" #",
" # Analyze nginx conf\n # - Deprecated usage of 'add_header' in nginx conf\n # - Spot path traversal issue vulnerability",
" #",
" for filename in os.listdir(self.path + \"/conf\"):",
" # Ignore subdirs or filename not containing nginx in the name\n if not os.path.isfile(self.path + \"/conf/\" + filename) or \"nginx\" not in filename:",
" continue",
"\n #\n # 'add_header' usage\n #",
" content = open(self.path + \"/conf/\" + filename).read()\n if \"location\" in content and \"add_header\" in content:\n print_warning(\n \"Do not use 'add_header' in the nginx conf. Use 'more_set_headers' instead. \"\n \"(See https://www.peterbe.com/plog/be-very-careful-with-your-add_header-in-nginx \"\n \"and https://github.com/openresty/headers-more-nginx-module#more_set_headers )\"\n )",
"\n #\n # Path traversal issues\n #\n lines = open(self.path + \"/conf/\" + filename).readlines()\n lines = [line.strip() for line in lines if not line.strip().startswith(\"#\")]\n # Let's find the first location line\n location_line = None\n path_traversal_vulnerable = False\n lines_iter = lines.__iter__()\n for line in lines_iter:\n if line.startswith(\"location\"):\n location_line = line\n break\n # Look at the next lines for an 'alias' directive\n if location_line is not None:\n for line in lines_iter:\n if line.startswith(\"location\"):\n # Entering a new location block ... abort here\n # and assume there's no alias block later...\n break\n if line.startswith(\"alias\"):\n # We should definitely check for path traversal issue\n # Does the location target ends with / ?\n target = location_line.split()[-2]\n if not target.endswith(\"/\"):\n path_traversal_vulnerable = True\n break\n if path_traversal_vulnerable:\n print_warning(\n \"The nginx configuration appears vulnerable to path traversal as explained in \"\n \"https://www.acunetix.com/vulnerabilities/web/path-traversal-via-misconfigured-nginx-alias/\\n\"\n \"To fix it, look at the first lines of the nginx conf of the example app : \"\n \"https://github.com/YunoHost/example_ynh/blob/master/conf/nginx.conf\"\n )"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 1184,
"char_start": 1153,
"chars": "Analyze nginx conf\n # - "
},
{
"char_end": 1292,
"char_start": 1240,
"chars": " - Spot path traversal issue vulnerability\n #"
},
{
"char_end": 1437,
"char_start": 1363,
"chars": "# Ignore subdirs or filename not containing nginx in the name\n "
},
{
"char_end": 1518,
"char_start": 1491,
"chars": " or \"nginx\" not in filename"
},
{
"char_end": 1606,
"char_start": 1544,
"chars": "\n\n #\n # 'add_header' usage\n #"
},
{
"char_end": 3888,
"char_start": 2089,
"chars": "\n\n #\n # Path traversal issues\n #\n lines = open(self.path + \"/conf/\" + filename).readlines()\n lines = [line.strip() for line in lines if not line.strip().startswith(\"#\")]\n # Let's find the first location line\n location_line = None\n path_traversal_vulnerable = False\n lines_iter = lines.__iter__()\n for line in lines_iter:\n if line.startswith(\"location\"):\n location_line = line\n break\n # Look at the next lines for an 'alias' directive\n if location_line is not None:\n for line in lines_iter:\n if line.startswith(\"location\"):\n # Entering a new location block ... abort here\n # and assume there's no alias block later...\n break\n if line.startswith(\"alias\"):\n # We should definitely check for path traversal issue\n # Does the location target ends with / ?\n target = location_line.split()[-2]\n if not target.endswith(\"/\"):\n path_traversal_vulnerable = True\n break\n if path_traversal_vulnerable:\n print_warning(\n \"The nginx configuration appears vulnerable to path traversal as explained in \"\n \"https://www.acunetix.com/vulnerabilities/web/path-traversal-via-misconfigured-nginx-alias/\\n\"\n \"To fix it, look at the first lines of the nginx conf of the example app : \"\n \"https://github.com/YunoHost/example_ynh/blob/master/conf/nginx.conf\"\n )"
}
],
"deleted": []
},
"commit_link": "github.com/YunoHost/package_linter/commit/f6e98894cfe841aedaa7efd590937f0255193913",
"file_name": "package_linter.py",
"func_name": "misc_file_checks",
"line_changes": {
"added": [
{
"char_end": 1520,
"char_start": 1425,
"line": " if not os.path.isfile(self.path + \"/conf/\" + filename) or \"nginx\" not in filename:\n",
"line_no": 42
},
{
"char_end": 1546,
"char_start": 1545,
"line": "\n",
"line_no": 44
}
],
"deleted": [
{
"char_end": 1336,
"char_start": 1268,
"line": " if not os.path.isfile(self.path + \"/conf/\" + filename):\n",
"line_no": 39
}
]
},
"vul_type": "cwe-022"
}
| 24
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n",
"",
" char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}"
] |
[
1,
0,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 310,
"char_start": 183,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_save_binary",
"line_changes": {
"added": [
{
"char_end": 219,
"char_start": 179,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 305,
"char_start": 219,
"line": " error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 306,
"char_start": 305,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 25
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n",
" if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n",
" char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}"
] |
[
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 310,
"char_start": 183,
"chars": "if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n\n "
}
],
"deleted": []
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/dump_dir.c",
"func_name": "dd_save_binary",
"line_changes": {
"added": [
{
"char_end": 219,
"char_start": 179,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 6
},
{
"char_end": 305,
"char_start": 219,
"line": " error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n",
"line_no": 7
},
{
"char_end": 306,
"char_start": 305,
"line": "\n",
"line_no": 8
}
],
"deleted": []
},
"vul_type": "cwe-022"
}
| 25
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def pascal_case(value: str) -> str:",
" return stringcase.pascalcase(value)"
] |
[
1,
0
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 79,
"char_start": 69,
"chars": "_sanitize("
},
{
"char_end": 86,
"char_start": 85,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/openapi-generators/openapi-python-client/commit/3e7dfae5d0b3685abf1ede1bc6c086a116ac4746",
"file_name": "openapi_python_client/utils.py",
"func_name": "pascal_case",
"line_changes": {
"added": [
{
"char_end": 86,
"char_start": 36,
"line": " return stringcase.pascalcase(_sanitize(value))\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 75,
"char_start": 36,
"line": " return stringcase.pascalcase(value)\n",
"line_no": 2
}
]
},
"vul_type": "cwe-022"
}
| 26
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"def pascal_case(value: str) -> str:",
" return stringcase.pascalcase(_sanitize(value))"
] |
[
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 79,
"char_start": 69,
"chars": "_sanitize("
},
{
"char_end": 86,
"char_start": 85,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/openapi-generators/openapi-python-client/commit/3e7dfae5d0b3685abf1ede1bc6c086a116ac4746",
"file_name": "openapi_python_client/utils.py",
"func_name": "pascal_case",
"line_changes": {
"added": [
{
"char_end": 86,
"char_start": 36,
"line": " return stringcase.pascalcase(_sanitize(value))\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 75,
"char_start": 36,
"line": " return stringcase.pascalcase(value)\n",
"line_no": 2
}
]
},
"vul_type": "cwe-022"
}
| 26
|
cwe-022
|
py
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"cleanup_pathname(struct archive_write_disk *a)\n{\n\tchar *dest, *src;\n\tchar separator = '\\0';",
"\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}",
"#if defined(__CYGWIN__)\n\tcleanup_pathname_win(a);\n#endif\n\t/* Skip leading '/'. */",
"\tif (*src == '/')",
"\t\tseparator = *src++;",
"",
"\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}",
"\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}",
"\t\tif (*src == '\\0')\n\t\t\tbreak;",
"\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}"
] |
[
1,
1,
1,
0,
1,
0,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 543,
"char_start": 353,
"chars": " {\n\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t \"Path is absolute\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n"
},
{
"char_end": 568,
"char_start": 565,
"chars": "\n\t}"
}
],
"deleted": []
},
"commit_link": "github.com/libarchive/libarchive/commit/59357157706d47c365b2227739e17daba3607526",
"file_name": "libarchive/archive_write_disk_posix.c",
"func_name": "cleanup_pathname",
"line_changes": {
"added": [
{
"char_end": 356,
"char_start": 336,
"line": "\tif (*src == '/') {\n",
"line_no": 17
},
{
"char_end": 415,
"char_start": 356,
"line": "\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n",
"line_no": 18
},
{
"char_end": 469,
"char_start": 415,
"line": "\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n",
"line_no": 19
},
{
"char_end": 511,
"char_start": 469,
"line": "\t\t\t \"Path is absolute\");\n",
"line_no": 20
},
{
"char_end": 539,
"char_start": 511,
"line": "\t\t\treturn (ARCHIVE_FAILED);\n",
"line_no": 21
},
{
"char_end": 543,
"char_start": 539,
"line": "\t\t}\n",
"line_no": 22
},
{
"char_end": 544,
"char_start": 543,
"line": "\n",
"line_no": 23
},
{
"char_end": 569,
"char_start": 566,
"line": "\t}\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 354,
"char_start": 336,
"line": "\tif (*src == '/')\n",
"line_no": 17
}
]
},
"vul_type": "cwe-022"
}
| 27
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"cleanup_pathname(struct archive_write_disk *a)\n{\n\tchar *dest, *src;\n\tchar separator = '\\0';",
"\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}",
"#if defined(__CYGWIN__)\n\tcleanup_pathname_win(a);\n#endif\n\t/* Skip leading '/'. */",
"\tif (*src == '/') {\n\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t \"Path is absolute\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n",
"\t\tseparator = *src++;",
"\t}",
"\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}",
"\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}",
"\t\tif (*src == '\\0')\n\t\t\tbreak;",
"\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}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 543,
"char_start": 353,
"chars": " {\n\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t \"Path is absolute\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n"
},
{
"char_end": 568,
"char_start": 565,
"chars": "\n\t}"
}
],
"deleted": []
},
"commit_link": "github.com/libarchive/libarchive/commit/59357157706d47c365b2227739e17daba3607526",
"file_name": "libarchive/archive_write_disk_posix.c",
"func_name": "cleanup_pathname",
"line_changes": {
"added": [
{
"char_end": 356,
"char_start": 336,
"line": "\tif (*src == '/') {\n",
"line_no": 17
},
{
"char_end": 415,
"char_start": 356,
"line": "\t\tif (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n",
"line_no": 18
},
{
"char_end": 469,
"char_start": 415,
"line": "\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n",
"line_no": 19
},
{
"char_end": 511,
"char_start": 469,
"line": "\t\t\t \"Path is absolute\");\n",
"line_no": 20
},
{
"char_end": 539,
"char_start": 511,
"line": "\t\t\treturn (ARCHIVE_FAILED);\n",
"line_no": 21
},
{
"char_end": 543,
"char_start": 539,
"line": "\t\t}\n",
"line_no": 22
},
{
"char_end": 544,
"char_start": 543,
"line": "\n",
"line_no": 23
},
{
"char_end": 569,
"char_start": 566,
"line": "\t}\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 354,
"char_start": 336,
"line": "\tif (*src == '/')\n",
"line_no": 17
}
]
},
"vul_type": "cwe-022"
}
| 27
|
cwe-022
|
c
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)\n{\n INITIALIZE_LIBREPORT();",
" char *type = problem_data_get_content_or_NULL(problem_data, FILENAME_ANALYZER);",
" if (!type)\n {\n error_msg(_(\"Missing required item: '%s'\"), FILENAME_ANALYZER);",
"",
" return NULL;\n }",
" uid_t uid = (uid_t)-1L;\n char *uid_str = problem_data_get_content_or_NULL(problem_data, FILENAME_UID);",
" if (uid_str)\n {\n char *endptr;\n errno = 0;\n long val = strtol(uid_str, &endptr, 10);",
" if (errno != 0 || endptr == uid_str || *endptr != '\\0' || INT_MAX < val)\n {\n error_msg(_(\"uid value is not valid: '%s'\"), uid_str);\n return NULL;\n }",
" uid = (uid_t)val;\n }",
" struct timeval tv;\n if (gettimeofday(&tv, NULL) < 0)\n {\n perror_msg(\"gettimeofday()\");\n return NULL;\n }",
" char *problem_id = xasprintf(\"%s-%s.%ld-%lu\"NEW_PD_SUFFIX, type, iso_date_string(&(tv.tv_sec)), (long)tv.tv_usec, (long)getpid());",
" log_info(\"Saving to %s/%s with uid %d\", base_dir_name, problem_id, uid);",
" struct dump_dir *dd;\n if (base_dir_name)\n dd = try_dd_create(base_dir_name, problem_id, uid);\n else\n {\n /* Try /var/run/abrt */\n dd = try_dd_create(LOCALSTATEDIR\"/run/abrt\", problem_id, uid);\n /* Try $HOME/tmp */\n if (!dd)\n {\n char *home = getenv(\"HOME\");\n if (home && home[0])\n {\n home = concat_path_file(home, \"tmp\");\n /*mkdir(home, 0777); - do we want this? */\n dd = try_dd_create(home, problem_id, uid);\n free(home);\n }\n }\n//TODO: try user's home dir obtained by getpwuid(getuid())?\n /* Try system temporary directory */\n if (!dd)\n dd = try_dd_create(LARGE_DATA_TMP_DIR, problem_id, uid);\n }",
" if (!dd) /* try_dd_create() already emitted the error message */\n goto ret;",
" GHashTableIter iter;\n char *name;\n struct problem_item *value;\n g_hash_table_iter_init(&iter, problem_data);\n while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))\n {",
"",
" if (value->flags & CD_FLAG_BIN)\n {\n char *dest = concat_path_file(dd->dd_dirname, name);\n log_info(\"copying '%s' to '%s'\", value->content, dest);\n off_t copied = copy_file(value->content, dest, DEFAULT_DUMP_DIR_MODE | S_IROTH);\n if (copied < 0)\n error_msg(\"Can't copy %s to %s\", value->content, dest);\n else\n log_info(\"copied %li bytes\", (unsigned long)copied);\n free(dest);\n",
" continue;\n }",
" /* only files should contain '/' and those are handled earlier */\n if (name[0] == '.' || strchr(name, '/'))\n {\n error_msg(\"Problem data field name contains disallowed chars: '%s'\", name);",
" continue;\n }",
" dd_save_text(dd, name, value->content);\n }",
" /* need to create basic files AFTER we save the pd to dump_dir\n * otherwise we can't skip already created files like in case when\n * reporting from anaconda where we can't read /etc/{system,redhat}-release\n * and os_release is taken from anaconda\n */\n dd_create_basic_files(dd, uid, NULL);",
" problem_id[strlen(problem_id) - strlen(NEW_PD_SUFFIX)] = '\\0';\n char* new_path = concat_path_file(base_dir_name, problem_id);\n log_info(\"Renaming from '%s' to '%s'\", dd->dd_dirname, new_path);\n dd_rename(dd, new_path);",
" ret:\n free(problem_id);\n return dd;\n}"
] |
[
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
0,
1,
1,
1,
1,
1
] |
SVEN
|
{
"char_changes": {
"added": [
{
"char_end": 497,
"char_start": 349,
"chars": "if (!str_is_correct_filename(type))\n {\n error_msg(_(\"'%s' is not correct file name\"), FILENAME_ANALYZER);\n return NULL;\n }\n\n "
},
{
"char_end": 2558,
"char_start": 2383,
"chars": "!str_is_correct_filename(name))\n {\n error_msg(\"Problem data field name contains disallowed chars: '%s'\", name);\n continue;\n }\n\n if ("
}
],
"deleted": [
{
"char_end": 2963,
"char_start": 2709,
"chars": "\n continue;\n }\n\n /* only files should contain '/' and those are handled earlier */\n if (name[0] == '.' || strchr(name, '/'))\n {\n error_msg(\"Problem data field name contains disallowed chars: '%s'\", name);"
}
]
},
"commit_link": "github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277",
"file_name": "src/lib/create_dump_dir.c",
"func_name": "create_dump_dir_from_problem_data",
"line_changes": {
"added": [
{
"char_end": 385,
"char_start": 345,
"line": " if (!str_is_correct_filename(type))\n",
"line_no": 13
},
{
"char_end": 391,
"char_start": 385,
"line": " {\n",
"line_no": 14
},
{
"char_end": 465,
"char_start": 391,
"line": " error_msg(_(\"'%s' is not correct file name\"), FILENAME_ANALYZER);\n",
"line_no": 15
},
{
"char_end": 486,
"char_start": 465,
"line": " return NULL;\n",
"line_no": 16
},
{
"char_end": 492,
"char_start": 486,
"line": " }\n",
"line_no": 17
},
{
"char_end": 493,
"char_start": 492,
"line": "\n",
"line_no": 18
},
{
"char_end": 2415,
"char_start": 2371,
"line": " if (!str_is_correct_filename(name))\n",
"line_no": 82
},
{
"char_end": 2425,
"char_start": 2415,
"line": " {\n",
"line_no": 83
},
{
"char_end": 2513,
"char_start": 2425,
"line": " error_msg(\"Problem data field name contains disallowed chars: '%s'\", name);\n",
"line_no": 84
},
{
"char_end": 2535,
"char_start": 2513,
"line": " continue;\n",
"line_no": 85
},
{
"char_end": 2545,
"char_start": 2535,
"line": " }\n",
"line_no": 86
},
{
"char_end": 2546,
"char_start": 2545,
"line": "\n",
"line_no": 87
}
],
"deleted": [
{
"char_end": 2817,
"char_start": 2743,
"line": " /* only files should contain '/' and those are handled earlier */\n",
"line_no": 90
},
{
"char_end": 2866,
"char_start": 2817,
"line": " if (name[0] == '.' || strchr(name, '/'))\n",
"line_no": 91
},
{
"char_end": 2876,
"char_start": 2866,
"line": " {\n",
"line_no": 92
},
{
"char_end": 2964,
"char_start": 2876,
"line": " error_msg(\"Problem data field name contains disallowed chars: '%s'\", name);\n",
"line_no": 93
},
{
"char_end": 2986,
"char_start": 2964,
"line": " continue;\n",
"line_no": 94
},
{
"char_end": 2996,
"char_start": 2986,
"line": " }\n",
"line_no": 95
},
{
"char_end": 2997,
"char_start": 2996,
"line": "\n",
"line_no": 96
}
]
},
"vul_type": "cwe-022"
}
| 28
|
cwe-022
|
c
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 37