| // Copyright 2026 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // https://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| // | |
| #include "validator/graph_internals.h" | |
| #include <string> | |
| #include <utility> | |
| #include "absl/container/flat_hash_set.h" | |
| #include "absl/strings/str_cat.h" | |
| #include "absl/strings/string_view.h" | |
| #include "proto/ingredient_assertion.pb.h" | |
| #include "proto/validation_status.pb.h" | |
| namespace credentio { | |
| namespace { | |
| ValidationStatus FromOriginalValidator(ValidationStatus status) { | |
| std::string explanation = "from original validator"; | |
| if (!status.explanation().empty()) { | |
| absl::StrAppend(&explanation, ": ", status.explanation()); | |
| } | |
| status.set_explanation(std::move(explanation)); | |
| return status; | |
| } | |
| } // namespace | |
| void PropagateFailuresFromIngredientAssertion( | |
| const IngredientAssertionV3& ingredient_assertion, | |
| ValidationStatusSet& validation, | |
| absl::flat_hash_set<std::pair<absl::string_view, absl::string_view>>& | |
| existing_failures) { | |
| const auto& failures = | |
| ingredient_assertion.validation_results().active_manifest().failures(); | |
| if (failures.empty()) { | |
| return; | |
| } | |
| for (const auto& failure : failures) { | |
| if (validation.failures_size() >= 10000) { | |
| break; | |
| } | |
| if (existing_failures.insert(std::make_pair(failure.code(), failure.url())) | |
| .second) { | |
| *validation.add_failures() = FromOriginalValidator(failure); | |
| } | |
| } | |
| } | |
| } // namespace credentio |