| ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
Conditional Code AnalysisConditional Code Analysis – improve accuracy detection with conditional code
CategoriesAs briefly introduced at end of advanced detection chapter, we will learn now that there are 3 categories of conditional code that could give wrong result, if there are not catched properly. These categories are :
How to catch them with web interfaceAt the beginning of first version that catch conditional code, there were only 3 options: ignore_functions, ignore_extensions and ignore_constants. Incovenient with these options, is that you should know the source code to parse, and identify whose functions, extensions or constants to avoid. Version 1.7.0 of API has introduced the ability to add name patterns to identify all or part of functions, extensions, constants to ignore from parsing. You should use now these options: ignore_functions_match, ignore_extensions_match or ignore_constants_match. Let's take a look with an example, how it's easy to catch whatever you want to exclude from parsing. We will take again example of PEAR::HTML_CSS 1.5.1 package already seen in advanced directory detection .
<?php
Here we catch all standard conditional code (function_exists, extension_loaded, defined) what match all names (regular expression given by array('/.*/')).
Example to ignore all functions prefixed by xdebug_ :
<?php
How to catch them with CLIIf you use the command-line parser with pci script, the solution is a bit different. To catch cond_code = 1 (function), you must run the command pci -inm functions-match.txt where functions-match.txt is a text file, that identify on each line a new condition. Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini) If first non blank character is an equal sign (=), then you can catch what ever function you want with a preg_match condition (see xdebug example in previous section (web interface) Example of text file contents ;=^xdebug_ ;=alias$ .* ;file_put_contents
To catch cond_code = 2 (extension), you must run the command pci -iem extensions-match.txt where extensions-match.txt is a text file, that identify on each line a new condition. Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini) If first non blank character is an equal sign (=), then you can catch what ever extension you want with a preg_match condition. Example of text file contents ;=xdebug ;sqlite =gd ;=sapi_apache
To catch cond_code = 4 (constant), you must run the command pci -icm constants-match.txt where constants-match.txt is a text file, that identify on each line a new condition. Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini) If first non blank character is an equal sign (=), then you can catch what ever constant you want with a preg_match condition. Example of text file contents =PHP_EOL =DATE_RSS ;FILE_FIND_VERSION
|
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「Conditional Code Analysis」をGoogle検索
|