Skip to content

Fuzzing framework #969

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

Open
wants to merge 74 commits into
base: master
Choose a base branch
from

Conversation

Gustavo-Jodar
Copy link

@Gustavo-Jodar Gustavo-Jodar commented May 19, 2025

Description

New fuzzing framework for Ledger SDK.
If you want to test the framework with an app, you can have a look at the boilerplate PR LedgerHQ/app-boilerplate#163

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Tests
  • Documentation
  • Other (for changes that might not fit in any category)

@ledger-wiz-cspm-secret-detection
Copy link

ledger-wiz-cspm-secret-detection bot commented May 19, 2025

Wiz Scan Summary

Scanner Findings
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations 1 High 1 Medium
Total 1 High 1 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@bboilot-ledger bboilot-ledger changed the title Gjo automatic mocks WIP - Fuzzing framework May 19, 2025
Copy link
Contributor

@0pendev 0pendev left a comment

Choose a reason for hiding this comment

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

Nice iteration. Will test it but it looks fairly easy to use and documented enough for new commers.

Made a review on the CMake scripts.

@Gustavo-Jodar Gustavo-Jodar force-pushed the gjo_automatic_mocks branch from 0b29590 to 6a77b64 Compare May 20, 2025 15:53
@Gustavo-Jodar Gustavo-Jodar requested a review from 0pendev May 27, 2025 11:53
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.08%. Comparing base (1fc96d8) to head (97cf2cb).
Report is 45 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #969      +/-   ##
==========================================
+ Coverage   61.45%   62.08%   +0.62%     
==========================================
  Files          13       13              
  Lines        1816     1817       +1     
==========================================
+ Hits         1116     1128      +12     
+ Misses        700      689      -11     
Flag Coverage Δ
unittests 62.08% <ø> (+0.62%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@Gustavo-Jodar Gustavo-Jodar force-pushed the gjo_automatic_mocks branch 4 times, most recently from 443e651 to da64141 Compare June 17, 2025 15:40
@Gustavo-Jodar Gustavo-Jodar force-pushed the gjo_automatic_mocks branch 2 times, most recently from 5549a40 to 3c70913 Compare June 25, 2025 14:30
@Gustavo-Jodar Gustavo-Jodar force-pushed the gjo_automatic_mocks branch 2 times, most recently from 3d5b806 to 6d18e2a Compare July 11, 2025 15:15
@Gustavo-Jodar Gustavo-Jodar force-pushed the gjo_automatic_mocks branch 2 times, most recently from dcd5b2f to 67b7893 Compare July 18, 2025 14:57
@bboilot-ledger bboilot-ledger changed the title WIP - Fuzzing framework Fuzzing framework Jul 21, 2025
@bboilot-ledger bboilot-ledger marked this pull request as ready for review July 21, 2025 09:08
@bboilot-ledger
Copy link
Contributor

FYI, if you want to test the framework with an app, you can have a look at the boilerplate PR LedgerHQ/app-boilerplate#163

@@ -0,0 +1,104 @@
API_LEVEL=22
Copy link
Contributor

Choose a reason for hiding this comment

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

This API_LEVEL value is already obsolete now.
How can we force the macros to be regenerated, at least on the PR workflows?
Moreover, we should probably find a way to auto-update the macro files regularly, to ensure they are always up-to-date, aligned with the surrent SDK
Maybe those files should not be stored under git, but generated at runtime?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Gustavo-Jodar did you leave this as an example? Or is there another use case?
This API_LEVEL should be present in the compile_commands.json when running from a released SDK.

Copy link
Author

Choose a reason for hiding this comment

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

To generate those files I extracted the macro definitions used when building app-boilerplate with the SDK, and it was left there like this as an example that should be changed in order to fuzz the sdk.
Which exposes the problem of having them obsolete, since this API_LEVEL was the one used before a new version of the sdk (interval between this review and my commit).
This process could be automated, since it is just a matter of compiling app-boilerplate with bear and using extract_macros.py to make the files.

Comment on lines 22 to 28
execute_process(
COMMAND sh -c "BOLOS_SDK=\${STAX_SDK} && TARGET=${TARGET_DEVICE} && CC=clang make list-defines"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/macros"
OUTPUT_VARIABLE MACRO_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to get as far as possible from platform specific commands.
Cmake has a few commands/functinos for such use cases.
Here we could try something like cmake env

Suggested change
execute_process(
COMMAND sh -c "BOLOS_SDK=\${STAX_SDK} && TARGET=${TARGET_DEVICE} && CC=clang make list-defines"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/macros"
OUTPUT_VARIABLE MACRO_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env
BOLOS_SDK=${STAX_SDK}
TARGET=${TARGET_DEVICE}
CC=clang
make list-defines
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/macros"
OUTPUT_VARIABLE MACRO_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if we specify TARGET then we should point to the currently in use sdk instead of STAX_SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants