MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / main

Function main

main.go:39–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37 |_|`
38
39func main() {
40
41 fmt.Println(logo)
42 fmt.Println("Current version:", version)
43
44 // 处理参数
45 args()
46
47 // 初始化HttpClient
48 initHttpClient()
49
50 // 检测参数
51 arg := &opensca.TaskArg{DataOrigin: config.Conf().Path}
52
53 // 是否跳过压缩包检测
54 if config.Conf().Optional.DirOnly {
55 arg.ExtractFileFilter = func(relpath string) bool { return false }
56 }
57 arg.IgnoreFileFilter = filter.IgnorePatterns(config.Conf().Optional.Ignore)
58
59 // 开启进度条
60 var stopProgress func()
61 if config.Conf().Optional.ProgressBar {
62 stopProgress = startProgressBar(arg)
63 }
64
65 // 运行检测任务
66 result := opensca.RunTask(context.Background(), arg)
67
68 // 日志中记录检测结果
69 if result.Error != nil {
70 logs.Error(result.Error)
71 }
72 for _, dep := range result.Deps {
73 if dep.Name != "" || len(dep.Children) > 0 {
74 logs.Debugf("dependency tree:\n%s", dep.Tree(false, false))
75 }
76 }
77
78 // 生成报告
79 report := taskReport(result)
80
81 // 导出报告
82 format.Save(report, config.Conf().Output)
83
84 // 等待进度条完成
85 if config.Conf().Optional.ProgressBar {
86 <-time.After(time.Millisecond * 200)
87 if stopProgress != nil {
88 stopProgress()
89 }
90 }
91
92 // 打印概览信息
93 dep, vul := format.Statis(report)
94 fmt.Println("\nComplete!\n" + dep + vul)
95 logs.Info("\nComplete!\n" + dep + vul)
96

Callers

nothing calls this directly

Calls 15

ConfFunction · 0.92
IgnorePatternsFunction · 0.92
RunTaskFunction · 0.92
ErrorFunction · 0.92
DebugfFunction · 0.92
SaveFunction · 0.92
StatisFunction · 0.92
InfoFunction · 0.92
SaasFunction · 0.92
WarnfFunction · 0.92
OpenUIFunction · 0.92
argsFunction · 0.85

Tested by

no test coverage detected