Ejemplo n.º 1
0
 def update_dependencies(options):
     easylist_path = options['storage_path'] / EASYLIST_PATH
     easylist_path.mkdir(parents=True, exist_ok=True)
     for filename in EASYLIST_FILES:
         download_url = EASYLIST_DOWNLOAD_PREFIX + filename
         target_file = (easylist_path / filename).open('wb')
         download_file(download_url, target_file)
Ejemplo n.º 2
0
def update_dependencies(options):
    if not file_is_outdated(GEOIP_DATABASE_PATH, GEOIP_MAX_AGE):
        return
    GEOIP_DATABASE_PATH.parent.mkdir(parents=True, exist_ok=True)
    FILES = ['COPYRIGHT.txt', 'LICENSE.txt', 'GeoLite2-Country.mmdb']
    with tempfile.NamedTemporaryFile() as f:
        download_file(GEOIP_DOWNLOAD_URL, f)
        archive = tarfile.open(f.name)
        for member in archive.getmembers():
            base_name = os.path.basename(member.name)
            if base_name in FILES and member.isfile():
                with (GEOIP_DATABASE_PATH.parent / base_name).open('wb') as f:
                    copy_to(archive.extractfile(member), f)
Ejemplo n.º 3
0
 def update_dependencies(cls, options):
     lookup_file = options['storage_path'] / 'hsts.json'
     if not file_is_outdated(lookup_file, 3600 * 24 * 7):
         return
     buf = io.BytesIO()
     download_url = options.get('hsts_preload_url', HSTS_PRELOAD_URL)
     download_file(download_url, buf)
     plain_json = ''.join(line for line in buf.getvalue().decode().splitlines()
                          if not line.lstrip().startswith('//'))
     hsts_data = json.loads(plain_json)
     lookup = {entry['name']: entry.get('include_subdomains')
               for entry in hsts_data['entries']}
     with lookup_file.open('w') as f:
         json.dump(lookup, f)
Ejemplo n.º 4
0
 def update_dependencies(self):
     geoip_database_path = self.options['geoip_database_path']
     geoip_max_age = self.options['geoip_max_age']
     if not file_is_outdated(geoip_database_path, geoip_max_age):
         return
     geoip_database_path.parent.mkdir(parents=True, exist_ok=True)
     FILES = ['COPYRIGHT.txt', 'LICENSE.txt', 'GeoLite2-Country.mmdb']
     with tempfile.NamedTemporaryFile() as f:
         download_file(GEOIP_DOWNLOAD_URL, f)
         archive = tarfile.open(f.name)
         for member in archive.getmembers():
             base_name = Path(member.name).name
             if base_name in FILES and member.isfile():
                 with (geoip_database_path.parent /
                       base_name).open('wb') as f:
                     copy_to(archive.extractfile(member), f)
Ejemplo n.º 5
0
 def update_dependencies(self):
     install_base_dir = self.options['install_base_dir']
     install_base_dir.mkdir(parents=True, exist_ok=True)
     hash_symlink = (install_base_dir / self.options['download_hash'])
     if hash_symlink.exists():
         self.logger.info('Expected testssl.sh version is already installed.')
         return
     self.logger.info('Downloading testssl.sh from %s', self.options['download_url'])
     with io.BytesIO() as f:
         download_file(self.options['download_url'], f,
                       verify_hash=self.options['download_hash'])
         f.seek(0)
         with tarfile.open(fileobj=f) as tarball:
             directory_name = Path(tarball.next().name).parts[0]
             tarball.extractall(path=str(install_base_dir))
     hash_symlink.symlink_to(directory_name, target_is_directory=True)
     self.logger.info('Successfully installed testssl.sh')
Ejemplo n.º 6
0
 def update_dependencies(options):
     EASYLIST_PATH.mkdir(parents=True, exist_ok=True)
     for filename in EASYLIST_FILES:
         download_url = EASYLIST_DOWNLOAD_PREFIX + filename
         target_file = (EASYLIST_PATH / filename).open('wb')
         download_file(download_url, target_file)