Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pre-commit
black==23.3.0
black==25.1.0
isort
flake8
6 changes: 3 additions & 3 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ 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:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: ["ubuntu", "centos", "rockylinux:9.0", "alpine", "busybox"]
image: ["ubuntu", "rockylinux:9.0", "alpine", "busybox"]

name: Generate Matrix
steps:
Expand Down
33 changes: 33 additions & 0 deletions container_guts/main/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion container_guts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down
Loading