-
Notifications
You must be signed in to change notification settings - Fork 3
/
scan.ex
46 lines (39 loc) · 1.26 KB
/
scan.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (C) 2020 by the Georgia Tech Research Institute (GTRI)
# This software may be modified and distributed under the terms of
# the BSD 3-Clause license. See the LICENSE file for details.
defmodule Mix.Tasks.Lei.Scan do
use Mix.Task
@shortdoc "Run LowEndInsight scan against a local project"
@moduledoc ~S"""
This is used to run a LowEndInsight scanner against a project.
#Usage
```
mix lei.scan
```
This will return a basic list of reports in JSON format. LowEndInsight
will scan the `mix.exs` file for the list of dependencies, enumerating
through them and fetching the source repo URL from the Hex.pm API. Then
the scanner passes that URL to LowEndInsight which does a temporary clone
to perform its analysis of each dependency.
"""
def run(args) do
Mix.Task.run("app.start")
cond do
length(args) == 0 ->
ScannerModule.scan(".")
|> Mix.shell().info()
length(args) == 1 ->
dir = List.first(args)
case File.exists?(dir) do
false ->
"Invalid path"
|> Mix.shell().info()
true ->
{:ok, repo} = GitModule.get_repo(dir)
repo.path
|> ScannerModule.scan()
|> Mix.shell().info()
end
end
end
end