.. image:: https://img.shields.io/github/v/tag/thoth-station/package-extract?style=plastic :target: https://github.com/thoth-station/package-extract/tags :alt: GitHub tag (latest by date)
.. image:: https://quay.io/repository/thoth-station/package-extract/status :target: https://quay.io/repository/thoth-station/package-extract?tab=tags :alt: Quay - Build
A tool to extract installed packages from container images.
Tool thoth-package-extract allows you to extract dependencies from an image directly by inspecting its content. As there is directly inspected the content of image, the output is accurate compared to the pure build log parsing.
To gather information about python packages installed, there is a need to execute python scripts of installed packages given the Python packaging design. In some cases this can be dangerous as there could be executed potentially malicious parts of code (see this typo squashing <http://www.nbu.gov.sk/skcsirt-sa-20170909-pypi/>
_ as an example).
Use prepared Dockerfile:
.. code-block:: console
git clone https://github.com/thoth-station/package-extract cd package-extract docker build . -t package-extract
An example of parsing installed packages during:
.. code-block:: console
$ pip3 install --user flask | docker run -i package-extract extract-buildlog -i -
{
"metadata": {
"analyzer": "thoth-package-extract",
"analyzer_version": "1.0.0",
"arguments": {
"extract-buildlog": {
"input_file": "<_io.TextIOWrapper name='
Or you can also use this tool to extract information about packages that were installed during docker build:
.. code-block:: console
$ docker build . -f Dockerfile.test --no-cache | docker run -i package-extract extract-buildlog -i -
{
"metadata": {
"analyzer": "thoth-package-extract",
"analyzer_version": "1.0.0",
"arguments": {
"extract-buildlog": {
"input_file": "<_io.TextIOWrapper name='
$ cat Dockerfile.test FROM fedora:28 RUN dnf install python3-pip && pip3 install flask && dnf update -y && dnf install -y vim
To extract packages present on the resulting image run:
.. code-block:: console
$ docker run -i package-extract -v extract-image -i fedora:27 2018-06-18 19:06:46,611 [1] DEBUG thoth.package_extract.image: Downloading image 'fedora:27' 2018-06-18 19:06:46,611 [1] DEBUG thoth.analyzer.command: Running command 'skopeo copy docker://fedora:27 dir://tmp/tmp9jmeuw__' 2018-06-18 19:06:51,669 [1] DEBUG thoth.package_extract.image: skopeo stdout: Getting image source signatures Copying blob sha256:2176639d844bbe1386912e1d9952cebdb8249923a16691025cf693963f8aec53
0 B / 77.54 MB 3.60 MB / 77.54 MB 9.65 MB / 77.54 MB 16.34 MB / 77.54 MB 22.86 MB / 77.54 MB 29.22 MB / 77.54 MB 35.59 MB / 77.54 MB 41.26 MB / 77.54 MB 47.86 MB / 77.54 MB 54.40 MB / 77.54 MB 61.01 MB / 77.54 MB 66.34 MB / 77.54 MB 72.99 MB / 77.54 MB 77.54 MB / 77.54 MB 77.54 MB / 77.54 MB 2s Copying config sha256:9110ae7f579f35ee0c3938696f23fe0f5fbe641738ea52eb83c2df7e9995fa17
0 B / 2.29 KB 2.29 KB / 2.29 KB 0s Writing manifest to image destination Storing signatures
2018-06-18 19:06:51,671 [1] DEBUG thoth.package_extract.image: Layers found: [{'mediaType': 'application/vnd.docker.image.rootfs.diff.tar.gzip', 'size': 81308994, 'digest': 'sha256:2176639d844bbe1386912e1d9952cebdb8249923a16691025cf693963f8aec53'}] 2018-06-18 19:06:51,671 [1] DEBUG thoth.package_extract.image: Extracting layer '2176639d844bbe1386912e1d9952cebdb8249923a16691025cf693963f8aec53' 2018-06-18 19:06:55,776 [1] DEBUG thoth.analyzer.command: Running command "rpm -qa --root '/tmp/tmp9jmeuw/rootfs'" 2018-06-18 19:06:55,874 [1] DEBUG thoth.analyzer.command: Running command "repoquery --deplist --installed --installroot '/tmp/tmp9jmeuw/rootfs'" { "metadata": { "analyzer": "thoth-package-extract", "analyzer_version": "1.0.0", "arguments": { "extract-image": { "image": "fedora:27", "no_pretty": false, "no_tls_verify": false, "output": null, "registry_credentials": null, "timeout": null }, "thoth-package-extract": { "no_color": false, "verbose": false } }, "datetime": "2018-06-18T19:05:33.205504", "distribution": { "codename": "Twenty Seven", "id": "fedora", "like": "", "version": "27", "version_parts": { "build_number": "", "major": "27", "minor": "" } }, "hostname": "bfd10ad99fd4", "python": { "api_version": 1013, "implementation_name": "cpython", "major": 3, "micro": 5, "minor": 6, "releaselevel": "final", "serial": 0 } }, "result": { "layers": [ "2176639d844bbe1386912e1d9952cebdb8249923a16691025cf693963f8aec53" ], { "digests": { "manifest": "638db309ccb9ca512fc1c7c9ac207028038b8d5c" }, "ecosystem": "Python-Dist", "path": "/usr/lib/python3.6/site-packages/pip-9.0.1.dist-info/metadata.json", "result": { "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Build Tools", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: PyPy" ], "rpm": [ "xkeyboard-config-2.22-1.fc27.noarch", "emacs-filesystem-25.3-3.fc27.noarch", "fedora-repos-27-2.noarch", "setup-2.10.10-1.fc27.noarch", "basesystem-11-4.fc27.noarch", "libreport-filesystem-2.9.3-2.fc27.x86_64", "tzdata-2018c-1.fc27.noarch", "glibc-langpack-en-2.26-26.fc27.x86_64", "ncurses-libs-6.0-13.20170722.fc27.x86_64", "libsepol-2.7-2.fc27.x86_64", "libselinux-2.7-3.fc27.x86_64", "info-6.4-6.fc27.x86_64", "bzip2-libs-1.0.6-24.fc27.x86_64", "expat-2.2.5-1.fc27.x86_64", "nspr-4.18.0-1.fc27.x86_64", "elfutils-libelf-0.170-1.fc27.x86_64", "libgcrypt-1.8.2-1.fc27.x86_64", "libxml2-2.9.7-1.fc27.x86_64", "gmp-6.1.2-6.fc27.x86_64", "libzstd-1.3.3-1.fc27.x86_64", "chkconfig-1.10-3.fc27.x86_64", "libcom_err-1.43.5-2.fc27.x86_64", "libattr-2.4.47-21.fc27.x86_64", "sed-4.4-4.fc27.x86_64", "libunistring-0.9.7-3.fc27.x86_64", "lz4-libs-1.8.0-1.fc27.x86_64", "libcap-ng-0.7.8-5.fc27.x86_64", "nss-softokn-freebl-3.35.0-1.0.fc27.x86_64", "nss-softokn-3.35.0-1.0.fc27.x86_64", "keyutils-libs-1.5.10-3.fc27.x86_64", "grep-3.1-3.fc27.x86_64", "dbus-libs-1.12.0-1.fc27.x86_64", "p11-kit-trust-0.23.9-2.fc27.x86_64", "libusbx-1.0.21-4.fc27.x86_64", "libpsl-0.18.0-1.fc27.x86_64", "mpfr-3.1.6-1.fc27.x86_64", "gdbm-1.13-6.fc27.x86_64", "libdb-utils-5.3.28-27.fc27.x86_64", "kmod-libs-25-1.fc27.x86_64", "coreutils-common-8.27-20.fc27.x86_64", "elfutils-default-yama-scope-0.170-1.fc27.noarch", "ncurses-6.0-13.20170722.fc27.x86_64", "coreutils-8.27-20.fc27.x86_64", "python3-pip-9.0.1-14.fc27.noarch", "python3-3.6.4-8.fc27.x86_64", "libblkid-2.30.2-1.fc27.x86_64", "libmount-2.30.2-1.fc27.x86_64", "dbus-glib-0.108-4.fc27.x86_64", "libutempter-1.1.6-11.fc27.x86_64", "python3-libcomps-0.1.8-6.fc27.x86_64", "python3-iniparse-0.4-26.fc27.noarch", "gzip-1.8-4.fc27.x86_64", "libpwquality-1.4.0-3.fc27.x86_64", "nss-pem-1.0.3-6.fc27.x86_64", "nss-sysinit-3.35.0-1.1.fc27.x86_64", "libarchive-3.3.1-3.fc27.x86_64", "trousers-lib-0.3.13-9.fc27.x86_64", "libsss_nss_idmap-1.16.0-6.fc27.x86_64", "libsigsegv-2.11-3.fc27.x86_64", "krb5-libs-1.15.2-7.fc27.x86_64", "openldap-2.4.45-4.fc27.x86_64", "qrencode-libs-3.4.4-3.fc27.x86_64", "gnupg2-2.2.5-1.fc27.x86_64", "python3-gpg-1.9.0-6.fc27.x86_64", "util-linux-2.30.2-1.fc27.x86_64", "iptables-libs-1.6.1-4.fc27.x86_64", "device-mapper-libs-1.02.144-1.fc27.x86_64", "systemd-pam-234-10.git5f8984e.fc27.x86_64", "dbus-1.12.0-1.fc27.x86_64", "libcurl-7.55.1-9.fc27.x86_64", "python3-librepo-1.8.0-1.fc27.x86_64", "rpm-plugin-selinux-4.14.1-1.fc27.x86_64", "rpm-4.14.1-1.fc27.x86_64", "libdnf-0.11.1-1.fc27.x86_64", "deltarpm-3.6-24.fc27.x86_64", "python3-rpm-4.14.1-1.fc27.x86_64", "dnf-2.7.5-2.fc27.noarch", "rpm-plugin-systemd-inhibit-4.14.1-1.fc27.x86_64", "gnupg2-smime-2.2.5-1.fc27.x86_64", "nss-tools-3.35.0-1.1.fc27.x86_64", "pinentry-0.9.7-4.fc27.x86_64", "shared-mime-info-1.9-1.fc27.x86_64", "tar-1.29-7.fc27.x86_64", "libxkbcommon-0.7.1-5.fc27.x86_64", "rootfiles-8.1-21.fc27.noarch", "libgcc-7.3.1-5.fc27.x86_64", "publicsuffix-list-dafsa-20180223-1.fc27.noarch", "fedora-gpg-keys-27-2.noarch", "fedora-release-27-1.noarch", "filesystem-3.3-3.fc27.x86_64", "ncurses-base-6.0-13.20170722.fc27.noarch", "dnf-conf-2.7.5-2.fc27.noarch", "glibc-common-2.26-26.fc27.x86_64", "glibc-2.26-26.fc27.x86_64", "bash-4.4.19-1.fc27.x86_64", "pcre2-10.31-1.fc27.x86_64", "zlib-1.2.11-4.fc27.x86_64", "xz-libs-5.2.3-4.fc27.x86_64", "libgpg-error-1.27-3.fc27.x86_64", "libdb-5.3.28-27.fc27.x86_64", "nss-util-3.35.0-1.0.fc27.x86_64", "libcap-2.25-7.fc27.x86_64", "popt-1.16-12.fc27.x86_64", "readline-7.0-7.fc27.x86_64", "libuuid-2.30.2-1.fc27.x86_64", "lua-libs-5.3.4-7.fc27.x86_64", "libassuan-2.5.1-1.fc27.x86_64", "libffi-3.1-14.fc27.x86_64", "libacl-2.2.52-18.fc27.x86_64", "p11-kit-0.23.9-2.fc27.x86_64", "libidn2-2.0.4-3.fc27.x86_64", "sqlite-libs-3.20.1-1.fc27.x86_64", "audit-libs-2.8.2-1.fc27.x86_64", "libcrypt-nss-2.26-26.fc27.x86_64", "libksba-1.3.5-5.fc27.x86_64", "pcre-8.41-5.fc27.x86_64", "systemd-libs-234-10.git5f8984e.fc27.x86_64", "libtasn1-4.13-1.fc27.x86_64", "ca-certificates-2018.2.22-1.0.fc27.noarch", "libsemanage-2.7-2.fc27.x86_64", "acl-2.2.52-18.fc27.x86_64", "nettle-3.4-1.fc27.x86_64", "libcomps-0.1.8-6.fc27.x86_64", "libmetalink-0.1.3-4.fc27.x86_64", "libidn-1.33-4.fc27.x86_64", "file-libs-5.31-10.fc27.x86_64", "elfutils-libs-0.170-1.fc27.x86_64", "openssl-libs-1.1.0g-1.fc27.x86_64", "crypto-policies-20170816-2.gite0a4066.fc27.noarch", "python3-setuptools-37.0.0-1.fc27.noarch", "python3-libs-3.6.4-8.fc27.x86_64", "shadow-utils-4.5-4.fc27.x86_64", "glib2-2.54.3-2.fc27.x86_64", "libsecret-0.18.5-5.fc27.x86_64", "libfdisk-2.30.2-1.fc27.x86_64", "python3-six-1.11.0-1.fc27.noarch", "gnutls-3.5.18-2.fc27.x86_64", "cracklib-2.9.6-7.fc27.x86_64", "pam-1.3.0-6.fc27.x86_64", "nss-3.35.0-1.1.fc27.x86_64", "ima-evm-utils-1.1-2.fc27.x86_64", "libssh2-1.8.0-5.fc27.x86_64", "libsss_idmap-1.16.0-6.fc27.x86_64", "libverto-0.2.6-11.fc27.x86_64", "gawk-4.1.4-8.fc27.x86_64", "cyrus-sasl-lib-2.1.26-34.fc27.x86_64", "libseccomp-2.3.3-1.fc27.x86_64", "npth-1.5-3.fc27.x86_64", "gpgme-1.9.0-6.fc27.x86_64", "libsmartcols-2.30.2-1.fc27.x86_64", "libpcap-1.8.1-6.fc27.x86_64", "device-mapper-1.02.144-1.fc27.x86_64", "cryptsetup-libs-1.7.5-3.fc27.x86_64", "systemd-234-10.git5f8984e.fc27.x86_64", "libnghttp2-1.25.0-1.fc27.x86_64", "librepo-1.8.0-1.fc27.x86_64", "curl-7.55.1-9.fc27.x86_64", "rpm-libs-4.14.1-1.fc27.x86_64", "libsolv-0.6.33-1.fc27.x86_64", "python3-hawkey-0.11.1-1.fc27.x86_64", "rpm-build-libs-4.14.1-1.fc27.x86_64", "python3-dnf-2.7.5-2.fc27.noarch", "dnf-yum-2.7.5-2.fc27.noarch", "trousers-0.3.13-9.fc27.x86_64", "sssd-client-1.16.0-6.fc27.x86_64", "cracklib-dicts-2.9.6-7.fc27.x86_64", "python3-dbus-1.2.4-8.fc27.x86_64", "vim-minimal-8.0.1553-1.fc27.x86_64", "diffutils-3.6-3.fc27.x86_64", "langpacks-en-1.0-10.fc27.noarch", "gpg-pubkey-f5282ee4-58ac92a3" ], "rpm-dependencies": [ { "arch": "x86_64", "dependencies": [ "libacl = 2.2.52-18.fc27", "libacl.so.1()(64bit)", "libacl.so.1(ACL_1.0)(64bit)", "libattr.so.1()(64bit)", "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.14)(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "acl", "package_identifier": "acl-2.2.52-18.fc27.x86_64", "release": "18.fc27", "src": false, "version": "2.2.52" }, { "arch": "x86_64", "dependencies": [ "/sbin/ldconfig", "/sbin/ldconfig", "config(audit-libs) = 2.8.2-1.fc27", "libaudit.so.1()(64bit)", "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.14)(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "libc.so.6(GLIBC_2.8)(64bit)", "libcap-ng.so.0()(64bit)", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "audit-libs", "package_identifier": "audit-libs-2.8.2-1.fc27.x86_64", "release": "1.fc27", "src": false, "version": "2.8.2" }, { "arch": "noarch", "dependencies": [ "filesystem", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "setup" ], "epoch": null, "name": "basesystem", "package_identifier": "basesystem-11-4.fc27.noarch", "release": "4.fc27", "src": false, "version": "11" }, { "arch": "x86_64", "dependencies": [ "/bin/sh", "config(bash) = 4.4.19-1.fc27", "filesystem >= 3", "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.11)(64bit)", "libc.so.6(GLIBC_2.14)(64bit)", "libc.so.6(GLIBC_2.15)(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "libc.so.6(GLIBC_2.8)(64bit)", "libdl.so.2()(64bit)", "libdl.so.2(GLIBC_2.2.5)(64bit)", "libtinfo.so.6()(64bit)", "rpmlib(BuiltinLuaScripts) <= 4.2.2-1", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "bash", "package_identifier": "bash-4.4.19-1.fc27.x86_64", "release": "1.fc27", "src": false, "version": "4.4.19" }, { "arch": "x86_64", "dependencies": [ "/sbin/ldconfig", "/sbin/ldconfig", "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "bzip2-libs", "package_identifier": "bzip2-libs-1.0.6-24.fc27.x86_64", "release": "24.fc27", "src": false, "version": "1.0.6" }, { "arch": "noarch", "dependencies": [ "/bin/sh", "/bin/sh", "/bin/sh", "config(ca-certificates) = 2018.2.22-1.0.fc27", "p11-kit >= 0.23.4", "p11-kit-trust >= 0.23.4", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1" ], "epoch": null, "name": "ca-certificates", "package_identifier": "ca-certificates-2018.2.22-1.0.fc27.noarch", "release": "1.0.fc27", "src": false, "version": "2018.2.22" }, { "arch": "x86_64", "dependencies": [ "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.14)(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "libc.so.6(GLIBC_2.8)(64bit)", "libpopt.so.0()(64bit)", "libpopt.so.0(LIBPOPT_0)(64bit)", "libselinux.so.1()(64bit)", "libsepol.so.1()(64bit)", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "chkconfig", "package_identifier": "chkconfig-1.10-3.fc27.x86_64", "release": "3.fc27", "src": false, "version": "1.10" }, { "arch": "x86_64", "dependencies": [ "coreutils-common = 8.27-20.fc27", "libacl.so.1()(64bit)", "libacl.so.1(ACL_1.0)(64bit)", "libattr.so.1()(64bit)", "libattr.so.1(ATTR_1.1)(64bit)", "libc.so.6()(64bit)", "libc.so.6(GLIBC_2.10)(64bit)", "libc.so.6(GLIBC_2.14)(64bit)", "libc.so.6(GLIBC_2.15)(64bit)", "libc.so.6(GLIBC_2.17)(64bit)", "libc.so.6(GLIBC_2.2.5)(64bit)", "libc.so.6(GLIBC_2.3)(64bit)", "libc.so.6(GLIBC_2.3.4)(64bit)", "libc.so.6(GLIBC_2.4)(64bit)", "libc.so.6(GLIBC_2.6)(64bit)", "libc.so.6(GLIBC_2.7)(64bit)", "libcap.so.2()(64bit)", "libcrypto.so.1.1()(64bit)", "libcrypto.so.1.1(OPENSSL_1_1_0)(64bit)", "libgmp.so.10()(64bit)", "libpthread.so.0()(64bit)", "libpthread.so.0(GLIBC_2.2.5)(64bit)", "libpthread.so.0(GLIBC_2.3.2)(64bit)", "librt.so.1()(64bit)", "librt.so.1(GLIBC_2.3.3)(64bit)", "libselinux.so.1()(64bit)", "ncurses", "rpmlib(CompressedFileNames) <= 3.0.4-1", "rpmlib(FileDigests) <= 4.6.0-1", "rpmlib(PayloadFilesHavePrefix) <= 4.0-1", "rpmlib(PayloadIsXz) <= 5.2-1", "rtld(GNU_HASH)" ], "epoch": null, "name": "coreutils", "package_identifier": "coreutils-8.27-20.fc27.x86_64", "release": "20.fc27", "src": false, "version": "8.27" },
...
}