diff --git a/.github/scripts/package.sh b/.github/scripts/package.sh new file mode 100644 index 0000000..4f9f504 --- /dev/null +++ b/.github/scripts/package.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -eu + +# Slightly tweaked from https://github.com/EmbarkStudios/cargo-about/blob/main/.github/workflows/rust-ci.yml (MIT or APACHE 2.0) +# When run in a container, the ownership will be messed up, so mark the +# checkout dir as safe regardless of our env +git config --global --add safe.directory "$GITHUB_WORKSPACE" + +# Normally we'll only do this on tags, but add --always to fallback to the revision +# if we're iterating or the like +tag=$(git describe --tags --abbrev=0 --always) + +if [[ ${tag:0:1} != "v" ]]; then + tag="nightly" +fi + +release_name="$NAME-$tag-$TARGET" +release_zip="${release_name}.zip" +release_tar="${release_name}.tar.gz" + +mkdir "$release_name" + +if [[ "$TARGET" =~ windows ]]; then + bin="$NAME.exe" + cp "examples/target/$TARGET/release-action/$bin" "$release_name/" + cp README.md LICENSE "$release_name/" + 7z a -tzip "$release_zip" "$release_name" +else + bin="$NAME" + cp "examples/target/$TARGET/release-action/$bin" "$release_name/" + cp README.md LICENSE "$release_name/" + tar czf "$release_tar" "$release_name" +fi + +rm -r "$release_name" + +# Windows environments in github actions don't have the gnu coreutils installed, +# which includes the shasum exe, so we just use powershell instead +if [[ "$TARGET" =~ windows ]]; then + echo "(Get-FileHash \"${release_zip}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_zip}.sha256\"" | pwsh -c - +else + echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" +fi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2ae32f1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release Example Binary + +permissions: + contents: write + +on: + push: + tags: + - v[0-9]+.* + +jobs: + upload-release: + strategy: + matrix: + info: + - os: "macOS-latest" + target: "x86_64-apple-darwin" + - os: "macOS-latest" + target: "aarch64-apple-darwin" + - os: "windows-latest" + target: "x86_64-pc-windows-msvc" + - os: "ubuntu-latest" + target: "x86_64-unknown-linux-gnu" + runs-on: ${{ matrix.info.os }} + steps: + - name: Setup Stable Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.info.target }} + components: clippy, rustfmt + + - name: Build Example + run: cd examples && cargo build --release --target ${{ matrix.info.target }} + + - name: Package Example + shell: bash + env: + NAME: unifiedlog_iterator + TARGET: ${{ matrix.info.target }} + run: .github/scripts/package.sh + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: "unifiedlog_iterator*" + name: "${{ vars.GITHUB_REF_NAME }} - Released!" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 12070c8..9025071 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,15 +11,15 @@ keywords = ["forensics", "macOS", "unifiedlog"] [dependencies] nom = "7.1.3" -serde_json = "1.0.133" -serde = { version = "1.0.215", features = ["derive"] } +serde_json = "1.0.135" +serde = { version = "1.0.217", features = ["derive"] } log = "0.4.22" lz4_flex = "0.11.3" byteorder = "1.5.0" plist = "1.7.0" regex = "1.11.1" base64 = "0.22.1" -chrono = "0.4.38" +chrono = "0.4.39" walkdir = "2.5.0" [dev-dependencies] @@ -27,7 +27,7 @@ simplelog = "0.12.2" csv = "1.3.1" chrono = "0.4.38" criterion = "0.5.1" -anyhow = "1.0.94" +anyhow = "1.0.95" test-case = "3.3" [[bench]] diff --git a/deny.toml b/deny.toml index 498541b..bb2268f 100644 --- a/deny.toml +++ b/deny.toml @@ -99,14 +99,7 @@ ignore = [] # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -allow = [ - "MIT", - "Apache-2.0", - "BSL-1.0", - "Unlicense", - "Unicode-DFS-2016", - "Unicode-3.0", -] +allow = ["MIT", "Apache-2.0", "BSL-1.0", "Unlicense", "Unicode-3.0"] # List of explicitly disallowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. diff --git a/src/parser.rs b/src/parser.rs index 67effeb..c6d624d 100755 --- a/src/parser.rs +++ b/src/parser.rs @@ -174,7 +174,7 @@ pub fn collect_timesync(provider: &dyn FileProvider) -> Result #[cfg(test)] mod tests { - use crate::filesystem::{LiveSystemProvider, LogarchiveProvider}; + use crate::filesystem::LogarchiveProvider; use crate::parser::{ build_log, collect_shared_strings, collect_strings, collect_timesync, parse_log, }; @@ -183,6 +183,7 @@ mod tests { #[test] #[cfg(target_os = "macos")] fn test_collect_strings_system() { + use crate::filesystem::LiveSystemProvider; let system_provider = LiveSystemProvider::default(); let uuidtext_results = collect_strings(&system_provider).unwrap(); assert!(uuidtext_results.len() > 100); @@ -191,6 +192,7 @@ mod tests { #[test] #[cfg(target_os = "macos")] fn test_collect_timesync_system() { + use crate::filesystem::LiveSystemProvider; let system_provider = LiveSystemProvider::default(); let timesync_results = collect_timesync(&system_provider).unwrap(); assert!(timesync_results.len() > 1); @@ -225,6 +227,7 @@ mod tests { #[test] #[cfg(target_os = "macos")] fn test_collect_shared_strings_system() { + use crate::filesystem::LiveSystemProvider; let system_provider = LiveSystemProvider::default(); let shared_strings_results = collect_shared_strings(&system_provider).unwrap(); assert!(shared_strings_results[0].ranges.len() > 1);