Rename Sentry Span Descriptions.

This commit is contained in:
Maximilian Paß
2023-03-11 13:27:06 +00:00
committed by Sebastian Serth
parent e0419c2e58
commit e877cd1e52
4 changed files with 55 additions and 22 deletions

View File

@ -41,17 +41,22 @@ func (er *ExecutionRequest) FullCommand() string {
return command
}
// WrapBashCommand escapes the passed command and wraps it into a new bash command.
// BashEscapeCommand escapes the passed command and surrounds it with double-quotes.
// The escaping includes the characters ", \, $, ` (comma-separated) as they are the exceptional characters
// that still have a special meaning with double quotes. See the Bash Manual - Chapter Quoting.
// We only handle the dollar-character and the backquote because the %q format already escapes the other two.
func WrapBashCommand(command string) string {
command = fmt.Sprintf("/bin/bash -c %q", command)
func BashEscapeCommand(command string) string {
command = fmt.Sprintf("%q", command)
command = strings.ReplaceAll(command, "$", "\\$")
command = strings.ReplaceAll(command, "`", "\\`")
return command
}
// WrapBashCommand escapes the passed command and wraps it into a new bash command.
func WrapBashCommand(command string) string {
return fmt.Sprintf("/bin/bash -c %s", BashEscapeCommand(command))
}
// EnvironmentID is an id of an environment.
type EnvironmentID int