Ruby: Model various JSON methods

This commit is contained in:
Harry Maclean
2022-11-07 12:46:03 +13:00
parent 0a98559fcb
commit 5259d4af63
5 changed files with 77 additions and 0 deletions

View File

@@ -24,3 +24,4 @@ private import codeql.ruby.frameworks.XmlParsing
private import codeql.ruby.frameworks.ActionDispatch
private import codeql.ruby.frameworks.PosixSpawn
private import codeql.ruby.frameworks.StringFormatters
private import codeql.ruby.frameworks.Json

View File

@@ -0,0 +1,22 @@
/** Provides modelling for the `json` gem. */
private import codeql.ruby.frameworks.data.ModelsAsData
/** Provides modelling for the `json` gem. */
module Json {
/**
* Flow summaries for common `JSON` methods.
* Not all of these methods are strictly defined in the `json` gem.
* The `JSON` namespace is heavily overloaded by other JSON parsing gems such as `oj`, `json_pure`, `multi_json` etc.
* This summary covers common methods we've seen called on `JSON` in the wild.
*/
private class JsonSummary extends ModelInput::SummaryModelCsv {
override predicate row(string row) {
row =
[
"json;;Member[JSON].Method[parse,parse!,load,restore];Argument[0];ReturnValue;taint",
"json;;Member[JSON].Method[generate,fast_generate,dump,unparse,fast_unparse];Argument[0];ReturnValue;taint",
]
}
}
}