MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / NormalizeServiceAccountJSON

Function NormalizeServiceAccountJSON

internal/auth/vertex/keyutil.go:16–33  ·  view source on GitHub ↗

NormalizeServiceAccountJSON normalizes the given JSON-encoded service account payload. It returns the normalized JSON (with sanitized private_key) or, if normalization fails, the original bytes and the encountered error.

(raw []byte)

Source from the content-addressed store, hash-verified

14// It returns the normalized JSON (with sanitized private_key) or, if normalization fails,
15// the original bytes and the encountered error.
16func NormalizeServiceAccountJSON(raw []byte) ([]byte, error) {
17 if len(raw) == 0 {
18 return raw, nil
19 }
20 var payload map[string]any
21 if err := json.Unmarshal(raw, &payload); err != nil {
22 return raw, err
23 }
24 normalized, err := NormalizeServiceAccountMap(payload)
25 if err != nil {
26 return raw, err
27 }
28 out, err := json.Marshal(normalized)
29 if err != nil {
30 return raw, err
31 }
32 return out, nil
33}
34
35// NormalizeServiceAccountMap returns a copy of the given service account map with
36// a sanitized private_key field that is guaranteed to contain a valid RSA PRIVATE KEY PEM block.

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected