From a45ab16cfb5e120f643081aebf8b5f3e3005d022 Mon Sep 17 00:00:00 2001 From: hupe1980 Date: Wed, 22 Jun 2022 00:06:37 +0200 Subject: [PATCH] Add overview --- API.md | 202 ++++++++++++++++++++++++++++++++++++++++++++++++ src/author.ts | 1 + src/index.ts | 1 + src/model.ts | 26 +++++++ src/overview.ts | 58 ++++++++++++++ 5 files changed, 288 insertions(+) create mode 100644 src/overview.ts diff --git a/API.md b/API.md index 41bdcb4..7b3598c 100644 --- a/API.md +++ b/API.md @@ -443,8 +443,10 @@ Model.of(construct: IConstruct) | businessCriticality | BusinessCriticality | *No description.* | | title | string | *No description.* | | version | string | *No description.* | +| businessOverview | Overview | *No description.* | | date | string | *No description.* | | managementSummary | string | *No description.* | +| technicalOverview | Overview | *No description.* | | synthesizer | IModelSynthesizer | *No description.* | --- @@ -501,6 +503,16 @@ public readonly version: string; --- +##### `businessOverview`Optional + +```typescript +public readonly businessOverview: Overview; +``` + +- *Type:* Overview + +--- + ##### `date`Optional ```typescript @@ -521,6 +533,16 @@ public readonly managementSummary: string; --- +##### `technicalOverview`Optional + +```typescript +public readonly technicalOverview: Overview; +``` + +- *Type:* Overview + +--- + ##### `synthesizer`Required ```typescript @@ -2512,10 +2534,12 @@ const modelProps: ModelProps = { ... } | businessCriticality | BusinessCriticality | Business criticality of the target. | | version | string | Version of the Threagile toolkit. | | abuseCases | AbuseCase[] | Custom abuse cases for the report. | +| businessOverview | Overview | Individual business overview for the report. | | date | string | Date of the model. | | managementSummary | string | Individual management summary for the report. | | questions | Question[] | Custom questions for the report. | | securityRequirements | SecurityRequirement[] | Custom security requirements for the report. | +| technicalOverview | Overview | Individual technical overview for the report. | | title | string | Title of the model. | --- @@ -2568,6 +2592,18 @@ Custom abuse cases for the report. --- +##### `businessOverview`Optional + +```typescript +public readonly businessOverview: Overview; +``` + +- *Type:* Overview + +Individual business overview for the report. + +--- + ##### `date`Optional ```typescript @@ -2616,6 +2652,18 @@ Custom security requirements for the report. --- +##### `technicalOverview`Optional + +```typescript +public readonly technicalOverview: Overview; +``` + +- *Type:* Overview + +Individual technical overview for the report. + +--- + ##### `title`Optional ```typescript @@ -2667,6 +2715,45 @@ public readonly justification: string; --- +### OverviewProps + +#### Initializer + +```typescript +import { OverviewProps } from 'cdktg' + +const overviewProps: OverviewProps = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| description | string | *No description.* | +| images | Image[] | *No description.* | + +--- + +##### `description`Required + +```typescript +public readonly description: string; +``` + +- *Type:* string + +--- + +##### `images`Optional + +```typescript +public readonly images: Image[]; +``` + +- *Type:* Image[] + +--- + ### ProjectProps #### Initializer @@ -4176,6 +4263,67 @@ public readonly vpn: boolean; --- +### Image + +#### Initializers + +```typescript +import { Image } from 'cdktg' + +new Image(filePath: string, title: string) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| filePath | string | *No description.* | +| title | string | *No description.* | + +--- + +##### `filePath`Required + +- *Type:* string + +--- + +##### `title`Required + +- *Type:* string + +--- + + + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| filePath | string | *No description.* | +| title | string | *No description.* | + +--- + +##### `filePath`Required + +```typescript +public readonly filePath: string; +``` + +- *Type:* string + +--- + +##### `title`Required + +```typescript +public readonly title: string; +``` + +- *Type:* string + +--- + + ### InScope #### Initializers @@ -4474,6 +4622,60 @@ public readonly justification: string; --- +### Overview + +#### Initializers + +```typescript +import { Overview } from 'cdktg' + +new Overview(props: OverviewProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| props | OverviewProps | *No description.* | + +--- + +##### `props`Required + +- *Type:* OverviewProps + +--- + + + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| description | string | *No description.* | +| images | Image[] | *No description.* | + +--- + +##### `description`Required + +```typescript +public readonly description: string; +``` + +- *Type:* string + +--- + +##### `images`Optional + +```typescript +public readonly images: Image[]; +``` + +- *Type:* Image[] + +--- + + ### Risk #### Initializers diff --git a/src/author.ts b/src/author.ts index b35c8d8..77245cd 100644 --- a/src/author.ts +++ b/src/author.ts @@ -2,6 +2,7 @@ export interface AuthorProps { readonly name: string; readonly homepage?: string; } + export class Author { public readonly name: string; public readonly homepage?: string; diff --git a/src/index.ts b/src/index.ts index e757fb7..49a7e23 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ export * from "./communication"; export * from "./data-asset"; export * from "./manifest"; export * from "./model"; +export * from "./overview"; export * from "./project"; export * from "./scope"; export * from "./security-requirement"; diff --git a/src/model.ts b/src/model.ts index f99b24a..c9cadb8 100644 --- a/src/model.ts +++ b/src/model.ts @@ -3,6 +3,7 @@ import { AbuseCase } from "./abuse-case"; import { Author } from "./author"; import { DataAsset } from "./data-asset"; +import { Overview } from "./overview"; import { RiskCategory } from "./risk-category"; import { RiskTracking, RiskTrackingProps } from "./rist-tracking"; import { SecurityRequirement } from "./security-requirement"; @@ -50,6 +51,16 @@ export interface ModelProps { */ readonly businessCriticality: BusinessCriticality; + /** + * Individual business overview for the report + */ + readonly businessOverview?: Overview; + + /** + * Individual technical overview for the report + */ + readonly technicalOverview?: Overview; + /** * Custom questions for the report */ @@ -96,6 +107,8 @@ export class Model extends Construct { public readonly date?: string; public readonly author: Author; public readonly managementSummary?: string; + public readonly businessOverview?: Overview; + public readonly technicalOverview?: Overview; public readonly businessCriticality: BusinessCriticality; public synthesizer: IModelSynthesizer; @@ -119,6 +132,17 @@ export class Model extends Construct { this.managementSummary = props.managementSummary; this.businessCriticality = props.businessCriticality; + this.businessOverview = props.businessOverview; + if ( + this.businessOverview && + this.businessOverview.images && + this.businessOverview.images.length > 0 + ) { + this.businessOverview.images.forEach((i) => i._bind(this)); + } + + this.technicalOverview = props.technicalOverview; + this.questions = new Map(); props.questions?.forEach((q) => { this.addQuestion(q.text, q.answer); @@ -246,6 +270,8 @@ export class Model extends Construct { data: this.date, author: this.author._toThreagile(), management_summary_comment: this.managementSummary, + business_overview: this.businessOverview?._toThreagile(), + technical_overview: this.technicalOverview?._toThreagile(), business_criticality: this.businessCriticality, questions: Object.fromEntries(this.questions), abuse_cases: Object.fromEntries(this.abuseCases), diff --git a/src/overview.ts b/src/overview.ts new file mode 100644 index 0000000..d74018d --- /dev/null +++ b/src/overview.ts @@ -0,0 +1,58 @@ +import * as path from "path"; +import { Construct } from "constructs"; + +import { Annotations } from "./annotations"; + +export class Image { + constructor( + public readonly filePath: string, + public readonly title: string + ) {} + + /** + * @internal + */ + public _bind(scope: Construct) { + const extension = path.extname(this.filePath); + + if (![".jpeg", ".jpg", ".png", ".gif"].includes(extension)) { + Annotations.of(scope).addWarning( + `Unsupported file extension. Image "${this.filePath}" may be ignored.` + ); + } + } + + /** + * @internal + */ + public _toThreagile() { + return { + [this.filePath]: this.title, + }; + } +} + +export interface OverviewProps { + readonly description: string; + readonly images?: Image[]; +} + +export class Overview { + public readonly description: string; + public readonly images?: Image[]; + + constructor(props: OverviewProps) { + this.description = props.description; + this.images = props.images; + } + + /** + * @internal + */ + public _toThreagile() { + return { + description: this.description, + images: this.images?.map((i) => i._toThreagile()), + }; + } +}