static code analysis - umsl blogs · 2016-01-13 · cppcheck cppcheck primarily detects the types...
TRANSCRIPT
![Page 1: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/1.jpg)
Static Code Analysis
By: Nathan Want, Nikolay Filipets, Sasa Basara
![Page 2: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/2.jpg)
Overview
▸ Method▸ Tools▸ Applications (dl-fidigi & Mantra broswer) ▸ Errors & Resolutions
![Page 3: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/3.jpg)
Static code analsyis is preformed without running the program. The analysis is preformed on the source code and is generally referred to as white box testing.
What is Static Code Analysis?
![Page 4: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/4.jpg)
Advantages andDisvantages
• Weakness found at exact location
• Quicker turn around for fixes
• Tools can scan entire code base
• False positives and false negatives
• Provide a false sense of secuirty
• Vulnerabilities in runtime environment not found
Advantages
Disadvantages
![Page 5: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/5.jpg)
Cppcheck
Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors in the code and reduce the false positives. Cppcheck unlike other analysis tools does not detect syntax errors in the code.
![Page 6: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/6.jpg)
Screen shot example of our analysis (of dl-fidigi) using cppchecker
![Page 7: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/7.jpg)
dl-fidigi
dl-fldigi is an adapted version of the excellent free FLdigi soundcard decoding software. It takes the audio from your radio, decodes the balloon's signal, and then sends the telemetry it's found over the internet to a server running habitat, which plots the payloads position on to the SpaceNear map.
![Page 8: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/8.jpg)
dl-fidigi
Static Analysis results using Cppcheck:
![Page 9: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/9.jpg)
Index missing conditional statement
Solution:
Make sure index does not exceed 13th element in ‘if’ statement.
![Page 10: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/10.jpg)
Solution:
Do not enter loop if j== s.size
Loop missing conditional
![Page 11: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/11.jpg)
Solution:
%5 should be %4
Incorret value
![Page 12: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/12.jpg)
Mantra broswer
Mantra is a web browser developed by OWASP. It is a free browser that comes with a powerful set of security tools. A few notable features of Mantra are: FireCat/KromCAT menu structure, proxy tools, FTP, SSH, REST and SQLite clients, and URL increment/decrement buttons to quickly change URLS.
![Page 13: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/13.jpg)
Mantra broswer
Static Analysis results using Cppcheck:
![Page 14: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/14.jpg)
Memory freed twice
Solution:
nGetterText was deleted previosuly.Only delete mGetterText once
![Page 15: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/15.jpg)
Array out of bounds
Solution:
Insert additonal condition to check if I is less than 32 before exuction of the statement
![Page 16: Static Code Analysis - UMSL Blogs · 2016-01-13 · Cppcheck Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors](https://reader030.vdocument.in/reader030/viewer/2022040818/5e63085a7f44704e4b75ddcf/html5/thumbnails/16.jpg)
Questions?