Current section

Files

Jump to
go_over src go_over@sources.erl
Raw

src/go_over@sources.erl

-module(go_over@sources).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/go_over/sources.gleam").
-export([get_vulnerable_warnings/3, get_retired_warnings/2, get_hex_warnings/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/go_over/sources.gleam", 13).
?DOC(false).
-spec get_vulnerable_warnings(
list(go_over@packages:package()),
go_over@config:config(),
list(go_over@advisories@advisories:advisory())
) -> list(go_over@warning:warning()).
get_vulnerable_warnings(Pkgs, Conf, All_advisories) ->
_pipe = go_over@advisories@advisories:check_for_advisories(
Pkgs,
All_advisories
),
_pipe@1 = gleam@list:map(
_pipe,
fun(P) ->
gxyz@tuple:map2_1(
P,
fun(_capture) ->
go_over@config:filter_advisory_ids(Conf, _capture)
end
)
end
),
_pipe@2 = gxyz@list:reject_tap(
_pipe@1,
fun gleam@pair:second/1,
fun gleam@list:is_empty/1
),
gleam@list:flat_map(
_pipe@2,
fun(_capture@1) ->
gxyz@tuple:apply_from2(
_capture@1,
fun go_over@warning:adv_to_warning/2
)
end
).
-file("src/go_over/sources.gleam", 24).
?DOC(false).
-spec get_retired_warnings(
list(go_over@packages:package()),
go_over@config:config()
) -> list(go_over@warning:warning()).
get_retired_warnings(Pkgs, Conf) ->
_pipe = Pkgs,
_pipe@2 = gleam@list:map(
_pipe,
fun(Pkg) ->
_pipe@1 = go_over@hex@retired:check_retired(
erlang:element(9, Conf),
Pkg
),
gleam@option:map(
_pipe@1,
fun(_capture) -> gleam@pair:new(Pkg, _capture) end
)
end
),
_pipe@3 = gleam@option:values(_pipe@2),
gleam@list:map(
_pipe@3,
fun(_capture@1) ->
gxyz@tuple:apply_from2(
_capture@1,
fun go_over@warning:retired_to_warning/2
)
end
).
-file("src/go_over/sources.gleam", 37).
?DOC(false).
-spec get_hex_warnings(
list(go_over@packages:package()),
go_over@config:config()
) -> {list(go_over@warning:warning()), list(binary())}.
get_hex_warnings(Pkgs, Conf) ->
Allowed_licenses = erlang:element(10, Conf),
gleam@list:fold(
Pkgs,
{[], []},
fun(Acc, Pkg) ->
{Warnings, Licenses} = Acc,
Pkg_licenses = go_over@hex@hex:fetch_licenses(
erlang:element(9, Conf),
Pkg
),
Pkg_warnings = begin
_pipe = go_over@hex@hex:rejected_license_sources(
Pkg_licenses,
Allowed_licenses
),
gleam@list:map(_pipe, fun(Source) -> case Source of
{rejected_license, Name} ->
go_over@warning:rejected_license_to_warning(
Pkg,
Name
)
end end)
end,
{lists:append(Warnings, Pkg_warnings),
lists:append(Licenses, Pkg_licenses)}
end
).