| skipped 1 lines |
2 | 2 | | |
3 | 3 | | import ( |
4 | 4 | | "fmt" |
5 | | - | "github.com/zan8in/afrog/pkg/utils" |
6 | 5 | | "os" |
| 6 | + | "sync" |
7 | 7 | | |
8 | 8 | | "github.com/urfave/cli/v2" |
9 | 9 | | "github.com/zan8in/afrog/internal/runner" |
| skipped 3 lines |
13 | 13 | | "github.com/zan8in/afrog/pkg/log" |
14 | 14 | | "github.com/zan8in/afrog/pkg/poc" |
15 | 15 | | "github.com/zan8in/afrog/pkg/upgrade" |
| 16 | + | "github.com/zan8in/afrog/pkg/utils" |
16 | 17 | | ) |
17 | 18 | | |
18 | 19 | | var options = &config.Options{} |
19 | 20 | | var htemplate = &html.HtmlTemplate{} |
| 21 | + | var lock sync.Mutex |
| 22 | + | var number = 0 |
20 | 23 | | |
21 | 24 | | func main() { |
22 | 25 | | app := cli.NewApp() |
| skipped 14 lines |
37 | 40 | | upgrade := upgrade.New() |
38 | 41 | | upgrade.UpgradeAfrogPocs() |
39 | 42 | | |
40 | | - | showBanner(upgrade.LastestAfrogVersion) |
| 43 | + | runner.ShowBanner2(upgrade.LastestAfrogVersion) |
41 | 44 | | |
42 | 45 | | fmt.Println("PATH:") |
43 | 46 | | fmt.Println(" " + options.Config.GetConfigPath()) |
| skipped 7 lines |
51 | 54 | | err := runner.New(options, func(result interface{}) { |
52 | 55 | | r := result.(*core.Result) |
53 | 56 | | |
54 | | - | options.OptLock.Lock() |
55 | | - | defer options.OptLock.Unlock() |
| 57 | + | lock.Lock() |
| 58 | + | defer lock.Unlock() |
56 | 59 | | |
57 | 60 | | if !options.Silent { |
58 | 61 | | options.CurrentCount++ |
59 | 62 | | } |
60 | 63 | | |
61 | 64 | | if r.IsVul { |
62 | | - | r.PrintColorResultInfoConsole() |
| 65 | + | number++ |
63 | 66 | | |
64 | 67 | | if len(r.Output) > 0 { |
65 | 68 | | htemplate.Result = r |
| 69 | + | htemplate.Number = utils.GetNumberText(number) |
66 | 70 | | htemplate.Append() |
67 | 71 | | } |
| 72 | + | |
| 73 | + | r.PrintColorResultInfoConsole(utils.GetNumberText(number)) |
68 | 74 | | } |
69 | 75 | | |
70 | 76 | | if !options.Silent { |
71 | 77 | | fmt.Printf("\r%d/%d | %d%% ", options.CurrentCount, options.Count, options.CurrentCount*100/options.Count) |
72 | 78 | | } |
| 79 | + | |
73 | 80 | | }) |
74 | 81 | | if err != nil { |
75 | 82 | | return err |
| skipped 9 lines |
85 | 92 | | } |
86 | 93 | | } |
87 | 94 | | |
88 | | - | func showBanner(afrogLatestversion string) { |
89 | | - | title := "NAME:\n " + log.LogColor.Banner(runner.ShowBanner()) + " - v" + config.Version |
90 | | - | old := "" |
91 | | - | if utils.Compare(afrogLatestversion, ">", config.Version) { |
92 | | - | old = log.LogColor.High(" (outdated)") |
93 | | - | old += log.LogColor.Title(" --> https://github.com/zan8in/afrog/releases/tag/v" + afrogLatestversion) |
94 | | - | } |
95 | | - | fmt.Println(title + old + "\n") |
96 | | - | } |
97 | | - | |