Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions internal/logger/jsonl_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ func (jl *JSONLLogger) Close() error {
return closeLogFile(jl.logFile, &jl.mu, "JSONL")
}

// sanitizePayload sanitizes a payload by applying regex patterns to the entire string
// It takes raw bytes, applies regex sanitization in one pass, and returns sanitized bytes
// This function is deprecated and will be removed in a future version.
// Use sanitize.SanitizeJSON() directly instead.
func sanitizePayload(payloadBytes []byte) json.RawMessage {
return sanitize.SanitizeJSON(payloadBytes)
}

// LogMessage logs an RPC message to the JSONL file
func (jl *JSONLLogger) LogMessage(entry *JSONLRPCMessage) error {
jl.mu.Lock()
Expand Down Expand Up @@ -113,7 +105,7 @@ func LogRPCMessageJSONL(direction RPCMessageDirection, messageType RPCMessageTyp
Type: string(messageType),
ServerID: serverID,
Method: method,
Payload: sanitizePayload(payloadBytes),
Payload: sanitize.SanitizeJSON(payloadBytes),
}

if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/logger/jsonl_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"testing"

"github.com/githubnext/gh-aw-mcpg/internal/logger/sanitize"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -170,9 +171,9 @@ func TestSanitizePayload(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := sanitizePayload([]byte(tt.input))
result := sanitize.SanitizeJSON([]byte(tt.input))

require.NotNil(t, result, "sanitizePayload returned nil")
require.NotNil(t, result, "sanitize.SanitizeJSON returned nil")

// The result is already a sanitized string
sanitizedStr := string(result)
Expand Down Expand Up @@ -219,7 +220,7 @@ func TestSanitizePayloadWithNestedStructures(t *testing.T) {
}
}`

result := sanitizePayload([]byte(input))
result := sanitize.SanitizeJSON([]byte(input))

// The result is already a sanitized string
sanitizedStr := string(result)
Expand Down Expand Up @@ -398,7 +399,7 @@ func TestSanitizePayloadCompactsJSON(t *testing.T) {
}
}`

result := sanitizePayload([]byte(multilineJSON))
result := sanitize.SanitizeJSON([]byte(multilineJSON))

// The result should not contain newlines
resultStr := string(result)
Expand Down
9 changes: 1 addition & 8 deletions internal/logger/markdown_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ func (ml *MarkdownLogger) Close() error {
return nil
}

// sanitizeSecrets replaces potential secrets with [REDACTED]
// This function is deprecated and will be removed in a future version.
// Use sanitize.SanitizeString() directly instead.
func sanitizeSecrets(message string) string {
return sanitize.SanitizeString(message)
}

// getEmojiForLevel returns the appropriate emoji for the log level
func getEmojiForLevel(level LogLevel) string {
switch level {
Expand Down Expand Up @@ -122,7 +115,7 @@ func (ml *MarkdownLogger) Log(level LogLevel, category, format string, args ...i
message := fmt.Sprintf(format, args...)

// Sanitize potential secrets
message = sanitizeSecrets(message)
message = sanitize.SanitizeString(message)

emoji := getEmojiForLevel(level)

Expand Down
Loading