Skip to content

Commit

Permalink
tests and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
miko37x committed Jun 4, 2024
1 parent 7b7a350 commit 3c1e97d
Show file tree
Hide file tree
Showing 7 changed files with 15,468 additions and 3,133 deletions.
33 changes: 20 additions & 13 deletions lib/cvss_4_0.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { CvssVersionDefinition, CvssLookup, MaxComposed, MaxSeverity } from "./types";
import {
CvssVersionDefinition,
CvssLookup,
MaxComposedObject,
MaxComposedNestedObject,
MaxSeverityObject,
MaxSeverityNestedObject
} from "./types";

export const definitions: CvssVersionDefinition = {
version: "4.0",
Expand Down Expand Up @@ -620,18 +627,18 @@ export const cvssLookup_global: CvssLookup = {
"212221": 0.1
};

export const maxComposed: MaxComposed = {
export const maxComposed = {
// EQ1
eq1: {
0: ["AV:N/PR:N/UI:N/"],
1: ["AV:A/PR:N/UI:N/", "AV:N/PR:L/UI:N/", "AV:N/PR:N/UI:P/"],
2: ["AV:P/PR:N/UI:N/", "AV:A/PR:L/UI:P/"]
},
} as MaxComposedObject,
// EQ2
eq2: {
0: ["AC:L/AT:N/"],
1: ["AC:H/AT:N/", "AC:L/AT:P/"]
},
} as MaxComposedObject,
// EQ3+EQ6
eq3: {
0: {
Expand All @@ -649,44 +656,44 @@ export const maxComposed: MaxComposed = {
]
},
2: { "1": ["VC:L/VI:L/VA:L/CR:H/IR:H/AR:H/"] }
},
} as MaxComposedNestedObject,
// EQ4
eq4: {
0: ["SC:H/SI:S/SA:S/"],
1: ["SC:H/SI:H/SA:H/"],
2: ["SC:L/SI:L/SA:L/"]
},
} as MaxComposedObject,
// EQ5
eq5: {
0: ["E:A/"],
1: ["E:P/"],
2: ["E:U/"]
}
} as MaxComposedObject
};

export const maxSeverity: MaxSeverity = {
export const maxSeverity = {
eq1: {
0: 1,
1: 4,
2: 5
},
} as MaxSeverityObject,
eq2: {
0: 1,
1: 2
},
} as MaxSeverityObject,
eq3eq6: {
0: { 0: 7, 1: 6 },
1: { 0: 8, 1: 8 },
2: { 1: 10 }
},
} as MaxSeverityNestedObject,
eq4: {
0: 6,
1: 5,
2: 4
},
} as MaxSeverityObject,
eq5: {
0: 1,
1: 1,
2: 1
}
} as MaxSeverityObject
};
33 changes: 21 additions & 12 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export type CvssVectorObject = {
AV: "N" | "A" | "L" | "P";
AC: "L" | "H";
PR: "N" | "L" | "H";
UI: "N" | "R";
S: "U" | "C";
C: "N" | "L" | "H";
I: "N" | "L" | "H";
A: "N" | "L" | "H";
AV?: "N" | "A" | "L" | "P";
AC?: "L" | "H";
PR?: "N" | "L" | "H";
UI?: "N" | "R";
S?: "U" | "C";
C?: "N" | "L" | "H";
I?: "N" | "L" | "H";
A?: "N" | "L" | "H";
E?: "X" | "H" | "F" | "P" | "U";
RL?: "X" | "U" | "W" | "T" | "O";
RC?: "X" | "C" | "R" | "U";
Expand All @@ -21,6 +21,13 @@ export type CvssVectorObject = {
MC?: "X" | "N" | "L" | "H";
MI?: "X" | "N" | "L" | "H";
MA?: "X" | "N" | "L" | "H";
AT?: "N" | "P";
VC?: "N" | "L" | "H";
VI?: "N" | "L" | "H";
VA?: "N" | "L" | "H";
SC?: "N" | "L" | "H";
SI?: "N" | "L" | "H";
SA?: "N" | "L" | "H";
CVSS: string;
};

Expand Down Expand Up @@ -66,8 +73,10 @@ export type CvssVersionDefinition = {
};
export type CvssLookup = { [key: string]: number };

export type MaxComposed = {
[key: string]: { [key: number]: { [key: string]: string[] } | string[] };
};
export type MaxComposedObject = { [key: number]: string[] };

export type MaxComposedNestedObject = { [key: number]: { [key: string]: string[] } };

export type MaxSeverityObject = { [key: number]: number };

export type MaxSeverity = { [key: string]: { [key: number]: { [key: number]: number } | number } };
export type MaxSeverityNestedObject = { [key: number]: { [key: number]: number } };
Loading

0 comments on commit 3c1e97d

Please sign in to comment.