Skip to content

Commit 5e977c3

Browse files
committedOct 15, 2024
merge 'typescript-update' into 'main'
2 parents 422a30e + 4ae751f commit 5e977c3

33 files changed

+5314
-4451
lines changed
 

‎.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"extends": "eslint:recommended",
99
"ignorePatterns": "dist/",
1010
"parserOptions": {
11-
"ecmaVersion": 12
11+
"ecmaVersion": 12,
12+
"sourceType": "module"
1213
},
1314
"rules": {
1415
"indent": ["error", 2],

‎.github/workflows/build.yml

-38
This file was deleted.

‎.github/workflows/ci.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest]
19+
fail-fast: false
20+
21+
steps:
22+
- id: checkout
23+
name: Checkout
24+
uses: actions/checkout@v3
25+
- id: setup-bun
26+
name: Setup Bun
27+
uses: oven-sh/setup-bun@v1
28+
with:
29+
bun-version: latest
30+
- id: install-deps
31+
name: Install dependencies
32+
run: |
33+
bun install
34+
- id: test
35+
name: Run test
36+
run: |
37+
bun test

‎.github/workflows/codeql-analysis.yml

-71
This file was deleted.

‎.github/workflows/lint.yml

-24
This file was deleted.

‎.github/workflows/node.js.yml

-28
This file was deleted.

‎.github/workflows/release.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: "20.x"
23+
registry-url: "https://registry.npmjs.org/"
24+
25+
- uses: oven-sh/setup-bun@v2
26+
with:
27+
bun-version: latest
28+
29+
- name: Install dependencies using Bun
30+
run: bun install
31+
32+
- name: Run build script using Bun
33+
run: bun run build
34+
35+
- name: Publish to npm
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
run: npm publish --provenance --access public

‎.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://npm.pkg.github.com/

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<h1 align="center">cvss.js by <a href="https://turingpoint.eu" target="_blank">turingpoint.</a></h1>
22
<p>
3-
<img alt="Version" src="https://img.shields.io/badge/version-1.5.0-blue.svg?cacheSeconds=2592000" />
3+
<img alt="Version" src="https://img.shields.io/badge/version-2.0.0-blue.svg?cacheSeconds=2592000" />
44
<a href="#" target="_blank">
55
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
66
</a>
77
</p>
88

9-
> A tiny library to work with [CVSS vectors](https://www.first.org/cvss/v3.0/specification-document) (v3.0 and v3.1) in JavaScript. The Common Vulnerability Scoring System (CVSS) is a free and open standard. It is owned and managed by [FIRST.Org](https://first.org).
9+
> A tiny library to work with [CVSS vectors](https://www.first.org/cvss/v3.0/specification-document) (v3.0, v3.1 and v4.0) in JavaScript. The Common Vulnerability Scoring System (CVSS) is a free and open standard. It is owned and managed by [FIRST.Org](https://first.org).
1010
1111
## Installation
1212

@@ -247,5 +247,5 @@ Feel free to check out the [issues page](https://github.com/turingpointde/cvss.j
247247

248248
## License
249249

250-
Copyright © 2022 [turingpoint GmbH](https://turingpoint.eu).
250+
Copyright © 2024 [turingpoint GmbH](https://turingpoint.eu).
251251
This project is [MIT](LICENSE) licensed.

‎build.mjs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import dts from "bun-plugin-dts";
2+
3+
const output = await Bun.build({
4+
entrypoints: ["index.ts"],
5+
outdir: "./dist",
6+
target: "browser",
7+
minify: false,
8+
plugins: [dts()],
9+
define: {
10+
global: "window",
11+
},
12+
});
13+
14+
if (!output.success) {
15+
for (const log of output.logs) {
16+
console.error(log);
17+
}
18+
}
19+
20+
const output2 = await Bun.build({
21+
entrypoints: ["index.ts"],
22+
outdir: "./dist_node",
23+
target: "node",
24+
minify: false,
25+
plugins: [dts()],
26+
define: {
27+
window: "undefined",
28+
},
29+
});
30+
31+
if (!output2.success) {
32+
for (const log of output2.logs) {
33+
console.error(log);
34+
}
35+
}

‎bun.lockb

10.7 KB
Binary file not shown.

‎dist/index.d.ts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Generated by dts-bundle-generator v9.5.1
2+
3+
export type CvssVectorObject = {
4+
AV?: "N" | "A" | "L" | "P";
5+
AC?: "L" | "H";
6+
PR?: "N" | "L" | "H";
7+
UI?: "N" | "R";
8+
S?: "U" | "C";
9+
C?: "N" | "L" | "H";
10+
I?: "N" | "L" | "H";
11+
A?: "N" | "L" | "H";
12+
E?: "X" | "H" | "F" | "P" | "U";
13+
RL?: "X" | "U" | "W" | "T" | "O";
14+
RC?: "X" | "C" | "R" | "U";
15+
CR?: "X" | "H" | "M" | "L";
16+
IR?: "X" | "H" | "M" | "L";
17+
AR?: "X" | "H" | "M" | "L";
18+
MAV?: "X" | "N" | "A" | "L" | "P";
19+
MAC?: "X" | "L" | "H";
20+
MPR?: "X" | "N" | "L" | "H";
21+
MUI?: "X" | "N" | "R";
22+
MS?: "X" | "U" | "C";
23+
MC?: "X" | "N" | "L" | "H";
24+
MI?: "X" | "N" | "L" | "H";
25+
MA?: "X" | "N" | "L" | "H";
26+
AT?: "N" | "P";
27+
VC?: "N" | "L" | "H";
28+
VI?: "N" | "L" | "H";
29+
VA?: "N" | "L" | "H";
30+
SC?: "N" | "L" | "H";
31+
SI?: "N" | "L" | "H";
32+
SA?: "N" | "L" | "H";
33+
CVSS: string;
34+
};
35+
export type DetailedMetric = {
36+
name: string;
37+
abbr: string;
38+
fullName: string;
39+
value: string;
40+
valueAbbr: string;
41+
};
42+
export type DetailedVectorObject = {
43+
metrics: DetailedMetric[];
44+
CVSS: string;
45+
};
46+
/**
47+
* Creates a new CVSS object
48+
*/
49+
export declare function CVSS(cvss: string | CvssVectorObject): {
50+
vector: string;
51+
getScore: () => number;
52+
getTemporalScore: () => number;
53+
getEnvironmentalScore: () => number;
54+
getRating: () => string;
55+
getTemporalRating: () => string;
56+
getEnvironmentalRating: () => string;
57+
getVectorObject: () => CvssVectorObject;
58+
getDetailedVectorObject: () => DetailedVectorObject;
59+
getVersion: () => "3.0" | "4.0" | "3.1" | "Error";
60+
getCleanVectorString: () => string;
61+
updateVectorValue: (metric: keyof CvssVectorObject, value: string) => string;
62+
getImpactSubScore: () => void;
63+
getExploitabilitySubScore: () => void;
64+
isVersionValid: string;
65+
isValid: boolean;
66+
};
67+
68+
export {};

0 commit comments

Comments
 (0)