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

yara.Match unexpected incompatibility #56

Closed
seb-acsc opened this issue Nov 13, 2024 · 4 comments · Fixed by #62
Closed

yara.Match unexpected incompatibility #56

seb-acsc opened this issue Nov 13, 2024 · 4 comments · Fixed by #62

Comments

@seb-acsc
Copy link
Contributor

Looks like 1.2.0 breaks compatibility for extractors that inspect yara rules.

Running maco with the demo extractors causes the following issue:

$ maco demo_extractors/ demo_extractors/
...
path: demo_extractors/complex/__pycache__/complex.cpython-312.pyc
run Complex extractor from rules ['Complex', 'ComplexAlt']
extractor error with demo_extractors/complex/__pycache__/complex.cpython-312.pyc ('StringMatch' object is not subscriptable)
Traceback (most recent call last):
  File ".../Maco/maco/cli.py", line 60, in process_file
    resp = collected.extract(stream, hits, extractor_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Maco/maco/collector.py", line 118, in extract
    resp = extractor["module"]().run(stream, matches)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Maco/demo_extractors/complex/complex.py", line 53, in run
  File "/home/seb/work/Maco/demo_extractors/complex/complex.py", line 53, in run
    strings = {y[2].decode("utf8") for x in matches for y in x.strings}
               ~^^^
TypeError: 'StringMatch' object is not subscriptable
...
@seb-acsc
Copy link
Contributor Author

Appears that it should now be something like strings = {z.plaintext().decode("utf8") for x in matches for y in x.strings for z in y.instances}

@seb-acsc
Copy link
Contributor Author

seb-acsc commented Nov 13, 2024

Assuming this is intentional, I can put together a PR to update the demo extractors and try to make a unit test for them

@cccs-rs
Copy link
Contributor

cccs-rs commented Nov 13, 2024

Well the maco.yara module is meant to contain a bunch of interfaces that are meant to replicate the behaviour of matches from yara-python (while running yara-x under the hood).

If this is an action that you can perform in yara-python normally, then I think we should extend that functionality to the interface classes

@seb-acsc
Copy link
Contributor Author

I've confirmed that this issue was originally raised with Yara (non x) v4.3.0, and that the maco interfaces are correct. I'll submit a PR with the updated demo extractor, and add testing of the demo extractor run so we can pick this up next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants