From f0caa4aa9cc92da45abeccc9dadfb909fa59c8bb Mon Sep 17 00:00:00 2001 From: j3ssie Date: Sun, 2 Aug 2020 22:29:39 +0700 Subject: [PATCH] Release v0.12 --- cmd/config.go | 1 + core/config.go | 6 ++++++ utils/helper.go | 13 +++++++++++++ utils/log.go | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 5c4e5ef..f385561 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -77,6 +77,7 @@ func runConfig(cmd *cobra.Command, _ []string) error { reloadSignature(path.Join(options.RootFolder, "base-signatures"), mics) break case "clear": + utils.GoodF("Cleaning your DB") database.CleanScans() database.CleanSigns() database.CleanRecords() diff --git a/core/config.go b/core/config.go index 15f5fe0..bafb6dd 100644 --- a/core/config.go +++ b/core/config.go @@ -103,5 +103,11 @@ func InitConfig(options *libs.Options) { if options.PassiveSummary == "" { options.PassiveSummary = path.Join(options.PassiveOutput, "jaeles-passive-summary.txt") } + + dbSize := utils.GetFileSize(options.Server.DBPath) + if dbSize > 5.0 { + utils.WarningF("Your Database size look very big: %vGB", fmt.Sprintf("%.2f", dbSize)) + utils.WarningF("Consider clean your db with this command: 'jaeles config -a clear' or just remove your '~/.jaeles/'") + } utils.InforF("Summary output: %v", options.SummaryOutput) } diff --git a/utils/helper.go b/utils/helper.go index 1ec38d9..8e3171a 100644 --- a/utils/helper.go +++ b/utils/helper.go @@ -328,3 +328,16 @@ func StripName(raw string) string { func MoveFolder(src string, dest string) { os.Rename(NormalizePath(src), NormalizePath(dest)) } + +// GetFileSize get file size of a file in GB +func GetFileSize(src string) float64 { + var sizeGB float64 + fi, err := os.Stat(NormalizePath(src)) + if err != nil { + return sizeGB + } + // get the size + size := fi.Size() + sizeGB = float64(size) / (1024 * 1024 * 1024) + return sizeGB +} diff --git a/utils/log.go b/utils/log.go index 3d66569..cfa4707 100644 --- a/utils/log.go +++ b/utils/log.go @@ -76,7 +76,7 @@ func PrintLine() { // GoodF print good message func GoodF(format string, args ...interface{}) { good := color.HiGreenString("[+]") - fmt.Printf("%s %s\n", good, fmt.Sprintf(format, args...)) + fmt.Fprintf(os.Stderr, "%s %s\n", good, fmt.Sprintf(format, args...)) } // BannerF print info message @@ -104,7 +104,7 @@ func ErrorF(format string, args ...interface{}) { // WarningF print good message func WarningF(format string, args ...interface{}) { good := color.YellowString("[!]") - fmt.Printf("%s %s\n", good, fmt.Sprintf(format, args...)) + fmt.Fprintf(os.Stderr, "%s %s\n", good, fmt.Sprintf(format, args...)) } // DebugF print debug message