Skip to content

Conversation

@AndreaMarangoni
Copy link
Contributor

Fixes 6402

Made parseStartupPath as a free function rather than private in order to test it.
I am not expanding paths because according to my tests they were coming already expanded.
As per comments on the issue report, I left the entries that didn't make much sense in order to keep the same behaviour.

Copy link
Member

@zwass zwass left a comment

Choose a reason for hiding this comment

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

I like the approach but please see my concern with returning empty values.

windows/windows_eventlog_tests.cpp
windows/windows_optional_features_tests.cpp
windows/windows_update_history_tests.cpp
windows/startup_items_tests.cpp
Copy link
Member

Choose a reason for hiding this comment

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

Please match indentation

Comment on lines +100 to +105
while (!pathExists(path)) {
path = boost::join(tmp_path, " ");
tmp_path = std::vector<std::string>{std::begin(args), --end};

if (std::begin(args) == end) {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

I can see why you decided to do this, but it does have the side effect of returning an empty string for path if no valid path is detected. I wonder if it's better to just return the entire entry in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the path is detected as invalid we skip producing a row entirely. Do you mean you prefer having the Row even if the path is detected as invalid or do you mean something else ? My reasoning was that an invalid path should not produce any row, but I understand that we might actually want to have a Row for invalid paths because it could be a concern.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I misunderstood but I do think an incomplete/invalid entry still makes sense to return -- since those values are actually configured on the system, osquery should return them (IMO).

Copy link
Contributor Author

@AndreaMarangoni AndreaMarangoni Feb 8, 2025

Choose a reason for hiding this comment

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

I have just remembered why I decided to not return anything: we cannot guarantee the path in the entry is double quoted when it includes spaces, so we are always going to split it into multiple components (the bug we are trying to fix). i.e. for the entry C:\Program Files\some space\file.exe is going to be split into C:\Program and Files\some and space\file.exe. And as far as I know it is impossible to reliably "understand" when we have a path unless the file exists on the filesystem, which is not the case when the entry is invalid/incomplete as the case we are trying to fix here. It is a catch 22.

Hence the decision of not including the entry in the result set.

Copy link
Member

Choose a reason for hiding this comment

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

Huh... That behavior sounds horrific.

@AndreaMarangoni AndreaMarangoni marked this pull request as ready for review April 15, 2025 11:39
@AndreaMarangoni AndreaMarangoni requested review from a team as code owners April 15, 2025 11:39
Copy link
Member

@zwass zwass left a comment

Choose a reason for hiding this comment

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

Okay thanks for addressing my concerns. I wish there was a better approach here, but I agree we should go ahead with what you did. Thank you!

@zwass zwass merged commit 73123f9 into osquery:master Apr 15, 2025
22 checks passed
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.

Incorrect presentation of unquoted registry data in "startup_items" table

3 participants