Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better error messages when HMAC authentication is attempted by federates when RTI does not support it #461

Merged
merged 5 commits into from
Jul 7, 2024

Conversation

Jakio815
Copy link
Collaborator

@Jakio815 Jakio815 commented Jul 1, 2024

This gives better error messages in lf-lang/lingua-franca#2326.
When the federates are using the HMAC authentication as auth:true, and the RTI is not executed using the -a or --auth option, the RTI will not expect the MSG_TYPE_FED_NONCE type, and reject it.
For better errors, add a rejection code RTI_NOT_EXECUTED_WITH_AUTH and messages.

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

Walkthrough

The recent updates to the RTI system's federated components enhance authentication handling by introducing a specific error message when an RTI nonce is not executed with HMAC authentication. This comprehensive modification affects the message rejection process with refined error handling and logging, ensuring clearer communication and stricter security protocols.

Changes

File(s) Change Summary
core/federated/RTI/rti_remote.c Modified handling of MSG_TYPE_FED_NONCE to reject the connection with RTI_NOT_EXECUTED_WITH_AUTH and log an error message.
core/federated/federate.c Added a new condition to handle MSG_TYPE_REJECT with the error RTI_NOT_EXECUTED_WITH_AUTH during HMAC authentication.
include/core/federated/network/net_common.h Introduced the constant #define RTI_NOT_EXECUTED_WITH_AUTH 7.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RTI Remote
    participant Authentication Module

    Client->>RTI Remote: Send MSG_TYPE_FED_NONCE
    RTI Remote->>Authentication Module: Authenticate Message
    Authentication Module-->>RTI Remote: Authentication Failed
    RTI Remote->>Client: Send MSG_TYPE_REJECT with RTI_NOT_EXECUTED_WITH_AUTH
    RTI Remote->>Log System: Log error "RTI not executed with HMAC authentication"
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4f8ea7d and 301712b.

Files selected for processing (3)
  • core/federated/RTI/rti_remote.c (1 hunks)
  • core/federated/federate.c (1 hunks)
  • include/core/federated/network/net_common.h (1 hunks)
Files skipped from review due to trivial changes (1)
  • include/core/federated/network/net_common.h
Additional comments not posted (3)
core/federated/RTI/rti_remote.c (2)

1203-1203: LGTM!

The log message provides useful information for debugging and aligns with the PR objectives.


1201-1203: LGTM! But verify the usage of RTI_NOT_EXECUTED_WITH_AUTH.

The new case for handling MSG_TYPE_FED_NONCE correctly sends a rejection with RTI_NOT_EXECUTED_WITH_AUTH and logs an error message.

However, ensure that RTI_NOT_EXECUTED_WITH_AUTH is used consistently across the codebase.

Verification successful

Verified: Consistent usage of RTI_NOT_EXECUTED_WITH_AUTH

The constant RTI_NOT_EXECUTED_WITH_AUTH is consistently used across the codebase, defined in net_common.h and utilized in federate.c and rti_remote.c.

  • net_common.h: Definition of RTI_NOT_EXECUTED_WITH_AUTH
  • federate.c: Usage in handling MSG_TYPE_REJECT
  • rti_remote.c: Usage in handling MSG_TYPE_FED_NONCE
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `RTI_NOT_EXECUTED_WITH_AUTH` in the codebase.

# Test: Search for the usage of the constant. Expect: Consistent usage across the codebase.
rg --type c --type h 'RTI_NOT_EXECUTED_WITH_AUTH'

Length of output: 340

core/federated/federate.c (1)

865-867: Improve error message for missing HMAC authentication.

The error message "RTI is not executed with HMAC option." can be made more user-friendly and informative.

- lf_print_error("RTI is not executed with HMAC option.");
+ lf_print_error("RTI is not executed with the HMAC authentication option. Please start the RTI with the -a or --auth option.");

@Jakio815 Jakio815 requested a review from edwardalee July 3, 2024 00:07
@lhstrh lhstrh changed the title Add better error messages when HMAC authentication option is not used when executing Auth. Better error messages when HMAC authentication is attempted by federates when RTI does not support it Jul 4, 2024
Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

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

LGTM!

@edwardalee edwardalee added this pull request to the merge queue Jul 7, 2024
Merged via the queue into main with commit 4abce72 Jul 7, 2024
29 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants