Giter Club home page Giter Club logo

securitytxttoolkit's Introduction

PowerShell Gallery Version (including pre-releases) PowerShell Gallery Codacy Badge

SecurityTxtToolkit

DOWNLOAD IT!

It's in the PowerShell Gallery now!

Install-Module SecurityTxtToolkit

SHORT DESCRIPTION

SecurityTxtToolkit is a module that works with "security.txt" files, as defined in RFC 9116.

LONG DESCRIPTION

SecurityTxtToolkit is a PowerShell module. It can create, download, test, and verify "security.txt" files.

"security.txt" is an RFC for letting web sites post and share information pertinent to security researchers. This module currently complies with draft version 12.

Testing "security.txt" Files with Test-SecurityTxtFile

To test a "security.txt" file, use the cmdlet Test-SecurityTxtFile. It can be used in both online and offline modes. It outputs a PSCustomObject that has note-properties corresponding to the fields in the "security.txt" file:

PS C:\> Test-SecurityTxtFile 'github.com'

As of this writing (June 2021), that will generate the following output:

Test-SecurityTxtFile: The mandatory Expires field was not found.

For                : github.com
IsValid            : False
IsCanonical        : True
Acknowledgements   : {https://bounty.github.com/bounty-hunters.html}
Canonical          : {https://github.com/.well-known/security.txt}
Contact            : {https://hackerone.com/github}
Encryption         : {}
Expires            :
Hiring             : {}
Policy             : {https://bounty.github.com/}
PreferredLanguages : {en}
IsSigned           : False

It looks like GitHub's "security.txt" file is not compliant with the specification (at the time of this writing)!

The Test-SecurityTxtFile cmdlet also accepts string input via -InputObject or the pipeline:

PS C:\> Get-Content "security.txt" | Test-SecurityTxtFile

That will test the file and validate its input:

For                : stdin
IsValid            : False
IsCanonical        : False
Acknowledgements   : {https://bounty.github.com/bounty-hunters.html}
Canonical          : {https://github.com/.well-known/security.txt}
Contact            : {https://hackerone.com/github}
Encryption         : {}
Expires            :
Hiring             : {}
Policy             : {https://bounty.github.com/}
PreferredLanguages : {en}
IsSigned           : False

However, that cannot be validated for canonicity. In this case, you can add the file's original URL to the cmdlet with the -TestCanonicalUri parameter:

PS C:\> Invoke-WebRequest -OutFile 'security.txt' -Uri 'https://github.com/.well-known/security.txt'

PS C:\> Get-Content 'security.txt' | Test-SecurityTxtFile -TestCanonicalUri 'https://github.com/.well-known/security.txt'

The latter command will parse the previously-downloaded "security.txt" file as if it had been fetched directly from a web server:

For                : stdin
IsValid            : False
IsCanonical        : True
Acknowledgements   : {https://bounty.github.com/bounty-hunters.html}
Canonical          : {https://github.com/.well-known/security.txt}
Contact            : {https://hackerone.com/github}
Encryption         : {}
Expires            :
Hiring             : {}
Policy             : {https://bounty.github.com/}
PreferredLanguages : {en}
IsSigned           : False

Generating Your Own "security.txt" Files

The New-SecurityTxtFile cmdlet will generate a "security.txt" file, sending its output to the pipeline. You may redirect it via standard means, or with the -OutFile parameter. The fields in the "security.txt" specification correspond to this cmdlet's parameters.

PS C:\> New-SecurityTxtFile -OutFile '.well-known/security.txt' -Canonical "https://contoso.com/.well-known/security.txt" -Contact "mailto:[email protected]" -Hiring "https://jobs.contoso.com"

That example will genereate the following output. The Expires field and PGP signature will vary:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

# This is a "security.txt" file that complies with RFC 9116:
# <https://www.rfc-editor.org/rfc/rfc9116>
#
# This file was made with SecurityTxtToolkit:
# <https://github.com/rhymeswithmogul/SecurityTxtToolkit>

Canonical: https://contoso.com/.well-known/security.txt
Contact: mailto:[email protected]
Expires: 2022-06-18T16:41:06-04:00
Hiring: https://jobs.contoso.com/

-----BEGIN PGP SIGNATURE-----

signature-goes-here
-----END PGP SIGNATURE-----

SEE ALSO

For more information about "security.txt" files in general, the creators of the specification, Edwin "EdOverflow" Foudil and Yakov Shafranovich, have a web page at https://securitytxt.org. This module might be listed on their web site, but I'm not affiliated with them.

Why not read my article about this to see it in action?

securitytxttoolkit's People

Contributors

jschpp avatar rhymeswithmogul avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

jschpp

securitytxttoolkit's Issues

Language Specific Code

Since you are using Select-String to look for the english message parts in the gpg output the gpg check will fail on a non english os.

It's more or less understood that the output of gpg --verify shouldn't be parsed like that. See this thread: https://lists.gnupg.org/pipermail/gnupg-users/2005-July/026212.html

Instead you should use gpg --status-fd 1 --verify which will add machine readable output.

[GNUPG:] NEWSIG
gpg: Signatur vom 12.05.2023 10:20:19 Mitteleurop�ische Sommerzeit
gpg:                mittels EDDSA-Schlüssel 50E6EA9B7AFD2553457C77C8A7F4B35E85BB2BAA
[GNUPG:] KEY_CONSIDERED 50E6EA9B7AFD2553457C77C8A7F4B35E85BB2BAA 0
[GNUPG:] SIG_ID J9x1yaxahXcGXBiOAfw+N7a0VxI 2023-05-12 1683879619
[GNUPG:] KEY_CONSIDERED 50E6EA9B7AFD2553457C77C8A7F4B35E85BB2BAA 0
[GNUPG:] GOODSIG A7F4B35E85BB2BAA IT Sicherheit Johann Wolfgang Goethe-Universit├ñt Frankfurt <[email protected]>
gpg: Korrekte Signatur von "IT Sicherheit Johann Wolfgang Goethe-Universität Frankfurt <[email protected]>" [ultimativ]
[GNUPG:] VALIDSIG 50E6EA9B7AFD2553457C77C8A7F4B35E85BB2BAA 2023-05-12 1683879619 0 4 0 22 10 01 50E6EA9B7AFD2553457C77C8A7F4B35E85BB2BAA
[GNUPG:] TRUST_ULTIMATE 0 pgp

See all parts starting with [GNUPG]

I'd be open to write a PR if you're interested.

Thank you for this nifty tool nevertheless :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.