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

A4-7-1: Identify guards for shift operations #396

Closed
lcartey opened this issue Oct 5, 2023 · 0 comments · Fixed by #542
Closed

A4-7-1: Identify guards for shift operations #396

lcartey opened this issue Oct 5, 2023 · 0 comments · Fixed by #542
Assignees
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@lcartey
Copy link
Collaborator

lcartey commented Oct 5, 2023

Affected rules

  • A4-7-1

Description

The IntegerExpressionLeadToDataLoss.ql query does not detect/identify guards for shift operations.

We already implement appropriate guards in the C rule INT34-C, and we should consider combining the implementations.

Example

std::size_t pow2(std::size_t i) {
  if (i < (sizeof(std::size_t) * CHAR_BIT)) {
     constexpr std::size_t one{1};
     return one << i; // COMPLIANT
  }
}
@lcartey lcartey added Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards labels Oct 5, 2023
@rvermeulen rvermeulen self-assigned this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

Successfully merging a pull request may close this issue.

2 participants