Skip to content

Commit

Permalink
Remove audit and logger statement from extensions request check (#1828)
Browse files Browse the repository at this point in the history
Older versions of NervesHubLink would crash if an unknown messages was
pushed down over the socket. Since extensions required a new message,
this could fail badly on older devices and so a check was put in place
to verify the Device API version NHL was reporting to know if it is safe
to request extension info or not.

This removes the audit log _and_ logger statement that was happening
when this safe check would not pass meaning the device version was too
old to request. However, this happens with _every_ socket connection and
can produce incredible amount of noise.

If that level of info is needed, I suggest a future change which shows
the device version reported and what that means for support on the
device (i.e. in the Device settings page perhaps?)
  • Loading branch information
jjcarstens authored Jan 24, 2025
1 parent 7393ed4 commit a9884a8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
10 changes: 0 additions & 10 deletions lib/nerves_hub/audit_logs/templates/device_templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ defmodule NervesHub.AuditLogs.DeviceTemplates do
AuditLogs.audit!(user, device, description)
end

@spec audit_unsupported_api_version(Device.t()) :: AuditLog.t()
def audit_unsupported_api_version(device) do
description =
"Device #{device.identifier} could not get extensions: Unsupported API version."

Logger.info("[DeviceChannel] #{description}")

AuditLogs.audit!(device, device, description)
end

## Firmware and upgrades

@spec audit_update_attempt(Device.t()) :: AuditLog.t()
Expand Down
3 changes: 1 addition & 2 deletions lib/nerves_hub_web/channels/device_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ defmodule NervesHubWeb.DeviceChannel do
# Earlier versions of nerves_hub_link don't have a fallback for unknown messages,
# so check version before requesting extensions
if safe_to_request_extensions?(socket.assigns.device_api_version),
do: push(socket, "extensions:get", %{}),
else: DeviceTemplates.audit_unsupported_api_version(device)
do: push(socket, "extensions:get", %{})

{:noreply, socket}
end
Expand Down

0 comments on commit a9884a8

Please sign in to comment.