[go: up one dir, main page]

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

Handle undefined string identifiers. #54

Merged
merged 2 commits into from
Apr 29, 2022

Conversation

wxsBSD
Copy link
Contributor
@wxsBSD wxsBSD commented Apr 29, 2022

When parsing rules gyp does not complain about undefined string identifiers.

For example, it does not error when parsing this rule:

rule a { condition: $x }

With these changes it now walks the condition AST and makes sure all string
references are valid, including wildcard expansion.

While I'm here I uncovered a slight error with the Children() method on the Of
node, where it would always set the Strings to nil if there were none, which is
now fixed.

I also discovered some existing tests that were broken by this (they did not
have a $foo4 string defined) so I "fixed" those too.

When parsing rules gyp does not complain about undefined string identifiers.

For example, it does not error when parsing this rule:

rule a { condition: $x }

With these changes it now walks the condition AST and makes sure all string
references are valid, including wildcard expansion.

While I'm here I uncovered a slight error with the Children() method on the Of
node, where it would always set the Strings to nil if there were none, which is
now fixed.

I also discovered some existing tests that were broken by this (they did not
have a $foo4 string defined) so I "fixed" those too.
parser/grammar.y Outdated Show resolved Hide resolved
Switch to tracking strings in the lexer struct and checking for existence of
strings as they are produced by the parser.
@plusvic plusvic merged commit 6b198f3 into VirusTotal:master Apr 29, 2022
@wxsBSD wxsBSD deleted the undefined_identifier branch April 29, 2022 20:06
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.

2 participants