-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add static analysis rules for NULL pointer dereference detection #132
Add static analysis rules for NULL pointer dereference detection #132
Conversation
WalkthroughThis pull request introduces new static analysis rules for detecting NULL pointer dereference vulnerabilities in C and C++ programming languages. Two new rule files ( Changes
Sequence DiagramsequenceDiagram
participant Code
participant Rule
participant AST
participant Analyzer
Code->>AST: Parse source code
AST->>Rule: Apply null dereference checks
Rule->>Analyzer: Identify potential vulnerabilities
Analyzer-->>Code: Report warnings for unsafe patterns
Possibly related PRs
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 10
🧹 Nitpick comments (4)
rules/c/security/null-library-function-c.yml (1)
21-23
: Consider enabling commented patterns.The commented patterns look valid and could enhance detection capabilities.
Consider enabling these patterns if they've been tested:
- # any: - # - pattern: $SOURCE($$$)[$$$] - # - pattern: ($SOURCE($$$))[$$$] + any: + - pattern: $SOURCE($$$)[$$$] + - pattern: ($SOURCE($$$))[$$$]rules/cpp/null-library-function-cpp.yml (3)
1-11
: Consider adding C++-specific references.While the rule is well-documented, consider adding C++-specific references and best practices.
Add references to C++ core guidelines, such as:
- C++ Core Guidelines: ES.65: Don't dereference an invalid pointer
- C++ Core Guidelines: I.12: Declare a pointer that must not be null as not_null
33-33
: Enhance function patterns for C++ standard library.The regex patterns could be expanded to include more C++ standard library functions.
Consider adding patterns for:
- Smart pointer functions (make_unique, make_shared)
- String operations (string::c_str, string::data)
- Container operations (vector::data)
- File system operations (filesystem::path::c_str)
Also applies to: 62-62, 94-94, 114-114, 173-173, 196-196, 230-230, 244-244
13-262
: Deduplicate rules between C and C++.The C and C++ rules are identical, leading to maintenance overhead.
Consider:
- Creating a base rule with common patterns
- Extending it with language-specific patterns
- Using YAML anchors and aliases to reduce duplication
🧰 Tools
🪛 yamllint (1.35.1)
[warning] 25-25: wrong indentation: expected 5 but found 7
(indentation)
[warning] 26-26: wrong indentation: expected 10 but found 12
(indentation)
[warning] 29-29: wrong indentation: expected 12 but found 14
(indentation)
[warning] 30-30: wrong indentation: expected 17 but found 18
(indentation)
[warning] 35-35: wrong indentation: expected 17 but found 18
(indentation)
[warning] 38-38: wrong indentation: expected 10 but found 11
(indentation)
[warning] 40-40: wrong indentation: expected 11 but found 13
(indentation)
[error] 42-42: trailing spaces
(trailing-spaces)
[warning] 45-45: wrong indentation: expected 5 but found 7
(indentation)
[warning] 46-46: wrong indentation: expected 10 but found 11
(indentation)
[warning] 51-51: wrong indentation: expected 10 but found 11
(indentation)
[warning] 54-54: wrong indentation: expected 12 but found 13
(indentation)
[error] 54-54: trailing spaces
(trailing-spaces)
[warning] 58-58: wrong indentation: expected 13 but found 15
(indentation)
[warning] 59-59: wrong indentation: expected 18 but found 19
(indentation)
[warning] 64-64: wrong indentation: expected 18 but found 19
(indentation)
[error] 66-66: trailing spaces
(trailing-spaces)
[error] 67-67: trailing spaces
(trailing-spaces)
[warning] 69-69: wrong indentation: expected 5 but found 7
(indentation)
[warning] 70-70: wrong indentation: expected 10 but found 11
(indentation)
[warning] 75-75: wrong indentation: expected 10 but found 11
(indentation)
[warning] 78-78: wrong indentation: expected 12 but found 13
(indentation)
[warning] 82-82: wrong indentation: expected 13 but found 15
(indentation)
[warning] 83-83: wrong indentation: expected 18 but found 19
(indentation)
[warning] 87-87: wrong indentation: expected 18 but found 19
(indentation)
[warning] 90-90: wrong indentation: expected 19 but found 21
(indentation)
[warning] 91-91: wrong indentation: expected 24 but found 25
(indentation)
[error] 95-95: trailing spaces
(trailing-spaces)
[warning] 98-98: wrong indentation: expected 5 but found 7
(indentation)
[warning] 103-103: wrong indentation: expected 10 but found 11
(indentation)
[warning] 106-106: wrong indentation: expected 12 but found 13
(indentation)
[warning] 110-110: wrong indentation: expected 13 but found 15
(indentation)
[warning] 111-111: wrong indentation: expected 18 but found 19
(indentation)
[warning] 116-116: wrong indentation: expected 18 but found 19
(indentation)
[warning] 119-119: wrong indentation: expected 10 but found 11
(indentation)
[warning] 120-120: wrong indentation: expected 12 but found 13
(indentation)
[warning] 123-123: wrong indentation: expected 14 but found 16
(indentation)
[warning] 127-127: wrong indentation: expected 10 but found 11
(indentation)
[warning] 128-128: wrong indentation: expected 12 but found 13
(indentation)
[warning] 131-131: wrong indentation: expected 13 but found 15
(indentation)
[warning] 132-132: wrong indentation: expected 18 but found 19
(indentation)
[warning] 136-136: wrong indentation: expected 18 but found 19
(indentation)
[warning] 139-139: wrong indentation: expected 20 but found 21
(indentation)
[warning] 142-142: wrong indentation: expected 22 but found 23
(indentation)
[warning] 148-148: wrong indentation: expected 5 but found 7
(indentation)
[warning] 149-149: wrong indentation: expected 10 but found 11
(indentation)
[warning] 154-154: wrong indentation: expected 10 but found 11
(indentation)
[warning] 157-157: wrong indentation: expected 12 but found 13
(indentation)
[error] 157-157: trailing spaces
(trailing-spaces)
[warning] 161-161: wrong indentation: expected 13 but found 15
(indentation)
[warning] 162-162: wrong indentation: expected 18 but found 19
(indentation)
[warning] 166-166: wrong indentation: expected 18 but found 19
(indentation)
[warning] 169-169: wrong indentation: expected 19 but found 21
(indentation)
[warning] 170-170: wrong indentation: expected 24 but found 25
(indentation)
[error] 173-173: trailing spaces
(trailing-spaces)
[error] 174-174: trailing spaces
(trailing-spaces)
[warning] 180-180: wrong indentation: expected 5 but found 7
(indentation)
[warning] 181-181: wrong indentation: expected 10 but found 11
(indentation)
[warning] 186-186: wrong indentation: expected 10 but found 11
(indentation)
[warning] 189-189: wrong indentation: expected 12 but found 13
(indentation)
[warning] 192-192: wrong indentation: expected 13 but found 15
(indentation)
[warning] 193-193: wrong indentation: expected 18 but found 19
(indentation)
[warning] 198-198: wrong indentation: expected 18 but found 19
(indentation)
[error] 200-200: trailing spaces
(trailing-spaces)
[warning] 203-203: wrong indentation: expected 5 but found 7
(indentation)
[error] 203-203: trailing spaces
(trailing-spaces)
[error] 204-204: trailing spaces
(trailing-spaces)
[warning] 206-206: wrong indentation: expected 5 but found 7
(indentation)
[warning] 207-207: wrong indentation: expected 10 but found 11
(indentation)
[warning] 212-212: wrong indentation: expected 10 but found 11
(indentation)
[warning] 215-215: wrong indentation: expected 12 but found 13
(indentation)
[error] 217-217: trailing spaces
(trailing-spaces)
[warning] 219-219: wrong indentation: expected 13 but found 15
(indentation)
[warning] 220-220: wrong indentation: expected 18 but found 19
(indentation)
[warning] 223-223: wrong indentation: expected 18 but found 19
(indentation)
[warning] 226-226: wrong indentation: expected 19 but found 21
(indentation)
[warning] 227-227: wrong indentation: expected 24 but found 25
(indentation)
[warning] 232-232: wrong indentation: expected 24 but found 25
(indentation)
[error] 234-234: trailing spaces
(trailing-spaces)
[warning] 237-237: wrong indentation: expected 6 but found 7
(indentation)
[warning] 241-241: wrong indentation: expected 10 but found 11
(indentation)
[error] 244-244: trailing spaces
(trailing-spaces)
[warning] 246-246: wrong indentation: expected 10 but found 11
(indentation)
[warning] 249-249: wrong indentation: expected 10 but found 11
(indentation)
[warning] 250-250: wrong indentation: expected 12 but found 13
(indentation)
[warning] 252-252: wrong indentation: expected 13 but found 15
(indentation)
[warning] 255-255: wrong indentation: expected 10 but found 11
(indentation)
[warning] 256-256: wrong indentation: expected 12 but found 13
(indentation)
[warning] 258-258: wrong indentation: expected 13 but found 15
(indentation)
[warning] 260-260: wrong indentation: expected 10 but found 11
(indentation)
[error] 262-262: no new line character at the end of file
(new-line-at-end-of-file)
[error] 262-262: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
rules/c/security/null-library-function-c.yml
(1 hunks)rules/cpp/null-library-function-cpp.yml
(1 hunks)tests/__snapshots__/null-library-function-c-snapshot.yml
(1 hunks)tests/__snapshots__/null-library-function-cpp-snapshot.yml
(1 hunks)tests/__snapshots__/return-c-str-cpp-snapshot.yml
(1 hunks)tests/__snapshots__/sizeof-this-c-snapshot.yml
(1 hunks)tests/c/null-library-function-c-test.yml
(1 hunks)tests/cpp/null-library-function-cpp-test.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
tests/c/null-library-function-c-test.yml
[error] 17-17: trailing spaces
(trailing-spaces)
[error] 21-21: trailing spaces
(trailing-spaces)
[error] 29-29: no new line character at the end of file
(new-line-at-end-of-file)
rules/cpp/null-library-function-cpp.yml
[warning] 25-25: wrong indentation: expected 5 but found 7
(indentation)
[warning] 26-26: wrong indentation: expected 10 but found 12
(indentation)
[warning] 29-29: wrong indentation: expected 12 but found 14
(indentation)
[warning] 30-30: wrong indentation: expected 17 but found 18
(indentation)
[warning] 35-35: wrong indentation: expected 17 but found 18
(indentation)
[warning] 38-38: wrong indentation: expected 10 but found 11
(indentation)
[warning] 40-40: wrong indentation: expected 11 but found 13
(indentation)
[error] 42-42: trailing spaces
(trailing-spaces)
[warning] 45-45: wrong indentation: expected 5 but found 7
(indentation)
[warning] 46-46: wrong indentation: expected 10 but found 11
(indentation)
[warning] 51-51: wrong indentation: expected 10 but found 11
(indentation)
[warning] 54-54: wrong indentation: expected 12 but found 13
(indentation)
[error] 54-54: trailing spaces
(trailing-spaces)
[warning] 58-58: wrong indentation: expected 13 but found 15
(indentation)
[warning] 59-59: wrong indentation: expected 18 but found 19
(indentation)
[warning] 64-64: wrong indentation: expected 18 but found 19
(indentation)
[error] 66-66: trailing spaces
(trailing-spaces)
[error] 67-67: trailing spaces
(trailing-spaces)
[warning] 69-69: wrong indentation: expected 5 but found 7
(indentation)
[warning] 70-70: wrong indentation: expected 10 but found 11
(indentation)
[warning] 75-75: wrong indentation: expected 10 but found 11
(indentation)
[warning] 78-78: wrong indentation: expected 12 but found 13
(indentation)
[warning] 82-82: wrong indentation: expected 13 but found 15
(indentation)
[warning] 83-83: wrong indentation: expected 18 but found 19
(indentation)
[warning] 87-87: wrong indentation: expected 18 but found 19
(indentation)
[warning] 90-90: wrong indentation: expected 19 but found 21
(indentation)
[warning] 91-91: wrong indentation: expected 24 but found 25
(indentation)
[error] 95-95: trailing spaces
(trailing-spaces)
[warning] 98-98: wrong indentation: expected 5 but found 7
(indentation)
[warning] 103-103: wrong indentation: expected 10 but found 11
(indentation)
[warning] 106-106: wrong indentation: expected 12 but found 13
(indentation)
[warning] 110-110: wrong indentation: expected 13 but found 15
(indentation)
[warning] 111-111: wrong indentation: expected 18 but found 19
(indentation)
[warning] 116-116: wrong indentation: expected 18 but found 19
(indentation)
[warning] 119-119: wrong indentation: expected 10 but found 11
(indentation)
[warning] 120-120: wrong indentation: expected 12 but found 13
(indentation)
[warning] 123-123: wrong indentation: expected 14 but found 16
(indentation)
[warning] 127-127: wrong indentation: expected 10 but found 11
(indentation)
[warning] 128-128: wrong indentation: expected 12 but found 13
(indentation)
[warning] 131-131: wrong indentation: expected 13 but found 15
(indentation)
[warning] 132-132: wrong indentation: expected 18 but found 19
(indentation)
[warning] 136-136: wrong indentation: expected 18 but found 19
(indentation)
[warning] 139-139: wrong indentation: expected 20 but found 21
(indentation)
[warning] 142-142: wrong indentation: expected 22 but found 23
(indentation)
[warning] 148-148: wrong indentation: expected 5 but found 7
(indentation)
[warning] 149-149: wrong indentation: expected 10 but found 11
(indentation)
[warning] 154-154: wrong indentation: expected 10 but found 11
(indentation)
[warning] 157-157: wrong indentation: expected 12 but found 13
(indentation)
[error] 157-157: trailing spaces
(trailing-spaces)
[warning] 161-161: wrong indentation: expected 13 but found 15
(indentation)
[warning] 162-162: wrong indentation: expected 18 but found 19
(indentation)
[warning] 166-166: wrong indentation: expected 18 but found 19
(indentation)
[warning] 169-169: wrong indentation: expected 19 but found 21
(indentation)
[warning] 170-170: wrong indentation: expected 24 but found 25
(indentation)
[error] 173-173: trailing spaces
(trailing-spaces)
[error] 174-174: trailing spaces
(trailing-spaces)
[warning] 180-180: wrong indentation: expected 5 but found 7
(indentation)
[warning] 181-181: wrong indentation: expected 10 but found 11
(indentation)
[warning] 186-186: wrong indentation: expected 10 but found 11
(indentation)
[warning] 189-189: wrong indentation: expected 12 but found 13
(indentation)
[warning] 192-192: wrong indentation: expected 13 but found 15
(indentation)
[warning] 193-193: wrong indentation: expected 18 but found 19
(indentation)
[warning] 198-198: wrong indentation: expected 18 but found 19
(indentation)
[error] 200-200: trailing spaces
(trailing-spaces)
[warning] 203-203: wrong indentation: expected 5 but found 7
(indentation)
[error] 203-203: trailing spaces
(trailing-spaces)
[error] 204-204: trailing spaces
(trailing-spaces)
[warning] 206-206: wrong indentation: expected 5 but found 7
(indentation)
[warning] 207-207: wrong indentation: expected 10 but found 11
(indentation)
[warning] 212-212: wrong indentation: expected 10 but found 11
(indentation)
[warning] 215-215: wrong indentation: expected 12 but found 13
(indentation)
[error] 217-217: trailing spaces
(trailing-spaces)
[warning] 219-219: wrong indentation: expected 13 but found 15
(indentation)
[warning] 220-220: wrong indentation: expected 18 but found 19
(indentation)
[warning] 223-223: wrong indentation: expected 18 but found 19
(indentation)
[warning] 226-226: wrong indentation: expected 19 but found 21
(indentation)
[warning] 227-227: wrong indentation: expected 24 but found 25
(indentation)
[warning] 232-232: wrong indentation: expected 24 but found 25
(indentation)
[error] 234-234: trailing spaces
(trailing-spaces)
[warning] 237-237: wrong indentation: expected 6 but found 7
(indentation)
[warning] 241-241: wrong indentation: expected 10 but found 11
(indentation)
[error] 244-244: trailing spaces
(trailing-spaces)
[warning] 246-246: wrong indentation: expected 10 but found 11
(indentation)
[warning] 249-249: wrong indentation: expected 10 but found 11
(indentation)
[warning] 250-250: wrong indentation: expected 12 but found 13
(indentation)
[warning] 252-252: wrong indentation: expected 13 but found 15
(indentation)
[warning] 255-255: wrong indentation: expected 10 but found 11
(indentation)
[warning] 256-256: wrong indentation: expected 12 but found 13
(indentation)
[warning] 258-258: wrong indentation: expected 13 but found 15
(indentation)
[warning] 260-260: wrong indentation: expected 10 but found 11
(indentation)
[error] 262-262: no new line character at the end of file
(new-line-at-end-of-file)
[error] 262-262: trailing spaces
(trailing-spaces)
tests/cpp/null-library-function-cpp-test.yml
[error] 17-17: trailing spaces
(trailing-spaces)
[error] 21-21: trailing spaces
(trailing-spaces)
[error] 29-29: no new line character at the end of file
(new-line-at-end-of-file)
rules/c/security/null-library-function-c.yml
[warning] 25-25: wrong indentation: expected 5 but found 7
(indentation)
[warning] 26-26: wrong indentation: expected 10 but found 12
(indentation)
[warning] 29-29: wrong indentation: expected 12 but found 14
(indentation)
[warning] 30-30: wrong indentation: expected 17 but found 18
(indentation)
[warning] 35-35: wrong indentation: expected 17 but found 18
(indentation)
[warning] 38-38: wrong indentation: expected 10 but found 11
(indentation)
[warning] 40-40: wrong indentation: expected 11 but found 13
(indentation)
[error] 42-42: trailing spaces
(trailing-spaces)
[warning] 45-45: wrong indentation: expected 5 but found 7
(indentation)
[warning] 46-46: wrong indentation: expected 10 but found 11
(indentation)
[warning] 51-51: wrong indentation: expected 10 but found 11
(indentation)
[warning] 54-54: wrong indentation: expected 12 but found 13
(indentation)
[error] 54-54: trailing spaces
(trailing-spaces)
[warning] 58-58: wrong indentation: expected 13 but found 15
(indentation)
[warning] 59-59: wrong indentation: expected 18 but found 19
(indentation)
[warning] 64-64: wrong indentation: expected 18 but found 19
(indentation)
[error] 66-66: trailing spaces
(trailing-spaces)
[error] 67-67: trailing spaces
(trailing-spaces)
[warning] 69-69: wrong indentation: expected 5 but found 7
(indentation)
[warning] 70-70: wrong indentation: expected 10 but found 11
(indentation)
[warning] 75-75: wrong indentation: expected 10 but found 11
(indentation)
[warning] 78-78: wrong indentation: expected 12 but found 13
(indentation)
[warning] 82-82: wrong indentation: expected 13 but found 15
(indentation)
[warning] 83-83: wrong indentation: expected 18 but found 19
(indentation)
[warning] 87-87: wrong indentation: expected 18 but found 19
(indentation)
[warning] 90-90: wrong indentation: expected 19 but found 21
(indentation)
[warning] 91-91: wrong indentation: expected 24 but found 25
(indentation)
[error] 95-95: trailing spaces
(trailing-spaces)
[warning] 98-98: wrong indentation: expected 5 but found 7
(indentation)
[warning] 103-103: wrong indentation: expected 10 but found 11
(indentation)
[warning] 106-106: wrong indentation: expected 12 but found 13
(indentation)
[warning] 110-110: wrong indentation: expected 13 but found 15
(indentation)
[warning] 111-111: wrong indentation: expected 18 but found 19
(indentation)
[warning] 116-116: wrong indentation: expected 18 but found 19
(indentation)
[warning] 119-119: wrong indentation: expected 10 but found 11
(indentation)
[warning] 120-120: wrong indentation: expected 12 but found 13
(indentation)
[warning] 123-123: wrong indentation: expected 14 but found 16
(indentation)
[warning] 127-127: wrong indentation: expected 10 but found 11
(indentation)
[warning] 128-128: wrong indentation: expected 12 but found 13
(indentation)
[warning] 131-131: wrong indentation: expected 13 but found 15
(indentation)
[warning] 132-132: wrong indentation: expected 18 but found 19
(indentation)
[warning] 136-136: wrong indentation: expected 18 but found 19
(indentation)
[warning] 139-139: wrong indentation: expected 20 but found 21
(indentation)
[warning] 142-142: wrong indentation: expected 22 but found 23
(indentation)
[warning] 148-148: wrong indentation: expected 5 but found 7
(indentation)
[warning] 149-149: wrong indentation: expected 10 but found 11
(indentation)
[warning] 154-154: wrong indentation: expected 10 but found 11
(indentation)
[warning] 157-157: wrong indentation: expected 12 but found 13
(indentation)
[error] 157-157: trailing spaces
(trailing-spaces)
[warning] 161-161: wrong indentation: expected 13 but found 15
(indentation)
[warning] 162-162: wrong indentation: expected 18 but found 19
(indentation)
[warning] 166-166: wrong indentation: expected 18 but found 19
(indentation)
[warning] 169-169: wrong indentation: expected 19 but found 21
(indentation)
[warning] 170-170: wrong indentation: expected 24 but found 25
(indentation)
[error] 173-173: trailing spaces
(trailing-spaces)
[error] 174-174: trailing spaces
(trailing-spaces)
[warning] 180-180: wrong indentation: expected 5 but found 7
(indentation)
[warning] 181-181: wrong indentation: expected 10 but found 11
(indentation)
[warning] 186-186: wrong indentation: expected 10 but found 11
(indentation)
[warning] 189-189: wrong indentation: expected 12 but found 13
(indentation)
[warning] 192-192: wrong indentation: expected 13 but found 15
(indentation)
[warning] 193-193: wrong indentation: expected 18 but found 19
(indentation)
[warning] 198-198: wrong indentation: expected 18 but found 19
(indentation)
[error] 200-200: trailing spaces
(trailing-spaces)
[warning] 203-203: wrong indentation: expected 5 but found 7
(indentation)
[error] 203-203: trailing spaces
(trailing-spaces)
[error] 204-204: trailing spaces
(trailing-spaces)
[warning] 206-206: wrong indentation: expected 5 but found 7
(indentation)
[warning] 207-207: wrong indentation: expected 10 but found 11
(indentation)
[warning] 212-212: wrong indentation: expected 10 but found 11
(indentation)
[warning] 215-215: wrong indentation: expected 12 but found 13
(indentation)
[error] 217-217: trailing spaces
(trailing-spaces)
[warning] 219-219: wrong indentation: expected 13 but found 15
(indentation)
[warning] 220-220: wrong indentation: expected 18 but found 19
(indentation)
[warning] 223-223: wrong indentation: expected 18 but found 19
(indentation)
[warning] 226-226: wrong indentation: expected 19 but found 21
(indentation)
[warning] 227-227: wrong indentation: expected 24 but found 25
(indentation)
[warning] 232-232: wrong indentation: expected 24 but found 25
(indentation)
[error] 234-234: trailing spaces
(trailing-spaces)
[warning] 237-237: wrong indentation: expected 6 but found 7
(indentation)
[warning] 241-241: wrong indentation: expected 10 but found 11
(indentation)
[error] 244-244: trailing spaces
(trailing-spaces)
[warning] 246-246: wrong indentation: expected 10 but found 11
(indentation)
[warning] 249-249: wrong indentation: expected 10 but found 11
(indentation)
[warning] 250-250: wrong indentation: expected 12 but found 13
(indentation)
[warning] 252-252: wrong indentation: expected 13 but found 15
(indentation)
[warning] 255-255: wrong indentation: expected 10 but found 11
(indentation)
[warning] 256-256: wrong indentation: expected 12 but found 13
(indentation)
[warning] 258-258: wrong indentation: expected 13 but found 15
(indentation)
[warning] 260-260: wrong indentation: expected 10 but found 11
(indentation)
[error] 262-262: no new line character at the end of file
(new-line-at-end-of-file)
[error] 262-262: trailing spaces
(trailing-spaces)
🔇 Additional comments (3)
tests/c/null-library-function-c-test.yml (1)
4-9
: Good error handling pattern!The code correctly checks errno after fwrite and handles errors appropriately.
tests/__snapshots__/null-library-function-c-snapshot.yml (1)
1-94
: Test patterns correctly demonstrate unsafe operationsThe snapshots effectively capture problematic patterns that should trigger static analysis warnings:
- Assignment within function parameters
- Missing NULL checks
- Resource leaks
- Potential NULL pointer dereferences
These patterns are good negative examples for testing the static analyzer.
rules/c/security/null-library-function-c.yml (1)
1-11
: LGTM! Well-documented rule configuration.The rule metadata is well-defined with clear message, severity, and references to CWE-476.
Summary by CodeRabbit
New Features
Tests
null-library-function-c
andnull-library-function-cpp
Documentation