Skip to content
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

fix: ignore SmartStart requests with missing keys for granted security classes #6787

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,16 @@ export class ZWaveController
// And that the entry contains valid data
assertProvisioningEntry(entry);

// Discard any invalid security classes that may have been granted. This can happen
// when switching the protocol to ZWLR for a device that requests S2 Unauthenticated
// for Z-Wave Classic.
if (entry.protocol === Protocols.ZWaveLongRange) {
entry.securityClasses = entry.securityClasses.filter((sc) =>
sc === SecurityClass.S2_AccessControl
|| sc === SecurityClass.S2_Authenticated
);
}

const provisioningList = [...this.provisioningList];

const index = provisioningList.findIndex((e) => e.dsk === entry.dsk);
Expand Down Expand Up @@ -2276,6 +2286,27 @@ export class ZWaveController
return;
}

// Ignore provisioning entries where some of the granted keys are not configured
const securityManager = isLongRange
? this.driver.securityManagerLR
: this.driver.securityManager2;
const missingKeys = provisioningEntry.securityClasses.filter(
(sc) => !securityManager?.hasKeysForSecurityClass(sc),
);
if (missingKeys.length > 0) {
this.driver.controllerLog.print(
`Ignoring inclusion request because the following security classes were granted but have no key configured:${
missingKeys.map((sc) =>
`\n· ${getEnumMemberName(SecurityClass, sc)}${
isLongRange ? " (Long Range)" : ""
}`
).join("")
}`,
"error",
);
return;
}

this.driver.controllerLog.print(
"NWI Home ID found in provisioning list, including node...",
);
Expand Down
Loading