Repository: OWASP/threat-dragon
Pull request #479 (2022-08-09 12:06:24)

Fix some multi line issues
**Summary**
<!--
What existing issue does the pull request solve?
Please provide enough information so that others can review your pull request
-->
This fixes some multi line display issues like as follows:
1. When you review the report, `mitigations` inside of table don't support multi-line.
2. When you print the analyzed report out , `High level system description` and table under the diagram don't support it.

It's related with https://github.com/OWASP/threat-dragon/issues/468

**Description for the changelog**
<!--
A short (one line) summary that describes the changes in this
pull request for inclusion in the change log
If this is a bug fix, your description sahould include "fixes #xxxx", or
"closes #xxxx", where #xxxx is the issue number
-->
I added CSS for the issue to fix.

**Other info**
<!--
Thanks for submitting a pull request!
Please make sure you read our contributing guidelines;
https://github.com/OWASP/threat-dragon/blob/main/CONTRIBUTING.md
-->



Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a33b116f..6a9c8532 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,7 +9,7 @@ The [roadmap for version 2.0](https://owasp.org/www-project-threat-dragon/#div-r
 sets out what is needed to get to the new version of Threat Dragon, and we are looking for help and contributions.
 
 When contributing:
-* see if there is [already an issue](https://github.com/OWASP/threat-dragon/issues) for what you want to do
+* see if there is [already an issue](https://github.com/OWASP/threat-dragon/issues) for wehat you want to do
 * follow our [Code of Conduct](CODE_OF_CONDUCT.md)
 * get started by following the [developer notes](https://www.threatdragon.com/docs/development/local.html)
 
diff --git a/docs/development/env.md b/docs/development/env.md
index 65e7bc90..59318eb9 100644
--- a/docs/development/env.md
+++ b/docs/development/env.md
@@ -170,7 +170,7 @@ ___
 | LOG_MAX_FILE_SIZE | Maximum size of the back-end express server log file, in MB | `24` |
 | NODE_ENV | The node environment, typically `test`, `production` or `development`.  The 'secure' cookie flag is set only if running in `production` mode | |
 | PORT | Defines the listening port for Threat Dragon's server, and used by Heroku | `3000`|
-| SERVER_API_PROTOCOL | The protocol used between Threat Dragon's server and frontend, used by Heroku: `http` / `https` | `https` |
+| SERVER_API_PROTOCOL | The protocol used between Threat Dragon's server and frontend, used by Heroku (http/https) | `http` |
 
 {:.table .table-striped}
 | Back-end specific variables | Description | Default |
diff --git a/docs/development/internationalization.md b/docs/development/internationalization.md
index a740162a..7c3f63c1 100644
--- a/docs/development/internationalization.md
+++ b/docs/development/internationalization.md
@@ -8,9 +8,7 @@ group: Internationalization
 
 ## [OWASP](https://www.owasp.org) Threat Dragon
 
-Internationalization is enabled by [vue-i18n](https://kazupon.github.io/vue-i18n/).
-At the time of writing, there are not any translations available.
-Hopefully this feature enables our community members to translate the application to new languages so it can be used by more people.
+Internationalization is enabled by [vue-i18n](https://kazupon.github.io/vue-i18n/).  At the time of writing, there are not any translations available.  Hopefully this feature enables our community members to translate the application to new languages so it can be used by more people.
 
 To add a new language:
 - Add a new file with the locale as the name (eg "de" or "en") in the `src/i18n` directory
@@ -18,4 +16,4 @@ To add a new language:
 - Import your file to `src/i18n/index.js` and add it to the `messages` object in the `get` method
 - Choose your new locale from the dropdown to test your translations
 
-By default, if a translation key cannot be found, it will fall-back to the default locale (`en`)
+By default, if a translation key cannot be found, it will fall-back to the default locale (`en`)
\ No newline at end of file
diff --git a/docs/home/about/contributing.md b/docs/home/about/contributing.md
index 16e0afaa..a6bc5b14 100644
--- a/docs/home/about/contributing.md
+++ b/docs/home/about/contributing.md
@@ -16,24 +16,6 @@ Pull requests, feature requests, bug reports and feedback of any kind are very w
 We are trying to keep the test coverage relatively high, so please try to update tests in any PRs.
 There are some [developer notes]({{ '/development/local.html' | relative_url }}) to help you get started with this project.
 
-### Quick start
-Clone and install the Threat Dragon repo:
-
-```
-git clone git@github.com:OWASP/threat-dragon.git
-cd threat-dragon
-pnpm install
-```
-
-After making any changes be sure to test them:
-
-```
-npm start
-npm test
-npm run test:vue
-```
-
-
 ### Vulnerability disclosure
 
 If you find a vulnerability in this project please let us know ASAP and we will fix it as a priority.
diff --git a/package.json b/package.json
index da669734..e38edcc0 100644
--- a/package.json
+++ b/package.json
@@ -19,15 +19,14 @@
         "postinstall": "cd td.server && pnpm install && cd ../td.vue && pnpm install",
         "start": "npm-run-all build:vue build:server start:server start:site",
         "start:desktop": "cd td.vue && npm run electron:serve",
-        "start:server": "cd td.server && npm run start:serve",
-        "start:site": "cd td.vue && npm run start:serve",
+        "start:server": "cd td.server && npm run start:dev",
+        "start:site": "cd td.vue && npm run start:dev",
         "stop": "npm-run-all stop:site stop:server",
-        "stop:server": "cd td.server && npm run stop:serve",
-        "stop:site": "cd td.vue && npm run stop:serve",
+        "stop:server": "cd td.server && npm run stop:dev",
+        "stop:site": "cd td.vue && npm run stop:dev",
         "test": "npm-run-all build pretest test:site test:server",
-        "test:server": "cd td.server && npm run test:unit",
-        "test:site": "cd td.vue && npm run test:unit",
-        "test:vue": "cd td.vue && npm run test:vue"
+        "test:server": "cd td.server && npm test",
+        "test:site": "cd td.vue && npm run test:unit"
     },
     "keywords": [
         "threat dragon",
diff --git a/td.server/package.json b/td.server/package.json
index 2c1e3055..1e2fa0bb 100644
--- a/td.server/package.json
+++ b/td.server/package.json
@@ -8,8 +8,8 @@
     "codecov": "echo 'Disabled for now: codecov'",
     "dev": "nodemon dev.js --exec babel-node",
     "start": "echo 'Please run the start command from the root of this repository' && exit 1",
-    "start:serve": "pm2 --name td.server start 'nodemon dev.js --exec babel-node'",
-    "stop:serve": "pm2 delete td.server",
+    "start:dev": "pm2 --name td.server start 'nodemon dev.js --exec babel-node'",
+    "stop:dev": "pm2 delete td.server",
     "transpile": "babel ./src --out-dir dist",
     "pretest": "npm run lint",
     "preinstall": "npx only-allow pnpm",
diff --git a/td.server/src/config/routes.config.js b/td.server/src/config/routes.config.js
index 36e70f6d..8925930a 100644
--- a/td.server/src/config/routes.config.js
+++ b/td.server/src/config/routes.config.js
@@ -2,7 +2,7 @@
 
 import auth from '../controllers/auth.js';
 import bearer from './bearer.config.js';
-import healthcheck from '../controllers/healthz.js';
+import healthcheck from '../controllers/healthcheck.js';
 import homeController from '../controllers/homecontroller.js';
 import threatmodelController from '../controllers/threatmodelcontroller.js';
 
diff --git a/td.server/src/controllers/auth.js b/td.server/src/controllers/auth.js
index 43db5e00..bb731373 100644
--- a/td.server/src/controllers/auth.js
+++ b/td.server/src/controllers/auth.js
@@ -64,9 +64,9 @@ const logout = (req, res) => responseWrapper.sendResponse(() => {
             // If this happens, it could be a client error, or it could be
             // something more nefarious. 
             return '';
+        } else {
+            tokenRepo.remove(refreshToken);
         }
-
-        tokenRepo.remove(refreshToken);
         return '';
     } catch (e) {
         logger.error(e);
diff --git a/td.server/src/controllers/healthcheck.js b/td.server/src/controllers/healthcheck.js
new file mode 100644
index 00000000..2b55c58c
--- /dev/null
+++ b/td.server/src/controllers/healthcheck.js
@@ -0,0 +1,12 @@
+import loggerHelper from '../helpers/logger.helper.js';
+
+const logger = loggerHelper.get('controllers/healthcheck.js');
+
+const healthz = (req, res) => {
+    logger.debug('API healthz request: ' + req);
+    return res.send(true);
+};
+
+export default {
+    healthz
+};
diff --git a/td.server/src/controllers/healthz.js b/td.server/src/controllers/healthz.js
deleted file mode 100644
index 24fe1af1..00000000
--- a/td.server/src/controllers/healthz.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// health-check endpoint for applications
-
-const healthz = (req, res) => {
-    const data = {
-        uptime: process.uptime(),
-        message: 'OK',
-        date: new Date()
-    };
-
-    return res.status(200).send(data);
-};
-
-export default {
-    healthz
-};
diff --git a/td.server/src/healthcheck.js b/td.server/src/healthcheck.js
index f17b81c8..5420a397 100644
--- a/td.server/src/healthcheck.js
+++ b/td.server/src/healthcheck.js
@@ -1,22 +1,16 @@
-import env from 'env/Env.js';
-import loggerHelper from 'helpers/logger.helper.js';
-
-const logger = loggerHelper.get('healthcheck.js');
+/* eslint-disable no-console */
 const http = require('http');
 
-const req = (env.get().config.SERVER_API_PROTOCOL || 'https') + '://localhost:' + (env.get().config.PORT || '3000') + '/healthz';
-
-http.get(req, (res) => {
+http.get('http://localhost:3000/healthz', (res) => {
     const { statusCode } = res;
-    logger.debug('Health check request: ' + req);
     
     if (statusCode !== 200) {
-        logger.error(`Healthcheck failure: invalid status code: ${statusCode}`);
+        console.error(`Healthcheck failure: invalid status code: ${statusCode}`);
         process.exit(1);
     }
 
     process.exit(0);
 }).on('error', (e) => {
-    logger.error(`Healthcheck failure: ${e.message}`);
+    console.error(`Healthcheck failure: ${e.message}`);
     process.exit(1);
 });
diff --git a/td.vue/package.json b/td.vue/package.json
index 30b4eae4..5956db48 100644
--- a/td.vue/package.json
+++ b/td.vue/package.json
@@ -6,16 +6,15 @@
   "scripts": {
     "preinstall": "npx only-allow pnpm",
     "codecov": "echo 'Disabled for now: codecov'",
-    "dev": "vue-cli-service serve --port 8080",
+    "dev": "vue-cli-service serve",
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build --no-unsafe-inline",
     "electron:build": "vue-cli-service electron:build",
     "electron:serve": "vue-cli-service electron:serve",
     "postinstall": "electron-builder install-app-deps",
     "postuninstall": "electron-builder install-app-deps",
-    "start": "echo 'Please run the start command from the root of this repository' && exit 1",
-    "start:serve": "pm2 --name td.vue start 'vue-cli-service serve'",
-    "stop:serve": "pm2 delete td.vue",
+    "start:dev": "pm2 --name td.vue start 'vue-cli-service serve'",
+    "stop:dev": "pm2 delete td.vue",
     "test:unit": "vue-cli-service test:unit",
     "test:e2e": "vue-cli-service test:e2e",
     "test:e2e:local": "vue-cli-service test:e2e -C cypress.local.json --url http://localhost:8080/",
@@ -24,7 +23,6 @@
     "test:e2e-smokes": "browserstack-cypress run --cf browserstack.smokes.json --sync",
     "test:e2e-smokes:local": "vue-cli-service test:e2e -C cypress.smokes.local.json --url http://localhost:8080/",
     "test:e2e-nightly": "browserstack-cypress run --cf browserstack.nightly.json --sync",
-    "test:vue": "vue-cli-service test:e2e --headless",
     "lint": "vue-cli-service lint"
   },
   "description": "OWASP Threat Dragon - a free, open source threat modeling tool",
diff --git a/td.vue/src/components/printed-report/ExecutiveSummary.vue b/td.vue/src/components/printed-report/ExecutiveSummary.vue
index 0991284c..1aa21c68 100644
--- a/td.vue/src/components/printed-report/ExecutiveSummary.vue
+++ b/td.vue/src/components/printed-report/ExecutiveSummary.vue
@@ -51,6 +51,7 @@
 .page {
     display: flex;
     flex-direction: column;
+    white-space: pre-wrap;
 }
 </style>
 
diff --git a/td.vue/src/components/printed-report/ReportEntity.vue b/td.vue/src/components/printed-report/ReportEntity.vue
index 98fbf9dd..9ff5eb7f 100644
--- a/td.vue/src/components/printed-report/ReportEntity.vue
+++ b/td.vue/src/components/printed-report/ReportEntity.vue
@@ -35,6 +35,7 @@
 .report-box {
     display: flex;
     flex-direction: column;
+    white-space: pre-wrap;
 }
 
 .entity-title {
@@ -46,6 +47,7 @@
 
 .entity-description {
     padding: 15px;
+    white-space: pre-wrap;
 }
 </style>
 
diff --git a/td.vue/src/components/report/ReportEntity.vue b/td.vue/src/components/report/ReportEntity.vue
index 557356be..143f34a4 100644
--- a/td.vue/src/components/report/ReportEntity.vue
+++ b/td.vue/src/components/report/ReportEntity.vue
@@ -29,6 +29,7 @@
 <style lang="scss" scoped>
 .td-threat-data {
     width: 99%;
+    white-space: pre-wrap;
 }
 </style>
 


Test patch:
diff --git a/docs/development/testing/e2e.md b/docs/development/testing/e2e.md
index 067a05d3..c38e6cb0 100644
--- a/docs/development/testing/e2e.md
+++ b/docs/development/testing/e2e.md
@@ -25,10 +25,7 @@ group: Testing
 </div>
 
 ## Running E2E Tests
-End to end testing is done using [cypress](https://www.cypress.io/),
-and the tests are defined in the `td.vue/tests/e2e` directory.
-
-A quick test can be done from the root directory, or the `td.vue` directory, using command `npm run test:vue` . 
+End to end testing is done using [cypress](https://www.cypress.io/), and lives in the `td.vue/tests/e2e` directory.
 
 ### Run test:e2e
 To run the e2e tests locally, navigate to the `td.vue` directory and run:
diff --git a/td.server/test/config/routes.config.spec.js b/td.server/test/config/routes.config.spec.js
index 642938b5..a1bad931 100644
--- a/td.server/test/config/routes.config.spec.js
+++ b/td.server/test/config/routes.config.spec.js
@@ -4,7 +4,7 @@ import sinon from 'sinon';
 
 import auth from '../../src/controllers/auth.js';
 import bearer from '../../src/config/bearer.config.js';
-import healthcheck from '../../src/controllers/healthz.js';
+import healthcheck from '../../src/controllers/healthcheck.js';
 import homeController from '../../src/controllers/homecontroller.js';
 import { getMockApp } from '../mocks/express.mocks.js';
 import routeConfig from '../../src/config/routes.config.js';
diff --git a/td.server/test/controllers/healthcheck.spec.js b/td.server/test/controllers/healthcheck.spec.js
index dea2b354..1aaffa93 100644
--- a/td.server/test/controllers/healthcheck.spec.js
+++ b/td.server/test/controllers/healthcheck.spec.js
@@ -2,9 +2,9 @@ import { expect } from 'chai';
 import sinon from 'sinon';
 
 import { getMockResponse } from '../mocks/express.mocks.js';
-import healthcheck from '../../src/controllers/healthz.js';
+import healthcheck from '../../src/controllers/healthcheck.js';
 
-describe('controllers/healthz.js', () => {
+describe('controllers/healthcheck.js', () => {
     let mockResponse;
 
     beforeEach(() => {
@@ -13,6 +13,6 @@ describe('controllers/healthz.js', () => {
     });
 
     it('sends a true response', () => {
-        expect(mockResponse.status).to.have.been.calledWith(200);
+        expect(mockResponse.send).to.have.been.calledWith(true);
     });
 });