appium 2.18.0 → 2.19.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.
Files changed (47) hide show
  1. package/build/lib/appium.d.ts +15 -5
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +20 -22
  4. package/build/lib/appium.js.map +1 -1
  5. package/build/lib/cli/driver-command.js +1 -1
  6. package/build/lib/cli/driver-command.js.map +1 -1
  7. package/build/lib/cli/extension-command.js +1 -1
  8. package/build/lib/cli/extension-command.js.map +1 -1
  9. package/build/lib/cli/parser.js +1 -1
  10. package/build/lib/cli/plugin-command.js +1 -1
  11. package/build/lib/cli/plugin-command.js.map +1 -1
  12. package/build/lib/constants.d.ts +4 -0
  13. package/build/lib/constants.d.ts.map +1 -1
  14. package/build/lib/constants.js +5 -1
  15. package/build/lib/constants.js.map +1 -1
  16. package/build/lib/extension/extension-config.js +1 -1
  17. package/build/lib/extension/extension-config.js.map +1 -1
  18. package/build/lib/insecure-features.d.ts +18 -0
  19. package/build/lib/insecure-features.d.ts.map +1 -0
  20. package/build/lib/insecure-features.js +117 -0
  21. package/build/lib/insecure-features.js.map +1 -0
  22. package/build/lib/main.d.ts +1 -1
  23. package/build/lib/main.d.ts.map +1 -1
  24. package/build/lib/main.js +3 -1
  25. package/build/lib/main.js.map +1 -1
  26. package/build/lib/schema/cli-args.d.ts +1 -1
  27. package/build/lib/schema/cli-args.js +1 -1
  28. package/build/lib/schema/cli-args.js.map +1 -1
  29. package/build/lib/schema/schema.d.ts +1 -1
  30. package/build/lib/schema/schema.js +1 -1
  31. package/build/lib/utils.d.ts +1 -8
  32. package/build/lib/utils.d.ts.map +1 -1
  33. package/build/lib/utils.js +1 -31
  34. package/build/lib/utils.js.map +1 -1
  35. package/lib/appium.js +23 -33
  36. package/lib/cli/driver-command.js +1 -1
  37. package/lib/cli/extension-command.js +1 -1
  38. package/lib/cli/parser.js +1 -1
  39. package/lib/cli/plugin-command.js +1 -1
  40. package/lib/constants.js +5 -0
  41. package/lib/extension/extension-config.js +1 -1
  42. package/lib/insecure-features.ts +132 -0
  43. package/lib/main.js +4 -1
  44. package/lib/schema/cli-args.js +2 -2
  45. package/lib/schema/schema.js +1 -1
  46. package/lib/utils.js +1 -34
  47. package/package.json +14 -14
@@ -0,0 +1,132 @@
1
+ import _ from 'lodash';
2
+ import logger from './logger';
3
+
4
+ import type {AppiumDriver} from './appium';
5
+ import type {ExternalDriver} from '@appium/types';
6
+
7
+ const ALL_DRIVERS_MATCH = '*';
8
+ const FEATURE_NAME_SEPARATOR = ':';
9
+
10
+ /**
11
+ * Configures insecure features according to the values in `args.relaxedSecurityEnabled`,
12
+ * `args.allowInsecure`, and `args.denyInsecure`, and informs the user about any
13
+ * globally-applied features.
14
+ * Uses `logger` instead of `this.log` to reduce user confusion.
15
+ */
16
+ export function configureGlobalFeatures(this: AppiumDriver) {
17
+ if (this.args.relaxedSecurityEnabled) {
18
+ logger.info(
19
+ `Enabling relaxed security. All insecure features will be ` +
20
+ `enabled unless explicitly disabled by --deny-insecure`,
21
+ );
22
+ this.relaxedSecurityEnabled = true;
23
+ } else if (!_.isEmpty(this.args.allowInsecure)) {
24
+ this.allowInsecure = validateFeatures(this.args.allowInsecure);
25
+ const globalAllowedFeatures = filterInsecureFeatures(this.allowInsecure);
26
+ if (!_.isEmpty(globalAllowedFeatures)) {
27
+ logger.info('Explicitly enabling insecure features:');
28
+ globalAllowedFeatures.forEach((a) => logger.info(` ${a}`));
29
+ }
30
+ }
31
+ if (_.isEmpty(this.args.denyInsecure)) {
32
+ return;
33
+ }
34
+ this.denyInsecure = validateFeatures(this.args.denyInsecure);
35
+ const globalDeniedFeatures = filterInsecureFeatures(this.denyInsecure);
36
+ if (_.isEmpty(globalDeniedFeatures)) {
37
+ return;
38
+ }
39
+ logger.info('Explicitly disabling insecure features:');
40
+ globalDeniedFeatures.forEach((a) => logger.info(` ${a}`));
41
+ }
42
+
43
+ /**
44
+ * If anything in the umbrella driver's insecure feature configuration applies to this driver,
45
+ * assign it to the driver instance
46
+ *
47
+ * @param driver
48
+ * @param driverName
49
+ */
50
+ export function configureDriverFeatures(
51
+ this: AppiumDriver,
52
+ driver: ExternalDriver,
53
+ driverName: string,
54
+ ) {
55
+ if (this.relaxedSecurityEnabled) {
56
+ this.log.info(
57
+ `Enabling relaxed security for this session as per the server configuration. ` +
58
+ `All insecure features will be enabled unless explicitly disabled by --deny-insecure`,
59
+ );
60
+ driver.relaxedSecurityEnabled = true;
61
+ }
62
+ const allowedDriverFeatures = filterInsecureFeatures(this.allowInsecure, driverName);
63
+ if (!_.isEmpty(allowedDriverFeatures)) {
64
+ this.log.info('Explicitly enabling insecure features for this session ' +
65
+ 'as per the server configuration:',
66
+ );
67
+ allowedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
68
+ driver.allowInsecure = allowedDriverFeatures;
69
+ }
70
+ const deniedDriverFeatures = filterInsecureFeatures(this.denyInsecure, driverName);
71
+ if (_.isEmpty(deniedDriverFeatures)) {
72
+ return;
73
+ }
74
+ this.log.info('Explicitly disabling insecure features for this session ' +
75
+ 'as per the server configuration:',
76
+ );
77
+ deniedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
78
+ driver.denyInsecure = deniedDriverFeatures;
79
+ }
80
+
81
+ /**
82
+ * Validates the list of allowed/denied server features
83
+ *
84
+ * @param features
85
+ */
86
+ function validateFeatures(features: string[]): string[] {
87
+ const validator = (fullName: string) => {
88
+ const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
89
+ // TODO: This is for the backward compatibility with Appium2
90
+ // TODO: In Appium3 the separator will be mandatory
91
+ if (separatorPos < 0) {
92
+ return `${ALL_DRIVERS_MATCH}${FEATURE_NAME_SEPARATOR}${fullName}`;
93
+ }
94
+
95
+ const [automationName, featureName] = [
96
+ fullName.substring(0, separatorPos),
97
+ fullName.substring(separatorPos + 1)
98
+ ];
99
+ if (!automationName || !featureName) {
100
+ throw new Error(
101
+ `The full feature name must include both the destination automation name or the ` +
102
+ `'${ALL_DRIVERS_MATCH}' wildcard to apply the feature to all installed drivers, and ` +
103
+ `the feature name split by a colon, got '${fullName}' instead`
104
+ );
105
+ }
106
+ return fullName;
107
+ };
108
+ return features.map(validator);
109
+ }
110
+
111
+ /**
112
+ * Filters the list of insecure features to only those that are
113
+ * applicable to the given driver name.
114
+ * Assumes that all feature names have already been validated
115
+ *
116
+ * @param features
117
+ * @param driverName
118
+ */
119
+ function filterInsecureFeatures(
120
+ features: string[],
121
+ driverName: string = ALL_DRIVERS_MATCH
122
+ ): string[] {
123
+ const filterFn = (fullName: string) => {
124
+ const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
125
+ if (separatorPos <= 0) {
126
+ return false;
127
+ }
128
+ const automationName = fullName.substring(0, separatorPos);
129
+ return [driverName, ALL_DRIVERS_MATCH].includes(automationName);
130
+ };
131
+ return features.filter(filterFn);
132
+ }
package/lib/main.js CHANGED
@@ -177,7 +177,7 @@ function determineAppiumHomeSource(appiumHomeFromArgs) {
177
177
  *
178
178
  * @template {CliCommand} [Cmd=ServerCommand]
179
179
  * @template {CliExtensionSubcommand|void} [SubCmd=void]
180
- * @param {Args<Cmd, SubCmd>} [args] - Partial args (progammatic usage only)
180
+ * @param {Args<Cmd, SubCmd>} [args] - Partial args (programmatic usage only)
181
181
  * @returns {Promise<InitResult<Cmd>>}
182
182
  * @example
183
183
  * import {init, getSchema} from 'appium';
@@ -375,6 +375,9 @@ async function main(args) {
375
375
 
376
376
  await logStartupInfo(parsedArgs);
377
377
 
378
+ // handle the insecure feature configuration since some features may apply globally
379
+ appiumDriver.configureGlobalFeatures();
380
+
378
381
  const appiumHomeSourceName = determineAppiumHomeSource(args?.appiumHome);
379
382
  logger.debug(`The ${appiumHomeSourceName}: ${appiumHome}`);
380
383
 
@@ -1,6 +1,6 @@
1
1
  import {ArgumentTypeError} from 'argparse';
2
2
  import _ from 'lodash';
3
- import {formatErrors as formatErrors} from '../config-file';
3
+ import {formatErrors} from '../config-file';
4
4
  import {flattenSchema, validate} from './schema';
5
5
  import {transformers, parseCsvLine} from './cli-transformers';
6
6
 
@@ -225,7 +225,7 @@ function subSchemaToArgDef(subSchema, argSpec) {
225
225
  * ArgumentDefinitions for handoff to `argparse`.
226
226
  *
227
227
  * @throws If schema has not been added to ajv (via `finalizeSchema()`)
228
- * @returns {import('../cli/args').ArgumentDefinitions} A map of arryas of
228
+ * @returns {import('../cli/args').ArgumentDefinitions} A map of arrays of
229
229
  * aliases to `argparse` arguments; empty if no schema found
230
230
  */
231
231
  export function toParserArgs() {
@@ -421,7 +421,7 @@ class AppiumSchema {
421
421
  * name. Used when translating to `argparse` options or getting the list of
422
422
  * default values (see {@link AppiumSchema.getDefaults}) for CLI or otherwise.
423
423
  *
424
- * The return value is an intermediate reprsentation used by `cli-args`
424
+ * The return value is an intermediate representation used by `cli-args`
425
425
  * module's `toParserArgs`, which converts the finalized schema to parameters
426
426
  * used by `argparse`.
427
427
  * @throws If {@link AppiumSchema.finalize} has not been called yet.
package/lib/utils.js CHANGED
@@ -17,8 +17,6 @@ const STANDARD_CAPS_LOWERCASE = new Set([...STANDARD_CAPS].map((cap) => cap.toLo
17
17
  export const V4_BROADCAST_IP = '0.0.0.0';
18
18
  export const V6_BROADCAST_IP = '::';
19
19
  export const npmPackage = fs.readPackageJsonFrom(__dirname);
20
- const ALL_DRIVERS_MATCH = '*';
21
- const FEATURE_NAME_SEPARATOR = ':';
22
20
 
23
21
  /**
24
22
  *
@@ -381,7 +379,7 @@ export function isPluginCommandArgs(args) {
381
379
  *
382
380
  * @param {4|6|null} family Either 4 to include ipv4 addresses only,
383
381
  * 6 to include ipv6 addresses only, or null to include all of them
384
- * @returns {os.NetworkInterfaceInfo[]} The list of matched interfcaes
382
+ * @returns {os.NetworkInterfaceInfo[]} The list of matched interfaces
385
383
  */
386
384
  export function fetchInterfaces (family = null) {
387
385
  let familyValue = null;
@@ -463,37 +461,6 @@ export function isBroadcastIp(address) {
463
461
  return [V4_BROADCAST_IP, V6_BROADCAST_IP, `[${V6_BROADCAST_IP}]`].includes(address);
464
462
  }
465
463
 
466
- /**
467
- * Validates the list of allowed/denied server features
468
- *
469
- * @param {string[]} features
470
- * @returns {string[]}
471
- */
472
- export function validateFeatures(features) {
473
- const validator = (/** @type {string} */ fullName) => {
474
- const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
475
- // TODO: This is for the backward compatibility with Appium2
476
- // TODO: In Appium3 the separator will be mandatory
477
- if (separatorPos < 0) {
478
- return `${ALL_DRIVERS_MATCH}${FEATURE_NAME_SEPARATOR}${fullName}`;
479
- }
480
-
481
- const [automationName, featureName] = [
482
- fullName.substring(0, separatorPos),
483
- fullName.substring(separatorPos + 1)
484
- ];
485
- if (!automationName || !featureName) {
486
- throw new Error(
487
- `The full feature name must include both the destination automation name or the ` +
488
- `'${ALL_DRIVERS_MATCH}' wildcard to apply the feature to all installed drivers, and ` +
489
- `the feature name split by a colon, got '${fullName}' instead`
490
- );
491
- }
492
- return fullName;
493
- };
494
- return features.map(validator);
495
- }
496
-
497
464
  /**
498
465
  * @typedef {import('@appium/types').StringRecord} StringRecord
499
466
  * @typedef {import('@appium/types').BaseDriverCapConstraints} BaseDriverCapConstraints
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.18.0",
3
+ "version": "2.19.0",
4
4
  "description": "Automation for Apps.",
5
5
  "keywords": [
6
6
  "automation",
@@ -60,20 +60,20 @@
60
60
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
61
61
  },
62
62
  "dependencies": {
63
- "@appium/base-driver": "^9.17.0",
64
- "@appium/base-plugin": "^2.3.6",
65
- "@appium/docutils": "^1.1.0",
66
- "@appium/logger": "^1.7.0",
63
+ "@appium/base-driver": "^9.18.0",
64
+ "@appium/base-plugin": "^2.3.7",
65
+ "@appium/docutils": "^1.1.1",
66
+ "@appium/logger": "^1.7.1",
67
67
  "@appium/schema": "^0.8.1",
68
- "@appium/support": "^6.1.0",
69
- "@appium/types": "^0.25.3",
68
+ "@appium/support": "^6.1.1",
69
+ "@appium/types": "^0.26.0",
70
70
  "@sidvind/better-ajv-errors": "3.0.1",
71
71
  "ajv": "8.17.1",
72
72
  "ajv-formats": "3.0.1",
73
73
  "argparse": "2.0.1",
74
74
  "async-lock": "1.4.1",
75
75
  "asyncbox": "3.0.0",
76
- "axios": "1.8.4",
76
+ "axios": "1.9.0",
77
77
  "bluebird": "3.7.2",
78
78
  "lilconfig": "3.1.3",
79
79
  "lodash": "4.17.21",
@@ -81,14 +81,14 @@
81
81
  "ora": "5.4.1",
82
82
  "package-changed": "3.0.0",
83
83
  "resolve-from": "5.0.0",
84
- "semver": "7.7.1",
84
+ "semver": "7.7.2",
85
85
  "source-map-support": "0.5.21",
86
- "teen_process": "2.3.1",
87
- "type-fest": "4.40.0",
86
+ "teen_process": "2.3.2",
87
+ "type-fest": "4.41.0",
88
88
  "winston": "3.17.0",
89
89
  "wrap-ansi": "7.0.0",
90
- "ws": "8.18.1",
91
- "yaml": "2.7.1"
90
+ "ws": "8.18.2",
91
+ "yaml": "2.8.0"
92
92
  },
93
93
  "engines": {
94
94
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "8476bd3f65fc549f9a589d20d19236d0ce4ea335"
100
+ "gitHead": "c8fe4412525f7e1fa237813cf83fe7d98f0125eb"
101
101
  }