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

ci: added multi-arch bin #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
32 changes: 17 additions & 15 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ name: create-bin

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
workflow_dispatch:

jobs:
build:
strategy:
matrix:
architecture: ["linux/amd64", "linux/arm64"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
submodules: recursive
- uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
sudo apt-get update
sudo apt-get install -y clang llvm libelf-dev gcc-multilib linux-headers-$(uname -r) build-essential
- name: Setting up libbpf
docker buildx build --platform ${{ matrix.architecture }} -o type=local,dest=./docker .
- name: Reformat architecture name
id: reformat_architecture
run: |
make -C lib/libbpf/src
sudo make -C lib/libbpf/src install
- name: Compile
run: |
make
echo "::set-output name=architecture::$(echo ${{ matrix.architecture }} | sed 's/\//-/g')"
- name: Archive production artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v2
with:
name: evilbpf-bin-${{ github.sha }}
name: evilbpf-bin-${{ github.sha }}-${{ steps.reformat_architecture.outputs.architecture }}
path: |
dst
docker/src/dst

# This is so slow ... i hate ARM emul
23 changes: 3 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,20 @@ on:

jobs:
build:
needs: create-bin
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang llvm libelf-dev gcc-multilib linux-headers-$(uname -r) build-essential
- name: Setting up libbpf
run: |
make -C lib/libbpf/src
sudo make -C lib/libbpf/src install
- name: Compile
run: |
make
- name: Zipping artifacts
run: |
zip -r evilbpf-${{ github.ref_name }}.zip dst
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
release_name: evilBPF ${{ github.ref_name }}
draft: true
prerelease: false
- name: Upload release asset
id: upload-release-asset
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/libbpf"]
path = lib/libbpf
url = https://github.com/libbpf/libbpf.git
[submodule "lib/bpftool"]
path = lib/bpftool
url = https://github.com/libbpf/bpftool
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Start from the latest Ubuntu image
FROM ubuntu:latest

# Install dependencies
RUN apt-get update && apt-get install -y \
clang \
llvm \
libelf-dev \
zlib1g-dev \
gcc \
build-essential \
pkgconf

# Copy your source code into the image
COPY . /src

# Set the working directory
WORKDIR /src

# Set up libbpf
RUN make -C lib/libbpf/src && make -C lib/libbpf/src install

# bpftool
RUN make -C lib/bpftool/src && make -C lib/bpftool/src install


# Compile the project
RUN make
1 change: 1 addition & 0 deletions lib/bpftool
Submodule bpftool added at 117434
3 changes: 2 additions & 1 deletion src/common.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARCH ?= $(shell uname -m|sed 's/x86_64/x86/'|sed 's/aarch64/arm/')
LIBBPF_PATH = $(ROOTDIR)/../lib/libbpf/src
LIBBPF_FLAGS = -I$(LIBBPF_PATH) -L$(LIBBPF_PATH) -l:libbpf.a -lbpf
LIBELF_FLAGS ?= $(shell pkg-config --static --libs libelf)
COMMON_INCLUDES = -I.
RELEASE_DIR = $(ROOTDIR)/../dst

Expand All @@ -20,7 +21,7 @@ release: release_dest
# Build application binary
$(APPS): %: | $(APPS).skel.h libbpf $(OBJ)
$(call msg,BINARY,$@)
clang -Wall -O2 [email protected] $(CFLAGS) $(OBJ) $(LIBBPF_FLAGS) -lelf -lz -o $@ -static
clang -Wall -O2 [email protected] $(CFLAGS) $(OBJ) $(LIBBPF_FLAGS) $(LIBELF_FLAGS) -o $@ -static
strip $@

# eBPF skeleton
Expand Down
2 changes: 1 addition & 1 deletion src/ssl_sniffer/ebpf/main.bpf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __VMLINUX_H
#define __VMLINUX_H
#include <vmlinux.h>
#include "vmlinux.h"
#endif
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ssl_sniffer/include/ebpf/maps_bpf.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __VMLINUX_H
#define __VMLINUX_H
#include <vmlinux.h>
#include "vmlinux.h"
#endif

#ifndef __MAPS_BPF_H
Expand Down
Loading