-
Notifications
You must be signed in to change notification settings - Fork 44
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
YARA-1806: Fix removing of parts of rules in tokenstream #206
Conversation
src/types/rule.cpp
Outdated
@@ -276,6 +276,10 @@ const Meta* Rule::getMetaWithName(const std::string& key) const | |||
*/ | |||
TokenIt Rule::getFirstTokenIt() const | |||
{ | |||
if (_mod_private.has_value()) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
src/types/rule.cpp
Outdated
@@ -276,6 +276,30 @@ const Meta* Rule::getMetaWithName(const std::string& key) const | |||
*/ | |||
TokenIt Rule::getFirstTokenIt() const | |||
{ | |||
if (isPrivate() && isGlobal()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Removing all relevant tokens when deleting YARA rule from
YaraFile
instance.