Skip to content

Commit 48e2553

Browse files
authored
Merge pull request #96 from talsec/add-adb
feat: add ADB detection callback
2 parents 2d8c33d + d342659 commit 48e2553

File tree

10 files changed

+40
-5
lines changed

10 files changed

+40
-5
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.11.0] - 2024-11-19
9+
10+
### React Native
11+
12+
#### Added
13+
14+
- Added `adbEnabled` callback, which allows you to detect USB debugging option enabled in the developer settings on the device
15+
16+
### Android
17+
18+
#### Added
19+
20+
- ADB detection feature
21+
822
## [3.10.0] - 2024-11-15
923

1024
- Android SDK version: 12.0.0

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ dependencies {
9090
implementation "com.facebook.react:react-native:$react_native_version"
9191
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
9292
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
93-
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:12.0.0"
93+
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:13.0.0"
9494
}
9595

9696
if (isNewArchitectureEnabled()) {

android/src/main/java/com/freeraspreactnative/FreeraspThreatHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ internal object FreeraspThreatHandler : ThreatListener.ThreatDetected, ThreatLis
5555
listener?.threatDetected(Threat.DevMode)
5656
}
5757

58+
override fun onADBEnabledDetected() {
59+
listener?.threatDetected(Threat.ADBEnabled)
60+
}
61+
5862
override fun onSystemVPNDetected() {
5963
listener?.threatDetected(Threat.SystemVPN)
6064
}

android/src/main/java/com/freeraspreactnative/Threat.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ internal sealed class Threat(val value: Int) {
2424
object SystemVPN : Threat((10000..999999999).random())
2525
object DevMode : Threat((10000..999999999).random())
2626
object Malware : Threat((10000..999999999).random())
27+
object ADBEnabled : Threat((10000..999999999).random())
2728

2829
companion object {
2930
internal fun getThreatValues(): WritableArray {
@@ -41,7 +42,8 @@ internal sealed class Threat(val value: Int) {
4142
UnofficialStore.value,
4243
ObfuscationIssues.value,
4344
DevMode.value,
44-
Malware.value
45+
Malware.value,
46+
ADBEnabled.value
4547
)
4648
)
4749
}

example/src/App.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const App = () => {
3232
// supportedAlternativeStores: ['storeOne', 'storeTwo'],
3333
malwareConfig: {
3434
blacklistedHashes: ['FgvSehLMM91E7lX/Zqp3u4jMmd0A7hH/Iqozu0TMVd0u'],
35-
blacklistedPackageNames: ['com.wultra.app.screenlogger'],
35+
blacklistedPackageNames: ['com.freeraspreactnativeexample'],
3636
suspiciousPermissions: [
3737
[
3838
'android.permission.INTERNET',
@@ -45,7 +45,7 @@ const App = () => {
4545
},
4646
},
4747
iosConfig: {
48-
appBundleId: 'com.freeraspreactnativeexample',
48+
appBundleId: 'org.reactjs.native.example.FreeraspReactNativeExample',
4949
appTeamId: 'your_team_ID',
5050
},
5151
watcherMail: '[email protected]',
@@ -180,6 +180,14 @@ const App = () => {
180180
)
181181
);
182182
},
183+
// Android only
184+
adbEnabled: () => {
185+
setAppChecks((currentState) =>
186+
currentState.map((threat) =>
187+
threat.name === 'ADB Enabled' ? { ...threat, status: 'nok' } : threat
188+
)
189+
);
190+
},
183191
};
184192

185193
const addItemsToMalwareWhitelist = async () => {

example/src/checks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export const androidChecks = [
1717
{ name: 'Obfuscation Issues', status: 'ok' },
1818
{ name: 'Developer Mode', status: 'ok' },
1919
{ name: 'Malware', status: 'ok' },
20+
{ name: 'ADB Enabled', status: 'ok' },
2021
];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "freerasp-react-native",
3-
"version": "3.10.0",
3+
"version": "3.11.0",
44
"description": "React Native plugin for improving app security and threat monitoring on Android and iOS mobile devices.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export const setThreatListeners = async <T extends NativeEventEmitterActions>(
117117
case Threat.Malware.value:
118118
config.malware?.(parseMalwareData(event[malwareKey]));
119119
break;
120+
case Threat.ADBEnabled.value:
121+
config.adbEnabled?.();
122+
break;
120123
default:
121124
onInvalidCallback();
122125
break;

src/threat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class Threat {
1717
static ObfuscationIssues = new Threat(0);
1818
static DevMode = new Threat(0);
1919
static Malware = new Threat(0);
20+
static ADBEnabled = new Threat(0);
2021

2122
constructor(value: number) {
2223
this.value = value;
@@ -38,6 +39,7 @@ export class Threat {
3839
this.ObfuscationIssues,
3940
this.DevMode,
4041
this.Malware,
42+
this.ADBEnabled,
4143
]
4244
: [
4345
this.AppIntegrity,

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ export type NativeEventEmitterActions = {
5252
devMode?: () => any;
5353
systemVPN?: () => any;
5454
malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;
55+
adbEnabled?: () => any;
5556
};

0 commit comments

Comments
 (0)