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

There's no way to return an error from MemoryBlockIterator #118

Open
smoofra opened this issue May 18, 2023 · 5 comments
Open

There's no way to return an error from MemoryBlockIterator #118

smoofra opened this issue May 18, 2023 · 5 comments

Comments

@smoofra
Copy link

smoofra commented May 18, 2023

In C, a YR_MEMORY_BLOCK_ITERATOR can set last_error from its iteration functions in order to return an error, but this doesn't seem to be accessible from go.

@hillu
Copy link
Owner

hillu commented May 19, 2023

Guilty as charged. ;-) I think this was added to YARA for 4.1.0, after I had done the iterator code. Just like file_size.

I have added another interface, MemoryBlockIterator in the iterator-last-error branch. Would you like to have a look if this works for you – and maybe contribute a test case for this? Thanks!

@smoofra
Copy link
Author

smoofra commented May 24, 2023

thanks for responding! What you've got would work, but I think returning an error directly from First() and Next() would be more go-like and easier to use. What do you think?

@hillu
Copy link
Owner

hillu commented May 25, 2023

Making First, Next return an error would break the API. Perhaps for version 5.0.

@smoofra
Copy link
Author

smoofra commented May 26, 2023

doesn't adding a new method to the interface also break the API?

@hillu
Copy link
Owner

hillu commented May 27, 2023

doesn't adding a new method to the interface also break the API?

No. For code using go-yara, implementing the extra interface is optional.

Even though this is not the most (Golang-)idiomatic way to signal an error, I can't think of a better alternative. Would you like to contirbute a test case?

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

No branches or pull requests

2 participants