diff --git a/assets/src/generated/graphql-kubernetes.ts b/assets/src/generated/graphql-kubernetes.ts index d1042cfb91..d29b0e2876 100644 --- a/assets/src/generated/graphql-kubernetes.ts +++ b/assets/src/generated/graphql-kubernetes.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/assets/src/generated/graphql-plural.ts b/assets/src/generated/graphql-plural.ts index 694f1a631a..2a8b931afc 100644 --- a/assets/src/generated/graphql-plural.ts +++ b/assets/src/generated/graphql-plural.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/assets/src/generated/graphql.ts b/assets/src/generated/graphql.ts index da7b6b1f91..7359a8975d 100644 --- a/assets/src/generated/graphql.ts +++ b/assets/src/generated/graphql.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/lib/console/utils/vuln.ex b/lib/console/utils/vuln.ex new file mode 100644 index 0000000000..241f78613d --- /dev/null +++ b/lib/console/utils/vuln.ex @@ -0,0 +1,37 @@ +defmodule Console.Utils.Vuln do + def grade("LOW"), do: :low + def grade("MEDIUM"), do: :medium + def grade("HIGH"), do: :high + def grade("CRITICAL"), do: :critical + def grade("L"), do: :low + def grade("M"), do: :medium + def grade("H"), do: :high + def grade(_), do: :none + + def vector("N"), do: :network + def vector("A"), do: :adjacent + def vector("L"), do: :local + def vector("P"), do: :physical + + def requirement("N"), do: :none + def requirement("R"), do: :required + + def parse_v3_vector("CVSS:" <> rest) do + [_ | parts] = String.split(rest, "/") + Enum.map(parts, fn part -> + case String.split(part, ":") do + ["AV", v] -> {:attack_vector, vector(v)} + ["AC", c] -> {:attack_complexity, grade(c)} + ["PR", p] -> {:privileges_required, grade(p)} + ["UI", ui] -> {:user_interaction, requirement(ui)} + ["C", c] -> {:confidentiality, grade(c)} + ["I", i] -> {:integrity, grade(i)} + ["A", a] -> {:availability, grade(a)} + _ -> nil + end + end) + |> Enum.filter(& &1) + |> Enum.into(%{}) + end + def parse_v3_vector(_), do: %{} +end