freerasp-react-native 4.5.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +12 -10
- package/android/src/main/java/com/freeraspreactnative/events/RaspExecutionStateEvent.kt +3 -5
- package/android/src/main/java/com/freeraspreactnative/events/ThreatEvent.kt +23 -25
- package/android/src/main/java/com/freeraspreactnative/models/RNSuspiciousAppInfo.kt +1 -1
- package/android/src/main/java/com/freeraspreactnative/utils/Extensions.kt +22 -2
- package/freerasp-react-native.podspec +31 -8
- package/freerasp_spm.rb +88 -0
- package/ios/TalsecRuntime.xcframework/Info.plist +5 -5
- package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
- package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeResources +42 -42
- package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +7 -7
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +4 -4
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +345 -289
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/_CodeSignature/CodeResources +15 -15
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +2 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +7 -7
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +4 -4
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +279 -223
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +279 -223
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +17 -17
- package/ios/TalsecRuntimePackage/Package.swift +19 -0
- package/lib/commonjs/api/methods/native.js +2 -1
- package/lib/commonjs/api/methods/native.js.map +1 -1
- package/lib/commonjs/utils/config.js +31 -0
- package/lib/commonjs/utils/config.js.map +1 -0
- package/lib/commonjs/utils/malware.js +1 -1
- package/lib/commonjs/utils/malware.js.map +1 -1
- package/lib/module/api/methods/native.js +2 -1
- package/lib/module/api/methods/native.js.map +1 -1
- package/lib/module/utils/config.js +23 -0
- package/lib/module/utils/config.js.map +1 -0
- package/lib/module/utils/malware.js +1 -1
- package/lib/module/utils/malware.js.map +1 -1
- package/lib/typescript/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/plugin/src/iosSpm.d.ts +8 -0
- package/lib/typescript/plugin/src/iosSpm.d.ts.map +1 -0
- package/lib/typescript/plugin/src/iosSpmProperties.d.ts +3 -0
- package/lib/typescript/plugin/src/iosSpmProperties.d.ts.map +1 -0
- package/lib/typescript/plugin/src/pluginConfig.d.ts +8 -0
- package/lib/typescript/plugin/src/pluginConfig.d.ts.map +1 -1
- package/lib/typescript/src/api/methods/native.d.ts.map +1 -1
- package/lib/typescript/src/types/types.d.ts +16 -8
- package/lib/typescript/src/types/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/config.d.ts +4 -0
- package/lib/typescript/src/utils/config.d.ts.map +1 -0
- package/package.json +2 -1
- package/plugin/build/index.js +38 -0
- package/plugin/build/iosSpm.d.ts +7 -0
- package/plugin/build/iosSpm.js +136 -0
- package/plugin/build/iosSpmProperties.d.ts +2 -0
- package/plugin/build/iosSpmProperties.js +29 -0
- package/plugin/build/pluginConfig.d.ts +8 -0
- package/plugin/tests/iosSpm.test.js +126 -0
- package/src/api/methods/native.ts +2 -1
- package/src/types/types.ts +25 -9
- package/src/utils/config.ts +42 -0
- package/src/utils/malware.ts +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FREERASP_SPM_ACTIVATION_TAG = '# @generated freerasp-react-native (SPM activation)';
|
|
4
|
+
const FREERASP_SPM_DISABLED_TAG = '# @generated freerasp-react-native (SPM disabled)';
|
|
5
|
+
const FREERASP_SPM_EMBED_TAG = '# @generated freerasp-react-native (SPM embed)';
|
|
6
|
+
const PREPARE_REACT_NATIVE_ANCHOR = 'prepare_react_native_project!';
|
|
7
|
+
const REACT_NATIVE_POST_INSTALL_ANCHOR = 'react_native_post_install(';
|
|
8
|
+
const indentationAt = (contents, index) => {
|
|
9
|
+
const lineStart = contents.lastIndexOf('\n', index - 1) + 1;
|
|
10
|
+
return contents.slice(lineStart, index).match(/^\s*/)?.[0] ?? '';
|
|
11
|
+
};
|
|
12
|
+
const removeManagedBlock = (contents, tag, bodyLineCount) => {
|
|
13
|
+
const newline = contents.includes('\r\n') ? '\r\n' : '\n';
|
|
14
|
+
const lines = contents.split(/\r?\n/);
|
|
15
|
+
const tagIndex = lines.findIndex((line) => line.trim() === tag);
|
|
16
|
+
if (tagIndex === -1) {
|
|
17
|
+
return contents;
|
|
18
|
+
}
|
|
19
|
+
let startIndex = tagIndex;
|
|
20
|
+
while (startIndex > 0 && lines[startIndex - 1]?.trim() === '') {
|
|
21
|
+
startIndex -= 1;
|
|
22
|
+
}
|
|
23
|
+
lines.splice(startIndex, tagIndex - startIndex + bodyLineCount + 1);
|
|
24
|
+
return lines.join(newline);
|
|
25
|
+
};
|
|
26
|
+
const findClosingParenthesis = (contents, openingIndex) => {
|
|
27
|
+
let depth = 0;
|
|
28
|
+
let quote;
|
|
29
|
+
let escaped = false;
|
|
30
|
+
let inComment = false;
|
|
31
|
+
for (let index = openingIndex; index < contents.length; index += 1) {
|
|
32
|
+
const character = contents[index];
|
|
33
|
+
if (inComment) {
|
|
34
|
+
if (character === '\n') {
|
|
35
|
+
inComment = false;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (quote) {
|
|
40
|
+
if (escaped) {
|
|
41
|
+
escaped = false;
|
|
42
|
+
}
|
|
43
|
+
else if (character === '\\') {
|
|
44
|
+
escaped = true;
|
|
45
|
+
}
|
|
46
|
+
else if (character === quote) {
|
|
47
|
+
quote = undefined;
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (character === '#') {
|
|
52
|
+
inComment = true;
|
|
53
|
+
}
|
|
54
|
+
else if (character === "'" || character === '"') {
|
|
55
|
+
quote = character;
|
|
56
|
+
}
|
|
57
|
+
else if (character === '(') {
|
|
58
|
+
depth += 1;
|
|
59
|
+
}
|
|
60
|
+
else if (character === ')') {
|
|
61
|
+
depth -= 1;
|
|
62
|
+
if (depth === 0) {
|
|
63
|
+
return index;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return -1;
|
|
68
|
+
};
|
|
69
|
+
const mutatePodfileForFreeraspSpm = (contents, enabled = true) => {
|
|
70
|
+
let updatedContents = removeManagedBlock(contents, FREERASP_SPM_ACTIVATION_TAG, 1);
|
|
71
|
+
updatedContents = removeManagedBlock(updatedContents, FREERASP_SPM_DISABLED_TAG, 1);
|
|
72
|
+
updatedContents = removeManagedBlock(updatedContents, FREERASP_SPM_EMBED_TAG, 4);
|
|
73
|
+
const missingAnchors = [];
|
|
74
|
+
const prepareIndex = updatedContents.indexOf(PREPARE_REACT_NATIVE_ANCHOR);
|
|
75
|
+
const postInstallIndex = enabled
|
|
76
|
+
? updatedContents.indexOf(REACT_NATIVE_POST_INSTALL_ANCHOR)
|
|
77
|
+
: -1;
|
|
78
|
+
const postInstallOpeningIndex = postInstallIndex === -1
|
|
79
|
+
? -1
|
|
80
|
+
: postInstallIndex + REACT_NATIVE_POST_INSTALL_ANCHOR.length - 1;
|
|
81
|
+
const postInstallClosingIndex = postInstallOpeningIndex === -1
|
|
82
|
+
? -1
|
|
83
|
+
: findClosingParenthesis(updatedContents, postInstallOpeningIndex);
|
|
84
|
+
if (prepareIndex === -1) {
|
|
85
|
+
missingAnchors.push(PREPARE_REACT_NATIVE_ANCHOR);
|
|
86
|
+
}
|
|
87
|
+
if (enabled && postInstallClosingIndex === -1) {
|
|
88
|
+
missingAnchors.push(REACT_NATIVE_POST_INSTALL_ANCHOR);
|
|
89
|
+
}
|
|
90
|
+
if (missingAnchors.length > 0) {
|
|
91
|
+
return { contents, changed: false, missingAnchors };
|
|
92
|
+
}
|
|
93
|
+
const newline = updatedContents.includes('\r\n') ? '\r\n' : '\n';
|
|
94
|
+
if (enabled) {
|
|
95
|
+
// Preserve the post-install index by inserting its snippet first.
|
|
96
|
+
const indent = indentationAt(updatedContents, postInstallIndex);
|
|
97
|
+
const snippet = [
|
|
98
|
+
'',
|
|
99
|
+
'',
|
|
100
|
+
`${indent}${FREERASP_SPM_EMBED_TAG}`,
|
|
101
|
+
`${indent}require Pod::Executable.execute_command('node', ['-p',`,
|
|
102
|
+
`${indent} 'require.resolve("freerasp-react-native/freerasp_spm.rb", {paths: [process.argv[1]]})',`,
|
|
103
|
+
`${indent} __dir__]).strip`,
|
|
104
|
+
`${indent}freerasp_embed_talsec_spm!(installer)`,
|
|
105
|
+
].join(newline);
|
|
106
|
+
updatedContents =
|
|
107
|
+
updatedContents.slice(0, postInstallClosingIndex + 1) +
|
|
108
|
+
snippet +
|
|
109
|
+
updatedContents.slice(postInstallClosingIndex + 1);
|
|
110
|
+
}
|
|
111
|
+
const insertAt = prepareIndex + PREPARE_REACT_NATIVE_ANCHOR.length;
|
|
112
|
+
const indent = indentationAt(updatedContents, prepareIndex);
|
|
113
|
+
const configurationSnippet = enabled
|
|
114
|
+
? [
|
|
115
|
+
'',
|
|
116
|
+
'',
|
|
117
|
+
`${indent}${FREERASP_SPM_ACTIVATION_TAG}`,
|
|
118
|
+
`${indent}ENV['FREERASP_USE_SPM'] = '1' unless ENV['FREERASP_USE_SPM'] == '0'`,
|
|
119
|
+
]
|
|
120
|
+
: [
|
|
121
|
+
'',
|
|
122
|
+
'',
|
|
123
|
+
`${indent}${FREERASP_SPM_DISABLED_TAG}`,
|
|
124
|
+
`${indent}ENV['FREERASP_USE_SPM'] = '0'`,
|
|
125
|
+
];
|
|
126
|
+
updatedContents =
|
|
127
|
+
updatedContents.slice(0, insertAt) +
|
|
128
|
+
configurationSnippet.join(newline) +
|
|
129
|
+
updatedContents.slice(insertAt);
|
|
130
|
+
return {
|
|
131
|
+
contents: updatedContents,
|
|
132
|
+
changed: updatedContents !== contents,
|
|
133
|
+
missingAnchors: [],
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
exports.default = mutatePodfileForFreeraspSpm;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FRAMEWORKS_PROPERTY = 'ios.useFrameworks';
|
|
4
|
+
const MANAGED_PROPERTY = 'freerasp.iosUseFrameworks';
|
|
5
|
+
const PREVIOUS_VALUE_PROPERTY = 'freerasp.previousIosUseFrameworks';
|
|
6
|
+
const UNSET_VALUE = '__freerasp_unset__';
|
|
7
|
+
const configureIosSpmProperties = (properties, spmEnabled) => {
|
|
8
|
+
if (spmEnabled) {
|
|
9
|
+
if (properties[MANAGED_PROPERTY] !== 'true') {
|
|
10
|
+
properties[PREVIOUS_VALUE_PROPERTY] =
|
|
11
|
+
properties[FRAMEWORKS_PROPERTY] ?? UNSET_VALUE;
|
|
12
|
+
}
|
|
13
|
+
properties[FRAMEWORKS_PROPERTY] = 'dynamic';
|
|
14
|
+
properties[MANAGED_PROPERTY] = 'true';
|
|
15
|
+
}
|
|
16
|
+
else if (properties[MANAGED_PROPERTY] === 'true') {
|
|
17
|
+
const previousValue = properties[PREVIOUS_VALUE_PROPERTY];
|
|
18
|
+
if (previousValue && previousValue !== UNSET_VALUE) {
|
|
19
|
+
properties[FRAMEWORKS_PROPERTY] = previousValue;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
delete properties[FRAMEWORKS_PROPERTY];
|
|
23
|
+
}
|
|
24
|
+
delete properties[MANAGED_PROPERTY];
|
|
25
|
+
delete properties[PREVIOUS_VALUE_PROPERTY];
|
|
26
|
+
}
|
|
27
|
+
return properties;
|
|
28
|
+
};
|
|
29
|
+
exports.default = configureIosSpmProperties;
|
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
* Interface representing base build properties configuration.
|
|
3
3
|
*/
|
|
4
4
|
export interface PluginConfigType {
|
|
5
|
+
ios?: PluginConfigTypeIos;
|
|
5
6
|
/**
|
|
6
7
|
* Interface representing available configuration for Android native build properties.
|
|
7
8
|
* @platform android
|
|
8
9
|
*/
|
|
9
10
|
android?: PluginConfigTypeAndroid;
|
|
10
11
|
}
|
|
12
|
+
/** @platform ios */
|
|
13
|
+
export interface PluginConfigTypeIos {
|
|
14
|
+
/**
|
|
15
|
+
* Use Swift Package Manager to deliver TalsecRuntime. Defaults to `true`.
|
|
16
|
+
*/
|
|
17
|
+
useSpm?: boolean;
|
|
18
|
+
}
|
|
11
19
|
/**
|
|
12
20
|
* Interface representing available configuration for Android native build properties.
|
|
13
21
|
* @platform android
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
|
|
3
|
+
const assert = require('assert').strict;
|
|
4
|
+
const mutatePodfileForFreeraspSpm = require('../build/iosSpm').default;
|
|
5
|
+
const configureIosSpmProperties = require('../build/iosSpmProperties').default;
|
|
6
|
+
|
|
7
|
+
const FREERASP_SPM_ACTIVATION_TAG =
|
|
8
|
+
'# @generated freerasp-react-native (SPM activation)';
|
|
9
|
+
const FREERASP_SPM_DISABLED_TAG =
|
|
10
|
+
'# @generated freerasp-react-native (SPM disabled)';
|
|
11
|
+
const FREERASP_SPM_EMBED_TAG = '# @generated freerasp-react-native (SPM embed)';
|
|
12
|
+
|
|
13
|
+
const podfile = `prepare_react_native_project!
|
|
14
|
+
|
|
15
|
+
target 'Example' do
|
|
16
|
+
post_install do |installer|
|
|
17
|
+
react_native_post_install(
|
|
18
|
+
installer,
|
|
19
|
+
config[:reactNativePath],
|
|
20
|
+
:mac_catalyst_enabled => nested_option(enabled: false),
|
|
21
|
+
:quoted_value => "parentheses do not count: ())"
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const mutation = mutatePodfileForFreeraspSpm(podfile);
|
|
28
|
+
assert.equal(mutation.changed, true);
|
|
29
|
+
assert.deepEqual(mutation.missingAnchors, []);
|
|
30
|
+
|
|
31
|
+
const activationIndex = mutation.contents.indexOf(FREERASP_SPM_ACTIVATION_TAG);
|
|
32
|
+
const targetIndex = mutation.contents.indexOf("target 'Example'");
|
|
33
|
+
assert(
|
|
34
|
+
activationIndex > mutation.contents.indexOf('prepare_react_native_project!')
|
|
35
|
+
);
|
|
36
|
+
assert(activationIndex < targetIndex);
|
|
37
|
+
assert(
|
|
38
|
+
mutation.contents.includes(
|
|
39
|
+
"ENV['FREERASP_USE_SPM'] = '1' unless ENV['FREERASP_USE_SPM'] == '0'"
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const postInstallCloseIndex = mutation.contents.indexOf('\n )');
|
|
44
|
+
const embedIndex = mutation.contents.indexOf(FREERASP_SPM_EMBED_TAG);
|
|
45
|
+
const postInstallEndIndex = mutation.contents.indexOf('\n end', embedIndex);
|
|
46
|
+
assert(embedIndex > postInstallCloseIndex);
|
|
47
|
+
assert(embedIndex < postInstallEndIndex);
|
|
48
|
+
|
|
49
|
+
const secondMutation = mutatePodfileForFreeraspSpm(mutation.contents);
|
|
50
|
+
assert.equal(secondMutation.changed, false);
|
|
51
|
+
assert.equal(secondMutation.contents, mutation.contents);
|
|
52
|
+
|
|
53
|
+
const disabledMutation = mutatePodfileForFreeraspSpm(mutation.contents, false);
|
|
54
|
+
assert.equal(disabledMutation.changed, true);
|
|
55
|
+
assert(disabledMutation.contents.includes(FREERASP_SPM_DISABLED_TAG));
|
|
56
|
+
assert(disabledMutation.contents.includes("ENV['FREERASP_USE_SPM'] = '0'"));
|
|
57
|
+
assert.equal(
|
|
58
|
+
disabledMutation.contents.includes(FREERASP_SPM_ACTIVATION_TAG),
|
|
59
|
+
false
|
|
60
|
+
);
|
|
61
|
+
assert.equal(disabledMutation.contents.includes(FREERASP_SPM_EMBED_TAG), false);
|
|
62
|
+
|
|
63
|
+
const secondDisabledMutation = mutatePodfileForFreeraspSpm(
|
|
64
|
+
disabledMutation.contents,
|
|
65
|
+
false
|
|
66
|
+
);
|
|
67
|
+
assert.equal(secondDisabledMutation.changed, false);
|
|
68
|
+
assert.equal(secondDisabledMutation.contents, disabledMutation.contents);
|
|
69
|
+
|
|
70
|
+
const reenabledMutation = mutatePodfileForFreeraspSpm(
|
|
71
|
+
disabledMutation.contents,
|
|
72
|
+
true
|
|
73
|
+
);
|
|
74
|
+
assert.equal(reenabledMutation.changed, true);
|
|
75
|
+
assert(reenabledMutation.contents.includes(FREERASP_SPM_ACTIVATION_TAG));
|
|
76
|
+
assert(reenabledMutation.contents.includes(FREERASP_SPM_EMBED_TAG));
|
|
77
|
+
assert.equal(
|
|
78
|
+
reenabledMutation.contents.includes(FREERASP_SPM_DISABLED_TAG),
|
|
79
|
+
false
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const missingAnchors = mutatePodfileForFreeraspSpm(
|
|
83
|
+
'target "Example" do\nend\n'
|
|
84
|
+
);
|
|
85
|
+
assert.equal(missingAnchors.changed, false);
|
|
86
|
+
assert.equal(missingAnchors.contents, 'target "Example" do\nend\n');
|
|
87
|
+
assert.deepEqual(missingAnchors.missingAnchors, [
|
|
88
|
+
'prepare_react_native_project!',
|
|
89
|
+
'react_native_post_install(',
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const windowsMutation = mutatePodfileForFreeraspSpm(
|
|
93
|
+
podfile.replace(/\n/g, '\r\n')
|
|
94
|
+
);
|
|
95
|
+
assert.equal(windowsMutation.changed, true);
|
|
96
|
+
assert.equal(
|
|
97
|
+
windowsMutation.contents.replace(/\r\n/g, '').includes('\n'),
|
|
98
|
+
false
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const propertiesWithoutFrameworks = {};
|
|
102
|
+
configureIosSpmProperties(propertiesWithoutFrameworks, true);
|
|
103
|
+
assert.equal(propertiesWithoutFrameworks['ios.useFrameworks'], 'dynamic');
|
|
104
|
+
configureIosSpmProperties(propertiesWithoutFrameworks, false);
|
|
105
|
+
assert.deepEqual(propertiesWithoutFrameworks, {});
|
|
106
|
+
|
|
107
|
+
const propertiesWithStaticFrameworks = {
|
|
108
|
+
'ios.useFrameworks': 'static',
|
|
109
|
+
};
|
|
110
|
+
configureIosSpmProperties(propertiesWithStaticFrameworks, true);
|
|
111
|
+
configureIosSpmProperties(propertiesWithStaticFrameworks, true);
|
|
112
|
+
assert.equal(propertiesWithStaticFrameworks['ios.useFrameworks'], 'dynamic');
|
|
113
|
+
configureIosSpmProperties(propertiesWithStaticFrameworks, false);
|
|
114
|
+
assert.deepEqual(propertiesWithStaticFrameworks, {
|
|
115
|
+
'ios.useFrameworks': 'static',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const unownedProperties = {
|
|
119
|
+
'ios.useFrameworks': 'dynamic',
|
|
120
|
+
};
|
|
121
|
+
configureIosSpmProperties(unownedProperties, false);
|
|
122
|
+
assert.deepEqual(unownedProperties, {
|
|
123
|
+
'ios.useFrameworks': 'dynamic',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
console.log('Expo iOS SPM tests passed.');
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { FreeraspReactNative } from '../nativeModules';
|
|
3
3
|
import type { TalsecConfig } from '../../types/types';
|
|
4
|
+
import { withDefaults } from '../../utils/config';
|
|
4
5
|
|
|
5
6
|
export const talsecStart = async (options: TalsecConfig): Promise<string> => {
|
|
6
|
-
return FreeraspReactNative.talsecStart(options);
|
|
7
|
+
return FreeraspReactNative.talsecStart(withDefaults(options));
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export const addToWhitelist = async (packageName: string): Promise<boolean> => {
|
package/src/types/types.ts
CHANGED
|
@@ -6,11 +6,34 @@ export type TalsecConfig = {
|
|
|
6
6
|
killOnBypass?: boolean;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
export type ScopeType =
|
|
10
|
+
| 'SIDELOADED_ONLY'
|
|
11
|
+
| 'SIDELOADED_AND_SYSTEM_EXCLUDE_OEM'
|
|
12
|
+
| 'SIDELOADED_AND_OEM'
|
|
13
|
+
| 'SIDELOADED_AND_SYSTEM_AND_OEM'
|
|
14
|
+
| 'ALL';
|
|
15
|
+
|
|
16
|
+
export type ReasonMode = 'ALL' | 'HIGHEST_CONFIDENCE';
|
|
17
|
+
|
|
18
|
+
export type ScanScope = {
|
|
19
|
+
scopeType: ScopeType;
|
|
20
|
+
trustedInstallSources?: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SuspiciousAppDetectionConfig = {
|
|
24
|
+
packageNames?: string[];
|
|
25
|
+
hashes?: string[];
|
|
26
|
+
requestedPermissions?: string[][];
|
|
27
|
+
grantedPermissions?: string[][];
|
|
28
|
+
scanScope: ScanScope;
|
|
29
|
+
reasonMode: ReasonMode;
|
|
30
|
+
};
|
|
31
|
+
|
|
9
32
|
export type TalsecAndroidConfig = {
|
|
10
33
|
packageName: string;
|
|
11
34
|
certificateHashes: string[];
|
|
12
35
|
supportedAlternativeStores?: string[];
|
|
13
|
-
|
|
36
|
+
suspiciousAppDetectionConfig?: SuspiciousAppDetectionConfig;
|
|
14
37
|
};
|
|
15
38
|
|
|
16
39
|
export type TalsecIosConfig = {
|
|
@@ -18,16 +41,9 @@ export type TalsecIosConfig = {
|
|
|
18
41
|
appTeamId: string;
|
|
19
42
|
};
|
|
20
43
|
|
|
21
|
-
export type TalsecMalwareConfig = {
|
|
22
|
-
blacklistedHashes?: string[];
|
|
23
|
-
blacklistedPackageNames?: string[];
|
|
24
|
-
suspiciousPermissions?: string[][];
|
|
25
|
-
whitelistedInstallationSources?: string[];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
44
|
export type SuspiciousAppInfo = {
|
|
29
45
|
packageInfo: PackageInfo;
|
|
30
|
-
|
|
46
|
+
reasons: string[];
|
|
31
47
|
permissions?: string[];
|
|
32
48
|
};
|
|
33
49
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ReasonMode,
|
|
3
|
+
ScanScope,
|
|
4
|
+
SuspiciousAppDetectionConfig,
|
|
5
|
+
TalsecAndroidConfig,
|
|
6
|
+
TalsecConfig,
|
|
7
|
+
} from '../types/types';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_SCAN_SCOPE: ScanScope = {
|
|
10
|
+
scopeType: 'SIDELOADED_ONLY',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const DEFAULT_REASON_MODE: ReasonMode = 'HIGHEST_CONFIDENCE';
|
|
14
|
+
|
|
15
|
+
const withDetectionDefaults = (
|
|
16
|
+
config: SuspiciousAppDetectionConfig
|
|
17
|
+
): SuspiciousAppDetectionConfig => ({
|
|
18
|
+
...config,
|
|
19
|
+
scanScope: config.scanScope ?? DEFAULT_SCAN_SCOPE,
|
|
20
|
+
reasonMode: config.reasonMode ?? DEFAULT_REASON_MODE,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const normalizeAndroidConfig = (
|
|
24
|
+
androidConfig: TalsecAndroidConfig
|
|
25
|
+
): TalsecAndroidConfig => {
|
|
26
|
+
if (!androidConfig.suspiciousAppDetectionConfig) {
|
|
27
|
+
return androidConfig;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...androidConfig,
|
|
31
|
+
suspiciousAppDetectionConfig: withDetectionDefaults(
|
|
32
|
+
androidConfig.suspiciousAppDetectionConfig
|
|
33
|
+
),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const withDefaults = (options: TalsecConfig): TalsecConfig => ({
|
|
38
|
+
...options,
|
|
39
|
+
androidConfig: options.androidConfig
|
|
40
|
+
? normalizeAndroidConfig(options.androidConfig)
|
|
41
|
+
: undefined,
|
|
42
|
+
});
|
package/src/utils/malware.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {
|
|
|
18
18
|
const packageInfo = data.packageInfo as PackageInfo;
|
|
19
19
|
return {
|
|
20
20
|
packageInfo,
|
|
21
|
-
|
|
21
|
+
reasons: data.reasons,
|
|
22
22
|
permissions: data.permissions,
|
|
23
23
|
} as SuspiciousAppInfo;
|
|
24
24
|
};
|