mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enable Address and Undefined Behavior Sanitizers (#36443)
Summary: This change does two things: 1) Moves RNTester on iOS to use an `.xctestplan` to configure its tests. This moves the test configuration out of the `.xcscheme` file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.  Note: this is partially me upstreaming a change from React Native macOS (https://github.com/microsoft/react-native-macos/pull/190/), though at some point our Xcode project got messed up and we were no longer referencing them ��. 2) Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan This should help catch some extra vulnerabilities should they ever show up while our tests run. Notably, I did not _also_ add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅. ## Changelog: [IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester Pull Request resolved: https://github.com/facebook/react-native/pull/36443 Test Plan: CI should pass Reviewed By: cortinico Differential Revision: D44213517 Pulled By: cipolleschi fbshipit-source-id: 0646174c4b416413a563e8178aa2cfca230b5e66
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cd65a324fe
commit
65e61f3c88
@@ -32,11 +32,11 @@ RCT_EXTERN CGFloat RCTInterpolateValueInRange(
|
||||
NSString *extrapolateLeft,
|
||||
NSString *extrapolateRight);
|
||||
|
||||
RCT_EXTERN int32_t
|
||||
RCT_EXTERN uint32_t
|
||||
RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<UIColor *> *outputRange);
|
||||
|
||||
// Represents a color as a int32_t. RGB components are assumed to be in [0-255] range and alpha in [0-1] range
|
||||
RCT_EXTERN int32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha);
|
||||
RCT_EXTERN uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha);
|
||||
|
||||
/**
|
||||
* Coefficient to slow down animations, respects the ios
|
||||
|
||||
@@ -84,7 +84,7 @@ CGFloat RCTInterpolateValueInRange(
|
||||
return RCTInterpolateValue(value, inputMin, inputMax, outputMin, outputMax, extrapolateLeft, extrapolateRight);
|
||||
}
|
||||
|
||||
int32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<UIColor *> *outputRange)
|
||||
uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<UIColor *> *outputRange)
|
||||
{
|
||||
NSUInteger rangeIndex = RCTFindIndexOfNearestValue(value, inputRange);
|
||||
CGFloat inputMin = inputRange[rangeIndex].doubleValue;
|
||||
@@ -102,10 +102,10 @@ int32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRang
|
||||
alphaMin + (value - inputMin) * (alphaMax - alphaMin) / (inputMax - inputMin));
|
||||
}
|
||||
|
||||
int32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
|
||||
uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
|
||||
{
|
||||
return ((int)round(alpha * 255) & 0xFF) << 24 | ((int)round(red) & 0xFF) << 16 | ((int)round(green) & 0xFF) << 8 |
|
||||
((int)round(blue) & 0xFF);
|
||||
return ((uint32_t)round(alpha * 255) & 0xFF) << 24 | ((uint32_t)round(red) & 0xFF) << 16 |
|
||||
((uint32_t)round(green) & 0xFF) << 8 | ((uint32_t)round(blue) & 0xFF);
|
||||
}
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"configurations" : [
|
||||
{
|
||||
"id" : "1D5134C7-450A-44B6-A8B1-13CD24FD50B9",
|
||||
"name" : "Address Sanitizer",
|
||||
"options" : {
|
||||
"addressSanitizer" : {
|
||||
"detectStackUseAfterReturn" : true,
|
||||
"enabled" : true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"defaultOptions" : {
|
||||
"codeCoverage" : false,
|
||||
"environmentVariableEntries" : [
|
||||
{
|
||||
"key" : "CI_USE_PACKAGER",
|
||||
"value" : "1"
|
||||
}
|
||||
],
|
||||
"targetForVariableExpansion" : {
|
||||
"containerPath" : "container:RNTesterPods.xcodeproj",
|
||||
"identifier" : "13B07F861A680F5B00A75B9A",
|
||||
"name" : "RNTester"
|
||||
},
|
||||
"undefinedBehaviorSanitizerEnabled" : true
|
||||
},
|
||||
"testTargets" : [
|
||||
{
|
||||
"target" : {
|
||||
"containerPath" : "container:RNTesterPods.xcodeproj",
|
||||
"identifier" : "E7DB215222B2F332005AC45F",
|
||||
"name" : "RNTesterIntegrationTests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"target" : {
|
||||
"containerPath" : "container:RNTesterPods.xcodeproj",
|
||||
"identifier" : "E7DB209E22B2BA84005AC45F",
|
||||
"name" : "RNTesterUnitTests"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 1
|
||||
}
|
||||
@@ -101,6 +101,7 @@
|
||||
6144DEEE56C6C17B301A90E4 /* libPods-RNTesterUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7FC437025B5EE3899315628B /* Pods-RNTester.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.release.xcconfig"; path = "Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig"; sourceTree = "<group>"; };
|
||||
8145AE05241172D900A3F8DA /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNTester/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
AC474BFB29BBD4A1002BDAED /* RNTester.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = RNTester.xctestplan; path = RNTester/RNTester.xctestplan; sourceTree = "<group>"; };
|
||||
B8219B8DAB1CDD38543E30A4 /* Pods-RNTesterUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterUnitTests.release.xcconfig"; path = "Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
BD6F35F6C79ACF7496CBC337 /* Pods-RNTesterIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.release.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
C4CEC47A71A2AEE236833CDF /* Pods-RNTesterUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterUnitTests.debug.xcconfig"; path = "Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
@@ -225,6 +226,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
|
||||
AC474BFB29BBD4A1002BDAED /* RNTester.xctestplan */,
|
||||
E771AEEA22B44E3100EA1189 /* Info.plist */,
|
||||
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
|
||||
5C60EB1B226440DB0018C04F /* AppDelegate.mm */,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1210"
|
||||
version = "1.3">
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
@@ -27,44 +27,12 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "NO">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
|
||||
BuildableName = "RNTester.app"
|
||||
BlueprintName = "RNTester"
|
||||
ReferencedContainer = "container:RNTesterPods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "CI_USE_PACKAGER"
|
||||
value = "1"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E7DB215222B2F332005AC45F"
|
||||
BuildableName = "RNTesterIntegrationTests.xctest"
|
||||
BlueprintName = "RNTesterIntegrationTests"
|
||||
ReferencedContainer = "container:RNTesterPods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E7DB209E22B2BA84005AC45F"
|
||||
BuildableName = "RNTesterUnitTests.xctest"
|
||||
BlueprintName = "RNTesterUnitTests"
|
||||
ReferencedContainer = "container:RNTesterPods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<TestPlans>
|
||||
<TestPlanReference
|
||||
reference = "container:RNTester/RNTester.xctestplan"
|
||||
default = "YES">
|
||||
</TestPlanReference>
|
||||
</TestPlans>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
|
||||
Reference in New Issue
Block a user