mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: sanitize run logs and api responses written to a terminal
run logs and api copied server bytes straight to stdout. CI logs are attacker-influenced through pull request workflows, so they could drive the terminal of whoever read them. On a terminal, run logs now keep only SGR color sequences, job names are reduced to plain text, and api drops control characters from the response. Piped output and --output-file stay byte-exact. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+58
-3
No files matched your search
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
"gitea.dev/tea/internal/clierr"
|
||||
"gitea.dev/tea/internal/services"
|
||||
"gitea.dev/tea/internal/terminal"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -209,6 +210,9 @@ func (a *application) apiCommand() *cobra.Command {
|
||||
}
|
||||
}
|
||||
return writeOutput(cmd, output, func(destination io.Writer) error {
|
||||
if output == "" || output == "-" {
|
||||
destination = terminal.SafeWriter(destination, a.deps.Streams.OutTTY, false)
|
||||
}
|
||||
return (services.API{Client: target.client}).Visit(cmd.Context(), services.APIOptions{Endpoint: endpoint, Method: method, Body: body, Headers: headers, Paginate: paginate, MaxPages: maxPages}, func(response *http.Response) error {
|
||||
if include {
|
||||
if _, err := fmt.Fprintf(cmd.ErrOrStderr(), "%s %s\n", response.Proto, response.Status); err != nil {
|
||||
|
||||
Reference in new issue
Block a user