SlideShare a Scribd company logo
CodeChecker
short overview
Olivera Milenkovic,
Ericsson
2021-06-21​
Intro DEMO SeI cert and
examples
Next steps
• No additional test code needed
• It saves time and money
• find software bugs before they find your customers
• Can identify potential security vulnerabilities
• Increase developer productivity
• Features
• Full path coverage
• False path pruning
• Inline explanations of defects
• Customer trust and satisfaction
• Enforce safe coding standards: MISRA, CWE, SEI cert
STATIC CODE ANALYSES
CodeChecker
Cppcheck
Flexlint
Speed Depth Accuracy Usability Supported versions of OS and language
Commercial Open source
And many more….
Codechecker
Clang Tidy
clang.llvm.org
Clang SA
clang-analyzer.llvm.org
CodeChecker
Report Mgmt
Web Server
GIT (CI)
Commit Loop
utilities
Browser
Eclipse Client
CodeCheckercmd line
analyzer
toolset
E///
Checkers
Analyzer Report Storage
Ericsson
only checkers
New Analyzer Features
Cross Translation Unit Analysis
Statistical Checkers
Viewer & Report
Management
Features
1
2
3
Analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
Demo
• http://codechecker-demo.eastus.cloudapp.azure.com/login.html#
• User id: demo
• Password: demo
• https://codechecker-demo.eastus.cloudapp.azure.com/Default/statistics/overview?is-
unique=on&detection-status=New&detection-status=Reopened&detection-
status=Unresolved
Short summary card CodeChecker 6.16.0 - current latest version (Clang 12)
Description
Analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy.
Static analysis infrastructure built on the LLVM/Clang Static Analyzer toolchain
Supported Languages
C, C++, Objective C,
Up to date C/C++ language support (C++11,14,17)
Supported Architectures Linux, OSX, docker support
Technology AST(Abstract Syntax Tree) Matcher, Symbolic Execution
Analyzers
Support for multiple analyzers, currently Clang Static Analyzer and Clang-Tidy,
Can also store results from CppCheck, FB Infer, Sanitizers more to come – report-converter
Features Inter-procedural analysis, Cross TU Analysis, statistical checkers, suppression handling, filtering,…
Price Free
Gerrit and GitLab integration Shows analysis results as Gitlab or Gerrit reviews
False Positive Rate Low
Checker Database
~300+ checkers (Clangsa 120+, clang-tidy 250+, clang warnings…)
+50 Ericsson rules
CodeChecker can enforce ~50% of the rules (through more than 400 checkers)
Developer Community Large open source. Apple, Google, Ericsson supported
Useful links
https://codechecker.readthedocs.io/en/latest/usage/
https://github.com/Ericsson/codechecker
https://github.com/Ericsson/CodeCheckerEclipsePlugin
Getting started (How-To with examples)
https://www.slideshare.net/OliveraMilenkovic/codechecker-overview-nov-2019
CodeChecker can be used as a
generic tool for visualizing
analyzer results.
For details see supported code
analyzers documentation and
the Report Converter Tool
Storage of reports from analyzer tools
Language Analyzer
C/C++
Clang Static Analyzer
Clang Tidy
Clang Sanitizers
Cppcheck
Facebook Infer
Coccinelle
Smatch
Kernel-Doc
Sparse
cpplint
Java
SpotBugs
Facebook Infer
Python
Pylint
Pyflakes
JavaScript ESLint
TypeScript TSLint
Go Golint
Markdown
Markdownlint
Sphinx
• Examples of commands to get list of checkers:
• CodeChecker checkers --profile sensitive
• CodeChecker checkers --guideline sei-cert
• See also https://codechecker.readthedocs.io/en/latest/usage/
• For analyze, parse and store commands you can use option
• --config <config file>
Codechecker config file example
{
"analyzer": [
"--jobs=10",
"--quiet",
"--ctu",
"--enable=sensitive",
"--enable= alpha.core.PointerArithm ",
"--disable= alpha.security.ArrayBound ",
"--disable= alpha.unix.cstring.BufferOverlap ",
"--report-hash=context-free-v2",
],
"parse": [
"--trim-path-prefix","${ROOT_PATH_FOR_REPO}",
"--print-step"
],
"store": [
"--url=<link to your Codechecker DB>",
"--trim-path-prefix","${ IROOT_PATH_FOR_REPO} ",
"--tag","${ CODECHECKER_STORE_TAG}"
]
}
Example of config file:
CODECHECKER_STORE_TAG can include SHA1 for commit, date,…
SEI cert related checkers
• $ CodeChecker checkers --guideline sei-cert
• alpha.ericsson.cpp.IteratorMismatch
• core.CallAndMessage
• core.DivideZero
• core.NonNullParamChecker
• core.NullDereference
• core.StackAddressEscape
• core.UndefinedBinaryOperatorResult
• core.VLASize
• core.uninitialized.UndefReturn
• cplusplus.InnerPointer
• cplusplus.Move
• cplusplus.NewDelete
• cplusplus.NewDeleteLeaks
• cplusplus.PlacementNew
• ericsson.cpp.InvalidatedIteratorAccess
• ericsson.cpp.PredWithState
• optin.cplusplus.VirtualCall
• optin.portability.UnixAPI
security.FloatLoopCounter
security.insecureAPI.gets
security.insecureAPI.vfork
unix.Malloc
unix.MallocSizeof
unix.MismatchedDeallocator
unix.Vfork
bugprone-assert-side-effect
bugprone-bad-signal-to-kill-thread
bugprone-exception-escape
bugprone-macro-repeated-side-effects
bugprone-narrowing-conversions
bugprone-signed-char-misuse
bugprone-sizeof-expression
bugprone-suspicious-memset-usage
bugprone-undefined-memory-manipulation
bugprone-unhandled-self-assignment
bugprone-unused-return-value
cert-dcl03-c
cert-dcl16-c
cert-dcl21-cpp
cert-dcl37-c
cert-dcl50-cpp
cert-dcl51-cpp
cert-dcl54-cpp
cert-dcl58-cpp
cert-dcl59-cpp
cert-env33-c
cert-err09-cpp
cert-err34-c
cert-err52-cpp
cert-err58-cpp
cert-err60-cpp
cert-err61-cpp
cert-fio38-c
cert-flp30-c
cert-mem57-cpp
cert-msc30-c
cert-msc32-c
cert-msc50-cpp
cert-msc51-cpp
cert-oop11-cpp
cert-oop54-cpp
cert-oop57-cpp
cert-oop58-cpp
cert-pos44-c
cert-str34-c
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-slicing
ericsson-cert-env32-c
misc-non-copyable-objects
misc-throw-by-value-catch-by-reference
CodeChecker references
• https://github.com/Ericsson/codechecker
• https://codechecker.readthedocs.io/en/latest/
• https://codechecker.readthedocs.io/en/latest/usage/
• http://codechecker-demo.eastus.cloudapp.azure.com/login.html#
• User id: demo
• Password: demo
• http://clang-analyzer.llvm.org/available_checks.html
• http://clang.llvm.org/extra/clang-tidy/checks/list.html
SUMMARY
Easier visual understanding of defects (The root cause of each defect is
clearly explained, making it easy to fix bugs)
Full path coverage – CTU analyses and statistical checkers
Overall summary of results for product (good for Status monitoring and
Planning of cleanups)
Filtering possibilities
Visibility of “Depth” of finding - number of steps that lead to error
Suppression handling (Per finding not file, False positive vs intentional)
Report generation
Easy detection of new defects
Easy integration to Gerrit verification for new defects
Eclipse integration...
Low false positive rate – path pruning
Some more backup slides
Ericsson Internal | 2016-03-08 | Page 5
Sim pl e An a l y s is
test1(){
int z=1/(3-abs(3));
}
int abs(int a){
if a<0
return –a;
else
return a;
}
source1.c Error:
Division by zero
Interprocedural: symbolic execution across
procedure (function) boundaries.
Simple analyses
Ericsson Internal | 2016-03-08 | Page 6
int abs(int a){
if a<0
return –a;
else
return a;
}
test1(){
int z=1/(3-abs(3));
}
Cr o s s Tr a n s l a t io n
Un it a n a l y s is (CTU)
source1.c
source2.c
Translation Unit 1
Translation Unit 2
Error:
Division by zero
To detect bugs across source file boundaries CTU analysis is needed!
Cross translational unit analyses (CTU)
Cross Translation unit analysis
CodeChecker analyze --ctu –b “make” –o reports_dir
• Default analysis is restricted to single translation unit only
• Cross Translation Unit mode: can catch faults across C/C++ file boundaries
• Analysis is slower (3-5 times) but finds 2-3 times more faults!
A.cpp
void abs(int&);
int foo(int j) {
return 42/(j + abs(j));
//division by zero
}
void main(){
foo(-5);
}
B.cpp
int abs(int a) {
if(a < 0)
return -a;
}
SUMMARY CTU
• Clang SA TU-internal analysis extended to Cross-TU analysis for C/C++
• Finds 2-3 times more reports
• Scalable & useful for industrial-size projects (PostgreSql, OpenSSL, …)
• Patch has been accepted into upstream Clang
• Try it yourself with latest Clang and CodeChecker
19
AST Matchers
`-FunctionDecl main 'int (void)'
`-CompoundStmt 0x5e40ea0 <col:11, line:6:1>
|-DeclStmt
| `-VarDecl used d 'double *'
|-BinaryOperator 'double *' lvalue '='
| |-DeclRefExpr 'double *' lvalue Var 0x5e2c5a0 'd' 'double *'
| `-CStyleCastExpr 'double *' <BitCast>
| `-CallExpr 'void *'
| |-ImplicitCastExpr 'void *(*)(int) throw()' <FunctionToPointerDecay>
| | `-DeclRefExpr 'void *(int) throw()' lvalue Function 0x5dea360 'malloc' 'void *(int) throw()'
| `-ImplicitCastExpr 'int' <IntegralCast>
| `-UnaryExprOrTypeTraitExpr 'unsigned long' sizeof
| `-ParenExpr 'double *' lvalue
| `-DeclRefExpr 'double *' lvalue Var 0x5e2c5a0 'd' 'double *'
`-ReturnStmt
`-IntegerLiteral 'int' 1
Call of operator sizeof Type of d is known
#include<stdlib.h>
int main(){
double *d;
d=(double*)malloc(sizeof(d));
return 1;
}
The allocated space is
pointer size and not double type size.
ASTMatchers
#include <stdlib.h>
#define ZERO 0
int getNull(int a) {
return a?0:1;
}
int getInput() __attribute__((notzero));
void test(int b)
{
int a,c;
double *d;
switch (b){
case 1: a = b / 0; break;
case 2: a = b / ZERO; break;
case 3: d = (double*) malloc(sizeof(d));
free(d); break;
case 4: c = b-4;
a = b / c; break;
case 5: a = b / getNull(b); break;
case 6: a = b / getInput(); break;
};
}
Found
Found as all preprocessor
statements are resolved.
Found as type resolution
can be used. (size_of checker)
Not found as
symbolic expressions
are not evaluated.
BUILD_MATCHER() { return
binaryOperator(hasOperatorName("/"),
hasRHS(integerLiteral(equals(0)).bind(
KEY_NODE)));
}
Flow insensitive
Symbolic Execution
• Path sensitive walk on the Control Flow Graph
• Simulated execution of the program
• On the most promising paths
• Variables are represented as symbolic values
• Constraints are calculated for symbolic values for each path
• Possible paths are calculated based on the constraints
• Impossible paths are dropped
Symbolic Execution
#include <stdlib.h>
void test(int b)
{
int a,c;
switch (b){
case 1: a = b / 0; break;
case 4:
c = b-4;
a = b / c; break;
};
}
b: $b
b: $b b: $b b: $b
$b=[4,4]
$b=[1,1]
$b=[MIN_INT,0],[2,3],
[5,MAX_INT]
b: $b
c: 0
$b=[4,4];
c=$b-4
c=0
b: $b
c: 0 $b=[4,4]
a=$b/$c
case 4
c = b-4;
Division by zero
switch(b)
a = b/c;
b: $b
a = b/0;
Nodes are
immutable program
states
SymbolicExecution
#include <stdlib.h>
#define ZERO 0
int getNull(int a) {
return a?0:1;
}
void test(int b)
{
int a,c;
double *d;
switch (b){
case 1: a = b / 0; break;
case 2: a = b / ZERO; break;
case 3: d = (double*) malloc(sizeof(d));
free(d); break;
case 4: c = b-4;
a = b / c; break;
case 5: a = b / getNull(b); break;
case 6: a = b / getInput(); break;
};
}
Internal function calls are followed
(context passed), variable constraints
are stored, possible paths are executed.
Context Sensitive
Inter-procedural
Analysis
Path Sensitive
Without context sensitivity, this is
undecidable.

More Related Content

What's hot

2021. Chương 2 3. Cơ sở toán học của blockchain
2021. Chương 2 3. Cơ sở toán học của blockchain2021. Chương 2 3. Cơ sở toán học của blockchain
2021. Chương 2 3. Cơ sở toán học của blockchain
Nhường Lê Đắc
 
Bridging the Security Testing Gap in Your CI/CD Pipeline
Bridging the Security Testing Gap in Your CI/CD PipelineBridging the Security Testing Gap in Your CI/CD Pipeline
Bridging the Security Testing Gap in Your CI/CD Pipeline
DevOps.com
 
Web and Mobile Application Security
Web and Mobile Application SecurityWeb and Mobile Application Security
Web and Mobile Application Security
Prateek Jain
 
Hyperledger Fabric
Hyperledger FabricHyperledger Fabric
Hyperledger Fabric
Murughan Palaniachari
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code AuditingCNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
The Mathematics Behind Bitcoin
The Mathematics Behind BitcoinThe Mathematics Behind Bitcoin
The Mathematics Behind Bitcoin
Cyril Grunspan
 
Tmc mastering bitcoins ppt
Tmc mastering bitcoins pptTmc mastering bitcoins ppt
Tmc mastering bitcoins ppt
Urvashi Choudhary
 
Hunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows InfrastructureHunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows Infrastructure
Sergey Soldatov
 
Homomorphic encryption on Blockchain Principles
Homomorphic encryption on Blockchain PrinciplesHomomorphic encryption on Blockchain Principles
Homomorphic encryption on Blockchain Principles
Johann Höchtl
 
How to do Cryptography right in Android Part Two
How to do Cryptography right in Android Part TwoHow to do Cryptography right in Android Part Two
How to do Cryptography right in Android Part Two
Arash Ramez
 
Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges
Merlec Mpyana
 
Security as Code: A DevSecOps Approach
Security as Code: A DevSecOps ApproachSecurity as Code: A DevSecOps Approach
Security as Code: A DevSecOps Approach
VMware Tanzu
 
Attacks on Smart Contracts
Attacks on Smart ContractsAttacks on Smart Contracts
Attacks on Smart Contracts
Marcin Majchrzak
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
SSIMeetup
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
Sam Bowne
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
Mikhail Egorov
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
Mohammed Danish Amber
 
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Simplilearn
 
Introducing DevOps
Introducing DevOpsIntroducing DevOps
Introducing DevOps
Nishanth K Hydru
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101
Yoss Cohen
 

What's hot (20)

2021. Chương 2 3. Cơ sở toán học của blockchain
2021. Chương 2 3. Cơ sở toán học của blockchain2021. Chương 2 3. Cơ sở toán học của blockchain
2021. Chương 2 3. Cơ sở toán học của blockchain
 
Bridging the Security Testing Gap in Your CI/CD Pipeline
Bridging the Security Testing Gap in Your CI/CD PipelineBridging the Security Testing Gap in Your CI/CD Pipeline
Bridging the Security Testing Gap in Your CI/CD Pipeline
 
Web and Mobile Application Security
Web and Mobile Application SecurityWeb and Mobile Application Security
Web and Mobile Application Security
 
Hyperledger Fabric
Hyperledger FabricHyperledger Fabric
Hyperledger Fabric
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code AuditingCNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
 
The Mathematics Behind Bitcoin
The Mathematics Behind BitcoinThe Mathematics Behind Bitcoin
The Mathematics Behind Bitcoin
 
Tmc mastering bitcoins ppt
Tmc mastering bitcoins pptTmc mastering bitcoins ppt
Tmc mastering bitcoins ppt
 
Hunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows InfrastructureHunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows Infrastructure
 
Homomorphic encryption on Blockchain Principles
Homomorphic encryption on Blockchain PrinciplesHomomorphic encryption on Blockchain Principles
Homomorphic encryption on Blockchain Principles
 
How to do Cryptography right in Android Part Two
How to do Cryptography right in Android Part TwoHow to do Cryptography right in Android Part Two
How to do Cryptography right in Android Part Two
 
Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges Blockchain Security Issues and Challenges
Blockchain Security Issues and Challenges
 
Security as Code: A DevSecOps Approach
Security as Code: A DevSecOps ApproachSecurity as Code: A DevSecOps Approach
Security as Code: A DevSecOps Approach
 
Attacks on Smart Contracts
Attacks on Smart ContractsAttacks on Smart Contracts
Attacks on Smart Contracts
 
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare NelsonZero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
Zero-Knowledge Proofs: Privacy-Preserving Digital Identity with Clare Nelson
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
 
Introducing DevOps
Introducing DevOpsIntroducing DevOps
Introducing DevOps
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101
 

Similar to CodeChecker summary 21062021

Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error predictionNIKHIL NAWATHE
 
Secure Coding Practices for Middleware
Secure Coding Practices for MiddlewareSecure Coding Practices for Middleware
Secure Coding Practices for MiddlewareManuel Brugnoli
 
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
Andrey Karpov
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
Andreas Czakaj
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Engineering Software Lab
 
Getting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testingGetting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testing
RISC-V International
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Elena Laskavaia
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
Amiq Consulting
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
Andrey Karpov
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernel
PVS-Studio
 
The CppCat Analyzer Checks TortoiseGit
The CppCat Analyzer Checks TortoiseGitThe CppCat Analyzer Checks TortoiseGit
The CppCat Analyzer Checks TortoiseGit
Andrey Karpov
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis technique
Andrey Karpov
 
SAST, CWE, SEI CERT and other smart words from the information security world
SAST, CWE, SEI CERT and other smart words from the information security worldSAST, CWE, SEI CERT and other smart words from the information security world
SAST, CWE, SEI CERT and other smart words from the information security world
Andrey Karpov
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
Andrey Karpov
 
Price of an Error
Price of an ErrorPrice of an Error
Price of an Error
Andrey Karpov
 
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
Christopher Diamantopoulos
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++" Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++"
Anna Shymchenko
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Windows Developer
 

Similar to CodeChecker summary 21062021 (20)

Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error prediction
 
Secure Coding Practices for Middleware
Secure Coding Practices for MiddlewareSecure Coding Practices for Middleware
Secure Coding Practices for Middleware
 
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
Getting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testingGetting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testing
 
Pragmatic Code Coverage
Pragmatic Code CoveragePragmatic Code Coverage
Pragmatic Code Coverage
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernel
 
The CppCat Analyzer Checks TortoiseGit
The CppCat Analyzer Checks TortoiseGitThe CppCat Analyzer Checks TortoiseGit
The CppCat Analyzer Checks TortoiseGit
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis technique
 
SAST, CWE, SEI CERT and other smart words from the information security world
SAST, CWE, SEI CERT and other smart words from the information security worldSAST, CWE, SEI CERT and other smart words from the information security world
SAST, CWE, SEI CERT and other smart words from the information security world
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Price of an Error
Price of an ErrorPrice of an Error
Price of an Error
 
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
IMAGE CAPTURE, PROCESSING AND TRANSFER VIA ETHERNET UNDER CONTROL OF MATLAB G...
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++" Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++"
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 

Recently uploaded

Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 

Recently uploaded (20)

Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 

CodeChecker summary 21062021

  • 2. Intro DEMO SeI cert and examples Next steps
  • 3. • No additional test code needed • It saves time and money • find software bugs before they find your customers • Can identify potential security vulnerabilities • Increase developer productivity • Features • Full path coverage • False path pruning • Inline explanations of defects • Customer trust and satisfaction • Enforce safe coding standards: MISRA, CWE, SEI cert STATIC CODE ANALYSES CodeChecker Cppcheck Flexlint Speed Depth Accuracy Usability Supported versions of OS and language Commercial Open source And many more….
  • 4. Codechecker Clang Tidy clang.llvm.org Clang SA clang-analyzer.llvm.org CodeChecker Report Mgmt Web Server GIT (CI) Commit Loop utilities Browser Eclipse Client CodeCheckercmd line analyzer toolset E/// Checkers Analyzer Report Storage Ericsson only checkers New Analyzer Features Cross Translation Unit Analysis Statistical Checkers Viewer & Report Management Features 1 2 3 Analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
  • 5. Demo • http://codechecker-demo.eastus.cloudapp.azure.com/login.html# • User id: demo • Password: demo • https://codechecker-demo.eastus.cloudapp.azure.com/Default/statistics/overview?is- unique=on&detection-status=New&detection-status=Reopened&detection- status=Unresolved
  • 6. Short summary card CodeChecker 6.16.0 - current latest version (Clang 12) Description Analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy. Static analysis infrastructure built on the LLVM/Clang Static Analyzer toolchain Supported Languages C, C++, Objective C, Up to date C/C++ language support (C++11,14,17) Supported Architectures Linux, OSX, docker support Technology AST(Abstract Syntax Tree) Matcher, Symbolic Execution Analyzers Support for multiple analyzers, currently Clang Static Analyzer and Clang-Tidy, Can also store results from CppCheck, FB Infer, Sanitizers more to come – report-converter Features Inter-procedural analysis, Cross TU Analysis, statistical checkers, suppression handling, filtering,… Price Free Gerrit and GitLab integration Shows analysis results as Gitlab or Gerrit reviews False Positive Rate Low Checker Database ~300+ checkers (Clangsa 120+, clang-tidy 250+, clang warnings…) +50 Ericsson rules CodeChecker can enforce ~50% of the rules (through more than 400 checkers) Developer Community Large open source. Apple, Google, Ericsson supported Useful links https://codechecker.readthedocs.io/en/latest/usage/ https://github.com/Ericsson/codechecker https://github.com/Ericsson/CodeCheckerEclipsePlugin Getting started (How-To with examples) https://www.slideshare.net/OliveraMilenkovic/codechecker-overview-nov-2019
  • 7. CodeChecker can be used as a generic tool for visualizing analyzer results. For details see supported code analyzers documentation and the Report Converter Tool Storage of reports from analyzer tools Language Analyzer C/C++ Clang Static Analyzer Clang Tidy Clang Sanitizers Cppcheck Facebook Infer Coccinelle Smatch Kernel-Doc Sparse cpplint Java SpotBugs Facebook Infer Python Pylint Pyflakes JavaScript ESLint TypeScript TSLint Go Golint Markdown Markdownlint Sphinx
  • 8.
  • 9. • Examples of commands to get list of checkers: • CodeChecker checkers --profile sensitive • CodeChecker checkers --guideline sei-cert • See also https://codechecker.readthedocs.io/en/latest/usage/ • For analyze, parse and store commands you can use option • --config <config file> Codechecker config file example { "analyzer": [ "--jobs=10", "--quiet", "--ctu", "--enable=sensitive", "--enable= alpha.core.PointerArithm ", "--disable= alpha.security.ArrayBound ", "--disable= alpha.unix.cstring.BufferOverlap ", "--report-hash=context-free-v2", ], "parse": [ "--trim-path-prefix","${ROOT_PATH_FOR_REPO}", "--print-step" ], "store": [ "--url=<link to your Codechecker DB>", "--trim-path-prefix","${ IROOT_PATH_FOR_REPO} ", "--tag","${ CODECHECKER_STORE_TAG}" ] } Example of config file: CODECHECKER_STORE_TAG can include SHA1 for commit, date,…
  • 10. SEI cert related checkers • $ CodeChecker checkers --guideline sei-cert • alpha.ericsson.cpp.IteratorMismatch • core.CallAndMessage • core.DivideZero • core.NonNullParamChecker • core.NullDereference • core.StackAddressEscape • core.UndefinedBinaryOperatorResult • core.VLASize • core.uninitialized.UndefReturn • cplusplus.InnerPointer • cplusplus.Move • cplusplus.NewDelete • cplusplus.NewDeleteLeaks • cplusplus.PlacementNew • ericsson.cpp.InvalidatedIteratorAccess • ericsson.cpp.PredWithState • optin.cplusplus.VirtualCall • optin.portability.UnixAPI security.FloatLoopCounter security.insecureAPI.gets security.insecureAPI.vfork unix.Malloc unix.MallocSizeof unix.MismatchedDeallocator unix.Vfork bugprone-assert-side-effect bugprone-bad-signal-to-kill-thread bugprone-exception-escape bugprone-macro-repeated-side-effects bugprone-narrowing-conversions bugprone-signed-char-misuse bugprone-sizeof-expression bugprone-suspicious-memset-usage bugprone-undefined-memory-manipulation bugprone-unhandled-self-assignment bugprone-unused-return-value cert-dcl03-c cert-dcl16-c cert-dcl21-cpp cert-dcl37-c cert-dcl50-cpp cert-dcl51-cpp cert-dcl54-cpp cert-dcl58-cpp cert-dcl59-cpp cert-env33-c cert-err09-cpp cert-err34-c cert-err52-cpp cert-err58-cpp cert-err60-cpp cert-err61-cpp cert-fio38-c cert-flp30-c cert-mem57-cpp cert-msc30-c cert-msc32-c cert-msc50-cpp cert-msc51-cpp cert-oop11-cpp cert-oop54-cpp cert-oop57-cpp cert-oop58-cpp cert-pos44-c cert-str34-c cppcoreguidelines-pro-type-const-cast cppcoreguidelines-slicing ericsson-cert-env32-c misc-non-copyable-objects misc-throw-by-value-catch-by-reference
  • 11. CodeChecker references • https://github.com/Ericsson/codechecker • https://codechecker.readthedocs.io/en/latest/ • https://codechecker.readthedocs.io/en/latest/usage/ • http://codechecker-demo.eastus.cloudapp.azure.com/login.html# • User id: demo • Password: demo • http://clang-analyzer.llvm.org/available_checks.html • http://clang.llvm.org/extra/clang-tidy/checks/list.html
  • 12. SUMMARY Easier visual understanding of defects (The root cause of each defect is clearly explained, making it easy to fix bugs) Full path coverage – CTU analyses and statistical checkers Overall summary of results for product (good for Status monitoring and Planning of cleanups) Filtering possibilities Visibility of “Depth” of finding - number of steps that lead to error Suppression handling (Per finding not file, False positive vs intentional) Report generation Easy detection of new defects Easy integration to Gerrit verification for new defects Eclipse integration... Low false positive rate – path pruning
  • 14. Ericsson Internal | 2016-03-08 | Page 5 Sim pl e An a l y s is test1(){ int z=1/(3-abs(3)); } int abs(int a){ if a<0 return –a; else return a; } source1.c Error: Division by zero Interprocedural: symbolic execution across procedure (function) boundaries. Simple analyses
  • 15. Ericsson Internal | 2016-03-08 | Page 6 int abs(int a){ if a<0 return –a; else return a; } test1(){ int z=1/(3-abs(3)); } Cr o s s Tr a n s l a t io n Un it a n a l y s is (CTU) source1.c source2.c Translation Unit 1 Translation Unit 2 Error: Division by zero To detect bugs across source file boundaries CTU analysis is needed! Cross translational unit analyses (CTU)
  • 16. Cross Translation unit analysis CodeChecker analyze --ctu –b “make” –o reports_dir • Default analysis is restricted to single translation unit only • Cross Translation Unit mode: can catch faults across C/C++ file boundaries • Analysis is slower (3-5 times) but finds 2-3 times more faults! A.cpp void abs(int&); int foo(int j) { return 42/(j + abs(j)); //division by zero } void main(){ foo(-5); } B.cpp int abs(int a) { if(a < 0) return -a; }
  • 17. SUMMARY CTU • Clang SA TU-internal analysis extended to Cross-TU analysis for C/C++ • Finds 2-3 times more reports • Scalable & useful for industrial-size projects (PostgreSql, OpenSSL, …) • Patch has been accepted into upstream Clang • Try it yourself with latest Clang and CodeChecker 19
  • 18. AST Matchers `-FunctionDecl main 'int (void)' `-CompoundStmt 0x5e40ea0 <col:11, line:6:1> |-DeclStmt | `-VarDecl used d 'double *' |-BinaryOperator 'double *' lvalue '=' | |-DeclRefExpr 'double *' lvalue Var 0x5e2c5a0 'd' 'double *' | `-CStyleCastExpr 'double *' <BitCast> | `-CallExpr 'void *' | |-ImplicitCastExpr 'void *(*)(int) throw()' <FunctionToPointerDecay> | | `-DeclRefExpr 'void *(int) throw()' lvalue Function 0x5dea360 'malloc' 'void *(int) throw()' | `-ImplicitCastExpr 'int' <IntegralCast> | `-UnaryExprOrTypeTraitExpr 'unsigned long' sizeof | `-ParenExpr 'double *' lvalue | `-DeclRefExpr 'double *' lvalue Var 0x5e2c5a0 'd' 'double *' `-ReturnStmt `-IntegerLiteral 'int' 1 Call of operator sizeof Type of d is known #include<stdlib.h> int main(){ double *d; d=(double*)malloc(sizeof(d)); return 1; } The allocated space is pointer size and not double type size.
  • 19. ASTMatchers #include <stdlib.h> #define ZERO 0 int getNull(int a) { return a?0:1; } int getInput() __attribute__((notzero)); void test(int b) { int a,c; double *d; switch (b){ case 1: a = b / 0; break; case 2: a = b / ZERO; break; case 3: d = (double*) malloc(sizeof(d)); free(d); break; case 4: c = b-4; a = b / c; break; case 5: a = b / getNull(b); break; case 6: a = b / getInput(); break; }; } Found Found as all preprocessor statements are resolved. Found as type resolution can be used. (size_of checker) Not found as symbolic expressions are not evaluated. BUILD_MATCHER() { return binaryOperator(hasOperatorName("/"), hasRHS(integerLiteral(equals(0)).bind( KEY_NODE))); } Flow insensitive
  • 20. Symbolic Execution • Path sensitive walk on the Control Flow Graph • Simulated execution of the program • On the most promising paths • Variables are represented as symbolic values • Constraints are calculated for symbolic values for each path • Possible paths are calculated based on the constraints • Impossible paths are dropped
  • 21. Symbolic Execution #include <stdlib.h> void test(int b) { int a,c; switch (b){ case 1: a = b / 0; break; case 4: c = b-4; a = b / c; break; }; } b: $b b: $b b: $b b: $b $b=[4,4] $b=[1,1] $b=[MIN_INT,0],[2,3], [5,MAX_INT] b: $b c: 0 $b=[4,4]; c=$b-4 c=0 b: $b c: 0 $b=[4,4] a=$b/$c case 4 c = b-4; Division by zero switch(b) a = b/c; b: $b a = b/0; Nodes are immutable program states
  • 22. SymbolicExecution #include <stdlib.h> #define ZERO 0 int getNull(int a) { return a?0:1; } void test(int b) { int a,c; double *d; switch (b){ case 1: a = b / 0; break; case 2: a = b / ZERO; break; case 3: d = (double*) malloc(sizeof(d)); free(d); break; case 4: c = b-4; a = b / c; break; case 5: a = b / getNull(b); break; case 6: a = b / getInput(); break; }; } Internal function calls are followed (context passed), variable constraints are stored, possible paths are executed. Context Sensitive Inter-procedural Analysis Path Sensitive Without context sensitivity, this is undecidable.

Editor's Notes

  1. The current solution seems bad but actually its fine in most cases (definitely improvable though