Skip to content

Commit 9b2a080

Browse files
committed
feat(iOS): merge debug and release versions
1 parent 8213ca5 commit 9b2a080

File tree

97 files changed

+74
-16744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+74
-16744
lines changed

README.md

Lines changed: 36 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ freeRASP for React Native is a mobile in-app protection and security monitoring
1414
- [(Optional) Create a new React Native demo application](#optional-create-a-new-react-native-demo-application)
1515
- [Step 1: Install the plugin](#step-1-install-the-plugin)
1616
- [Step 2: Set up the dependencies](#step-2-set-up-the-dependencies)
17-
- [Step 3: Dev vs Release version](#step-3-dev-vs-release-version)
18-
- [Step 4: Import freeRASP into the app](#step-4-import-freerasp-into-the-app)
19-
- [Step 5: Setup the configuration, callbacks and initialize freeRASP](#step-5-setup-the-configuration-callbacks-and-initialize-freerasp)
20-
- [Step 6: Additional note about obfuscation](#step-6-additional-note-about-obfuscation)
21-
- [Step 7: User Data Policies](#step-7-user-data-policies)
17+
- [Step 3: Import freeRASP into the app](#step-3-import-freerasp-into-the-app)
18+
- [Step 4: Setup the configuration, callbacks and initialize freeRASP](#step-4-setup-the-configuration-callbacks-and-initialize-freerasp)
19+
- [Step 5: Additional note about obfuscation](#step-5-additional-note-about-obfuscation)
20+
- [Step 6: User Data Policies](#step-6-user-data-policies)
2221
- [Security Report](#security-report)
2322
- [Enterprise Services](#bar_chart-enterprise-services)
2423
- [Commercial version](#commercial-version)
@@ -96,86 +95,56 @@ freeRASP React Native plugin uses Pods. Navigate to the `ios` folder and run:
9695

9796
$ pod install
9897

99-
## Step 3: Dev vs Release version
98+
## Step 3: Import freeRASP into the app
10099

101-
The Dev version is used to not complicate the development process of the application, e.g. if you would implement killing of the application on the debugger callback. It disables some checks which won't be triggered during the development process:
100+
We provide a custom hook that handles all required logic as registration of freeRASP, mounting and unmounting of listeners for you. Import the hook into your app:
102101

103-
- Emulator-usage (simulator)
104-
- Debugging (debug)
105-
- Signing (appIntegrity)
106-
- Unofficial store (unofficialStore)
102+
```ts
103+
import { useFreeRasp } from 'freerasp-react-native';
104+
```
107105

108-
Which version of freeRASP is used is tied to the application's development stage - more precisely, how the application is compiled.
106+
## Step 4: Setup the configuration, callbacks and initialize freeRASP
109107

110-
### Android
108+
First, the configuration and callbacks will be explained. Then the [Initialization](#initialization) chapter shows the implementation.
111109

112-
Android implementation of the React Native plugin detects selected development stage and automatically applies the suitable version of the library.
110+
### Configuration
113111

114-
- `npx react-native run-android` (debug) -> uses dev version of freeRASP
115-
- `npx react-native run-android --variant release` (release) -> uses release version of freeRASP
112+
You need to provide configuration for freeRASP to work properly and initialize it. The freeRASP configuration is an JavaScript object that contains configs for both Android and iOS, as well as common configuration. You must fill all the required values for the plugin to work. If you are developing for just one platform, you can skip configuration of the other.
116113

117-
### iOS
114+
#### Android configuration:
118115

119-
For the iOS implemtation, it's neccesary to add script into the Xcode environment, that automatically switches between the library dev/release versions according to selected development stage. Then, it is necessary to embedd a symlink to correct TalsecRuntime.xcframework.
120-
121-
1. Add pre-built script for changing the Debug and Release versions of the framework:
122-
- Open up the **.xcworkspace** file
123-
- Go to **Product** -> **Scheme** -> **Edit Scheme...** -> **Build (dropdown arrow)** -> **Pre-actions**
124-
- Hit **+** and then **New Run Script Action**
125-
- Set **Provide build setting from** to your application
126-
- Copy-paste following script:
127-
```shell
128-
cd "${SRCROOT}/../node_modules/freerasp-react-native/ios"
129-
if [ "${CONFIGURATION}" = "Release" ]; then
130-
rm -rf ./TalsecRuntime.xcframework
131-
ln -s ./Release/TalsecRuntime.xcframework/ TalsecRuntime.xcframework
132-
else
133-
rm -rf ./TalsecRuntime.xcframework
134-
ln -s ./Debug/TalsecRuntime.xcframework/ TalsecRuntime.xcframework
135-
fi
136-
```
137-
- **Close**
138-
2. Add dependency on the symlink
139-
- Go to your **Target** -> **Build Phases** -> **Link Binary With Libraries**
140-
- Add dependency (drag & drop right after **libPods**) on the symlink on the following location:
141-
_AwesomeProject/node_modules/freerasp-react-native/ios/TalsecRuntime.xcframework_
142-
- If there is no symlink, try to create it manually in that folder by the following command:
143-
- $ ln -s ./Debug/TalsecRuntime.xcframework/ TalsecRuntime.xcframework
144-
145-
Followingly:
146-
147-
- `npx react-native run-ios` (debug) -> uses dev version of freeRASP
148-
- `npx react-native run-ios --configuration Release` (release) -> uses release version of freeRASP
149-
150-
## Step 4: Import freeRASP into the app
116+
Create an object under `androidConfig` key with following entries:
151117

152-
We provide a custom hook that handles all required logic as registration of freeRASP, mounting and unmounting of listeners for you. Import the hook into your app:
118+
- `packageName` _: string_ - package name of your app you chose when you created it
119+
- `certificateHashes` _: string[]_ - hash of the certificate of the key which was used to sign the application. **Hash which is passed here must be encoded in Base64 form.** If you are not sure how to get your certificate hash, you can check out the guide on our [Github wiki](https://github.com/talsec/Free-RASP-Community/wiki/Getting-your-signing-certificate-hash-of-app). Multiple hashes are supported, e.g. if you are using a different one for the Huawei App Gallery.
120+
- `supportedAlternativeStores` _: string[] | undefined_ - If you publish on the Google Play Store and/or Huawei AppGallery, you **don't have to assign anything** there as those are supported out of the box.
153121

154-
```ts
155-
import { useFreeRasp } from 'freerasp-react-native';
156-
```
122+
#### iOS configuration
157123

158-
## Step 5: Setup the configuration, callbacks and initialize freeRASP
124+
Create an object under `iosConfig` key with following entries:
159125

160-
First, the configuration and callbacks will be explained. Then the **Initialization** chapter shows the implementation.
126+
- `appBundleId` _: string_ - Bundle ID of your app
127+
- `appTeamId` _: string_ - the Apple Team ID
161128

162-
### Configuration
129+
#### Common configuration
163130

164-
You need to provide configuration for freeRASP to work properly and initialize it. The freeRASP configuration contains configs for both Android and iOS. You must fill all the required values for the plugin to work.
131+
Lastly, set up common configuration for both iOS and Android:
165132

166-
For Android:
133+
- `watcherMail` _: string_ - your mail address where you wish to receive reports. Mail has a strict form `[email protected]` which is passed as String.
134+
- `isProd` _: boolean | undefined_ - defaults to `true` when undefined. If you want to use the Dev version to disable checks described [in the chapter below](#dev-vs-release-version), set the parameter to `false`. Make sure that you have the Release version in the production (i.e. isProd set to true)!
167135

168-
- `packageName` - package name of your app you chose when you created it
169-
- `certificateHashes` - hash of the certificate of the key which was used to sign the application. **Hash which is passed here must be encoded in Base64 form.** If you are not sure how to get your certificate hash, you can check out the guide on our [Github wiki](https://github.com/talsec/Free-RASP-Community/wiki/Getting-your-signing-certificate-hash-of-app). Multiple hashes are supported, e.g. if you are using a different one for the Huawei App Gallery.
170-
- `supportedAlternativeStores` _(optional)_ - If you publish on the Google Play Store and/or Huawei AppGallery, you **don't have to assign anything** there as those are supported out of the box.
136+
### Dev vs Release version
171137

172-
For iOS similarly to Android, `appBundleId` and `appTeamId` are required.
138+
The Dev version is used to not complicate the development process of the application, e.g. if you would implement killing of the application on the debugger callback. It disables some checks which won't be triggered during the development process:
173139

174-
Lastly, pass a mail address to `watcherMail` to be able to get reports. Mail has a strict form `[email protected]` which is passed as String.
140+
- Emulator-usage (simulator)
141+
- Debugging (debug)
142+
- Signing (appIntegrity)
143+
- Unofficial store (unofficialStore)
175144

176145
### Callbacks
177146

178-
freeRASP executes periodical checks when the application is running. Handle the detected threats in the **listeners**. For example, you can log the event, show a window to the user or kill the application. Visit our [wiki](https://github.com/talsec/Free-RASP-Community/wiki/Threat-detection) to learn more details about the performed checks and their importance for app security.
147+
freeRASP executes periodical checks when the application is running. Handle the detected threats in the **listeners**. For example, you can log the event, show a window to the user or kill the application. [Visit our wiki](https://github.com/talsec/Free-RASP-Community/wiki/Threat-detection) to learn more details about the performed checks and their importance for app security.
179148

180149
### Initialization
181150

@@ -249,9 +218,9 @@ useFreeRasp(config, actions);
249218

250219
When freeRASP initializes correctly, you should see `freeRASP initialized` message in logs. Otherwise, you'll see warning with description of what went wrong.
251220

252-
_You can override this default behavior by extending the `actions` object with `'started'` key (to change action after successful initialization), and `'initializationError'` key (to set up action after unsuccessful initialization)_
221+
_You can override this default behavior by extending the `actions` object with `started` key (to change action after successful initialization), and `initializationError` key (to set up action after unsuccessful initialization)_
253222

254-
## Step 6: Additional note about obfuscation
223+
## Step 5: Additional note about obfuscation
255224

256225
The freeRASP contains public API, so the integration process is as simple as possible. Unfortunately, this public API also creates opportunities for the attacker to use publicly available information to interrupt freeRASP operations or modify your custom reaction implementation in threat callbacks. In order for freeRASP to be as effective as possible, it is highly recommended to apply obfuscation to the final package/application, making the public API more difficult to find and also partially randomized for each application so it cannot be automatically abused by generic hooking scripts.
257226

@@ -278,7 +247,7 @@ android {
278247
}
279248
```
280249

281-
## Step 7: User Data Policies
250+
## Step 6: User Data Policies
282251

283252
Google Play [requires](https://support.google.com/googleplay/android-developer/answer/10787469?hl=en) all app publishers to declare how they collect and handle user data for the apps they publish on Google Play. They should inform users properly of the data collected by the apps and how the data is shared and processed. Therefore, Google will reject the apps which do not comply with the policy.
284253

example/ios/FreeraspReactNativeExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1515
7699B88040F8A987B510C191 /* libPods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests.a */; };
1616
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
17-
A41E05192962BAB100B363A8 /* TalsecRuntime.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A44E6986295D7CAB000A719C /* TalsecRuntime.xcframework */; };
1817
/* End PBXBuildFile section */
1918

2019
/* Begin PBXContainerItemProxy section */
@@ -44,6 +43,8 @@
4443
5DCACB8F33CDC322A6C60F78 /* libPods-FreeraspReactNativeExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FreeraspReactNativeExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4544
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = FreeraspReactNativeExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
4645
89C6BE57DB24E9ADA2F236DE /* Pods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests.release.xcconfig"; path = "Target Support Files/Pods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests/Pods-FreeraspReactNativeExample-FreeraspReactNativeExampleTests.release.xcconfig"; sourceTree = "<group>"; };
46+
8C2BD8B529DF06E4000304E9 /* Talsec */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Talsec; path = ../../ios/Talsec; sourceTree = "<group>"; };
47+
8C2BD8BB29DF0976000304E9 /* TalsecRuntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = TalsecRuntime.xcframework; path = ../../ios/Talsec/TalsecRuntime.xcframework; sourceTree = "<group>"; };
4748
A41E05172962B9FD00B363A8 /* TalsecRuntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = TalsecRuntime.xcframework; path = "../../../../React/test2/someTestProject/node_modules/freerasp-react-native/ios/TalsecRuntime.xcframework"; sourceTree = "<group>"; };
4849
A44E6986295D7CAB000A719C /* TalsecRuntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = TalsecRuntime.xcframework; path = ../../ios/TalsecRuntime.xcframework; sourceTree = "<group>"; };
4950
A44E698B295D7E12000A719C /* TalsecRuntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = TalsecRuntime.xcframework; path = ../../ios/Debug/TalsecRuntime.xcframework; sourceTree = "<group>"; };
@@ -65,7 +66,6 @@
6566
buildActionMask = 2147483647;
6667
files = (
6768
0C80B921A6F3F58F76C31292 /* libPods-FreeraspReactNativeExample.a in Frameworks */,
68-
A41E05192962BAB100B363A8 /* TalsecRuntime.xcframework in Frameworks */,
6969
);
7070
runOnlyForDeploymentPostprocessing = 0;
7171
};
@@ -105,6 +105,8 @@
105105
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
106106
isa = PBXGroup;
107107
children = (
108+
8C2BD8BB29DF0976000304E9 /* TalsecRuntime.xcframework */,
109+
8C2BD8B529DF06E4000304E9 /* Talsec */,
108110
A44E6986295D7CAB000A719C /* TalsecRuntime.xcframework */,
109111
A44E698B295D7E12000A719C /* TalsecRuntime.xcframework */,
110112
A44E69A2295DA98F000A719C /* TalsecRuntime.xcframework */,

example/ios/FreeraspReactNativeExample.xcodeproj/xcshareddata/xcschemes/FreeraspReactNativeExample.xcscheme

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
33
LastUpgradeVersion = "1210"
4-
version = "1.7">
4+
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8-
<PreActions>
9-
<ExecutionAction
10-
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
11-
<ActionContent
12-
title = "Run Script"
13-
scriptText = "cd &quot;${SRCROOT}/../../ios&quot;&#10;if [ &quot;${CONFIGURATION}&quot; = &quot;Release&quot; ]; then&#10; rm -rf ./TalsecRuntime.xcframework&#10; ln -s ./Release/TalsecRuntime.xcframework/ TalsecRuntime.xcframework&#10;else&#10; rm -rf ./TalsecRuntime.xcframework&#10; ln -s ./Debug/TalsecRuntime.xcframework/ TalsecRuntime.xcframework&#10;fi &#10;">
14-
<EnvironmentBuildable>
15-
<BuildableReference
16-
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
18-
BuildableName = "FreeraspReactNativeExample.app"
19-
BlueprintName = "FreeraspReactNativeExample"
20-
ReferencedContainer = "container:FreeraspReactNativeExample.xcodeproj">
21-
</BuildableReference>
22-
</EnvironmentBuildable>
23-
</ActionContent>
24-
</ExecutionAction>
25-
</PreActions>
268
<BuildActionEntries>
279
<BuildActionEntry
2810
buildForTesting = "YES"

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ SPEC CHECKSUMS:
548548
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
549549
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
550550
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
551-
freerasp-react-native: 402dcc7a34804b8ae4805f18c79666e606d24b1e
551+
freerasp-react-native: 68f18a583428d1bbb484228abdb3b9cd258795b4
552552
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
553553
hermes-engine: 2af7b7a59128f250adfd86f15aa1d5a2ecd39995
554554
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913

example/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const App = () => {
2222
appTeamId: 'your_team_ID',
2323
},
2424
watcherMail: '[email protected]',
25+
isProd: true,
2526
};
2627

2728
const actions = {

freerasp-react-native.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
1515
s.source = { :git => "https://github.com/talsec/freerasp-react-native.git", :tag => "#{s.version}" }
1616

1717
s.source_files = "ios/**/*.{h,m,mm,swift}"
18-
s.ios.vendored_frameworks = "ios/Debug/TalsecRuntime.xcframework"
18+
s.ios.vendored_frameworks = "ios/TalsecRuntime.xcframework"
1919

2020
s.dependency "React-Core"
2121

ios/Debug/TalsecRuntime.xcframework/Info.plist

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)