Skip to content
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

Added length check on bugs_by_version for specific version_number #2499

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

MukulKolpe
Copy link
Contributor

@MukulKolpe MukulKolpe commented Jun 27, 2024

Description:

The incorrect_sol detector previously checked for known issues using the condition if version_number in bugs_by_version. This approach did not account for cases where the list of issues for a given version was empty, leading to false positives.

Updated the _check_version method to include a check for non-empty issue lists:

if version_number in bugs_by_version and len(bugs_by_version[version_number]):

Resolves #2478

Summary by CodeRabbit

  • Bug Fixes
    • Improved version check to accurately detect and handle buggy versions, ensuring more reliable feedback on potential issues.

Copy link

coderabbitai bot commented Jun 27, 2024

Walkthrough

Walkthrough

The code modification ensures that the solc-version detector checks for the presence and count of bugs before displaying a message about known issues for a specific Solidity version. This change addresses a bug where the detector would previously show a misleading message for versions without known issues.

Changes

Files Change Summary
.../incorrect_solc.py Modified the _check_version method to verify that there are actual bugs associated with a Solidity version before displaying an info message, preventing false alerts for versions with no known issues.

Sequence Diagrams

The changes were too simple and did not modify the control flow significantly, so no sequence diagrams were generated.

Assessment against linked issues

Objective Addressed Explanation
Ensure that the solc-version detector only shows messages if there are known issues (##2478)

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

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 84e8633 and 95e153d.

Files selected for processing (1)
  • slither/detectors/attributes/incorrect_solc.py (1 hunks)
Additional comments not posted (2)
slither/detectors/attributes/incorrect_solc.py (2)

74-74: Ensure correct handling of non-empty bug lists.

The change correctly adds a check to ensure the list of bugs for a given version_number is non-empty before reporting issues. This should effectively reduce false positives as described in the PR objectives. However, ensure that bugs_by_version is always a dictionary and that each key in this dictionary always maps to a list, to avoid any type errors or key errors.


Line range hint 98-100: Verify interaction between version checking and pragma handling.

The _check_pragma and _detect methods rely on the updated _check_version method. Ensure that the changes in _check_version do not affect the logic in these methods in unexpected ways, especially considering complex pragma statements and the handling of multiple version constraints.

Also applies to: 118-122

@0xalpharush
Copy link
Contributor

Thanks @MukulKolpe!

@0xalpharush 0xalpharush merged commit 8499b5d into crytic:dev Jul 2, 2024
73 checks passed
@MukulKolpe MukulKolpe deleted the bugsByVersionLC branch July 2, 2024 13:38
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.

2 participants