Merge pull request #1053 from versity/ben/fix_ipa_quoting

Potential fix for code scanning alert no. 15: Potentially unsafe quoting
This commit is contained in:
Ben McClelland
2025-02-03 09:17:19 -08:00
committed by GitHub

View File

@@ -354,15 +354,18 @@ func (ipa *IpaIAMService) newRequest(method string, args []string, dict map[stri
return "", fmt.Errorf("ipa request invalid: %w", err)
}
return fmt.Sprintf(`{
"id": %d,
"method": %s,
"params": [
%s,
%s
]
request := map[string]interface{}{
"id": id,
"method": json.RawMessage(jmethod),
"params": []json.RawMessage{json.RawMessage(jargs), json.RawMessage(jdict)},
}
`, id, jmethod, jargs, jdict), nil
requestJSON, err := json.Marshal(request)
if err != nil {
return "", fmt.Errorf("failed to marshal request: %w", err)
}
return string(requestJSON), nil
}
// pkcs7Unpad validates and unpads data from the given bytes slice.