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

Print module names. #1801

Merged
merged 2 commits into from
Oct 14, 2022
Merged

Print module names. #1801

merged 2 commits into from
Oct 14, 2022

Conversation

wxsBSD
Copy link
Collaborator

@wxsBSD wxsBSD commented Oct 12, 2022

Add a -M option to the cli which will print the module names to stdout. As the number of modules has grown it can become confusing to know what modules are available, so this option will display them on stdout.

NOTE: I'm not sure I like how I implemented this. It seems hackish to expose an API that just prints things on stdout but it felt even more hackish to walk the yr_modules_table array from outside of the module code. ;)

Fixes #737.

Add a -M option to the cli which will print the module names to stdout. As the
number of modules has grown it can become confusing to know what modules are
available, so this option will display them on stdout.

NOTE: I'm not sure I like how I implemented this. It seems hackish to expose an
API that just prints things on stdout but it felt even more hackish to walk the
yr_modules_table array from outside of the module code. ;)

Fixes VirusTotal#737.
@@ -191,3 +191,9 @@ int yr_modules_unload_all(YR_SCAN_CONTEXT* context)

return ERROR_SUCCESS;
}

void yr_modules_print_names(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this a proper API that returns the list of module names without printing it. You may want to get the list of modules for some other reason besides printing it to the console.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but I'm not sure you will like the name I went with: yr_modules_get_table(). I'm happy to rename it to something better if you have suggestions, maybe yr_modules_get_modules()?

Also, I'll update docs for this before merging.

Lastly, any thoughts on adding something like this to yara-python? I think it would be useful to be able to get that information from there too. I'll add it there if you agree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that adding it to yara-python may be useful too.

This adds a yr_modules_get_table to the libyara API so callers can get access to
the modules. This is currently only used for printing the available module names
in the yara cli. With this change it is now possible to expose this information
in yara-python too.
@plusvic plusvic merged commit b4f33e2 into VirusTotal:master Oct 14, 2022
@wxsBSD wxsBSD deleted the list_modules branch October 14, 2022 11:14
@vthib vthib mentioned this pull request Dec 27, 2022
7 tasks
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 this pull request may close these issues.

Command to list the modules installed
2 participants