mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-17 05:11:46 +00:00
Unescape query parameters in legacy message converter
This commit is contained in:
parent
e9bd1575aa
commit
abab0eb0a4
3 changed files with 13 additions and 2 deletions
|
|
@ -64,9 +64,13 @@ func convertAndSerializeIntoLegacyFormat(
|
||||||
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query != "" {
|
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query != "" {
|
||||||
parameters = map[string]interface{}{}
|
parameters = map[string]interface{}{}
|
||||||
|
|
||||||
|
unescapedQuery, err := url.QueryUnescape(*event.ProtoPayload.RequestMetadata.RequestAttributes.Query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
parsedUrl, err := url.Parse(fmt.Sprintf("%s?%s",
|
parsedUrl, err := url.Parse(fmt.Sprintf("%s?%s",
|
||||||
event.ProtoPayload.RequestMetadata.RequestAttributes.Path,
|
event.ProtoPayload.RequestMetadata.RequestAttributes.Path,
|
||||||
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query))
|
unescapedQuery))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -355,6 +356,8 @@ func TestDynamicLegacyAuditApi(t *testing.T) {
|
||||||
|
|
||||||
// Instantiate test data
|
// Instantiate test data
|
||||||
event, objectIdentifier := NewOrganizationAuditEvent(nil)
|
event, objectIdentifier := NewOrganizationAuditEvent(nil)
|
||||||
|
escapedQuery := url.QueryEscape("param=value")
|
||||||
|
event.ProtoPayload.RequestMetadata.RequestAttributes.Query = &escapedQuery
|
||||||
|
|
||||||
// Log the event to solace
|
// Log the event to solace
|
||||||
visibility := auditV1.Visibility_VISIBILITY_PUBLIC
|
visibility := auditV1.Visibility_VISIBILITY_PUBLIC
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,8 @@ func TestLegacyAuditApi(t *testing.T) {
|
||||||
|
|
||||||
// Instantiate test data
|
// Instantiate test data
|
||||||
event, objectIdentifier := NewOrganizationAuditEvent(nil)
|
event, objectIdentifier := NewOrganizationAuditEvent(nil)
|
||||||
|
escapedQuery := url.QueryEscape("param=value")
|
||||||
|
event.ProtoPayload.RequestMetadata.RequestAttributes.Query = &escapedQuery
|
||||||
|
|
||||||
// Log the event to solace
|
// Log the event to solace
|
||||||
visibility := auditV1.Visibility_VISIBILITY_PUBLIC
|
visibility := auditV1.Visibility_VISIBILITY_PUBLIC
|
||||||
|
|
@ -462,9 +464,11 @@ func validateSentMessageWithDetails(
|
||||||
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query != "" {
|
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query != "" {
|
||||||
parameters = map[string]interface{}{}
|
parameters = map[string]interface{}{}
|
||||||
|
|
||||||
|
unescapedQuery, err := url.QueryUnescape(*event.ProtoPayload.RequestMetadata.RequestAttributes.Query)
|
||||||
|
assert.NoError(t, err)
|
||||||
parsedUrl, err := url.Parse(fmt.Sprintf("%s?%s",
|
parsedUrl, err := url.Parse(fmt.Sprintf("%s?%s",
|
||||||
event.ProtoPayload.RequestMetadata.RequestAttributes.Path,
|
event.ProtoPayload.RequestMetadata.RequestAttributes.Path,
|
||||||
*event.ProtoPayload.RequestMetadata.RequestAttributes.Query))
|
unescapedQuery))
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
for k, v := range parsedUrl.Query() {
|
for k, v := range parsedUrl.Query() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue