Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Executing a multiline query starting with -- comment returns error #7961

@lszcs90

Description

@lszcs90

Bug report

Executing a multiline query starting with -- comment returns error. Reproduced with osqueryi.

What operating system and version are you using?

Windows 10, 10.0.19044.2728

What version of osquery are you using?

Reproduced with 5.5.1 and 5.8.1.

What steps did you take to reproduce the issue?

PS C:\Windows\System32> $query = Get-Content -Raw 'd:\test1.query'
PS C:\Windows\System32> $query
-- some comment
SELECT *
FROM time;
PS C:\Windows\System32> & 'D:\osqueryi.exe' $query
ERROR: unknown command line flag ' some comment
SELECT *
FROM time;'

What did you expect to see?

Result of the query, no error.

What did you see instead?

Command line parsing error.

Notes

Comments with /* */ works as expected:

PS C:\Windows\System32> $query = Get-Content -Raw 'd:\test2.query'
PS C:\Windows\System32> $query
/*some comment*/
SELECT *
FROM time;
PS C:\Windows\System32> & 'D:\osqueryi.exe' $query
+----------+------+-------+-----+------+---------+---------+----------+-------------------+------------+------------------------------+----------------------+----------------------+--------------------+
| weekday  | year | month | day | hour | minutes | seconds | timezone | local_timezone    | unix_time  | timestamp                    | datetime             | iso_8601             | win_timestamp      |
+----------+------+-------+-----+------+---------+---------+----------+-------------------+------------+------------------------------+----------------------+----------------------+--------------------+
| Saturday | 2023 | 3     | 18  | 9    | 37      | 46      | UTC      | GTB Standard Time | 1679132266 | Sat Mar 18 09:37:46 2023 UTC | 2023-03-18T09:37:46Z | 2023-03-18T09:37:46Z | 133236058667177168 |
+----------+------+-------+-----+------+---------+---------+----------+-------------------+------------+------------------------------+----------------------+----------------------+--------------------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions