From e0775cb16122325c8dce04b6f0cd2622e5da0b5b Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Tue, 17 Oct 2023 17:18:09 +0200 Subject: [PATCH] Misspelings --- .codespell_ignore_list | 1 + .github/workflows/misspellings_checks.yml | 29 +++++++++++++++++++++++ protocol.md | 10 ++++---- src/apdu_parser.c | 6 ++--- src/buffer.c | 4 ++-- src/check_tx_signature.c | 2 +- src/parse_check_address_message.c | 2 +- src/parse_coin_config.c | 2 +- src/process_transaction.c | 2 +- src/ui/validate_transaction_nbgl.c | 8 +++---- test/python/apps/exchange_test_runner.py | 2 +- test/python/apps/signing_authority.py | 6 ++--- test/python/apps/tezos.py | 2 +- test/python/test_fund_flow_ethereum.py | 4 ++-- test/python/test_sell_flow_ethereum.py | 2 +- 15 files changed, 56 insertions(+), 26 deletions(-) create mode 100644 .codespell_ignore_list create mode 100644 .github/workflows/misspellings_checks.yml diff --git a/.codespell_ignore_list b/.codespell_ignore_list new file mode 100644 index 00000000..22224534 --- /dev/null +++ b/.codespell_ignore_list @@ -0,0 +1 @@ +nin diff --git a/.github/workflows/misspellings_checks.yml b/.github/workflows/misspellings_checks.yml new file mode 100644 index 00000000..e595d194 --- /dev/null +++ b/.github/workflows/misspellings_checks.yml @@ -0,0 +1,29 @@ +name: Misspellings checks + +# This workflow performs some misspelling checks on the repository +# It is there to help us maintain a level of quality in our codebase and does not have to be kept on forked +# applications. + +on: + workflow_dispatch: + push: + branches: + - master + - main + - develop + pull_request: + +jobs: + misspell: + name: Check misspellings + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v3 + + - name: Check misspellings + uses: codespell-project/actions-codespell@v1 + with: + builtin: clear,rare + check_filenames: true + path: src/,test/python/,protocol.md,Makefile,README.md diff --git a/protocol.md b/protocol.md index 6c9c8d57..8cc734d0 100644 --- a/protocol.md +++ b/protocol.md @@ -1,6 +1,6 @@ # Protocol to speak with EXCHANGE application -Communication is done through a serie of request-response exchanges (APDU / RAPDU). +Communication is done through a series of request-response exchanges (APDU / RAPDU). ## Request: @@ -19,7 +19,7 @@ Communication is done through a serie of request-response exchanges (APDU / RAPD | Name | Value | Description | | ---------------------------- | ----- | ------------------------------------------------------------------------------------- | -| GET_VERSION | 0x02 | Get application version. This APDU can be sent independantly of the current app state | +| GET_VERSION | 0x02 | Get application version. This APDU can be sent independently of the current app state | | START_NEW_TRANSACTION | 0x03 | Start new EXCHANGE transaction. This APDU resets the app state | | SET_PARTNER_KEY | 0x04 | Set the credentials of the exchange partner | | CHECK_PARTNER | 0x05 | Check that the credentials of the exchange partner are signed by the Ledger key | @@ -119,7 +119,7 @@ No data expected. | N bytes | Partner name encoded with utf-8 | | LC - (1 + N) bytes | Partner public key | -##### For all UNFIED TYPES, the data for this command is: +##### For all UNIFIED TYPES, the data for this command is: | Bytes | Description | | ------------------ | ------------------------------------ | @@ -149,7 +149,7 @@ Please refer to the src/protobuf files for the actual transaction proposal conte | 1 byte | Length M of the transaction fees | | M bytes | Transaction fees | -##### For all UNFIED TYPES, the data for this command is: +##### For all UNIFIED TYPES, the data for this command is: | Bytes | Description | | ------- | -------------------------------------------- | @@ -177,7 +177,7 @@ For SELL_LEGACY and FUND_LEGACY the signature is computed on the transaction pro For SWAP_LEGACY and FUND_LEGACY, the signature is in DER format. \ For SELL_LEGACY the signature is in (R,S) format. -##### For all UNFIED TYPES, the data for this command is: +##### For all UNIFIED TYPES, the data for this command is: | Bytes | Description | | ------------ | ------------------------------------------------------------- | diff --git a/src/apdu_parser.c b/src/apdu_parser.c index 51efc5be..631edbf9 100644 --- a/src/apdu_parser.c +++ b/src/apdu_parser.c @@ -36,9 +36,9 @@ typedef struct apdu_s { uint8_t rate; uint8_t subcommand; uint16_t data_length; - // We could have put the recontructed apdu buffer here but it would increase the RAM usage by + // We could have put the reconstructed apdu buffer here but it would increase the RAM usage by // 512 bytes which is a lot on NANOS - // Instead the recontructed apdu buffer is G_swap_ctx.raw_transaction + // Instead the reconstructed apdu buffer is G_swap_ctx.raw_transaction // It is unionized with the decoded protobuf transaction requests // Pro: less memory usage // Cons: use cautiously and only during the command PROCESS_TRANSACTION_RESPONSE_COMMAND @@ -74,7 +74,7 @@ static uint16_t check_instruction(uint8_t instruction, uint8_t subcommand) { case GET_VERSION_COMMAND: // We ignore the current context for this command as it doesn't modify anything check_subcommand_context = false; - // No strict dependancy on the current state as long as it is not a protected state + // No strict dependency on the current state as long as it is not a protected state // (WAITING_USER_VALIDATION and WAITING_SIGNING) check_current_state = -1; break; diff --git a/src/buffer.c b/src/buffer.c index 2c4a98bd..82230536 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -6,7 +6,7 @@ // param[in] the total size of the buffer to parse // param[in] the size of the length field in the header // param[out] the buf_t read from in_buffer at offset, can by 0 sized -// param[in/out] the current offset at wich we are in +// param[in/out] the current offset at which we are in bool parse_to_sized_buffer(uint8_t *in_buffer, uint16_t in_size, uint8_t size_of_length_field, @@ -55,7 +55,7 @@ bool parse_to_sized_buffer(uint8_t *in_buffer, // param[in] the total buffer to parse // param[in] the total size of the buffer to parse // param[out] the int read from in_buffer at offset -// param[in/out] the current offset at wich we are in +// param[in/out] the current offset at which we are in bool pop_uint8_from_buffer(uint8_t *in_buffer, uint16_t in_size, uint8_t *out, uint16_t *offset) { if (*offset + 1 > in_size) { PRINTF("Failed to read the uint, only %d bytes available\n", in_size); diff --git a/src/check_tx_signature.c b/src/check_tx_signature.c index dd86212a..0d09a020 100644 --- a/src/check_tx_signature.c +++ b/src/check_tx_signature.c @@ -78,7 +78,7 @@ int check_tx_signature(const command_t *cmd) { uint16_t payload_size = remaining_input.bytes[DER_OFFSET_LENGTH]; if (payload_size + DER_HEADER_SIZE != remaining_input.size) { - PRINTF("DER signature header advertizes %d bytes, we received %d\n", + PRINTF("DER signature header advertises %d bytes, we received %d\n", payload_size, remaining_input.size); return reply_error(INCORRECT_COMMAND_DATA); diff --git a/src/parse_check_address_message.c b/src/parse_check_address_message.c index c8a1682c..b83b9938 100644 --- a/src/parse_check_address_message.c +++ b/src/parse_check_address_message.c @@ -31,7 +31,7 @@ static bool parse_der_signature(uint8_t *in, uint16_t in_size, buf_t *der, uint1 // 1 byte 0x30 1 + X // 1 byte length C of compound object 2 + X // C bytes -// 1 byte length Y of address paramaters 1 + X + D +// 1 byte length Y of address parameters 1 + X + D // Y bytes of address parameters 2 + X + D int parse_check_address_message(const command_t *cmd, buf_t *config, diff --git a/src/parse_coin_config.c b/src/parse_coin_config.c index 2a82f0ba..13fe0e32 100644 --- a/src/parse_coin_config.c +++ b/src/parse_coin_config.c @@ -28,7 +28,7 @@ const app_name_alias_t appnames_aliases[] = { * - A the application name, La its size * - C the sub configuration, Lc its size * - * As the sub configuration is optionnal, we accept Lc == 0 + * As the sub configuration is optional, we accept Lc == 0 */ bool parse_coin_config(buf_t input, buf_t *ticker, diff --git a/src/process_transaction.c b/src/process_transaction.c index b01f6e74..549ff0e0 100644 --- a/src/process_transaction.c +++ b/src/process_transaction.c @@ -274,7 +274,7 @@ static void normalize_currencies(subcommand) { } } -// triming leading 0s +// trim leading 0s static void trim_amounts(subcommand) { if (subcommand == SWAP || subcommand == SWAP_NG) { trim_pb_bytes_array( diff --git a/src/ui/validate_transaction_nbgl.c b/src/ui/validate_transaction_nbgl.c index e3742488..4e8e7594 100644 --- a/src/ui/validate_transaction_nbgl.c +++ b/src/ui/validate_transaction_nbgl.c @@ -23,18 +23,18 @@ static char refusal_text[REFUSAL_TEXT_MAX_SIZE]; #define REVIEW_P1_TITLE "Review transaction" #define REVIEW_P1_CONFIRM "Sign transaction" -// Delimitor ' ' or '\n' +// Delimiter ' ' or '\n' #define REVIEW_P2 "to" -// Delimitor ' ' or '\n' +// Delimiter ' ' or '\n' // One of: #define REVIEW_P3_SWAP "swap " #define REVIEW_P3_SELL "sell " #define REVIEW_P3_FUND "fund account" -// Delimitor ' ' or '\n' +// Delimiter ' ' or '\n' // One of: #define REVIEW_P4_SWAP "to " @@ -187,7 +187,7 @@ void ui_validate_amounts(void) { break; } - // Detect if we shoud display on 2 or 3 lines. + // Detect if we should display on 2 or 3 lines. if ((G_swap_ctx.subcommand == FUND || G_swap_ctx.subcommand == FUND_NG) || (strlen(dyn_string_1) + strlen(dyn_string_2) >= 10)) { PRINTF("Review title and confirm on 3 lines\n"); diff --git a/test/python/apps/exchange_test_runner.py b/test/python/apps/exchange_test_runner.py index 324579af..b6bcf258 100644 --- a/test/python/apps/exchange_test_runner.py +++ b/test/python/apps/exchange_test_runner.py @@ -38,7 +38,7 @@ class ExchangeTestRunner: # fake_payout_memo: str # signature_refusal_error_code: int - # You can optionnaly overwrite the following default values if you want + # You can optionally overwrite the following default values if you want partner_name = "Default name" fund_user_id = "Jon Wick" fund_account_name = "My account 00" diff --git a/test/python/apps/signing_authority.py b/test/python/apps/signing_authority.py index dbfa7e78..6b7526d8 100644 --- a/test/python/apps/signing_authority.py +++ b/test/python/apps/signing_authority.py @@ -56,7 +56,7 @@ def __init__(self, curve: ec.EllipticCurve, name: str, existing_key: Optional[in @property def credentials(self) -> bytes: """ - :return: The partner credentials correctly formated for legacy flows + :return: The partner credentials correctly formatted for legacy flows :rtype: bytes """ return self._credentials @@ -64,7 +64,7 @@ def credentials(self) -> bytes: @property def credentials_ng(self) -> bytes: """ - :return: The partner credentials correctly formated for ng flows + :return: The partner credentials correctly formatted for ng flows :rtype: bytes """ return self._credentials_ng @@ -73,7 +73,7 @@ def sign(self, payload_to_sign: bytes) -> bytes: """ Sign the requested data - :param payload_to_sign: The payload the parnter needs to sign + :param payload_to_sign: The payload the partner needs to sign :type payload_to_sign: bytes :return: The payload signed diff --git a/test/python/apps/tezos.py b/test/python/apps/tezos.py index b2234aaa..3e27f269 100644 --- a/test/python/apps/tezos.py +++ b/test/python/apps/tezos.py @@ -99,7 +99,7 @@ def blake2_hash_pubkey(pubkey: bytes) -> bytes: return blake2b(pubkey, digest_size=HASH_SIZE).digest() -# Weird Tezos formating used for values: +# Weird Tezos formatting used for values: # Values are packed on the 7 week bits of each byte # The strongest bit is set to true if the value is over # Example with format(300): diff --git a/test/python/test_fund_flow_ethereum.py b/test/python/test_fund_flow_ethereum.py index 1865057e..f96f2bca 100644 --- a/test/python/test_fund_flow_ethereum.py +++ b/test/python/test_fund_flow_ethereum.py @@ -33,7 +33,7 @@ def test_fund_flow_ethereum_max_partner_name_length(backend, exchange_navigation eth = EthereumClient(backend) assert eth.get_public_key().status == 0x9000 # The original bug was that the Ethereum app was returning just after - # launch, and the first Ethereum:get_public_key call was in fact catched + # launch, and the first Ethereum:get_public_key call was in fact caught # by the Exchange app and interpreted as an Exchange::get_version call. # Exchange version are on 3 bytes, so we check the call does not return # 3 bytes of data @@ -68,7 +68,7 @@ def test_fund_flow_ethereum_min_partner_name_length(backend, exchange_navigation eth = EthereumClient(backend) assert eth.get_public_key().status == 0x9000 # The original bug was that the Ethereum app was returning just after - # launch, and the first Ethereum:get_public_key call was in fact catched + # launch, and the first Ethereum:get_public_key call was in fact caught # by the Exchange app and interpreted as an Exchange::get_version call. # Exchange version are on 3 bytes, so we check the call does not return # 3 bytes of data diff --git a/test/python/test_sell_flow_ethereum.py b/test/python/test_sell_flow_ethereum.py index 77b1eaed..6c339dd2 100644 --- a/test/python/test_sell_flow_ethereum.py +++ b/test/python/test_sell_flow_ethereum.py @@ -34,7 +34,7 @@ def test_sell_flow(backend, exchange_navigation_helper): eth = EthereumClient(backend) assert eth.get_public_key().status == 0x9000 # The original bug was that the Ethereum app was returning just after - # launch, and the first Ethereum:get_public_key call was in fact catched + # launch, and the first Ethereum:get_public_key call was in fact caught # by the Exchange app and interpreted as an Exchange::get_version call. # Exchange version are on 3 bytes, so we check the call does not return # 3 bytes of data