Sfoglia il codice sorgente

Show s00 stats instead of "first_parser" (#2055)

* show s00 if verbose is provided

* Clean up code

* Fix failing test
Laurence Jones 2 anni fa
parent
commit
5aca11af70
2 ha cambiato i file con 15 aggiunte e 19 eliminazioni
  1. 14 18
      pkg/hubtest/parser_assert.go
  2. 1 1
      tests/bats/testdata/explain/explain-log.txt

+ 14 - 18
pkg/hubtest/parser_assert.go

@@ -396,25 +396,21 @@ func DumpTree(parser_results ParserResults, bucket_pour BucketPourInfo, opts Dum
 				detailsDisplay := ""
 
 				if res {
-					if prev_item.Stage == "" {
-						changeStr = "first_parser"
-					} else {
-						changelog, _ := diff.Diff(prev_item, parsers[parser].Evt)
-						for _, change := range changelog {
-							switch change.Type {
-							case "create":
-								created++
-								detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s : %s\n", presep, sep, change.Type, strings.Join(change.Path, "."), green(change.To))
-							case "update":
-								detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s : %s -> %s\n", presep, sep, change.Type, strings.Join(change.Path, "."), change.From, yellow(change.To))
-								if change.Path[0] == "Whitelisted" && change.To == true {
-									whitelisted = true
-								}
-								updated++
-							case "delete":
-								deleted++
-								detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s\n", presep, sep, change.Type, red(strings.Join(change.Path, ".")))
+					changelog, _ := diff.Diff(prev_item, parsers[parser].Evt)
+					for _, change := range changelog {
+						switch change.Type {
+						case "create":
+							created++
+							detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s : %s\n", presep, sep, change.Type, strings.Join(change.Path, "."), green(change.To))
+						case "update":
+							detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s : %s -> %s\n", presep, sep, change.Type, strings.Join(change.Path, "."), change.From, yellow(change.To))
+							if change.Path[0] == "Whitelisted" && change.To == true {
+								whitelisted = true
 							}
+							updated++
+						case "delete":
+							deleted++
+							detailsDisplay += fmt.Sprintf("\t%s\t\t%s %s evt.%s\n", presep, sep, change.Type, red(strings.Join(change.Path, ".")))
 						}
 					}
 					prev_item = parsers[parser].Evt

+ 1 - 1
tests/bats/testdata/explain/explain-log.txt

@@ -1,6 +1,6 @@
 line: Sep 19 18:33:22 scw-d95986 sshd[24347]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=1.2.3.4
 	├ s00-raw
-	|	└ 🟢 crowdsecurity/syslog-logs (first_parser)
+	|	└ 🟢 crowdsecurity/syslog-logs (+12 ~9)
 	├ s01-parse
 	|	└ 🟢 crowdsecurity/sshd-logs (+8 ~1)
 	├ s02-enrich