1.0.3 • Published 1 year ago

cache-security-checker v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

cache-security-checker

Quick Start

Installation

npm i cache-security-checker

Simple Usage

const Checker = require('cache-security-checker')

async function main() {
  console.log(await Checker.checkCache("https://niteco.com/"))
  console.log(await Checker.checkSecurity("https://niteco.com/"))
}
main()

await Checker.checkCache("https://niteco.com/")

{
  hasCache: false,
  headerResponse: {
    date: 'Tue, 28 Feb 2023 03:10:56 GMT',
    'content-type': 'text/html; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    vary: 'Accept-Encoding',
    'set-cookie': [ 'EPiStateMarker=true; path=/; secure; httponly' ],
    'x-content-type-options': 'nosniff',
    'content-security-policy': "frame-ancestors 'self' http://*.niteco.se https://*.niteco.se; base-uri 'self';",
    'x-content-security-policy': "default-src 'self';",
    'x-xss-protection': '1; mode=block',
    'x-frame-options': 'SAMEORIGIN',
    'referrer-policy': 'strict-origin',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'cf-cache-status': 'DYNAMIC',
    'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=aBlBYK5C%2BTfQdTMdjT2j1mQsvGcrYcmQjwc5OSGpu971Tv5YcajPTwzFrUVSdy7gGpdBAcsZX86FfxfB1tpx5jvqoUtlTBvS240WVzhkRbWJ2riMGNNhHuIf7uY%3D"}],"group":"cf-nel","max_age":604800}',
    nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
    server: 'cloudflare',
    'cf-ray': '7a05f8508ec76e5d-HKG',
    'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'
  }
}

await Checker.checkSecurity("https://niteco.com/")

{
  headerResponse: {
    connection: 'close',
    'cache-control': 'private',
    'content-type': 'text/html; charset=utf-8',
    'strict-transport-security': 'max-age=15552000',
    'x-frame-options': 'SAMEORIGIN',
    'set-cookie': [
      'OptanonConsent=; expires=Sun, 26 Feb 2023 03:10:56 GMT; domain=.stackoverflow.com; path=/; secure; samesite=none; httponly',       
      'OptanonAlertBoxClosed=; expires=Sun, 26 Feb 2023 03:10:56 GMT; domain=.stackoverflow.com; path=/; secure; samesite=none; httponly',
      'prov_tgt=; expires=Sun, 26 Feb 2023 03:10:56 GMT; domain=.stackoverflow.com; path=/; secure; samesite=none; httponly',
      'prov=a2c8c1ae-5608-8e1b-28e8-b96b9ea910ff; domain=.stackoverflow.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly'     
    ],
    'x-request-guid': '91886fca-574f-4e34-8217-244792c66e54',        
    'feature-policy': "microphone 'none'; speaker 'none'",
    'content-security-policy': "upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com",
    'accept-ranges': 'bytes',
    date: 'Tue, 28 Feb 2023 03:10:57 GMT',
    via: '1.1 varnish',
    'x-served-by': 'cache-qpg1243-QPG',
    'x-cache': 'MISS',
    'x-cache-hits': '0',
    'x-timer': 'S1677553857.743981,VS0,VE319',
    vary: 'Accept-Encoding,Fastly-SSL',
    'x-dns-prefetch-control': 'off',
    'transfer-encoding': 'chunked'
  },
  valid: {
    'content-security-policy': 'Content Security Policy is an effective measure to protect your site from XSS attacks. By whitelisting sources of approved content, you can prevent the browser from loading malicious assets. Analyse this policy in more detail. You can sign up for a free account on Report URI to collect reports about problems on your site.',
    'x-frame-options': 'X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking.',
    'strict-transport-security': 'HTTP Strict Transport Security is an excellent feature to support on your site and strengthens your implementation of TLS by getting the User Agent to enforce the use of HTTPS.'
  },
  missing: {
    'Permissions-Policy': 'Permissions Policy is a new header that allows a site to control which features and APIs can be used in the browser.',
    'Cross-Origin-Embedder-Policy': 'Cross-Origin Embedder Policy allows a site to prevent assets being loaded that do not grant permission to load them via CORS or CORP.',
    'Cross-Origin-Opener-Policy': 'Cross-Origin Opener Policy allows a site to opt-in to Cross-Origin Isolation in the browser.',
    'Cross-Origin-Resource-Policy': 'Cross-Origin Resource Policy allows a resource owner to specify who can load the resource.',
    'x-content-type-options': '\tX-Content-Type-Options stops a browser from trying to MIME-sniff the content type and forces it to stick with the declared content-type. The only valid value for this header is "X-Content-Type-Options: nosniff".',
    'x-content-security-policy': 'X Content Security Policy is required for CSP support in IE 10 and IE 11. For other modern browsers the Content-Security-Policy header should be used.',
    'x-xss-protection': 'X-XSS-Protection sets the configuration for the XSS Auditor built into older browsers. The recommended value was "X-XSS-Protection: 1; mode=block" but you should now look at Content Security Policy instead.',
    'referrer-policy': '\tReferrer Policy is a new header that allows a site to control how much information the browser includes with navigations away from a document and should be set by all sites.',      
    'report-to': 'Report-To enables the Reporting API. This allows a website to collect reports from the browser about various errors that may occur. You can sign up for a free account on Report URI to collect these reports.',
    nel: 'Network Error Logging is a new header that instructs the browser to send reports during various network or application errors. You can sign up for a free account on Report URI to collect these reports.',
    server: 'Server value has been changed. Typically you will see values like "Microsoft-IIS/8.0" or "nginx 1.7.2".'
  },
  validPoint: 3,
  maxPoint: 14
}
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago