From f102b82d3da6dd4d5f9af1cd622fce93d0c494eb Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 10 Dec 2024 18:31:24 -0500 Subject: [PATCH] sarif-replay: fix missing URLs [PR117944] gcc/ChangeLog: PR other/117944 * libsarifreplay.cc (sarif_replayer::handle_result_obj): Get any helpUri from the rule_obj and pass it to add_rule. Signed-off-by: David Malcolm --- gcc/libsarifreplay.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/libsarifreplay.cc b/gcc/libsarifreplay.cc index 9a053f7fe61..e8b5a55b918 100644 --- a/gcc/libsarifreplay.cc +++ b/gcc/libsarifreplay.cc @@ -1004,7 +1004,20 @@ sarif_replayer::handle_result_obj (const json::object &result_obj, libgdiagnostics::group g (m_output_mgr); auto err (m_output_mgr.begin_diagnostic (level)); if (rule_id) - err.add_rule (rule_id->get_string (), nullptr); + { + const char *url = nullptr; + if (rule_obj) + { + /* rule_obj should be a reportingDescriptor object (3.49). + Get any ยง3.49.12 helpUri property. */ + const property_spec_ref prop_help_uri + ("reportingDescriptor", "helpUri", "3.49.12"); + if (auto url_val = get_optional_property(*rule_obj, + prop_help_uri)) + url = url_val->get_string (); + } + err.add_rule (rule_id->get_string (), url); + } err.set_location (physical_loc); err.set_logical_location (logical_loc); if (path.m_inner)