From 5d4e214d94623b1ffe19affb4b2b030fa67df45b Mon Sep 17 00:00:00 2001 From: vsoch Date: Fri, 30 May 2025 18:24:59 -0600 Subject: [PATCH 1/3] feat: add support for trace with ldd Signed-off-by: vsoch --- container_guts/main/client.py | 33 +++++++++++++++++++++++++++++++++ container_guts/version.py | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/container_guts/main/client.py b/container_guts/main/client.py index 8fc4608..d5a1556 100644 --- a/container_guts/main/client.py +++ b/container_guts/main/client.py @@ -109,6 +109,39 @@ def run(self, image, includes=None): shutil.rmtree(tmpdir, ignore_errors=True) return {image.uri: self.manifests[image.uri]} + @ensure_container + def trace(self, image, paths, cleanup=True): + """ + Find and trace a binary in the container + + Paths must be provided, either the full path or a basename. + """ + print(f"Looking for {len(paths)} path(s) in image") + tmpdir = self.container.export(image, cleanup=False) + + # Results will be lookup with binary path and links + results = {} + for path in paths: + + # We rely on the user to provide something on the path OR a fullpath + links = self.container.execute(image, ["ldd", path]) + if links["return_code"] != 0: + print(links["message"]) + return + links = [ + x.replace("\t", "") for x in links["message"].split("\n") if x.strip() + ] + results[path] = [ + x.split("(")[0].split("=> ")[-1] for x in links if "=>" in x + ] + + if cleanup: + self.container.cleanup(image) + + # Assume that something that isn't linked won't be mapped + shutil.rmtree(tmpdir, ignore_errors=True) + return results + @ensure_container def get_environment_paths(self, image): """ diff --git a/container_guts/version.py b/container_guts/version.py index 94c8e98..4baa54e 100644 --- a/container_guts/version.py +++ b/container_guts/version.py @@ -2,7 +2,7 @@ __copyright__ = "Copyright 2021-2024, Vanessa Sochat" __license__ = "MPL 2.0" -__version__ = "0.0.16" +__version__ = "0.0.17" AUTHOR = "Vanessa Sochat" NAME = "container-guts" EMAIL = "vsoch@users.noreply.github.com" From 2e170a9fe6d071d63503cbaaf99dde6889031cf5 Mon Sep 17 00:00:00 2001 From: vsoch Date: Fri, 30 May 2025 18:27:40 -0600 Subject: [PATCH 2/3] dev: bump black version requirements Signed-off-by: vsoch --- .github/dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dev-requirements.txt b/.github/dev-requirements.txt index 6116de3..c08ad92 100644 --- a/.github/dev-requirements.txt +++ b/.github/dev-requirements.txt @@ -1,4 +1,4 @@ pre-commit -black==23.3.0 +black==25.1.0 isort flake8 From 60fb3f387be2c35969d7e3e3db492b7cf5b2fbf0 Mon Sep 17 00:00:00 2001 From: vsoch Date: Fri, 30 May 2025 18:29:16 -0600 Subject: [PATCH 3/3] remove centos Signed-off-by: vsoch --- .github/workflows/generate.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 2b3e8e0..b546b1a 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -24,12 +24,12 @@ jobs: - name: Test Basic Guts uses: ./action/manifest with: - image: centos + image: ubuntu - name: Filesystem Include uses: ./action/manifest with: - image: centos + image: ubuntu include: fs generate-recipes: @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - image: ["ubuntu", "centos", "rockylinux:9.0", "alpine", "busybox"] + image: ["ubuntu", "rockylinux:9.0", "alpine", "busybox"] name: Generate Matrix steps: