Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add r2-5.8.8 base image #23

Merged
merged 1 commit into from
Jan 16, 2024
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
11 changes: 1 addition & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
name: Python application

on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
Expand All @@ -23,16 +24,6 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Building the test container
run: |
docker compose up --build malcallgraph_test
35 changes: 3 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
# =================
FROM python:3.8-alpine as base
FROM ghcr.io/attilamester/r2-5.8.8
# =================

WORKDIR /usr/callgraph

RUN apk add curl wget graphviz graphviz-dev git make build-base graphviz-libs pkgconfig musl-dev&& \
python3 -m pip install pip==23.0
# && \
#apt-get clean all && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN curl -Ls https://github.com/radareorg/radare2/releases/download/5.8.8/radare2-5.8.8.tar.xz | tar xJv && \
cd radare2-5.8.8 && sed -i "265 i patch-capstone capstone-patch:" ./shlr/Makefile && sed -i 's/CS_VER=4.*/CS_VER=5\.0.1/' ./shlr/Makefile && ./sys/install.sh
#&& \
#apt-get clean all && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY ./requirements.txt .
RUN python3 -m pip install pygraphviz==1.6 --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/" && \
python3 -m pip install -r requirements.txt

# =================
FROM python:3.8-alpine as main
# =================

WORKDIR /usr/callgraph

COPY --from=base /usr/local/bin/python3.8 /usr/local/bin/python3.8
COPY --from=base /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
COPY --from=base /usr/lib/libcgraph* /usr/lib/
COPY --from=base /usr/lib/libcdt* /usr/lib/
COPY --from=base /usr/include/graphviz /usr/include/graphviz
COPY --from=base /usr/share/graphviz /usr/share/graphviz
COPY --from=base /usr/local/lib/radare2 /usr/local/lib/radare2
COPY --from=base /usr/local/bin/radare2 /usr/local/bin/radare2
COPY --from=base /usr/local/share/radare2 /usr/local/share/radare2
COPY --from=base /usr/local/bin/r2 /usr/local/bin/r2
COPY --from=base /usr/local/lib/libr_*.so /usr/local/lib/
COPY --from=base /usr/callgraph/radare2-5.8.8/libr /usr/callgraph/radare2-5.8.8/libr
RUN python3 -m pip install pip==23.0 && \
python3 -m pip install -r requirements.txt

COPY ./src ./src
COPY ./test ./test
Expand Down
31 changes: 31 additions & 0 deletions build/radare2-5.8.8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# =================
FROM python:3.8-alpine as base
# =================

WORKDIR /usr/callgraph

RUN apk update && apk add curl wget graphviz graphviz-dev git make g++ build-base graphviz-libs pkgconfig musl-dev && \
python3 -m pip install pip==23.0

RUN curl -Ls https://github.com/radareorg/radare2/releases/download/5.8.8/radare2-5.8.8.tar.xz | tar xJv && \
cd radare2-5.8.8 && sed -i "265 i patch-capstone capstone-patch:" ./shlr/Makefile && sed -i 's/CS_VER=4.*/CS_VER=5\.0.1/' ./shlr/Makefile && ./sys/install.sh

COPY ./requirements.txt .
RUN python3 -m pip install -r requirements.txt

# =================
FROM python:3.8-alpine as main
# =================

WORKDIR /usr/callgraph

COPY --from=base /usr/local/bin/python3.8 /usr/local/bin/python3.8
COPY --from=base /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
COPY --from=base /usr/include/graphviz /usr/include/graphviz
COPY --from=base /usr/share/graphviz /usr/share/graphviz
COPY --from=base /usr/local/lib/radare2 /usr/local/lib/radare2
COPY --from=base /usr/local/bin/radare2 /usr/local/bin/radare2
COPY --from=base /usr/local/share/radare2 /usr/local/share/radare2
COPY --from=base /usr/local/bin/r2 /usr/local/bin/r2
COPY --from=base /usr/local/lib/libr_*.so /usr/local/lib/
COPY --from=base /usr/callgraph/radare2-5.8.8/libr /usr/callgraph/radare2-5.8.8/libr
5 changes: 0 additions & 5 deletions Dockerfile_deb → build/radare2-5.8.8/Dockerfile_deb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ COPY --from=base /usr/local/share/radare2 /usr/local/share/radare2
COPY --from=base /usr/local/bin/r2 /usr/local/bin/r2
COPY --from=base /usr/local/lib/libr_*.so /usr/local/lib/
COPY --from=base /usr/callgraph/radare2-5.8.8/libr /usr/callgraph/radare2-5.8.8/libr

COPY ./src ./src
COPY ./test ./test

CMD ["python3", "-m", "pytest", "-ra", "./test/test.py"]
4 changes: 4 additions & 0 deletions build/radare2-5.8.8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `r2-5.8.8` image

* `docker login`
* `docker push <(docker/ghcr).io>/attilamester/r2-5.8.8`
11 changes: 11 additions & 0 deletions build/radare2-5.8.8/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.8'
services:

r2-5.8.8:
image: attilamester/r2-5.8.8
container_name: container_r2-5.8.8
build:
context: .
network: host
dockerfile: ./Dockerfile
network_mode: "host"
3 changes: 3 additions & 0 deletions build/radare2-5.8.8/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy==1.24.4
pygraphviz==1.11
r2pipe==1.8.8
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ python-dotenv==0.15.0
pytz==2019.1
requests==2.21.0
urllib3==1.24.3
networkx==2.4
python-louvain==0.15
pygraphviz==1.6
networkx==3.1
pygraphviz==1.11
r2pipe==1.8.8
numpy==1.16.3
numpy==1.24.4
pyzipper==0.3.6
pytest==7.4.4
pre-commit==3.5.0
Loading