npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cvss-draft

v0.0.1

Published

The Common Vulnerability Scoring System ([CVSS](https://www.first.org/cvss/)) [base](https://www.first.org/cvss/specification-document#Base-Metrics) [score](https://www.first.org/cvss/specification-document#1-2-Scoring) calculator and validator library wr

Downloads

19

Readme

cvss

The Common Vulnerability Scoring System (CVSS) base score calculator and validator library written in TypeScript.

Basics 🧾

CVSS outputs numerical scores, indicating severity of vulnerability, based on some principal technical vulnerability characteristics. Its outputs include numerical scores indicating the severity of a vulnerability relative to other vulnerabilities. Link

The CVSS v3 vector string begins with the label CVSS: and a numeric representation of the version. After version string it contains a set of /-separated CVSS metrics. Each metric consists of name and value (both abbreviated) separated with ':'.

Sample

Sample CVSS v3.1 vector string: CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N

Score is: 3.8, severity: Low

Current library limitations 🚧

CVSS specification defines three metric groups: Base, Temporal, and Environmental, but only Base metrics are supported by given library for now.

Supported CVSS versions: 3.0 and 3.1

Install 🚀

npm i --save @neuralegion/cvss

API

calculateBaseScore(cvssString): number

Calculates Base Score, which depends on sub-formulas for Impact Sub-Score (ISS), Impact, and Exploitability,

calculateIss(metricsMap): number

Calculates Impact Sub-Score (ISS)

calculateImpact(metricsMap, iss): number

Calculates Impact

calculateExploitability(metricsMap): number

Calculates Exploitability

validate(cvssString): void

Throws an Error if given CVSS string is either invalid or unsupported.

Error contains verbose message with error details. Sample error messages:

  • CVSS vector must start with "CVSS:"
  • Invalid CVSS string. Example: CVSS:3.0/AV:A/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
  • Unsupported CVSS version: 2.0. Only 3.0 and 3.1 are supported
  • Duplicated metric: "AC:L"
  • Missing mandatory CVSS base metric C (Confidentiality)
  • Unknown CVSS metric "X". Allowed metrics: AV, AC, PR, UI, S, C, I, A
  • Invalid value for CVSS metric PR (Privileges Required): Y. Allowed values: N (None), L (Low), H (High)

humanizeBaseMetric(metric)

Return un-abbreviated metric name: e.g. 'Confidentiality' for input 'C'

humanizeBaseMetricValue(value, metric)

Return un-abbreviated metric value: e.g. 'Network' for input ('AV', 'N')

Usage

import { calculateBaseScore } from 'cvss';

console.log('score: ', calculateBaseScore('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N'));
const cvss = require('cvss');

console.log(cvss.calculateBaseScore('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N'));

usage.mjs file:

import cvss from 'cvss';

console.log(cvss.calculateBaseScore('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N'));

Running: node --experimental-modules ./usage.mjs

<script src="./node_modules/cvss/dist/bundle.umd.js"></script>
<script>
  alert(`Score: ${cvss.calculateBaseScore('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N')}`);
</script>
<script type="module">
  import { calculateBaseScore } from './node_modules/cvss/dist/bundle.es.js';
  alert(`Score: ${calculateBaseScore('CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N')}`);
</script>

Development 🛠

Issues and pull requests are highly welcome. 👍

Please, don't forget to lint (npm run lint) and test (npm t) the code.

License

Copyright © 2020 NeuraLegion.

This project is licensed under the MIT License - see the LICENSE file for details.