[MM-67382] Improve mmctl output by filtering escape sequences #35191 (#35334)

Automatic Merge
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2026-02-17 18:09:38 +01:00
коммит произвёл GitHub
родитель e68120775b
Коммит 21ced4716b
3 изменённых файлов: 201 добавлений и 1 удалений

Просмотреть файл

@@ -273,7 +273,10 @@ func (p Printer) linesToBytes(opts printOpts) (b []byte, err error) {
case FormatPlain:
var buf bytes.Buffer
for i := range p.Lines {
fmt.Fprintf(&buf, "%s%s", p.Lines[i], newline)
// Sanitize output to prevent terminal escape injection attacks
// when writing user-controlled content to the terminal
line := fmt.Sprintf("%s", p.Lines[i])
fmt.Fprintf(&buf, "%s%s", SanitizeForTerminal(line), newline)
}
b = buf.Bytes()
case FormatJSON: