SlideShare a Scribd company logo
1 of 36
Download to read offline
STATIC ANALYSIS SAVED
MY CODE TONIGHT
PHP UK, LONDON, FEBRUARY 2017.
PHPUK 2017
AGENDA
‣ Under the hood of a static analyzer
‣ What can analyzers do for you
‣ Adopt them now!
‣ Damien Seguy
‣ CTO at exakat
‣ Static code analysis for PHP
‣ Retiring house for oldest 

elephpant
PHPUK 2017
SPEAKER
Elephpant in the death valley
‣ IS IT FAST?
‣ IS THIS BACKWARD COMPATIBLE?
‣ IS THIS SECURE? ‣ IS THIS COMPATIBLE WITH PHP 7?
‣ SHOULD I USE ++$I OR ARRAY_MERGE_RECURSIVE() ?
‣ IS IT TIME FOR LUNCH ?
‣ WHY NOT USE A FRAMEWORK?
PHPUK 2017
STATIC ANALYSIS IS AN EXTRA STEP
EXECUTION
TEXT FILE
OPCODE
CODING CONVENTIONS
PHPUK 2017
STATIC ANALYSIS IS AN EXTRA STEP
EXECUTION
TEXT FILE
OPCODE STATIC ANALYSIS
OPCODE
PHPUK 2017
STATIC ANALYSIS IS AN EXTRA STEP
EXECUTION
TEXT FILE
STATIC ANALYSIS
PHPUK 2017
SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE
<?php   
switch($x) {   
    case '1' :    
        break;   
    default :    
        break;   
    default :    
        break;   
    case '2' :    
        break;   
}   
PHP Lint
PHPUK 2017
SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE
switch($x) {   
    case 1 :    
        break;   
    case 0+1 :    
        break;   
    case '1' :    
        break;   
    case true :    
        break;   
    case 1.0 :    
        break;   
    case $y :    
        break;   
}   
PHPUK 2017
STATIC ANALYSIS UNDER THE HOOD
PHP 5 / 7
Calisthenics
ClearPHP
Performance
Metrics
Couplings
 
 

PHPUK 2017
PHP TOKENS
[248] => Array
(
[0] => 382
[1] =>
[2] => 167
)
[249] => Array
(
[0] => 319
[1] => define
[2] => 167
)
[250] => (
[251] => Array
(
[0] => 323
[1] => 'EXT'
[2] => 167
)
[252] => ,
[253] => Array
(
[0] => 382
[1] =>
[2] => 167
)
‣ Comments, Doc, whitespace
‣ Delimiters : " () {} [] `
‣ 2/3 of the tokens are removed
<?php
//....
    define('EXT', '.php');
PHPUK 2017
AST
‣ PHP 7.0 : ext/ast
‣ nikic/php-parser
PHPUK 2017
AST
<?php
class Foo {
    function bar($arg) {
        return StrToUpper($arg + 2);
    }
}
$foo = new Foo();
$foo->bar(__FILE__);
TEXTE
<?php
    $x = source();
    
    if ($x < 10) {
        $y = $x + 1;
        $x = corrige($y);
    } else {
        $y = $x;
    }
FLOW CONTROL
TEXTE
FLOW CONTROL GRAPH
$x = source();
if ($x < 10) 
$y = $x + 1;
$x = corrige($y);
$y = $x;
PHP
Exit
Else
Then
<?php
    $x = source();
    
    if ($x < 10) {
        $y = $x + 1;
        $x = corrige($y);
    } else {
        $y = $x;
    }
PHPUK 2017
PROGRAM DEPENDENCY GRAPH
$x = source();
if ($x < 10) 
$y = $x + 1;
$x = corrige($y);
$y = $x;
Depend de $x
Depend de $x
Depend de $y
Depend de $x
Depend de $x
Depend de $x
<?php
    $x = source();
    
    if ($x < 10) {
        $y = $x + 1;
        $x = corrige($y);
    } else {
        $y = $x;
    }
PHPUK 2017
PHP AS A CODE DATABASE
‣ Source code is a highly organized dataset
‣ We need a way to query it
‣ There are over 68 static analysis tools for PHP
‣ https://github.com/exakat/php-static-analysis-tools
PHPUK 2017
STATIC ANALYSIS TOOLS
▸ Migration tools
▸ Code quality
▸ Security tools
▸ Metrics
▸ Inventories
PHPUK 2017
MIGRATION TOOLS
‣ Exakat
‣ php7mar
‣ php7cc
EXAKAT REPORT FOR PHP 7.2 COMPATIBILITY
PHPUK 2017
CODE QUALITY
‣ PHPstan
‣ Phan
‣ Psalm
‣ Exakat
PHPSTAN REPORT
------ --------------------------------------------- 

Line code/functions/scripts/pingCheck.php 

------ --------------------------------------------- 

362 Instantiated class phpipam_mail not found. 

415 Function create_link not found. 

446 Catched class phpmailerException not found. 

------ ------------------------------------ 

Line code/index.php 

------ ------------------------------------ 

228 Undefined variable: $heredoc 

------ ---------------------------------------- 

Line library/Exakat/Tasks/Files.php 

------ ---------------------------------------- 

197 Undefined variable: $toRemoveFromFiles 

------ ------------------------------------------------ 

Line code/functions/scripts/resolveIPaddresses.php 

------ ------------------------------------------------ 

236 Undefined variable: $returnPath 

[ERROR] Found 1846 errors
PHPUK 2017
SECURITY TOOLS
‣ psecio:parse
‣ php vuln hunter
‣ RIPS 0.5 / Ripstech saas
$x = source();
if ($x < 10) 
$y = $x + 1;
$x = corrige($y);
$y = $x;
Depend de $x
Depend de $x
Depend de $y
Depend de $x
Depend de $x
Depend de $x
PSECIO REPORT
55) projects/phpipam/code/app/dashboard/widgets/inactive-hosts.php on line 40

Avoid the use of $_REQUEST (know where your data comes from)

> if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_REQUEST['section'])) { $Result->show(
For more information execute 'psecio-parse rules RequestUse'

296) functions/classes/class.Tools.php on line 2762

Avoid the use of `exit` or `die` with strings as it could lead to injection issues (direct output)

> $outFile = file_get_contents(dirname(__FILE__) . '/../../app/subnets/import-subnet/upload/i
upload/import.csv'), true));

For more information execute 'psecio-parse rules ExitOrDie'

448) index.php on line 284

'header()' calls should not use concatenation directly

> if (!in_array($_GET['section'], $tools_menu_items)) { header("Location:
For more information execute 'psecio-parse rules SetHeaderWithInput'
PHPUK 2017
METRICS
‣ PHP Metrics
‣ PHP MD
‣ PHP LOC
PHPMETRICS REPORT
PHPMETRICS REPORT
PHPUK 2017
INVENTORIES
‣ Collection of names, literals, feature
‣ Magic number syndrome
‣ PHP compilation directives
‣ Error messages check
‣ Spelling, consistency…
‣ Exakat
INVENTORY REPORT
PHP COMPILE SCRIPT
;;;;;;;;;;;;;;;;;;;;;;;;
; PHP configure list ;
;;;;;;;;;;;;;;;;;;;;;;;;
./configure
--with-apxs2
--enable-bcmath
--with-curl=DIR
--disable-dom
--enable-exif
--disable-fileinfo
--with-gd
--with-jpeg-dir=DIR
--with-png-dir=DIR
--with-xpm-dir=DIR
--with-vpx-dir=DIR
--with-freetype-dir=DIR
--enable-gd-native-ttf
--with-gettext=DIR
--with-gmp
--with-ldap[=DIR]
--with-ldap-sasl[=DIR]
--disable-libxml
--enable-mbstring
--with-libmbfl=DIR
--enable-mbstr-enc-trans
--disable-mbregex
--with-mcrypt=[DIR]
; Duration of time (in seconds) for which to cache realpath information
; given file or directory. If the application's code doesn't change too o
; may set this directive to 3600 (one hour) or even more.
realpath_cache_ttl = 3600
; More information about file :
;http://php.net/manual/en/filesystem.configuration.php
[File Upload]
; This is the maximum uploaded size. It is recommended to keep this
; as possible.
upload_max_filesize = 2M
; This is the maximum number of uploaded files in a single request.
max_file_uploads = 1
; Upload directory where PHP stores the temporary files. It is recomm
; this value, and separate it from other temporary directories.
upload_tmp_dir = /tmp/php_upload
; This is the maximum amount of data that PHP will accept in a POST r
; has to be higher or equal to upload_max_filesize. For security reason
; should be as low as possible, to prevent PHP using too much memo
post_max_size = 2M
PHP DIRECTIVES CHECKLIST
PHPUK 2017
OTHER USAGE
▸ Dependency graph
▸ Namespaces graph
▸ Deptrack
▸ Taint analysis
PHPUK 2017
WRITE YOUR OWN STATIC ANALYSER
▸ ext/ast : Access the internal AST
▸ nikic/php-parser : for PHP 7
▸ BetterReflection
▸ Fork an existing tool
▸ Use regex
PHPUK 2017
MORE IDEAS
▸ Static analysis for frameworks
▸ Class diagram extractors
▸ Definition / usage paradigm
▸ More coding references
▸ East-programming, SOLID
▸ ~40% of PHP code is static
TEXTE
NEVER CODE ALONE AGAIN
▸ Use experience from others
▸ Use some one else point of view
▸ Prepare for the future
▸ Learn, Find, Capitalize
THANKS
@EXAKAT / EXAKAT.IO

More Related Content

What's hot

No REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsNo REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsC4Media
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphitedamaex17
 
マイクロサービスバックエンドAPIのためのRESTとgRPC
マイクロサービスバックエンドAPIのためのRESTとgRPCマイクロサービスバックエンドAPIのためのRESTとgRPC
マイクロサービスバックエンドAPIのためのRESTとgRPCdisc99_
 
Failing at Scale - PNWPHP 2016
Failing at Scale - PNWPHP 2016Failing at Scale - PNWPHP 2016
Failing at Scale - PNWPHP 2016Chris Tankersley
 
nextcomputing-cyberpro
nextcomputing-cyberpronextcomputing-cyberpro
nextcomputing-cyberproblabadini
 
Docker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 WorkshopDocker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 WorkshopChris Tankersley
 
OSMC 2018 | Distributed Tracing FAQ by Gianluca Arbezzano
OSMC 2018 | Distributed Tracing FAQ by Gianluca ArbezzanoOSMC 2018 | Distributed Tracing FAQ by Gianluca Arbezzano
OSMC 2018 | Distributed Tracing FAQ by Gianluca ArbezzanoNETWAYS
 

What's hot (9)

No REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIsNo REST - Architecting Real-time Bulk Async APIs
No REST - Architecting Real-time Bulk Async APIs
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphite
 
マイクロサービスバックエンドAPIのためのRESTとgRPC
マイクロサービスバックエンドAPIのためのRESTとgRPCマイクロサービスバックエンドAPIのためのRESTとgRPC
マイクロサービスバックエンドAPIのためのRESTとgRPC
 
CCNP Quizzes
CCNP QuizzesCCNP Quizzes
CCNP Quizzes
 
SIP Tutorial/Workshop 1
SIP Tutorial/Workshop 1SIP Tutorial/Workshop 1
SIP Tutorial/Workshop 1
 
Failing at Scale - PNWPHP 2016
Failing at Scale - PNWPHP 2016Failing at Scale - PNWPHP 2016
Failing at Scale - PNWPHP 2016
 
nextcomputing-cyberpro
nextcomputing-cyberpronextcomputing-cyberpro
nextcomputing-cyberpro
 
Docker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 WorkshopDocker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 Workshop
 
OSMC 2018 | Distributed Tracing FAQ by Gianluca Arbezzano
OSMC 2018 | Distributed Tracing FAQ by Gianluca ArbezzanoOSMC 2018 | Distributed Tracing FAQ by Gianluca Arbezzano
OSMC 2018 | Distributed Tracing FAQ by Gianluca Arbezzano
 

Viewers also liked

Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Damien Seguy
 
Review unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphpReview unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphpDamien Seguy
 
當六脈神劍遇上 PhpStorm
當六脈神劍遇上 PhpStorm當六脈神劍遇上 PhpStorm
當六脈神劍遇上 PhpStormOomusou Xiao
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxDamien Seguy
 
Hunt for dead code
Hunt for dead codeHunt for dead code
Hunt for dead codeDamien Seguy
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
Google Analytics Campaign Tracking Fundamentals
Google Analytics Campaign Tracking FundamentalsGoogle Analytics Campaign Tracking Fundamentals
Google Analytics Campaign Tracking FundamentalsKayden Kelly
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7Damien Seguy
 
Rasmus, Think Again! Agile Framework == Happy Php Developer
Rasmus, Think Again! Agile Framework == Happy Php DeveloperRasmus, Think Again! Agile Framework == Happy Php Developer
Rasmus, Think Again! Agile Framework == Happy Php DeveloperArno Schneider
 
BSides Algiers - PHP Static Code Analysis - Abdeldjalil Belakhdar
BSides Algiers - PHP Static Code Analysis - Abdeldjalil BelakhdarBSides Algiers - PHP Static Code Analysis - Abdeldjalil Belakhdar
BSides Algiers - PHP Static Code Analysis - Abdeldjalil BelakhdarShellmates
 
How to stop writing spaghetti code
How to stop writing spaghetti codeHow to stop writing spaghetti code
How to stop writing spaghetti codeTom Croucher
 
RIPS - static code analyzer for vulnerabilities in PHP
RIPS - static code analyzer for vulnerabilities in PHPRIPS - static code analyzer for vulnerabilities in PHP
RIPS - static code analyzer for vulnerabilities in PHPSorina Chirilă
 
Introduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksIntroduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksGerald Krishnan
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHPVladimir Reznichenko
 
Night of the Long Knives
Night of the Long KnivesNight of the Long Knives
Night of the Long KnivesDHUMPHREYS
 
Machine learning in php php con poland
Machine learning in php   php con polandMachine learning in php   php con poland
Machine learning in php php con polandDamien Seguy
 
Machine learning in php
Machine learning in phpMachine learning in php
Machine learning in phpDamien Seguy
 
S3 Overview Presentation
S3 Overview PresentationS3 Overview Presentation
S3 Overview Presentationbcburchn
 

Viewers also liked (20)

Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)
 
Review unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphpReview unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphp
 
當六脈神劍遇上 PhpStorm
當六脈神劍遇上 PhpStorm當六脈神劍遇上 PhpStorm
當六脈神劍遇上 PhpStorm
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php benelux
 
Hunt for dead code
Hunt for dead codeHunt for dead code
Hunt for dead code
 
php & performance
 php & performance php & performance
php & performance
 
Google Analytics Campaign Tracking Fundamentals
Google Analytics Campaign Tracking FundamentalsGoogle Analytics Campaign Tracking Fundamentals
Google Analytics Campaign Tracking Fundamentals
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7
 
Rasmus, Think Again! Agile Framework == Happy Php Developer
Rasmus, Think Again! Agile Framework == Happy Php DeveloperRasmus, Think Again! Agile Framework == Happy Php Developer
Rasmus, Think Again! Agile Framework == Happy Php Developer
 
BSides Algiers - PHP Static Code Analysis - Abdeldjalil Belakhdar
BSides Algiers - PHP Static Code Analysis - Abdeldjalil BelakhdarBSides Algiers - PHP Static Code Analysis - Abdeldjalil Belakhdar
BSides Algiers - PHP Static Code Analysis - Abdeldjalil Belakhdar
 
Spaghetti Code vs MVC
Spaghetti Code vs MVCSpaghetti Code vs MVC
Spaghetti Code vs MVC
 
How to stop writing spaghetti code
How to stop writing spaghetti codeHow to stop writing spaghetti code
How to stop writing spaghetti code
 
RIPS - static code analyzer for vulnerabilities in PHP
RIPS - static code analyzer for vulnerabilities in PHPRIPS - static code analyzer for vulnerabilities in PHP
RIPS - static code analyzer for vulnerabilities in PHP
 
Introduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksIntroduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC Frameworks
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHP
 
Night of the Long Knives
Night of the Long KnivesNight of the Long Knives
Night of the Long Knives
 
Machine learning in php php con poland
Machine learning in php   php con polandMachine learning in php   php con poland
Machine learning in php php con poland
 
Machine learning in php
Machine learning in phpMachine learning in php
Machine learning in php
 
Php performance-talk
Php performance-talkPhp performance-talk
Php performance-talk
 
S3 Overview Presentation
S3 Overview PresentationS3 Overview Presentation
S3 Overview Presentation
 

Similar to Static analysis saved my code tonight

Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Mark Niebergall
 
Static analysis saved my code tonight
Static analysis saved my code tonightStatic analysis saved my code tonight
Static analysis saved my code tonightDamien Seguy
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboardsDenis Ristic
 
Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009PHPBelgium
 
Award-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheUlf Wendel
 
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018PGConf APAC
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Toolsrjsmelo
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them allSebastian Marek
 
Movable Type 5.2 Overview at MTDDC 2012
Movable Type 5.2 Overview at MTDDC 2012Movable Type 5.2 Overview at MTDDC 2012
Movable Type 5.2 Overview at MTDDC 2012Yuji Takayama
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hosterCombell NV
 
Last 2 Months in PHP - July & August 2016
Last 2 Months in PHP - July & August 2016Last 2 Months in PHP - July & August 2016
Last 2 Months in PHP - July & August 2016Eric Poe
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
What We Learned Building an R-Python Hybrid Predictive Analytics Pipeline
What We Learned Building an R-Python Hybrid Predictive Analytics PipelineWhat We Learned Building an R-Python Hybrid Predictive Analytics Pipeline
What We Learned Building an R-Python Hybrid Predictive Analytics PipelineWork-Bench
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPSPaolo Tonin
 

Similar to Static analysis saved my code tonight (20)

Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
Static analysis saved my code tonight
Static analysis saved my code tonightStatic analysis saved my code tonight
Static analysis saved my code tonight
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
 
Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009
 
Running PHP on Nginx
Running PHP on NginxRunning PHP on Nginx
Running PHP on Nginx
 
Running PHP on nginx
Running PHP on nginxRunning PHP on nginx
Running PHP on nginx
 
Award-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cache
 
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them all
 
Movable Type 5.2 Overview at MTDDC 2012
Movable Type 5.2 Overview at MTDDC 2012Movable Type 5.2 Overview at MTDDC 2012
Movable Type 5.2 Overview at MTDDC 2012
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hoster
 
Last 2 Months in PHP - July & August 2016
Last 2 Months in PHP - July & August 2016Last 2 Months in PHP - July & August 2016
Last 2 Months in PHP - July & August 2016
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Api Design
Api DesignApi Design
Api Design
 
What We Learned Building an R-Python Hybrid Predictive Analytics Pipeline
What We Learned Building an R-Python Hybrid Predictive Analytics PipelineWhat We Learned Building an R-Python Hybrid Predictive Analytics Pipeline
What We Learned Building an R-Python Hybrid Predictive Analytics Pipeline
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPS
 

More from Damien Seguy

Strong typing @ php leeds
Strong typing  @ php leedsStrong typing  @ php leeds
Strong typing @ php leedsDamien Seguy
 
Strong typing : adoption, adaptation and organisation
Strong typing : adoption, adaptation and organisationStrong typing : adoption, adaptation and organisation
Strong typing : adoption, adaptation and organisationDamien Seguy
 
Qui a laissé son mot de passe dans le code
Qui a laissé son mot de passe dans le codeQui a laissé son mot de passe dans le code
Qui a laissé son mot de passe dans le codeDamien Seguy
 
Analyse statique et applications
Analyse statique et applicationsAnalyse statique et applications
Analyse statique et applicationsDamien Seguy
 
Top 10 pieges php afup limoges
Top 10 pieges php   afup limogesTop 10 pieges php   afup limoges
Top 10 pieges php afup limogesDamien Seguy
 
Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020Damien Seguy
 
Meilleur du typage fort (AFUP Day, 2020)
Meilleur du typage fort (AFUP Day, 2020)Meilleur du typage fort (AFUP Day, 2020)
Meilleur du typage fort (AFUP Day, 2020)Damien Seguy
 
Top 10 php classic traps confoo
Top 10 php classic traps confooTop 10 php classic traps confoo
Top 10 php classic traps confooDamien Seguy
 
Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Damien Seguy
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbiaDamien Seguy
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 
Top 10 chausse trappes
Top 10 chausse trappesTop 10 chausse trappes
Top 10 chausse trappesDamien Seguy
 
Code review workshop
Code review workshopCode review workshop
Code review workshopDamien Seguy
 
Understanding static analysis php amsterdam 2018
Understanding static analysis   php amsterdam 2018Understanding static analysis   php amsterdam 2018
Understanding static analysis php amsterdam 2018Damien Seguy
 
Review unknown code with static analysis php ce 2018
Review unknown code with static analysis   php ce 2018Review unknown code with static analysis   php ce 2018
Review unknown code with static analysis php ce 2018Damien Seguy
 
Everything new with PHP 7.3
Everything new with PHP 7.3Everything new with PHP 7.3
Everything new with PHP 7.3Damien Seguy
 
Php 7.3 et ses RFC (AFUP Toulouse)
Php 7.3 et ses RFC  (AFUP Toulouse)Php 7.3 et ses RFC  (AFUP Toulouse)
Php 7.3 et ses RFC (AFUP Toulouse)Damien Seguy
 
Tout sur PHP 7.3 et ses RFC
Tout sur PHP 7.3 et ses RFCTout sur PHP 7.3 et ses RFC
Tout sur PHP 7.3 et ses RFCDamien Seguy
 
Review unknown code with static analysis php ipc 2018
Review unknown code with static analysis   php ipc 2018Review unknown code with static analysis   php ipc 2018
Review unknown code with static analysis php ipc 2018Damien Seguy
 
Code review for busy people
Code review for busy peopleCode review for busy people
Code review for busy peopleDamien Seguy
 

More from Damien Seguy (20)

Strong typing @ php leeds
Strong typing  @ php leedsStrong typing  @ php leeds
Strong typing @ php leeds
 
Strong typing : adoption, adaptation and organisation
Strong typing : adoption, adaptation and organisationStrong typing : adoption, adaptation and organisation
Strong typing : adoption, adaptation and organisation
 
Qui a laissé son mot de passe dans le code
Qui a laissé son mot de passe dans le codeQui a laissé son mot de passe dans le code
Qui a laissé son mot de passe dans le code
 
Analyse statique et applications
Analyse statique et applicationsAnalyse statique et applications
Analyse statique et applications
 
Top 10 pieges php afup limoges
Top 10 pieges php   afup limogesTop 10 pieges php   afup limoges
Top 10 pieges php afup limoges
 
Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020Top 10 php classic traps DPC 2020
Top 10 php classic traps DPC 2020
 
Meilleur du typage fort (AFUP Day, 2020)
Meilleur du typage fort (AFUP Day, 2020)Meilleur du typage fort (AFUP Day, 2020)
Meilleur du typage fort (AFUP Day, 2020)
 
Top 10 php classic traps confoo
Top 10 php classic traps confooTop 10 php classic traps confoo
Top 10 php classic traps confoo
 
Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbia
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
Top 10 chausse trappes
Top 10 chausse trappesTop 10 chausse trappes
Top 10 chausse trappes
 
Code review workshop
Code review workshopCode review workshop
Code review workshop
 
Understanding static analysis php amsterdam 2018
Understanding static analysis   php amsterdam 2018Understanding static analysis   php amsterdam 2018
Understanding static analysis php amsterdam 2018
 
Review unknown code with static analysis php ce 2018
Review unknown code with static analysis   php ce 2018Review unknown code with static analysis   php ce 2018
Review unknown code with static analysis php ce 2018
 
Everything new with PHP 7.3
Everything new with PHP 7.3Everything new with PHP 7.3
Everything new with PHP 7.3
 
Php 7.3 et ses RFC (AFUP Toulouse)
Php 7.3 et ses RFC  (AFUP Toulouse)Php 7.3 et ses RFC  (AFUP Toulouse)
Php 7.3 et ses RFC (AFUP Toulouse)
 
Tout sur PHP 7.3 et ses RFC
Tout sur PHP 7.3 et ses RFCTout sur PHP 7.3 et ses RFC
Tout sur PHP 7.3 et ses RFC
 
Review unknown code with static analysis php ipc 2018
Review unknown code with static analysis   php ipc 2018Review unknown code with static analysis   php ipc 2018
Review unknown code with static analysis php ipc 2018
 
Code review for busy people
Code review for busy peopleCode review for busy people
Code review for busy people
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Static analysis saved my code tonight

  • 1. STATIC ANALYSIS SAVED MY CODE TONIGHT PHP UK, LONDON, FEBRUARY 2017.
  • 2. PHPUK 2017 AGENDA ‣ Under the hood of a static analyzer ‣ What can analyzers do for you ‣ Adopt them now!
  • 3. ‣ Damien Seguy ‣ CTO at exakat ‣ Static code analysis for PHP ‣ Retiring house for oldest 
 elephpant PHPUK 2017 SPEAKER Elephpant in the death valley
  • 4. ‣ IS IT FAST? ‣ IS THIS BACKWARD COMPATIBLE? ‣ IS THIS SECURE? ‣ IS THIS COMPATIBLE WITH PHP 7? ‣ SHOULD I USE ++$I OR ARRAY_MERGE_RECURSIVE() ? ‣ IS IT TIME FOR LUNCH ? ‣ WHY NOT USE A FRAMEWORK?
  • 5. PHPUK 2017 STATIC ANALYSIS IS AN EXTRA STEP EXECUTION TEXT FILE OPCODE CODING CONVENTIONS
  • 6. PHPUK 2017 STATIC ANALYSIS IS AN EXTRA STEP EXECUTION TEXT FILE OPCODE STATIC ANALYSIS
  • 7. OPCODE PHPUK 2017 STATIC ANALYSIS IS AN EXTRA STEP EXECUTION TEXT FILE STATIC ANALYSIS
  • 8. PHPUK 2017 SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE <?php    switch($x) {        case '1' :             break;        default :             break;        default :             break;        case '2' :             break;    }    PHP Lint
  • 9. PHPUK 2017 SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE switch($x) {        case 1 :             break;        case 0+1 :             break;        case '1' :             break;        case true :             break;        case 1.0 :             break;        case $y :             break;    }   
  • 10. PHPUK 2017 STATIC ANALYSIS UNDER THE HOOD PHP 5 / 7 Calisthenics ClearPHP Performance Metrics Couplings     
  • 11. PHPUK 2017 PHP TOKENS [248] => Array ( [0] => 382 [1] => [2] => 167 ) [249] => Array ( [0] => 319 [1] => define [2] => 167 ) [250] => ( [251] => Array ( [0] => 323 [1] => 'EXT' [2] => 167 ) [252] => , [253] => Array ( [0] => 382 [1] => [2] => 167 ) ‣ Comments, Doc, whitespace ‣ Delimiters : " () {} [] ` ‣ 2/3 of the tokens are removed <?php //....     define('EXT', '.php');
  • 12. PHPUK 2017 AST ‣ PHP 7.0 : ext/ast ‣ nikic/php-parser
  • 16. PHPUK 2017 PROGRAM DEPENDENCY GRAPH $x = source(); if ($x < 10)  $y = $x + 1; $x = corrige($y); $y = $x; Depend de $x Depend de $x Depend de $y Depend de $x Depend de $x Depend de $x <?php     $x = source();          if ($x < 10) {         $y = $x + 1;         $x = corrige($y);     } else {         $y = $x;     }
  • 17. PHPUK 2017 PHP AS A CODE DATABASE ‣ Source code is a highly organized dataset ‣ We need a way to query it ‣ There are over 68 static analysis tools for PHP ‣ https://github.com/exakat/php-static-analysis-tools
  • 18. PHPUK 2017 STATIC ANALYSIS TOOLS ▸ Migration tools ▸ Code quality ▸ Security tools ▸ Metrics ▸ Inventories
  • 19. PHPUK 2017 MIGRATION TOOLS ‣ Exakat ‣ php7mar ‣ php7cc
  • 20. EXAKAT REPORT FOR PHP 7.2 COMPATIBILITY
  • 21. PHPUK 2017 CODE QUALITY ‣ PHPstan ‣ Phan ‣ Psalm ‣ Exakat
  • 22. PHPSTAN REPORT ------ --------------------------------------------- Line code/functions/scripts/pingCheck.php ------ --------------------------------------------- 362 Instantiated class phpipam_mail not found. 415 Function create_link not found. 446 Catched class phpmailerException not found. ------ ------------------------------------ Line code/index.php ------ ------------------------------------ 228 Undefined variable: $heredoc ------ ---------------------------------------- Line library/Exakat/Tasks/Files.php ------ ---------------------------------------- 197 Undefined variable: $toRemoveFromFiles ------ ------------------------------------------------ Line code/functions/scripts/resolveIPaddresses.php ------ ------------------------------------------------ 236 Undefined variable: $returnPath [ERROR] Found 1846 errors
  • 23. PHPUK 2017 SECURITY TOOLS ‣ psecio:parse ‣ php vuln hunter ‣ RIPS 0.5 / Ripstech saas $x = source(); if ($x < 10)  $y = $x + 1; $x = corrige($y); $y = $x; Depend de $x Depend de $x Depend de $y Depend de $x Depend de $x Depend de $x
  • 24. PSECIO REPORT 55) projects/phpipam/code/app/dashboard/widgets/inactive-hosts.php on line 40 Avoid the use of $_REQUEST (know where your data comes from) > if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_REQUEST['section'])) { $Result->show( For more information execute 'psecio-parse rules RequestUse' 296) functions/classes/class.Tools.php on line 2762 Avoid the use of `exit` or `die` with strings as it could lead to injection issues (direct output) > $outFile = file_get_contents(dirname(__FILE__) . '/../../app/subnets/import-subnet/upload/i upload/import.csv'), true)); For more information execute 'psecio-parse rules ExitOrDie' 448) index.php on line 284 'header()' calls should not use concatenation directly > if (!in_array($_GET['section'], $tools_menu_items)) { header("Location: For more information execute 'psecio-parse rules SetHeaderWithInput'
  • 25. PHPUK 2017 METRICS ‣ PHP Metrics ‣ PHP MD ‣ PHP LOC
  • 28. PHPUK 2017 INVENTORIES ‣ Collection of names, literals, feature ‣ Magic number syndrome ‣ PHP compilation directives ‣ Error messages check ‣ Spelling, consistency… ‣ Exakat
  • 30. PHP COMPILE SCRIPT ;;;;;;;;;;;;;;;;;;;;;;;; ; PHP configure list ; ;;;;;;;;;;;;;;;;;;;;;;;; ./configure --with-apxs2 --enable-bcmath --with-curl=DIR --disable-dom --enable-exif --disable-fileinfo --with-gd --with-jpeg-dir=DIR --with-png-dir=DIR --with-xpm-dir=DIR --with-vpx-dir=DIR --with-freetype-dir=DIR --enable-gd-native-ttf --with-gettext=DIR --with-gmp --with-ldap[=DIR] --with-ldap-sasl[=DIR] --disable-libxml --enable-mbstring --with-libmbfl=DIR --enable-mbstr-enc-trans --disable-mbregex --with-mcrypt=[DIR] ; Duration of time (in seconds) for which to cache realpath information ; given file or directory. If the application's code doesn't change too o ; may set this directive to 3600 (one hour) or even more. realpath_cache_ttl = 3600 ; More information about file : ;http://php.net/manual/en/filesystem.configuration.php [File Upload] ; This is the maximum uploaded size. It is recommended to keep this ; as possible. upload_max_filesize = 2M ; This is the maximum number of uploaded files in a single request. max_file_uploads = 1 ; Upload directory where PHP stores the temporary files. It is recomm ; this value, and separate it from other temporary directories. upload_tmp_dir = /tmp/php_upload ; This is the maximum amount of data that PHP will accept in a POST r ; has to be higher or equal to upload_max_filesize. For security reason ; should be as low as possible, to prevent PHP using too much memo post_max_size = 2M PHP DIRECTIVES CHECKLIST
  • 31. PHPUK 2017 OTHER USAGE ▸ Dependency graph ▸ Namespaces graph ▸ Deptrack ▸ Taint analysis
  • 32.
  • 33. PHPUK 2017 WRITE YOUR OWN STATIC ANALYSER ▸ ext/ast : Access the internal AST ▸ nikic/php-parser : for PHP 7 ▸ BetterReflection ▸ Fork an existing tool ▸ Use regex
  • 34. PHPUK 2017 MORE IDEAS ▸ Static analysis for frameworks ▸ Class diagram extractors ▸ Definition / usage paradigm ▸ More coding references ▸ East-programming, SOLID ▸ ~40% of PHP code is static
  • 35. TEXTE NEVER CODE ALONE AGAIN ▸ Use experience from others ▸ Use some one else point of view ▸ Prepare for the future ▸ Learn, Find, Capitalize