Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Hugal31/yara-rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugal31 committed Apr 6, 2023
2 parents f296fcd + ff1ad6e commit 75ccad1
Show file tree
Hide file tree
Showing 12 changed files with 740 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
override: true
- uses: katyo/publish-crates@v1
with:
args: "--features bundled-4_2_3"
args: "--features bundled-4_3_0"
dry-run: ${{ github.event.inputs.dry_run }}
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features bindgen,bundled-4_2_3,vendored -- -D warnings
args: --features bindgen,bundled-4_3_0,vendored -- -D warnings

test-posix:
strategy:
matrix:
os: [ ubuntu-latest ]
target: ["x86_64-unknown-linux-musl", "x86_64-unknown-linux-gnu"]
features: [ "vendored,bindgen", "vendored,bundled-4_2_3" ]
features: [ "vendored,bindgen", "vendored,bundled-4_3_0" ]
rust: [ stable, nightly ]

runs-on: ${{ matrix.os }}
Expand All @@ -68,7 +68,7 @@ jobs:
strategy:
matrix:
os: [ windows-2019 ]
features: [ "vendored,bundled-4_2_3" ]
features: [ "vendored,bundled-4_3_0" ]
rust: [ stable ]
cryptolib: [ "OpenSSL", "WinCrypt", "disabled" ]

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
strategy:
matrix:
os: [ macos-10.15 ]
features: [ "vendored,bindgen", "vendored,bundled-4_2_3" ]
features: [ "vendored,bindgen", "vendored,bundled-4_3_0" ]
rust: [ stable, nightly ]
cryptolib: [ "OpenSSL", "CommonCrypto", "disabled" ]
openssl_dir: [ "/usr/local/opt/openssl@1.1" ]
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ edition = "2018"
[features]
default = ["bindgen", 'module-dotnet', 'module-dex', 'module-macho', 'module-hash', 'ndebug']
bindgen = ["yara-sys/bindgen"]
bundled-4_2_3 = ["yara-sys/bundled-4_2_3"]
bundled-4_3_0 = ["yara-sys/bundled-4_3_0"]
vendored = ["yara-sys/vendored"]
module-cuckoo = ["yara-sys/module-cuckoo"]
module-magic = ["yara-sys/module-magic"]
Expand Down Expand Up @@ -48,4 +48,4 @@ default-features = false

[package.metadata.docs.rs]
no-default-features = true
features = ["bundled-4_2_3"]
features = ["bundled-4_3_0"]
4 changes: 2 additions & 2 deletions yara-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2018"

[features]
default = ["bindgen", 'module-dotnet', 'module-dex', 'module-macho', 'module-hash', 'ndebug']
bundled-4_2_3 = []
bundled-4_3_0 = []
vendored = ["cc", "globwalk", "fs_extra"]
module-cuckoo = []
module-magic = []
Expand All @@ -35,4 +35,4 @@ fs_extra = { version = "1.2", optional = true }

[package.metadata.docs.rs]
no-default-features = true
features = ["bundled-4_2_3"]
features = ["bundled-4_3_0"]
4 changes: 2 additions & 2 deletions yara-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ version of Yara. Just make sure the version you specify is the same that the
version on your system!

- `bindgen`: **recommended**: this is the default feature, to use generated bindings.
- `vendored`: automatically compile and link libyara v4.2.3.
- `bundled-4_2_3`: use pre-generated bindings for Yara 4.2.3. Useful if you do not
- `vendored`: automatically compile and link libyara v4.3.0.
- `bundled-4_3_0`: use pre-generated bindings for Yara 4.3.0. Useful if you do not
want to install LLVM to run bindgen. However, you'll have to make sure you use
a version of Yara with the same major and minor version number. List of supported targets:
- x86_64-apple-darwin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub const ERROR_DUPLICATED_MODIFIER: u32 = 60;
pub const ERROR_BLOCK_NOT_READY: u32 = 61;
pub const ERROR_INVALID_PERCENTAGE: u32 = 62;
pub const ERROR_IDENTIFIER_MATCHES_WILDCARD: u32 = 63;
pub const ERROR_INVALID_VALUE: u32 = 64;
pub const CALLBACK_MSG_RULE_MATCHING: u32 = 1;
pub const CALLBACK_MSG_RULE_NOT_MATCHING: u32 = 2;
pub const CALLBACK_MSG_SCAN_FINISHED: u32 = 3;
Expand Down Expand Up @@ -2578,6 +2579,7 @@ pub struct YR_MATCH {
pub next: *mut YR_MATCH,
pub chain_length: i32,
pub is_private: bool,
pub xor_key: u8,
}
#[test]
fn bindgen_test_layout_YR_MATCH() {
Expand Down Expand Up @@ -2683,6 +2685,16 @@ fn bindgen_test_layout_YR_MATCH() {
stringify!(is_private)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).xor_key) as usize - ptr as usize },
53usize,
concat!(
"Offset of field: ",
stringify!(YR_MATCH),
"::",
stringify!(xor_key)
)
);
}
#[repr(C)]
#[repr(align(8))]
Expand Down Expand Up @@ -4290,9 +4302,115 @@ fn bindgen_test_layout_YR_INT_ENUM_ITERATOR() {
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YR_STRING_SET_ITERATOR {
pub count: i64,
pub index: i64,
pub strings: [*mut YR_STRING; 1usize],
}
#[test]
fn bindgen_test_layout_YR_STRING_SET_ITERATOR() {
const UNINIT: ::std::mem::MaybeUninit<YR_STRING_SET_ITERATOR> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<YR_STRING_SET_ITERATOR>(),
24usize,
concat!("Size of: ", stringify!(YR_STRING_SET_ITERATOR))
);
assert_eq!(
::std::mem::align_of::<YR_STRING_SET_ITERATOR>(),
8usize,
concat!("Alignment of ", stringify!(YR_STRING_SET_ITERATOR))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(YR_STRING_SET_ITERATOR),
"::",
stringify!(count)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(YR_STRING_SET_ITERATOR),
"::",
stringify!(index)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).strings) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(YR_STRING_SET_ITERATOR),
"::",
stringify!(strings)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YR_TEXT_STRING_SET_ITERATOR {
pub count: i64,
pub index: i64,
pub strings: [*mut SIZED_STRING; 1usize],
}
#[test]
fn bindgen_test_layout_YR_TEXT_STRING_SET_ITERATOR() {
const UNINIT: ::std::mem::MaybeUninit<YR_TEXT_STRING_SET_ITERATOR> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<YR_TEXT_STRING_SET_ITERATOR>(),
24usize,
concat!("Size of: ", stringify!(YR_TEXT_STRING_SET_ITERATOR))
);
assert_eq!(
::std::mem::align_of::<YR_TEXT_STRING_SET_ITERATOR>(),
8usize,
concat!("Alignment of ", stringify!(YR_TEXT_STRING_SET_ITERATOR))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(YR_TEXT_STRING_SET_ITERATOR),
"::",
stringify!(count)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(YR_TEXT_STRING_SET_ITERATOR),
"::",
stringify!(index)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).strings) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(YR_TEXT_STRING_SET_ITERATOR),
"::",
stringify!(strings)
)
);
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YR_ITERATOR {
pub next_func_idx: ::std::os::raw::c_int,
pub next_func_idx: u8,
pub __bindgen_anon_1: YR_ITERATOR__bindgen_ty_1,
}
#[repr(C)]
Expand All @@ -4302,6 +4420,8 @@ pub union YR_ITERATOR__bindgen_ty_1 {
pub dict_it: YR_DICT_ITERATOR,
pub int_range_it: YR_INT_RANGE_ITERATOR,
pub int_enum_it: YR_INT_ENUM_ITERATOR,
pub string_set_it: YR_STRING_SET_ITERATOR,
pub text_string_set_it: YR_TEXT_STRING_SET_ITERATOR,
}
#[test]
fn bindgen_test_layout_YR_ITERATOR__bindgen_ty_1() {
Expand Down Expand Up @@ -4358,6 +4478,26 @@ fn bindgen_test_layout_YR_ITERATOR__bindgen_ty_1() {
stringify!(int_enum_it)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).string_set_it) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(YR_ITERATOR__bindgen_ty_1),
"::",
stringify!(string_set_it)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).text_string_set_it) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(YR_ITERATOR__bindgen_ty_1),
"::",
stringify!(text_string_set_it)
)
);
}
#[test]
fn bindgen_test_layout_YR_ITERATOR() {
Expand Down
Loading

0 comments on commit 75ccad1

Please sign in to comment.