Skip to content

Commit 60706c5

Browse files
Merge pull request #142 from purecloudlabs/GCVCALLP-3051
GCVCALLP-3052 adding redact pii from other 2 commits
2 parents 95c32a4 + 835195f commit 60706c5

83 files changed

Lines changed: 350 additions & 230 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

blacklists.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "context.h"
4141
#include "timer.h"
4242
#include "ut.h"
43+
#include "redact_pii.h"
4344

4445
static struct bl_head *blst_heads;
4546
static unsigned int bl_default_marker;
@@ -1060,7 +1061,7 @@ static mi_response_t *mi_check_all_blacklists(const mi_params_t *params,
10601061
if (add_mi_string(resp_arr, NULL, 0, blst_heads[i].name.s,
10611062
blst_heads[i].name.len) < 0) {
10621063
LM_ERR("cannot add blacklist %.*s\n",
1063-
blst_heads[i].name.len, blst_heads[i].name.s);
1064+
blst_heads[i].name.len, redact_pii(blst_heads[i].name.s));
10641065
free_mi_response(resp);
10651066
resp = NULL;
10661067
goto end;

cfg.lex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ MCAST_LOOPBACK "mcast_loopback"
279279
MCAST_TTL "mcast_ttl"
280280
TOS "tos"
281281
DISABLE_DNS_FAILOVER "disable_dns_failover"
282+
REDACT_PII_ "redact_pii_"
282283
DISABLE_DNS_BLACKLIST "disable_dns_blacklist"
283284
DST_BLACKLIST "dst_blacklist"
284285
MAX_WHILE_LOOPS "max_while_loops"
@@ -525,6 +526,8 @@ SPACE [ ]
525526
return TOS; }
526527
<INITIAL>{DISABLE_DNS_FAILOVER} { count(); yylval.strval=yytext;
527528
return DISABLE_DNS_FAILOVER; }
529+
<INITIAL>{REDACT_PII_} { count(); yylval.strval=yytext;
530+
return REDACT_PII_;}
528531
<INITIAL>{DISABLE_DNS_BLACKLIST} { count(); yylval.strval=yytext;
529532
return DISABLE_DNS_BLACKLIST; }
530533
<INITIAL>{DST_BLACKLIST} { count(); yylval.strval=yytext;

cfg.y

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ extern int cfg_parse_only_routes;
394394
%token MCAST_TTL
395395
%token TOS
396396
%token DISABLE_DNS_FAILOVER
397+
%token REDACT_PII_
397398
%token DISABLE_DNS_BLACKLIST
398399
%token DST_BLACKLIST
399400
%token DISABLE_STATELESS_FWD
@@ -1593,6 +1594,10 @@ assign_stm: LOGLEVEL EQUAL snumber { IFOR();
15931594
disable_dns_failover=$3;
15941595
}
15951596
| DISABLE_DNS_FAILOVER error { yyerror("boolean value expected"); }
1597+
| REDACT_PII_ EQUAL NUMBER { IFOR();
1598+
redact_pii_=$3;
1599+
}
1600+
| REDACT_PII_ error { yyerror("boolean value expected"); }
15961601
| DISABLE_DNS_BLACKLIST EQUAL NUMBER { IFOR();
15971602
disable_dns_blacklist=$3;
15981603
}

core_cmds.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include "mod_fix.h"
4545
/* needed by tcpconn_add_alias() */
4646
#include "net/tcp_conn_defs.h"
47+
#include "net/net_tcp.h"
48+
#include "redact_pii.h"
4749

4850
static int fixup_forward_dest(void** param);
4951
static int fixup_destination(void** param);
@@ -552,7 +554,7 @@ static int fixup_f_send_sock(void** param)
552554

553555
he=resolvehost(host_nt.s,0);
554556
if (he==0){
555-
LM_ERR(" could not resolve %s\n", host_nt.s);
557+
LM_ERR(" could not resolve %s\n", redact_pii(host_nt.s));
556558
goto error;
557559
}
558560
hostent2ip_addr(&ip, he, 0);

dset.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "mem/mem.h"
3838
#include "ip_addr.h"
3939
#include "usr_avp.h"
40+
#include "redact_pii.h"
4041

4142
#define CONTACT "Contact: "
4243
#define CONTACT_LEN (sizeof(CONTACT) - 1)
@@ -321,7 +322,7 @@ int update_msg_branch_uri(unsigned int idx, str *val)
321322
br = dsct->branches + idx;
322323

323324
if (val->len > MAX_URI_SIZE - 1) {
324-
LM_ERR("too long uri: [%.*s]/%d\n", val->len, val->s, val->len);
325+
LM_ERR("too long uri: [%.*s]/%d\n", val->len, redact_pii(val->s), val->len);
325326
return -1;
326327
}
327328
br->branch.uri.s = br->uri; /* internal buffer */
@@ -350,7 +351,7 @@ int update_msg_branch_dst_uri(unsigned int idx, str *val)
350351
br->branch.dst_uri.len = 0;
351352
} else {
352353
if (val->len > MAX_URI_SIZE - 1) {
353-
LM_ERR("too long dst_uri: [%.*s]/%d\n", val->len, val->s,val->len);
354+
LM_ERR("too long dst_uri: [%.*s]/%d\n", val->len, redact_pii(val->s),val->len);
354355
return -1;
355356
}
356357
br->branch.dst_uri.s = br->dst_uri; /* internal buffer */

forward.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#include "blacklists.h"
8080
#include "msg_callbacks.h"
8181
#include "md5utils.h"
82+
#include "redact_pii.h"
8283

8384

8485

@@ -512,7 +513,7 @@ int forward_reply(struct sip_msg* msg)
512513
msg->via1->port?msg->via1->port:SIP_PORT,
513514
msg->via1->proto)!=1){
514515
LM_ERR("host in first via!=me : %.*s:%d\n",
515-
msg->via1->host.len, msg->via1->host.s, msg->via1->port);
516+
msg->via1->host.len, redact_pii(msg->via1->host.s), msg->via1->port);
516517
/* send error msg back? */
517518
goto error;
518519
}

globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ extern int mcast_ttl;
102102
extern int tos;
103103

104104
extern int disable_dns_failover;
105+
extern int redact_pii_;
105106
extern int disable_dns_blacklist;
106107

107108
extern int cfg_errors;

lib/reg/path.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "../../parser/parse_uri.h"
2727
#include "../../ut.h"
2828
#include "../../strcommon.h"
29+
#include "../../redact_pii.h"
2930

3031
#include "path.h"
3132
#include "config.h"
@@ -122,7 +123,7 @@ int build_path_vector(struct sip_msg *_m, str *path, str *received,
122123
&unescape_buf) != 0)
123124
LM_ERR("failed to unescape received=%.*s\n",
124125
hooks.contact.received->body.len,
125-
hooks.contact.received->body.s);
126+
redact_pii(hooks.contact.received->body.s));
126127
else
127128
*received = unescape_buf;
128129
}

lib/reg/pn.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "../../usr_avp.h"
2929
#include "../../data_lump.h"
3030
#include "../../data_lump_rpl.h"
31+
#include "../../redact_pii.h"
3132

3233
#include "../../modules/usrloc/ul_evi.h"
3334
#include "../../modules/event_routing/api.h"
@@ -280,7 +281,7 @@ enum pn_action pn_inspect_ct_params(struct sip_msg *req, const str *ct_uri)
280281
int i, is_cap_query = 1, is_handled_upstream = 0;
281282

282283
if (parse_uri(ct_uri->s, ct_uri->len, &puri) != 0) {
283-
LM_ERR("failed to parse Contact URI '%.*s'\n", ct_uri->len, ct_uri->s);
284+
LM_ERR("failed to parse Contact URI '%.*s'\n", ct_uri->len, redact_pii(ct_uri->s));
284285
return -1;
285286
}
286287

@@ -551,7 +552,7 @@ static struct usr_avp *pn_trim_pn_params(evi_params_t *params)
551552
pn_has_uri_params(&p->val.s, &puri)) {
552553
if (pn_remove_uri_params(&puri, p->val.s.len, &_sval) != 0) {
553554
LM_ERR("failed to remove PN params from Contact '%.*s'\n",
554-
p->val.s.len, p->val.s.s);
555+
p->val.s.len, redact_pii(p->val.s.s));
555556
sval = &p->val.s;
556557
} else {
557558
sval = &_sval;
@@ -641,13 +642,13 @@ int pn_awake_pn_contacts(struct sip_msg *req, ucontact_t **cts, int sz,
641642
for (end = cts + sz; cts < end; cts++) {
642643
if (parse_uri((*cts)->c.s, (*cts)->c.len, &puri) != 0) {
643644
LM_ERR("failed to parse Contact '%.*s'\n",
644-
(*cts)->c.len, (*cts)->c.s);
645+
(*cts)->c.len, redact_pii((*cts)->c.s));
645646
continue;
646647
}
647648

648649
if (pn_trigger_pn(req, *cts, &puri) != 0) {
649650
LM_ERR("failed to trigger PN for Contact: '%.*s'\n",
650-
(*cts)->c.len, (*cts)->c.s);
651+
(*cts)->c.len, redact_pii((*cts)->c.s));
651652
continue;
652653
}
653654

@@ -670,7 +671,7 @@ int pn_trigger_pn(struct sip_msg *req, const ucontact_t *ct,
670671
if (get_uri_param_val(ct_uri, &f->uri_param_key, &f->val) != 0) {
671672
LM_ERR("failed to locate '%.*s' URI param in Contact '%.*s'\n",
672673
f->uri_param_key.len, f->uri_param_key.s,
673-
ct->c.len, ct->c.s);
674+
ct->c.len, redact_pii(ct->c.s));
674675
return -1;
675676
}
676677
}
@@ -679,7 +680,7 @@ int pn_trigger_pn(struct sip_msg *req, const ucontact_t *ct,
679680
pn_trim_pn_params, pn_notify_branch, pn_refresh_timeout,
680681
EBR_SUBS_EXPIRE_NOTIFY) != 0) {
681682
LM_ERR("failed to EBR-subscribe to "UL_EV_CT_UPDATE", Contact: %.*s\n",
682-
ct->c.len, ct->c.s);
683+
ct->c.len, redact_pii(ct->c.s));
683684
return -1;
684685
}
685686

@@ -704,7 +705,7 @@ int pn_has_uri_params(const str *ct, struct sip_uri *puri)
704705
puri = &_puri;
705706

706707
if (parse_uri(ct->s, ct->len, puri) != 0) {
707-
LM_ERR("failed to parse contact: '%.*s'\n", ct->len, ct->s);
708+
LM_ERR("failed to parse contact: '%.*s'\n", ct->len, redact_pii(ct->s));
708709
return 0;
709710
}
710711

@@ -802,7 +803,7 @@ int pn_async_process_purr(struct sip_msg *req, async_ctx *ctx, udomain_t *d)
802803
/* locate "pn-purr" in the R-URI */
803804
if (parse_sip_msg_uri(req) < 0) {
804805
LM_ERR("failed to parse R-URI: '%.*s'\n",
805-
GET_RURI(req)->len, GET_RURI(req)->s);
806+
GET_RURI(req)->len, redact_pii(GET_RURI(req)->s));
806807
return -1;
807808
}
808809

@@ -825,7 +826,7 @@ int pn_async_process_purr(struct sip_msg *req, async_ctx *ctx, udomain_t *d)
825826

826827
rt_uri = &((rr_t *)req->route->parsed)->nameaddr.uri;
827828
if (parse_uri(rt_uri->s, rt_uri->len, &puri) != 0) {
828-
LM_ERR("failed to parse Route URI: '%.*s'\n", rt_uri->len, rt_uri->s);
829+
LM_ERR("failed to parse Route URI: '%.*s'\n", rt_uri->len, redact_pii(rt_uri->s));
829830
return -1;
830831
}
831832

@@ -854,7 +855,7 @@ int pn_async_process_purr(struct sip_msg *req, async_ctx *ctx, udomain_t *d)
854855
purr->len, purr->s);
855856

856857
if (parse_uri(c->c.s, c->c.len, &puri) != 0) {
857-
LM_ERR("failed to parse Contact: '%.*s'\n", c->c.len, c->c.s);
858+
LM_ERR("failed to parse Contact: '%.*s'\n", c->c.len, redact_pii(c->c.s));
858859
goto err_unlock;
859860
}
860861

@@ -863,7 +864,7 @@ int pn_async_process_purr(struct sip_msg *req, async_ctx *ctx, udomain_t *d)
863864
if (get_uri_param_val(&puri, &f->uri_param_key, &f->val) != 0) {
864865
LM_ERR("failed to locate '%.*s' URI param in Contact '%.*s'\n",
865866
f->uri_param_key.len, f->uri_param_key.s,
866-
c->c.len, c->c.s);
867+
c->c.len, redact_pii(c->c.s));
867868
goto err_unlock;
868869
}
869870
}
@@ -872,7 +873,7 @@ int pn_async_process_purr(struct sip_msg *req, async_ctx *ctx, udomain_t *d)
872873
if (ebr.async_wait_for_event(req, ctx, ev_ct_update, pn_ebr_filters,
873874
pn_trim_pn_params, pn_refresh_timeout) != 0) {
874875
LM_ERR("failed to EBR-subscribe to "UL_EV_CT_UPDATE", ct: '%.*s'\n",
875-
c->c.len, c->c.s);
876+
c->c.len, redact_pii(c->c.s));
876877
goto err_unlock;
877878
}
878879

@@ -903,7 +904,7 @@ int pn_add_reply_purr(const ucontact_t *ct)
903904
return 0;
904905

905906
if (parse_uri(ct->c.s, ct->c.len, &puri) != 0) {
906-
LM_ERR("failed to parse Contact URI: '%.*s'\n", ct->c.len, ct->c.s);
907+
LM_ERR("failed to parse Contact URI: '%.*s'\n", ct->c.len, redact_pii(ct->c.s));
907908
return -1;
908909
}
909910

lib/reg/sip_msg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "../../parser/contact/parse_contact.h"
2525
#include "../../parser/parse_uri.h"
26+
#include "../../redact_pii.h"
2627

2728
#include "common.h"
2829

@@ -420,7 +421,7 @@ int calc_contact_q(param_t* _q, qvalue_t* _r)
420421
if (rc < 0) {
421422
rerrno = R_INV_Q; /* Invalid q parameter */
422423
LM_ERR("invalid qvalue (%.*s): %s\n",
423-
_q->body.len, _q->body.s, qverr2str(rc));
424+
_q->body.len, redact_pii(_q->body.s), qverr2str(rc));
424425
return -1;
425426
}
426427
}

0 commit comments

Comments
 (0)