[Windows] Security model for files permissions - STEP 2 (#6895)

This PR is the second part of #6497 to ease the integration, following the new plan propose by @bmw here: #6497 (comment)

This PR creates the module certbot.compat.os, that delegates everything to os, and that will be the safeguard against problematic methods of the standard module. On top of that, a quality check wrapper is called in the lint tox environment. This wrapper calls pylint and ensures that standard os module is no used directly in the certbot codebase.

Finally local oldest requirements are updated to ensure that tests will take the new logic when running.

* Add executable permissions

* Add the delegate certbot.compat.os module, add check coding style to enforce usage of certbot.compat.os instead of standard os

* Load certbot.compat.os instead of os

* Move existing compat test

* Update local oldest requirements

* Import sys

* Update account_test.py

* Update os.py

* Update os.py

* Update local oldest requirements

* Implement the new linter_plugin

* Fix local oldest for nginx

* Remove check coding style

* Update linter_plugin.py

* Add several comments

* Update the setup.py

* Add documentation

* Update acme dependencies

* Update certbot/compat/os.py

* Update docs/contributing.rst

* Update linter_plugin.py

* Handle os.path. Simplify checker.

* Add a comment to a reference implementation

* Update changelog

* Fix module registering

* Update docs/contributing.rst

* Update config and changelog
This commit is contained in:
Adrien Ferrand
2019-04-12 13:32:51 -07:00
committed by Brad Warren
parent 9c54f3dec8
commit d5de24d9fc
133 changed files with 321 additions and 240 deletions
+2 -1
View File
@@ -1,8 +1,9 @@
""" Utility functions for certbot-apache plugin """
import binascii
import os
from certbot import util
from certbot.compat import os
def get_mod_deps(mod_name):
"""Get known module dependencies.
@@ -3,7 +3,6 @@
import copy
import fnmatch
import logging
import os
import re
import socket
import time
@@ -17,13 +16,14 @@ import zope.component
import zope.interface
from acme import challenges
from acme.magic_typing import Any, DefaultDict, Dict, List, Set, Union # pylint: disable=unused-import, no-name-in-module
from acme.magic_typing import DefaultDict, Dict, List, Set, Union # pylint: disable=unused-import, no-name-in-module
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.achallenges import KeyAuthorizationAnnotatedChallenge # pylint: disable=unused-import
from certbot.compat import os
from certbot.plugins import common
from certbot.plugins.util import path_surgery
from certbot.plugins.enhancements import AutoHSTSEnhancement
+2 -4
View File
@@ -1,14 +1,12 @@
"""Contains UI methods for Apache operations."""
import logging
import os
import zope.component
import certbot.display.util as display_util
from certbot import errors
from certbot import interfaces
import certbot.display.util as display_util
from certbot.compat import os
logger = logging.getLogger(__name__)
+4 -1
View File
@@ -1,15 +1,18 @@
"""A class that performs HTTP-01 challenges for Apache"""
import logging
import os
from acme.magic_typing import List, Set # pylint: disable=unused-import, no-name-in-module
from certbot import errors
from certbot.compat import os
from certbot.plugins import common
from certbot_apache.obj import VirtualHost # pylint: disable=unused-import
from certbot_apache.parser import get_aug_path
logger = logging.getLogger(__name__)
class ApacheHttp01(common.TLSSNI01):
"""Class that performs HTTP-01 challenges within the Apache configurator."""
@@ -1,19 +1,20 @@
""" Distribution specific override class for Debian family (Ubuntu/Debian) """
import logging
import os
import pkg_resources
import pkg_resources
import zope.interface
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.compat import os
from certbot_apache import apache_util
from certbot_apache import configurator
logger = logging.getLogger(__name__)
@zope.interface.provider(interfaces.IPluginFactory)
class DebianConfigurator(configurator.ApacheConfigurator):
"""Debian specific ApacheConfigurator override class"""
+2 -1
View File
@@ -2,7 +2,6 @@
import copy
import fnmatch
import logging
import os
import re
import subprocess
import sys
@@ -10,7 +9,9 @@ import sys
import six
from acme.magic_typing import Dict, List, Set # pylint: disable=unused-import, no-name-in-module
from certbot import errors
from certbot.compat import os
logger = logging.getLogger(__name__)
@@ -1,11 +1,11 @@
"""Test for certbot_apache.augeas_configurator."""
import os
import shutil
import unittest
import mock
from certbot import errors
from certbot.compat import os
from certbot_apache.tests import util
@@ -1,12 +1,14 @@
"""Test for certbot_apache.configurator for CentOS 6 overrides"""
import os
import unittest
from certbot.compat import os
from certbot.errors import MisconfigurationError
from certbot_apache import obj
from certbot_apache import override_centos
from certbot_apache import parser
from certbot_apache.tests import util
from certbot.errors import MisconfigurationError
def get_vh_truth(temp_dir, config_name):
"""Return the ground truth for the specified directory."""
@@ -1,15 +1,16 @@
"""Test for certbot_apache.configurator for Centos overrides"""
import os
import unittest
import mock
from certbot import errors
from certbot.compat import os
from certbot_apache import obj
from certbot_apache import override_centos
from certbot_apache.tests import util
def get_vh_truth(temp_dir, config_name):
"""Return the ground truth for the specified directory."""
prefix = os.path.join(
@@ -1,9 +1,9 @@
"""Tests for certbot_apache.parser."""
import os
import shutil
import unittest
from certbot import errors
from certbot.compat import os
from certbot_apache.tests import util
@@ -1,7 +1,6 @@
# pylint: disable=too-many-public-methods,too-many-lines
"""Test for certbot_apache.configurator."""
import copy
import os
import shutil
import socket
import tempfile
@@ -16,15 +15,14 @@ from acme import challenges
from certbot import achallenges
from certbot import crypto_util
from certbot import errors
from certbot.compat import os
from certbot.tests import acme_util
from certbot.tests import util as certbot_util
from certbot_apache import apache_util
from certbot_apache import constants
from certbot_apache import parser
from certbot_apache import obj
from certbot_apache import parser
from certbot_apache.tests import util
@@ -1,11 +1,11 @@
"""Test for certbot_apache.configurator for Debian overrides"""
import os
import shutil
import unittest
import mock
from certbot import errors
from certbot.compat import os
from certbot_apache import apache_util
from certbot_apache import obj
@@ -1,15 +1,16 @@
"""Test for certbot_apache.configurator for Gentoo overrides"""
import os
import unittest
import mock
from certbot import errors
from certbot.compat import os
from certbot_apache import override_gentoo
from certbot_apache import obj
from certbot_apache import override_gentoo
from certbot_apache.tests import util
def get_vh_truth(temp_dir, config_name):
"""Return the ground truth for the specified directory."""
prefix = os.path.join(
@@ -1,5 +1,4 @@
"""Test for certbot_apache.http_01."""
import os
import unittest
import mock
@@ -8,8 +7,9 @@ from acme.magic_typing import List # pylint: disable=unused-import, no-name-in-
from certbot import achallenges
from certbot import errors
from certbot.compat import os
from certbot.tests import acme_util
from certbot_apache.parser import get_aug_path
from certbot_apache.tests import util
@@ -1,5 +1,4 @@
"""Tests for certbot_apache.parser."""
import os
import shutil
import unittest
@@ -7,6 +6,7 @@ import augeas
import mock
from certbot import errors
from certbot.compat import os
from certbot_apache.tests import util
+1 -3
View File
@@ -1,5 +1,4 @@
"""Common utilities for certbot_apache."""
import os
import shutil
import sys
import unittest
@@ -9,10 +8,9 @@ import josepy as jose
import mock
import zope.component
from certbot.compat import os
from certbot.display import util as display_util
from certbot.plugins import common
from certbot.tests import util as test_util
from certbot_apache import configurator