@@ -1466,8 +1466,61 @@ std::string getPath() {
1466
1466
}
1467
1467
}
1468
1468
1469
+ void RedactField (nlohmann::json& jsonObject, const std::string& fieldName)
1470
+ {
1471
+
1472
+ if (jsonObject.contains (fieldName)) {
1473
+ jsonObject[fieldName] = " REDACTED" ;
1474
+ }
1475
+ }
1476
+
1469
1477
void debugInfo (std::string data, std::string url, std::string response) {
1470
1478
1479
+ // turn response into json
1480
+ nlohmann::json responses = nlohmann::json::parse (response);
1481
+ RedactField (responses, " sessionid" );
1482
+ RedactField (responses, " ownerid" );
1483
+ RedactField (responses, " app" );
1484
+ RedactField (responses, " name" );
1485
+ RedactField (responses, " contents" );
1486
+ RedactField (responses, " key" );
1487
+ RedactField (responses, " username" );
1488
+ RedactField (responses, " password" );
1489
+ RedactField (responses, " secret" );
1490
+ RedactField (responses, " version" );
1491
+ RedactField (responses, " fileid" );
1492
+ RedactField (responses, " webhooks" );
1493
+ std::string redacted_response = responses.dump ();
1494
+
1495
+ // turn data into json
1496
+ std::replace (data.begin (), data.end (), ' &' , ' ' );
1497
+
1498
+ nlohmann::json datas;
1499
+
1500
+ std::istringstream iss (data);
1501
+ std::vector<std::string> results ((std::istream_iterator<std::string>(iss)),
1502
+ std::istream_iterator<std::string>());
1503
+
1504
+ for (auto const & value : results) {
1505
+ datas[value.substr (0 , value.find (' =' ))] = value.substr (value.find (' =' ) + 1 );
1506
+ }
1507
+
1508
+ RedactField (datas, " sessionid" );
1509
+ RedactField (datas, " ownerid" );
1510
+ RedactField (datas, " app" );
1511
+ RedactField (datas, " name" );
1512
+ RedactField (datas, " key" );
1513
+ RedactField (datas, " username" );
1514
+ RedactField (datas, " password" );
1515
+ RedactField (datas, " contents" );
1516
+ RedactField (datas, " secret" );
1517
+ RedactField (datas, " version" );
1518
+ RedactField (datas, " fileid" );
1519
+ RedactField (datas, " webhooks" );
1520
+
1521
+ std::string redacted_data = datas.dump ();
1522
+
1523
+
1471
1524
// gets the path
1472
1525
std::string path = getPath ();
1473
1526
@@ -1485,7 +1538,7 @@ void debugInfo(std::string data, std::string url, std::string response) {
1485
1538
// /////////////////////
1486
1539
1487
1540
// creates variables for the paths needed :smile:
1488
- std::string KeyAuthPath = path + " \\ KeyAuth" ;
1541
+ std::string KeyAuthPath = path + " \\ KeyAuth" ;
1489
1542
std::string logPath = KeyAuthPath + " \\ Debug\\ " + filenameOnly.substr (0 , filenameOnly.size () - 4 );
1490
1543
1491
1544
// basically loops until we have all the paths
@@ -1530,7 +1583,7 @@ void debugInfo(std::string data, std::string url, std::string response) {
1530
1583
1531
1584
std::string currentTimeString = std::to_string (hours) + " :" + formattedMinutes + " " + period;
1532
1585
1533
- std::string contents = " \n\n @ " + currentTimeString + " \n Data sent : " + data + " \n Response : " + response + " Sent to: " + url;
1586
+ std::string contents = " \n\n @ " + currentTimeString + " \n Data sent : " + redacted_data + " \n Response : " + redacted_response + " Sent to: " + url;
1534
1587
1535
1588
logfile << contents;
1536
1589
0 commit comments