Documentation ¶
Overview ¶
Package redact contains utilities functions to obscure sensitive data.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPData ¶
HTTPData returns the input string with sensitive HTTP data obscured. Redacts the Authorization header, password and key fields.
Example ¶
package main import ( "fmt" "github.com/Vonage/gosrvlib/pkg/redact" ) func main() { // example input data data := ` GET /v1/version HTTP/1.1 Host: test.redact.invalid User-Agent: Go-http-client/1.1 Authorization: Basic SECRET_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789= authorization : ApiKey=SECRET OtherData=SECRET X-Nexmo-Trace-Id: abcdef0123456789 Accept-Encoding: gzip password=SECRET test_password=SECRET PASSWORD=SECRET TEST_PASSWORD=SECRET key=SECRET test_key=SECRET KEY=SECRET TEST_KEY=SECRET password=SECRET&key=SECRET alpha=beta&password=SECRET&key=SECRET&gamma=delta { "password": "SECRET", "test_password": "SECRET", "PASSWORD": "SECRET", "TEST_PASSWORD": "SECRET", "key": "SECRET", "test_key": "SECRET", "KEY": "SECRET", "TEST_KEY": "SECRET" } ` // redact input data redactedData := redact.HTTPData(data) fmt.Println(redactedData) }
Output: GET /v1/version HTTP/1.1 Host: test.redact.invalid User-Agent: Go-http-client/1.1 Authorization: @~REDACTED~@ authorization : @~REDACTED~@ X-Nexmo-Trace-Id: abcdef0123456789 Accept-Encoding: gzip password=@~REDACTED~@ test_password=@~REDACTED~@ PASSWORD=@~REDACTED~@ TEST_PASSWORD=@~REDACTED~@ key=@~REDACTED~@ test_key=@~REDACTED~@ KEY=@~REDACTED~@ TEST_KEY=@~REDACTED~@ password=@~REDACTED~@&key=@~REDACTED~@ alpha=beta&password=@~REDACTED~@&key=@~REDACTED~@&gamma=delta { "password": "@~REDACTED~@", "test_password": "@~REDACTED~@", "PASSWORD": "@~REDACTED~@", "TEST_PASSWORD": "@~REDACTED~@", "key": "@~REDACTED~@", "test_key": "@~REDACTED~@", "KEY": "@~REDACTED~@", "TEST_KEY": "@~REDACTED~@" }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.