/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
sapi/fuzzer/generate_parser_corpus.php
24 строки
716 B
Nikita Popov
Reduce max input size in parser fuzzer
06 окт 2021, 20:14
06 окт 2021, 20:14
5d05f81
Код
Авторство
О чём код?
<?php $testsDir = __DIR__ . '/../../Zend/tests/'; $it = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($testsDir), RecursiveIteratorIterator::LEAVES_ONLY ); $corpusDir = __DIR__ . '/corpus/parser'; @mkdir($corpusDir); $maxLen = 6 * 1024; foreach ($it as $file) { if (!preg_match('/\.phpt$/', $file)) continue; $code = file_get_contents($file); if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $code, $matches)) continue; $code = $matches[1]; if (strlen($code) > $maxLen) continue; $outFile = str_replace($testsDir, '', $file); $outFile = str_replace('/', '_', $outFile); $outFile = $corpusDir . '/' . $outFile; file_put_contents($outFile, $code); }