fix(diagnostics): redact the OCF device name; log description on unknown type
Two things a review of this branch turned up. /oic/d's `n` is free text the owner sets from the SmartThings app, so it may carry a person's name. Nothing in the /device/0 dump has ever exposed it -- it only became reachable when diagnostics started reporting /oic/d earlier in this branch, which would have started carrying it into public issue reports. Redact it. `rt`, the device-type signal the block exists for, is untouched, and no /device/0 resource uses a bare 'n' key, so nothing else changes. The unknown-device-type warning logged only modelNum. That line is what a user pastes into an issue, and modelNum alone can't identify a washer from a dryer -- both report the shared DA_WM_ laundry board, and detection reads the consumer-model code out of `description` for exactly that reason. Log both fields.
This commit is contained in:
4 files changed
+41
-16
No files matched your search
+11
-7
@@ -78,28 +78,32 @@ def test_redacts_bare_ocf_identity_keys():
|
||||
"""/oic/d and /oic/p identify the unit with two-letter keys ('di', 'pi')
|
||||
that the substring rules can't see."""
|
||||
redacted = redact_resources({
|
||||
'/oic/d': {'di': 'ab-cd-ef', 'n': 'Family Hub'},
|
||||
'/oic/d': {'di': 'ab-cd-ef', 'n': "Marc's Fridge",
|
||||
'rt': ['oic.wk.d', 'oic.d.refrigerator']},
|
||||
'/oic/p': {'pi': '12-34-56', 'mnmo': 'RF9000B'},
|
||||
})
|
||||
|
||||
assert redacted['/oic/d']['di'] == REDACTED
|
||||
assert redacted['/oic/p']['pi'] == REDACTED
|
||||
# Non-identifying neighbours in the same payloads survive.
|
||||
assert redacted['/oic/d']['n'] == 'Family Hub'
|
||||
# 'n' is free text the owner sets from the SmartThings app, so it can
|
||||
# carry a person's name -- redacted too. `rt`, the device-type signal
|
||||
# we actually want out of /oic/d, is not.
|
||||
assert redacted['/oic/d']['n'] == REDACTED
|
||||
assert redacted['/oic/d']['rt'] == ['oic.wk.d', 'oic.d.refrigerator']
|
||||
assert redacted['/oic/p']['mnmo'] == 'RF9000B'
|
||||
|
||||
|
||||
def test_bare_key_redaction_does_not_leak_into_substring_matching():
|
||||
"""'di'/'pi' are whole-key matches only -- plenty of ordinary appliance
|
||||
fields contain those two letters and must survive untouched."""
|
||||
"""The bare keys are whole-key matches only -- plenty of ordinary
|
||||
appliance fields contain those letters and must survive untouched."""
|
||||
redacted = redact_resources({
|
||||
'/x': {
|
||||
'condition': 'Normal', 'display': 'On', 'dispenser': 'Cubed',
|
||||
'humidity': '45', 'spinSpeed': '1200',
|
||||
'humidity': '45', 'spinSpeed': '1200', 'name': 'FilterProgress',
|
||||
},
|
||||
})
|
||||
|
||||
assert redacted['/x'] == {
|
||||
'condition': 'Normal', 'display': 'On', 'dispenser': 'Cubed',
|
||||
'humidity': '45', 'spinSpeed': '1200',
|
||||
'humidity': '45', 'spinSpeed': '1200', 'name': 'FilterProgress',
|
||||
}
|
||||
Reference in new issue
Block a user