Skip to content

Commit

Permalink
feat(dynamic): make dynamic analysis optional for better platform sup…
Browse files Browse the repository at this point in the history
…port (#31)

* feat(dynamic): make dynamic analysis optional for better platform support

* feat(ci): expand the build matrix

* chore(file): disable general file analysis for windows

#35

* feat(release): publish pre-built binaries for more platforms

* docs(website): mention feature flags

* chore: enable builds for more platforms

* chore(ci): add powerpc64le-unknown-linux-gnu target
  • Loading branch information
orhun authored Sep 18, 2024
1 parent 3179751 commit 580c9ec
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 168 deletions.
157 changes: 136 additions & 21 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,102 @@ on:

jobs:
publish-github:
name: Publish on GitHub
runs-on: ubuntu-22.04
name: Publish for ${{ matrix.build.OS }} (${{ matrix.build.TARGET }})
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: false
matrix:
TARGET: [x86_64-unknown-linux-gnu]
build:
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-musl,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: riscv64gc-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv5te-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv7-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: powerpc64le-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-msvc,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
ALL_FEATURES: false,
}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -20,52 +111,76 @@ jobs:
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
targets: ${{ matrix.TARGET }}
toolchain: ${{ matrix.build.TOOLCHAIN }}
targets: ${{ matrix.build.TARGET }}

- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2

- name: Build
run: cargo build --release --locked --target ${{ matrix.TARGET }}
shell: bash
run: |
if [ "${{ matrix.build.ALL_FEATURES }}" = true ]; then
cargo build --release --locked --target ${{ matrix.build.TARGET }}
else
cargo build --release --no-default-features --locked --target ${{ matrix.build.TARGET }}
fi
- name: Prepare release assets
shell: bash
run: |
mkdir -p release
cp {LICENSE-MIT,LICENSE-APACHE,README.md,CHANGELOG.md} release/
cp target/${{ matrix.TARGET }}/release/binsider release/ && strip -s release/binsider
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
cp target/${{ matrix.build.TARGET }}/release/binsider.exe release/
else
cp target/${{ matrix.build.TARGET }}/release/binsider release/ && strip -s release/binsider
fi
mv release/ binsider-${{env.RELEASE_VERSION}}/
- name: Create release artifacts
shell: bash
run: |
tar -czvf binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
binsider-${{ env.RELEASE_VERSION }}/
sha512sum binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
> binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
7z a -tzip "binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \
binsider-${{ env.RELEASE_VERSION }}/
else
tar -czvf binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
binsider-${{ env.RELEASE_VERSION }}/
shasum -a 512 binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
> binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512
fi
- name: Sign the release
if: matrix.build.OS != 'windows-2022'
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{secrets.GPG_PASSPHRASE}}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
args: --latest --github-repo ${{ github.repository }}
env:
OUTPUT: CHANGES.md

- name: Create release
run: |
gh release create "${{ github.ref_name }}" -F CHANGES.md
gh release upload "${{ github.ref_name }}" \
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sig \
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Upload the binary releases
uses: svenstaro/upload-release-action@v2
with:
file: binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: ${{ steps.git-cliff.outputs.content }}
repo_token: ${{ secrets.RELEASE_TOKEN }}

publish-crates-io:
name: Publish on crates.io
Expand Down
88 changes: 87 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,91 @@ jobs:
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-musl,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: riscv64gc-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv5te-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv7-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: powerpc64le-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-msvc,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
ALL_FEATURES: false,
}
steps:
- name: Checkout the repository
Expand All @@ -51,7 +131,13 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build the project
run: cargo build --locked --verbose
shell: bash
run: |
if [ "${{ matrix.build.ALL_FEATURES }}" = true ]; then
cargo build --locked --verbose
else
cargo build --no-default-features --locked --verbose
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ include = [
"CHANGELOG.md",
]

[features]
default = ["dynamic-analysis"]
dynamic-analysis = ["lurk-cli"]

[dependencies]
ratatui = "0.28.1"
clap = { version = "4.5.17", features = ["derive", "env", "wrap_help", "cargo"] }
Expand All @@ -30,7 +34,7 @@ tui-input = "0.10.1"
tui-popup = "0.5.0"
unicode-width = "0.1.11"
textwrap = "0.16.1"
lurk-cli = "0.3.6"
lurk-cli = { version = "0.3.7", optional = true }
nix = { version = "0.29.0", features = ["ptrace", "signal"] }
ansi-to-tui = "6.0.0"
console = "0.15.8"
Expand Down
10 changes: 9 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
elf::Elf,
error::{Error, Result},
file::FileInfo,
tracer::TraceData,
tui::event::Event,
};
use elf::{endian::AnyEndian, ElfBytes};
Expand All @@ -18,6 +17,15 @@ use std::{
thread,
};

/// Tracer data.
#[derive(Debug, Default)]
pub struct TraceData {
/// System calls.
pub syscalls: Vec<u8>,
/// Summary.
pub summary: Vec<u8>,
}

/// Binary analyzer.
pub struct Analyzer<'a> {
/// List of files that are being analyzed.
Expand Down
Loading

0 comments on commit 580c9ec

Please sign in to comment.