Showing 1 of 3 files from the diff.

@@ -6,6 +6,7 @@
Loading
6 6
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
7 7
# Copyright © 2013-2016 Luca Wehrstedt <luca.wehrstedt@gmail.com>
8 8
# Copyright © 2016 William Di Luigi <williamdiluigi@gmail.com>
9 +
# Copyright © 2020 Andrey Vihrov <andrey.vihrov@gmail.com>
9 10
#
10 11
# This program is free software: you can redistribute it and/or modify
11 12
# it under the terms of the GNU Affero General Public License as
@@ -26,6 +27,7 @@
Loading
26 27
import logging
27 28
import netifaces
28 29
import os
30 +
import stat
29 31
import sys
30 32
31 33
import chardet
@@ -63,10 +65,9 @@
Loading
63 65
            return True
64 66
65 67
66 -
# This function is vulnerable to a symlink attack, see:
67 -
# https://bugs.python.org/issue4489
68 -
# It appears the only bulletproof fix requires the ability to traverse
69 -
# directories using file descriptors (like fwalk) which is only in py3.
68 +
# This function uses os.fwalk() to avoid the symlink attack, see:
69 +
# - https://bugs.python.org/issue4489
70 +
# - https://bugs.python.org/issue13734
70 71
def rmtree(path):
71 72
    """Recursively delete a directory tree.
72 73
@@ -79,20 +80,20 @@
Loading
79 80
    raise (OSError): in case of errors in the elementary operations.
80 81
81 82
    """
82 -
    if os.path.islink(path):
83 -
        raise OSError("unsafe to call rmtree on a symlink")
84 -
85 -
    for dirpath, subdirnames, filenames in os.walk(path, topdown=False):
83 +
    # If path is a symlink, fwalk() yields no entries.
84 +
    for _, subdirnames, filenames, dirfd in os.fwalk(path, topdown=False):
86 85
        for filename in filenames:
87 -
            os.remove(os.path.join(dirpath, filename))
86 +
            os.remove(filename, dir_fd=dirfd)
88 87
            gevent.sleep(0)
89 88
        for subdirname in subdirnames:
90 -
            subdirpath = os.path.join(dirpath, subdirname)
91 -
            if os.path.islink(subdirpath):
92 -
                os.remove(subdirpath)
93 -
                gevent.sleep(0)
94 -
        os.rmdir(dirpath)
95 -
        gevent.sleep(0)
89 +
            if stat.S_ISLNK(os.lstat(subdirname, dir_fd=dirfd).st_mode):
90 +
                os.remove(subdirname, dir_fd=dirfd)
91 +
            else:
92 +
                os.rmdir(subdirname, dir_fd=dirfd)
93 +
            gevent.sleep(0)
94 +
95 +
    # Remove the directory itself. An exception is raised if path is a symlink.
96 +
    os.rmdir(path)
96 97
97 98
98 99
def utf8_decoder(value):
Files Coverage
cms 72.61%
cmscommon 60.69%
cmscontrib 45.62%
cmsranking 58.66%
cmstaskenv 0.00%
Project Totals (232 files) 62.44%
1521.1
3.6=functionaltests.6
TRAVIS_OS_NAME=linux
functionaltests
1521.1
3.6=unittests.6
TRAVIS_OS_NAME=linux
unittests

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading