מצגת חלקית של הרצאה בנושא מבוא לאנליזה סטטית של קוד.
Introduction to Static Code Analysis.
ניתן להזמין להרצאה מלאה (ללא עלות למוסדות אקדמאים) דרך אתר טריניטי
www.trinity.co.il 09-4677880
3. מי אני? ולמה אני פה?
• גיל קיני
• טריניטי תוכנה ומעבר
• מנהל פורום
Static Code Analysis in Israel
• אז מה יהיה לנו ...
– הגדרות
– שיטות
– פתרונות
5. כמה עולה לי ? BUG
"זמן אפס" – הנקודה הזולה
ביותר והיצירתית ביותר
בתהליך הפיתוח
6. Code Review
• תהליך של התבוננות בקוד על ידי בדיקה ויזואלית בלבד
וללא סיוע של כלים אוטומטיים, ידוע בשם המקובל סקר-
קוד-מקור )( Manual / Peer Code-Review
• לשם בקרת המימוש
• שיפור איכות הקוד
יעילות / ביצועים –
תיעוד –
תקינות מימוש לוגי –
)מקום אחרון( ניפוי שגיאות "טכניות" –
7. מה זו אנליזה סטטית?
שיטה של דיבוג תוכנת מחשב )ניפוי שגיאות( •
סריקה וניתוח אוטומטי של קוד המקור למציאת באגים •
ללא ביצוע או הרצת התוכנית •
יכול לעזור להבטיח שהקוד הינו איכותי, והמימוש הינו לפי •
תקני התעשייה
8. מה אנליזה סטטית יכולה לגלות?
דליפות זיכרון •
גלישות ממערכים •
גישה למצביעים לא מאותחלים •
גישה ל- NULL •
בעיות בחישוב מקבילי )נעילות( •
קוד מת •
שימוש לא זהיר בקלט חיצוני •
משתנים לא מאותחלים •
9. Accurate Bug Identification &
Vulnerability Analysis
Quality/Reliability Security Vulnerability Maintainability
Memory and resources leaks Buffer overflow Architectural violations
Using de-allocated memory Un-validated user input Header file structure
Incorrect memory de-allocation SQL injection Deadcode
Dereferencing NULL pointers Path injection Unreachable code
Usage of uninitialized data Cross-site scripting Calculated values that are never
Resource management Information leakage used
Concurrency violations Weak encryption Unused function parameters
Vulnerable coding practices Unused local variables
+ Software metrics generation and management
+ Risk management and mitigation
CONFIDENTIAL
10. חוזקות ויתרונות של ניתוח סטטי ...
• הטמעה מהירה יחסית בתהליך הפיתוח
• אפס מאמץ נדרש מהמפתחים למצוא באג
• מכסה מגוון רחב של באגים / כשלים / בעיות
• מוצא ומדווח על מיקום מדויק של הבאג
• מאפשר מחזור תיקון מהיר של באגים
• נועד לשימוש ע"י מפתחים למציאת באגים בשלבים
מוקדמים של הפיתוח
... •
11. ... חוזקות ויתרונות של ניתוח סטטי
• ...
• הכלים והתהליכים ניתנים לאוטומציה )בקלות( – קבלה
מהירה של תוצאות האנליזה
• סורק את כלל הקוד בפרויקט לקבלת "כיסוי" מלא
• מאפשר קבלת מידע נוסף/תומך להבנת הבעיה
) , (tracebackבכך מקטין את זמן ה-"מחקר"
• מאפשר מציאת באגים בשלבים מוקדמים בתהליך
הפיתוח, מקטין עיכובים ומוזיל עלות תיקון
12. חולשות וחסרונות של ניתוח סטטי ...
• הכלים אינם תומכים בכל השפות
• הכלים אינם מכסים את כל סוגי הבאגים
• לא מכסים סוגיות ומצבים הקשורים בסביבת המטרה
• ...
13. ... חולשות וחסרונות של ניתוח סטטי
• ...
• טעויות בדיווח מסוגי דיווחי-שקר )שאינם בעיות אמיתיות(
ודיווחי-חסר )פספוס בעיות אמיתיות(
– בחירה בכלים חזקים ) (High-Endתחסוך לכם זמן, מאמץ, וכסף
• עלול לספק תחושה שקרית של בטחון שכל הבעיות
מטופלות
14. סטטי מול דינמי
• Static Code Analysis
כיסוי של כל מסלולי התוכנה האפשריים •
מהיר – עד פי 2 מזמן קומפילציה •
טיפול במגוון רחב ביותר של בעיות •
תועלת עבור מחיר - הטובה ביותר •
• Dynamic Code Analysis
מכסה רק את המסלולים אשר עבורים יש test cases •
דורש סביבת הרצה מלאה •
משנה את התנהגות המערכת •
15. Overview – Software Lifecycle
Validation
System Acceptance
Requirements Test
Verification Phase
Architectural System Exit
Design Test Criteria
Verification Phase
Detailed Integration
Integration Exit
Design Test
Test Criteria
Phase
Verification
Component Unit
Unit Exit
Design Test
Test Criteria
Code
Static Code Analysis
Implementation Flow
Dynamic Testing
19. KLOCWORKאנליזה סטטית במאה ה- - 12
אנליזה של מיליוני שורות קוד •
בבת אחת,
תוך מעקב אחר לוגיקה בין
קבצים ומודולים שונים
שילוב מלא ב- IDEבעמדת •
המפתח
שילוב בתהליך ה- build •
המערכתי
אנליזת ארכיטקטורת התוכנה בפועל •
להבנת הקוד בו מטפלים
20. KLOCWORKאנליזה סטטית במאה ה- - 12
מעקב לאורך זמן על איכות •
התוכנה
כלי למנהלים לבקרה על התהליך •
יכולות אינטגרציה לכלי bug •
trackingו- SCMומערכות build
הכל נגיש מ- command line •
21. כלים לארכיטקטים
• הצגה גרפית ואינטואיטיבית של מבנה התוכנה בפועל
• יצירת מודולים ויחידות נקיות לשיפור reuseוחיי-מדף
ארוכים יותר
• הבנה ואופטימיזציה של headers
22. תובנה טובה יותר של התוכנה
• מעל 001 מטריקות – לפי חיתוכים שונים: פרוייקט, צוות,
אדם
• מעקב אחר תהליך הפיתוח, הערכת וניהול סיכונים, נקיטת
צעדים מבעוד מועד
• מעודכן אוטומטית בסיום
כל אנליזה
23. כלים למפתחים – שילוב ב- IDE
גם שילוב בסביבת הפיתוח וגם העוצמה והדיוק של •
אנליזה מערכתית
חיבור ישיר למפתח – בנוחות לסביבה הגרפית ובגמישות •
מירבית מ- command line
לראות את התמונה הגדולה – ישירות מעמדת המפתח, •
בדיוק המירבי, בביצועים הטובים ביותר, ובהקשר מערכתי
ניהול ושיתוף – טביעת אצבע של בעיה מאפשרת מעקב •
וקישור רובסטי של הערות וסטטוס
24. ללא אנליזה סטטית
Cost of Defects:
Cost of Defects:
Gartner – 50 to 1000X
Gartner – 50 to 1000X
IBM – 40 to 60 X
IBM – 40 to 60 X
HP – 30 X
HP – 30 X
# Coding
Defects
Found
25. אנליזה סטטית כיום
Source code
analysis today
Cost of Defects:
Cost of Defects:
• שילוב בתהליך הפיתוח Gartner – 50 to 1000X
Gartner – 50 to 1000X
IBM – 40 to 60 X
IBM – 40 to 60 X
CMMI principle is “in-phase” defect containment HP – 30 X
HP – 30 X
• הדור הראשון קידם את מציאת הבאגים
System Build לשלב
! check-in • הדור ההבא ימצא את הבאגים לפני
# Coding
Defects
Found
26. להכות בברזל כשהוא חם
• שילוב מלא בסביבת הפיתוח
• שיפור ללא החלפת הסביבה
• קוד ללא באגים החל מרמת המפתח
Cost of Defects:
Cost of Defects:
Gartner – 50 to 1000X
Gartner – 50 to 1000X
IBM – 40 to 60 X
IBM – 40 to 60 X
Klocwork Insight –
HP – 30 X
HP – 30 X
Don’t let bugs enter
the code stream
# Coding
Defects
Found
27. Connected Desktop Analysis
Developer SCA - Benefits System SCA - Benefits
Reported problems can be fixed right Required for good analysis accuracy due
away by the developer before it impacts to “whole system” visibility
anyone else Essential for management and build over
Enables “in-phase” defect containment build reporting on quality trends
Developer SCA – Limitations Systems SCA – Limitations
Accuracy problems if a developer runs Doesn’t enable “in-phase defect
only a few files without full system containment” – developers have to
context check-in broken code to find out its
Developers can’t communicate broken
changes/updates to defects they’re Developers still caught in a “rinse and
reviewing repeat” bug finding/fix/check-in cycle
28. ( Connected Desktop Analysis (cont’d
Klocwork developer desktop is automatically connected with system analysis
» Best performance, best accuracy, full system context delivered locally
» Creates peer-to-peer collaboration on bug resolution
Klocwork Insight is the only source code analysis solution to combine the
productivity benefits of desktop source code analysis with the power and
accuracy of system-wide analysis
33. Why Klocwork – What makes us unique
• Proven – over 1000 customers in some of the largest
most complex software development sites in the
world use Klocwork
• Developer Focused – Connected Desktop makes
source code analysis part of a developer’s tool set and
enable analysis before check-in
• Powerful – breadth of capability in one solution
includes Quality, Security, Architecture, and Metrics
analysis
Confidential
34. שאלות? טענות? מענות?
• איפה אפשר ללמוד עוד על הנושא?
• בכל מקום ...
תודה !
גיל קיני
Gil @ Trinity.co.il
- This slide provides additional details on Klocwork’s Architecture and Header File Anomalies
- This slide provides additional details on Klocwork’s Architecture and Header File Anomalies
Developers are the key to the creative process Tools to support developers must work for the developer, not against them: Effectively locate defects and vulnerabilities as early as possible Integrate into the developer’s preferred working environment, don’t force the developer to go “somewhere else” for the information And they must be as non-intrusive as possible Must execute quickly Mustn’t overload the developer with too much “noise” Klocwork Developer High performance defect and vulnerability detection Tightly integrated into major development environments Visual Studio Eclipse IDEA Available via command line interface for non-IDE interaction Providing support for C, C++ and Java on a variety of O/S platforms