cwe stringclasses 9
values | func_name stringclasses 551
values | func_src_before stringlengths 72 114k | func_src_after stringclasses 576
values | line_changes stringclasses 576
values | char_changes stringclasses 574
values | commit_link stringclasses 430
values | file_name stringclasses 411
values | vul_type stringclasses 9
values | num_tokens float64 16 28.1k ⌀ | refactored bool 2
classes | parsing_score bool 2
classes | generated bool 2
classes |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
cwe-022 | _inject_admin_password_into_fs | def _inject_admin_password_into_fs(admin_passwd, fs, execute=None):
"""Set the root password to admin_passwd
admin_password is a root password
fs is the path to the base of the filesystem into which to inject
the key.
This method modifies the instance filesystem directly,
and does not require ... | def _inject_admin_password_into_fs(admin_passwd, fs, execute=None):
"""Set the root password to admin_passwd
admin_password is a root password
fs is the path to the base of the filesystem into which to inject
the key.
This method modifies the instance filesystem directly,
and does not require ... | {'deleted': [{'line_no': 23, 'char_start': 689, 'char_end': 760, 'line': " utils.execute('cp', os.path.join(fs, 'etc', 'passwd'), tmp_passwd,\n"}, {'line_no': 24, 'char_start': 760, 'char_end': 796, 'line': ' run_as_root=True)\n'}, {'line_no': 25, 'char_start': 796, 'char_end': 867, 'line': " uti... | {'deleted': [{'char_start': 693, 'char_end': 694, 'chars': 'u'}, {'char_start': 696, 'char_end': 701, 'chars': 'ls.ex'}, {'char_start': 703, 'char_end': 704, 'chars': 'u'}, {'char_start': 705, 'char_end': 706, 'chars': 'e'}, {'char_start': 711, 'char_end': 712, 'chars': ','}, {'char_start': 714, 'char_end': 716, 'chars... | github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7 | nova/virt/disk/api.py | cwe-022 | 287 | false | true | false |
cwe-022 | misc_file_checks | def misc_file_checks(self):
print_header("MISC FILE CHECKS")
#
# Check for recommended and mandatory files
#
filenames = ("manifest.json", "LICENSE", "README.md",
"scripts/install", "scripts/remove",
"scripts/upgrade",
... | def misc_file_checks(self):
print_header("MISC FILE CHECKS")
#
# Check for recommended and mandatory files
#
filenames = ("manifest.json", "LICENSE", "README.md",
"scripts/install", "scripts/remove",
"scripts/upgrade",
... | {'deleted': [{'line_no': 39, 'char_start': 1268, 'char_end': 1336, 'line': ' if not os.path.isfile(self.path + "/conf/" + filename):\n'}], 'added': [{'line_no': 42, 'char_start': 1425, 'char_end': 1520, 'line': ' if not os.path.isfile(self.path + "/conf/" + filename) or "nginx" not in filename:\n'... | {'deleted': [], 'added': [{'char_start': 1153, 'char_end': 1184, 'chars': 'Analyze nginx conf\n # - '}, {'char_start': 1240, 'char_end': 1292, 'chars': ' - Spot path traversal issue vulnerability\n #'}, {'char_start': 1363, 'char_end': 1437, 'chars': '# Ignore subdirs or filename not containing nginx in t... | github.com/YunoHost/package_linter/commit/f6e98894cfe841aedaa7efd590937f0255193913 | package_linter.py | cwe-022 | 386 | false | true | false |
cwe-022 | render | def render(self, request):
action = "download"
if "action" in request.args:
action = request.args["action"][0]
if "file" in request.args:
filename = request.args["file"][0].decode('utf-8', 'ignore').encode('utf-8')
filename = re.sub("^/+", "/", os.path.realpath(filename))
if not os.path.exists(file... | def render(self, request):
action = "download"
if "action" in request.args:
action = request.args["action"][0]
if "file" in request.args:
filename = lenient_force_utf_8(request.args["file"][0])
filename = sanitise_filename_slashes(os.path.realpath(filename))
if not os.path.exists(filename):
ret... | {'deleted': [{'line_no': 7, 'char_start': 149, 'char_end': 229, 'line': '\t\t\tfilename = request.args["file"][0].decode(\'utf-8\', \'ignore\').encode(\'utf-8\')\n'}, {'line_no': 8, 'char_start': 229, 'char_end': 290, 'line': '\t\t\tfilename = re.sub("^/+", "/", os.path.realpath(filename))\n'}], 'added': [{'line_no': 7... | {'deleted': [{'char_start': 186, 'char_end': 227, 'chars': ".decode('utf-8', 'ignore').encode('utf-8'"}, {'char_start': 243, 'char_end': 244, 'chars': 'r'}, {'char_start': 245, 'char_end': 246, 'chars': '.'}, {'char_start': 247, 'char_end': 249, 'chars': 'ub'}, {'char_start': 250, 'char_end': 262, 'chars': '"^/+", "/",... | github.com/E2OpenPlugins/e2openplugin-OpenWebif/commit/a846b7664eda3a4c51a452e00638cf7337dc2013 | plugin/controllers/file.py | cwe-022 | 590 | false | true | false |
cwe-022 | list | def list(self, keyfilter='/'):
path = os.path.join(self.namespace, keyfilter)
if path != '/':
path = path.rstrip('/')
try:
result = self.etcd.read(path, recursive=True)
except etcd.EtcdKeyNotFound:
return None
except etcd.EtcdException as e... | def list(self, keyfilter='/'):
path = self._absolute_key(keyfilter)
if path != '/':
path = path.rstrip('/')
try:
result = self.etcd.read(path, recursive=True)
except etcd.EtcdKeyNotFound:
return None
except etcd.EtcdException as err:
... | {'deleted': [{'line_no': 2, 'char_start': 35, 'char_end': 90, 'line': ' path = os.path.join(self.namespace, keyfilter)\n'}], 'added': [{'line_no': 2, 'char_start': 35, 'char_end': 80, 'line': ' path = self._absolute_key(keyfilter)\n'}]} | {'deleted': [{'char_start': 50, 'char_end': 63, 'chars': 'os.path.join('}, {'char_start': 68, 'char_end': 69, 'chars': 'n'}, {'char_start': 70, 'char_end': 72, 'chars': 'me'}, {'char_start': 73, 'char_end': 76, 'chars': 'pac'}, {'char_start': 77, 'char_end': 79, 'chars': ', '}], 'added': [{'char_start': 55, 'char_end':... | github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4 | custodia/store/etcdstore.py | cwe-022 | 167 | false | true | false |
cwe-022 | cut | def cut(self, key):
try:
self.etcd.delete(os.path.join(self.namespace, key))
except etcd.EtcdKeyNotFound:
return False
except etcd.EtcdException as err:
log_error("Error removing key %s: [%r]" % (key, repr(err)))
raise CSStoreError('Error occur... | def cut(self, key):
try:
self.etcd.delete(self._absolute_key(key))
except etcd.EtcdKeyNotFound:
return False
except etcd.EtcdException as err:
log_error("Error removing key %s: [%r]" % (key, repr(err)))
raise CSStoreError('Error occurred while ... | {'deleted': [{'line_no': 3, 'char_start': 37, 'char_end': 101, 'line': ' self.etcd.delete(os.path.join(self.namespace, key))\n'}], 'added': [{'line_no': 3, 'char_start': 37, 'char_end': 91, 'line': ' self.etcd.delete(self._absolute_key(key))\n'}]} | {'deleted': [{'char_start': 66, 'char_end': 79, 'chars': 'os.path.join('}, {'char_start': 84, 'char_end': 85, 'chars': 'n'}, {'char_start': 86, 'char_end': 88, 'chars': 'me'}, {'char_start': 89, 'char_end': 92, 'chars': 'pac'}, {'char_start': 93, 'char_end': 95, 'chars': ', '}], 'added': [{'char_start': 71, 'char_end':... | github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4 | custodia/store/etcdstore.py | cwe-022 | 85 | false | true | false |
cwe-022 | create_dump_dir_from_problem_data | struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
{
INITIALIZE_LIBREPORT();
char *type = problem_data_get_content_or_NULL(problem_data, FILENAME_ANALYZER);
if (!type)
{
error_msg(_("Missing required item: '%s'"), FILENAME_ANALYZER);
... | struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name)
{
INITIALIZE_LIBREPORT();
char *type = problem_data_get_content_or_NULL(problem_data, FILENAME_ANALYZER);
if (!type)
{
error_msg(_("Missing required item: '%s'"), FILENAME_ANALYZER);
... | {'deleted': [{'line_no': 90, 'char_start': 2743, 'char_end': 2817, 'line': " /* only files should contain '/' and those are handled earlier */\n"}, {'line_no': 91, 'char_start': 2817, 'char_end': 2866, 'line': " if (name[0] == '.' || strchr(name, '/'))\n"}, {'line_no': 92, 'char_start': 2866, 'char_end': ... | {'deleted': [{'char_start': 2709, 'char_end': 2963, '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... | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/create_dump_dir.c | cwe-022 | 933 | false | true | false |
cwe-022 | compose_path | char *compose_path(ctrl_t *ctrl, char *path)
{
struct stat st;
static char rpath[PATH_MAX];
char *name, *ptr;
char dir[PATH_MAX] = { 0 };
strlcpy(dir, ctrl->cwd, sizeof(dir));
DBG("Compose path from cwd: %s, arg: %s", ctrl->cwd, path ?: "");
if (!path || !strlen(path))
goto check;
if (path) {
if (path[0] ... | char *compose_path(ctrl_t *ctrl, char *path)
{
struct stat st;
static char rpath[PATH_MAX];
char *name, *ptr;
char dir[PATH_MAX] = { 0 };
strlcpy(dir, ctrl->cwd, sizeof(dir));
DBG("Compose path from cwd: %s, arg: %s", ctrl->cwd, path ?: "");
if (!path || !strlen(path))
goto check;
if (path) {
if (path[0] ... | {'deleted': [{'line_no': 63, 'char_start': 1460, 'char_end': 1514, 'line': '\tif (!chrooted && strncmp(dir, home, strlen(home))) {\n'}], 'added': [{'line_no': 63, 'char_start': 1460, 'char_end': 1516, 'line': '\tif (!chrooted && strncmp(rpath, home, strlen(home))) {\n'}]} | {'deleted': [{'char_start': 1486, 'char_end': 1488, 'chars': 'di'}], 'added': [{'char_start': 1487, 'char_end': 1491, 'chars': 'path'}]} | github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe | src/common.c | cwe-022 | 512 | false | false | false |
cwe-022 | get_paths | def get_paths(base_path: pathlib.Path):
data_file = pathlib.Path(str(base_path) + ".data")
metadata_file = pathlib.Path(str(base_path) + ".meta")
return data_file, metadata_file | def get_paths(root: str, sub_path: str) \
-> typing.Tuple[pathlib.Path, pathlib.Path]:
base_path = flask.safe_join(root, sub_path)
data_file = pathlib.Path(base_path + ".data")
metadata_file = pathlib.Path(base_path + ".meta")
return data_file, metadata_file | {'deleted': [{'line_no': 1, 'char_start': 0, 'char_end': 40, 'line': 'def get_paths(base_path: pathlib.Path):\n'}], 'added': [{'line_no': 1, 'char_start': 0, 'char_end': 42, 'line': 'def get_paths(root: str, sub_path: str) \\\n'}, {'line_no': 2, 'char_start': 42, 'char_end': 95, 'line': ' -> typing.Tuple[pathlib... | {'deleted': [{'char_start': 18, 'char_end': 19, 'chars': '_'}, {'char_start': 23, 'char_end': 24, 'chars': ':'}, {'char_start': 38, 'char_end': 39, 'chars': ':'}, {'char_start': 69, 'char_end': 73, 'chars': 'str('}, {'char_start': 82, 'char_end': 83, 'chars': ')'}, {'char_start': 128, 'char_end': 132, 'chars': 'str('},... | github.com/horazont/xmpp-http-upload/commit/82056540191e89f0cd697c81f57714c00962ed75 | xhu.py | cwe-022 | 44 | false | true | false |
cwe-022 | create_basename_core | def create_basename_core(basename):
try:
basename = basename.casefold()
except Exception:
basename = basename.lower()
basename = basename.replace(' ', '-')
basename = re.sub(r'<[^>]*>', r'', basename)
basename = re.sub(r'[^a-z0-9\-]', r'', basename)
basename = re.sub(r'\-\-', r'... | def create_basename_core(basename):
try:
basename = basename.casefold()
except Exception:
basename = basename.lower()
basename = re.sub(r'[ \./]', r'-', basename)
basename = re.sub(r'<[^>]*>', r'', basename)
basename = re.sub(r'[^a-z0-9\-]', r'', basename)
basename = re.sub(r'\-... | {'deleted': [{'line_no': 7, 'char_start': 143, 'char_end': 185, 'line': " basename = basename.replace(' ', '-')\n"}], 'added': [{'line_no': 7, 'char_start': 143, 'char_end': 192, 'line': " basename = re.sub(r'[ \\./]', r'-', basename)\n"}]} | {'deleted': [{'char_start': 158, 'char_end': 165, 'chars': 'basenam'}, {'char_start': 168, 'char_end': 175, 'chars': 'eplace('}], 'added': [{'char_start': 158, 'char_end': 159, 'chars': 'r'}, {'char_start': 161, 'char_end': 164, 'chars': 'sub'}, {'char_start': 165, 'char_end': 166, 'chars': 'r'}, {'char_start': 167, 'c... | github.com/syegulalp/mercury/commit/3f7c7442fa49aec37577dbdb47ce11a848e7bd03 | MeTal/core/utils.py | cwe-022 | 96 | false | true | false |
cwe-022 | dd_save_text | void dd_save_text(struct dump_dir *dd, const char *name, const char *data)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
char *full_path = concat_path_file(dd->dd_dirname, name);
save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);
free(... | void dd_save_text(struct dump_dir *dd, const char *name, const char *data)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
if (!str_is_correct_filename(name))
error_msg_and_die("Cannot save text. '%s' is not a valid file name", name);
char *full_path = concat_path... | {'deleted': [], 'added': [{'line_no': 6, 'char_start': 162, 'char_end': 202, 'line': ' if (!str_is_correct_filename(name))\n'}, {'line_no': 7, 'char_start': 202, 'char_end': 286, 'line': ' error_msg_and_die("Cannot save text. \'%s\' is not a valid file name", name);\n'}, {'line_no': 8, 'char_start': 286, 'cha... | {'deleted': [], 'added': [{'char_start': 166, 'char_end': 291, '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 '}]} | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/dump_dir.c | cwe-022 | 92 | false | true | false |
cwe-022 | get_files | def get_files(self, submit_id, password=None, astree=False):
"""
Returns files from a submitted analysis.
@param password: The password to unlock container archives with
@param astree: sflock option; determines the format in which the files are returned
@return: A tree of fil... | def get_files(self, submit_id, password=None, astree=False):
"""
Returns files from a submitted analysis.
@param password: The password to unlock container archives with
@param astree: sflock option; determines the format in which the files are returned
@return: A tree of fil... | {'deleted': [{'line_no': 14, 'char_start': 574, 'char_end': 645, 'line': ' filepath = os.path.join(submit.tmp_path, data["data"])\n'}, {'line_no': 15, 'char_start': 645, 'char_end': 700, 'line': ' filedata = open(filepath, "rb").read()\n'}, {'line_no': 18, 'char_start': 743, 'char_end': 80... | {'deleted': [{'char_start': 631, 'char_end': 661, 'chars': 'data["data"])\n '}, {'char_start': 665, 'char_end': 675, 'chars': 'data = ope'}, {'char_start': 676, 'char_end': 682, 'chars': '(filep'}, {'char_start': 683, 'char_end': 694, 'chars': 'th, "rb").r'}, {'char_start': 695, 'char_end': 698, 'chars':... | github.com/cuckoosandbox/cuckoo/commit/168cabf86730d56b7fa319278bf0f0034052666a | cuckoo/core/submit.py | cwe-022 | 346 | false | true | false |
cwe-022 | candidate_paths_for_url | def candidate_paths_for_url(self, url):
for root, prefix in self.directories:
if url.startswith(prefix):
yield os.path.join(root, url[len(prefix):]) | def candidate_paths_for_url(self, url):
for root, prefix in self.directories:
if url.startswith(prefix):
path = os.path.join(root, url[len(prefix):])
if os.path.commonprefix((root, path)) == root:
yield path | {'deleted': [{'line_no': 4, 'char_start': 129, 'char_end': 188, 'line': ' yield os.path.join(root, url[len(prefix):])\n'}], 'added': [{'line_no': 4, 'char_start': 129, 'char_end': 190, 'line': ' path = os.path.join(root, url[len(prefix):])\n'}, {'line_no': 5, 'char_start': 190, 'char_end':... | {'deleted': [{'char_start': 145, 'char_end': 150, 'chars': 'yield'}], 'added': [{'char_start': 145, 'char_end': 151, 'chars': 'path ='}, {'char_start': 189, 'char_end': 283, 'chars': '\n if os.path.commonprefix((root, path)) == root:\n yield path'}]} | github.com/evansd/whitenoise/commit/4d8a3ab1e97d7ddb18b3fa8b4909c92bad5529c6 | whitenoise/base.py | cwe-022 | 38 | false | true | false |
cwe-022 | addKey | def addKey(client):
"""Adds a new key with the specified name and contents.
Returns an error if a key with the specified name already exists.
"""
global BAD_REQUEST
global CREATED
validateClient(client)
client_pub_key = loadClientRSAKey(client)
token_data = decodeRequestToken(request.data, client_pub_key)
va... | def addKey(client):
"""Adds a new key with the specified name and contents.
Returns an error if a key with the specified name already exists.
"""
global BAD_REQUEST
global CREATED
validateClient(client)
client_pub_key = loadClientRSAKey(client)
token_data = decodeRequestToken(request.data, client_pub_key)
val... | {'deleted': [{'line_no': 9, 'char_start': 210, 'char_end': 211, 'line': '\n'}], 'added': [{'line_no': 12, 'char_start': 348, 'char_end': 385, 'line': "\tvalidateKeyName(token_data['name'])\n"}]} | {'deleted': [{'char_start': 210, 'char_end': 211, 'chars': '\n'}], 'added': [{'char_start': 346, 'char_end': 383, 'chars': ")\n\tvalidateKeyName(token_data['name']"}]} | github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833 | impl.py | cwe-022 | 169 | false | true | false |
cwe-022 | dd_get_item_size | long dd_get_item_size(struct dump_dir *dd, const char *name)
{
long size = -1;
char *iname = concat_path_file(dd->dd_dirname, name);
struct stat statbuf;
if (lstat(iname, &statbuf) == 0 && S_ISREG(statbuf.st_mode))
size = statbuf.st_size;
else
{
if (errno == ENOENT)
... | long dd_get_item_size(struct dump_dir *dd, const char *name)
{
if (!str_is_correct_filename(name))
error_msg_and_die("Cannot get item size. '%s' is not a valid file name", name);
long size = -1;
char *iname = concat_path_file(dd->dd_dirname, name);
struct stat statbuf;
if (lstat(iname, &st... | {'deleted': [], 'added': [{'line_no': 3, 'char_start': 63, 'char_end': 103, 'line': ' if (!str_is_correct_filename(name))\n'}, {'line_no': 4, 'char_start': 103, 'char_end': 191, 'line': ' error_msg_and_die("Cannot get item size. \'%s\' is not a valid file name", name);\n'}, {'line_no': 5, 'char_start': 191, '... | {'deleted': [], 'added': [{'char_start': 67, 'char_end': 196, '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 '}]} | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/dump_dir.c | cwe-022 | 129 | false | true | false |
cwe-022 | dd_exist | int dd_exist(const struct dump_dir *dd, const char *path)
{
char *full_path = concat_path_file(dd->dd_dirname, path);
int ret = exist_file_dir(full_path);
free(full_path);
return ret;
} | int dd_exist(const struct dump_dir *dd, const char *path)
{
if (!str_is_correct_filename(path))
error_msg_and_die("Cannot test existence. '%s' is not a valid file name", path);
char *full_path = concat_path_file(dd->dd_dirname, path);
int ret = exist_file_dir(full_path);
free(full_path);
re... | {'deleted': [], 'added': [{'line_no': 3, 'char_start': 60, 'char_end': 100, 'line': ' if (!str_is_correct_filename(path))\n'}, {'line_no': 4, 'char_start': 100, 'char_end': 189, 'line': ' error_msg_and_die("Cannot test existence. \'%s\' is not a valid file name", path);\n'}, {'line_no': 5, 'char_start': 189, ... | {'deleted': [], 'added': [{'char_start': 64, 'char_end': 194, 'chars': 'if (!str_is_correct_filename(path))\n error_msg_and_die("Cannot test existence. \'%s\' is not a valid file name", path);\n\n '}]} | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/dump_dir.c | cwe-022 | 53 | false | true | false |
cwe-022 | _inject_net_into_fs | def _inject_net_into_fs(net, fs, execute=None):
"""Inject /etc/network/interfaces into the filesystem rooted at fs.
net is the contents of /etc/network/interfaces.
"""
netdir = os.path.join(os.path.join(fs, 'etc'), 'network')
utils.execute('mkdir', '-p', netdir, run_as_root=True)
utils.execute(... | def _inject_net_into_fs(net, fs, execute=None):
"""Inject /etc/network/interfaces into the filesystem rooted at fs.
net is the contents of /etc/network/interfaces.
"""
netdir = _join_and_check_path_within_fs(fs, 'etc', 'network')
utils.execute('mkdir', '-p', netdir, run_as_root=True)
utils.exec... | {'deleted': [{'line_no': 6, 'char_start': 181, 'char_end': 243, 'line': " netdir = os.path.join(os.path.join(fs, 'etc'), 'network')\n"}, {'line_no': 10, 'char_start': 426, 'char_end': 475, 'line': " netfile = os.path.join(netdir, 'interfaces')\n"}, {'line_no': 11, 'char_start': 475, 'char_end': 545, 'line': " ... | {'deleted': [{'char_start': 194, 'char_end': 202, 'chars': 'os.path.'}, {'char_start': 206, 'char_end': 210, 'chars': '(os.'}, {'char_start': 214, 'char_end': 217, 'chars': '.jo'}, {'char_start': 229, 'char_end': 230, 'chars': ')'}, {'char_start': 456, 'char_end': 458, 'chars': 'di'}, {'char_start': 479, 'char_end': 48... | github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7 | nova/virt/disk/api.py | cwe-022 | 146 | false | true | false |
cwe-022 | get | def get(self, key):
try:
result = self.etcd.get(os.path.join(self.namespace, key))
except etcd.EtcdException as err:
log_error("Error fetching key %s: [%r]" % (key, repr(err)))
raise CSStoreError('Error occurred while trying to get key')
return result.valu... | def get(self, key):
try:
result = self.etcd.get(self._absolute_key(key))
except etcd.EtcdException as err:
log_error("Error fetching key %s: [%r]" % (key, repr(err)))
raise CSStoreError('Error occurred while trying to get key')
return result.value | {'deleted': [{'line_no': 3, 'char_start': 37, 'char_end': 107, 'line': ' result = self.etcd.get(os.path.join(self.namespace, key))\n'}], 'added': [{'line_no': 3, 'char_start': 37, 'char_end': 97, 'line': ' result = self.etcd.get(self._absolute_key(key))\n'}]} | {'deleted': [{'char_start': 72, 'char_end': 85, 'chars': 'os.path.join('}, {'char_start': 90, 'char_end': 91, 'chars': 'n'}, {'char_start': 92, 'char_end': 94, 'chars': 'me'}, {'char_start': 95, 'char_end': 98, 'chars': 'pac'}, {'char_start': 99, 'char_end': 101, 'chars': ', '}], 'added': [{'char_start': 77, 'char_end'... | github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4 | custodia/store/etcdstore.py | cwe-022 | 74 | false | true | false |
cwe-022 | dd_save_binary | void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
char *full_path = concat_path_file(dd->dd_dirname, name);
save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);
... | void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
if (!str_is_correct_filename(name))
error_msg_and_die("Cannot save binary. '%s' is not a valid file name", name);
char *full... | {'deleted': [], 'added': [{'line_no': 6, 'char_start': 179, 'char_end': 219, 'line': ' if (!str_is_correct_filename(name))\n'}, {'line_no': 7, 'char_start': 219, 'char_end': 305, 'line': ' error_msg_and_die("Cannot save binary. \'%s\' is not a valid file name", name);\n'}, {'line_no': 8, 'char_start': 305, 'c... | {'deleted': [], 'added': [{'char_start': 183, 'char_end': 310, '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 '}]} | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/dump_dir.c | cwe-022 | 94 | false | true | false |
cwe-022 | handle_method_call | static void handle_method_call(GDBusConnection *connection,
const gchar *caller,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
... | static void handle_method_call(GDBusConnection *connection,
const gchar *caller,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
... | {'deleted': [{'line_no': 259, 'char_start': 9073, 'char_end': 9148, 'line': " if (element == NULL || element[0] == '\\0' || strlen(element) > 64)\n"}], 'added': [{'line_no': 259, 'char_start': 9073, 'char_end': 9120, 'line': ' if (!str_is_correct_filename(element))\n'}, {'line_no': 318, 'char_start': 1155... | {'deleted': [{'char_start': 9085, 'char_end': 9126, 'chars': "element == NULL || element[0] == '\\0' || "}, {'char_start': 9141, 'char_end': 9146, 'chars': ' > 64'}], 'added': [{'char_start': 9085, 'char_end': 9097, 'chars': '!str_is_corr'}, {'char_start': 9098, 'char_end': 9103, 'chars': 'ct_fi'}, {'char_start': 9106,... | github.com/abrt/abrt/commit/f3c2a6af3455b2882e28570e8a04f1c2d4500d5b | src/dbus/abrt-dbus.c | cwe-022 | 3,390 | false | true | false |
cwe-022 | dd_delete_item | int dd_delete_item(struct dump_dir *dd, const char *name)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
char *path = concat_path_file(dd->dd_dirname, name);
int res = unlink(path);
if (res < 0)
{
if (errno == ENOENT)
errno = res = 0;
... | int dd_delete_item(struct dump_dir *dd, const char *name)
{
if (!dd->locked)
error_msg_and_die("dump_dir is not opened"); /* bug */
if (!str_is_correct_filename(name))
error_msg_and_die("Cannot delete item. '%s' is not a valid file name", name);
char *path = concat_path_file(dd->dd_dirname... | {'deleted': [], 'added': [{'line_no': 6, 'char_start': 145, 'char_end': 185, 'line': ' if (!str_is_correct_filename(name))\n'}, {'line_no': 7, 'char_start': 185, 'char_end': 271, 'line': ' error_msg_and_die("Cannot delete item. \'%s\' is not a valid file name", name);\n'}, {'line_no': 8, 'char_start': 271, 'c... | {'deleted': [], 'added': [{'char_start': 149, 'char_end': 276, '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 '}]} | github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277 | src/lib/dump_dir.c | cwe-022 | 115 | false | true | false |
cwe-022 | _inject_file_into_fs | def _inject_file_into_fs(fs, path, contents):
absolute_path = os.path.join(fs, path.lstrip('/'))
parent_dir = os.path.dirname(absolute_path)
utils.execute('mkdir', '-p', parent_dir, run_as_root=True)
utils.execute('tee', absolute_path, process_input=contents,
run_as_root=True) | def _inject_file_into_fs(fs, path, contents, append=False):
absolute_path = _join_and_check_path_within_fs(fs, path.lstrip('/'))
parent_dir = os.path.dirname(absolute_path)
utils.execute('mkdir', '-p', parent_dir, run_as_root=True)
args = []
if append:
args.append('-a')
args.append(abs... | {'deleted': [{'line_no': 5, 'char_start': 212, 'char_end': 276, 'line': " utils.execute('tee', absolute_path, process_input=contents,\n"}, {'line_no': 6, 'char_start': 276, 'char_end': 303, 'line': ' run_as_root=True)\n'}], 'added': [{'line_no': 1, 'char_start': 0, 'char_end': 60, 'line': 'def _inject_file_... | {'deleted': [{'char_start': 67, 'char_end': 69, 'chars': 's.'}, {'char_start': 73, 'char_end': 76, 'chars': '.jo'}, {'char_start': 216, 'char_end': 218, 'chars': 'ut'}, {'char_start': 219, 'char_end': 220, 'chars': 'l'}, {'char_start': 222, 'char_end': 224, 'chars': 'ex'}, {'char_start': 225, 'char_end': 229, 'chars': ... | github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7 | nova/virt/disk/api.py | cwe-022 | 74 | false | true | false |
cwe-022 | get | def get(self, path):
return static_file(path, self.get_base_path()) | def get(self, path):
path = self.sanitize_path(path)
base_paths = self.get_base_paths()
if hasattr(base_paths, 'split'):
# String, so go simple
base_path = base_paths
else:
base_path = self.get_first_base(base_paths, path)
return static_fil... | {'deleted': [{'line_no': 2, 'char_start': 25, 'char_end': 79, 'line': ' return static_file(path, self.get_base_path())\n'}], 'added': [{'line_no': 2, 'char_start': 25, 'char_end': 65, 'line': ' path = self.sanitize_path(path)\n'}, {'line_no': 3, 'char_start': 65, 'char_end': 108, 'line': ' base_pat... | {'deleted': [{'char_start': 36, 'char_end': 37, 'chars': 'u'}, {'char_start': 44, 'char_end': 49, 'chars': 'ic_fi'}, {'char_start': 51, 'char_end': 52, 'chars': '('}, {'char_start': 56, 'char_end': 57, 'chars': ','}, {'char_start': 77, 'char_end': 78, 'chars': ')'}], 'added': [{'char_start': 33, 'char_end': 76, 'chars'... | github.com/foxbunny/seagull/commit/1fb790712fe0c1d1957b31e34a8e0e6593af87a7 | seagull/routes/app.py | cwe-022 | 18 | false | true | false |
cwe-022 | handle | def handle(self, keepalive=True, initial_timeout=None):
# we are requested to skip processing and keep the previous values
if self.skip:
return self.response.handle()
# default to no keepalive in case something happens while even trying ensure we have a request
self.keep... | def handle(self, keepalive=True, initial_timeout=None):
# we are requested to skip processing and keep the previous values
if self.skip:
return self.response.handle()
# default to no keepalive in case something happens while even trying ensure we have a request
self.keep... | {'deleted': [{'line_no': 53, 'char_start': 1744, 'char_end': 1834, 'line': ' self.method, self.resource, self.request_http = self.request_line.split()\n'}], 'added': [{'line_no': 53, 'char_start': 1744, 'char_end': 1829, 'line': ' self.method, resource, self.request_http = self.request_lin... | {'deleted': [{'char_start': 1773, 'char_end': 1778, 'chars': 'self.'}], 'added': [{'char_start': 1827, 'char_end': 1890, 'chars': ')\n self.resource = urllib.parse.unquote(resource'}]} | github.com/fkmclane/python-fooster-web/commit/80202a6d3788ad1212a162d19785c600025e6aa4 | fooster/web/web.py | cwe-022 | 761 | false | true | false |
cwe-022 | deleteKey | def deleteKey(client):
"""Deletes the specified key.
Returns an error if the key doesn't exist
"""
global BAD_REQUEST
global NOT_FOUND
validateClient(client)
client_pub_key = loadClientRSAKey(client)
token_data = decodeRequestToken(request.data, client_pub_key)
if re.search('[^a-zA-Z0-9]', token_data['key']... | def deleteKey(client):
"""Deletes the specified key.
Returns an error if the key doesn't exist
"""
global NOT_FOUND
validateClient(client)
client_pub_key = loadClientRSAKey(client)
token_data = decodeRequestToken(request.data, client_pub_key)
validateKeyName(token_data['key'])
try:
os.remove('keys/%s/%s.ke... | {'deleted': [{'line_no': 5, 'char_start': 102, 'char_end': 122, 'line': '\tglobal BAD_REQUEST\n'}, {'line_no': 9, 'char_start': 165, 'char_end': 166, 'line': '\n'}, {'line_no': 12, 'char_start': 272, 'char_end': 273, 'line': '\n'}, {'line_no': 13, 'char_start': 273, 'char_end': 323, 'line': "\tif re.search('[^a-zA-Z0-9... | {'deleted': [{'char_start': 110, 'char_end': 130, 'chars': 'BAD_REQUEST\n\tglobal '}, {'char_start': 165, 'char_end': 166, 'chars': '\n'}, {'char_start': 272, 'char_end': 273, 'chars': '\n'}, {'char_start': 275, 'char_end': 278, 'chars': 'f r'}, {'char_start': 279, 'char_end': 281, 'chars': '.s'}, {'char_start': 283, '... | github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833 | impl.py | cwe-022 | 154 | false | true | false |
cwe-022 | TarFileReader::extract | std::string TarFileReader::extract(const string &_path) {
if (_path.empty()) THROW("path cannot be empty");
if (!hasMore()) THROW("No more tar files");
string path = _path;
if (SystemUtilities::isDirectory(path)) path += "/" + getFilename();
LOG_DEBUG(5, "Extracting: " << path);
return extract(*SystemUti... | std::string TarFileReader::extract(const string &_path) {
if (_path.empty()) THROW("path cannot be empty");
if (!hasMore()) THROW("No more tar files");
string path = _path;
if (SystemUtilities::isDirectory(path)) {
path += "/" + getFilename();
// Check that path is under the target directory
strin... | {'deleted': [{'line_no': 6, 'char_start': 180, 'char_end': 251, 'line': ' if (SystemUtilities::isDirectory(path)) path += "/" + getFilename();\n'}, {'line_no': 10, 'char_start': 293, 'char_end': 342, 'line': ' return extract(*SystemUtilities::oopen(path));\n'}], 'added': [{'line_no': 6, 'char_start': 180, 'char_end':... | {'deleted': [], 'added': [{'char_start': 222, 'char_end': 228, 'chars': '{\n '}, {'char_start': 260, 'char_end': 544, 'chars': ' // Check that path is under the target directory\n string a = SystemUtilities::getCanonicalPath(_path);\n string b = SystemUtilities::getCanonicalPath(path);\n if (!String::start... | github.com/CauldronDevelopmentLLC/cbang/commit/1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7 | src/cbang/tar/TarFileReader.cpp | cwe-022 | 90 | false | true | false |
cwe-022 | pascal_case | def pascal_case(value: str) -> str:
return stringcase.pascalcase(value) | def pascal_case(value: str) -> str:
return stringcase.pascalcase(_sanitize(value)) | {'deleted': [{'line_no': 2, 'char_start': 36, 'char_end': 75, 'line': ' return stringcase.pascalcase(value)\n'}], 'added': [{'line_no': 2, 'char_start': 36, 'char_end': 86, 'line': ' return stringcase.pascalcase(_sanitize(value))\n'}]} | {'deleted': [], 'added': [{'char_start': 69, 'char_end': 79, 'chars': '_sanitize('}, {'char_start': 85, 'char_end': 86, 'chars': ')'}]} | github.com/openapi-generators/openapi-python-client/commit/3e7dfae5d0b3685abf1ede1bc6c086a116ac4746 | openapi_python_client/utils.py | cwe-022 | 20 | false | true | false |
cwe-022 | _inject_key_into_fs | def _inject_key_into_fs(key, fs, execute=None):
"""Add the given public ssh key to root's authorized_keys.
key is an ssh key string.
fs is the path to the base of the filesystem into which to inject the key.
"""
sshdir = os.path.join(fs, 'root', '.ssh')
utils.execute('mkdir', '-p', sshdir, run_... | def _inject_key_into_fs(key, fs, execute=None):
"""Add the given public ssh key to root's authorized_keys.
key is an ssh key string.
fs is the path to the base of the filesystem into which to inject the key.
"""
sshdir = _join_and_check_path_within_fs(fs, 'root', '.ssh')
utils.execute('mkdir', ... | {'deleted': [{'line_no': 7, 'char_start': 229, 'char_end': 275, 'line': " sshdir = os.path.join(fs, 'root', '.ssh')\n"}, {'line_no': 11, 'char_start': 455, 'char_end': 509, 'line': " keyfile = os.path.join(sshdir, 'authorized_keys')\n"}, {'line_no': 12, 'char_start': 509, 'char_end': 526, 'line': ' key_data = ... | {'deleted': [{'char_start': 243, 'char_end': 245, 'chars': 's.'}, {'char_start': 249, 'char_end': 252, 'chars': '.jo'}, {'char_start': 485, 'char_end': 488, 'chars': 'dir'}, {'char_start': 655, 'char_end': 656, 'chars': 'u'}, {'char_start': 659, 'char_end': 663, 'chars': 's.ex'}, {'char_start': 664, 'char_end': 666, 'c... | github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7 | nova/virt/disk/api.py | cwe-022 | 199 | false | true | false |
cwe-022 | wiki_handle_rest_call | wiki_handle_rest_call(HttpRequest *req,
HttpResponse *res,
char *func)
{
if (func != NULL && *func != '\0')
{
if (!strcmp(func, "page/get"))
{
char *page = http_request_param_get(req, "page");
if (page == NULL)
page = http_request_get_query_string(req);
if (page &... | wiki_handle_rest_call(HttpRequest *req,
HttpResponse *res,
char *func)
{
if (func != NULL && *func != '\0')
{
if (!strcmp(func, "page/get"))
{
char *page = http_request_param_get(req, "page");
if (page == NULL)
page = http_request_get_query_string(req);
if (page &... | {'deleted': [{'line_no': 15, 'char_start': 307, 'char_end': 350, 'line': '\t if (page && (access(page, R_OK) == 0)) \n'}, {'line_no': 28, 'char_start': 699, 'char_end': 741, 'line': '\t file_write(page, wikitext);\t \n'}, {'line_no': 41, 'char_start': 1015, 'char_end': 1050, 'line': '\t if (page && (unlink(... | {'deleted': [{'char_start': 348, 'char_end': 349, 'chars': ' '}, {'char_start': 733, 'char_end': 740, 'chars': '\t '}, {'char_start': 1374, 'char_end': 1375, 'chars': ' '}], 'added': [{'char_start': 322, 'char_end': 349, 'chars': 'page_name_is_good(page) && '}, {'char_start': 725, 'char_end': 764, 'chars': '\t if... | github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea | src/wiki.c | cwe-022 | 641 | false | false | false |
cwe-022 | wiki_handle_http_request | wiki_handle_http_request(HttpRequest *req)
{
HttpResponse *res = http_response_new(req);
char *page = http_request_get_path_info(req);
char *command = http_request_get_query_string(req);
char *wikitext = "";
util_dehttpize(page); /* remove any encoding on the requested
... | wiki_handle_http_request(HttpRequest *req)
{
HttpResponse *res = http_response_new(req);
char *page = http_request_get_path_info(req);
char *command = http_request_get_query_string(req);
char *wikitext = "";
util_dehttpize(page); /* remove any encoding on the requested
... | {'deleted': [{'line_no': 54, 'char_start': 1350, 'char_end': 1375, 'line': " if (strchr(page, '/'))\n"}], 'added': [{'line_no': 54, 'char_start': 1350, 'char_end': 1382, 'line': ' if (!page_name_is_good(page))\n'}]} | {'deleted': [{'char_start': 1357, 'char_end': 1362, 'chars': 'trchr'}, {'char_start': 1367, 'char_end': 1372, 'chars': ", '/'"}], 'added': [{'char_start': 1356, 'char_end': 1368, 'chars': '!page_name_i'}, {'char_start': 1369, 'char_end': 1374, 'chars': '_good'}]} | github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea | src/wiki.c | cwe-022 | 795 | false | false | false |
cwe-022 | save | async def save(request):
# TODO csrf
data = await request.post()
item = Item(data['src'])
# Update name
new_src = data.get('new_src')
if new_src and new_src != data['src']:
# don't need to worry about html unquote
shutil.move(item.abspath, settings.STORAGE_DIR + new_src)
... | async def save(request):
# TODO csrf
data = await request.post()
item = Item(data['src'])
# Update name
new_src = data.get('new_src')
if new_src:
new_abspath = os.path.abspath(settings.STORAGE_DIR + new_src)
if not new_abspath.startswith(settings.STORAGE_DIR):
return... | {'deleted': [{'line_no': 8, 'char_start': 155, 'char_end': 198, 'line': " if new_src and new_src != data['src']:\n"}, {'line_no': 10, 'char_start': 247, 'char_end': 313, 'line': ' shutil.move(item.abspath, settings.STORAGE_DIR + new_src)\n'}, {'line_no': 11, 'char_start': 313, 'char_end': 362, 'line': ' ... | {'deleted': [{'char_start': 170, 'char_end': 173, 'chars': 'and'}, {'char_start': 179, 'char_end': 181, 'chars': 'rc'}, {'char_start': 182, 'char_end': 183, 'chars': '!'}, {'char_start': 185, 'char_end': 186, 'chars': 'd'}, {'char_start': 189, 'char_end': 191, 'chars': "['"}, {'char_start': 194, 'char_end': 197, 'chars... | github.com/crccheck/gallery-cms/commit/60dec5c580a779ae27824ed54cb113eca25afdc0 | gallery/gallery.py | cwe-022 | 239 | false | true | false |
cwe-022 | Utility::UnZip | bool Utility::UnZip(const QString &zippath, const QString &destpath)
{
int res = 0;
QDir dir(destpath);
if (!cp437) {
cp437 = new QCodePage437Codec();
}
#ifdef Q_OS_WIN32
zlib_filefunc64_def ffunc;
fill_win32_filefunc64W(&ffunc);
unzFile zfile = unzOpen2_64(Utility::QStringToStdWStri... | bool Utility::UnZip(const QString &zippath, const QString &destpath)
{
int res = 0;
QDir dir(destpath);
if (!cp437) {
cp437 = new QCodePage437Codec();
}
#ifdef Q_OS_WIN32
zlib_filefunc64_def ffunc;
fill_win32_filefunc64W(&ffunc);
unzFile zfile = unzOpen2_64(Utility::QStringToStdWStri... | {'deleted': [], 'added': [{'line_no': 39, 'char_start': 1400, 'char_end': 1401, 'line': '\n'}, {'line_no': 46, 'char_start': 1800, 'char_end': 1801, 'line': '\n'}, {'line_no': 47, 'char_start': 1801, 'char_end': 1846, 'line': '\t QString original_path = qfile_name;\n'}, {'line_no': 48, 'char_start': 1846, 'char_... | {'deleted': [], 'added': [{'char_start': 1400, 'char_end': 2937, 'chars': '\n\t // for security reasons against maliciously crafted zip archives\n\t // we need the file path to always be inside the target folder \n\t // and not outside, so we will remove all illegal backslashes\n\t // and al... | github.com/Sigil-Ebook/Sigil/commit/0979ba8d10c96ebca330715bfd4494ea0e019a8f | src/Misc/Utility.cpp | cwe-022 | 928 | false | false | false |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 31