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

String location coordinates should start at the $ symbol #126

Open
MatejKastak opened this issue Aug 17, 2020 · 0 comments
Open

String location coordinates should start at the $ symbol #126

MatejKastak opened this issue Aug 17, 2020 · 0 comments

Comments

@MatejKastak
Copy link
Member

MatejKastak commented Aug 17, 2020

String location does not point to the character $ and instead points to the first character of the identifier name.

  • string.location.begin [should be equal] string.token_id.location.begin
  • location.begin should point to the $ character
  • location.end should point to the last character of the string value (depending on the string type)
  • correctness can be checked with the following test:
    def test_string_id_location(self):
        ymod = yaramod.Yaramod()
        yara_file = ymod.parse_string(r'''rule rule1 : Tag1 {
    strings:
        $1 = "Hello World!"
    condition:
        false
}
''')
        s = yara_file.rules[0].strings[0]
        self.assertEqual(s.token_id.location.begin.line, 3)
        self.assertEqual(s.token_id.location.begin.column, 9)
        self.assertEqual(s.token_id.location.end.line, 3)
        self.assertEqual(s.token_id.location.end.column, 10)
        self.assertEqual(s.location.begin.line, 3)
        self.assertEqual(s.location.begin.column, 9)  # FIXME: Wrong - 10 / Correct - 9
        self.assertEqual(s.location.end.line, 3)
        self.assertEqual(s.location.end.column, 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant