-
Notifications
You must be signed in to change notification settings - Fork 18
release: freeRASP 4.4.0 #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8baf864
9c3ea5e
f96752d
40618e4
570c124
848b36d
2a611ec
a70a4b9
a9ba177
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| FreeraspReactNative_kotlinVersion=2.1.0 | ||
| FreeraspReactNative_minSdkVersion=23 | ||
| FreeraspReactNative_targetSdkVersion=35 | ||
| FreeraspReactNative_compileSdkVersion=35 | ||
| FreeraspReactNative_targetSdkVersion=36 | ||
| FreeraspReactNative_compileSdk=36 | ||
| FreeraspReactNative_ndkversion=21.4.7075529 | ||
| FreeraspReactNative_reactNativeVersion=+ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule | |
| import com.freeraspreactnative.events.BaseRaspEvent | ||
| import com.freeraspreactnative.events.RaspExecutionStateEvent | ||
| import com.freeraspreactnative.events.ThreatEvent | ||
| import com.freeraspreactnative.interfaces.WrapperExecutionStateListener | ||
| import com.freeraspreactnative.interfaces.WrapperThreatListener | ||
| import com.freeraspreactnative.utils.Utils | ||
| import com.freeraspreactnative.utils.getArraySafe | ||
| import com.freeraspreactnative.utils.getBooleanSafe | ||
|
|
@@ -33,7 +35,12 @@ import com.freeraspreactnative.utils.toEncodedWritableArray | |
| class FreeraspReactNativeModule(private val reactContext: ReactApplicationContext) : | ||
| ReactContextBaseJavaModule(reactContext) { | ||
|
|
||
| private val listener = ThreatListener(FreeraspThreatHandler, FreeraspThreatHandler, FreeraspThreatHandler) | ||
| private val listener = ThreatListener( | ||
| WrapperThreatHandler.threatDetected, | ||
| WrapperThreatHandler.deviceState, | ||
| WrapperThreatHandler.raspExecutionState | ||
| ) | ||
|
|
||
| private val lifecycleListener = object : LifecycleEventListener { | ||
| override fun onHostResume() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { | ||
|
|
@@ -69,7 +76,6 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| try { | ||
| val config = buildTalsecConfig(options) | ||
| FreeraspThreatHandler.listener = ThreatListener | ||
| listener.registerListener(reactContext) | ||
| runOnUiThread { | ||
| Talsec.start(reactContext, config, TalsecMode.BACKGROUND) | ||
|
|
@@ -147,13 +153,30 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
| } | ||
|
|
||
| @ReactMethod | ||
| fun addListener(@Suppress("UNUSED_PARAMETER") eventName: String) { | ||
| // Set up any upstream listeners or background tasks as necessary | ||
| fun addListener(eventName: String) { | ||
| if (eventName == ThreatEvent.CHANNEL_NAME) { | ||
| WrapperThreatHandler.threatDispatcher.listener = WrapperListener | ||
| } | ||
| if (eventName == RaspExecutionStateEvent.CHANNEL_NAME) { | ||
| WrapperThreatHandler.executionStateDispatcher.listener = WrapperListener | ||
| } | ||
| } | ||
|
|
||
| @ReactMethod | ||
| fun removeListeners(@Suppress("UNUSED_PARAMETER") count: Int) { | ||
| // Remove upstream listeners, stop unnecessary background tasks | ||
| // built-in RN method, however it does not suit us as it just tells | ||
| // number of un-registered listeners, so we use `removeListenerForEvent` | ||
| } | ||
|
|
||
| @ReactMethod | ||
| fun removeListenerForEvent(eventName: String, promise: Promise) { | ||
| if (eventName == ThreatEvent.CHANNEL_NAME) { | ||
| WrapperThreatHandler.threatDispatcher.listener = null | ||
| } | ||
| if (eventName == RaspExecutionStateEvent.CHANNEL_NAME) { | ||
| WrapperThreatHandler.executionStateDispatcher.listener = null | ||
| } | ||
| promise.resolve("Listener unregistered") | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -218,17 +241,17 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| @ReactMethod | ||
| fun storeExternalId( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Talsec.storeExternalId method now enforces value restrictions (regex) and returns an ExternalIdResult instead of void. Your current implementation ignores this return value and always resolves the promise with "OK". This means if an invalid externalId is passed, the native side will reject it, but the React Native app will incorrectly think it was saved successfully. |
||
| externalId: String, promise: Promise | ||
| externalId: String, promise: Promise | ||
| ) { | ||
| try { | ||
| Talsec.storeExternalId(reactContext, externalId) | ||
| promise.resolve("OK - Store external ID") | ||
| } catch (e: Exception) { | ||
| promise.reject( | ||
| "NativePluginError", | ||
| "Error during storeExternalId operation in Talsec Native Plugin" | ||
| ) | ||
| } | ||
| try { | ||
| Talsec.storeExternalId(reactContext, externalId) | ||
| promise.resolve("OK - Store external ID") | ||
| } catch (e: Exception) { | ||
| promise.reject( | ||
| "NativePluginError", | ||
| "Error during storeExternalId operation in Talsec Native Plugin" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private fun buildTalsecConfig(config: ReadableMap): TalsecConfig { | ||
|
|
@@ -294,7 +317,7 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
| } | ||
| } | ||
|
|
||
| internal object ThreatListener : FreeraspThreatHandler.TalsecReactNative { | ||
| internal object WrapperListener : WrapperThreatListener, WrapperExecutionStateListener { | ||
| override fun threatDetected(threatEventType: ThreatEvent) { | ||
| notifyEvent(threatEventType) | ||
| } | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have 18.0.2, could you please use that version?