Install from pip:
▶ pip install securitytxt-parser==1.0
Parse a security.txt
variable:
from securitytxt import SecurityTxt
sectxt = "Contact: [email protected]\nAcknowledgements: https://yeswehack.com/programs/yes-we-hack"
s = SecurityTxt()
if s.parse(sectxt):
print("Contact : %s" % s.contact())
print(s.to_dict())
Parse a security.txt
URL:
from securitytxt import SecurityTxt
s = SecurityTxt()
if s.parse_url("https://securitytxt.org/.well-known/security.txt"):
print("Contact : %s" % s.contact())
print(s.to_dict())
Set security.txt
fields :
from securitytxt import SecurityTxt
sectxt = "Contact: [email protected]\nAcknowledgements: https://yeswehack.com/programs/yes-we-hack"
s = SecurityTxt(field_choices=['contact'])
if s.parse(sectxt):
print(s.to_dict())