-
Notifications
You must be signed in to change notification settings - Fork 16
release: freeRASP 4.3.0 #125
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
Open
tompsota
wants to merge
8
commits into
master
Choose a base branch
from
rc/4.3.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c7f8843
add implementation
tompsota 7817025
feat: refactor ios
tompsota de12a24
feat: add permissions, killOnBypass
tompsota a758598
fix: resolve potential collision with threat identifiers
tompsota 3a4dc1f
fix: update identifiers on ios
tompsota ead2fd5
chore: bump android to 17.0.1
tompsota 393ab9e
chore: remove unused file
tompsota fef4ad3
chore: fix ios podspec
tompsota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,11 @@ import android.os.Build | |
| import android.os.Handler | ||
| import android.os.HandlerThread | ||
| import android.os.Looper | ||
| import android.util.Log | ||
| import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo | ||
| import com.aheaditec.talsec_security.security.api.Talsec | ||
| import com.aheaditec.talsec_security.security.api.TalsecConfig | ||
| import com.aheaditec.talsec_security.security.api.TalsecMode | ||
| import com.aheaditec.talsec_security.security.api.ThreatListener | ||
| import com.facebook.react.bridge.Arguments | ||
| import com.facebook.react.bridge.LifecycleEventListener | ||
|
|
@@ -18,6 +20,9 @@ import com.facebook.react.bridge.ReadableMap | |
| import com.facebook.react.bridge.UiThreadUtil.runOnUiThread | ||
| import com.facebook.react.bridge.WritableArray | ||
| 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.utils.Utils | ||
| import com.freeraspreactnative.utils.getArraySafe | ||
| import com.freeraspreactnative.utils.getBooleanSafe | ||
|
|
@@ -29,7 +34,7 @@ import com.freeraspreactnative.utils.toEncodedWritableArray | |
| class FreeraspReactNativeModule(private val reactContext: ReactApplicationContext) : | ||
| ReactContextBaseJavaModule(reactContext) { | ||
|
|
||
| private val listener = ThreatListener(FreeraspThreatHandler, FreeraspThreatHandler) | ||
| private val listener = ThreatListener(FreeraspThreatHandler, FreeraspThreatHandler, FreeraspThreatHandler) | ||
| private val lifecycleListener = object : LifecycleEventListener { | ||
| override fun onHostResume() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { | ||
|
|
@@ -67,7 +72,7 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
| FreeraspThreatHandler.listener = ThreatListener | ||
| listener.registerListener(reactContext) | ||
| runOnUiThread { | ||
| Talsec.start(reactContext, config) | ||
| Talsec.start(reactContext, config, TalsecMode.BACKGROUND) | ||
|
Member
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. We do not give an option to set a different mode?
Member
Author
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. Opted not to do so in Flutter as well |
||
| mainHandler.post { | ||
| talsecStarted = true | ||
| // This code must be called only AFTER Talsec.start | ||
|
|
@@ -90,19 +95,39 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
| */ | ||
| @ReactMethod | ||
| fun getThreatIdentifiers(promise: Promise) { | ||
| promise.resolve(Threat.getThreatValues()) | ||
| promise.resolve(ThreatEvent.ALL_EVENTS) | ||
| } | ||
|
|
||
| /** | ||
| * Method to setup the message passing between native and React Native | ||
| * Method to get the random identifiers of callbacks | ||
| */ | ||
| @ReactMethod | ||
| fun getRaspExecutionStateIdentifiers(promise: Promise) { | ||
| promise.resolve(RaspExecutionStateEvent.ALL_EVENTS) | ||
| } | ||
|
|
||
| /** | ||
| * Method to setup the threat message passing between native and React Native | ||
| * @return list of [THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY] | ||
| */ | ||
| @ReactMethod | ||
| fun getThreatChannelData(promise: Promise) { | ||
| val channelData: WritableArray = Arguments.createArray() | ||
| channelData.pushString(THREAT_CHANNEL_NAME) | ||
| channelData.pushString(THREAT_CHANNEL_KEY) | ||
| channelData.pushString(MALWARE_CHANNEL_KEY) | ||
| channelData.pushString(ThreatEvent.CHANNEL_NAME) | ||
| channelData.pushString(ThreatEvent.CHANNEL_KEY) | ||
| channelData.pushString(ThreatEvent.MALWARE_CHANNEL_KEY) | ||
| promise.resolve(channelData) | ||
| } | ||
|
|
||
| /** | ||
| * Method to setup the execution state message passing between native and React Native | ||
| * @return list of [THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY] | ||
| */ | ||
| @ReactMethod | ||
| fun getRaspExecutionStateChannelData(promise: Promise) { | ||
| val channelData: WritableArray = Arguments.createArray() | ||
| channelData.pushString(RaspExecutionStateEvent.CHANNEL_NAME) | ||
| channelData.pushString(RaspExecutionStateEvent.CHANNEL_KEY) | ||
| promise.resolve(channelData) | ||
| } | ||
|
|
||
|
|
@@ -207,8 +232,9 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| val talsecBuilder = TalsecConfig.Builder(packageName, certificateHashes) | ||
| .watcherMail(config.getString("watcherMail")) | ||
| .supportedAlternativeStores(androidConfig.getArraySafe("supportedAlternativeStores")) | ||
| .prod(config.getBooleanSafe("isProd")) | ||
| .killOnBypass(config.getBooleanSafe("killOnBypass", false)) | ||
| .supportedAlternativeStores(androidConfig.getArraySafe("supportedAlternativeStores")) | ||
|
|
||
| if (androidConfig.hasKey("malwareConfig")) { | ||
| val malwareConfig = androidConfig.getMapThrowing("malwareConfig") | ||
|
|
@@ -223,12 +249,6 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| companion object { | ||
| const val NAME = "FreeraspReactNative" | ||
| private val THREAT_CHANNEL_NAME = (10000..999999999).random() | ||
| .toString() // name of the channel over which threat callbacks are sent | ||
| private val THREAT_CHANNEL_KEY = (10000..999999999).random() | ||
| .toString() // key of the argument map under which threats are expected | ||
| private val MALWARE_CHANNEL_KEY = (10000..999999999).random() | ||
| .toString() // key of the argument map under which malware data is expected | ||
|
|
||
| private val backgroundHandlerThread = HandlerThread("BackgroundThread").apply { start() } | ||
| private val backgroundHandler = Handler(backgroundHandlerThread.looper) | ||
|
|
@@ -238,11 +258,11 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| internal var talsecStarted = false | ||
|
|
||
| private fun notifyListeners(threat: Threat) { | ||
| private fun notifyEvent(event: BaseRaspEvent) { | ||
| val params = Arguments.createMap() | ||
| params.putInt(THREAT_CHANNEL_KEY, threat.value) | ||
| params.putInt(event.channelKey, event.value) | ||
| appReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) | ||
| .emit(THREAT_CHANNEL_NAME, params) | ||
| .emit(event.channelName, params) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -256,25 +276,29 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex | |
|
|
||
| mainHandler.post { | ||
| val params = Arguments.createMap() | ||
| params.putInt(THREAT_CHANNEL_KEY, Threat.Malware.value) | ||
| params.putInt(ThreatEvent.CHANNEL_KEY, ThreatEvent.Malware.value) | ||
| params.putArray( | ||
| MALWARE_CHANNEL_KEY, encodedSuspiciousApps | ||
| ThreatEvent.MALWARE_CHANNEL_KEY, encodedSuspiciousApps | ||
| ) | ||
|
|
||
| appReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) | ||
| .emit(THREAT_CHANNEL_NAME, params) | ||
| .emit(ThreatEvent.CHANNEL_NAME, params) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| internal object ThreatListener : FreeraspThreatHandler.TalsecReactNative { | ||
| override fun threatDetected(threatType: Threat) { | ||
| notifyListeners(threatType) | ||
| override fun threatDetected(threatEventType: ThreatEvent) { | ||
| notifyEvent(threatEventType) | ||
| } | ||
|
|
||
| override fun malwareDetected(suspiciousApps: MutableList<SuspiciousAppInfo>) { | ||
| notifyMalware(suspiciousApps) | ||
| } | ||
|
|
||
| override fun raspExecutionStateChanged(event: RaspExecutionStateEvent) { | ||
| notifyEvent(event) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unused import?