-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And check for dependencies in example targets.
- Loading branch information
Showing
4 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
// This only works with php-fuzzer.phar, which uses a prefixed version of php-parser! | ||
|
||
/** @var PhpFuzzer\Fuzzer $fuzzer */ | ||
|
||
$fuzzer->setMaxLen(1024); | ||
$fuzzer->addDictionary(__DIR__ . '/php.dict'); | ||
if (class_exists(PhpParser\Parser\Php7::class)) { | ||
echo "The PHP-Parser target can only be used with php-fuzzer.phar,\n"; | ||
echo "otherwise there is a conflict with php-fuzzer's own use of PHP-Parser.\n"; | ||
exit(1); | ||
} | ||
|
||
$autoload = __DIR__ . '/PHP-Parser/vendor/autoload.php'; | ||
if (!file_exists($autoload)) { | ||
echo "Cannot find PHP-Parser installation in " . __DIR__ . "/PHP-Parser\n"; | ||
exit(1); | ||
} | ||
|
||
require $autoload; | ||
|
||
require __DIR__ . '/../../PHP-Parser/vendor/autoload.php'; | ||
$parser = new PhpParser\Parser\Php7(new PhpParser\Lexer); | ||
$prettyPrinter = new PhpParser\PrettyPrinter\Standard(); | ||
|
||
$fuzzer->setTarget(function(string $input) use($parser, $prettyPrinter) { | ||
$stmts = $parser->parse($input); | ||
$prettyPrinter->prettyPrintFile($stmts); | ||
}); | ||
|
||
$fuzzer->setMaxLen(1024); | ||
$fuzzer->addDictionary(__DIR__ . '/php.dict'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
<?php declare(strict_types=1); | ||
|
||
// Using tolerant-php-parser here, because the instrumentation uses php-parser, | ||
// so we can't easily fuzz php-parser itself. | ||
|
||
/** @var PhpFuzzer\Fuzzer $fuzzer */ | ||
|
||
$fuzzer->setMaxLen(1024); | ||
$fuzzer->addDictionary(__DIR__ . '/php.dict'); | ||
$autoload = __DIR__ . '/tolerant-php-parser/vendor/autoload.php'; | ||
if (!file_exists($autoload)) { | ||
echo "Cannot find tolerant-php-parser installation in " . __DIR__ . "/tolerant-php-parser\n"; | ||
exit(1); | ||
} | ||
|
||
require $autoload; | ||
|
||
require __DIR__ . '/../../tolerant-php-parser/vendor/autoload.php'; | ||
$parser = new Microsoft\PhpParser\Parser(); | ||
|
||
$fuzzer->setTarget(function(string $input) use($parser) { | ||
$parser->parseSourceFile($input); | ||
}); | ||
|
||
$fuzzer->setMaxLen(1024); | ||
$fuzzer->addDictionary(__DIR__ . '/php.dict'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters