-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[taint] Match potential tainted values wrt field matchers, taint the …
…rhs of Sil.Store Summary: Here we add functionality for matching a field name against a field matcher and tainting the corresponding `rhs` value of the `Sil.Store` instruction. Better error message and more tests in upcoming diffs. Reviewed By: geralt-encore Differential Revision: D45869653 fbshipit-source-id: c717d4cbdb527905d75f118240fbc3dd1c0a51c2
- Loading branch information
1 parent
78f28b2
commit 109e7a1
Showing
9 changed files
with
393 additions
and
167 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
88 changes: 88 additions & 0 deletions
88
infer/tests/codetoanalyze/objc/pulse/taint/StoreIvarTaint.m
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,88 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface Item : NSObject | ||
@property(nonatomic, copy) NSString* token; | ||
@end | ||
|
||
typedef void (^LibraryFetchCompletionBlock)(NSArray<id>* items, | ||
NSArray<NSError*>* errors); | ||
|
||
@interface Library : NSObject | ||
+ (instancetype)sharedInstance; | ||
@end | ||
|
||
@implementation Library | ||
|
||
+ (instancetype)sharedInstance { | ||
static dispatch_once_t dispatchOnceToken; | ||
static Library* sharedLibrary = nil; | ||
dispatch_once(&dispatchOnceToken, ^{ | ||
sharedLibrary = [Library new]; | ||
}); | ||
return sharedLibrary; | ||
} | ||
|
||
- (void)fetchWithCompletion:(LibraryFetchCompletionBlock)completion { | ||
} | ||
|
||
@end | ||
|
||
@interface StoreIvarTaint : NSObject | ||
|
||
@end | ||
|
||
@implementation StoreIvarTaint { | ||
NSString* _token; | ||
} | ||
|
||
- (void)_fetchToken_bad { | ||
__weak __typeof(self) weakSelf = self; | ||
[[Library sharedInstance] | ||
fetchWithCompletion:^(NSArray<Item*>* accounts, | ||
NSArray<NSError*>* _Nonnull errors) { | ||
NSString* const accessToken = [accounts firstObject].token; | ||
NSString* token = [accessToken copy]; | ||
[self setToken:token]; | ||
}]; | ||
} | ||
|
||
- (void)setToken:(NSString*)token { | ||
_token = token; | ||
} | ||
|
||
@end | ||
|
||
@interface OtherClass : NSObject | ||
- (NSString*)getSource; | ||
@end | ||
|
||
@implementation OtherClass { | ||
NSString* _item; | ||
@public | ||
NSString* _name; | ||
} | ||
|
||
- (void)setItem:(NSString*)item { | ||
_item = item; | ||
} | ||
|
||
@end | ||
|
||
void storeIvarBad() { | ||
OtherClass* c = [OtherClass new]; | ||
NSString* source = [c getSource]; | ||
[c setItem:source]; | ||
} | ||
|
||
void storeIvarGood() { | ||
OtherClass* c = [OtherClass new]; | ||
NSString* source = [c getSource]; | ||
c->_name = source; | ||
} |