mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Enable modernize linter for golangci-lint (#8996)
Didn't know this was a thing now. That certainly helps! Also some follow-up fixes from the previous modernize PR. --------- Signed-off-by: Anders Eknert <anders.eknert@apple.com> Signed-off-by: Charlie Egan <charlie_egan@apple.com> Co-authored-by: Charlie Egan <charlie_egan@apple.com>
This commit is contained in:
@@ -151,23 +151,31 @@ func SignV4(headers map[string][]string, method string, theURL *url.URL, body []
|
||||
|
||||
// the "canonical request" is the normalized version of the AWS service access
|
||||
// that we're attempting to perform
|
||||
canonicalReq := method + "\n" // HTTP method
|
||||
canonicalReq += theURL.EscapedPath() + "\n" // URI-escaped path
|
||||
canonicalReq += theURL.RawQuery + "\n" // RAW Query String
|
||||
buf := bytes.NewBufferString(method)
|
||||
buf.WriteByte('\n')
|
||||
buf.WriteString(theURL.EscapedPath())
|
||||
buf.WriteByte('\n')
|
||||
buf.WriteString(theURL.RawQuery)
|
||||
buf.WriteByte('\n')
|
||||
|
||||
// include the values for the signed headers
|
||||
orderedKeys := util.KeysSorted(headersToSign)
|
||||
for _, k := range orderedKeys {
|
||||
// TODO: fix later
|
||||
//nolint:perfsprint
|
||||
canonicalReq += k + ":" + strings.Join(headersToSign[k], ",") + "\n"
|
||||
buf.WriteString(k)
|
||||
buf.WriteByte(':')
|
||||
buf.WriteString(strings.Join(headersToSign[k], ","))
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
canonicalReq += "\n" // linefeed to terminate headers
|
||||
|
||||
buf.WriteByte('\n') // linefeed to terminate headers
|
||||
|
||||
// include the list of the signed headers
|
||||
headerList := strings.Join(orderedKeys, ";")
|
||||
canonicalReq += headerList + "\n"
|
||||
canonicalReq += contentSha256
|
||||
buf.WriteString(headerList)
|
||||
buf.WriteByte('\n')
|
||||
buf.WriteString(contentSha256)
|
||||
|
||||
canonicalReq := buf.String()
|
||||
|
||||
// the "string to sign" is a time-bounded, scoped request token which
|
||||
// is linked to the "canonical request" by inclusion of its SHA-256 hash
|
||||
|
||||
Reference in New Issue
Block a user