mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Changes to avoid placing sensitive information in debug logs.
This commit is contained in:
parent
cc38f2f4a1
commit
1934ce6205
4 changed files with 212 additions and 18 deletions
|
@ -65,6 +65,11 @@
|
|||
# include <sys/socket.h> // For MSG_PEEK, etc
|
||||
#endif
|
||||
|
||||
@interface GSMimeHeader (HTTPRequest)
|
||||
- (void) addToBuffer: (NSMutableData*)buf
|
||||
masking: (NSMutableData**)masked;
|
||||
@end
|
||||
|
||||
/*
|
||||
* Implement map keys for strings with case insensitive comparisons,
|
||||
* so we can have case insensitive matching of http headers (correct
|
||||
|
@ -427,6 +432,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSString *key;
|
||||
NSString *val;
|
||||
NSMutableData *buf;
|
||||
NSMutableData *masked = nil;
|
||||
NSString *version;
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
|
@ -574,7 +580,14 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
GSMimeHeader *h;
|
||||
|
||||
h = [[GSMimeHeader alloc] initWithName: key value: val parameters: nil];
|
||||
[buf appendData: [h rawMimeDataPreservingCase: YES foldedAt: 0]];
|
||||
if (debug || masked)
|
||||
{
|
||||
[h addToBuffer: buf masking: &masked];
|
||||
}
|
||||
else
|
||||
{
|
||||
[h addToBuffer: buf masking: NULL];
|
||||
}
|
||||
RELEASE(h);
|
||||
}
|
||||
NSEndMapTableEnumeration(&enumerator);
|
||||
|
@ -603,11 +616,15 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
*/
|
||||
if (debug)
|
||||
{
|
||||
if (NO == [ioDelegate putBytes: [buf bytes]
|
||||
ofLength: [buf length]
|
||||
if (nil == masked)
|
||||
{
|
||||
masked = buf; // Just log unmasked data
|
||||
}
|
||||
if (NO == [ioDelegate putBytes: [masked bytes]
|
||||
ofLength: [masked length]
|
||||
byHandle: self])
|
||||
{
|
||||
debugWrite(self, buf);
|
||||
debugWrite(self, masked);
|
||||
}
|
||||
}
|
||||
[sock writeInBackgroundAndNotify: buf];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue