Skip to content

Commit

Permalink
feat: Add proper type for ProductStatus_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Aug 31, 2023
1 parent eb3115d commit 827aa00
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
ProductStatusSymbol,
type Vulnerability,
type Product,
type Relationship
type Relationship,
type ProductStatus_t,
type ProductStatus_t_Key
} from "./productvulnerabilitiestypes";

const generateProductVulnerabilities = (jsonDocument: any) => {
Expand All @@ -31,7 +33,7 @@ const generateCrossTableFrom = (products: Product[], vulnerabilities: Vulnerabil
const getCVE = vulnerabilities.map((vulnerability: Vulnerability) => vulnerability.cve);
header = header.concat(getCVE);
result.push(header);
let productLines = products.map((product: any) => {
let productLines = products.map((product: Product) => {
let line = [product.name];
line = line.concat(generateLineWith(product, vulnerabilities));
return line;
Expand Down Expand Up @@ -110,8 +112,8 @@ const isProduct = (branch: any) => {
return branch.product && branch.product.product_id && branch.product.name;
};

const generateDictFrom = (productStatus: any, section: string) => {
return productStatus[section].reduce((o: any, n: string) => {
const generateDictFrom = (productStatus: ProductStatus_t, section: ProductStatus_t_Key) => {
return productStatus[section]!.reduce((o: any, n: string) => {
o[n] = n;
return o;
}, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ export const ProductStatus = {
RECOMMENDED: "RECOMMENDED"
} as const;

export type ProductStatus_t = {
first_affected?: string[];
first_fixed?: string[];
fixed?: string[];
known_affected?: string[];
known_not_affected?: string[];
last_affected?: string[];
recommended?: string[];
under_investigation?: string[];
};

export type ProductStatus_t_Key = keyof ProductStatus_t;

export const ProductStatusSymbol = {
FIXED: "F",
UNDER_INVESTIGATION: "U",
Expand Down

0 comments on commit 827aa00

Please sign in to comment.