-
-
Notifications
You must be signed in to change notification settings - Fork 4
Increase server robustness on invalid underlying data #668
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,17 +13,24 @@ | |
| #include <cassert> // assert | ||
| #include <filesystem> // std::filesystem | ||
| #include <sstream> // std::ostringstream | ||
| #include <stdexcept> // std::runtime_error | ||
| #include <string> // std::string, std::getline | ||
| #include <string_view> // std::string_view | ||
|
|
||
| namespace sourcemeta::one { | ||
|
|
||
| static auto search(const std::filesystem::path &search_index, | ||
| const std::string_view query) -> sourcemeta::core::JSON { | ||
| assert(std::filesystem::exists(search_index)); | ||
| if (!std::filesystem::exists(search_index)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this PR’s intent is to avoid debug-only enforcement, note the remaining Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| throw std::runtime_error("Search index not found"); | ||
cubic-dev-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| assert(search_index.is_absolute()); | ||
|
|
||
| auto file{read_stream_raw(search_index)}; | ||
| assert(file.has_value()); | ||
| if (!file.has_value()) { | ||
| throw std::runtime_error("Failed to read search index"); | ||
| } | ||
|
|
||
| auto result{sourcemeta::core::JSON::make_array()}; | ||
| // TODO: Extend the Core JSONL iterators to be able | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
has_value()check won’t help if malformedcurrent_locationcausescurrent_location.at("baseDialect")(and laterat("dialect")) to assert/UB beforeto_base_dialect()is called. If these fields can be missing/invalid, consider validating presence/type withoutat()first.Severity: high
Other Locations
src/server/action_jsonschema_evaluate.h:103🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.