diff --git a/.github/workflows/darwin-arm64.yml b/.github/workflows/darwin-arm64.yml new file mode 100644 index 00000000..3180fd98 --- /dev/null +++ b/.github/workflows/darwin-arm64.yml @@ -0,0 +1,40 @@ +name: darwin-arm64 + +on: + push: + branches: [master] + pull_request: + branches: [master] +env: + CARGO_TERM_COLOR: always +jobs: + darwin-arm64: + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + - name: Install x86 Brew + run: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + - name: Brew packages + continue-on-error: true + run: | + arch -x86_64 /usr/local/bin/brew update + arch -x86_64 /usr/local/bin/brew install gdb curl python llvm \ + openjdk ca-certificates gnupg nodejs --overwrite + - name: Build + run: cargo build --all-features --verbose + - name: NPM packages + run: | + sudo npm install -g jsfuzz + sudo npm install --save-dev @jazzer.js/core + - name: Rust packages + run: | + curl https://sh.rustup.rs -o rustup.sh && chmod +x rustup.sh && \ + ./rustup.sh -y && rm rustup.sh + rustup install nightly + export PATH=/root/.cargo/bin:$PATH + cargo install cargo-fuzz + - name: Run tests + run: | + cargo test --release --verbose --lib -- --test-threads 1 + cargo test --release --verbose --package casr diff --git a/README.md b/README.md index e3ce0538..ea3747f9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![amd64](https://github.com/ispras/casr/actions/workflows/amd64.yml/badge.svg?branch=master)](https://github.com/ispras/casr/actions/workflows/amd64.yml) [![aarch64](https://github.com/ispras/casr/actions/workflows/aarch64.yml/badge.svg?branch=master)](https://github.com/ispras/casr/actions/workflows/aarch64.yml) [![riscv64](https://github.com/ispras/casr/actions/workflows/riscv64.yml/badge.svg?branch=master)](https://github.com/ispras/casr/actions/workflows/riscv64.yml) +[![darwin-arm64](https://github.com/ispras/casr/actions/workflows/darwin-arm64.yml/badge.svg?branch=master)](https://github.com/ispras/casr/actions/workflows/darwin-arm64.yml) [![fuzzing](https://github.com/ispras/casr/actions/workflows/fuzzing.yml/badge.svg?branch=master)](https://github.com/ispras/casr/actions/workflows/fuzzing.yml) # CASR: Crash Analysis and Severity Report diff --git a/casr/src/bin/casr-san.rs b/casr/src/bin/casr-san.rs index 7b25dd15..bb20f660 100644 --- a/casr/src/bin/casr-san.rs +++ b/casr/src/bin/casr-san.rs @@ -22,7 +22,6 @@ use clap::{Arg, ArgAction, ArgGroup}; use gdb_command::mappings::{MappedFiles, MappedFilesExt}; use gdb_command::stacktrace::StacktraceExt; use gdb_command::*; -use linux_personality::personality; use regex::Regex; use std::env; @@ -141,15 +140,24 @@ fn main() -> Result<()> { if argv.len() > 1 { sanitizers_cmd.args(&argv[1..]); } - let sanitizers_cmd = unsafe { - sanitizers_cmd.pre_exec(|| { - if personality(linux_personality::ADDR_NO_RANDOMIZE).is_err() { - panic!("Cannot set personality"); - } - Ok(()) - }) - }; - let sanitizers_result = util::get_output(sanitizers_cmd, timeout, true)?; + #[cfg(target_os = "macos")] + { + sanitizers_cmd.env("DYLD_NO_PIE", "1"); + } + #[cfg(target_os = "linux")] + { + use linux_personality::{personality, ADDR_NO_RANDOMIZE}; + + unsafe { + sanitizers_cmd.pre_exec(|| { + if personality(ADDR_NO_RANDOMIZE).is_err() { + panic!("Cannot set personality"); + } + Ok(()) + }) + }; + } + let sanitizers_result = util::get_output(&mut sanitizers_cmd, timeout, true)?; let sanitizers_stderr = String::from_utf8_lossy(&sanitizers_result.stderr); if sanitizers_stderr.contains("Cannot set personality") { diff --git a/casr/tests/casr_tests/darwin_Makefile b/casr/tests/casr_tests/darwin_Makefile new file mode 100644 index 00000000..0399e166 --- /dev/null +++ b/casr/tests/casr_tests/darwin_Makefile @@ -0,0 +1,45 @@ +all: test_returnAv test_segFaultOnPc test_abort test_destAv test_destAvNearNull test_sourceAv test_sourceAvNearNull test_callAv test_callAvTainted test_heapError test_canary test_badInstruction test_safeFunc test_stackOverflow test_destAvTainted test_DivByZero test_sigbus test_sig_me + +test_returnAv: test_returnAv.c + gcc -g -O0 -fno-stack-protector test_returnAv.c -o ./mac_bin/test_returnAv +test_segFaultOnPc: test_segFaultOnPc.c + gcc -g -O0 -fno-stack-protector test_segFaultOnPc.c -o ./mac_bin/test_segFaultOnPc +test_abort: test_abort.c + gcc -g -O0 -D_FORTIFY_SOURCE=2 test_abort.c -o ./mac_bin/test_abort +test_destAv: test_destAv.c + gcc -g -O0 test_destAv.c -o ./mac_bin/test_destAv +test_destAvNearNull: + gcc -g test_destAvNearNull.c -o ./mac_bin/test_destAvNearNull +test_sourceAv: test_sourceAv.c + gcc -g test_sourceAv.c -o ./mac_bin/test_sourceAv +test_sourceAvNearNull: test_sourceAvNearNull.c + gcc -g test_sourceAvNearNull.c -o ./mac_bin/test_sourceAvNearNull +test_callAvTainted: test_callAv.c + gcc -g -O0 test_callAv.c -o ./mac_bin/test_callAvTainted +test_callAv: test_callAv.c + gcc -g -O2 test_callAv.c -o ./mac_bin/test_callAv +test_heapError: test_heapError.c + gcc -g -O0 test_heapError.c -o ./mac_bin/test_heapError +test_canary: test_returnAv.c + gcc -g -O0 -fstack-protector-all test_returnAv.c -o ./mac_bin/test_canary +test_safeFunc: test_returnAv.c + gcc -g -O2 test_returnAv.c -o ./mac_bin/test_safeFunc +test_badInstruction: test_badInstruction.c + gcc -O0 ./test_badInstruction.c -o ./mac_bin/test_badInstruction +test_stackOverflow: test_stackOverflow.c + gcc -O0 ./test_stackOverflow.c -o ./mac_bin/./test_stackOverflow +test_destAvTainted: test_destAvTainted.c + gcc -O0 ./test_destAvTainted.c -o ./mac_bin/./test_destAvTainted +test_DivByZero: + gcc -g test_DivByZero.c -o ./mac_bin/test_DivByZero +test_sigbus: + gcc -g test_sigbus.c -o ./mac_bin/test_sigbus +test_sig_me: + gcc -g test_sig_me.c -o ./mac_bin/test_sig_me + +clean: + cd mac_bin && rm -f test_stackOverflow \ + test_badInstruction test_safeFunc test_returnAv test_segFaultOnPc \ + test_abort test_destAv test_destAvNearNull test_sourceAv \ + test_sourceAvNearNull test_callAv test_heapError \ + test_canary test_callAvTainted test_DivByZero test_destAvTainted \ No newline at end of file diff --git a/casr/tests/casr_tests/mac_bin/test_DivByZero b/casr/tests/casr_tests/mac_bin/test_DivByZero new file mode 100755 index 00000000..ce4fdfcb Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_DivByZero differ diff --git a/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Info.plist new file mode 100644 index 00000000..d95a8756 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_DivByZero + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/DWARF/test_DivByZero b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/DWARF/test_DivByZero new file mode 100644 index 00000000..286f5824 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/DWARF/test_DivByZero differ diff --git a/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/Relocations/x86_64/test_DivByZero.yml b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/Relocations/x86_64/test_DivByZero.yml new file mode 100644 index 00000000..1dc0bd92 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_DivByZero.dSYM/Contents/Resources/Relocations/x86_64/test_DivByZero.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_DivByZero' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F20, symSize: 0x65 } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F20, symSize: 0x65 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_abort b/casr/tests/casr_tests/mac_bin/test_abort new file mode 100755 index 00000000..03b743cc Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_abort differ diff --git a/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Info.plist new file mode 100644 index 00000000..409d5769 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_abort + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/DWARF/test_abort b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/DWARF/test_abort new file mode 100644 index 00000000..ddb78e89 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/DWARF/test_abort differ diff --git a/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/Relocations/x86_64/test_abort.yml b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/Relocations/x86_64/test_abort.yml new file mode 100644 index 00000000..ca2a8cbf --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_abort.dSYM/Contents/Resources/Relocations/x86_64/test_abort.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_abort' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x61 } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x61 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_badInstruction b/casr/tests/casr_tests/mac_bin/test_badInstruction new file mode 100755 index 00000000..0de2726f Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_badInstruction differ diff --git a/casr/tests/casr_tests/mac_bin/test_callAv b/casr/tests/casr_tests/mac_bin/test_callAv new file mode 100755 index 00000000..f2f3c751 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_callAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Info.plist new file mode 100644 index 00000000..a8e6f477 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_callAv + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/DWARF/test_callAv b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/DWARF/test_callAv new file mode 100644 index 00000000..bb2c165e Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/DWARF/test_callAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/Relocations/x86_64/test_callAv.yml b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/Relocations/x86_64/test_callAv.yml new file mode 100644 index 00000000..815b0e0c --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_callAv.dSYM/Contents/Resources/Relocations/x86_64/test_callAv.yml @@ -0,0 +1,9 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_callAv' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _func1, symObjAddr: 0x0, symBinAddr: 0x100003F20, symSize: 0x10 } + - { offsetInCU: 0x33, offset: 0x33, size: 0x8, addend: 0x0, symName: _func1, symObjAddr: 0x0, symBinAddr: 0x100003F20, symSize: 0x10 } + - { offsetInCU: 0x48, offset: 0x48, size: 0x8, addend: 0x0, symName: _func2, symObjAddr: 0x10, symBinAddr: 0x100003F30, symSize: 0x10 } + - { offsetInCU: 0x5D, offset: 0x5D, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x20, symBinAddr: 0x100003F40, symSize: 0x50 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_callAvTainted b/casr/tests/casr_tests/mac_bin/test_callAvTainted new file mode 100755 index 00000000..61b4c53e Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_callAvTainted differ diff --git a/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Info.plist new file mode 100644 index 00000000..0cd1cea2 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_callAvTainted + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/DWARF/test_callAvTainted b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/DWARF/test_callAvTainted new file mode 100644 index 00000000..55ffb9dd Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/DWARF/test_callAvTainted differ diff --git a/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/Relocations/x86_64/test_callAvTainted.yml b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/Relocations/x86_64/test_callAvTainted.yml new file mode 100644 index 00000000..4a75c83a --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_callAvTainted.dSYM/Contents/Resources/Relocations/x86_64/test_callAvTainted.yml @@ -0,0 +1,9 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_callAvTainted' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _func1, symObjAddr: 0x0, symBinAddr: 0x100003EF0, symSize: 0x10 } + - { offsetInCU: 0x33, offset: 0x33, size: 0x8, addend: 0x0, symName: _func1, symObjAddr: 0x0, symBinAddr: 0x100003EF0, symSize: 0x10 } + - { offsetInCU: 0x48, offset: 0x48, size: 0x8, addend: 0x0, symName: _func2, symObjAddr: 0x10, symBinAddr: 0x100003F00, symSize: 0x10 } + - { offsetInCU: 0x5D, offset: 0x5D, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x20, symBinAddr: 0x100003F10, symSize: 0x87 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_canary b/casr/tests/casr_tests/mac_bin/test_canary new file mode 100755 index 00000000..75b63179 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_canary differ diff --git a/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Info.plist new file mode 100644 index 00000000..90858b8f --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_canary + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/DWARF/test_canary b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/DWARF/test_canary new file mode 100644 index 00000000..ec3a8cb6 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/DWARF/test_canary differ diff --git a/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/Relocations/x86_64/test_canary.yml b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/Relocations/x86_64/test_canary.yml new file mode 100644 index 00000000..ba22fcb7 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_canary.dSYM/Contents/Resources/Relocations/x86_64/test_canary.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_canary' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x96 } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x96 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_destAv b/casr/tests/casr_tests/mac_bin/test_destAv new file mode 100755 index 00000000..a78793ed Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_destAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Info.plist new file mode 100644 index 00000000..5b5c3423 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_destAv + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/DWARF/test_destAv b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/DWARF/test_destAv new file mode 100644 index 00000000..2271256e Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/DWARF/test_destAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/Relocations/x86_64/test_destAv.yml b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/Relocations/x86_64/test_destAv.yml new file mode 100644 index 00000000..60bba687 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_destAv.dSYM/Contents/Resources/Relocations/x86_64/test_destAv.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_destAv' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x96 } + - { offsetInCU: 0x53, offset: 0x53, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x96 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_destAvNearNull b/casr/tests/casr_tests/mac_bin/test_destAvNearNull new file mode 100755 index 00000000..e5b6ac9f Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_destAvNearNull differ diff --git a/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Info.plist new file mode 100644 index 00000000..a87a81b3 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_destAvNearNull + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/DWARF/test_destAvNearNull b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/DWARF/test_destAvNearNull new file mode 100644 index 00000000..78a7970a Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/DWARF/test_destAvNearNull differ diff --git a/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_destAvNearNull.yml b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_destAvNearNull.yml new file mode 100644 index 00000000..983c3eb8 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_destAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_destAvNearNull.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_destAvNearNull' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EC0, symSize: 0xB0 } + - { offsetInCU: 0x53, offset: 0x53, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EC0, symSize: 0xB0 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_destAvTainted b/casr/tests/casr_tests/mac_bin/test_destAvTainted new file mode 100755 index 00000000..5b11d7e0 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_destAvTainted differ diff --git a/casr/tests/casr_tests/mac_bin/test_heapError b/casr/tests/casr_tests/mac_bin/test_heapError new file mode 100755 index 00000000..60a870f3 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_heapError differ diff --git a/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Info.plist new file mode 100644 index 00000000..2559bb81 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_heapError + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/DWARF/test_heapError b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/DWARF/test_heapError new file mode 100644 index 00000000..8777fe0f Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/DWARF/test_heapError differ diff --git a/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/Relocations/x86_64/test_heapError.yml b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/Relocations/x86_64/test_heapError.yml new file mode 100644 index 00000000..b0e08a0b --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_heapError.dSYM/Contents/Resources/Relocations/x86_64/test_heapError.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_heapError' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EE0, symSize: 0x8E } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EE0, symSize: 0x8E } +... diff --git a/casr/tests/casr_tests/mac_bin/test_returnAv b/casr/tests/casr_tests/mac_bin/test_returnAv new file mode 100755 index 00000000..41121539 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_returnAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Info.plist new file mode 100644 index 00000000..fa28bbe0 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_returnAv + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/DWARF/test_returnAv b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/DWARF/test_returnAv new file mode 100644 index 00000000..9acefdb2 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/DWARF/test_returnAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/Relocations/x86_64/test_returnAv.yml b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/Relocations/x86_64/test_returnAv.yml new file mode 100644 index 00000000..01b91bcf --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_returnAv.dSYM/Contents/Resources/Relocations/x86_64/test_returnAv.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_returnAv' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x6A } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x6A } +... diff --git a/casr/tests/casr_tests/mac_bin/test_safeFunc b/casr/tests/casr_tests/mac_bin/test_safeFunc new file mode 100755 index 00000000..d2af44b8 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_safeFunc differ diff --git a/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Info.plist new file mode 100644 index 00000000..c9a738f0 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_safeFunc + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/DWARF/test_safeFunc b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/DWARF/test_safeFunc new file mode 100644 index 00000000..480e3a4c Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/DWARF/test_safeFunc differ diff --git a/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/Relocations/x86_64/test_safeFunc.yml b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/Relocations/x86_64/test_safeFunc.yml new file mode 100644 index 00000000..f8dfb815 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_safeFunc.dSYM/Contents/Resources/Relocations/x86_64/test_safeFunc.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_safeFunc' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x62 } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F10, symSize: 0x62 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_segFaultOnPc b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc new file mode 100755 index 00000000..b17facbb Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc differ diff --git a/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Info.plist new file mode 100644 index 00000000..d9a3ab1f --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_segFaultOnPc + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/DWARF/test_segFaultOnPc b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/DWARF/test_segFaultOnPc new file mode 100644 index 00000000..af3007db Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/DWARF/test_segFaultOnPc differ diff --git a/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/Relocations/x86_64/test_segFaultOnPc.yml b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/Relocations/x86_64/test_segFaultOnPc.yml new file mode 100644 index 00000000..fb4a6671 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_segFaultOnPc.dSYM/Contents/Resources/Relocations/x86_64/test_segFaultOnPc.yml @@ -0,0 +1,8 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_segFaultOnPc' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _copyTolocal, symObjAddr: 0x0, symBinAddr: 0x100003EF0, symSize: 0x30 } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _copyTolocal, symObjAddr: 0x0, symBinAddr: 0x100003EF0, symSize: 0x30 } + - { offsetInCU: 0x74, offset: 0x74, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x30, symBinAddr: 0x100003F20, symSize: 0x55 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_sig_me b/casr/tests/casr_tests/mac_bin/test_sig_me new file mode 100755 index 00000000..412fbca2 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sig_me differ diff --git a/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Info.plist new file mode 100644 index 00000000..0b6e6f5f --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_sig_me + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/DWARF/test_sig_me b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/DWARF/test_sig_me new file mode 100644 index 00000000..05d83d09 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/DWARF/test_sig_me differ diff --git a/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/Relocations/x86_64/test_sig_me.yml b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/Relocations/x86_64/test_sig_me.yml new file mode 100644 index 00000000..9c4ec2a8 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sig_me.dSYM/Contents/Resources/Relocations/x86_64/test_sig_me.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_sig_me' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003E60, symSize: 0x10E } + - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003E60, symSize: 0x10E } +... diff --git a/casr/tests/casr_tests/mac_bin/test_sigbus b/casr/tests/casr_tests/mac_bin/test_sigbus new file mode 100755 index 00000000..51a58323 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sigbus differ diff --git a/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Info.plist new file mode 100644 index 00000000..6f3c217e --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_sigbus + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/DWARF/test_sigbus b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/DWARF/test_sigbus new file mode 100644 index 00000000..85897b36 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/DWARF/test_sigbus differ diff --git a/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/Relocations/x86_64/test_sigbus.yml b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/Relocations/x86_64/test_sigbus.yml new file mode 100644 index 00000000..4487c9ea --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sigbus.dSYM/Contents/Resources/Relocations/x86_64/test_sigbus.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_sigbus' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F60, symSize: 0x3C } + - { offsetInCU: 0x4B, offset: 0x4B, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F60, symSize: 0x3C } +... diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAv b/casr/tests/casr_tests/mac_bin/test_sourceAv new file mode 100755 index 00000000..56961879 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sourceAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Info.plist new file mode 100644 index 00000000..19d264c9 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_sourceAv + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/DWARF/test_sourceAv b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/DWARF/test_sourceAv new file mode 100644 index 00000000..f029b572 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/DWARF/test_sourceAv differ diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAv.yml b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAv.yml new file mode 100644 index 00000000..42a3044e --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sourceAv.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAv.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_sourceAv' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x9D } + - { offsetInCU: 0x53, offset: 0x53, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003ED0, symSize: 0x9D } +... diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull new file mode 100755 index 00000000..955c73da Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull differ diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Info.plist b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Info.plist new file mode 100644 index 00000000..d7cc07a8 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.test_sourceAvNearNull + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/DWARF/test_sourceAvNearNull b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/DWARF/test_sourceAvNearNull new file mode 100644 index 00000000..0e8dce15 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/DWARF/test_sourceAvNearNull differ diff --git a/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAvNearNull.yml b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAvNearNull.yml new file mode 100644 index 00000000..84fffac8 --- /dev/null +++ b/casr/tests/casr_tests/mac_bin/test_sourceAvNearNull.dSYM/Contents/Resources/Relocations/x86_64/test_sourceAvNearNull.yml @@ -0,0 +1,7 @@ +--- +triple: 'x86_64-apple-darwin' +binary-path: './mac_bin/test_sourceAvNearNull' +relocations: + - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F70, symSize: 0x31 } + - { offsetInCU: 0x45, offset: 0x45, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F70, symSize: 0x31 } +... diff --git a/casr/tests/casr_tests/mac_bin/test_stackOverflow b/casr/tests/casr_tests/mac_bin/test_stackOverflow new file mode 100755 index 00000000..a443f994 Binary files /dev/null and b/casr/tests/casr_tests/mac_bin/test_stackOverflow differ diff --git a/casr/tests/tests.rs b/casr/tests/tests.rs index a426f461..9490cb18 100644 --- a/casr/tests/tests.rs +++ b/casr/tests/tests.rs @@ -31,7 +31,13 @@ fn abs_path(rpath: &str) -> String { let rpath = match std::env::consts::ARCH { "aarch64" => rpath.replace("bin", "arm_bin"), "riscv64" => rpath.replace("bin", "riscv_bin"), - _ => rpath.to_string(), + _ => { + if std::env::consts::OS == "macos" { + rpath.replace("bin", "mac_bin") + } else { + rpath.to_string() + } + } }; let project_dir = PathBuf::from(*PROJECT_DIR.read().unwrap()); let mut path = PathBuf::new(); @@ -42,6 +48,7 @@ fn abs_path(rpath: &str) -> String { } #[test] +#[cfg(not(target_os = "macos"))] fn test_segfault_on_pc() { let paths = [ abs_path("tests/casr_tests/bin/core.test_segFaultOnPc"), @@ -78,6 +85,7 @@ fn test_segfault_on_pc() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_dest_av() { let paths = [ abs_path("tests/casr_tests/bin/core.test_destAv"), @@ -114,6 +122,7 @@ fn test_dest_av() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_dest_av_near_null() { let paths = [ abs_path("tests/casr_tests/bin/core.test_destAvNearNull"), @@ -223,6 +232,7 @@ fn test_call_av() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_call_av_tainted() { let paths = [ abs_path("tests/casr_tests/bin/core.test_callAvTainted"), @@ -259,6 +269,7 @@ fn test_call_av_tainted() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_source_av() { let paths = [ abs_path("tests/casr_tests/bin/core.test_sourceAv"), @@ -295,6 +306,7 @@ fn test_source_av() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_source_av_near_null() { let paths = [ abs_path("tests/casr_tests/bin/core.test_sourceAvNearNull"), @@ -331,6 +343,7 @@ fn test_source_av_near_null() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_abort() { let paths = [ abs_path("tests/casr_tests/bin/core.test_abort"), @@ -440,6 +453,7 @@ fn test_safe_func() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_bad_instruction() { let paths = [ abs_path("tests/casr_tests/bin/core.test_badInstruction"), @@ -513,6 +527,7 @@ fn test_stack_overflow() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_dest_av_tainted() { let paths = [ abs_path("tests/casr_tests/bin/core.test_destAvTainted"), @@ -3417,6 +3432,7 @@ fn test_casr_san_segf() { } #[test] +#[cfg(not(target_os = "macos"))] fn test_casr_san_exception() { let paths = [ abs_path("tests/casr_tests/test_exception.cpp"), diff --git a/libcasr/src/report.rs b/libcasr/src/report.rs index 5b1a9dd7..ae7fb1ed 100644 --- a/libcasr/src/report.rs +++ b/libcasr/src/report.rs @@ -272,20 +272,44 @@ impl CrashReport { /// Add information about operation system pub fn add_os_info(&mut self) -> error::Result<()> { // Get os and os release. - let mut info_cmd = Command::new("sh"); - info_cmd.arg("-c").arg("lsb_release -sir"); - let info_out = info_cmd.output()?; - if info_out.status.success() { - if let Ok(info) = String::from_utf8(info_out.stdout) { - info.split('\n').enumerate().for_each(|(i, s)| match i { - 0 => { - self.os = s.trim().to_string(); - } - 1 => { - self.os_release = s.trim().to_string(); - } - _ => {} - }); + #[cfg(target_os = "linux")] + { + let mut info_cmd = Command::new("sh"); + info_cmd.arg("-c").arg("lsb_release -sir"); + let info_out = info_cmd.output()?; + if info_out.status.success() { + if let Ok(info) = String::from_utf8(info_out.stdout) { + info.split('\n').enumerate().for_each(|(i, s)| match i { + 0 => { + self.os = s.trim().to_string(); + } + 1 => { + self.os_release = s.trim().to_string(); + } + _ => {} + }); + } + } + } + #[cfg(target_os = "macos")] + { + // Use sw_vers + let mut os_cmd = Command::new("sw_vers"); + os_cmd.arg("--productName"); + let os_out = os_cmd.output()?; + if os_out.status.success() { + if let Ok(os) = String::from_utf8(os_out.stdout) { + self.os = os.trim().to_string(); + } + } + + let mut release_cmd = Command::new("sw_vers"); + release_cmd.arg("-productVersion"); + let release_out = release_cmd.output()?; + if release_out.status.success() { + if let Ok(release) = String::from_utf8(release_out.stdout) { + self.os_release = release.trim().to_string(); + } } } // Get uname -a.