MCPcopy Create free account
hub / github.com/baidu/openrasp / fetch_bool

Method fetch_bool

agent/php7/utils/json_reader.cc:133–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133bool JsonReader::fetch_bool(const std::vector<std::string> &keys, const bool &default_value)
134{
135 json::json_pointer ptr = json::json_pointer(to_json_pointer(keys));
136 try
137 {
138 if (j.at(ptr).is_boolean())
139 {
140 return j.at(ptr);
141 }
142 else
143 {
144 throw nlohmann::detail::other_error::create(900, "type should be boolean");
145 }
146 }
147 catch (const nlohmann::detail::exception &e)
148 {
149 if (get_exception_report())
150 {
151 openrasp_error(LEVEL_WARNING, CONFIG_ERROR, _("%s, config \"%s\" use the default value \"%s\""),
152 e.what(), BaseReader::stringfy_keys(keys).c_str(), default_value ? "true" : "false");
153 }
154 }
155 return default_value;
156}
157
158std::vector<std::string> JsonReader::fetch_object_keys(const std::vector<std::string> &keys)
159{

Callers 1

updateMethod · 0.45

Calls 4

to_json_pointerFunction · 0.70
openrasp_errorFunction · 0.50
_Function · 0.50
whatMethod · 0.45

Tested by

no test coverage detected