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

Only track selected functions #32

Open
AryazE opened this issue Jun 28, 2023 · 3 comments
Open

Only track selected functions #32

AryazE opened this issue Jun 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@AryazE
Copy link
Collaborator

AryazE commented Jun 28, 2023

For some analyses it would be nice to only instrument and analyze specific functions.
This can either be done by

  • appending the name to pre_call and post_call, e.g. pre_call_open or
  • adding decorators, e.g.
@only(functions=['open', 'close'])
def pre_call(...)
...

@except(functions=['read', 'write'])
def post_call(...)
@AryazE AryazE added the enhancement New feature or request label Jun 28, 2023
@AryazE
Copy link
Collaborator Author

AryazE commented Jul 3, 2023

Also

  • literals with specific patterns
  • identifiers (function names, attribute names, etc.)
    Even for arguments of hooks, e.g. binary operations applied to foo

@nimamg
Copy link
Contributor

nimamg commented Jul 6, 2023

Another enhancement related to this issue would be to track objects of a specific type (or subclass of a particular class).

Also, if decorators such as the example you provided are to be used, it could be even better to call any arbitrary function as a hook as long as it has the decorator. This can help in writing cleaner analyzers, as the dispatch per object type should be handled manually in the hook right now.

For example:

@pre_call(functions=['open', 'close']
def file_handling_pre_call(...)

@pre_call(functions=['startswith', 'endswith'])
def string_handling_pre_call(...)

Although this would be a major breaking change.

@AryazE
Copy link
Collaborator Author

AryazE commented Oct 26, 2023

@nimamg Do you mean to have hooks for specific object types? Like a hook that gets called every time there is a function call on a string type?

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

No branches or pull requests

2 participants