Skip to content
A security.txt parser for PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SecurityTxt
test
.gitignore
Makefile
README.md
composer.json
phpunit.xml

README.md

PHP security.txt parser

Work in progress.

Install

Install from packagist:

▶ composer require tomnomnom/phpsecuritytxt

Usage

Parse a security.txt file:

<?php
$raw = file_get_contents("test/fixtures/basic.txt");

$sectxt = new \SecurityTxt\Parser($raw);

You can create and empty object and call parse() instead:

<?php
$raw = file_get_contents("test/fixtures/basic.txt");

$sectxt = new \SecurityTxt\Parser();
$sectxt->parse($raw);

Get contact info:

<?php
foreach ($sectxt->contact() as $contact){
    echo "Contact: {$contact}\n";
}

Get encryption info:

<?php
foreach ($sectxt->encryption() as $encryption){
    echo "Encryption link: {$encryption}\n";
}

Get acknowledgement info:

<?php
foreach ($sectxt->acknowledgement() as $acknowledgement){
    echo "Acknowledgement link: {$acknowledgement}\n";
}

Get parser errors:

<?php
foreach ($sectxt->errors() as $error){
    echo "Error: {$error}\n";
}

Get comments:

<?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
You can’t perform that action at this time.