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

fix: Add stricter checks to JSON parsing #8229

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

Smjert
Copy link
Member

@Smjert Smjert commented Dec 23, 2023

I went through or uses of fromString and checked where we weren't making sure that the correct root node of the JSON tree was of the correct type.

We should also go through all uses of rapidjson and see if all the proper checks when accessing the rest of the JSON nodes are correct (checking that something IsString before doing GetString and so on).

@Smjert Smjert added the bug label Dec 23, 2023
@Smjert Smjert requested review from a team as code owners December 23, 2023 10:49
Copy link
Member

@directionless directionless left a comment

Choose a reason for hiding this comment

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

I always wonder if this is the sort of thing we can lint for. But I don't know how good our linting tools are. Feels like it ought be solvable with static analysis

@Smjert
Copy link
Member Author

Smjert commented Dec 23, 2023

I always wonder if this is the sort of thing we can lint for. But I don't know how good our linting tools are. Feels like it ought be solvable with static analysis

With CodeQL rules it should be somewhat possible. The main issue is still that C++ is hard to parse and to create the CodeQL database takes time, and you need to do that for each platform.
I have been working in the past to have CodeQL run on github actions: https://github.com/Smjert/osquery/tree/stefano/ci/codeql

I had it working in the past for Linux, but now I'm updating it to run on Windows and macOS too; on Linux, as far as the object cache can be used, it takes 1h for the workflow to run.

Mind that this is all done on free time.

@directionless directionless added this to the 5.11.0 milestone Dec 27, 2023
@Smjert Smjert merged commit d9ac612 into osquery:master Dec 27, 2023
16 checks passed
@Smjert Smjert deleted the stefano/fix/json-type-checks branch December 27, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants