Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-security-txt

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-security-txt

Express middleware that implements a security.txt path and policy

  • 2.5.0
  • npm
  • Socket score

Version published
Weekly downloads
1K
increased by28.82%
Maintainers
1
Weekly downloads
 
Created
Source

view on npm view on npm npm module downloads Build codecov Known Vulnerabilities Security Responsible Disclosure

semantic-release Greenkeeper badge Commitizen friendly

Express Security Txt

Express middleware that implements a security.txt path and policy

References:

Installation

yarn add express-security-txt

Usage

Define an options object with the proper fields that make up a valid security.txt policy, and use it as a middleware for an express app.

const securityTxt = require('express-security-txt')

const options = {
  contact: 'mailto:email@example.com',
  encryption: 'https://www.mykey.com/pgp-key.txt',
  acknowledgement: 'thank you'
}

app.use(securityTxt.setup(options))

Chaining

Where allowed, you can provide multiple values for a single directive by passing an array.

const securityTxt = require('express-security-txt')

const options = {
  contact: [
    'https://firstMethodOfContact.example.com',
    'https://secondMethodOfContact.example.com'
  ]
}

app.use(securityTxt.setup(options))

Comments

To add a comment at the beggining or end of the security.txt file, one may use the keys _prefixComment and _postfixComment respectively. If one wishes to place a comment immediately before a field, one may use an object which specifies the value of the field and the comment which must come before it.

const securityTxt = require('express-security-txt')

const options = {
  _prefixComment: 'This comment goes at the very beggining of the file',
  contact: {
    comment: 'This comment goes directly before the Contact: directive',
    value: 'mailto:email@example.com'
  },
  encryption: [
    'https://example.com/encryption',
    {
      comment: 'Comments can appear in the middle of an array of values',
      value: 'https://example.com/alternativeEncryption'
    }
  ],
  _postfixComment: 'This comment goes at the very end of the file'
}

app.use(securityTxt.setup(options))

Would generate the file

# This comment goes at the very beggining of the file
# This comment goes directly before the Contact: directive
Contact: mailto:email@example.com
Encryption: https://example.com/encryption
# Comments can appear in the middle of an array of values
Encryption: https://example.com/alternativeEncryption
# This comment goes at the very end of the file

If your comment spans multiple lines, you can use \n to split it. express-security-txt will automatically insert the relevant # symbols. Alternatively, one can use an array of lines instead of a string.

For example:

const options = {
  _prefixComment: ['this is a', 'comment\nwhich', 'spans many lines'],
  contact: 'mailto:email@example.com'
}

Would generate

# this is a
# comment
# which
# spans many lines
Contact: mailto:email@example.com

Tests

Project tests:

yarn run test

Project linting:

yarn run lint

Contributing

Commit Guidelines

The project uses the commitizen tool for standardizing changelog style commit messages so you should follow it as so:

git add .           # add files to staging
yarn run commit      # use the wizard for the commit message

FAQs

Package last updated on 10 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc