Skip to content

Commit

Permalink
update the is_plug? fuction to be plug?
Browse files Browse the repository at this point in the history
  • Loading branch information
iarekk committed Feb 12, 2024
1 parent 79b23ca commit 6d8c44d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/sobelow/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ defmodule Sobelow.Config do

def vuln_pipeline?({:pipeline, _, [_name, [do: block]]}, :csrf) do
plugs = get_plug_list(block)
has_csrf? = Enum.any?(plugs, &is_plug?(&1, :protect_from_forgery))
has_session? = Enum.any?(plugs, &is_plug?(&1, :fetch_session))
has_csrf? = Enum.any?(plugs, &plug?(&1, :protect_from_forgery))
has_session? = Enum.any?(plugs, &plug?(&1, :fetch_session))

has_session? and not has_csrf?
end

def vuln_pipeline?({:pipeline, _, [_name, [do: block]]}, :headers) do
plugs = get_plug_list(block)
has_headers? = Enum.any?(plugs, &is_plug?(&1, :put_secure_browser_headers))
has_headers? = Enum.any?(plugs, &plug?(&1, :put_secure_browser_headers))
accepts = Enum.find_value(plugs, &get_plug_accepts/1)

!has_headers? && is_list(accepts) && Enum.member?(accepts, "html")
Expand All @@ -142,9 +142,9 @@ defmodule Sobelow.Config do

def parse_accepts([{:<<>>, _, [accepts | _]}, []]), do: String.split(accepts, " ")

def is_plug?({:plug, _, [type]}, type), do: true
def is_plug?({:plug, _, [type, _]}, type), do: true
def is_plug?(_, _), do: false
def plug?({:plug, _, [type]}, type), do: true
def plug?({:plug, _, [type, _]}, type), do: true
def plug?(_, _), do: false

def get_fuzzy_configs(key, filepath) do
ast = Parse.ast(filepath)
Expand Down

0 comments on commit 6d8c44d

Please sign in to comment.