]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sarif-replay: fix missing URLs [PR117944]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 10 Dec 2024 23:31:24 +0000 (18:31 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 10 Dec 2024 23:37:57 +0000 (18:37 -0500)
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 <dmalcolm@redhat.com>
gcc/libsarifreplay.cc

index 9a053f7fe6125133010ac0f888362f957724db5b..e8b5a55b9188242236955a7382825b736c68c21c 100644 (file)
@@ -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<json::string>(*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)