Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

DIY: Analyse statique en Java

714 views

Published on

DIY: Analyse statique en Java par Nicolas Peru et Michael Gumowski

Trouver des bugs dans votre code java sans avoir à l’exécuter ? C'est possible. Découvrez de quelle manière l'analyse statique est un moyen de trouver des bugs en comprenant le fonctionnement de l'analyseur Java de SonarQube. Quelles sont les difficultés pour comprendre le langage Java ? Qu'est-ce que l'analyse syntaxique, l'analyse sémantique et l’exécution symbolique ? Et comment, en se basant sur le code source, il est possible de trouver des problèmes dans votre code sans avoir à l’exécuter ? Répondre à toutes ces questions vous permettra d'écrire vos propres règles d'analyse statique !

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

DIY: Analyse statique en Java

  1. 1. GenevaJug #sonarqube DIY: Java Static Analysis Nicolas PERU - @benzonico Michael GUMOWSKI - @m-g-sonar
  2. 2. Ego boost ● Nicolas PERU - @benzonico ○ Java developer@SonarSource ○ Developer in language team ○ Lead of sonar java plugin ○ Geneva Jug enthusiast ● Michael GUMOWSKI ○ Java developer@SonarSource ○ Developer in language team ○ Run half marathon in 1h24
  3. 3. Static Analysis Analyze code, without executing it.
  4. 4. ● Back Story Sonar Java Plugin
  5. 5. Challenge Get the language.
  6. 6. Lexical Analysis Only two things are infinite, the universe and human stupidity, and I am not sure about the former.
  7. 7. Syntactic Analysis Only two things are infinite, the universe and human stupidity, and I am not sure about the former. Albert E. Subjects Verbs
  8. 8. Lexical Analysis class A { int b; }
  9. 9. Syntactic Analysis class A { int b; } Keywords Identifiers punctuators
  10. 10. Syntax Tree + 3 21 + 1 + 2 + 3 interface BinaryExpressionTree { ExpressionTree leftOperand(); SyntaxToken operatorToken(); ExpressionTree rightOperand(); }
  11. 11. Java pop quizz !! [ ]
  12. 12. [ ] ) [ ] [ ] {
  13. 13. int[ ] foo(int a[ ] ) [ ] [ ] { return null; }
  14. 14. int[ ] foo(int a[ ] ) [ ] [ ] { return null; }
  15. 15. int[ ][ ][ ] foo(int[ ] a) { return null; }
  16. 16. Semantic Analysis Only two things are infinite, the universe and human stupidity, and I am not sure about the former. Albert E.
  17. 17. Semantic Analysis Only two things are infinite, the universe and human stupidity, and I am not sure about the former. Albert E.
  18. 18. Semantic Analysis class A { int b; A(int b) { this.b = b; } }
  19. 19. Java pop quizz !! class Foo<T> { class T { } T myField; }
  20. 20. Java pop quizz !! class Foo<T> { class T { } T myField; }
  21. 21. How do you know that ? JLS is your best friend http://docs.oracle.com/javase/specs/jls/se8/html/index.html
  22. 22. Java pop quizz !! interface F1 { } interface F2 { }
  23. 23. Java pop quizz !! class A<T extends F1 & F2>{ void fun(F1 f1){} void fun(T t){} }
  24. 24. Java pop quizz !! class A<T extends F2 & F1>{ void fun(F1 f1){} void fun(T t){} }
  25. 25. Java pop quizz !! The erasure of a type variable is the erasure of its leftmost bound.
  26. 26. How do you know that ? JLS is your best friend http://docs.oracle.com/javase/specs/jls/se8/html/index.html
  27. 27. Your turn now : Custom rules !
  28. 28. Beyond semantic : Symbolic Execution Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { ... } else { myObject.toString(); } //NPE
  29. 29. Symbolic Execution Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { … } else { myObject.toString(); } //NPE Program State#0 myObject != null
  30. 30. Symbolic Execution Object myObject = new Object(); if(a) { myObject = null; } ... if( !a ) { … } else { myObject.toString(); } //NPE Program State#0 myObject != null Program State#1 myObject != null a = false Program State#2 myObject = null a = true
  31. 31. Symbolic Execution ... if( !a ) { … } else { myObject.toString(); // NPE } Program State#1 myObject != null a = false Program State#2 myObject = null a = true Program State#4 myObject = null a = true Program State#3 ...
  32. 32. Symbolic Execution challenges Complex flows : Try Catch Finally try { methodCall(); methodThrowingException(); } catch ( CustomException e) { ... }finally { ... }
  33. 33. Symbolic Execution challenges Complex conditions : if(a + 1 < (b* 10 - 39) ) { if( b > a/10 + 4 ) { … } // Always true }
  34. 34. Symbolic Execution challenges Explosion of states : if(a) {...} else {...} if(b) {...} else {...} if(c) {...} else {...} instruction; //evaluated by 8 states.
  35. 35. Uhoh ?! From apache vysper: https://nemo.sonarqube.org/issues/search#issues=AVJ9P2Bzm66gr6MLNW_j
  36. 36. Uhoh ?! From elastic search: https://nemo.sonarqube.org/issues/search#issues=AVJ9mFy_m66gr6MLNXpJ
  37. 37. Reach us sonarqube@googlegroups.com https://groups.google.com/forum/#!forum/sonarqube
  38. 38. sonarsource jobs@sonarsource.com
  39. 39. Q & A

×