From 16cf8d7fbf0c5bced3738d3e0521dc983395f355 Mon Sep 17 00:00:00 2001 From: Rick Mouritzen Date: Fri, 11 Oct 2024 16:00:53 -0700 Subject: [PATCH 1/2] Support source and references metadata attributes --- Dockerfile | 2 +- lib/schema/cache.ex | 3 ++ lib/schema_web/templates/page/class.html.eex | 7 +++ lib/schema_web/templates/page/object.html.eex | 8 ++++ lib/schema_web/views/page_view.ex | 44 ++++++++++++++++++- mix.lock | 4 +- test/test_ocsf_schema/dictionary.json | 34 +++++++++++--- test/test_ocsf_schema/events/alpha.json | 15 ++++++- test/test_ocsf_schema/events/beta.json | 4 ++ .../extensions/rpg/events/alpha_(patch).json | 6 +++ test/test_ocsf_schema/objects/device.json | 14 +++++- test/test_ocsf_schema/profiles/host.json | 8 +++- 12 files changed, 137 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e707c4..c430357 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG elixir_image=elixir:1.17.2-alpine +ARG elixir_image=elixir:1.17.3-alpine FROM ${elixir_image} AS builder diff --git a/lib/schema/cache.ex b/lib/schema/cache.ex index 52a10c2..0e939fb 100644 --- a/lib/schema/cache.ex +++ b/lib/schema/cache.ex @@ -1013,6 +1013,7 @@ defmodule Schema.Cache do # Top-level path-based observables. # Only occurs in classes, but is safe to do for objects too. |> Utils.put_non_nil(:observables, item[:observables]) + |> Utils.put_non_nil(:references, item[:references]) |> patch_constraints(item) Map.put(acc, base_key, patched_base) @@ -1366,6 +1367,8 @@ defmodule Schema.Cache do |> copy_new(from, :object_name) |> copy_new(from, :object_type) |> copy_new(from, :observable) + |> copy_new(from, :source) + |> copy_new(from, :references) end defp copy_new(to, from, key) do diff --git a/lib/schema_web/templates/page/class.html.eex b/lib/schema_web/templates/page/class.html.eex index 96d6aa8..77d4aab 100644 --- a/lib/schema_web/templates/page/class.html.eex +++ b/lib/schema_web/templates/page/class.html.eex @@ -19,6 +19,7 @@ limitations under the License. <% category_name = @data[:category_name] %> <% extension = @data[:extension] %> <% observables = @data[:observables] %> +<% references = @data[:references] %>
@@ -45,6 +46,12 @@ limitations under the License. <%= if observables != nil and !Enum.empty?(observables) do %>Class-specific attribute path observables are at the bottom of this page.<% end %>
+ <%= if references != nil and !Enum.empty?(references) do %> +
+
References + <%= raw Enum.map(references, fn ref -> ["
", reference_anchor(ref)] end) %> +
+ <% end %>