homebridge-lg-thinq-2 2.0.11 → 2.0.13

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## v2.0.13
4
+
5
+ ### Security
6
+
7
+ * Fixed the host name checks that pick the root certificate for the MQTT connection: the dots in the patterns were not escaped, so they matched any character and host names that only looked like AWS IoT or LG hosts. Found by CodeQL.
8
+ * When migrating cache files from older versions, each file is now checked and read through the same open file, so it cannot be replaced in between. Found by CodeQL.
9
+
10
+ ### Development
11
+
12
+ * Hardened the GitHub Actions workflows: the CI workflow now has a read-only token, actions are pinned to commit SHAs, dependencies are installed without running their install scripts (`npm ci --ignore-scripts`), jobs have time limits, and newer pushes to a pull request cancel older checks.
13
+ * Added Dependabot version updates for npm and GitHub Actions (weekly, development dependencies grouped), and CodeQL code scanning for JavaScript and TypeScript.
14
+
15
+ ## v2.0.12
16
+
17
+ ### Homebridge UI
18
+
19
+ * The settings of each device type are now shown open instead of in a collapsed section. They were collapsed when every device showed the settings of all device types; now each device shows only its own, so collapsing them only added a click.
20
+
3
21
  ## v2.0.11
4
22
 
5
23
  ### Login
@@ -288,8 +288,6 @@
288
288
  "type": "fieldset",
289
289
  "title": "Air purifier specific settings",
290
290
  "description": "Configure air purifier device settings.",
291
- "expandable": true,
292
- "expanded": false,
293
291
  "items": [
294
292
  "devices[].air_fast_mode"
295
293
  ],
@@ -301,8 +299,6 @@
301
299
  "type": "fieldset",
302
300
  "title": "Washer / Dryer specific settings",
303
301
  "description": "Configure washer/dryer device settings.",
304
- "expandable": true,
305
- "expanded": false,
306
302
  "items": [
307
303
  "devices[].washer_trigger",
308
304
  "devices[].washer_tub_clean",
@@ -316,8 +312,6 @@
316
312
  "type": "fieldset",
317
313
  "title": "Air conditioner specific settings",
318
314
  "description": "Configure AC device settings.",
319
- "expandable": true,
320
- "expanded": false,
321
315
  "items": [
322
316
  "devices[].ac_air_quality",
323
317
  "devices[].ac_mode",
@@ -349,8 +343,6 @@
349
343
  "type": "fieldset",
350
344
  "title": "Refrigerator specific settings",
351
345
  "description": "Configure refrigerator device settings.",
352
- "expandable": true,
353
- "expanded": false,
354
346
  "items": [
355
347
  "devices[].ref_express_freezer",
356
348
  "devices[].ref_express_fridge",
@@ -364,8 +356,6 @@
364
356
  "type": "fieldset",
365
357
  "title": "Dishwasher specific settings",
366
358
  "description": "Configure dishwasher device settings.",
367
- "expandable": true,
368
- "expanded": false,
369
359
  "items": [
370
360
  "devices[].dishwasher_trigger"
371
361
  ],
@@ -2,6 +2,20 @@ import NodePersist from 'node-persist';
2
2
  import Fs from 'fs/promises';
3
3
  import Path from 'path';
4
4
  import Crypto from 'crypto';
5
+ /** Reads a file as UTF-8, or returns null if it is missing or not a regular file. */
6
+ async function readRegularFile(path) {
7
+ const handle = await Fs.open(path, 'r').catch(() => null);
8
+ if (!handle) {
9
+ return null;
10
+ }
11
+ try {
12
+ const stat = await handle.stat();
13
+ return stat.isFile() ? await handle.readFile({ encoding: 'utf8' }) : null;
14
+ }
15
+ finally {
16
+ await handle.close();
17
+ }
18
+ }
5
19
  export function isPersistCacheMiss(value) {
6
20
  return value === null || value === undefined;
7
21
  }
@@ -58,15 +72,15 @@ export default class Persist {
58
72
  continue;
59
73
  }
60
74
  const p = Path.join(this.dir, f);
61
- const stat = await Fs.stat(p).catch(() => null);
62
- if (!stat || !stat.isFile()) {
63
- continue;
64
- }
65
75
  if (/^[a-f0-9]{64}$/.test(f)) {
66
76
  continue;
67
77
  }
68
78
  try {
69
- const raw = await Fs.readFile(p, { encoding: 'utf8' });
79
+ // Check and read the same open file, so it cannot be replaced in between.
80
+ const raw = await readRegularFile(p);
81
+ if (raw === null) {
82
+ continue;
83
+ }
70
84
  const parsed = JSON.parse(raw);
71
85
  const key = parsed && typeof parsed === 'object' && parsed.key ? parsed.key : f;
72
86
  const datum = { key, value: parsed && parsed.key ? parsed.value ?? parsed : parsed, ttl: undefined };
@@ -12,11 +12,14 @@ export const MQTT_CLIENT_PATH = 'service/users/client';
12
12
  export const MQTT_CERTIFICATE_PATH = 'service/users/client/certificate';
13
13
  export const MQTT_RETRY_ATTEMPTS = 5;
14
14
  export const MQTT_RETRY_DELAY_MS = 5000;
15
+ // Dots are escaped: an unescaped "." matches any character, so other hosts could match.
16
+ const AWS_ATS_MQTT_HOST = /^[^.]+-ats\.iot\.[^.]+\.amazonaws\.com$/;
17
+ const LG_MQTT_HOST = /^[^.]+\.iot\.ruic\.lgthinq\.com$/;
15
18
  export function rootCaUrlForMqttHost(hostname) {
16
- if (hostname.match(/^([^.]+)-ats.iot.([^.]+).amazonaws.com$/g)) {
19
+ if (AWS_ATS_MQTT_HOST.test(hostname)) {
17
20
  return ATS_ROOT_CA_URL;
18
21
  }
19
- if (hostname.match(/^([^.]+).iot.ruic.lgthinq.com$/g)) {
22
+ if (LG_MQTT_HOST.test(hostname)) {
20
23
  return LG_ROOT_CA_URL;
21
24
  }
22
25
  return LEGACY_ROOT_CA_URL;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge LG ThinQ 2",
3
3
  "name": "homebridge-lg-thinq-2",
4
- "version": "2.0.11",
4
+ "version": "2.0.13",
5
5
  "description": "Community-maintained continuation of homebridge-lg-thinq: a Homebridge plugin for controlling/monitoring LG ThinQ devices via the LG ThinQ platform.",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",