SlideShare a Scribd company logo
The Use of Static Code Analysis When Teaching
or Developing Open-Source Software
Presenter:
George Gribkov
1. Static analysis: short overview
2. Use of static analysis at colleges and universities
3. Use of static analysis in student and open projects
Contents
2
Static Analysis: Short Overview
3
ο‚§ Write correct code
ο‚§ Unit tests
ο‚§ Regression testing
ο‚§ Code review
ο‚§ …is there some other way?
ο‚§ Yes! For example – tools for automated analysis.
How to Improve Code Quality
4
ο‚§ Static analysis tools: check code when it’s not
executed
ο‚§ Dynamic analysis tools: check code when it’s being
executed
Automated Code Analysis Tools
5
ο‚§ Both approaches compliment each other very well.
Cost to Fix a Bug
6
ο‚§ Issues false positives
ο‚§ Difficulties with multithreading
ο‚§ Does not eliminate the need for code review
Static Analysis Disadvantages
7
ο‚§ Covers the entire code
ο‚§ Significantly faster than dynamic code analysis
ο‚§ More convenient for large projects
Static Analysis Advantages
8
ο‚§ Can check code style or whether the code complies
with a coding standard (MISRA, AUTOSAR C++)
ο‚§ Easy to use
ο‚§ Helps developers learn and teach
Static Analysis Advantages
9
Use of Static Analysis at Colleges and
Universitites
10
ο‚§ Helps check homework
ο‚§ Helps check final projects
ο‚§ Saves instructors’ time
For Instructors
11
ο‚§ Provides a chance to learn a new approach
ο‚§ Helps with self-study and problem solving
ο‚§ Facilitates development
ο‚§ Shows and helps study error patterns
For Students
12
Pattern Examples (Vangers)
13
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete p;
delete p1;
}
Pattern Examples (Vangers)
14
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete p; // <=
delete p1; // <=
}
Pattern Examples (Vangers)
15
void aciPackFile(....)
{
int sz,sz1;
char *p,*p1;
....
p = new char[sz];
p1 = new char[sz1];
....
delete [] p;
delete [] p1;
}
Pattern Examples (Apache HTTP Server)
16
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset(x, 0, sizeof(x));
}
Pattern Examples (Apache HTTP Server)
17
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset(x, 0, sizeof(x)); // <=
}
Pattern Examples (Apache HTTP Server)
18
static void MD4Transform(
apr_uint32_t state[4],
const unsigned char block[64])
{
apr_uint32_t a = state[0], b = state[1],
c = state[2], d = state[3],
x[APR_MD4_DIGESTSIZE];
....
/* Zeroize sensitive information. */
memset_s(x, 0, sizeof(x));
}
*Or use the following flag: -fno-builtin-memset!
ο‚§ Provides a chance to learn a new approach
ο‚§ Helps with self-study and problem solving
ο‚§ Facilitates development
ο‚§ Shows and helps study error patterns
For Students
19
Use of Static Analysis in Student and
Open Projects
20
ο‚§ Static analysis provides its maximum benefit
only when used regularly!
Regular Use is the Main Thing
21
Regular Use is the Main Thing
22
Efficient Static Analyzers
23
β€’ PVS-Studio
β€’ Clang Static Analyzer
β€’ Cppcheck
β€’ Infer
β€’ IntelliJ IDEA
β€’ FindBugs
β€’ ...
β€’ A detailed list of static
analyzers:
1. A classic development scenario
(in office)
2. Developing student and open-source projects
Introducing Analysis
24
ο‚§ Locally on developers’ computer (plugins for IDE,
compilation monitoring system)
A Typical Scenario
25
ο‚§ Continuous integration systems (command-line utilities,
plugins for CI systems, monitoring systems)
A Typical Scenario
26
A Typical Scenario
27
What’s the difference?
Student and Open-Source Projects
28
A Typical Scenario
29
Student and Open-Source Projects
30
Student and Open-Source Projects
31
Student and Open-Source Projects
32
Student and Open-Source Projects
33
Using an Analyzer on Open-Source Projects
34
Using an Analyzer on Open-Source Projects
35
How to Analyze Community Contribution?
36
What to Do After the First Check?
37
Using an Analyzer on Open-Source Projects
38
Using an Analyzer on Open-Source Projects
39
Pull Request Analysis
40
How to Analyze Community Contribution?
41
ο‚§ Suppress bases are a mass suppression tool for
the analyzer’s warnings.
After the First Check
42
ο‚§ Suppress bases are a mass suppression tool for
the analyzer’s warnings.
After the First Check
43
ο‚§ Hide old errors – keep up the normal pace
ο‚§ See only the latest warnings starting from this moment
ο‚§ Get immediate benefits from the analyzer
ο‚§ Do not forget about the old errors! Come back and fix them
one-by-one.
The Purpose of Suppress Bases
44
ο‚§ A very convenient approach: the β€œratcheting” method
ο‚§ The number of errors in the base is committed to the repository.
ο‚§ Changes are allowed only when they do not increase the total
number of errors.
How to Work with Suppress Base
45
How to Work with Suppress Base
46
ο‚§ https://habr.com/en/post/440610/
An Article on the Topic
47
Conclusion
48
ο‚§ Static analysis helps study programming
ο‚§ It’s important to use static analysis regularly
ο‚§ It’s okay to use static analysis in open-source projects!
Recap
49
A Free PVS-Studio License for Open-Source Project
Developers
50
END
Q&A51

More Related Content

PDF
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
PDF
TMPA-2017: Vellvm - Verifying the LLVM
PDF
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
PDF
TMPA-2015: A Need To Specify and Verify Standard Functions
PDF
Cppcheck
PPTX
Reverse Engineering automation
PDF
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
PPT
Testing
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
TMPA-2015: A Need To Specify and Verify Standard Functions
Cppcheck
Reverse Engineering automation
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
Testing

What's hot (20)

PDF
Symbolic Execution (introduction and hands-on)
PPTX
Loops in c
PDF
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
PPT
Code Analysis-run time error prediction
PPTX
Static analysis
PDF
Search-driven String Constraint Solving for Vulnerability Detection
PDF
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
PPTX
IEEE SCAM 2017 Revisiting Exception Handling Practices with Exception Flow An...
PPT
Templates exception handling
PPT
9781285852744 ppt ch14
PPTX
Extending C# with Roslyn and Code Aware Libraries
PPT
Unit iii
PDF
Mock object
PDF
Java 8 - Lambdas and much more
PPTX
STAMP
PPTX
C programming language tutorial
PPT
Storage classes
DOCX
Qtp certification questions2
PPTX
C language (Part 2)
PDF
Headache from using mathematical software
Symbolic Execution (introduction and hands-on)
Loops in c
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Code Analysis-run time error prediction
Static analysis
Search-driven String Constraint Solving for Vulnerability Detection
SherLog: Error Diagnosis by Connecting Clues from Run-time Logs
IEEE SCAM 2017 Revisiting Exception Handling Practices with Exception Flow An...
Templates exception handling
9781285852744 ppt ch14
Extending C# with Roslyn and Code Aware Libraries
Unit iii
Mock object
Java 8 - Lambdas and much more
STAMP
C programming language tutorial
Storage classes
Qtp certification questions2
C language (Part 2)
Headache from using mathematical software
Ad

Similar to The Use of Static Code Analysis When Teaching or Developing Open-Source Software (20)

PDF
Stale pointers are the new black - white paper
PPTX
Static code analysis: what? how? why?
PDF
Videos about static code analysis
PPTX
Does static analysis need machine learning?
PDF
Secure Programming With Static Analysis
PDF
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
PDF
PVS-Studio advertisement - static analysis of C/C++ code
PDF
Static Analysis: From Getting Started to Integration
PDF
What's the Difference Between Static Analysis and Compiler Warnings?
PDF
0136 ideal static_analyzer
PDF
An ideal static analyzer, or why ideals are unachievable
PPTX
Static Analysis Primer
PDF
Static Code Analysis and Cppcheck
PPTX
Static-Analysis-in-Industry.pptx
PDF
Achieving quality with tools case study
PDF
PVS-Studio advertisement - static analysis of C/C++ code
PDF
Peddle the Pedal to the Metal
PDF
Static and Dynamic Code Analysis
PPTX
200 Open Source Projects Later: Source Code Static Analysis Experience
PPTX
PVS-Studio and static code analysis technique
Stale pointers are the new black - white paper
Static code analysis: what? how? why?
Videos about static code analysis
Does static analysis need machine learning?
Secure Programming With Static Analysis
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
PVS-Studio advertisement - static analysis of C/C++ code
Static Analysis: From Getting Started to Integration
What's the Difference Between Static Analysis and Compiler Warnings?
0136 ideal static_analyzer
An ideal static analyzer, or why ideals are unachievable
Static Analysis Primer
Static Code Analysis and Cppcheck
Static-Analysis-in-Industry.pptx
Achieving quality with tools case study
PVS-Studio advertisement - static analysis of C/C++ code
Peddle the Pedal to the Metal
Static and Dynamic Code Analysis
200 Open Source Projects Later: Source Code Static Analysis Experience
PVS-Studio and static code analysis technique
Ad

More from Andrey Karpov (20)

PDF
60 Π°Π½Ρ‚ΠΈΠΏΠ°Ρ‚Ρ‚Π΅Ρ€Π½ΠΎΠ² для Π‘++ программиста
PDF
60 terrible tips for a C++ developer
PPTX
Ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ слоТно Π·Π°ΠΌΠ΅Ρ‚ΠΈΡ‚ΡŒ Π½Π° code review, Π½ΠΎ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ находятся статичСс...
PDF
PVS-Studio in 2021 - Error Examples
PDF
PVS-Studio in 2021 - Feature Overview
PDF
PVS-Studio Π² 2021 - ΠŸΡ€ΠΈΠΌΠ΅Ρ€Ρ‹ ошибок
PDF
PVS-Studio Π² 2021
PPTX
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
PPTX
Best Bugs from Games: Fellow Programmers' Mistakes
PPTX
Typical errors in code on the example of C++, C#, and Java
PPTX
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
PPTX
Game Engine Code Quality: Is Everything Really That Bad?
PPTX
C++ Code as Seen by a Hypercritical Reviewer
PPTX
Static Code Analysis for Projects, Built on Unreal Engine
PPTX
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
PPTX
The Great and Mighty C++
PDF
Zero, one, two, Freddy's coming for you
PDF
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PDF
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PDF
Analysis of commits and pull requests in Travis CI, Buddy and AppVeyor using ...
60 Π°Π½Ρ‚ΠΈΠΏΠ°Ρ‚Ρ‚Π΅Ρ€Π½ΠΎΠ² для Π‘++ программиста
60 terrible tips for a C++ developer
Ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ слоТно Π·Π°ΠΌΠ΅Ρ‚ΠΈΡ‚ΡŒ Π½Π° code review, Π½ΠΎ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ находятся статичСс...
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Feature Overview
PVS-Studio Π² 2021 - ΠŸΡ€ΠΈΠΌΠ΅Ρ€Ρ‹ ошибок
PVS-Studio Π² 2021
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Best Bugs from Games: Fellow Programmers' Mistakes
Typical errors in code on the example of C++, C#, and Java
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
Game Engine Code Quality: Is Everything Really That Bad?
C++ Code as Seen by a Hypercritical Reviewer
Static Code Analysis for Projects, Built on Unreal Engine
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
The Great and Mighty C++
Zero, one, two, Freddy's coming for you
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
Analysis of commits and pull requests in Travis CI, Buddy and AppVeyor using ...

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Β 
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Pharma ospi slides which help in ospi learning
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
O7-L3 Supply Chain Operations - ICLT Program
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Β 
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Pharma ospi slides which help in ospi learning
Basic Mud Logging Guide for educational purpose
Renaissance Architecture: A Journey from Faith to Humanism
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
01-Introduction-to-Information-Management.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Complications of Minimal Access Surgery at WLH
FourierSeries-QuestionsWithAnswers(Part-A).pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Types and Its function , kingdom of life
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
Supply Chain Operations Speaking Notes -ICLT Program
Insiders guide to clinical Medicine.pdf

The Use of Static Code Analysis When Teaching or Developing Open-Source Software

  • 1. The Use of Static Code Analysis When Teaching or Developing Open-Source Software Presenter: George Gribkov
  • 2. 1. Static analysis: short overview 2. Use of static analysis at colleges and universities 3. Use of static analysis in student and open projects Contents 2
  • 4. ο‚§ Write correct code ο‚§ Unit tests ο‚§ Regression testing ο‚§ Code review ο‚§ …is there some other way? ο‚§ Yes! For example – tools for automated analysis. How to Improve Code Quality 4
  • 5. ο‚§ Static analysis tools: check code when it’s not executed ο‚§ Dynamic analysis tools: check code when it’s being executed Automated Code Analysis Tools 5 ο‚§ Both approaches compliment each other very well.
  • 6. Cost to Fix a Bug 6
  • 7. ο‚§ Issues false positives ο‚§ Difficulties with multithreading ο‚§ Does not eliminate the need for code review Static Analysis Disadvantages 7
  • 8. ο‚§ Covers the entire code ο‚§ Significantly faster than dynamic code analysis ο‚§ More convenient for large projects Static Analysis Advantages 8
  • 9. ο‚§ Can check code style or whether the code complies with a coding standard (MISRA, AUTOSAR C++) ο‚§ Easy to use ο‚§ Helps developers learn and teach Static Analysis Advantages 9
  • 10. Use of Static Analysis at Colleges and Universitites 10
  • 11. ο‚§ Helps check homework ο‚§ Helps check final projects ο‚§ Saves instructors’ time For Instructors 11
  • 12. ο‚§ Provides a chance to learn a new approach ο‚§ Helps with self-study and problem solving ο‚§ Facilitates development ο‚§ Shows and helps study error patterns For Students 12
  • 13. Pattern Examples (Vangers) 13 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete p; delete p1; }
  • 14. Pattern Examples (Vangers) 14 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete p; // <= delete p1; // <= }
  • 15. Pattern Examples (Vangers) 15 void aciPackFile(....) { int sz,sz1; char *p,*p1; .... p = new char[sz]; p1 = new char[sz1]; .... delete [] p; delete [] p1; }
  • 16. Pattern Examples (Apache HTTP Server) 16 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset(x, 0, sizeof(x)); }
  • 17. Pattern Examples (Apache HTTP Server) 17 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset(x, 0, sizeof(x)); // <= }
  • 18. Pattern Examples (Apache HTTP Server) 18 static void MD4Transform( apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[APR_MD4_DIGESTSIZE]; .... /* Zeroize sensitive information. */ memset_s(x, 0, sizeof(x)); } *Or use the following flag: -fno-builtin-memset!
  • 19. ο‚§ Provides a chance to learn a new approach ο‚§ Helps with self-study and problem solving ο‚§ Facilitates development ο‚§ Shows and helps study error patterns For Students 19
  • 20. Use of Static Analysis in Student and Open Projects 20
  • 21. ο‚§ Static analysis provides its maximum benefit only when used regularly! Regular Use is the Main Thing 21
  • 22. Regular Use is the Main Thing 22
  • 23. Efficient Static Analyzers 23 β€’ PVS-Studio β€’ Clang Static Analyzer β€’ Cppcheck β€’ Infer β€’ IntelliJ IDEA β€’ FindBugs β€’ ... β€’ A detailed list of static analyzers:
  • 24. 1. A classic development scenario (in office) 2. Developing student and open-source projects Introducing Analysis 24
  • 25. ο‚§ Locally on developers’ computer (plugins for IDE, compilation monitoring system) A Typical Scenario 25
  • 26. ο‚§ Continuous integration systems (command-line utilities, plugins for CI systems, monitoring systems) A Typical Scenario 26
  • 28. What’s the difference? Student and Open-Source Projects 28
  • 30. Student and Open-Source Projects 30
  • 31. Student and Open-Source Projects 31
  • 32. Student and Open-Source Projects 32
  • 33. Student and Open-Source Projects 33
  • 34. Using an Analyzer on Open-Source Projects 34
  • 35. Using an Analyzer on Open-Source Projects 35
  • 36. How to Analyze Community Contribution? 36
  • 37. What to Do After the First Check? 37
  • 38. Using an Analyzer on Open-Source Projects 38
  • 39. Using an Analyzer on Open-Source Projects 39
  • 41. How to Analyze Community Contribution? 41
  • 42. ο‚§ Suppress bases are a mass suppression tool for the analyzer’s warnings. After the First Check 42
  • 43. ο‚§ Suppress bases are a mass suppression tool for the analyzer’s warnings. After the First Check 43
  • 44. ο‚§ Hide old errors – keep up the normal pace ο‚§ See only the latest warnings starting from this moment ο‚§ Get immediate benefits from the analyzer ο‚§ Do not forget about the old errors! Come back and fix them one-by-one. The Purpose of Suppress Bases 44
  • 45. ο‚§ A very convenient approach: the β€œratcheting” method ο‚§ The number of errors in the base is committed to the repository. ο‚§ Changes are allowed only when they do not increase the total number of errors. How to Work with Suppress Base 45
  • 46. How to Work with Suppress Base 46
  • 49. ο‚§ Static analysis helps study programming ο‚§ It’s important to use static analysis regularly ο‚§ It’s okay to use static analysis in open-source projects! Recap 49
  • 50. A Free PVS-Studio License for Open-Source Project Developers 50