Skip to content

Commit

Permalink
Merge pull request #23 from brant-ruan/dev
Browse files Browse the repository at this point in the history
fix #9
  • Loading branch information
brant-ruan authored May 7, 2021
2 parents 8b19743 + 1a5c3a6 commit ded8f0b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
12 changes: 11 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@
release=release)

# kernel apt repositories
_kernel_apt_repo_entry_xenial_official = 'deb http://security.ubuntu.com/ubuntu xenial-security main'
_kernel_apt_repo_entry_trusty_official = 'deb http://security.ubuntu.com/ubuntu trusty-security main'
_kernel_apt_repo_entry_xenial_official = 'deb http://security.ubuntu.com/ubuntu xenial-security main'
_kernel_apt_repo_entry_bionic_official = 'deb http://security.ubuntu.com/ubuntu bionic-security main'

# containerd apt repository
_containerd_apt_repo_entry_xenial_official = 'deb http://archive.ubuntu.com/ubuntu xenial-updates universe'
_containerd_apt_repo_entry_bionic_official = 'deb http://archive.ubuntu.com/ubuntu bionic-updates universe'

# active k8s components images source
k8s_images_prefix_official = "k8s.gcr.io/"
k8s_images_prefix_official_9 = "gcr.io/google_containers/"
Expand Down Expand Up @@ -104,6 +108,12 @@
_kernel_apt_repo_entry_bionic_official,
]

# active containerd apt repository
containerd_apt_repo_entries = [
_containerd_apt_repo_entry_xenial_official,
_containerd_apt_repo_entry_bionic_official,
]

# CNI plugins
available_cni_plugins = [
'flannel',
Expand Down
15 changes: 8 additions & 7 deletions core/env_managers/docker_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ def _pre_install(cls, verbose=False):
# install requirements
color_print.debug('installing prerequisites')
try:
subprocess.run(
cls.cmd_apt_update,
stdout=stdout,
stderr=stderr,
check=True)
if not cls._apt_update(verbose=verbose):
return False
subprocess.run(
cls.cmd_apt_install +
cls._docker_requirements,
Expand All @@ -89,8 +86,12 @@ def _pre_install(cls, verbose=False):
check=True)
except subprocess.CalledProcessError:
return False
return cls._add_apt_repository(gpg_url=config.docker_apt_repo_gpg,
repo_entry=config.docker_apt_repo_entry, verbose=verbose)
cls._add_apt_repository(gpg_url=config.docker_apt_repo_gpg,
repo_entry=config.docker_apt_repo_entry, verbose=verbose)
for repo in config.containerd_apt_repo_entries:
cls._add_apt_repository(repo_entry=repo, verbose=verbose)

return True


if __name__ == "__main__":
Expand Down
18 changes: 13 additions & 5 deletions core/env_managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ def _install_one_gadget_by_version(
color_print.warning('no candidate version for %s' % name)
return False

@classmethod
def _apt_update(cls, verbose=False):
stdout, stderr = verbose_func.verbose_output(verbose)
try:
subprocess.run(
cls.cmd_apt_update,
stdout=stdout,
stderr=stderr,
check=True)
return True
except subprocess.CalledProcessError:
return False

@classmethod
def _add_apt_repository(cls, repo_entry, gpg_url=None, verbose=False):
stdout, stderr = verbose_func.verbose_output(verbose)
Expand Down Expand Up @@ -132,11 +145,6 @@ def _add_apt_repository(cls, repo_entry, gpg_url=None, verbose=False):
stdout=stdout,
stderr=stderr,
check=True)
subprocess.run(
cls.cmd_apt_update,
stdout=stdout,
stderr=stderr,
check=True)
return True
except subprocess.CalledProcessError:
return False
Expand Down
1 change: 1 addition & 0 deletions core/env_managers/kernel_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def install_by_version(cls, gadgets, context=None, verbose=False):
color_print.debug('switching kernel by version')
for repo in config.kernel_apt_repo_entries:
cls._add_apt_repository(repo_entry=repo, verbose=verbose)

if cls._is_version_available_in_apt(version, verbose=verbose):
return cls._install_by_version_with_apt(version, verbose=verbose)
else:
Expand Down
6 changes: 1 addition & 5 deletions core/env_managers/kubernetes_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,7 @@ def _pre_install(cls, mappings=None, verbose=False):
color_print.debug('pre-installing')
stdout, stderr = verbose_func.verbose_output(verbose)
# install requirements
subprocess.run(
cls.cmd_apt_update,
stdout=stdout,
stderr=stderr,
check=True)
cls._apt_update(verbose=verbose)
subprocess.run(
cls.cmd_apt_install +
cls._kubernetes_requirements,
Expand Down
3 changes: 3 additions & 0 deletions vulns_cn/docker/cve-2020-15257.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ dependencies:
- name: docker-ce
version: 18.03.1
versions: ~
- name: containerd
version: 1.3.3
versions: ~
links:
- https://nvd.nist.gov/vuln/detail/CVE-2020-15257
- https://xz.aliyun.com/t/8681

0 comments on commit ded8f0b

Please sign in to comment.