From 57cfc413e19541f10a67cd055e01206f6473a07e Mon Sep 17 00:00:00 2001 From: Rick Mouritzen Date: Thu, 23 May 2024 13:44:42 -0700 Subject: [PATCH 1/2] Temporarily disabling graph endpoints due to bug that pegs a CPU. This in turn can cause the burstable T3 EC2 instance that the OCSF server runs on to be pulled offline. --- lib/schema_web/controllers/page_controller.ex | 85 ++++++++++--------- lib/schema_web/router.ex | 6 +- mix.exs | 2 +- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/lib/schema_web/controllers/page_controller.ex b/lib/schema_web/controllers/page_controller.ex index eb373c6..566ec98 100644 --- a/lib/schema_web/controllers/page_controller.ex +++ b/lib/schema_web/controllers/page_controller.ex @@ -15,54 +15,57 @@ defmodule SchemaWeb.PageController do alias SchemaWeb.SchemaController - @spec guidelines(Plug.Conn.t(), any) :: Plug.Conn.t() - def guidelines(conn, params) do - render(conn, "guidelines.html", - extensions: Schema.extensions(), - profiles: SchemaController.get_profiles(params) - ) - end + # TODO: guidelines.html is missing (route is also commented out) + # @spec guidelines(Plug.Conn.t(), any) :: Plug.Conn.t() + # def guidelines(conn, params) do + # render(conn, "guidelines.html", + # extensions: Schema.extensions(), + # profiles: SchemaController.get_profiles(params) + # ) + # end @spec class_graph(Plug.Conn.t(), any) :: Plug.Conn.t() def class_graph(conn, %{"id" => id} = params) do - try do - case SchemaWeb.SchemaController.class_ex(id, params) do - nil -> - send_resp(conn, 404, "Not Found: #{id}") - - class -> - data = Schema.Graph.build(class) - - render(conn, "class_graph.html", - extensions: Schema.extensions(), - profiles: SchemaController.get_profiles(params), - data: data - ) - end - rescue - e -> send_resp(conn, 400, "Bad Request: #{inspect(e)}") - end + # try do + # case SchemaWeb.SchemaController.class_ex(id, params) do + # nil -> + # send_resp(conn, 404, "Not Found: #{id}") + + # class -> + # data = Schema.Graph.build(class) + + # render(conn, "class_graph.html", + # extensions: Schema.extensions(), + # profiles: SchemaController.get_profiles(params), + # data: data + # ) + # end + # rescue + # e -> send_resp(conn, 400, "Bad Request: #{inspect(e)}") + # end + send_resp(conn, 501, "The graph feature is temporarily disabled and will return soon.") end @spec object_graph(Plug.Conn.t(), any) :: Plug.Conn.t() def object_graph(conn, %{"id" => id} = params) do - try do - case SchemaWeb.SchemaController.object_ex(id, params) do - nil -> - send_resp(conn, 404, "Not Found: #{id}") - - obj -> - data = Schema.Graph.build(obj) - - render(conn, "object_graph.html", - extensions: Schema.extensions(), - profiles: SchemaController.get_profiles(params), - data: data - ) - end - rescue - e -> send_resp(conn, 400, "Bad Request: #{inspect(e)}") - end + # try do + # case SchemaWeb.SchemaController.object_ex(id, params) do + # nil -> + # send_resp(conn, 404, "Not Found: #{id}") + + # obj -> + # data = Schema.Graph.build(obj) + + # render(conn, "object_graph.html", + # extensions: Schema.extensions(), + # profiles: SchemaController.get_profiles(params), + # data: data + # ) + # end + # rescue + # e -> send_resp(conn, 400, "Bad Request: #{inspect(e)}") + # end + send_resp(conn, 501, "The graph feature is temporarily disabled and will return soon.") end @doc """ diff --git a/lib/schema_web/router.ex b/lib/schema_web/router.ex index b72f2d7..6e6fd9b 100644 --- a/lib/schema_web/router.ex +++ b/lib/schema_web/router.ex @@ -53,7 +53,8 @@ defmodule SchemaWeb.Router do get "/object/graph/:extension/:id", PageController, :object_graph get "/data_types", PageController, :data_types - get "/guidelines", PageController, :guidelines + # TODO: guidelines.html is missing (also commented out in PageController) + # get "/guidelines", PageController, :guidelines end # Other scopes may use custom stacks. @@ -132,7 +133,8 @@ defmodule SchemaWeb.Router do %{ info: %{ title: "The OCSF Schema API", - description: "The Open Cybersecurity Schema Framework (OCSF) server API allows to access the JSON schema definitions and to validate and translate events.", + description: + "The Open Cybersecurity Schema Framework (OCSF) server API allows to access the JSON schema definitions and to validate and translate events.", license: %{ name: "Apache 2.0", url: "http://www.apache.org/licenses/LICENSE-2.0.html" diff --git a/mix.exs b/mix.exs index cdd5e65..7a5fab0 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ defmodule Schema.MixProject do use Mix.Project - @version "2.70.2" + @version "2.70.3" def project do build = System.get_env("GITHUB_RUN_NUMBER") || "SNAPSHOT" From 231da16c14667dd3d93d9993fcef402cc9437aba Mon Sep 17 00:00:00 2001 From: Rick Mouritzen Date: Thu, 23 May 2024 13:47:06 -0700 Subject: [PATCH 2/2] Minor formatting fix --- lib/schema_web/router.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/schema_web/router.ex b/lib/schema_web/router.ex index 6e6fd9b..c5681f7 100644 --- a/lib/schema_web/router.ex +++ b/lib/schema_web/router.ex @@ -134,7 +134,8 @@ defmodule SchemaWeb.Router do info: %{ title: "The OCSF Schema API", description: - "The Open Cybersecurity Schema Framework (OCSF) server API allows to access the JSON schema definitions and to validate and translate events.", + "The Open Cybersecurity Schema Framework (OCSF) server API allows to access the JSON" <> + " schema definitions and to validate and translate events.", license: %{ name: "Apache 2.0", url: "http://www.apache.org/licenses/LICENSE-2.0.html"