popen()的Veracode发行的不受信任的初始化

时间:2018-08-21 10:05:02

标签: php

下面是不可信初始化的代码

<?php 

    function _svnFindPath($file)
    {
        $xml = '';
        $command = "svn info --xml $file";
        $fp = popen($command, "r"); // open command in read mode
        while ($line = fgets($fp, 1024)) {
            $xml .= rtrim($line)."\n";
        }
        pclose($fp);
        $url_tag = strpos($xml, '<url>');
        $url = substr($xml, $url_tag + 5, strpos($xml, '</url>', $url_tag + 5) - 
        ($url_tag + 5));

        $path = array();
        $path['from'] = substr($url, 0, strrpos($url, '/'));
        $path['base'] = substr($path['from'], 0, strrpos($path['from'], '/') + 
        1);

        // Figure out the local paths - see http://pear.php.net/bugs/17463
        $pos = strpos($file, DIRECTORY_SEPARATOR . 'trunk' . 
        DIRECTORY_SEPARATOR);
        if ($pos === false) {
            $pos = strpos($file, DIRECTORY_SEPARATOR . 'branches' . 
        DIRECTORY_SEPARATOR);
        }
        $path['local']['base'] = substr($file, 0, $pos + 1);

        return $path; //returns path 
    }

?>

上面是PHP的代码,它显示了一些不受信任的初始化     popen()函数     解决不可信初始化的解决方案是什么?     寻找可以通过任何功能修复的解决方案。     popen函数的功能类似于fopen,但仅具有读写模式。

0 个答案:

没有答案