Skip to content

Add dedicated Astarte FDO library#1819

Open
mizzet1 wants to merge 3 commits intoastarte-platform:masterfrom
mizzet1:astartefdolib
Open

Add dedicated Astarte FDO library#1819
mizzet1 wants to merge 3 commits intoastarte-platform:masterfrom
mizzet1:astartefdolib

Conversation

@mizzet1
Copy link
Contributor

@mizzet1 mizzet1 commented Feb 25, 2026

to avoid circular dependencies (and having libraries depend on apps), this pr aim to create a new library astarte_fdo to move dedicated fdo modules there

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.80%. Comparing base (c98b9ad) to head (8401f6c).

Files with missing lines Patch % Lines
...te_data_access/lib/astarte_data_access/fdo/cbor.ex 0.00% 13 Missing ⚠️
..._access/lib/astarte_data_access/fdo/session_key.ex 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1819      +/-   ##
==========================================
- Coverage   85.96%   85.80%   -0.17%     
==========================================
  Files         559      561       +2     
  Lines        9757     9747      -10     
==========================================
- Hits         8388     8363      -25     
- Misses       1369     1384      +15     
Files with missing lines Coverage Δ
...keeping/lib/astarte_housekeeping/realms/queries.ex 91.54% <ø> (ø)
...airing/lib/astarte_pairing/fdo/owner_onboarding.ex 74.72% <ø> (+0.49%) ⬆️
...airing/fdo/owner_onboarding/device_service_info.ex 73.33% <ø> (ø)
.../fdo/owner_onboarding/device_service_info_ready.ex 80.95% <ø> (ø)
...pairing/fdo/owner_onboarding/owner_service_info.ex 100.00% <ø> (ø)
...tarte_pairing/fdo/owner_onboarding/prove_ov_hdr.ex 72.22% <ø> (ø)
...ib/astarte_pairing/fdo/owner_onboarding/session.ex 98.21% <ø> (+3.84%) ⬆️
...starte_pairing/fdo/owner_onboarding/session_key.ex 90.76% <ø> (-0.28%) ⬇️
...tarte_pairing/fdo/owner_onboarding/setup_device.ex 90.00% <ø> (ø)
...rte_pairing/fdo/owner_onboarding/signature_info.ex 57.14% <ø> (-1.20%) ⬇️
... and 15 more

... and 15 files with indirect coverage changes

Flag Coverage Δ
astarte_appengine_api 85.71% <ø> (-0.17%) ⬇️
astarte_data_access 79.10% <0.00%> (-3.46%) ⬇️
astarte_data_updater_plant 86.98% <ø> (-0.08%) ⬇️
astarte_events 79.40% <ø> (ø)
astarte_generators 97.56% <ø> (-0.18%) ⬇️
astarte_realm_management 87.58% <ø> (-0.08%) ⬇️
astarte_rpc 88.23% <ø> (ø)
astarte_trigger_engine 82.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mizzet1 mizzet1 force-pushed the astartefdolib branch 7 times, most recently from 818b75e to 8845121 Compare March 3, 2026 13:22
@mizzet1 mizzet1 changed the base branch from feat/fido-device-onboard to release-1.3 March 3, 2026 13:36
@github-actions github-actions bot added the size/m label Mar 3, 2026
@mizzet1 mizzet1 changed the base branch from release-1.3 to master March 3, 2026 15:03
@github-actions github-actions bot added the size/l label Mar 3, 2026
@mizzet1 mizzet1 force-pushed the astartefdolib branch 12 times, most recently from 92aaab0 to da1285f Compare March 4, 2026 17:07
@mizzet1
Copy link
Contributor Author

mizzet1 commented Mar 4, 2026

Points addressed from #1801 :

  • Added decoded_cbor function directly in the Hash module
  • Use custom type Astarte.FDO.CBOR, using: Astarte.FDO.Hash for hmac field in to2_session
  • Use Exandra.EmbeddedType instead of Exandra.UDT for session keys fields

Missing:
explore avoid having a custom SessionKey type in astarte_fdo (but keeping it at the db level) and encode/decode to/from COSE.Keys.Symmetric (by opening pr in COSE)

@mizzet1 mizzet1 force-pushed the astartefdolib branch 2 times, most recently from a4725f9 to f63fdb8 Compare March 4, 2026 17:24
sevk blob,
svk blob,
sek blob,
sevk session_key,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that the feature branch has been merged, we actually do need to create new migrations and treat existing ones as read only

@@ -0,0 +1,18 @@
defmodule AstarteFdo do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can delete this file

# limitations under the License.
#

defmodule Astarte.FDO.CBOR do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is astarte data access material, it has nothing to do with astarte_fdo

Comment on lines -20 to -26
@moduledoc """
This module defines the structure of an error message in
the FDO protocol, including the error code, previous message ID,
error message, timestamp, and correlation ID.
It also provides functions for encoding the error message
into a CBOR for transmission in the FDO protocol.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have we removed moduledocs?

Comment on lines +35 to +36
{:ok, public_key} <- decode(cbor_list) do
{:ok, public_key}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should trigger a failure in credo, why isn't it failing?

{:httpoison, "~> 2.2", override: true}
{:astarte_fdo, path: astarte_lib("astarte_fdo")},
{:astarte_generators, path: astarte_lib("astarte_generators"), only: [:dev, :test]},
{:stream_data, "~> 1.1", only: [:dev, :test]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this added?

Comment on lines 31 to 32
alias COSE.Messages.Sign1
alias COSE.Messages.Sign1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

end
end

def fetch(realm_name, guid) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, we use core modules to place implementations of functions which are complex or long enough and internal logic makes sense on its own

for instance, we may have a function in the "outer" module with validation and the function in the core module which expects that its preconditions are met, and the outer calls core after having made its validations.

in general, you never want other modules to use Core directly (except maybe tests), but all functionality should be available from the outer OwnershipVoucher module

personally, I would leave these functions there


def from_db(%{"alg" => alg, "k" => k, "kty" => kty}) do
%Symmetric{
alg: String.to_existing_atom(alg),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cursed 💀

}
)
when is_empty(service_info) do
when service_info.module == nil and service_info.key == nil and service_info.value == nil do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the guard

@mizzet1 mizzet1 force-pushed the astartefdolib branch 14 times, most recently from 9da63f2 to 64d8fd9 Compare March 6, 2026 11:01
mizzet1 added 3 commits March 6, 2026 12:06
Signed-off-by: Riccardo Nalgi <riccardo.nalgi@secomind.com>
Signed-off-by: Riccardo Nalgi <riccardo.nalgi@secomind.com>
- remove unused astarte_fdo and gitignore files from fdo library
- create new migrations and treat existing ones as read only
- move all Ecto related FDO modules to astarte_data_access
- add missing moduledocs
- place "fdo" scope under libraries
- delete github workflow files from fdo library
- add missing copyright header
- use guard to check emptyness of service info
- remove data_access dependency from fdo library

Signed-off-by: Riccardo Nalgi <riccardo.nalgi@secomind.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants