зеркало из https://github.com/microsoft/hcsshim.git
Adding padding to base64 encoded policy decisions (#1738)
Switching to standard encoding Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
This commit is contained in:
Родитель
11439346dd
Коммит
d816cbe89e
|
@ -146,7 +146,7 @@ func ExtractPolicyDecision(errorMessage string) (string, error) {
|
|||
return "", errors.Errorf("unable to extract policy decision from error message: %s", errorMessage)
|
||||
}
|
||||
|
||||
errorBytes, err := base64.RawURLEncoding.DecodeString(matches[1])
|
||||
errorBytes, err := base64.StdEncoding.DecodeString(matches[1])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ func (policy *regoEnforcer) policyDecisionToError(ctx context.Context, decision
|
|||
|
||||
log.G(ctx).WithField("policyDecision", string(decisionJSON))
|
||||
|
||||
base64EncodedDecisionJSON := base64.RawURLEncoding.EncodeToString(decisionJSON)
|
||||
base64EncodedDecisionJSON := base64.StdEncoding.EncodeToString(decisionJSON)
|
||||
errorMessage := fmt.Errorf(policyDecisionPattern, base64EncodedDecisionJSON)
|
||||
if policy.maxErrorMessageLength == 0 {
|
||||
// indicates no message truncation
|
||||
|
@ -373,7 +373,7 @@ func (policy *regoEnforcer) policyDecisionToError(ctx context.Context, decision
|
|||
log.G(ctx).WithError(err).Error("unable to marshal error object")
|
||||
decisionJSON = []byte(`"Unable to marshal error object"`)
|
||||
}
|
||||
base64EncodedDecisionJSON = base64.RawURLEncoding.EncodeToString(decisionJSON)
|
||||
base64EncodedDecisionJSON = base64.StdEncoding.EncodeToString(decisionJSON)
|
||||
errorMessage = fmt.Errorf(policyDecisionPattern, base64EncodedDecisionJSON)
|
||||
|
||||
if len(errorMessage.Error()) <= policy.maxErrorMessageLength {
|
||||
|
|
Загрузка…
Ссылка в новой задаче