refactor: don't use global Config in private func (#1197)
* refactor: cve_client.go * refactor: don't use global Config in private func * remove import alias for config * refactor: dbclient * refactor: resultDir * refactor: resultsDir * refactor * refactor: gost * refactor: db client * refactor: cveDB * refactor: cvedb * refactor: exploitDB * refactor: remove detector/dbclient.go * refactor: writer * refactor: syslog writer * refactor: ips * refactor: ensureResultDir * refactor: proxy * fix(db): call CloseDB * add integration test * feat(report): sort array in json * sort func for json diff * add build-int to makefile * add int-rds-redis to makefile * fix: test case, makefile * fix makefile * show cve count after diff * make diff * diff -c * sort exploits in json for diff * sort metasploit, exploit
This commit is contained in:
23
util/util.go
23
util/util.go
@@ -110,8 +110,16 @@ func IP() (ipv4Addrs []string, ipv6Addrs []string, err error) {
|
||||
return ipv4Addrs, ipv6Addrs, nil
|
||||
}
|
||||
|
||||
// ProxyEnv returns shell environment variables to set proxy
|
||||
func ProxyEnv() string {
|
||||
// PrependProxyEnv prepends proxy environment variable
|
||||
func PrependProxyEnv(cmd string) string {
|
||||
if config.Conf.HTTPProxy == "" {
|
||||
return cmd
|
||||
}
|
||||
return fmt.Sprintf("%s %s", proxyEnv(), cmd)
|
||||
}
|
||||
|
||||
// proxyEnv returns shell environment variables to set proxy
|
||||
func proxyEnv() string {
|
||||
httpProxyEnv := ""
|
||||
keys := []string{
|
||||
"http_proxy",
|
||||
@@ -120,20 +128,11 @@ func ProxyEnv() string {
|
||||
"HTTPS_PROXY",
|
||||
}
|
||||
for _, key := range keys {
|
||||
httpProxyEnv += fmt.Sprintf(
|
||||
` %s="%s"`, key, config.Conf.HTTPProxy)
|
||||
httpProxyEnv += fmt.Sprintf(` %s="%s"`, key, config.Conf.HTTPProxy)
|
||||
}
|
||||
return httpProxyEnv
|
||||
}
|
||||
|
||||
// PrependProxyEnv prepends proxy environment variable
|
||||
func PrependProxyEnv(cmd string) string {
|
||||
if config.Conf.HTTPProxy == "" {
|
||||
return cmd
|
||||
}
|
||||
return fmt.Sprintf("%s %s", ProxyEnv(), cmd)
|
||||
}
|
||||
|
||||
// func unixtime(s string) (time.Time, error) {
|
||||
// i, err := strconv.ParseInt(s, 10, 64)
|
||||
// if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user