Skip to content

Commit

Permalink
feat(filter): send request body to presidio
Browse files Browse the repository at this point in the history
  • Loading branch information
qlonik committed Mar 7, 2024
1 parent 0251fce commit 5ace267
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 4 additions & 0 deletions privacy-profile-composer/pkg/envoyfilter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (f *Filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.
}

func (f *Filter) DecodeData(buffer api.BufferInstance, endStream bool) api.StatusType {
log.Println("decode data")
log.Println("buffer value:")
log.Println(buffer)

if !endStream {
// TODO: we might need to be careful about collecting the data from all
// of these buffers. Maybe go has some builtin methods to work with it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,13 @@ import (
)

func PiiAnalysis(presidioSvcURL string, svcName string, bufferBytes []byte) (string, error) {
var jsonBody = `{
"key_F": {
"key_a1": "My phone number is 212-121-1424"
},
"URL": "www.abc.com",
"key_c": 3,
"names": ["James Bond", "Clark Kent", "Hakeem Olajuwon", "No name here!"],
"address": "123 Alpha Beta, Waterloo ON N2L3G1, Canada",
"DOB": "01-01-1989",
"gender": "Female",
"race": "Asian",
"language": "English"
}`

svcNameBuf, err := json.Marshal(svcName)
if err != nil {
return "", fmt.Errorf("could not marshal service name string into a valid JSON string: %w", err)
}

// TODO replace jsonBody with bufferBytes input arg
msgString := `{"json_to_analyze":` + jsonBody + `,"derive_purpose":` + string(svcNameBuf) + `}`
msgString := `{"json_to_analyze":` + string(bufferBytes) + `,"derive_purpose":` + string(svcNameBuf) + `}`

resp, err := http.Post(presidioSvcURL, "application/json", bytes.NewBufferString(msgString))
if err != nil {
Expand Down

0 comments on commit 5ace267

Please sign in to comment.