func logOutput(s string, l *BuildResult, opt DaemonOptions) { if !utf8.ValidString(s) { v := make([]rune, 0, len(s)) for i, r := range s { if r == utf8.RuneError { _, size := utf8.DecodeRuneInString(s[i:]) if size == 1 { continue } } v = append(v, r) } s = string(v) } s = strings.Trim(s, string(0)) s = strings.TrimSpace(s) //TODO: Move this code to a new function in kit/score package? Reason: easier to test. if strings.Contains(s, opt.Secret) { // TODO: must be a better way of detecting JSON data! TODO: Hein@Heine: Why? var testscore score.Score err := json.Unmarshal([]byte(s), &testscore) if err == nil { if testscore.Secret == opt.Secret { testscore.Secret = "Sanitized" l.TestScores = append(l.TestScores, testscore) } return } // ensure that the error message does not reveal the secret token es := strings.Replace(err.Error(), opt.Secret, "Sanitized", -1) log.Printf("Parse error: %s\n", es) } s = strings.Replace(s, opt.Secret, "Sanitized", -1) s = strings.Replace(s, opt.AdminToken, "Sanitized", -1) l.Log = append(l.Log, strings.TrimSpace(s)) fmt.Println(s) }