Skip to content

Commit 8051ec7

Browse files
committed
Add add-on pipeline for collecting dwarfs from elfs
Signed-off-by: Tushar Goel <[email protected]>
1 parent 27480f5 commit 8051ec7

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

scanpipe/models.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,23 @@ def has_directory_content_fingerprint(self):
19461946
and ~Q(extra_data__directory_content__in=IGNORED_DIRECTORY_FINGERPRINTS)
19471947
)
19481948

1949+
def elfs(self):
1950+
"""
1951+
Resources that are ``files`` and their filetype startswith `elf` and contains any of thes
1952+
`executable`, `relocatable`, `shared object`.
1953+
"""
1954+
return (
1955+
self.files()
1956+
.filter(
1957+
file_type__istartswith="elf",
1958+
)
1959+
.filter(
1960+
Q(file_type__icontains="executable")
1961+
| Q(file_type__icontains="relocatable")
1962+
| Q(file_type__icontains="shared object")
1963+
)
1964+
)
1965+
19491966

19501967
class ScanFieldsModelMixin(models.Model):
19511968
"""Fields returned by the ScanCode-toolkit scans."""
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pathlib import Path
2+
3+
from elf_inspector.dwarf import get_dwarf_paths
4+
5+
from scanpipe.models import CodebaseResource
6+
from scanpipe.pipelines import Pipeline
7+
from scanpipe.pipes import purldb
8+
from scanpipe.pipes import scancode
9+
10+
11+
class GetDwarfsFromElfs(Pipeline):
12+
"""Get dwarfs from elfs."""
13+
14+
download_inputs = False
15+
is_addon = True
16+
17+
@classmethod
18+
def steps(cls):
19+
return (cls.get_dwarfs_from_elfs,)
20+
21+
def get_dwarfs_from_elfs(self):
22+
"""
23+
Update ``extra_data`` of project with
24+
dwarf data extracted from elf files.
25+
"""
26+
for elf in self.project.codebaseresources.elfs():
27+
data = get_dwarf_paths(Path(self.project.codebase_path / elf.path))
28+
self.project.update_extra_data({elf.path: data})

setup.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ install_requires =
7676
# FetchCode
7777
fetchcode-container==1.2.3.210512; sys_platform == "linux"
7878
# Inspectors
79-
python-inspector==0.11.0
79+
python-inspector==0.10.0
80+
elf-inspector==0.0.1
8081
aboutcode-toolkit==10.1.0
8182
# Utilities
8283
XlsxWriter==3.1.9
@@ -126,6 +127,7 @@ scancodeio_pipelines =
126127
analyze_root_filesystem_or_vm_image = scanpipe.pipelines.root_filesystem:RootFS
127128
analyze_windows_docker_image = scanpipe.pipelines.docker_windows:DockerWindows
128129
find_vulnerabilities = scanpipe.pipelines.find_vulnerabilities:FindVulnerabilities
130+
get_dwarfs_from_elfs = scanpipe.pipelines.get_dwarfs_from_elfs:GetDwarfsFromElfs
129131
inspect_packages = scanpipe.pipelines.inspect_packages:InspectPackages
130132
load_inventory = scanpipe.pipelines.load_inventory:LoadInventory
131133
load_sbom = scanpipe.pipelines.load_sbom:LoadSBOM

0 commit comments

Comments
 (0)