From 7e373950218bf9885ee567934761225a3fbd845b Mon Sep 17 00:00:00 2001 From: gioboa Date: Mon, 25 Feb 2019 13:15:34 +0100 Subject: [PATCH] v 0.14.1 - fix: added custom make request with cartificate params - fix: added additional certificate setting --- CHANGELOG.md | 6 ++++++ README.md | 2 ++ package-lock.json | 2 +- package.json | 30 +++++++++++++++++++++++++- src/http/jira-instance-patch.ts | 37 +++++++++++++++++++++++++++++++-- src/shared/constants.ts | 3 ++- 6 files changed, 75 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d22e49..a3311db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.14.1 + +### Bug Fixes + +- added additional certificate settings + ## 0.14.0 ### Features diff --git a/README.md b/README.md index f2c2a31..90372f1 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ After setup you have to set the working project, you can click on status-bar ico The extension store credentials in VS Code settings.

**n.b:** the extension store the password in VS Code internal storage so it's safe and hidden. :wink:
+- **Additional Certificate**
+ Additional certificate settings - **Additional Statuses**
Additional custom statuses, used for manage some Jira wrong behavior - **Base Url**
diff --git a/package-lock.json b/package-lock.json index 0249eb8..b5d2d7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jira-plugin", - "version": "0.13.2", + "version": "0.14.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e4c2cee..512ee5f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jira-plugin", "displayName": "Jira Plugin", "description": "Jira integration for vscode", - "version": "0.14.0", + "version": "0.14.1", "publisher": "gioboa", "icon": "images/icons/icon.png", "galleryBanner": { @@ -125,6 +125,34 @@ "type": "boolean", "description": "You can manage your Jira unread notifications inside VsCode notification center (n.b: only new Jira versions has notifications)", "default": false + }, + "jira-plugin.additionalCertificate": { + "type": "object", + "title": "Additional certificate settings", + "properties": { + "ca": { + "type": "array", + "description": "CA full files path (n.b: necessary only if the server uses a self-signed certificate)", + "items": { + "type": "string" + } + }, + "cert": { + "type": "string", + "description": "Certificate authority full file path (n.b: necessary only if the server requires client certificate authentication)" + }, + "key": { + "type": "string", + "description": "Private key full file path (n.b: necessary only if the server requires client certificate authentication)" + } + }, + "default": { + "ca": [ + "" + ], + "cert": "", + "key": "" + } } } }, diff --git a/src/http/jira-instance-patch.ts b/src/http/jira-instance-patch.ts index cb39ee3..2656a78 100644 --- a/src/http/jira-instance-patch.ts +++ b/src/http/jira-instance-patch.ts @@ -1,3 +1,7 @@ +import { readFileSync } from 'fs'; +import { configuration, logger } from '../services'; +import { CONFIG } from '../shared/constants'; + const cleanOptions = (options: any): void => { if (!!options.headers && Object.keys(options.headers).length === 0) { delete options.header; @@ -34,13 +38,42 @@ export const patchJiraInstance = (jiraInstance: any) => { }; jiraInstance.project.customRequest = customRequest; - const originalRequestLib = jiraInstance.requestLib; + jiraInstance.originalRequestLib = jiraInstance.requestLib; const customRequestLib = (options: any) => { if (!!options && !!options.headers && options.headers.deleteAuth) { delete options.auth; delete options.headers.deleteAuth; } - return originalRequestLib(options); + return jiraInstance.originalRequestLib(options); }; jiraInstance.requestLib = customRequestLib; + + let certificate: any; + try { + const caSettings = configuration.get(CONFIG.ADDITIONAL_CERTIFICATE); + if (!!caSettings.ca || !!caSettings.cert || !!caSettings.key) { + certificate = { + ca: !!caSettings.ca && caSettings.ca.every((c: string) => !!c) ? caSettings.ca.map((c: string) => readFileSync(c)) : undefined, + cert: !!caSettings.cert ? readFileSync(caSettings.cert) : undefined, + key: !!caSettings.key ? readFileSync(caSettings.key) : undefined + }; + if (!!certificate.cert && !!certificate.key) { + certificate.requestCert = true; + } + } + } catch (e) { + certificate = undefined; + logger.printErrorMessageInOutputAndShowAlert('Invalid certificate settings'); + } + jiraInstance.originalMakeRequest = jiraInstance.makeRequest; + const customMakeRequest = (options: any, callback: any, successString: any) => { + if (!!certificate) { + options = { + ...options, + ...certificate + }; + } + return jiraInstance.originalMakeRequest(options, callback, successString); + }; + jiraInstance.makeRequest = customMakeRequest; }; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 82b6156..eebd479 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -14,7 +14,8 @@ export const CONFIG = { GIT_INTEGRATION_ENABLED: 'gitIntegration', NUMBER_ISSUES_IN_LIST: 'numberOfIssuesInList', DEFAULT_JQL_SEARCH: 'defaultJqlSearch', - CHECK_FOR_NOTIFICATIONS_ENABLE: 'enableCheckForNotifications' + CHECK_FOR_NOTIFICATIONS_ENABLE: 'enableCheckForNotifications', + ADDITIONAL_CERTIFICATE: 'additionalCertificate' }; // all the tracking time mode