The following issues were found
Lib/turtledemo/rosette.py
17 issues
Line: 16
Column: 1
Followed by a complete undo().
"""
from turtle import Screen, Turtle, mainloop
from time import perf_counter as clock, sleep
def mn_eck(p, ne,sz):
turtlelist = [p]
#create ne-1 additional turtles
Reported by Pylint.
Line: 19
Column: 1
from turtle import Screen, Turtle, mainloop
from time import perf_counter as clock, sleep
def mn_eck(p, ne,sz):
turtlelist = [p]
#create ne-1 additional turtles
for i in range(1,ne):
q = p.clone()
q.rt(360.0/ne)
Reported by Pylint.
Line: 19
Column: 1
from turtle import Screen, Turtle, mainloop
from time import perf_counter as clock, sleep
def mn_eck(p, ne,sz):
turtlelist = [p]
#create ne-1 additional turtles
for i in range(1,ne):
q = p.clone()
q.rt(360.0/ne)
Reported by Pylint.
Line: 19
Column: 1
from turtle import Screen, Turtle, mainloop
from time import perf_counter as clock, sleep
def mn_eck(p, ne,sz):
turtlelist = [p]
#create ne-1 additional turtles
for i in range(1,ne):
q = p.clone()
q.rt(360.0/ne)
Reported by Pylint.
Line: 19
Column: 1
from turtle import Screen, Turtle, mainloop
from time import perf_counter as clock, sleep
def mn_eck(p, ne,sz):
turtlelist = [p]
#create ne-1 additional turtles
for i in range(1,ne):
q = p.clone()
q.rt(360.0/ne)
Reported by Pylint.
Line: 23
Column: 9
turtlelist = [p]
#create ne-1 additional turtles
for i in range(1,ne):
q = p.clone()
q.rt(360.0/ne)
turtlelist.append(q)
p = q
for i in range(ne):
c = abs(ne/2.0-i)/(ne*.7)
Reported by Pylint.
Line: 28
Column: 9
turtlelist.append(q)
p = q
for i in range(ne):
c = abs(ne/2.0-i)/(ne*.7)
# let those ne turtles make a step
# in parallel:
for t in turtlelist:
t.rt(360./ne)
t.pencolor(1-c,0,c)
Reported by Pylint.
Line: 31
Column: 13
c = abs(ne/2.0-i)/(ne*.7)
# let those ne turtles make a step
# in parallel:
for t in turtlelist:
t.rt(360./ne)
t.pencolor(1-c,0,c)
t.fd(sz)
def main():
Reported by Pylint.
Line: 36
Column: 1
t.pencolor(1-c,0,c)
t.fd(sz)
def main():
s = Screen()
s.bgcolor("black")
p=Turtle()
p.speed(0)
p.hideturtle()
Reported by Pylint.
Line: 37
Column: 5
t.fd(sz)
def main():
s = Screen()
s.bgcolor("black")
p=Turtle()
p.speed(0)
p.hideturtle()
p.pencolor("red")
Reported by Pylint.
Lib/zipapp.py
17 issues
Line: 76
Column: 59
os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC)
def create_archive(source, target=None, interpreter=None, main=None,
filter=None, compressed=False):
"""Create an application archive from SOURCE.
The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.
Reported by Pylint.
Line: 77
Column: 20
def create_archive(source, target=None, interpreter=None, main=None,
filter=None, compressed=False):
"""Create an application archive from SOURCE.
The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.
Reported by Pylint.
Line: 1
Column: 1
import contextlib
import os
import pathlib
import shutil
import stat
import sys
import zipfile
__all__ = ['ZipAppError', 'create_archive', 'get_interpreter']
Reported by Pylint.
Line: 28
Column: 5
# file has no BOM. So use UTF-8 on Windows.
# On Unix, use the filesystem encoding.
if sys.platform.startswith('win'):
shebang_encoding = 'utf-8'
else:
shebang_encoding = sys.getfilesystemencoding()
class ZipAppError(ValueError):
Reported by Pylint.
Line: 33
Column: 1
shebang_encoding = sys.getfilesystemencoding()
class ZipAppError(ValueError):
pass
@contextlib.contextmanager
def _maybe_open(archive, mode):
Reported by Pylint.
Line: 40
Column: 37
@contextlib.contextmanager
def _maybe_open(archive, mode):
if isinstance(archive, (str, os.PathLike)):
with open(archive, mode) as f:
yield f
else:
yield archive
Reported by Pylint.
Line: 46
Column: 1
yield archive
def _write_file_prefix(f, interpreter):
"""Write a shebang line."""
if interpreter:
shebang = b'#!' + interpreter.encode(shebang_encoding) + b'\n'
f.write(shebang)
Reported by Pylint.
Line: 76
Column: 1
os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC)
def create_archive(source, target=None, interpreter=None, main=None,
filter=None, compressed=False):
"""Create an application archive from SOURCE.
The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.
Reported by Pylint.
Line: 76
Column: 1
os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC)
def create_archive(source, target=None, interpreter=None, main=None,
filter=None, compressed=False):
"""Create an application archive from SOURCE.
The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.
Reported by Pylint.
Line: 76
Column: 1
os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC)
def create_archive(source, target=None, interpreter=None, main=None,
filter=None, compressed=False):
"""Create an application archive from SOURCE.
The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.
Reported by Pylint.
Modules/_decimal/libmpdec/mpdecimal.c
17 issues
Line: 2012
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
result->exp = a->exp;
result->digits = a->digits;
result->len = a->len;
memcpy(result->data, a->data, a->len * (sizeof *result->data));
return 1;
}
/* Same as mpd_qcopy, but do not set the result to NaN on failure. */
Reported by FlawFinder.
Line: 2031
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
result->exp = a->exp;
result->digits = a->digits;
result->len = a->len;
memcpy(result->data, a->data, a->len * (sizeof *result->data));
return 1;
}
/*
Reported by FlawFinder.
Line: 2045
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
{
if (result == a) return;
memcpy(result->data, a->data, a->len * (sizeof *result->data));
mpd_copy_flags(result, a);
result->exp = a->exp;
result->digits = a->digits;
result->len = a->len;
Reported by FlawFinder.
Line: 2065
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if ((result = mpd_qnew_size(a->len)) == NULL) {
return NULL;
}
memcpy(result->data, a->data, a->len * (sizeof *result->data));
mpd_copy_flags(result, a);
result->exp = a->exp;
result->digits = a->digits;
result->len = a->len;
Reported by FlawFinder.
Line: 5495
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
/* la >= lb > m */
memcpy(w, a, m * sizeof *w);
w[m] = 0;
_mpd_baseaddto(w, a+m, la-m);
memcpy(w+(m+1), b, m * sizeof *w);
w[m+1+m] = 0;
Reported by FlawFinder.
Line: 5499
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
w[m] = 0;
_mpd_baseaddto(w, a+m, la-m);
memcpy(w+(m+1), b, m * sizeof *w);
w[m+1+m] = 0;
_mpd_baseaddto(w+(m+1), b+m, lb-m);
_karatsuba_rec(c+m, w, w+(m+1), w+2*(m+1), m+1, m+1);
Reported by FlawFinder.
Line: 5679
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
goto malloc_error;
}
memcpy(c1, u, ulen * (sizeof *c1));
memcpy(c2, u, ulen * (sizeof *c2));
memcpy(c3, u, ulen * (sizeof *c3));
if (u == v) {
if (!fnt_autoconvolute(c1, n, P1) ||
Reported by FlawFinder.
Line: 5680
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
memcpy(c1, u, ulen * (sizeof *c1));
memcpy(c2, u, ulen * (sizeof *c2));
memcpy(c3, u, ulen * (sizeof *c3));
if (u == v) {
if (!fnt_autoconvolute(c1, n, P1) ||
!fnt_autoconvolute(c2, n, P2) ||
Reported by FlawFinder.
Line: 5681
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
memcpy(c1, u, ulen * (sizeof *c1));
memcpy(c2, u, ulen * (sizeof *c2));
memcpy(c3, u, ulen * (sizeof *c3));
if (u == v) {
if (!fnt_autoconvolute(c1, n, P1) ||
!fnt_autoconvolute(c2, n, P2) ||
!fnt_autoconvolute(c3, n, P3)) {
Reported by FlawFinder.
Line: 5695
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
goto malloc_error;
}
memcpy(vtmp, v, vlen * (sizeof *vtmp));
if (!fnt_convolute(c1, vtmp, n, P1)) {
mpd_free(vtmp);
goto malloc_error;
}
Reported by FlawFinder.
Modules/_elementtree.c
17 issues
Line: 485
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (!children)
goto nomemory;
/* copy existing children from static area to malloc buffer */
memcpy(children, self->extra->children,
self->extra->length * sizeof(PyObject*));
}
self->extra->children = children;
self->extra->allocated = size;
}
Reported by FlawFinder.
Line: 3127
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
p = PyBytes_AS_STRING(tag);
p[0] = '{';
memcpy(p+1, string, size);
size++;
} else {
/* plain name; use key as tag */
Py_INCREF(key);
tag = key;
Reported by FlawFinder.
Line: 3242
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
Py_XDECREF(res);
} else if (!PyErr_Occurred()) {
/* Report the first error, not the last */
char message[128] = "undefined entity ";
strncat(message, data_in, data_len < 100?data_len:100);
expat_set_error(
XML_ERROR_UNDEFINED_ENTITY,
EXPAT(GetErrorLineNumber)(self->parser),
EXPAT(GetErrorColumnNumber)(self->parser),
Reported by FlawFinder.
Line: 3092
Column: 36
CWE codes:
126
/* convert a UTF-8 tag/attribute name from the expat parser
to a universal name string */
Py_ssize_t size = (Py_ssize_t) strlen(string);
PyObject* key;
PyObject* value;
/* look the 'raw' name up in the names dictionary */
key = PyBytes_FromStringAndSize(string, size);
Reported by FlawFinder.
Line: 3243
Column: 9
CWE codes:
120
Suggestion:
Consider strcat_s, strlcat, snprintf, or automatically resizing strings
} else if (!PyErr_Occurred()) {
/* Report the first error, not the last */
char message[128] = "undefined entity ";
strncat(message, data_in, data_len < 100?data_len:100);
expat_set_error(
XML_ERROR_UNDEFINED_ENTITY,
EXPAT(GetErrorLineNumber)(self->parser),
EXPAT(GetErrorColumnNumber)(self->parser),
message
Reported by FlawFinder.
Line: 3281
Column: 66
CWE codes:
126
}
while (attrib_in[0] && attrib_in[1]) {
PyObject* key = makeuniversal(self, attrib_in[0]);
PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict");
if (!key || !value) {
Py_XDECREF(value);
Py_XDECREF(key);
Py_DECREF(attrib);
Py_DECREF(tag);
Reported by FlawFinder.
Line: 3402
Column: 54
CWE codes:
126
TreeBuilderObject *target = (TreeBuilderObject*) self->target;
if (target->events_append && target->start_ns_event_obj) {
prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict");
if (!prefix)
return;
uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict");
if (!uri) {
Py_DECREF(prefix);
Reported by FlawFinder.
Line: 3405
Column: 48
CWE codes:
126
prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict");
if (!prefix)
return;
uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict");
if (!uri) {
Py_DECREF(prefix);
return;
}
Reported by FlawFinder.
Line: 3416
Column: 50
CWE codes:
126
Py_DECREF(prefix);
}
} else if (self->handle_start_ns) {
prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict");
if (!prefix)
return;
uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict");
if (!uri) {
Py_DECREF(prefix);
Reported by FlawFinder.
Line: 3419
Column: 44
CWE codes:
126
prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict");
if (!prefix)
return;
uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict");
if (!uri) {
Py_DECREF(prefix);
return;
}
Reported by FlawFinder.
Modules/mmapmodule.c
17 issues
Line: 114
Column: 17
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
#endif
PyObject *weakreflist;
access_mode access;
} mmap_object;
typedef struct {
PyTypeObject *mmap_object_type;
} mmap_state;
Reported by FlawFinder.
Line: 368
Column: 15
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
static int
is_writable(mmap_object *self)
{
if (self->access != ACCESS_READ)
return 1;
PyErr_Format(PyExc_TypeError, "mmap can't modify a readonly memory map.");
return 0;
}
Reported by FlawFinder.
Line: 743
Column: 23
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
} else {
const char *access_str;
switch (mobj->access) {
case ACCESS_DEFAULT:
access_str = "ACCESS_DEFAULT";
break;
case ACCESS_READ:
access_str = "ACCESS_READ";
Reported by FlawFinder.
Line: 1154
Column: 39
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "in|iii" _Py_PARSE_OFF_T, keywords,
&fd, &map_size, &flags, &prot,
&access, &offset))
return NULL;
if (map_size < 0) {
PyErr_SetString(PyExc_OverflowError,
"memory mapped length must be positive");
return NULL;
Reported by FlawFinder.
Line: 1167
Column: 10
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
return NULL;
}
if ((access != (int)ACCESS_DEFAULT) &&
((flags != MAP_SHARED) || (prot != (PROT_WRITE | PROT_READ))))
return PyErr_Format(PyExc_ValueError,
"mmap can't specify both access and flags, prot.");
switch ((access_mode)access) {
case ACCESS_READ:
Reported by FlawFinder.
Line: 1171
Column: 26
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
((flags != MAP_SHARED) || (prot != (PROT_WRITE | PROT_READ))))
return PyErr_Format(PyExc_ValueError,
"mmap can't specify both access and flags, prot.");
switch ((access_mode)access) {
case ACCESS_READ:
flags = MAP_SHARED;
prot = PROT_READ;
break;
case ACCESS_WRITE:
Reported by FlawFinder.
Line: 1202
Column: 35
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
}
if (PySys_Audit("mmap.__new__", "ini" _Py_PARSE_OFF_T,
fd, map_size, access, offset) < 0) {
return NULL;
}
#ifdef __APPLE__
/* Issue #11277: fsync(2) is not enough on OS X - a special, OS X specific
Reported by FlawFinder.
Line: 1298
Column: 34
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
m_obj->access = (access_mode)access;
return (PyObject *)m_obj;
}
#endif /* UNIX */
#ifdef MS_WINDOWS
Reported by FlawFinder.
Line: 1332
Column: 49
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "in|ziL", keywords,
&fileno, &map_size,
&tagname, &access, &offset)) {
return NULL;
}
if (PySys_Audit("mmap.__new__", "iniL",
fileno, map_size, access, offset) < 0) {
Reported by FlawFinder.
Line: 1337
Column: 39
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
}
if (PySys_Audit("mmap.__new__", "iniL",
fileno, map_size, access, offset) < 0) {
return NULL;
}
switch((access_mode)access) {
case ACCESS_READ:
Reported by FlawFinder.
Modules/unicodedata.c
17 issues
Line: 156
CWE codes:
908
if (!have_old)
rc = Py_UNICODE_TODECIMAL(c);
if (rc < 0) {
if (default_value == NULL) {
PyErr_SetString(PyExc_ValueError,
"not a decimal");
return NULL;
}
Reported by Cppcheck.
Line: 244
CWE codes:
908
if (!have_old)
rc = Py_UNICODE_TONUMERIC(c);
if (rc == -1.0) {
if (default_value == NULL) {
PyErr_SetString(PyExc_ValueError, "not a numeric character");
return NULL;
}
else {
Reported by Cppcheck.
Line: 1102
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
return 0;
strcpy(buffer, "HANGUL SYLLABLE ");
buffer += 16;
strcpy(buffer, hangul_syllables[L][0]);
buffer += strlen(hangul_syllables[L][0]);
strcpy(buffer, hangul_syllables[V][1]);
buffer += strlen(hangul_syllables[V][1]);
strcpy(buffer, hangul_syllables[T][2]);
buffer += strlen(hangul_syllables[T][2]);
Reported by FlawFinder.
Line: 1104
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
buffer += 16;
strcpy(buffer, hangul_syllables[L][0]);
buffer += strlen(hangul_syllables[L][0]);
strcpy(buffer, hangul_syllables[V][1]);
buffer += strlen(hangul_syllables[V][1]);
strcpy(buffer, hangul_syllables[T][2]);
buffer += strlen(hangul_syllables[T][2]);
*buffer = '\0';
return 1;
Reported by FlawFinder.
Line: 1106
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
buffer += strlen(hangul_syllables[L][0]);
strcpy(buffer, hangul_syllables[V][1]);
buffer += strlen(hangul_syllables[V][1]);
strcpy(buffer, hangul_syllables[T][2]);
buffer += strlen(hangul_syllables[T][2]);
*buffer = '\0';
return 1;
}
Reported by FlawFinder.
Line: 411
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
/*[clinic end generated code: output=7d699f3ec7565d27 input=e4c12459ad68507b]*/
{
char decomp[256];
int code, index, count;
size_t i;
unsigned int prefix_index;
Py_UCS4 c = (Py_UCS4)chr;
Reported by FlawFinder.
Line: 448
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
/* copy prefix */
i = strlen(decomp_prefix[prefix_index]);
memcpy(decomp, decomp_prefix[prefix_index], i);
while (count-- > 0) {
if (i)
decomp[i++] = ' ';
assert(i < sizeof(decomp));
Reported by FlawFinder.
Line: 1100
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
if (buflen < 27)
/* Worst case: HANGUL SYLLABLE <10chars>. */
return 0;
strcpy(buffer, "HANGUL SYLLABLE ");
buffer += 16;
strcpy(buffer, hangul_syllables[L][0]);
buffer += strlen(hangul_syllables[L][0]);
strcpy(buffer, hangul_syllables[V][1]);
buffer += strlen(hangul_syllables[V][1]);
Reported by FlawFinder.
Line: 1116
Column: 9
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
if (buflen < 28)
/* Worst case: CJK UNIFIED IDEOGRAPH-20000 */
return 0;
sprintf(buffer, "CJK UNIFIED IDEOGRAPH-%X", code);
return 1;
}
/* get offset into phrasebook */
offset = phrasebook_offset1[(code>>phrasebook_shift)];
Reported by FlawFinder.
Line: 1175
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
{
/* check if code corresponds to the given name */
int i;
char buffer[NAME_MAXLEN+1];
if (!_getucname(self, code, buffer, NAME_MAXLEN, 1))
return 0;
for (i = 0; i < namelen; i++) {
if (Py_TOUPPER(name[i]) != buffer[i])
return 0;
Reported by FlawFinder.
Tools/c-analyzer/c_parser/parser/_compound_decl_body.py
17 issues
Line: 3
Column: 1
import re
from ._regexes import (
STRUCT_MEMBER_DECL as _STRUCT_MEMBER_DECL,
ENUM_MEMBER_DECL as _ENUM_MEMBER_DECL,
)
from ._common import (
log_match,
parse_var_decl,
Reported by Pylint.
Line: 7
Column: 1
STRUCT_MEMBER_DECL as _STRUCT_MEMBER_DECL,
ENUM_MEMBER_DECL as _ENUM_MEMBER_DECL,
)
from ._common import (
log_match,
parse_var_decl,
set_capture_groups,
)
Reported by Pylint.
Line: 106
Column: 20
else:
# This shouldn't happen (we expect each field to have a name).
raise NotImplementedError
name = sized_name or anon_name('struct-field-')
data = int(size)
yield srcinfo.resolve('field', data, name, parent) # XXX Restart?
if ending == ',':
remainder = rf'{qualspec} {remainder}'
Reported by Pylint.
Line: 42
Column: 43
if srcinfo is not None:
srcinfo.done()
return
for item in _parse_struct_next(m, srcinfo, anon_name, parent):
if callable(item):
parse_body = item
yield from parse_body(source)
else:
yield item
Reported by Pylint.
Line: 87
Column: 3
data.append(item)
else:
yield item
# XXX Should "parent" really be None for inline type decls?
yield srcinfo.resolve(kind, data, name, parent=None)
srcinfo.resume()
yield parse_body
Reported by Pylint.
Line: 106
Column: 13
else:
# This shouldn't happen (we expect each field to have a name).
raise NotImplementedError
name = sized_name or anon_name('struct-field-')
data = int(size)
yield srcinfo.resolve('field', data, name, parent) # XXX Restart?
if ending == ',':
remainder = rf'{qualspec} {remainder}'
Reported by Pylint.
Line: 109
Column: 3
name = sized_name or anon_name('struct-field-')
data = int(size)
yield srcinfo.resolve('field', data, name, parent) # XXX Restart?
if ending == ',':
remainder = rf'{qualspec} {remainder}'
srcinfo.advance(remainder)
Reported by Pylint.
Line: 139
Column: 21
if srcinfo is not None:
srcinfo.done()
return
remainder = srcinfo.text[m.end():]
(close,
name, init, ending,
) = m.groups()
if close:
Reported by Pylint.
Line: 148
Column: 19
ending = '}'
else:
data = init
yield srcinfo.resolve('field', data, name, _parent)
srcinfo.advance(remainder)
#############################
Reported by Pylint.
Line: 149
Column: 9
else:
data = init
yield srcinfo.resolve('field', data, name, _parent)
srcinfo.advance(remainder)
#############################
DECL_BODY_PARSERS = {
Reported by Pylint.
Tools/scripts/get-remote-certificate.py
17 issues
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
status = proc.wait()
output = proc.stdout.read()
return status, output
def strip_to_x509_cert(certfile_contents, outfile=None):
Reported by Bandit.
Line: 15
Column: 37
import tempfile
def fetch_server_certificate (host, port):
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
status = proc.wait()
Reported by Pylint.
Line: 15
Column: 31
import tempfile
def fetch_server_certificate (host, port):
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
status = proc.wait()
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b306-mktemp-q
if not m:
return None
else:
tn = tempfile.mktemp()
with open(tn, "wb") as fp:
fp.write(m.group(1) + b"\n")
try:
tn2 = (outfile or tempfile.mktemp())
status, output = subproc(r'openssl x509 -in "%s" -out "%s"' %
Reported by Bandit.
Line: 35
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b306-mktemp-q
with open(tn, "wb") as fp:
fp.write(m.group(1) + b"\n")
try:
tn2 = (outfile or tempfile.mktemp())
status, output = subproc(r'openssl x509 -in "%s" -out "%s"' %
(tn, tn2))
if status != 0:
raise RuntimeError('OpenSSL x509 failed with status %s and '
'output: %r' % (status, output))
Reported by Bandit.
Line: 49
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b306-mktemp-q
os.unlink(tn)
if sys.platform.startswith("win"):
tfile = tempfile.mktemp()
with open(tfile, "w") as fp:
fp.write("quit\n")
try:
status, output = subproc(
'openssl s_client -connect "%s:%s" -showcerts < "%s"' %
Reported by Bandit.
Line: 1
Column: 1
#!/usr/bin/env python3
#
# fetch the certificate that the server(s) are providing in PEM form
#
# args are HOST:PORT [, HOST:PORT...]
#
# By Bill Janssen.
import re
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
#
# fetch the certificate that the server(s) are providing in PEM form
#
# args are HOST:PORT [, HOST:PORT...]
#
# By Bill Janssen.
import re
Reported by Pylint.
Line: 15
Column: 1
import tempfile
def fetch_server_certificate (host, port):
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
status = proc.wait()
Reported by Pylint.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
def fetch_server_certificate (host, port):
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
status = proc.wait()
output = proc.stdout.read()
return status, output
Reported by Bandit.
Tools/scripts/findnocoding.py
17 issues
Line: 19
Column: 1
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
elif os.path.isdir(path):
for root, dirs, files in os.walk(path):
Reported by Pylint.
Line: 19
Column: 1
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
elif os.path.isdir(path):
for root, dirs, files in os.walk(path):
Reported by Pylint.
Line: 19
Column: 1
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
elif os.path.isdir(path):
for root, dirs, files in os.walk(path):
Reported by Pylint.
Line: 24
Column: 31
if os.path.isfile(path):
yield path.endswith(".py")
elif os.path.isdir(path):
for root, dirs, files in os.walk(path):
for filename in files:
if filename.endswith(".py"):
yield os.path.join(root, filename)
pysource = pysource()
Reported by Pylint.
Line: 52
Column: 23
else:
return True
def needs_declaration(fullpath):
try:
infile = open(fullpath, 'rb')
except IOError: # Oops, the file was removed - ignore it
return None
Reported by Pylint.
Line: 10
Column: 1
__author__ = "Oleg Broytmann, Georg Brandl"
import sys, os, re, getopt
# our pysource module finds Python source files
try:
import pysource
except ImportError:
Reported by Pylint.
Line: 17
Column: 5
import pysource
except ImportError:
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
Reported by Pylint.
Line: 17
Column: 5
import pysource
except ImportError:
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
Reported by Pylint.
Line: 17
Column: 5
import pysource
except ImportError:
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
Reported by Pylint.
Line: 19
Column: 9
# emulate the module with a simple os.walk
class pysource:
has_python_ext = looks_like_python = can_be_compiled = None
def walk_python_files(self, paths, *args, **kwargs):
for path in paths:
if os.path.isfile(path):
yield path.endswith(".py")
elif os.path.isdir(path):
for root, dirs, files in os.walk(path):
Reported by Pylint.
Tools/peg_generator/scripts/test_pypi_packages.py
17 issues
Line: 59
Column: 12
def run_tests(dirname: str, tree: int) -> int:
return test_parse_directory.parse_directory(
dirname,
verbose=False,
excluded_files=[],
tree_arg=tree,
short=True,
Reported by Pylint.
Line: 59
Column: 12
def run_tests(dirname: str, tree: int) -> int:
return test_parse_directory.parse_directory(
dirname,
verbose=False,
excluded_files=[],
tree_arg=tree,
short=True,
Reported by Pylint.
Line: 59
Column: 12
def run_tests(dirname: str, tree: int) -> int:
return test_parse_directory.parse_directory(
dirname,
verbose=False,
excluded_files=[],
tree_arg=tree,
short=True,
Reported by Pylint.
Line: 12
Column: 1
import pathlib
import sys
from typing import Generator, Any
sys.path.insert(0, ".")
from pegen import build
from scripts import test_parse_directory
Reported by Pylint.
Line: 16
Column: 1
sys.path.insert(0, ".")
from pegen import build
from scripts import test_parse_directory
HERE = pathlib.Path(__file__).resolve().parent
argparser = argparse.ArgumentParser(
Reported by Pylint.
Line: 83
Column: 15
print(e)
continue
print(f"Trying to parse all python files ... ")
dirname = find_dirname(package)
status = run_tests(dirname, tree)
if status == 0:
shutil.rmtree(dirname)
else:
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3.8
import argparse
import os
import glob
import tarfile
import zipfile
import shutil
import pathlib
Reported by Pylint.
Line: 16
Column: 1
sys.path.insert(0, ".")
from pegen import build
from scripts import test_parse_directory
HERE = pathlib.Path(__file__).resolve().parent
argparser = argparse.ArgumentParser(
Reported by Pylint.
Line: 17
Column: 1
sys.path.insert(0, ".")
from pegen import build
from scripts import test_parse_directory
HERE = pathlib.Path(__file__).resolve().parent
argparser = argparse.ArgumentParser(
prog="test_pypi_packages",
Reported by Pylint.
Line: 30
Column: 1
)
def get_packages() -> Generator[str, None, None]:
all_packages = (
glob.glob("./data/pypi/*.tar.gz")
+ glob.glob("./data/pypi/*.zip")
+ glob.glob("./data/pypi/*.tgz")
)
Reported by Pylint.