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

feat: test framework #44

Merged
merged 6 commits into from
Oct 4, 2023
Merged
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
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Files that must preserve LF line endings, even on Windows.
*.formatted text eol=lf
*.unformatted text eol=lf
*.in text eol=lf
*.out text eol=lf
*.unformatted text eol=lf
107 changes: 102 additions & 5 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions yara-x/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ yara-x-proto = { workspace = true }
criterion = { workspace = true }
pretty_assertions = { workspace = true }
wasmprinter = "0.2.62"
ihex = "3.0.0"
goldenfile = "1.5.2"
yara = { version = "0.19.0", features = ["vendored"] }

[[bench]]
Expand Down
14 changes: 12 additions & 2 deletions yara-x/src/modules/macho/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,10 @@ fn handle_segment_command(
cmd: Some(sg.cmd),
cmdsize: Some(sg.cmdsize),
segname: Some(
std::str::from_utf8(&sg.segname).unwrap_or_default().to_string(),
std::str::from_utf8(&sg.segname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
vmaddr: Some(sg.vmaddr as u64),
vmsize: Some(sg.vmsize as u64),
Expand Down Expand Up @@ -1469,11 +1472,13 @@ fn handle_segment_command(
segname: Some(
std::str::from_utf8(&sec.segname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
sectname: Some(
std::str::from_utf8(&sec.sectname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
addr: Some(sec.addr as u64),
Expand Down Expand Up @@ -1552,7 +1557,10 @@ fn handle_segment_command_64(
cmd: Some(sg.cmd),
cmdsize: Some(sg.cmdsize),
segname: Some(
std::str::from_utf8(&sg.segname).unwrap_or_default().to_string(),
std::str::from_utf8(&sg.segname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
vmaddr: Some(sg.vmaddr),
vmsize: Some(sg.vmsize),
Expand Down Expand Up @@ -1584,11 +1592,13 @@ fn handle_segment_command_64(
segname: Some(
std::str::from_utf8(&sec.segname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
sectname: Some(
std::str::from_utf8(&sec.sectname)
.unwrap_or_default()
.trim_end_matches('\0')
.to_string(),
),
addr: Some(sec.addr),
Expand Down
114 changes: 114 additions & 0 deletions yara-x/src/modules/macho/tests/input/macho_ppc_file.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
:10000000FEEDFACE00000012000000000000000229
:100010000000000A000005CC00000085000000017F
:10002000000000385F5F504147455A45524F00007D
:1000300000000000000000000000100000000000B0
:1000400000000000000000000000000000000000B0
:100050000000000400000001000002145F5F54452E
:1000600058540000000000000000000000001000D4
:100070000000F000000000000000F0000000000799
:100080000000000500000007000000005F5F7465CD
:100090007874000000000000000000005F5F54451D
:1000A00058540000000000000000000000001EB8CE
:1000B0000000B83800000EB8000000020000000088
:1000C00000000000800004000000000000000000AC
:1000D0005F5F70696373796D626F6C5F7374756273
:1000E0005F5F54455854000000000000000000000D
:1000F0000000D6F0000000000000C6F00000000282
:100100000000000000000000800000080000000067
:10011000000000245F5F73796D626F6C5F737475AC
:10012000620000005F5F544558540000000000006A
:10013000000000000000D6F0000000000000C6F043
:100140000000000200000000000000008000000825
:1001500000000000000000145F5F70696373796D38
:10016000626F6C73747562315F5F54455854000060
:1001700000000000000000000000D6F000000A00AF
:100180000000C6F0000000020000000000000000B7
:100190008000040800000000000000205F5F63731F
:1001A0007472696E67000000000000005F5F5445D4
:1001B0005854000000000000000000000000E0F0C3
:1001C00000001E880000D0F00000000200000000C7
:1001D000000000000000000200000000000000001D
:1001E0005F5F6C69746572616C380000000000002C
:1001F0005F5F5445585400000000000000000000FC
:100200000000FF78000000500000EF7800000003BD
:1002100000000000000000000000000400000000DA
:10022000000000005F5F65685F6672616D650000D9
:10023000000000005F5F54455854000000000000BB
:10024000000000000000FFC8000000340000EFC8FC
:100250000000000200000000000000006800000B29
:10026000000000000000000000000001000001D0BC
:100270005F5F4441544100000000000000000000A6
:1002800000010000000010000000F000000010005D
:10029000000000070000000300000006000000004E
:1002A0005F5F6461746100000000000000000000F6
:1002B0005F5F444154410000000000000000000066
:1002C00000010000000002540000F00000000003E4
:1002D000000000000000000000000000000000001E
:1002E000000000005F5F6C615F73796D626F6C5F2F
:1002F000707472005F5F44415441000000000000D0
:100300000000000000010254000001400000F2540F
:1003100000000002000000000000000000000007D4
:1003200000000050000000005F5F6E6C5F73796D2D
:10033000626F6C5F707472005F5F444154410000F3
:100340000000000000000000000103940000007C99
:100350000000F39400000002000000000000000014
:1003600000000006000000A0000000005F5F64794C
:100370006C64000000000000000000005F5F44416A
:1003800054410000000000000000000000010410C3
:100390000000001C0000F41000000002000000003B
:1003A000000000000000000000000000000000004D
:1003B0005F5F627373000000000000000000000037
:1003C0005F5F444154410000000000000000000055
:1003D0000001042C000004080000000000000002DE
:1003E000000000000000000000000001000000000C
:1003F000000000005F5F636F6D6D6F6E00000000B6
:10040000000000005F5F4441544100000000000014
:100410000000000000010840000000D000000000C3
:1004200000000004000000000000000000000001C7
:100430000000000000000000000000010000003883
:100440005F5F4C494E4B454449540000000000009A
:10045000000110000000C000000100000000B3D047
:100460000000000700000001000000000000000480
:100470000000000E0000001C0000000C2F757372BD
:100480002F6C69622F64796C640000000000000C1E
:100490000000003400000018423A3B7C0047010194
:1004A000000100002F7573722F6C69622F6C6962F6
:1004B00053797374656D2E422E64796C6962000005
:1004C0000000000200000018000100000000093FC9
:1004D00000017348000040880000000B000000503D
:1004E000000000000000087A0000087A0000006F99
:1004F000000008E9000000560000000000000000B5
:1005000000000000000000000000000000000000EB
:100510000001704C000000BF00000000000000005F
:1005200000000000000000000000001600000010A5
:1005300000016EF40000005600000005000000B04D
:10054000000000010000002800001EB800000000AC
:10055000000000000000000000000000000000009B
:10056000000000000000000000000000000000008B
:10057000000000000000000000000000000000007B
:10058000000000000000000000000000000000006B
:10059000000000000000000000000000000000005B
:1005A000000000000000000000000000000000004B
:1005B000000000000000000000000000000000003B
:1005C000000000000000000000000000000000002B
:1005D000000000000000000000000000000000001B
:1005E000000000000000000000000000000000000B
:1005F00000000000000000000000000000000000FB
:1006000000000000000000000000000000000000EA
:1006100000000000000000000000000000000000DA
:1006200000000000000000000000000000000000CA
:1006300000000000000000000000000000000000BA
:1006400000000000000000000000000000000000AA
:10065000000000000000000000000000000000009A
:10066000000000000000000000000000000000008A
:10067000000000000000000000000000000000007A
:10068000000000000000000000000000000000006A
:10069000000000000000000000000000000000005A
:1006A000000000000000000000000000000000004A
:1006B000000000000000000000000000000000003A
:1006C000000000000000000000000000000000002A
:1006D000000000000000000000000000000000001A
:1006E000000000000000000000000000000000000A
:0406F0000000000006
:00000001FF

Loading