PHP security.txt parser
Work in progress., (*1)
Install
Install from packagist:, (*2)
▶ composer require tomnomnom/phpsecuritytxt
Usage
Parse a security.txt file:, (*3)
<?php
$raw = file_get_contents("test/fixtures/basic.txt");
$sectxt = new \SecurityTxt\Parser($raw);
You can create and empty object and call parse() instead:, (*4)
<?php
$raw = file_get_contents("test/fixtures/basic.txt");
$sectxt = new \SecurityTxt\Parser();
$sectxt->parse($raw);
Get contact info:, (*5)
<?php
foreach ($sectxt->contact() as $contact){
echo "Contact: {$contact}\n";
}
Get encryption info:, (*6)
<?php
foreach ($sectxt->encryption() as $encryption){
echo "Encryption link: {$encryption}\n";
}
Get acknowledgement info:, (*7)
<?php
foreach ($sectxt->acknowledgement() as $acknowledgement){
echo "Acknowledgement link: {$acknowledgement}\n";
}
Get parser errors:, (*8)
<?php
foreach ($sectxt->errors() as $error){
echo "Error: {$error}\n";
}
Get comments:, (*9)
<?php
foreach ($sectxt->comments() as $comment){
echo "Comment: {$comment}\n";
}
TODO
- Add support for fetching URLs directly
- Improve test coverage
- Set up travis to run tests