Skip to content

Conversation

@Smjert
Copy link
Member

@Smjert Smjert commented Jul 17, 2023

No description provided.

@Smjert Smjert requested review from a team as code owners July 17, 2023 21:01
@Smjert Smjert marked this pull request as draft July 17, 2023 22:20
@Smjert Smjert force-pushed the stefano/improvement/regex-split-discard-empty branch from 8d5c7c3 to de127f0 Compare July 18, 2023 14:58
@Smjert Smjert force-pushed the stefano/improvement/regex-split-discard-empty branch from de127f0 to 6190a09 Compare July 18, 2023 14:59
@Smjert Smjert changed the title Improvement: Avoid returning empty matches with regex_split sql: Avoid returning empty matches with regex_split Jul 18, 2023
osquery> .mode line

osquery> select uid from users;
osquery> select uid from users;
Copy link
Member

Choose a reason for hiding this comment

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

Is this whitespace intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's to force a linebreak, since if you check here https://osquery.readthedocs.io/en/latest/introduction/sql/#string-functions, the uid = 500 line is rendered on the same line of the query.

EXPECT_EQ(d[0]["t1"], "foo");
EXPECT_EQ(d[0]["t2"], "bar");
EXPECT_EQ(d[0]["t3"], "");
EXPECT_EQ(d[0]["t0"], "foo");
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 breaking change. And I have no idea what correct is in the larger world.

Though, I guess regex_split and split behave differently, and that's also confusing:

osquery> select split('/foo/bar', '/', 1), regex_split('/foo/bar', '/', 1);
+---------------------------+---------------------------------+
| split('/foo/bar', '/', 1) | regex_split('/foo/bar', '/', 1) |
+---------------------------+---------------------------------+
| bar                       | foo                             |
+---------------------------+---------------------------------+

Still, I worry about a breaking change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants