stsSessionName returns the name for the STS session in the format of `sops@ `. It sanitizes the hostname with stsSessionRegex, and truncates to roleSessionNameLengthLimit when it exceeds the limit.
()
| 460 | // `sops@<hostname>`. It sanitizes the hostname with stsSessionRegex, and |
| 461 | // truncates to roleSessionNameLengthLimit when it exceeds the limit. |
| 462 | func stsSessionName() (string, error) { |
| 463 | hostname, err := osHostname() |
| 464 | if err != nil { |
| 465 | return "", fmt.Errorf("failed to construct STS session name: %w", err) |
| 466 | } |
| 467 | |
| 468 | re := regexp.MustCompile(stsSessionRegex) |
| 469 | sanitizedHostname := re.ReplaceAllString(hostname, "") |
| 470 | |
| 471 | name := "sops@" + sanitizedHostname |
| 472 | if len(name) >= roleSessionNameLengthLimit { |
| 473 | name = name[:roleSessionNameLengthLimit] |
| 474 | } |
| 475 | return name, nil |
| 476 | } |
| 477 | |
| 478 | func stringPointerToStringMap(in map[string]*string) map[string]string { |
| 479 | var out = make(map[string]string) |
no outgoing calls