Skip to content

Commit 9c92c8a

Browse files
Merge pull request #1 from aboutcode-org/support-rust-binary
Support rust binary parsing Reference: aboutcode-org/scancode.io#1475
2 parents 0c67387 + f02962c commit 9c92c8a

34 files changed

+318380
-147
lines changed

.github/workflows/docs-ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Documentation
1+
name: CI Documentation and Code style
22

33
on: [push, pull_request]
44

@@ -21,7 +21,7 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222

2323
- name: Install Dependencies
24-
run: pip install -e .[docs]
24+
run: pip install -e .[docs,testing]
2525

2626
- name: Check Sphinx Documentation build minimally
2727
working-directory: ./docs
@@ -31,4 +31,5 @@ jobs:
3131
working-directory: ./docs
3232
run: ./scripts/doc8_style_check.sh
3333

34-
34+
- name: Check for Code style errors
35+
run: make check-ci

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ version: 2
77

88
# Build in latest ubuntu/python
99
build:
10-
os: ubuntu-22.04
10+
os: ubuntu-24.04
1111
tools:
12-
python: "3.11"
12+
python: "3.12"
1313

1414
# Build PDF & ePub
1515
formats:

AUTHORS.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
The following organizations or individuals have contributed to this repo:
22

3-
-
3+
- Ayan Sinha Mahapatra @AyanSinhaMahapatra
4+
- nexB Inc.
5+

CHANGELOG.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ Changelog
22
=========
33

44

5-
v0.0.0
6-
------
5+
v0.1.0 (30th December, 2024)
6+
-----------------------------
77

8-
*xxxx-xx-xx* -- Initial release.
8+
Initial release with support for rust binary parsing to:
9+
10+
* Get packages and dependencies information from a rust binary
11+
* Get parsed list of demangled and cleaned symbols from a rust binary
12+
* A scancode-toolkit plugin for colelcting rust symbols with the option --rust-symbol
13+
* A scancode-toolkit DatafileHandler to integrate getting package data from a rust binary

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ valid: isort black
3333

3434
check:
3535
@echo "-> Run pycodestyle (PEP8) validation"
36-
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,migrations,settings.py,.cache .
36+
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,scripts,tests,migrations,settings.py,.cache .
3737
@echo "-> Run isort imports ordering validation"
38-
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
38+
@${ACTIVATE} isort --sl -l 100 src tests setup.py --check-only
3939
@echo "-> Run black validation"
40-
@${ACTIVATE} black --check --check -l 100 src tests setup.py
40+
@${ACTIVATE} black --check -l 100 src tests setup.py
41+
42+
check-ci:
43+
@echo "-> Run pycodestyle (PEP8) validation"
44+
pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,scripts,tests,migrations,settings.py,.cache .
45+
@echo "-> Run isort imports ordering validation"
46+
isort --sl -l 100 src tests setup.py --check-only
47+
@echo "-> Run black validation"
48+
black --check -l 100 src tests setup.py
4149

4250
clean:
4351
@echo "-> Clean the Python env"

README.rst

Lines changed: 130 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,148 @@
1-
A Simple Python Project Skeleton
1+
rust-inspector
22
================================
3-
This repo attempts to standardize the structure of the Python-based project's
4-
repositories using modern Python packaging and configuration techniques.
5-
Using this `blog post`_ as inspiration, this repository serves as the base for
6-
all new Python projects and is mergeable in existing repositories as well.
73

8-
.. _blog post: https://blog.jaraco.com/a-project-skeleton-for-python-projects/
4+
rust-inspector is a utility to extract dependencies and symbols from Rust binaries.
5+
It is designed to work as a ScanCode Toolkit plugin and integrated in ScanCode.io
6+
pipelines.
97

8+
To install and use:
109

11-
Usage
12-
=====
10+
- Run ``pip install rust-inspector``
11+
- Use with ``scancode --json-pp - --rust-symbol --verbose <PATH to a tree or file with Rust binaries>``
1312

14-
A brand new project
15-
-------------------
16-
.. code-block:: bash
13+
The JSON output will contain binary symbols found in Rust binaries if any.
1714

18-
git init my-new-repo
19-
cd my-new-repo
20-
git pull [email protected]:nexB/skeleton
15+
A Go compiler is required to build go-inspector. Install Go from
16+
https://go.dev/doc/install or from a package manager.
2117

22-
# Create the new repo on GitHub, then update your remote
23-
git remote set-url origin [email protected]:nexB/your-new-repo.git
18+
- License: Apache-2.0 AND MIT
19+
- Copyright (c) nexB Inc., AboutCode, OWASP Foundation and others.
20+
- Homepage: https://github.com/aboutcode-org/rust-inspector
2421

25-
From here, you can make the appropriate changes to the files for your specific project.
22+
Development
23+
----------------
2624

27-
Update an existing project
28-
---------------------------
29-
.. code-block:: bash
25+
- Install requirements and dependencies using ``./configure --clean && ./configure --dev``
26+
- Then ``source venv/bin/activate``
3027

31-
cd my-existing-project
32-
git remote add skeleton [email protected]:nexB/skeleton
33-
git fetch skeleton
34-
git merge skeleton/main --allow-unrelated-histories
28+
Testing:
3529

36-
This is also the workflow to use when updating the skeleton files in any given repository.
30+
- To run tests: ``pytest -vvs``
31+
- To regen test fixtures: ``SCANCODE_REGEN_TEST_FIXTURES=yes pytest -vvs``
3732

38-
More usage instructions can be found in ``docs/skeleton-usage.rst``.
33+
Acknowledgements, Funding, Support and Sponsoring
34+
--------------------------------------------------------
3935

36+
This project is funded, supported and sponsored by:
4037

41-
Release Notes
42-
=============
38+
- Generous support and contributions from users like you!
39+
- the European Commission NGI programme
40+
- the NLnet Foundation
41+
- the Swiss State Secretariat for Education, Research and Innovation (SERI)
42+
- Google, including the Google Summer of Code and the Google Seasons of Doc programmes
43+
- Mercedes-Benz Group
44+
- Microsoft and Microsoft Azure
45+
- AboutCode ASBL
46+
- nexB Inc.
4347

44-
- 2023-07-18:
45-
- Add macOS-13 job in azure-pipelines.yml
48+
This project also uses some functions from other packages:
4649

47-
- 2022-03-04:
48-
- Synchronize configure and configure.bat scripts for sanity
49-
- Update CI operating system support with latest Azure OS images
50-
- Streamline utility scripts in etc/scripts/ to create, fetch and manage third-party dependencies
51-
There are now fewer scripts. See etc/scripts/README.rst for details
50+
- blint (https://github.com/owasp-dep-scan/blint)
51+
- symbolic (https://pypi.org/project/symbolic/)
52+
- lief (https://pypi.org/project/lief/)
5253

53-
- 2021-09-03:
54-
- ``configure`` now requires pinned dependencies via the use of ``requirements.txt`` and ``requirements-dev.txt``
55-
- ``configure`` can now accept multiple options at once
56-
- Add utility scripts from scancode-toolkit/etc/release/ for use in generating project files
57-
- Rename virtual environment directory from ``tmp`` to ``venv``
58-
- Update README.rst with instructions for generating ``requirements.txt`` and ``requirements-dev.txt``,
59-
as well as collecting dependencies as wheels and generating ABOUT files for them.
6054

61-
- 2021-05-11:
62-
- Adopt new configure scripts from ScanCode TK that allows correct configuration of which Python version is used.
55+
|europa| |dgconnect|
56+
57+
|ngi| |nlnet|
58+
59+
|aboutcode| |nexb|
60+
61+
62+
63+
This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial
64+
support from the European Commission's Next Generation Internet programme, under the aegis of DG
65+
Communications Networks, Content and Technology under grant agreement No 101069594.
66+
67+
|ngizeroentrust| https://nlnet.nl/project/Back2source/
68+
69+
70+
This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial
71+
support from the European Commission's Next Generation Internet programme, under the aegis of DG
72+
Communications Networks, Content and Technology under grant agreement No 101092990.
73+
74+
|ngizerocore| https://nlnet.nl/project/Back2source-next/
75+
76+
77+
This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial
78+
support from the European Commission's Next Generation Internet programme, under the aegis of DG
79+
Communications Networks, Content and Technology under grant agreement No 101069594.
80+
81+
|ngizeroentrust| https://nlnet.nl/project/purl2all/
82+
83+
84+
85+
.. |nlnet| image:: https://nlnet.nl/logo/banner.png
86+
:target: https://nlnet.nl
87+
:height: 50
88+
:alt: NLnet foundation logo
89+
90+
.. |ngi| image:: https://ngi.eu/wp-content/uploads/thegem-logos/logo_8269bc6efcf731d34b6385775d76511d_1x.png
91+
:target: https://ngi.eu35
92+
:height: 50
93+
:alt: NGI logo
94+
95+
.. |nexb| image:: https://nexb.com/wp-content/uploads/2022/04/nexB.svg
96+
:target: https://nexb.com
97+
:height: 30
98+
:alt: nexB logo
99+
100+
.. |europa| image:: https://ngi.eu/wp-content/uploads/sites/77/2017/10/bandiera_stelle.png
101+
:target: http://ec.europa.eu/index_en.htm
102+
:height: 40
103+
:alt: Europa logo
104+
105+
.. |aboutcode| image:: https://aboutcode.org/wp-content/uploads/2023/10/AboutCode.svg
106+
:target: https://aboutcode.org/
107+
:height: 30
108+
:alt: AboutCode logo
109+
110+
.. |swiss| image:: https://www.sbfi.admin.ch/sbfi/en/_jcr_content/logo/image.imagespooler.png/1493119032540/logo.png
111+
:target: https://www.sbfi.admin.ch/sbfi/en/home/seri/seri.html
112+
:height: 40
113+
:alt: Swiss logo
114+
115+
.. |dgconnect| image:: https://commission.europa.eu/themes/contrib/oe_theme/dist/ec/images/logo/positive/logo-ec--en.svg
116+
:target: https://commission.europa.eu/about-european-commission/departments-and-executive-agencies/communications-networks-content-and-technology_en
117+
:height: 40
118+
:alt: EC DG Connect logo
119+
120+
.. |ngizerocore| image:: https://nlnet.nl/image/logos/NGI0_tag.svg
121+
:target: https://nlnet.nl/core
122+
:height: 40
123+
:alt: NGI Zero Core Logo
124+
125+
.. |ngizerocommons| image:: https://nlnet.nl/image/logos/NGI0_tag.svg
126+
:target: https://nlnet.nl/commonsfund/
127+
:height: 40
128+
:alt: NGI Zero Commons Logo
129+
130+
.. |ngizeropet| image:: https://nlnet.nl/image/logos/NGI0PET_tag.svg
131+
:target: https://nlnet.nl/PET
132+
:height: 40
133+
:alt: NGI Zero PET logo
134+
135+
.. |ngizeroentrust| image:: https://nlnet.nl/image/logos/NGI0Entrust_tag.svg
136+
:target: https://nlnet.nl/entrust
137+
:height: 38
138+
:alt: NGI Zero Entrust logo
139+
140+
.. |ngiassure| image:: https://nlnet.nl/image/logos/NGIAssure_tag.svg
141+
:target: https://nlnet.nl/image/logos/NGIAssure_tag.svg
142+
:height: 32
143+
:alt: NGI Assure logo
144+
145+
.. |ngidiscovery| image:: https://nlnet.nl/image/logos/NGI0Discovery_tag.svg
146+
:target: https://nlnet.nl/discovery/
147+
:height: 40
148+
:alt: NGI Discovery logo

azure-pipelines.yml

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,22 @@ jobs:
1111
parameters:
1212
job_name: ubuntu20_cpython
1313
image_name: ubuntu-20.04
14-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
14+
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
1515
test_suites:
1616
all: venv/bin/pytest -n 2 -vvs
1717

1818
- template: etc/ci/azure-posix.yml
1919
parameters:
2020
job_name: ubuntu22_cpython
2121
image_name: ubuntu-22.04
22-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
22+
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
2323
test_suites:
2424
all: venv/bin/pytest -n 2 -vvs
2525

2626
- template: etc/ci/azure-posix.yml
2727
parameters:
28-
job_name: macos12_cpython
29-
image_name: macOS-12
30-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
28+
job_name: ubuntu24_cpython
29+
image_name: ubuntu-24.04
30+
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
3131
test_suites:
3232
all: venv/bin/pytest -n 2 -vvs
33-
34-
- template: etc/ci/azure-posix.yml
35-
parameters:
36-
job_name: macos13_cpython
37-
image_name: macOS-13
38-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
39-
test_suites:
40-
all: venv/bin/pytest -n 2 -vvs
41-
42-
- template: etc/ci/azure-posix.yml
43-
parameters:
44-
job_name: macos14_cpython_arm64
45-
image_name: macOS-14
46-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
47-
test_suites:
48-
all: venv/bin/pytest -n 2 -vvs
49-
50-
- template: etc/ci/azure-posix.yml
51-
parameters:
52-
job_name: macos14_cpython
53-
image_name: macOS-14-large
54-
python_versions: ['3.8', '3.8', '3.9', '3.10', '3.12']
55-
test_suites:
56-
all: venv/bin/pytest -n 2 -vvs
57-
58-
- template: etc/ci/azure-win.yml
59-
parameters:
60-
job_name: win2019_cpython
61-
image_name: windows-2019
62-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
63-
test_suites:
64-
all: venv\Scripts\pytest -n 2 -vvs
65-
66-
- template: etc/ci/azure-win.yml
67-
parameters:
68-
job_name: win2022_cpython
69-
image_name: windows-2022
70-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
71-
test_suites:
72-
all: venv\Scripts\pytest -n 2 -vvs

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scancode-toolkit==32.3.0

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# from blint v2.3.2
2+
# https://github.com/owasp-dep-scan/blint/blob/1e1250a4bf6c25eccba8970bd877901ee56070c7/poetry.lock
3+
lief==0.15.1
4+
symbolic==10.2.1

setup.cfg

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[metadata]
2-
name = skeleton
3-
license = Apache-2.0
2+
name = rust-inspector
3+
license = Apache-2.0 AND MIT
44

55
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390
6-
description = skeleton
6+
description = rust-inspector is a scancode plugin to extract symbols and dependencies found in Rust binaries.
77
long_description = file:README.rst
88
long_description_content_type = text/x-rst
9-
url = https://github.com/aboutcode-org/skeleton
9+
url = https://github.com/nexB/rust-inspector
1010

1111
author = nexB. Inc. and others
1212
author_email = [email protected]
@@ -38,17 +38,27 @@ zip_safe = false
3838

3939
setup_requires = setuptools_scm[toml] >= 4
4040

41-
python_requires = >=3.8
41+
python_requires = >=3.9
4242

4343
install_requires =
44+
commoncode
45+
plugincode
46+
typecode
47+
lief==0.15.1
48+
symbolic==10.2.1
4449

50+
[options.entry_points]
51+
52+
scancode_scan =
53+
rust_symbol = rust_inspector.plugin:RustSymbolScannerPlugin
4554

4655
[options.packages.find]
4756
where = src
4857

4958

5059
[options.extras_require]
5160
testing =
61+
scancode-toolkit
5262
pytest >= 6, != 7.0.0
5363
pytest-xdist >= 2
5464
aboutcode-toolkit >= 7.0.2
@@ -65,4 +75,3 @@ docs =
6575
sphinx-autobuild
6676
sphinx-rtd-dark-mode>=1.3.0
6777
sphinx-copybutton
68-

0 commit comments

Comments
 (0)