Skip to content

Commit c2b44c5

Browse files
authored
feat: stop closing the app on threat detection (temporary solution) (#1161)
1 parent d284234 commit c2b44c5

File tree

10 files changed

+4
-106
lines changed

10 files changed

+4
-106
lines changed

android/app/capacitor.build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dependencies {
2424
implementation project(':capacitor-splash-screen')
2525
implementation project(':capacitor-status-bar')
2626
implementation project(':evva-capacitor-secure-storage-plugin')
27-
implementation project(':jimcase-capacitor-exit-app')
2827
implementation project(':capacitor-freerasp')
2928
implementation project(':capacitor-native-settings')
3029
implementation project(':capacitor-plugin-safe-area')

android/capacitor.settings.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacit
4747
include ':evva-capacitor-secure-storage-plugin'
4848
project(':evva-capacitor-secure-storage-plugin').projectDir = new File('../node_modules/@evva/capacitor-secure-storage-plugin/android')
4949

50-
include ':jimcase-capacitor-exit-app'
51-
project(':jimcase-capacitor-exit-app').projectDir = new File('../node_modules/@jimcase/capacitor-exit-app/android')
52-
5350
include ':capacitor-freerasp'
5451
project(':capacitor-freerasp').projectDir = new File('../node_modules/capacitor-freerasp/android')
5552

ios/App/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def capacitor_pods
2626
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
2727
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
2828
pod 'EvvaCapacitorSecureStoragePlugin', :path => '../../node_modules/@evva/capacitor-secure-storage-plugin'
29-
pod 'JimcaseCapacitorExitApp', :path => '../../node_modules/@jimcase/capacitor-exit-app'
3029
pod 'CapacitorFreerasp', :path => '../../node_modules/capacitor-freerasp'
3130
pod 'CapacitorNativeSettings', :path => '../../node_modules/capacitor-native-settings'
3231
pod 'CapacitorPluginSafeArea', :path => '../../node_modules/capacitor-plugin-safe-area'

ios/App/Podfile.lock

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ PODS:
6565
- GoogleUtilities/Logger
6666
- GoogleUtilities/Privacy
6767
- GTMSessionFetcher/Core (3.5.0)
68-
- JimcaseCapacitorExitApp (1.0.7):
69-
- Capacitor
7068
- MLImage (1.0.0-beta6)
7169
- MLKitBarcodeScanning (6.0.0):
7270
- MLKitCommon (~> 12.0)
@@ -119,7 +117,6 @@ DEPENDENCIES:
119117
- "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)"
120118
- "CapacitorStatusBar (from `../../node_modules/@capacitor/status-bar`)"
121119
- "EvvaCapacitorSecureStoragePlugin (from `../../node_modules/@evva/capacitor-secure-storage-plugin`)"
122-
- "JimcaseCapacitorExitApp (from `../../node_modules/@jimcase/capacitor-exit-app`)"
123120

124121
SPEC REPOS:
125122
trunk:
@@ -179,8 +176,6 @@ EXTERNAL SOURCES:
179176
:path: "../../node_modules/@capacitor/status-bar"
180177
EvvaCapacitorSecureStoragePlugin:
181178
:path: "../../node_modules/@evva/capacitor-secure-storage-plugin"
182-
JimcaseCapacitorExitApp:
183-
:path: "../../node_modules/@jimcase/capacitor-exit-app"
184179

185180
SPEC CHECKSUMS:
186181
AparajitaCapacitorBiometricAuth: 3057403ee3e9e390e57bfb92b576f439157951b8
@@ -208,7 +203,6 @@ SPEC CHECKSUMS:
208203
GoogleToolboxForMac: d1a2cbf009c453f4d6ded37c105e2f67a32206d8
209204
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
210205
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
211-
JimcaseCapacitorExitApp: 499b429827d7d0cacf1b7a0faf18bf88e4b6cc78
212206
MLImage: 0ad1c5f50edd027672d8b26b0fee78a8b4a0fc56
213207
MLKitBarcodeScanning: 0a3064da0a7f49ac24ceb3cb46a5bc67496facd2
214208
MLKitCommon: 07c2c33ae5640e5380beaaa6e4b9c249a205542d
@@ -219,6 +213,6 @@ SPEC CHECKSUMS:
219213
SQLCipher: 77fbe633cd84db04b07876dd50766b4924b57d61
220214
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
221215

222-
PODFILE CHECKSUM: ef0d222c85763e963d3ab216ae37e81f4007042b
216+
PODFILE CHECKSUM: edddec9e8109b205b25d5fc1413526aaa8b9f97f
223217

224218
COCOAPODS: 1.15.2

ios/xcconfig-overwrites/JimcaseCapacitorExitApp/JimcaseCapacitorExitApp.xcconfig

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

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"@ionic/react": "^8.4.3",
4444
"@ionic/react-router": "^8.4.3",
4545
"@ionic/storage": "^3.0.6",
46-
"@jimcase/capacitor-exit-app": "^1.0.7",
4746
"@reduxjs/toolkit": "^1.9.5",
4847
"bip39": "^3.0.4",
4948
"capacitor-freerasp": "^1.10.0",

src/security/freerasp.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ export enum ThreatName {
2222
DEVICE_ID = "Device ID",
2323
}
2424

25-
export const EMULATOR_THREATS = [
26-
ThreatName.SIMULATOR,
27-
ThreatName.SECURE_HARDWARE_NOT_AVAILABLE,
28-
];
29-
3025
export interface ThreatCheck {
3126
name: ThreatName;
3227
description: string;

src/ui/App.test.tsx

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Provider } from "react-redux";
44
import { MemoryRouter } from "react-router-dom";
55
import configureStore from "redux-mock-store";
66
import { startFreeRASP } from "capacitor-freerasp";
7-
import { ExitApp } from "@jimcase/capacitor-exit-app";
87
import { IdentifierService } from "../core/agent/services";
98
import Eng_Trans from "../locales/en/en.json";
109
import { TabsRoutePath } from "../routes/paths";
@@ -22,12 +21,6 @@ import {
2221
} from "./globals/constants";
2322
import { InitializationPhase } from "../store/reducers/stateCache/stateCache.types";
2423

25-
jest.mock("@jimcase/capacitor-exit-app", () => ({
26-
ExitApp: {
27-
exitApp: jest.fn(),
28-
},
29-
}));
30-
3124
jest.mock("capacitor-freerasp", () => ({
3225
startFreeRASP: jest.fn(),
3326
}));
@@ -903,33 +896,7 @@ describe("System threat alert", () => {
903896
});
904897
});
905898

906-
test("Catch a threat and close the app on start", async () => {
907-
startFreeRASPMock = startFreeRASP as jest.Mock;
908-
startFreeRASPMock.mockResolvedValue(true);
909-
910-
render(
911-
<Provider store={storeMocked}>
912-
<App />
913-
</Provider>
914-
);
915-
916-
await waitFor(() => {
917-
expect(startFreeRASPMock).toHaveBeenCalled();
918-
});
919-
920-
await act(async () => {
921-
const privilegedAccessAction = (startFreeRASPMock.mock.calls[0][1] as any)
922-
.privilegedAccess;
923-
924-
privilegedAccessAction();
925-
});
926-
927-
await waitFor(() => {
928-
expect(ExitApp.exitApp).toBeCalled();
929-
});
930-
});
931-
932-
test("Catch emulator threat and avoid closing the app", async () => {
899+
test("Catch a threat and show SystemThreatAlert", async () => {
933900
startFreeRASPMock = startFreeRASP as jest.Mock;
934901
startFreeRASPMock.mockResolvedValue(true);
935902

@@ -953,11 +920,10 @@ describe("System threat alert", () => {
953920
await waitFor(() => {
954921
expect(getByText("Threats Detected")).toBeVisible();
955922
expect(getByText(Eng_Trans.systemthreats.rules.simulator)).toBeVisible();
956-
expect(ExitApp.exitApp).not.toBeCalled();
957923
});
958924
});
959925

960-
test("Catches a threat and close the app after renders SetUserName modal", async () => {
926+
test("Catches a threat after renders SetUserName modal", async () => {
961927
const initialState = {
962928
stateCache: {
963929
routes: [{ path: TabsRoutePath.ROOT }],

src/ui/App.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from "@ionic/react";
1111
import { IonReactRouter } from "@ionic/react-router";
1212
import { StrictMode, useEffect, useState } from "react";
13-
import { ExitApp } from "@jimcase/capacitor-exit-app";
1413
import { SafeArea } from "capacitor-plugin-safe-area";
1514
import { Routes } from "../routes";
1615
import { useAppDispatch, useAppSelector } from "../store/hooks";
@@ -43,12 +42,7 @@ import {
4342
} from "./globals/constants";
4443
import { InitializationPhase } from "../store/reducers/stateCache/stateCache.types";
4544
import { LoadingType } from "./pages/LoadingPage/LoadingPage.types";
46-
import {
47-
EMULATOR_THREATS,
48-
initializeFreeRASP,
49-
ThreatCheck,
50-
ThreatName,
51-
} from "../security/freerasp";
45+
import { initializeFreeRASP, ThreatCheck } from "../security/freerasp";
5246
import { SystemThreatAlert } from "./pages/SystemThreatAlert/SystemThreatAlert";
5347
import { ConfigurationService } from "../core/configuration";
5448
import { i18n } from "../i18n";
@@ -93,22 +87,6 @@ const App = () => {
9387
initConfiguration();
9488
}, []);
9589

96-
const checkSecurity = () => {
97-
if (isFreeRASPInitialized && Capacitor.isNativePlatform()) {
98-
const threats = threatsDetected.filter(
99-
(threat) => !EMULATOR_THREATS.includes(threat.name)
100-
);
101-
if (threats.length > 0) {
102-
ExitApp.exitApp();
103-
}
104-
}
105-
};
106-
107-
useEffect(() => {
108-
if (!Capacitor.isNativePlatform()) return;
109-
checkSecurity();
110-
}, [isFreeRASPInitialized, threatsDetected]);
111-
11290
useEffect(() => {
11391
const handleUnknownPromiseError = (event: PromiseRejectionEvent) => {
11492
event.preventDefault();

0 commit comments

Comments
 (0)