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-1806: Fix removing of parts of rules in tokenstream #206

Merged
merged 11 commits into from
Mar 22, 2022

Conversation

TadeasKucera
Copy link
Contributor

@TadeasKucera TadeasKucera commented Mar 10, 2022

Removing all relevant tokens when deleting YARA rule from YaraFile instance.

@@ -276,6 +276,10 @@ const Meta* Rule::getMetaWithName(const std::string& key) const
*/
TokenIt Rule::getFirstTokenIt() const
{
if (_mod_private.has_value())
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this assume that there is a specific order in which rule modifiers are specified? But YARA grammar allows to specify both private global and global private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I assumed that private comes before global, which is a mistake, thank you very much for noticing! Will fix that.

@@ -276,6 +276,30 @@ const Meta* Rule::getMetaWithName(const std::string& key) const
*/
TokenIt Rule::getFirstTokenIt() const
{
if (isPrivate() && isGlobal())
Copy link
Member

Choose a reason for hiding this comment

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

This feels like a workaround for the problem. What if the new modifier is added? Are we going to list out all the possible combinations? Why not storing the modifiers in some sort of containers. Whenever the first token is requested just the first token is returned from the container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. I have changed the way we work with modifiers so it should be much easier now to add more rule modifiers. Please see the last commit.

@metthal metthal merged commit 0eabede into master Mar 22, 2022
@metthal metthal deleted the fix_removing_of_parts_of_rules_in_tokenstream branch March 22, 2022 21:04
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.

None yet

2 participants