This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a sensitiveParameterKeyPahts property to HMRequest class to pr…
…event sensitive information from being included in the description.
- Loading branch information
Showing
7 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// NSDictionary+DescriptionHelpers.h | ||
// Hermod | ||
// | ||
// Created by Borja Arias Drake on 18/10/2018. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSDictionary (DescriptionHelpers) | ||
|
||
/** | ||
Generates a description of the dictionary where there keypaths passed by parameter have been removed. | ||
@param keyPaths Elements in these keypaths will be removed from the description. | ||
@return A description of the dictionary without the specified keypaths. | ||
*/ | ||
- (NSString *)hm_descriptionRemovingKeyPaths:(NSArray <NSString *>*)keyPaths; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// NSDictionary+DescriptionHelpers.m | ||
// Hermod | ||
// | ||
// Created by Borja Arias Drake on 18/10/2018. | ||
// | ||
|
||
#import "NSDictionary+DescriptionHelpers.h" | ||
|
||
@implementation NSDictionary (DescriptionHelpers) | ||
|
||
- (NSString *)hm_descriptionRemovingKeyPaths:(NSArray <NSString *>*)keyPaths | ||
{ | ||
if (keyPaths == nil || keyPaths.count == 0) { | ||
return self.description; | ||
} | ||
|
||
NSDictionary *copy = [self hm_deepCopyRemovingKeyPaths:keyPaths currentKeyPath:@""]; | ||
return copy.description; | ||
} | ||
|
||
- (NSDictionary *)hm_deepCopyRemovingKeyPaths:(NSArray <NSString *>*)keypathsToRemove currentKeyPath:(NSString *)currentKeyPath | ||
{ | ||
NSMutableDictionary *newDictionary = [NSMutableDictionary new]; | ||
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { | ||
|
||
// Generate next keyPath | ||
NSString *nextKeyPath = [self hm_appendComponent:key toCurrentKeyPath:currentKeyPath]; | ||
|
||
// Quit if keypath is in list | ||
if ([keypathsToRemove containsObject:nextKeyPath]) { | ||
// Base case | ||
return; | ||
} | ||
|
||
if (!([obj isKindOfClass:NSDictionary.class] || [obj isKindOfClass:NSMutableDictionary.class])) { | ||
// Base case | ||
newDictionary[key] = [obj copy]; | ||
return; | ||
} | ||
|
||
// Recursion step | ||
newDictionary[key] = [obj hm_deepCopyRemovingKeyPaths:keypathsToRemove currentKeyPath:nextKeyPath]; | ||
}]; | ||
|
||
return [newDictionary copy]; | ||
} | ||
|
||
- (NSString *)hm_appendComponent:(NSString *)component toCurrentKeyPath:(NSString *)keyPath | ||
{ | ||
NSString *nextKeyPath = nil; | ||
if (keyPath.length == 0) | ||
{ | ||
nextKeyPath = [keyPath stringByAppendingFormat:@"%@", component]; | ||
} | ||
else | ||
{ | ||
nextKeyPath = [keyPath stringByAppendingFormat:@".%@", component]; | ||
} | ||
|
||
return nextKeyPath; | ||
} | ||
|
||
@end |