Skip to content

Commit 52ad24b

Browse files
authored
TLS v1.2 fixes and packaging updates (#29)
* Force TLSv1.2 * TLS update to force TLS 1.2 and fixes * Remove comments
1 parent bd97acf commit 52ad24b

File tree

9 files changed

+79
-59
lines changed

9 files changed

+79
-59
lines changed

Tasks/emailReportTask/EmailSender.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,35 @@ const nodemailer = require("nodemailer");
88

99
export class EmailSender implements IReportSender {
1010
public async sendReportAsync(report: Report, htmlReportMessage: string, mailConfiguration: MailConfiguration): Promise<boolean> {
11-
1211
const mailAddressViewModel = new MailAddressViewModel(report, mailConfiguration);
1312

14-
let transporter = nodemailer.createTransport({
15-
host: mailConfiguration.$smtpConfig.$smtpHost,
16-
port: 587,
17-
tls: mailConfiguration.$smtpConfig.$enableTLS,
18-
auth: {
19-
user: mailConfiguration.$smtpConfig.$userName,
20-
pass: mailConfiguration.$smtpConfig.$password
21-
}
22-
});
13+
let transporter: any;
14+
if(mailConfiguration.$smtpConfig.$enableTLS) {
15+
transporter = nodemailer.createTransport({
16+
host: mailConfiguration.$smtpConfig.$smtpHost,
17+
port: 587,
18+
tls: {
19+
maxVersion: 'TLSv1.2',
20+
minVersion: 'TLSv1.2',
21+
rejectUnauthorized: false
22+
},
23+
requireTLS: true,
24+
auth: {
25+
user: mailConfiguration.$smtpConfig.$userName,
26+
pass: mailConfiguration.$smtpConfig.$password
27+
}
28+
});
29+
}
30+
else {
31+
transporter = nodemailer.createTransport({
32+
host: mailConfiguration.$smtpConfig.$smtpHost,
33+
port: 587,
34+
auth: {
35+
user: mailConfiguration.$smtpConfig.$userName,
36+
pass: mailConfiguration.$smtpConfig.$password
37+
}
38+
});
39+
}
2340

2441
try {
2542
const result = await this.sendMailAsync(transporter, mailAddressViewModel, mailConfiguration, htmlReportMessage);

Tasks/emailReportTask/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { TelemetryLogger } from "./telemetry/TelemetryLogger";
1111

1212
async function run(): Promise<void> {
1313
try {
14+
15+
console.log('Node Version: ' + process.version);
16+
1417
const configProvider = new ConfigurationProvider();
1518
const reportConfiguration = new ReportConfiguration(configProvider);
1619
const reportProvider = new ReportProvider(new DataProviderFactory(configProvider.getPipelineConfiguration()));

Tasks/emailReportTask/providers/pipeline/BuildDataProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class BuildDataProvider implements IDataProvider {
7474
return new PhaseModel(
7575
phase.name,
7676
jobModels,
77-
phase.result.toString(),
77+
isNullOrUndefined(phase.result) ? "Unknown" : phase.result.toString(),
7878
this.getOrder(phase));
7979
});
8080
return phaseModels;

Tasks/emailReportTask/task.dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 2,
16-
"Patch": 116
16+
"Patch": 200
1717
},
1818
"groups": [
1919
{

Tasks/emailReportTask/task.prod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
],
1212
"author": "Microsoft Corporation",
1313
"version": {
14-
"Major": 2,
15-
"Minor": 0,
16-
"Patch": 3
14+
"Major": 1,
15+
"Minor": 1,
16+
"Patch": 2
1717
},
1818
"groups": [
1919
{

Tasks/emailReportTask/tests/__e_to_e_tests__/InvokeTest.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ export class ReportCreatorWrapper implements IHTMLReportCreator {
5757
export class MockConfigProvider implements IConfigurationProvider {
5858

5959
getPipelineConfiguration(): PipelineConfiguration {
60-
return new PipelineConfiguration(PipelineType.Release, 13587876, "AzureDevOps", "AzureDevOps", 156109317, 9462, false, "https://dev.azure.com/mseng/", accessKey);
60+
return new PipelineConfiguration(PipelineType.Release, 13942411, "AzureDevOps", "AzureDevOps", 160977787, 9462, false, "https://dev.azure.com/{account}/", accessKey);
6161
}
6262

6363
getMailConfiguration(): MailConfiguration {
6464
return new MailConfiguration("[{environmentStatus}] {passPercentage} tests passed",
6565
new RecipientsConfiguration("[email protected]", false, false, false, false),
6666
new RecipientsConfiguration("", false, false, false, false),
67-
new SmtpConfiguration(smtpUser, smtpPassword, "smtp.live.com", true), "test.com");
67+
new SmtpConfiguration(smtpUser, smtpPassword, "smtp.live.com", true), "test.m");
6868
}
6969

7070
getReportDataConfiguration(): ReportDataConfiguration {
@@ -73,12 +73,13 @@ export class MockConfigProvider implements IConfigurationProvider {
7373
}
7474

7575
getSendMailCondition(): SendMailCondition {
76-
return SendMailCondition.OnNewFailuresOnly;
76+
return SendMailCondition.Always;
7777
}
7878
}
7979

8080
async function run(): Promise<void> {
8181

82+
console.log('Node Version: ' + process.version);
8283
const configProvider = new MockConfigProvider();
8384
const reportConfiguration = new ReportConfiguration(configProvider);
8485
TelemetryLogger.LogTaskConfig(reportConfiguration);
@@ -94,4 +95,4 @@ if (isNullOrUndefined(accessKey)) {
9495
console.error("Set Environment Vars for AccessKey.");
9596
} else {
9697
run();
97-
}
98+
}

Tasks/emailReportTask/vss-extension.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "EmailReportExtension",
44
"name": "Email Report Extension",
5-
"version": "1.0.6",
5+
"version": "1.1.0",
66
"publisher": "epsteam",
77
"targets": [
88
{
@@ -37,7 +37,7 @@
3737
},
3838
"contributions": [
3939
{
40-
"id": "c4ffd380-3a3b-4fa6-b02a-00ee18afe1f4",
40+
"id": "EmailReport",
4141
"type": "ms.vss-distributed-task.task",
4242
"targets": [
4343
"ms.vss-distributed-task.tasks"

commands/package.js

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,37 @@ exec(npmInstallCommand, function (error) {
2525
console.log(`NPM Install Error: ${error}`);
2626
} else {
2727
console.log("NPM Install Done");
28-
}
29-
});
30-
31-
var imagesDir = path.resolve(common.TaskSrcDir, "images");
32-
if (fs.existsSync(imagesDir)) {
33-
var files = fs.readdirSync(imagesDir);
34-
//listing all files using forEach
35-
files.forEach(function (file) {
36-
// Do whatever you want to do with the file
37-
if (file.endsWith(".png")) {
38-
common.CopyFile(imagesDir, file, `${common.ExtensionOutDir}/images/`);
28+
29+
var imagesDir = path.resolve(common.TaskSrcDir, "images");
30+
if (fs.existsSync(imagesDir)) {
31+
var files = fs.readdirSync(imagesDir);
32+
//listing all files using forEach
33+
files.forEach(function (file) {
34+
// Do whatever you want to do with the file
35+
if (file.endsWith(".png")) {
36+
common.CopyFile(imagesDir, file, `${common.ExtensionOutDir}/images/`);
37+
}
38+
});
39+
40+
if(fs.existsSync(path.resolve(imagesDir, "icon.png"))) {
41+
common.CopyFile(imagesDir, "icon.png", `${common.TaskOutDir}`);
42+
}
3943
}
40-
});
41-
42-
if(fs.existsSync(path.resolve(imagesDir, "icon.png"))) {
43-
common.CopyFile(imagesDir, "icon.png", `${common.TaskOutDir}`);
44-
}
45-
}
46-
47-
// Package extension only for prod
48-
if (common.ReleaseType.toLowerCase() == "prod") {
49-
console.log(`Run command in ${common.ExtensionOutDir}: tfx extension create --root . --extension-id ${extensionId} --no-prompt`);
50-
process.chdir(common.ExtensionOutDir);
51-
var command = `tfx extension create --root . --extension-id ${extensionId} --no-prompt`;
52-
console.log(`Running: ${command}`);
53-
exec(command, function (error) {
54-
if (error) {
55-
console.log(`Package create error: ${error}`);
56-
} else {
57-
console.log("Package created. Upload the VSIX to Visual Studio Marketplace if you wish to publish the extension.");
44+
// Package extension only for prod
45+
if (common.ReleaseType.toLowerCase() == "prod") {
46+
console.log(`Run command in ${common.ExtensionOutDir}: tfx extension create --root . --extension-id ${extensionId} --no-prompt`);
47+
process.chdir(common.ExtensionOutDir);
48+
var command = `tfx extension create --root . --extension-id ${extensionId} --no-prompt`;
49+
console.log(`Running: ${command}`);
50+
exec(command, function (error) {
51+
if (error) {
52+
console.log(`Package create error: ${error}`);
53+
} else {
54+
console.log("Package created. Upload the VSIX to Visual Studio Marketplace if you wish to publish the extension.");
55+
console.log(`If you want to upload to AzureDevOps account directly, then Navigate to ${common.TaskOutDir} and run the tfx upload command on the desired azure devops account to upload task directly. Command: 'tfx login && tfx build tasks upload --task-path .'`);
56+
process.chdir(cwd);
57+
}
58+
});
5859
}
59-
});
60-
}
61-
console.log(`If you want to upload to AzureDevOps account directly, then Navigate to ${common.TaskOutDir} and run the tfx upload command on the desired azure devops account to upload task directly. Command: 'tfx login && tfx build tasks upload --task-path .'`);
62-
63-
process.chdir(cwd);
60+
}
61+
});

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"description": "",
55
"scripts": {
66
"test": "npm run jest",
7-
"build": "npm install --no-optional && npm run build:t1 && npm run build:t2",
8-
"build:t1": "npm run build:emailreport",
9-
"build:t2": "npm run build:prinsights",
7+
"prebuild": "npm install --no-optional",
8+
"build": "npm run prebuild && npm run build:emailreport && npm run build:prinsights",
9+
"build:t1": "npm run prebuild && npm run build:emailreport",
10+
"build:t2": "npm run prebuild && npm run build:prinsights",
1011
"pack:t1": "npm run clean && npm run build:t1 && npm run pack:emailreport",
1112
"pack:t2": "npm run clean && npm run build:t2 && npm run pack:prinsights",
1213
"e2e:t1": "npm run e2e:emailreport",
@@ -17,7 +18,7 @@
1718
"pack:prinsights": "node ./commands/package.js pullRequestInsights",
1819
"e2e:emailreport": "node js/emailReportExtension/emailReportTask/tests/__e_to_e_tests__/InvokeTest.js",
1920
"e2e:prinsights": "node js/pullRequestInsightsExtension/pullRequestInsightsTask/tests/__e_to_e_tests__/InvokeTest.js",
20-
"clean": "rimraf dist && rimraf node_modules"
21+
"clean": "rimraf dist"
2122
},
2223
"repository": {
2324
"type": "git",

0 commit comments

Comments
 (0)