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

Don't throw exceptions in specific HLIL APIs #6020

Open
fuzyll opened this issue Oct 21, 2024 · 1 comment
Open

Don't throw exceptions in specific HLIL APIs #6020

fuzyll opened this issue Oct 21, 2024 · 1 comment
Labels
Component: API Issue needs changes to the API Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality
Milestone

Comments

@fuzyll
Copy link
Contributor

fuzyll commented Oct 21, 2024

What is the feature you'd like to have?
From an Enterprise user:

Docs say ReferenceSource.hlil may return HighLevelILInstruction or None, which is the behavior I want, but Function.llil (used internally) will raise an ILException if LLIL wasn’t loaded. It would be nice if it returned None without an exception. But, if Exception is the way, can this be reflected in docs?

Is your feature request related to a problem?
Exceptions don’t play nice with map() and filter(), but None does.

Are any alternative solutions acceptable?
I'm not actually sure we should make it not throw an Exception. An alternative way we could solve this is by having e.g. a ReferenceSource.hlil_if_available that, under-the-hood, calls Function.llil_if_available, which (I believe) does what this user wants.

@xusheng6 xusheng6 added Type: Enhancement Issue is a small enhancement to existing functionality Component: API Issue needs changes to the API Impact: Low Issue is a papercut or has a good, supported workaround Effort: Low Issue should take < 1 week labels Oct 29, 2024
@xusheng6
Copy link
Member

I think we should just return None for it. See code at https://github.com/mandiant/capa/blob/2987eeb0acc03e187bdd90bb1644377774a2045a/capa/features/extractors/binja/function.py#L28, where I am aware of .llil may not always give me a result, but the exception throws me off. See mandiant/capa#2249 for more details on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: API Issue needs changes to the API Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants