Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily disabling graph endpoints #92

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 44 additions & 41 deletions lib/schema_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,57 @@

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

Check warning on line 28 in lib/schema_web/controllers/page_controller.ex

View workflow job for this annotation

GitHub Actions / Build and test

variable "id" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 28 in lib/schema_web/controllers/page_controller.ex

View workflow job for this annotation

GitHub Actions / Build and test

variable "params" is unused (if the variable is not meant to be used, prefix it with an underscore)
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

Check warning on line 50 in lib/schema_web/controllers/page_controller.ex

View workflow job for this annotation

GitHub Actions / Build and test

variable "id" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 50 in lib/schema_web/controllers/page_controller.ex

View workflow job for this annotation

GitHub Actions / Build and test

variable "params" is unused (if the variable is not meant to be used, prefix it with an underscore)
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 """
Expand Down
7 changes: 5 additions & 2 deletions lib/schema_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -132,7 +133,9 @@ 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"
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading