From daf52d0e628d2d57b9f50a2556e404a3f05c34aa Mon Sep 17 00:00:00 2001 From: hakito Date: Wed, 20 Dec 2023 07:06:46 +0000 Subject: [PATCH] Sanitize UFT-8 content in logs (#453) I accidently closed my previous PR #384 This PR replaces invalid UTF-8 character in a stream with `?` character. On Windows Server 2019 other characters are replaced by `?` as well so it's consistent. fixes #452 Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/act_runner/pulls/453 Reviewed-by: Lunny Xiao Reviewed-by: Jason Song Co-authored-by: hakito Co-committed-by: hakito --- internal/app/cmd/exec.go | 2 +- internal/pkg/report/reporter.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/app/cmd/exec.go b/internal/app/cmd/exec.go index 9a28170..335f658 100644 --- a/internal/app/cmd/exec.go +++ b/internal/app/cmd/exec.go @@ -484,7 +484,7 @@ func loadExecCmd(ctx context.Context) *cobra.Command { execCmd.PersistentFlags().BoolVarP(&execArg.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout") execCmd.PersistentFlags().BoolVarP(&execArg.debug, "debug", "d", false, "enable debug log") execCmd.PersistentFlags().BoolVarP(&execArg.dryrun, "dryrun", "n", false, "dryrun mode") - execCmd.PersistentFlags().StringVarP(&execArg.image, "image", "i", "node:16-bullseye", "docker image to use") + execCmd.PersistentFlags().StringVarP(&execArg.image, "image", "i", "node:16-bullseye", "Docker image to use. Use \"-self-hosted\" to run directly on the host.") execCmd.PersistentFlags().StringVarP(&execArg.network, "network", "", "", "Specify the network to which the container will connect") execCmd.PersistentFlags().StringVarP(&execArg.githubInstance, "gitea-instance", "", "", "Gitea instance to use.") diff --git a/internal/pkg/report/reporter.go b/internal/pkg/report/reporter.go index 7e9a2d5..0a3ed79 100644 --- a/internal/pkg/report/reporter.go +++ b/internal/pkg/report/reporter.go @@ -418,7 +418,7 @@ func (r *Reporter) parseLogRow(entry *log.Entry) *runnerv1.LogRow { return &runnerv1.LogRow{ Time: timestamppb.New(entry.Time), - Content: content, + Content: strings.ToValidUTF8(content, "?"), } }