Skip to content

Commit 2b663e6

Browse files
committed
Add test for python pyx matching
Signed-off-by: Jono Yang <[email protected]>
1 parent e99000a commit 2b663e6

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

scanpipe/pipes/d2d.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,9 +1946,7 @@ def map_elfs_binaries_with_symbols(project, logger=None):
19461946
)
19471947

19481948
# Collect source symbols from elf related source files
1949-
elf_from_resources = from_resources.filter(
1950-
extension__in=[".c", ".cpp", ".h", ".pyx", ".pxd"]
1951-
)
1949+
elf_from_resources = from_resources.filter(extension__in=[".c", ".cpp", ".h"])
19521950

19531951
map_binaries_with_symbols(
19541952
project=project,
@@ -2152,7 +2150,7 @@ def _map_javascript_symbols(to_resource, javascript_from_resources, logger):
21522150

21532151

21542152
def map_python_pyx_to_binaries(project, logger=None):
2155-
"""Map ELF binaries to their sources in ``project``."""
2153+
"""Map Cython source to their compiled binaries in ``project``."""
21562154
from_resources = (
21572155
project.codebaseresources.files()
21582156
.from_codebase()
Binary file not shown.
Binary file not shown.

scanpipe/tests/pipes/test_d2d.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,36 @@ def test_scanpipe_pipes_d2d_map_macho_symbols(self):
16301630
).count(),
16311631
)
16321632

1633+
def test_scanpipe_pipes_d2d_map_python_pyx(self):
1634+
input_dir = self.project1.input_path
1635+
input_resources = [
1636+
self.data / "d2d-python/to-intbitset.whl",
1637+
self.data / "d2d-python/from-intbitset.tar.gz",
1638+
]
1639+
copy_inputs(input_resources, input_dir)
1640+
self.from_files, self.to_files = d2d.get_inputs(self.project1)
1641+
inputs_with_codebase_path_destination = [
1642+
(self.from_files, self.project1.codebase_path / d2d.FROM),
1643+
(self.to_files, self.project1.codebase_path / d2d.TO),
1644+
]
1645+
for input_files, codebase_path in inputs_with_codebase_path_destination:
1646+
for input_file_path in input_files:
1647+
scancode.extract_archive(input_file_path, codebase_path)
1648+
1649+
scancode.extract_archives(
1650+
self.project1.codebase_path,
1651+
recurse=True,
1652+
)
1653+
pipes.collect_and_create_codebase_resources(self.project1)
1654+
buffer = io.StringIO()
1655+
d2d.map_python_pyx_to_binaries(project=self.project1, logger=buffer.write)
1656+
self.assertEqual(
1657+
1,
1658+
CodebaseRelation.objects.filter(
1659+
project=self.project1, map_type="python_pyx_match"
1660+
).count(),
1661+
)
1662+
16331663
@skipIf(sys.platform == "darwin", "Test is failing on macOS")
16341664
def test_scanpipe_pipes_d2d_map_winpe_symbols(self):
16351665
input_dir = self.project1.input_path

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ install_requires =
8686
rust-inspector==0.1.0
8787
binary-inspector==0.1.2
8888
python-inspector==0.14.0
89-
source-inspector @ git+https://github.com/aboutcode-org/source-inspector@990e93b9c6bcb28e105e50af6507a0a2f0515213
89+
source-inspector @ git+https://github.com/aboutcode-org/source-inspector@91d02f65e88aa95e72ed2884a47475c434865d1a
9090
aboutcode-toolkit==11.1.1
9191
# Utilities
9292
XlsxWriter==3.2.5

0 commit comments

Comments
 (0)