Skip to content

Implement Types Package #237

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

Merged
merged 61 commits into from
Mar 29, 2023
Merged

Implement Types Package #237

merged 61 commits into from
Mar 29, 2023

Conversation

jeongsoolee09
Copy link
Contributor

@jeongsoolee09 jeongsoolee09 commented Mar 3, 2023

Description

Implement the Types Package.

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • RULE-12-5
    • RULE-7-4
    • INT34-C
    • INT36-C
    • DIR-4-6
  • Queries have been modified for the following rules:

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

Query development review checklist

For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:

Author

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

🤖 Beep Boop! Matrix Testing for this PR has been initiated. Please check back later for results.

💡 If you do not hear back from me please check my status! I will report even if this PR does not contain files eligible for matrix testing.

@jsinglet
Copy link
Contributor

jsinglet commented Mar 3, 2023

🤖 Beep Boop! clang/cpp/x86_64 Matrix Testing for this PR has been completed but I didn't find anything to test!

@jsinglet
Copy link
Contributor

jsinglet commented Mar 3, 2023

🤖 Beep Boop! gcc/c/x86_64 Matrix Testing for this PR has been completed. See below for the results!


RULE                 : INT34-C
COMPILE_ERROR_OUTPUT : 
SUITE                : CERT-C
QUERY                : ExprShiftedbyNegativeOrGreaterPrecisionOperand
TEST_DIFFERENCE      : 
TEST_PASS            : True
PACKAGE              : Types
COMPILE_PASS         : True

RULE                 : INT36-C
COMPILE_ERROR_OUTPUT : 
SUITE                : CERT-C
QUERY                : ConvertingAPointerToIntegerOrIntegerToPointer
TEST_DIFFERENCE      : 
TEST_PASS            : True
PACKAGE              : Types
COMPILE_PASS         : True

RULE                 : DIR-4-6
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
QUERY                : PlainNumericalTypeUsedOverExplicitTypedef
TEST_DIFFERENCE      : --- expected
                       +++ actual
                       @@ -1,1 +1,1 @@
                       -No expected results have yet been specified
                       +| test.c:27:5:27:26 | _astronomical_number_t | The type _astronomical_number_t is not a fixed-width numeric type nor an alias to one. |
                       [1/1 comp 29.2s eval 1.1s] FAILED(RESULT) /__w/codeql-coding-standards-release-engineering/codeql-coding-standards-release-engineering/codeql-coding-standards/c/misra/test/rules/DIR-4-6/PlainNumericalTypeUsedOverExplicitTypedef.qlref
                       
TEST_PASS            : False
PACKAGE              : Types
COMPILE_PASS         : True

RULE                 : RULE-12-5
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
QUERY                : SizeofOperatorUsedOnArrayTypeParam
TEST_DIFFERENCE      : 
TEST_PASS            : True
PACKAGE              : Types
COMPILE_PASS         : True

RULE                 : RULE-7-4
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
QUERY                : StringLiteralAssignedToNonConstChar
TEST_DIFFERENCE      : 
TEST_PASS            : True
PACKAGE              : Types
COMPILE_PASS         : True


@jsinglet
Copy link
Contributor

🤖 Beep Boop! clang/cpp/X86_64 Matrix Testing for this PR has been completed. See below for the results!


COMPILE_PASS         : True
QUERY                : VariableWidthIntegerTypesUsed
TEST_DIFFERENCE      : 
TEST_PASS            : True
PACKAGE              : Declarations
SUITE                : AUTOSAR
RULE                 : A3-9-1
COMPILE_ERROR_OUTPUT : 


@jsinglet
Copy link
Contributor

🤖 Beep Boop! gcc/cpp/X86_64 Matrix Testing for this PR has been completed. See below for the results!


RULE                 : A3-9-1
QUERY                : VariableWidthIntegerTypesUsed
SUITE                : AUTOSAR
TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
COMPILE_PASS         : True
TEST_DIFFERENCE      : 
PACKAGE              : Declarations


@jsinglet
Copy link
Contributor

🤖 Beep Boop! qcc/cpp/AARCH64LE Matrix Testing for this PR has been completed. See below for the results!


TEST_DIFFERENCE      : 
COMPILE_PASS         : True
TEST_PASS            : True
RULE                 : A3-9-1
QUERY                : VariableWidthIntegerTypesUsed
COMPILE_ERROR_OUTPUT : 
SUITE                : AUTOSAR
PACKAGE              : Declarations


@jsinglet
Copy link
Contributor

🤖 Beep Boop! gcc/c/X86_64 Matrix Testing for this PR has been completed. See below for the results!


QUERY                : ExprShiftedbyNegativeOrGreaterPrecisionOperand
TEST_PASS            : True
TEST_DIFFERENCE      : 
RULE                 : INT34-C
COMPILE_ERROR_OUTPUT : 
PACKAGE              : Types1
SUITE                : CERT-C
COMPILE_PASS         : True

QUERY                : ConvertingAPointerToIntegerOrIntegerToPointer
TEST_PASS            : True
TEST_DIFFERENCE      : 
RULE                 : INT36-C
COMPILE_ERROR_OUTPUT : 
PACKAGE              : Types1
SUITE                : CERT-C
COMPILE_PASS         : True

QUERY                : PlainNumericalTypeUsedOverExplicitTypedef
TEST_PASS            : True
TEST_DIFFERENCE      : 
RULE                 : DIR-4-6
COMPILE_ERROR_OUTPUT : 
PACKAGE              : Types1
SUITE                : MISRA-C-2012
COMPILE_PASS         : True

QUERY                : SizeofOperatorUsedOnArrayTypeParam
TEST_PASS            : True
TEST_DIFFERENCE      : 
RULE                 : RULE-12-5
COMPILE_ERROR_OUTPUT : 
PACKAGE              : Types1
SUITE                : MISRA-C-2012
COMPILE_PASS         : True

QUERY                : StringLiteralAssignedToNonConstChar
TEST_PASS            : True
TEST_DIFFERENCE      : 
RULE                 : RULE-7-4
COMPILE_ERROR_OUTPUT : 
PACKAGE              : Types1
SUITE                : MISRA-C-2012
COMPILE_PASS         : True


@jsinglet
Copy link
Contributor

🤖 Beep Boop! clang/c/X86_64 Matrix Testing for this PR has been completed. See below for the results!


COMPILE_ERROR_OUTPUT : 
TEST_PASS            : True
COMPILE_PASS         : True
RULE                 : INT34-C
SUITE                : CERT-C
TEST_DIFFERENCE      : 
QUERY                : ExprShiftedbyNegativeOrGreaterPrecisionOperand
PACKAGE              : Types1

COMPILE_ERROR_OUTPUT : 
TEST_PASS            : True
COMPILE_PASS         : True
RULE                 : INT36-C
SUITE                : CERT-C
TEST_DIFFERENCE      : 
QUERY                : ConvertingAPointerToIntegerOrIntegerToPointer
PACKAGE              : Types1

COMPILE_ERROR_OUTPUT : 
TEST_PASS            : True
COMPILE_PASS         : True
RULE                 : DIR-4-6
SUITE                : MISRA-C-2012
TEST_DIFFERENCE      : 
QUERY                : PlainNumericalTypeUsedOverExplicitTypedef
PACKAGE              : Types1

COMPILE_ERROR_OUTPUT : 
TEST_PASS            : True
COMPILE_PASS         : True
RULE                 : RULE-12-5
SUITE                : MISRA-C-2012
TEST_DIFFERENCE      : 
QUERY                : SizeofOperatorUsedOnArrayTypeParam
PACKAGE              : Types1

COMPILE_ERROR_OUTPUT : 
TEST_PASS            : True
COMPILE_PASS         : True
RULE                 : RULE-7-4
SUITE                : MISRA-C-2012
TEST_DIFFERENCE      : 
QUERY                : StringLiteralAssignedToNonConstChar
PACKAGE              : Types1


@jsinglet
Copy link
Contributor

🤖 Beep Boop! qcc/c/AARCH64LE Matrix Testing for this PR has been completed. See below for the results!


TEST_PASS            : True
PACKAGE              : Types1
QUERY                : ExprShiftedbyNegativeOrGreaterPrecisionOperand
COMPILE_ERROR_OUTPUT : 
SUITE                : CERT-C
RULE                 : INT34-C
TEST_DIFFERENCE      : 
COMPILE_PASS         : True

TEST_PASS            : True
PACKAGE              : Types1
QUERY                : ConvertingAPointerToIntegerOrIntegerToPointer
COMPILE_ERROR_OUTPUT : 
SUITE                : CERT-C
RULE                 : INT36-C
TEST_DIFFERENCE      : 
COMPILE_PASS         : True

TEST_PASS            : True
PACKAGE              : Types1
QUERY                : PlainNumericalTypeUsedOverExplicitTypedef
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
RULE                 : DIR-4-6
TEST_DIFFERENCE      : 
COMPILE_PASS         : True

TEST_PASS            : True
PACKAGE              : Types1
QUERY                : SizeofOperatorUsedOnArrayTypeParam
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
RULE                 : RULE-12-5
TEST_DIFFERENCE      : 
COMPILE_PASS         : True

TEST_PASS            : True
PACKAGE              : Types1
QUERY                : StringLiteralAssignedToNonConstChar
COMPILE_ERROR_OUTPUT : 
SUITE                : MISRA-C-2012
RULE                 : RULE-7-4
TEST_DIFFERENCE      : 
COMPILE_PASS         : True


@jsinglet
Copy link
Contributor

🤖 Beep Boop! Matrix Testing for this PR has been completed. If no reports were posted it means this PR does not contain things that need matrix testing!

@jsinglet
Copy link
Contributor

🤖 Beep Boop! qcc/c/AARCH64LE Matrix Testing for this PR has been completed. See below for the results!


TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
RULE                 : INT34-C
TEST_DIFFERENCE      : 
QUERY                : ExprShiftedbyNegativeOrGreaterPrecisionOperand
SUITE                : CERT-C
COMPILE_PASS         : True
PACKAGE              : Types1

TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
RULE                 : INT36-C
TEST_DIFFERENCE      : 
QUERY                : ConvertingAPointerToIntegerOrIntegerToPointer
SUITE                : CERT-C
COMPILE_PASS         : True
PACKAGE              : Types1

TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
RULE                 : DIR-4-6
TEST_DIFFERENCE      : 
QUERY                : PlainNumericalTypeUsedOverExplicitTypedef
SUITE                : MISRA-C-2012
COMPILE_PASS         : True
PACKAGE              : Types1

TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
RULE                 : RULE-12-5
TEST_DIFFERENCE      : 
QUERY                : SizeofOperatorUsedOnArrayTypeParam
SUITE                : MISRA-C-2012
COMPILE_PASS         : True
PACKAGE              : Types1

TEST_PASS            : True
COMPILE_ERROR_OUTPUT : 
RULE                 : RULE-7-4
TEST_DIFFERENCE      : 
QUERY                : StringLiteralAssignedToNonConstChar
SUITE                : MISRA-C-2012
COMPILE_PASS         : True
PACKAGE              : Types1


@jsinglet
Copy link
Contributor

🤖 Beep Boop! Matrix Testing for this PR has been completed. If no reports were posted it means this PR does not contain things that need matrix testing!

@lcartey
Copy link
Collaborator

lcartey commented Mar 27, 2023

/test-performance

@github-actions
Copy link

🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute.

💡 If you do not hear back from me please check my status! I will report even if I fail!

@jeongsoolee09 jeongsoolee09 enabled auto-merge March 27, 2023 21:20
jeongsoolee09 and others added 7 commits March 28, 2023 11:40
If the expression is explicitly converted to a larger type, the shift
happens on the larger type.
 * Include uncertainty in the alert message (e.g. "may")
 * Report upper bound if relevant.
Recursively identify typedefs that are to the built in  numeric types,
but do not use the size alias.
@lcartey lcartey dismissed rvermeulen’s stale review March 29, 2023 10:34

Comments addressed.

@jeongsoolee09 jeongsoolee09 added this pull request to the merge queue Mar 29, 2023
Merged via the queue into main with commit 6628857 Mar 29, 2023
@jeongsoolee09 jeongsoolee09 deleted the jeongsoolee09/Types branch March 29, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants