mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:22:16 +02:00
Incorporated Schoen's feedback and really fixed py26 support?...
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""Let's Encrypt Apache configuration submission script"""
|
"""Let's Encrypt Apache configuration submission script"""
|
||||||
import argparse
|
import argparse
|
||||||
|
import atexit
|
||||||
import contextlib
|
import contextlib
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
@@ -31,8 +34,9 @@ argument and the path to the binary.
|
|||||||
|
|
||||||
|
|
||||||
# Keywords likely to be found in filenames of sensitive files
|
# Keywords likely to be found in filenames of sensitive files
|
||||||
_SENSITIVE_KEYWORDS = ["private", "secret", "cert", "crt", "key", "pem", "der",
|
_SENSITIVE_FILENAME_REGEX = re.compile(r"^(?!.*proxy_fdpass).*pass.*$|private|"
|
||||||
"rsa", "dsa", "pass", "pw"]
|
r"secret|cert|crt|key|\.pem|\.der|rsa|"
|
||||||
|
r"dsa|pw")
|
||||||
|
|
||||||
|
|
||||||
def make_and_verify_selection(server_root, temp_dir):
|
def make_and_verify_selection(server_root, temp_dir):
|
||||||
@@ -131,9 +135,9 @@ def safe_config_file(config_file):
|
|||||||
:rtype: bool
|
:rtype: bool
|
||||||
|
|
||||||
"""
|
"""
|
||||||
for keyword in _SENSITIVE_KEYWORDS:
|
config_file_lower = config_file.lower()
|
||||||
if keyword in config_file:
|
if _SENSITIVE_FILENAME_REGEX.search(config_file_lower):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
proc = subprocess.Popen(["file", config_file],
|
proc = subprocess.Popen(["file", config_file],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@@ -284,6 +288,7 @@ def main():
|
|||||||
|
|
||||||
verify_config(args)
|
verify_config(args)
|
||||||
tempdir = setup_tempdir(args)
|
tempdir = setup_tempdir(args)
|
||||||
|
atexit.register(lambda: shutil.rmtree(tempdir))
|
||||||
make_and_verify_selection(args.server_root, tempdir)
|
make_and_verify_selection(args.server_root, tempdir)
|
||||||
|
|
||||||
tarpath = os.path.join(tempdir, "config.tar.gz")
|
tarpath = os.path.join(tempdir, "config.tar.gz")
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ class LetsHelpApacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
testdir = tar.next()
|
testdir = tar.next()
|
||||||
self.assertTrue(testdir.isdir())
|
self.assertTrue(testdir.isdir())
|
||||||
testdir_path = os.path.join(".", testdir_basename)
|
self.assertEqual(os.path.basename(testdir.name),
|
||||||
self.assertEqual(testdir.name, testdir_path)
|
testdir_basename)
|
||||||
|
|
||||||
self.assertEqual(tar.next(), None)
|
self.assertEqual(tar.next(), None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user