-
Notifications
You must be signed in to change notification settings - Fork 64
CERT: Add query tags for "Risk Assessment" properties #896
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enriches all CERT C queries with detailed risk assessment tags (severity, likelihood, remediation-cost, priority, level) and introduces three new query suites for Level 1–3 rules.
- Added risk assessment metadata tags to each CERT rule query.
- Created
cert-c-l1.qls
,cert-c-l2.qls
, andcert-c-l3.qls
suites filtering by level. - Enhanced validation to ensure risk tags on CERT queries only and updated missing markdown headers.
Reviewed Changes
Copilot reviewed 317 out of 317 changed files in this pull request and generated 22 comments.
Show a summary per file
File | Description |
---|---|
c/cert/src/rules/CON37-C/DoNotCallSignalInMultithreadedProgram.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON36-C/WrapFunctionsThatCanSpuriouslyWakeUpInLoop.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON35-C/DeadlockByLockingInPredefinedOrder.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON34-C/ThreadObjectStorageDurationsNotInitialized.ql | Added CERT risk assessment & recommendation tags |
c/cert/src/rules/CON34-C/AppropriateThreadObjectStorageDurations.ql | Added CERT risk assessment & recommendation tags |
c/cert/src/rules/CON33-C/RaceConditionsWhenUsingLibraryFunctions.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON32-C/PreventDataRacesWithMultipleThreads.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON31-C/DoNotDestroyAMutexWhileItIsLocked.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON31-C/DoNotAllowAMutexToGoOutOfScopeWhileLocked.ql | Added CERT risk assessment tags |
c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR39-C/DoNotAddOrSubtractAScaledIntegerToAPointer.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR38-C/LibraryFunctionArgumentOutOfBounds.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR37-C/DoNotUsePointerArithmeticOnNonArrayObjectPointers.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR36-C/DoNotSubtractPointersThatDoNotReferToTheSameArray.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR36-C/DoNotRelatePointersThatDoNotReferToTheSameArray.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR32-C/VariableLengthArraySizeNotInValidRange.ql | Added CERT risk assessment tags |
c/cert/src/rules/ARR30-C/DoNotFormOutOfBoundsPointersOrArraySubscripts.ql | Added CERT risk assessment tags |
c/cert/src/codeql-suites/cert-c-l3.qls | New Level 3 suite (priority 1–4) |
c/cert/src/codeql-suites/cert-c-l2.qls | New Level 2 suite (priority 6–9) |
c/cert/src/codeql-suites/cert-c-l1.qls | New Level 1 suite (priority 12–27) |
Comments suppressed due to low confidence (1)
c/cert/src/rules/CON34-C/AppropriateThreadObjectStorageDurations.ql:12
- This recommendation query already has the recommendation tag; ensure only the rule query is updated elsewhere.
* external/cert/recommendation/con34-c
* external/cert/severity/low | ||
* external/cert/likelihood/probable | ||
* external/cert/remediation-cost/low | ||
* external/cert/priority/p6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The priority tag should be p2 for low (1) * probable (2) * low (1) = 2; update to p2 and adjust the level accordingly.
* external/cert/priority/p6 | |
* external/cert/priority/p2 |
Copilot uses AI. Check for mistakes.
* external/cert/likelihood/probable | ||
* external/cert/remediation-cost/low | ||
* external/cert/priority/p6 | ||
* external/cert/level/l2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With priority p2, the level tag should be l3, not l2.
* external/cert/level/l2 | |
* external/cert/level/l3 |
Copilot uses AI. Check for mistakes.
@@ -10,6 +10,12 @@ | |||
* external/cert/audit | |||
* correctness | |||
* concurrency | |||
* external/cert/recommendation/con34-c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommendation tags belong only on recommendation queries; remove this tag from the rule query.
* external/cert/recommendation/con34-c |
Copilot uses AI. Check for mistakes.
* external/cert/severity/medium | ||
* external/cert/likelihood/probable | ||
* external/cert/remediation-cost/high | ||
* external/cert/priority/p4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity medium (2) * probable (2) * high (3) = 12, so priority should be p12.
* external/cert/priority/p4 | |
* external/cert/priority/p12 |
Copilot uses AI. Check for mistakes.
* external/cert/likelihood/probable | ||
* external/cert/remediation-cost/high | ||
* external/cert/priority/p4 | ||
* external/cert/level/l3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With priority p12, the level tag should be l1.
* external/cert/level/l3 | |
* external/cert/level/l1 |
Copilot uses AI. Check for mistakes.
* external/cert/severity/high | ||
* external/cert/likelihood/likely | ||
* external/cert/remediation-cost/high | ||
* external/cert/priority/p9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity high (3) * likely (3) * high (3) = 27, so priority should be p27.
* external/cert/priority/p9 | |
* external/cert/priority/p27 |
Copilot uses AI. Check for mistakes.
* external/cert/likelihood/likely | ||
* external/cert/remediation-cost/high | ||
* external/cert/priority/p9 | ||
* external/cert/level/l2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With priority p27, the level tag should be l1.
* external/cert/level/l2 | |
* external/cert/level/l1 |
Copilot uses AI. Check for mistakes.
- description: CERT C 2016 Level 3 Rules (Priority 1 - Priority 4) | ||
- qlpack: codeql/cert-c-coding-standards | ||
- include: | ||
kind: | ||
- problem | ||
- path-problem | ||
- external/cert/obligation/rule | ||
tags contain: | ||
- external/cert/level/l3 | ||
- exclude: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top‑level keys in a .qls should not be prefixed with '-'; remove the hyphen before 'description'.
- description: CERT C 2016 Level 3 Rules (Priority 1 - Priority 4) | |
- qlpack: codeql/cert-c-coding-standards | |
- include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l3 | |
- exclude: | |
description: CERT C 2016 Level 3 Rules (Priority 1 - Priority 4) | |
qlpack: codeql/cert-c-coding-standards | |
include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l3 | |
exclude: |
Copilot uses AI. Check for mistakes.
- description: CERT C 2016 Level 2 Rules (Priority 6 - Priority 9) | ||
- qlpack: codeql/cert-c-coding-standards | ||
- include: | ||
kind: | ||
- problem | ||
- path-problem | ||
- external/cert/obligation/rule | ||
tags contain: | ||
- external/cert/level/l2 | ||
- exclude: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top‑level keys in a .qls should not be prefixed with '-'; remove the hyphen before 'description'.
- description: CERT C 2016 Level 2 Rules (Priority 6 - Priority 9) | |
- qlpack: codeql/cert-c-coding-standards | |
- include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l2 | |
- exclude: | |
description: CERT C 2016 Level 2 Rules (Priority 6 - Priority 9) | |
qlpack: codeql/cert-c-coding-standards | |
include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l2 | |
exclude: |
Copilot uses AI. Check for mistakes.
- description: CERT C 2016 Level 1 Rules (Priority 12 - Priority 27) | ||
- qlpack: codeql/cert-c-coding-standards | ||
- include: | ||
kind: | ||
- problem | ||
- path-problem | ||
- external/cert/obligation/rule | ||
tags contain: | ||
- external/cert/level/l1 | ||
- exclude: | ||
tags contain: | ||
- external/cert/default-disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top‑level keys in a .qls should not be prefixed with '-'; remove the hyphen before 'description'.
- description: CERT C 2016 Level 1 Rules (Priority 12 - Priority 27) | |
- qlpack: codeql/cert-c-coding-standards | |
- include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l1 | |
- exclude: | |
tags contain: | |
- external/cert/default-disabled | |
description: CERT C 2016 Level 1 Rules (Priority 12 - Priority 27) | |
qlpack: codeql/cert-c-coding-standards | |
include: | |
kind: | |
- problem | |
- path-problem | |
- external/cert/obligation/rule | |
tags contain: | |
- external/cert/level/l1 | |
exclude: | |
tags contain: | |
- external/cert/default-disabled |
Copilot uses AI. Check for mistakes.
Description
This PR adds query tags for the five Risk Assessment properties which are specified on CERT rules:
We add these properties to help users be able to select which queries to run based on the risk assessment properties.
In addition to the properties, we also add new query suites for L1, L2 and L3 rules. I think these are the most likely properties users will want to use, as they combine the three individual categories to create a blended priority score.
From an implementation perspective, this PR:
.md
help files for the Risk Assessment tables, and adds them as tags to the rule package json files.##
.cert-<lang>-<level>.qls
. Note: these include the rules and not the recommendations, based on users likely wanting a more focused set of queries, not additional queries.Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
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.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
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
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.
Reviewer
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.