class
Analyzer::Elixir::Plug
- Analyzer::Elixir::Plug
- Analyzer::Elixir::ElixirEngine
- Analyzer
- Reference
- Object
Direct Known Subclasses
Defined in:
analyzer/analyzers/elixir/elixir_plug.crConstant Summary
-
PLUG_ROUTE_MACROS =
{"get" => "GET", "post" => "POST", "put" => "PUT", "patch" => "PATCH", "delete" => "DELETE", "head" => "HEAD", "options" => "OPTIONS", "forward" => "FORWARD"} -
The route macro must start a fresh token. Without the
(?:^|[^.\w])guard the bare verb matched as a substring of any identifier —@temp_slot_options "TEMPORARY …"read as anoptionsroute,Repo.delete "x"as adeleteroute — flooding non-router modules with junk endpoints. The captured path is also required to start with/, because the Plug.Router DSL only ever registers absolute paths; that single constraint drops the remainingget "true"-style false positives. -
PLUG_ROUTE_PATTERNS =
PLUG_ROUTE_MACROS.keys.to_h do |verb| {verb, Regex.new("(?:^|[^.\\w])#{verb}\\s+[\"']([^\"']+)[\"']")} end -
Precompiled per-verb route regexes.
#line_to_endpointruns once per line of every.exfile, andRegex.newrebuilt these 8 PCRE2 patterns on every call — the same recompilation cost the Phoenix analyzer carried. Build them once.
Instance Method Summary
- #analyze_content(content : String, file_path : String) : Array(Endpoint)
- #analyze_file(path : String) : Array(Endpoint)
- #extract_params_from_block(lines : Array(String), start_index : Int32, method : String, block_end : Int32 | Nil = nil) : Array(Param)
- #find_block_end(lines : Array(String), start_index : Int32) : Int32
- #line_to_endpoint(line : String) : Array(Endpoint)