add support of lief, based on a suggestion by trou #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Testing portability (OS and python version) | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-20.04", "ubuntu-latest", "macos-latest"] | |
python-version: ["3.10", "pypy2.7", "pypy3.9", "graalpy-22.3"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Compute python major version | |
id: pyver | |
run: | | |
python -c 'import sys;print("pyver=%s"%sys.version_info[0])' >> "$GITHUB_OUTPUT" | |
- name: pypy2.7 does not have lzma by default | |
if: ${{ matrix.python-version == 'pypy2.7' }} | |
run: | | |
if test Linux = `uname -s`; then sudo apt-get install xz-utils; fi | |
unxz cpu_rec_corpus/*.xz | |
- name: Analyze /bin/sh | |
run: | | |
python ./cpu_rec.py -v /bin/sh | |
- name: Same, but should be faster because using pickled data | |
run: | | |
python ./cpu_rec.py -v /bin/sh | |
- name: Install three variants of elfesteem | |
run: | | |
git clone https://github.com/LRGH/elfesteem | |
mv elfesteem elfesteem.LRGH | |
git clone https://github.com/airbus-seclab/elfesteem | |
mv elfesteem elfesteem.seclab | |
git clone https://github.com/serpilliere/elfesteem | |
mv elfesteem elfesteem.serpi | |
- name: Analyze /bin/sh with LRGH's elfesteem | |
run: | | |
export PYTHONPATH=./elfesteem.LRGH | |
python ./cpu_rec.py -v /bin/sh | |
- name: Analyze /bin/sh with airbus-seclab's elfesteem | |
if: ${{ steps.pyver.outputs.pyver == 2 && matrix.os != 'macos-latest' }} | |
# Cannot parse Mach-O | |
run: | | |
export PYTHONPATH=./elfesteem.seclab | |
python ./cpu_rec.py -v /bin/sh | |
- name: Analyze /bin/sh with serpilliere's elfesteem | |
if: ${{ steps.pyver.outputs.pyver == 2 && matrix.os != 'macos-latest' }} | |
# Cannot parse Mach-O | |
run: | | |
export PYTHONPATH=./elfesteem.serpi | |
python ./cpu_rec.py -v /bin/sh | |
- name: Install lief | |
if: ${{ steps.pyver.outputs.pyver == 3 && !(matrix.os == 'macos-latest' && matrix.python-version == 'graalpy-22.3') }} | |
# To check why lief/graalpy does not work with MacOSX | |
run: | | |
pip install lief | |
- name: Analyze /bin/sh with lief | |
if: ${{ steps.pyver.outputs.pyver == 3 && !(matrix.os == 'macos-latest' && matrix.python-version == 'graalpy-22.3') }} | |
run: | | |
python ./cpu_rec.py -v /bin/sh | |
python24: | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 2.4 | |
run: | | |
cd .. | |
curl -O https://www.python.org/ftp/python/2.4.6/Python-2.4.6.tgz | |
tar xzf Python-2.4.6.tgz | |
cd Python-2.4.6 | |
./configure | |
make | |
export PATH=$(pwd):$PATH | |
cd ../cpu_rec | |
python -c 'import sys;print(sys.version)' | |
- name: Analyze /bin/sh | |
run: | | |
python ./cpu_rec.py -v /bin/sh | |
- name: Same, but should be faster because using pickled data | |
run: | | |
python ./cpu_rec.py -v /bin/sh | |
- name: Install elfesteem | |
run: | | |
git clone https://github.com/LRGH/elfesteem | |
- name: Analyze /bin/sh with LRGH's elfesteem | |
run: | | |
export PYTHONPATH=./elfesteem | |
python ./cpu_rec.py -v /bin/sh | |
test-C: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-latest", "macos-latest"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Uncompress corpus | |
run: | | |
cp -r cpu_rec_corpus /tmp | |
unxz /tmp/cpu_rec_corpus/*.xz | |
- name: Compile cpu_rec | |
run: | | |
gcc -O3 -o cpu_rec cpu_rec.c -lm | |
- name: Analyze /bin/sh | |
run: | | |
./cpu_rec /bin/sh | sort +1 |