Packages

A tool to audit Erlang & Elixir dependencies, to make sure your Gleam ✨ projects really sparkle!

Retired package: Security issue - Vulnerability warnings were never emitted due to an inverted advisory filter. Upgrade to 3.3.1 or 4.0.0-rc2+.

Current section

Files

Jump to
go_over src go_over.erl
Raw

src/go_over.erl

-module(go_over).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-export_type([flags/0]).
-type flags() :: {flags,
boolean(),
boolean(),
boolean(),
boolean(),
gleam@option:option(go_over@config:format())}.
-file("/home/bwireman/src/go-over/src/go_over.gleam", 34).
-spec merge_flags_and_config(flags(), go_over@config:config()) -> go_over@config:config().
merge_flags_and_config(Flags, Cfg) ->
{config,
erlang:element(2, Cfg),
erlang:element(3, Cfg),
erlang:element(4, Cfg) orelse erlang:element(4, Flags),
erlang:element(5, Cfg) orelse erlang:element(5, Flags),
erlang:element(2, Flags),
erlang:element(3, Flags),
gleam@option:unwrap(erlang:element(6, Flags), erlang:element(8, Cfg)),
erlang:element(9, Cfg),
erlang:element(10, Cfg),
erlang:element(11, Cfg),
erlang:element(12, Cfg)}.
-file("/home/bwireman/src/go-over/src/go_over.gleam", 50).
-spec spin_up(go_over@config:config()) -> go_over@config:config().
spin_up(Cfg) ->
Args = shellout_ffi:start_arguments(),
Format = begin
_pipe = gleam@list:find(
Args,
fun(_capture) ->
gleam@string:starts_with(_capture, <<"--format"/utf8>>)
end
),
_pipe@1 = gleam@result:'try'(
_pipe,
fun(_capture@1) ->
gleam@string:split_once(_capture@1, <<"="/utf8>>)
end
),
_pipe@2 = gleam@result:map(_pipe@1, fun gxyz@gxyz_tuple:at2_1/1),
_pipe@3 = gleam@result:map(
_pipe@2,
fun go_over@config:parse_config_format/1
),
gleam@option:from_result(_pipe@3)
end,
Flags = {flags,
go_over@util@util:has_flag(Args, <<"force"/utf8>>),
go_over@util@util:has_flag(Args, <<"fake"/utf8>>),
go_over@util@util:has_flag(Args, <<"outdated"/utf8>>),
go_over@util@util:has_flag(Args, <<"ignore-indirect"/utf8>>),
Format},
merge_flags_and_config(Flags, Cfg).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 72).
-spec get_vulnerable_packages(
list(go_over@packages:package()),
go_over@config:config()
) -> list(go_over@warning:warning()).
get_vulnerable_packages(Pkgs, Conf) ->
_pipe = go_over@advisories@advisories:check_for_advisories(
Pkgs,
erlang:element(6, Conf) orelse not erlang:element(3, Conf)
),
_pipe@1 = gleam@list:map(
_pipe,
fun(P) ->
gxyz@gxyz_tuple:map2_1(
P,
fun(_capture) ->
go_over@config:filter_advisory_ids(Conf, _capture)
end
)
end
),
_pipe@2 = gleam@list:filter(
_pipe@1,
fun(P@1) -> gxyz@gxyz_tuple:at2_1(P@1) =:= [] end
),
gleam@list:flat_map(
_pipe@2,
fun(_capture@1) ->
gxyz@gxyz_tuple:apply_from2(
_capture@1,
fun go_over@warning:adv_to_warning/2
)
end
).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 81).
-spec get_retired_packages(
list(go_over@packages:package()),
go_over@config:config()
) -> list(go_over@warning:warning()).
get_retired_packages(Pkgs, Conf) ->
_pipe = Pkgs,
_pipe@2 = gleam@list:map(
_pipe,
fun(Pkg) ->
_pipe@1 = go_over@retired@retired:check_retired(
Pkg,
erlang:element(6, Conf) orelse not erlang:element(3, Conf)
),
gleam@option:map(_pipe@1, fun(Ret) -> {Pkg, Ret} end)
end
),
_pipe@3 = gleam@option:values(_pipe@2),
gleam@list:map(
_pipe@3,
fun(_capture) ->
gxyz@gxyz_tuple:apply_from2(
_capture,
fun go_over@warning:retired_to_warning/2
)
end
).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 91).
-spec get_outdated_packages(
list(go_over@packages:package()),
go_over@config:config()
) -> list(go_over@warning:warning()).
get_outdated_packages(Pkgs, Conf) ->
_pipe = Pkgs,
_pipe@1 = gleam@list:map(
_pipe,
fun(Pkg) ->
case go_over@retired@outdated:check_outdated(
Pkg,
erlang:element(6, Conf) orelse not erlang:element(3, Conf)
) of
{some, Ret} ->
{some, {Pkg, Ret}};
none ->
none
end
end
),
_pipe@2 = gleam@option:values(_pipe@1),
gleam@list:map(
_pipe@2,
fun(_capture) ->
gxyz@gxyz_tuple:apply_from2(
_capture,
fun go_over@warning:outdated_to_warning/2
)
end
).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 103).
-spec print_warnings_count(list(go_over@warning:warning())) -> nil.
print_warnings_count(Vulns) ->
_pipe = (<<<<<<"⛔ "/utf8,
(gleam@int:to_string(erlang:length(Vulns)))/binary>>/binary,
" WARNING(s) FOUND!"/utf8>>/binary,
(<<"\n-----------------------------------------------\n"/utf8>>)/binary>>),
gleam@io:print_error(_pipe).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 113).
-spec print_warnings(list(go_over@warning:warning()), go_over@config:config()) -> nil.
print_warnings(Vulns, Conf) ->
case erlang:element(8, Conf) of
minimal ->
print_warnings_count(Vulns),
_pipe = Vulns,
_pipe@1 = gleam@list:map(
_pipe,
fun go_over@warning:format_as_string_minimal/1
),
_pipe@2 = gleam@string:join(_pipe@1, <<""/utf8>>),
gleam@io:print_error(_pipe@2);
json ->
_pipe@3 = Vulns,
_pipe@4 = gleam@list:map(
_pipe@3,
fun go_over@warning:format_as_json/1
),
_pipe@5 = gleam@json:preprocessed_array(_pipe@4),
_pipe@6 = gleam@json:to_string(_pipe@5),
gleam@io:print_error(_pipe@6);
_ ->
print_warnings_count(Vulns),
_pipe@7 = Vulns,
_pipe@8 = gleam@list:map(
_pipe@7,
fun go_over@warning:format_as_string/1
),
_pipe@9 = gleam@string:join(
_pipe@8,
<<"\n-----------------------------------------------\n"/utf8>>
),
gleam@io:print_error(_pipe@9)
end,
shellout_ffi:os_exit(1).
-file("/home/bwireman/src/go-over/src/go_over.gleam", 143).
-spec main() -> nil.
main() ->
Conf = spin_up(go_over@config:read_config(<<"./gleam.toml"/utf8>>)),
gxyz@gxyz_function:ignore_result(
not erlang:element(3, Conf),
gxyz@gxyz_function:freeze1(
fun simplifile_erl:delete/1,
go_over@util@constants:go_over_path()
)
),
Pkgs = begin
_pipe = go_over@packages:read_manifest(<<"./manifest.toml"/utf8>>),
_pipe@1 = go_over@config:filter_dev_dependencies(Conf, _pipe),
_pipe@2 = go_over@config:filter_packages(Conf, _pipe@1),
go_over@config:filter_indirect(Conf, _pipe@2)
end,
Vulnerable_packages = get_vulnerable_packages(Pkgs, Conf),
Retired_packages = get_retired_packages(Pkgs, Conf),
Outdated_packages = gxyz@gxyz_function:iff(
erlang:element(4, Conf),
gxyz@gxyz_function:freeze2(fun get_outdated_packages/2, Pkgs, Conf),
[]
),
gxyz@gxyz_function:iff_nil(
erlang:element(7, Conf),
gxyz@gxyz_function:freeze2(
fun print_warnings/2,
[{warning,
none,
<<"fake"/utf8>>,
<<"x.y.z"/utf8>>,
<<"Retired"/utf8>>,
vulnerable,
<<"Critical"/utf8>>,
direct},
{warning,
none,
<<"another_fake"/utf8>>,
<<"1.2.3"/utf8>>,
<<"Vulnerable"/utf8>>,
vulnerable,
<<"High"/utf8>>,
direct},
{warning,
none,
<<"and_another"/utf8>>,
<<"4.5.6"/utf8>>,
<<"Vulnerable"/utf8>>,
vulnerable,
<<"Moderate"/utf8>>,
direct},
{warning,
none,
<<"one_more"/utf8>>,
<<"7.8.9"/utf8>>,
<<"Vulnerable"/utf8>>,
vulnerable,
<<"LOW"/utf8>>,
indirect},
{warning,
none,
<<"this_one_was_retired"/utf8>>,
<<"10.11.12"/utf8>>,
<<"Retired"/utf8>>,
retired,
<<"Package Retired"/utf8>>,
indirect}],
Conf
)
),
Warnings = begin
_pipe@3 = lists:append(Retired_packages, Vulnerable_packages),
_pipe@4 = lists:append(_pipe@3, Outdated_packages),
go_over@config:filter_severity(Conf, _pipe@4)
end,
case Warnings of
[] ->
go_over@util@print:success(<<"All good! ✅"/utf8>>);
Vulns ->
print_warnings(Vulns, Conf)
end.