-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-tidy] Move 'cert-msc51-cpp', 'cert-msc32-c' checks outside of 'cert' module and give a proper name #167143
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
vbvictor
merged 12 commits into
llvm:main
from
luobochuanqi:cleanup-cert-module-random-seed-check
Nov 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fd994fd
[clang-tidy] Move 'cert-msc51-cpp', 'cert-msc32-c' checks outside of …
luobochuanqi ac312ee
Fix some grammar details and the documentation.
luobochuanqi aa56aae
Fix the documentation.
luobochuanqi 2841a2f
Fix the documentation.
luobochuanqi 47379b1
Format the file.
luobochuanqi 7feda4c
Update clang-tools-extra/docs/clang-tidy/checks/bugprone/random-gener…
luobochuanqi 3ce8e8e
Update clang-tools-extra/test/clang-tidy/checkers/bugprone/random-gen…
luobochuanqi b3462eb
Update clang-tools-extra/docs/clang-tidy/checks/list.rst
luobochuanqi 96384dc
Update random-generator-seed.c
luobochuanqi a3e50c3
Merge branch 'main' into cleanup-cert-module-random-seed-check
luobochuanqi 1d9b0ce
Remove ThrownExceptionTypeCheck from CMakeLists
luobochuanqi 28b789d
Remove unused include for ThrownExceptionTypeCheck
luobochuanqi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
clang-tools-extra/docs/clang-tidy/checks/bugprone/random-generator-seed.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| .. title:: clang-tidy - bugprone-random-generator-seed | ||
|
|
||
| bugprone-random-generator-seed | ||
| ============================== | ||
|
|
||
| This check flags all pseudo-random number engines, engine adaptor | ||
luobochuanqi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| instantiations and ``srand()`` when initialized or seeded with default argument, | ||
| constant expression or any user-configurable type. Pseudo-random number | ||
| engines seeded with a predictable value may cause vulnerabilities e.g. in | ||
| security protocols. | ||
| This is a CERT security rule, see | ||
luobochuanqi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| `MSC51-CPP. Ensure your random number generator is properly seeded | ||
| <https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC51-CPP.+Ensure+your+random+number+generator+is+properly+seeded>`_ and | ||
| `MSC32-C. Properly seed pseudorandom number generators | ||
| <https://wiki.sei.cmu.edu/confluence/display/c/MSC32-C.+Properly+seed+pseudorandom+number+generators>`_. | ||
|
|
||
| Examples: | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| void foo() { | ||
| std::mt19937 engine1; // Diagnose, always generate the same sequence | ||
| std::mt19937 engine2(1); // Diagnose | ||
| engine1.seed(); // Diagnose | ||
| engine2.seed(1); // Diagnose | ||
|
|
||
| std::time_t t; | ||
| engine1.seed(std::time(&t)); // Diagnose, system time might be controlled by user | ||
|
|
||
| int x = atoi(argv[1]); | ||
| std::mt19937 engine3(x); // Will not warn | ||
| } | ||
|
|
||
| Options | ||
| ------- | ||
|
|
||
| .. option:: DisallowedSeedTypes | ||
|
|
||
| A comma-separated list of the type names which are disallowed. | ||
| Default value is `time_t,std::time_t`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...a/test/clang-tidy/checkers/cert/msc32-c.c → ...checkers/bugprone/random-generator-seed.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.