Implement a consistent realpath function in certbot.compat.filesystem (#7242)

Fixes #7115 

This PR creates a `realpath` method in `filesystem`, whose goal is to replace any call to `os.path.realpath` in Certbot. The reason is that `os.path.realpath` is broken on some versions of Python for Windows. See https://bugs.python.org/issue9949. The function created here works consistently across Linux and Windows.

As for the other forbidden functions in `os` module, our `certbot.compat.os` will raise an exception if its `path.realpath` function is invoked, and using the `os` module from Python is forbidden from the pylint check implemented in our CI.

Every call to `os.path.realpath` is corrected in `certbot` and `certbot-apache` modules.

* Forbid os.path.realpath

* Finish implementation

* Use filesystem.realpath

* Control symlink loops also for Linux

* Add a test for forbidden method

* Import a new object from os.path module

* Use same approach of wrapping than certbot.compat.os

* Correct errors

* Fix dependencies

* Make path module internal
This commit is contained in:
Adrien Ferrand
2019-07-18 14:31:39 -07:00
committed by Brad Warren
parent 41a17f913e
commit 71ff47daad
20 changed files with 134 additions and 45 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ version = '0.37.0.dev0'
# acme/certbot version.
install_requires = [
'acme>=0.29.0',
'certbot>=0.36.0',
'certbot>=0.37.0.dev0',
'mock',
'python-augeas',
'setuptools',