SlideShare a Scribd company logo
1© 2017 Rogue Wave Software, Inc. All Rights Reserved. 1
Confronting the mission-
critical software testing
challenge
Episode 2:
Static analysis works for mission-
critical systems, why not yours?
Walter Capitani
Product manager, Klocwork
2© 2017 Rogue Wave Software, Inc. All Rights Reserved. 2
Presenter
Walter Capitani
Product manager, Klocwork
Rogue Wave Software
walter.capitani@roguewave.com
Twitter: @walter_capitani
3© 2017 Rogue Wave Software, Inc. All Rights Reserved. 3
1. How do you select a static code analysis
tool?
2. What kind of defects/issues are you looking
for?
3. How/when/where should you deploy static
code analysis?
4. Common myths and barriers to adoption
5. Q&A
Agenda
4© 2017 Rogue Wave Software, Inc. All Rights Reserved. 4
Poll #1
What is the primary method you use to test code?
• Code reviews
• Unit tests
• Manual tests at build time
• Automated tests at build time
• Automated testing using CI tools
5© 2017 Rogue Wave Software, Inc. All Rights Reserved. 5
How do you select a static
code analysis tool?
6© 2017 Rogue Wave Software, Inc. All Rights Reserved. 6
Decision metrics for static code
analysis
• What kind of defects are you looking for?
Security
issues
Memory
leaks
Application
crashes
Other
defects
Improve
quality
Enforce
compliance
Improve
security
Other
• What are you trying to accomplish?
7© 2017 Rogue Wave Software, Inc. All Rights Reserved. 7
What kind of defects/issues
are you looking for?
8© 2017 Rogue Wave Software, Inc. All Rights Reserved. 8
• Find common issues in code
• Not easy to spot with the human eye
– Not generally found by code review
– Many are traditionally found with dynamic testing after a failure has
occurred in testing or the field
What kind of defects are we looking
for?
Buffer overflows
Security exploit
or program
crashes
Null pointer
dereferences
Your program
crashes
Memory leaks
Processor runs
out of memory
and locks up
Uninitialized data
usage
Data injection
Platform/OS
specifics
Privilege
escalation, etc.
Concurrency
Deadlock
Suspicious
coding practices
Variable
assignments,
function calls
9© 2017 Rogue Wave Software, Inc. All Rights Reserved. 9
What is static code analysis?
Performs one or
more processes
Syntax Analysis
Data Flow Analysis
Symbolic Logic
Analysis
Requires
source code
The most accurate
tools must be able to
compile the code
No changes to your
existing build flow
Different types
of analysis
Intra-procedural
(simplest analysis)
Inter-procedural
Inter-file
10© 2017 Rogue Wave Software, Inc. All Rights Reserved. 10
Syntax Analysis
• Creates a lossless transformation of the source code
• Generates the ‘Abstract Syntax Tree’
• Can be used to find Coding Style Issues and Simple Defects
– Simple security defects (e.g. use of banned encryption API)
– Simple coding style issues (e.g. no dynamic memory allocation)
This function
allocates
memory
Name = “malloc”,
Source Code Abstract Syntax Tree
11© 2017 Rogue Wave Software, Inc. All Rights Reserved. 11
Syntax Analysis -example
if(i = j) j++;
if(i == j) j++;
Defect: Assignment
operator used in
conditional statement
Assignment operator
replaced with intended
comparison operator
Vulnerable Code
Fixed Code
12© 2017 Rogue Wave Software, Inc. All Rights Reserved. 12
This seems to work well, but…
• These defects are contained in a single program
statement
• They are not dependent on values from external
functions
• Syntax Analysis can only find a limited set of defects
To find more interesting defects
you need to perform
more sophisticated analysis
13© 2017 Rogue Wave Software, Inc. All Rights Reserved. 13
Data Flow Analysis
• Monitoring of the lifecycle
of data objects:
– Creation
– Assignment
– Usage
– Deletion
• Must be monitored across all
paths in the Control Flow Graph
– Function calls
– Compilation units
• Can find program crashes across functions and files
14© 2017 Rogue Wave Software, Inc. All Rights Reserved. 14
Data Flow Analysis - example
• This function a()will cause the program to crash at line 3
• This function g() will cause the program to crash if position is outside
the valid range – how do we know if this will happen?
1 void a(){
2 int buffer[32]; // valid range of 0..31
1 buffer[35] = 5; // buffer access outside valid range (35)
4 return;
5 }
1 void g(int position, int value){
2 int buffer[32]; // valid range of 0..31
3 buffer[position] = value;
4 return;
5 }
3 buffer[35] = 5; // buffer access outside valid range (35)
Defect: Array bounds
violation
15© 2017 Rogue Wave Software, Inc. All Rights Reserved. 15
Data Flow Analysis - example
• Data Flow Analysis tracks what potential values are actually used when
function f() calls function g()
1 void g(int position, int value){
2 int buffer[32]; // valid range of 0..31
3 buffer[position] = value;
4 return;
5 }
1 void f(){
2 g(10,55); // calls function g with position=10, value=55
3 return;
4 }
No defect: values within
valid range
Vulnerable Code
16© 2017 Rogue Wave Software, Inc. All Rights Reserved. 16
1 void h(){
2 g(35,25); // calls function g with position=35, value=25
3 return;
1 }
Data Flow Analysis - example
• Data Flow Analysis tracks what potential values are actually used when
function h() calls function g()
1 void g(int position, int value){
2 int buffer[32]; // valid range of 0..31
1 buffer[position] = value;
4 return;
5 }
3 buffer[position] = value; // buffer access outside valid range (35)
Defect: Array bounds
violation (program crash)
Vulnerable Code
2 g(35,25); // calls function g with position=35, value=25
17© 2017 Rogue Wave Software, Inc. All Rights Reserved. 17
1 void h(){
2 g(35,25); // calls function g with position=35, value=25
3 return;
1 }
Data Flow Analysis - example
• Data Flow Analysis tracks what potential values are actually used when
function h() calls function g()
1 void g(int position, int value){
2 int buffer[32]; // valid range of 0..31
3 if (position < 0 || position >31 0) // Check position is valid
4 return;
5 buffer[position] = value;
6 return;
7 }
No defect
Fixed Code
2 g(35,25); // calls function g with position=35, value=25
3 if (position < 0 || position > 31) // Check position is valid
4 return;
18© 2017 Rogue Wave Software, Inc. All Rights Reserved. 18
This also seems to work well, but…
• Data Flow Analysis alone can only understand actual
numeric values (or ranges of values)
• What if there are no numeric values at all? How do we
determine valid data flow paths?
To find more interesting defects
you need to augment data flow analysis
with Symbolic Logic
19© 2017 Rogue Wave Software, Inc. All Rights Reserved. 19
Symbolic Logic
• Define functional behavior between symbols
• Don’t necessarily know what the values will be at runtime
• Used to infer software behavior
1 void f(int i, int j){
2 int buffer[32]; // valid range of 0..31
3 i = j;
4
5 /* set the value of k */
6 if (i == j)
7 k = get_tainted_data(); // Since i equals j, k is tainted
8 else
9 k = 0;
10
11 /* read the value of k */
12 if (i != j) // Since i = j, k will not be used
13 buffer[k] = 0;
14 return;
15 }
3 i = j;
7 k = get_tainted_data(); // Since i equals j, k is tainted
12 if (i != j) // Since i == j, k will not be used
20© 2017 Rogue Wave Software, Inc. All Rights Reserved. 20
Symbolic Logic
• Symbolic logic determines that since i = j, there is no use of tainted
data at line 13
• Otherwise a tool must “guess” at the defect
1 void f(int i, int j){
2 int buffer[32]; // valid range of 0..31
3 i = j;
4
5 /* set the value of k */
6 if (i == j)
7 k = get_tainted_data(); // Since i equals j, k is tainted
8 else
9 k = 0;
10
11 /* read the value of k */
12 if (i != j) // Since i = j, k will not be used
13 buffer[k] = 0;
14 return;
15 }
3 i = j;
7 k = get_tainted_data(); // Since i equals j, k is tainted
12 if (i != j) // Since i == j, k will not be used
21© 2017 Rogue Wave Software, Inc. All Rights Reserved. 21
Symbolic Logic
• If we change line 12, then a defect appears!
1 void f(int i, int j){
2 int buffer[32]; // valid range of 0..31
3 i = j;
4
5 /* set the value of k */
6 if (i == j)
7 k = get_tainted_data(); // Since i equals j, k is tainted
8 else
9 k = 0;
10
11 /* read the value of k */
12 if (i != j) // Since i = j, k will not be used
13 buffer[k] = 0;
14 return;
15 }
12 if (i == j) // Since i == j, k will be used
Defect: Unvalidated input in
array index (program crash)
Vulnerable Code
22© 2017 Rogue Wave Software, Inc. All Rights Reserved. 22
How/when/where should you
deploy static code analysis?
23© 2017 Rogue Wave Software, Inc. All Rights Reserved. 23
What are we trying to accomplish?
• This will guide what kind of implementations our static code analysis tools
should support
Improve
quality
Enforce
compliance
Improve
security
24© 2017 Rogue Wave Software, Inc. All Rights Reserved. 24
Frequency of analysis
Once per release
Every check-in
Continuous integration
Nightly/Weekly
Developer desktop
Can be used to ensure that no
issues are introduced with any
check-in
Good for security compliance,
minimizes backlog of work to
do in release phase
Detect issues as they are typed
Most efficient method to save
developers’ time
Typically used for compliance
purposes, limited value to
improving code
25© 2017 Rogue Wave Software, Inc. All Rights Reserved. 25
Development Cycle
Edit Save Compile Test Check In Build
Analyze
& Fix
• Late stage “rework” reduces tool adoption
• Timelines compromised
• Issues are more expensive to fix
Traditional analysis done after compile/build
26© 2017 Rogue Wave Software, Inc. All Rights Reserved. 26
 Eliminates new defects from being checked back into the team level build
 No extra work for developers
 In-context checking and fixes
 Continuity of development flow
Edit Save
Analyze
& Fix
Compile Test Check In Build
Development Cycle
Best practice: Analysis earlier in the cycle
27© 2017 Rogue Wave Software, Inc. All Rights Reserved. 27
 Improves coding practices
 Alerts the developer immediately when they enter a defect
 Provides entire path from “source to sink” of how the issue occurs
 Provide help on how to remedy
 Provides links to the specific coding standards that may be violated
 Allows you to edit and customize that advice with simple HTML editing.
 The key is that not only do we help the developer, by telling them immediately it
is an excellent “teachable moment.”
 Finally, since the developer makes the fix immediately, your code base is never
impacted.
Edit Save
Analyze
& Fix
Compile Test Check In Build
Development Cycle
Desktop analysis advantages
28© 2017 Rogue Wave Software, Inc. All Rights Reserved. 28
Common myths and barriers to
adoption
29© 2017 Rogue Wave Software, Inc. All Rights Reserved. 29
Poll #2
What are the barriers to adoption in your
organization?
• Cost of the SCA tool
• Lack of perceived value to developers
• To complex to integrate
• Too many false positives
• No barrier – we use an SCA tool already
30© 2017 Rogue Wave Software, Inc. All Rights Reserved. 30
#1: The truth about false positives
• All automated safety systems have false positives
– That what static code analysis is:
an automated safety system for your software developers
• Safety systems in automobiles:
– Blind Spot Detection systems
– Back up sensors
• All of these systems will generate erroneous warnings sometimes
• As long as the Signal-to-Noise ratio is reasonable, and we can tune the
system to generate the results we are looking for, these systems add value
31© 2017 Rogue Wave Software, Inc. All Rights Reserved. 31
Common sources of false positives
• Enabling the wrong defect checkers
• “Developer false positives”
• Third party libraries
32© 2017 Rogue Wave Software, Inc. All Rights Reserved. 32
How to manage false positives
• Refer to our decision criteria
– Look at defects that serve your purpose:
• Improve Security  Enable security defects
• Improve Quality  Enable memory leak defects
• Prioritize what defects specific developers should look at:
– Advanced static code analysis tools provide different ways for
developers to view defects
• Tune the static code analysis tool to reduce or eliminate defects from third
party libraries
33© 2017 Rogue Wave Software, Inc. All Rights Reserved. 33
#2: Static code analysis is for junior
developers
• If that were true, it would mean software written by senior
developers would be bug-free
• Sophisticated tools with data flow analysis find issues that
may even get past senior developers, particularly in large
complex code bases (what about 3rd party and legacy code)
• Static code analysis tools evolve over time to find new
security defects – even senior developers will need training
to spot these new threats…
34© 2017 Rogue Wave Software, Inc. All Rights Reserved. 34
#3: Should test and QA find bugs?
• 80% of defects are introduced in development
• Each defect found in test costs 50x to fix
• Test and QA can spend more time trying to make the
product better, rather than reporting issues that could
have been found at the development stage
35© 2017 Rogue Wave Software, Inc. All Rights Reserved. 35
Summary
36© 2017 Rogue Wave Software, Inc. All Rights Reserved. 36
Summary
• Select a tool that supports the corresponding depth
of analysis
Decide what kind of defects you need to find
• Select a tool that supports the appropriate workflow
Decide what you are trying to accomplish
Proper configuration and tuning of the SCA tool helps with
developer adoption
1
2
3
37© 2017 Rogue Wave Software, Inc. All Rights Reserved. 37
Q&A
38© 2017 Rogue Wave Software, Inc. All Rights Reserved. 38
Follow up
Free e-book:
Building better code with static code
analysis
www.roguewave.com/programs/building-better-code-with-sca
Learn more about Klocwork static code analysis:
Kate Andreeva
Inside Sales Account Executive
kate.andreeva@roguewave.com
39© 2017 Rogue Wave Software, Inc. All Rights Reserved. 39
Stay tuned
Confronting the mission-critical software testing
challenge
Feb. 22: What if you could eliminate the hidden costs of development?
Combat different types of development inefficiency by examining error-prone tasks, waiting for
resources, “bug fix crowdsourcing,” and more to learn what the industry is doing about them and
what you can do to get ahead.
Available on-demand www.roguewave.com/sca
Episode 1: How to achieve security, reliability, and productivity in less time
Episode 2: Static analysis works for mission-critical systems, why not yours? (Soon!)
40© 2017 Rogue Wave Software, Inc. All Rights Reserved. 40

More Related Content

PPTX
STAR: Stack Trace based Automatic Crash Reproduction
PPT
Crowd debugging (FSE 2015)
PPTX
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
PPTX
CrashLocator: Locating Crashing Faults Based on Crash Stacks (ISSTA 2014)
PPTX
Symbexecsearch
PPTX
Software Defect Prediction on Unlabeled Datasets
PPTX
Mobilesoft 2017 Keynote
PDF
Personalized Defect Prediction
STAR: Stack Trace based Automatic Crash Reproduction
Crowd debugging (FSE 2015)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
CrashLocator: Locating Crashing Faults Based on Crash Stacks (ISSTA 2014)
Symbexecsearch
Software Defect Prediction on Unlabeled Datasets
Mobilesoft 2017 Keynote
Personalized Defect Prediction

What's hot (20)

PPTX
LSRepair: Live Search of Fix Ingredients for Automated Program Repair
PDF
Partitioning Composite Code Changes to Facilitate Code Review (MSR2015)
PDF
Formal verification
PPTX
Automated Program Repair Keynote talk
PPTX
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
PDF
Mining Fix Patterns for FindBugs Violations
PPTX
Bug prediction + sdlc automation
PPT
Dissertation Defense
PPTX
A Closer Look at Real-World Patches
PDF
The Road Not Taken: Estimating Path Execution Frequency Statically
PPTX
TBar: Revisiting Template-based Automated Program Repair
PPTX
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
PDF
A Survey on Automatic Software Evolution Techniques
PPTX
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
PPTX
Deep API Learning (FSE 2016)
PDF
Static Slicing Technique with Algorithmic Approach
PPTX
Testing, fixing, and proving with contracts
PDF
Software testing lab manual
PDF
Formal Verification
PDF
Algorithmic problem solving
LSRepair: Live Search of Fix Ingredients for Automated Program Repair
Partitioning Composite Code Changes to Facilitate Code Review (MSR2015)
Formal verification
Automated Program Repair Keynote talk
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
Mining Fix Patterns for FindBugs Violations
Bug prediction + sdlc automation
Dissertation Defense
A Closer Look at Real-World Patches
The Road Not Taken: Estimating Path Execution Frequency Statically
TBar: Revisiting Template-based Automated Program Repair
You Cannot Fix What You Cannot Find! --- An Investigation of Fault Localizati...
A Survey on Automatic Software Evolution Techniques
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
Deep API Learning (FSE 2016)
Static Slicing Technique with Algorithmic Approach
Testing, fixing, and proving with contracts
Software testing lab manual
Formal Verification
Algorithmic problem solving
Ad

Viewers also liked (12)

PDF
ICST2015勉強会 Static Analysis トラック論文紹介
PPTX
Find & fix the flaws in your code
PPT
Jabox presentation
PDF
Software audit strategies: how often is enough?
PPTX
Managing Open Source in Application Security and Software Development Lifecycle
PDF
DevOps Best Practices: Managing and Scaling Release Automation Using Visual a...
PPTX
Guide to Open Source Compliance
PDF
Monitoring CDN Performance
PPTX
NGINX Microservices Reference Architecture: Ask Me Anything
PPTX
What if you could eliminate the hidden costs of development?
PDF
CircleCI and XebiaLabs: A Winning Combination for Seamless, Scalable Continuo...
PPTX
Docker Online Meetup: Announcing Docker CE + EE
ICST2015勉強会 Static Analysis トラック論文紹介
Find & fix the flaws in your code
Jabox presentation
Software audit strategies: how often is enough?
Managing Open Source in Application Security and Software Development Lifecycle
DevOps Best Practices: Managing and Scaling Release Automation Using Visual a...
Guide to Open Source Compliance
Monitoring CDN Performance
NGINX Microservices Reference Architecture: Ask Me Anything
What if you could eliminate the hidden costs of development?
CircleCI and XebiaLabs: A Winning Combination for Seamless, Scalable Continuo...
Docker Online Meetup: Announcing Docker CE + EE
Ad

Similar to Static analysis works for mission-critical systems, why not yours? (20)

PPTX
No liftoff, touchdown, or heartbeat shall miss because of a software failure
PPTX
Cyber security - It starts with the embedded system
PPTX
Programming languages and techniques for today’s embedded andIoT world
PDF
Secure Programming With Static Analysis
PDF
Technologies used in the PVS-Studio code analyzer for finding bugs and potent...
PPTX
Rapid software testing and conformance with static code analysis
PDF
Videos about static code analysis
PPTX
SAST and Application Security: how to fight vulnerabilities in the code
PPTX
Static code analyzers as a DevSecOps solution
PPTX
How Data Flow analysis works in a static code analyzer
PPTX
Static-Analysis-in-Industry.pptx
PPTX
Static Analysis Primer
PDF
Top 5 best practice for delivering secure in-vehicle software
PDF
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PPT
Chapter 8 - Software Testing.ppt
PPT
Dependable Software Development in Software Engineering SE18
PPT
4.Security Assessment And Testing
PDF
Crash Analysis with Reverse Taint
PPTX
Static Code Analysis
PDF
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
No liftoff, touchdown, or heartbeat shall miss because of a software failure
Cyber security - It starts with the embedded system
Programming languages and techniques for today’s embedded andIoT world
Secure Programming With Static Analysis
Technologies used in the PVS-Studio code analyzer for finding bugs and potent...
Rapid software testing and conformance with static code analysis
Videos about static code analysis
SAST and Application Security: how to fight vulnerabilities in the code
Static code analyzers as a DevSecOps solution
How Data Flow analysis works in a static code analyzer
Static-Analysis-in-Industry.pptx
Static Analysis Primer
Top 5 best practice for delivering secure in-vehicle software
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
Chapter 8 - Software Testing.ppt
Dependable Software Development in Software Engineering SE18
4.Security Assessment And Testing
Crash Analysis with Reverse Taint
Static Code Analysis
Static Analysis Techniques For Testing Application Security - Houston Tech Fest

More from Rogue Wave Software (20)

PPTX
The Global Influence of Open Banking, API Security, and an Open Data Perspective
PDF
Disrupt or be disrupted – Using secure APIs to drive digital transformation
PPTX
Leveraging open banking specifications for rigorous API security – What’s in...
PPTX
Adding layers of security to an API in real-time
PPTX
Getting the most from your API management platform: A case study
PPTX
Advanced technologies and techniques for debugging HPC applications
PPTX
The forgotten route: Making Apache Camel work for you
PPTX
Are open source and embedded software development on a collision course?
PDF
Three big mistakes with APIs and microservices
PPTX
5 strategies for enterprise cloud infrastructure success
PPTX
PSD2 & Open Banking: How to go from standards to implementation and compliance
PPTX
Java 10 and beyond: Keeping up with the language and planning for the future
PPTX
How to keep developers happy and lawyers calm (Presented at ESC Boston)
PPTX
Open source applied - Real world use cases (Presented at Open Source 101)
PPTX
How to migrate SourcePro apps from Solaris to Linux
PPTX
Approaches to debugging mixed-language HPC apps
PPTX
Enterprise Linux: Justify your migration from Red Hat to CentOS
PPTX
Walk through an enterprise Linux migration
PPTX
How to keep developers happy and lawyers calm
PPTX
Open source and embedded software development
The Global Influence of Open Banking, API Security, and an Open Data Perspective
Disrupt or be disrupted – Using secure APIs to drive digital transformation
Leveraging open banking specifications for rigorous API security – What’s in...
Adding layers of security to an API in real-time
Getting the most from your API management platform: A case study
Advanced technologies and techniques for debugging HPC applications
The forgotten route: Making Apache Camel work for you
Are open source and embedded software development on a collision course?
Three big mistakes with APIs and microservices
5 strategies for enterprise cloud infrastructure success
PSD2 & Open Banking: How to go from standards to implementation and compliance
Java 10 and beyond: Keeping up with the language and planning for the future
How to keep developers happy and lawyers calm (Presented at ESC Boston)
Open source applied - Real world use cases (Presented at Open Source 101)
How to migrate SourcePro apps from Solaris to Linux
Approaches to debugging mixed-language HPC apps
Enterprise Linux: Justify your migration from Red Hat to CentOS
Walk through an enterprise Linux migration
How to keep developers happy and lawyers calm
Open source and embedded software development

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Essential Infomation Tech presentation.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Digital Strategies for Manufacturing Companies
PPTX
Introduction to Artificial Intelligence
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
System and Network Administration Chapter 2
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Wondershare Filmora 15 Crack With Activation Key [2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
ai tools demonstartion for schools and inter college
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo Companies in India – Driving Business Transformation.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
wealthsignaloriginal-com-DS-text-... (1).pdf
Essential Infomation Tech presentation.pptx
Understanding Forklifts - TECH EHS Solution
Digital Strategies for Manufacturing Companies
Introduction to Artificial Intelligence
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

Static analysis works for mission-critical systems, why not yours?

  • 1. 1© 2017 Rogue Wave Software, Inc. All Rights Reserved. 1 Confronting the mission- critical software testing challenge Episode 2: Static analysis works for mission- critical systems, why not yours? Walter Capitani Product manager, Klocwork
  • 2. 2© 2017 Rogue Wave Software, Inc. All Rights Reserved. 2 Presenter Walter Capitani Product manager, Klocwork Rogue Wave Software walter.capitani@roguewave.com Twitter: @walter_capitani
  • 3. 3© 2017 Rogue Wave Software, Inc. All Rights Reserved. 3 1. How do you select a static code analysis tool? 2. What kind of defects/issues are you looking for? 3. How/when/where should you deploy static code analysis? 4. Common myths and barriers to adoption 5. Q&A Agenda
  • 4. 4© 2017 Rogue Wave Software, Inc. All Rights Reserved. 4 Poll #1 What is the primary method you use to test code? • Code reviews • Unit tests • Manual tests at build time • Automated tests at build time • Automated testing using CI tools
  • 5. 5© 2017 Rogue Wave Software, Inc. All Rights Reserved. 5 How do you select a static code analysis tool?
  • 6. 6© 2017 Rogue Wave Software, Inc. All Rights Reserved. 6 Decision metrics for static code analysis • What kind of defects are you looking for? Security issues Memory leaks Application crashes Other defects Improve quality Enforce compliance Improve security Other • What are you trying to accomplish?
  • 7. 7© 2017 Rogue Wave Software, Inc. All Rights Reserved. 7 What kind of defects/issues are you looking for?
  • 8. 8© 2017 Rogue Wave Software, Inc. All Rights Reserved. 8 • Find common issues in code • Not easy to spot with the human eye – Not generally found by code review – Many are traditionally found with dynamic testing after a failure has occurred in testing or the field What kind of defects are we looking for? Buffer overflows Security exploit or program crashes Null pointer dereferences Your program crashes Memory leaks Processor runs out of memory and locks up Uninitialized data usage Data injection Platform/OS specifics Privilege escalation, etc. Concurrency Deadlock Suspicious coding practices Variable assignments, function calls
  • 9. 9© 2017 Rogue Wave Software, Inc. All Rights Reserved. 9 What is static code analysis? Performs one or more processes Syntax Analysis Data Flow Analysis Symbolic Logic Analysis Requires source code The most accurate tools must be able to compile the code No changes to your existing build flow Different types of analysis Intra-procedural (simplest analysis) Inter-procedural Inter-file
  • 10. 10© 2017 Rogue Wave Software, Inc. All Rights Reserved. 10 Syntax Analysis • Creates a lossless transformation of the source code • Generates the ‘Abstract Syntax Tree’ • Can be used to find Coding Style Issues and Simple Defects – Simple security defects (e.g. use of banned encryption API) – Simple coding style issues (e.g. no dynamic memory allocation) This function allocates memory Name = “malloc”, Source Code Abstract Syntax Tree
  • 11. 11© 2017 Rogue Wave Software, Inc. All Rights Reserved. 11 Syntax Analysis -example if(i = j) j++; if(i == j) j++; Defect: Assignment operator used in conditional statement Assignment operator replaced with intended comparison operator Vulnerable Code Fixed Code
  • 12. 12© 2017 Rogue Wave Software, Inc. All Rights Reserved. 12 This seems to work well, but… • These defects are contained in a single program statement • They are not dependent on values from external functions • Syntax Analysis can only find a limited set of defects To find more interesting defects you need to perform more sophisticated analysis
  • 13. 13© 2017 Rogue Wave Software, Inc. All Rights Reserved. 13 Data Flow Analysis • Monitoring of the lifecycle of data objects: – Creation – Assignment – Usage – Deletion • Must be monitored across all paths in the Control Flow Graph – Function calls – Compilation units • Can find program crashes across functions and files
  • 14. 14© 2017 Rogue Wave Software, Inc. All Rights Reserved. 14 Data Flow Analysis - example • This function a()will cause the program to crash at line 3 • This function g() will cause the program to crash if position is outside the valid range – how do we know if this will happen? 1 void a(){ 2 int buffer[32]; // valid range of 0..31 1 buffer[35] = 5; // buffer access outside valid range (35) 4 return; 5 } 1 void g(int position, int value){ 2 int buffer[32]; // valid range of 0..31 3 buffer[position] = value; 4 return; 5 } 3 buffer[35] = 5; // buffer access outside valid range (35) Defect: Array bounds violation
  • 15. 15© 2017 Rogue Wave Software, Inc. All Rights Reserved. 15 Data Flow Analysis - example • Data Flow Analysis tracks what potential values are actually used when function f() calls function g() 1 void g(int position, int value){ 2 int buffer[32]; // valid range of 0..31 3 buffer[position] = value; 4 return; 5 } 1 void f(){ 2 g(10,55); // calls function g with position=10, value=55 3 return; 4 } No defect: values within valid range Vulnerable Code
  • 16. 16© 2017 Rogue Wave Software, Inc. All Rights Reserved. 16 1 void h(){ 2 g(35,25); // calls function g with position=35, value=25 3 return; 1 } Data Flow Analysis - example • Data Flow Analysis tracks what potential values are actually used when function h() calls function g() 1 void g(int position, int value){ 2 int buffer[32]; // valid range of 0..31 1 buffer[position] = value; 4 return; 5 } 3 buffer[position] = value; // buffer access outside valid range (35) Defect: Array bounds violation (program crash) Vulnerable Code 2 g(35,25); // calls function g with position=35, value=25
  • 17. 17© 2017 Rogue Wave Software, Inc. All Rights Reserved. 17 1 void h(){ 2 g(35,25); // calls function g with position=35, value=25 3 return; 1 } Data Flow Analysis - example • Data Flow Analysis tracks what potential values are actually used when function h() calls function g() 1 void g(int position, int value){ 2 int buffer[32]; // valid range of 0..31 3 if (position < 0 || position >31 0) // Check position is valid 4 return; 5 buffer[position] = value; 6 return; 7 } No defect Fixed Code 2 g(35,25); // calls function g with position=35, value=25 3 if (position < 0 || position > 31) // Check position is valid 4 return;
  • 18. 18© 2017 Rogue Wave Software, Inc. All Rights Reserved. 18 This also seems to work well, but… • Data Flow Analysis alone can only understand actual numeric values (or ranges of values) • What if there are no numeric values at all? How do we determine valid data flow paths? To find more interesting defects you need to augment data flow analysis with Symbolic Logic
  • 19. 19© 2017 Rogue Wave Software, Inc. All Rights Reserved. 19 Symbolic Logic • Define functional behavior between symbols • Don’t necessarily know what the values will be at runtime • Used to infer software behavior 1 void f(int i, int j){ 2 int buffer[32]; // valid range of 0..31 3 i = j; 4 5 /* set the value of k */ 6 if (i == j) 7 k = get_tainted_data(); // Since i equals j, k is tainted 8 else 9 k = 0; 10 11 /* read the value of k */ 12 if (i != j) // Since i = j, k will not be used 13 buffer[k] = 0; 14 return; 15 } 3 i = j; 7 k = get_tainted_data(); // Since i equals j, k is tainted 12 if (i != j) // Since i == j, k will not be used
  • 20. 20© 2017 Rogue Wave Software, Inc. All Rights Reserved. 20 Symbolic Logic • Symbolic logic determines that since i = j, there is no use of tainted data at line 13 • Otherwise a tool must “guess” at the defect 1 void f(int i, int j){ 2 int buffer[32]; // valid range of 0..31 3 i = j; 4 5 /* set the value of k */ 6 if (i == j) 7 k = get_tainted_data(); // Since i equals j, k is tainted 8 else 9 k = 0; 10 11 /* read the value of k */ 12 if (i != j) // Since i = j, k will not be used 13 buffer[k] = 0; 14 return; 15 } 3 i = j; 7 k = get_tainted_data(); // Since i equals j, k is tainted 12 if (i != j) // Since i == j, k will not be used
  • 21. 21© 2017 Rogue Wave Software, Inc. All Rights Reserved. 21 Symbolic Logic • If we change line 12, then a defect appears! 1 void f(int i, int j){ 2 int buffer[32]; // valid range of 0..31 3 i = j; 4 5 /* set the value of k */ 6 if (i == j) 7 k = get_tainted_data(); // Since i equals j, k is tainted 8 else 9 k = 0; 10 11 /* read the value of k */ 12 if (i != j) // Since i = j, k will not be used 13 buffer[k] = 0; 14 return; 15 } 12 if (i == j) // Since i == j, k will be used Defect: Unvalidated input in array index (program crash) Vulnerable Code
  • 22. 22© 2017 Rogue Wave Software, Inc. All Rights Reserved. 22 How/when/where should you deploy static code analysis?
  • 23. 23© 2017 Rogue Wave Software, Inc. All Rights Reserved. 23 What are we trying to accomplish? • This will guide what kind of implementations our static code analysis tools should support Improve quality Enforce compliance Improve security
  • 24. 24© 2017 Rogue Wave Software, Inc. All Rights Reserved. 24 Frequency of analysis Once per release Every check-in Continuous integration Nightly/Weekly Developer desktop Can be used to ensure that no issues are introduced with any check-in Good for security compliance, minimizes backlog of work to do in release phase Detect issues as they are typed Most efficient method to save developers’ time Typically used for compliance purposes, limited value to improving code
  • 25. 25© 2017 Rogue Wave Software, Inc. All Rights Reserved. 25 Development Cycle Edit Save Compile Test Check In Build Analyze & Fix • Late stage “rework” reduces tool adoption • Timelines compromised • Issues are more expensive to fix Traditional analysis done after compile/build
  • 26. 26© 2017 Rogue Wave Software, Inc. All Rights Reserved. 26  Eliminates new defects from being checked back into the team level build  No extra work for developers  In-context checking and fixes  Continuity of development flow Edit Save Analyze & Fix Compile Test Check In Build Development Cycle Best practice: Analysis earlier in the cycle
  • 27. 27© 2017 Rogue Wave Software, Inc. All Rights Reserved. 27  Improves coding practices  Alerts the developer immediately when they enter a defect  Provides entire path from “source to sink” of how the issue occurs  Provide help on how to remedy  Provides links to the specific coding standards that may be violated  Allows you to edit and customize that advice with simple HTML editing.  The key is that not only do we help the developer, by telling them immediately it is an excellent “teachable moment.”  Finally, since the developer makes the fix immediately, your code base is never impacted. Edit Save Analyze & Fix Compile Test Check In Build Development Cycle Desktop analysis advantages
  • 28. 28© 2017 Rogue Wave Software, Inc. All Rights Reserved. 28 Common myths and barriers to adoption
  • 29. 29© 2017 Rogue Wave Software, Inc. All Rights Reserved. 29 Poll #2 What are the barriers to adoption in your organization? • Cost of the SCA tool • Lack of perceived value to developers • To complex to integrate • Too many false positives • No barrier – we use an SCA tool already
  • 30. 30© 2017 Rogue Wave Software, Inc. All Rights Reserved. 30 #1: The truth about false positives • All automated safety systems have false positives – That what static code analysis is: an automated safety system for your software developers • Safety systems in automobiles: – Blind Spot Detection systems – Back up sensors • All of these systems will generate erroneous warnings sometimes • As long as the Signal-to-Noise ratio is reasonable, and we can tune the system to generate the results we are looking for, these systems add value
  • 31. 31© 2017 Rogue Wave Software, Inc. All Rights Reserved. 31 Common sources of false positives • Enabling the wrong defect checkers • “Developer false positives” • Third party libraries
  • 32. 32© 2017 Rogue Wave Software, Inc. All Rights Reserved. 32 How to manage false positives • Refer to our decision criteria – Look at defects that serve your purpose: • Improve Security  Enable security defects • Improve Quality  Enable memory leak defects • Prioritize what defects specific developers should look at: – Advanced static code analysis tools provide different ways for developers to view defects • Tune the static code analysis tool to reduce or eliminate defects from third party libraries
  • 33. 33© 2017 Rogue Wave Software, Inc. All Rights Reserved. 33 #2: Static code analysis is for junior developers • If that were true, it would mean software written by senior developers would be bug-free • Sophisticated tools with data flow analysis find issues that may even get past senior developers, particularly in large complex code bases (what about 3rd party and legacy code) • Static code analysis tools evolve over time to find new security defects – even senior developers will need training to spot these new threats…
  • 34. 34© 2017 Rogue Wave Software, Inc. All Rights Reserved. 34 #3: Should test and QA find bugs? • 80% of defects are introduced in development • Each defect found in test costs 50x to fix • Test and QA can spend more time trying to make the product better, rather than reporting issues that could have been found at the development stage
  • 35. 35© 2017 Rogue Wave Software, Inc. All Rights Reserved. 35 Summary
  • 36. 36© 2017 Rogue Wave Software, Inc. All Rights Reserved. 36 Summary • Select a tool that supports the corresponding depth of analysis Decide what kind of defects you need to find • Select a tool that supports the appropriate workflow Decide what you are trying to accomplish Proper configuration and tuning of the SCA tool helps with developer adoption 1 2 3
  • 37. 37© 2017 Rogue Wave Software, Inc. All Rights Reserved. 37 Q&A
  • 38. 38© 2017 Rogue Wave Software, Inc. All Rights Reserved. 38 Follow up Free e-book: Building better code with static code analysis www.roguewave.com/programs/building-better-code-with-sca Learn more about Klocwork static code analysis: Kate Andreeva Inside Sales Account Executive kate.andreeva@roguewave.com
  • 39. 39© 2017 Rogue Wave Software, Inc. All Rights Reserved. 39 Stay tuned Confronting the mission-critical software testing challenge Feb. 22: What if you could eliminate the hidden costs of development? Combat different types of development inefficiency by examining error-prone tasks, waiting for resources, “bug fix crowdsourcing,” and more to learn what the industry is doing about them and what you can do to get ahead. Available on-demand www.roguewave.com/sca Episode 1: How to achieve security, reliability, and productivity in less time Episode 2: Static analysis works for mission-critical systems, why not yours? (Soon!)
  • 40. 40© 2017 Rogue Wave Software, Inc. All Rights Reserved. 40