azure-pipelines-task-lib 4.8.2 → 4.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internal.d.ts +1 -0
- package/internal.js +12 -1
- package/mock-task.js +2 -0
- package/package.json +1 -1
- package/task.d.ts +21 -1
- package/task.js +39 -3
package/internal.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare enum IssueSource {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function _startsWith(str: string, start: string): boolean;
|
|
20
20
|
export declare function _endsWith(str: string, end: string): boolean;
|
|
21
|
+
export declare function _truncateBeforeSensitiveKeyword(str: string, sensitiveKeywordsPattern: RegExp): string;
|
|
21
22
|
export declare function _writeLine(str: string): void;
|
|
22
23
|
export declare function _setStdStream(stdStream: any): void;
|
|
23
24
|
export declare function _setErrStream(errStream: any): void;
|
package/internal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._exposeCertSettings = exports._exposeProxySettings = exports._normalizeSeparators = exports._isRooted = exports._getDirectoryName = exports._ensureRooted = exports._isUncPath = exports._loadData = exports._ensurePatternRooted = exports._getFindInfoFromPattern = exports._cloneMatchOptions = exports._legacyFindFiles_convertPatternToRegExp = exports._which = exports._checkPath = exports._exist = exports._debug = exports._error = exports._warning = exports._command = exports._getVariableKey = exports._getVariable = exports._loc = exports._setResourcePath = exports._setErrStream = exports._setStdStream = exports._writeLine = exports._endsWith = exports._startsWith = exports.IssueSource = exports._vault = exports._knownVariableMap = void 0;
|
|
3
|
+
exports._exposeCertSettings = exports._exposeProxySettings = exports._normalizeSeparators = exports._isRooted = exports._getDirectoryName = exports._ensureRooted = exports._isUncPath = exports._loadData = exports._ensurePatternRooted = exports._getFindInfoFromPattern = exports._cloneMatchOptions = exports._legacyFindFiles_convertPatternToRegExp = exports._which = exports._checkPath = exports._exist = exports._debug = exports._error = exports._warning = exports._command = exports._getVariableKey = exports._getVariable = exports._loc = exports._setResourcePath = exports._setErrStream = exports._setStdStream = exports._writeLine = exports._truncateBeforeSensitiveKeyword = exports._endsWith = exports._startsWith = exports.IssueSource = exports._vault = exports._knownVariableMap = void 0;
|
|
4
4
|
var fs = require("fs");
|
|
5
5
|
var path = require("path");
|
|
6
6
|
var os = require("os");
|
|
@@ -46,6 +46,17 @@ function _endsWith(str, end) {
|
|
|
46
46
|
return str.slice(-end.length) == end;
|
|
47
47
|
}
|
|
48
48
|
exports._endsWith = _endsWith;
|
|
49
|
+
function _truncateBeforeSensitiveKeyword(str, sensitiveKeywordsPattern) {
|
|
50
|
+
if (!str) {
|
|
51
|
+
return str;
|
|
52
|
+
}
|
|
53
|
+
var index = str.search(sensitiveKeywordsPattern);
|
|
54
|
+
if (index <= 0) {
|
|
55
|
+
return str;
|
|
56
|
+
}
|
|
57
|
+
return str.substring(0, index) + "...";
|
|
58
|
+
}
|
|
59
|
+
exports._truncateBeforeSensitiveKeyword = _truncateBeforeSensitiveKeyword;
|
|
49
60
|
//-----------------------------------------------------
|
|
50
61
|
// General Helpers
|
|
51
62
|
//-----------------------------------------------------
|
package/mock-task.js
CHANGED
|
@@ -27,6 +27,7 @@ module.exports.Platform = task.Platform;
|
|
|
27
27
|
module.exports.setStdStream = task.setStdStream;
|
|
28
28
|
module.exports.setErrStream = task.setErrStream;
|
|
29
29
|
module.exports.setResult = task.setResult;
|
|
30
|
+
module.exports.setSanitizedResult = task.setSanitizedResult;
|
|
30
31
|
//-----------------------------------------------------
|
|
31
32
|
// Loc Helpers
|
|
32
33
|
//-----------------------------------------------------
|
|
@@ -60,6 +61,7 @@ module.exports.getInput = task.getInput;
|
|
|
60
61
|
module.exports.getInputRequired = task.getInputRequired;
|
|
61
62
|
module.exports.getBoolInput = task.getBoolInput;
|
|
62
63
|
module.exports.getBoolFeatureFlag = task.getBoolFeatureFlag;
|
|
64
|
+
module.exports.getPipelineFeature = task.getPipelineFeature;
|
|
63
65
|
module.exports.getDelimitedInput = task.getDelimitedInput;
|
|
64
66
|
module.exports.filePathSupplied = task.filePathSupplied;
|
|
65
67
|
function getPathInput(name, required, check) {
|
package/package.json
CHANGED
package/task.d.ts
CHANGED
|
@@ -61,6 +61,18 @@ export declare const setErrStream: typeof im._setErrStream;
|
|
|
61
61
|
*/
|
|
62
62
|
export declare function setResult(result: TaskResult.Succeeded, message?: string, done?: boolean): void;
|
|
63
63
|
export declare function setResult(result: Exclude<TaskResult, 'Succeeded'>, message: string, done?: boolean): void;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the result of the task with sanitized message.
|
|
66
|
+
*
|
|
67
|
+
* @param result TaskResult enum of Succeeded, SucceededWithIssues, Failed, Cancelled or Skipped.
|
|
68
|
+
* @param message A message which will be logged as an error issue if the result is Failed. Message will be truncated
|
|
69
|
+
* before first occurence of wellknown sensitive keyword.
|
|
70
|
+
* @param done Optional. Instructs the agent the task is done. This is helpful when child processes
|
|
71
|
+
* may still be running and prevent node from fully exiting. This argument is supported
|
|
72
|
+
* from agent version 2.142.0 or higher (otherwise will no-op).
|
|
73
|
+
* @returns void
|
|
74
|
+
*/
|
|
75
|
+
export declare function setSanitizedResult(result: TaskResult, message: string, done?: boolean): void;
|
|
64
76
|
export declare const setResourcePath: typeof im._setResourcePath;
|
|
65
77
|
export declare const loc: typeof im._loc;
|
|
66
78
|
export declare const getVariable: typeof im._getVariable;
|
|
@@ -135,12 +147,20 @@ export declare function getInputRequired(name: string): string;
|
|
|
135
147
|
export declare function getBoolInput(name: string, required?: boolean): boolean;
|
|
136
148
|
/**
|
|
137
149
|
* Gets the value of an feature flag and converts to a bool.
|
|
138
|
-
*
|
|
150
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
139
151
|
* @param name name of the feature flag to get.
|
|
140
152
|
* @param defaultValue default value of the feature flag in case it's not found in env. (optional. Default value = false)
|
|
141
153
|
* @returns boolean
|
|
154
|
+
* @deprecated Don't use this for new development. Use getPipelineFeature instead.
|
|
142
155
|
*/
|
|
143
156
|
export declare function getBoolFeatureFlag(ffName: string, defaultValue?: boolean): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Gets the value of an task feature and converts to a bool.
|
|
159
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
160
|
+
* @param name name of the feature to get.
|
|
161
|
+
* @returns boolean
|
|
162
|
+
*/
|
|
163
|
+
export declare function getPipelineFeature(featureName: string): boolean;
|
|
144
164
|
/**
|
|
145
165
|
* Gets the value of an input and splits the value using a delimiter (space, comma, etc).
|
|
146
166
|
* Empty values are removed. This function is useful for splitting an input containing a simple
|
package/task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.execAsync = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getAgentMode = exports.getNodeMajorVersion = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.IssueSource = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
|
|
3
|
+
exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.execAsync = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getAgentMode = exports.getNodeMajorVersion = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getPipelineFeature = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setSanitizedResult = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.IssueSource = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
|
|
4
4
|
var shell = require("shelljs");
|
|
5
5
|
var childProcess = require("child_process");
|
|
6
6
|
var fs = require("fs");
|
|
@@ -81,6 +81,23 @@ function setResult(result, message, done) {
|
|
|
81
81
|
exports.command('task.complete', properties, message);
|
|
82
82
|
}
|
|
83
83
|
exports.setResult = setResult;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the result of the task with sanitized message.
|
|
86
|
+
*
|
|
87
|
+
* @param result TaskResult enum of Succeeded, SucceededWithIssues, Failed, Cancelled or Skipped.
|
|
88
|
+
* @param message A message which will be logged as an error issue if the result is Failed. Message will be truncated
|
|
89
|
+
* before first occurence of wellknown sensitive keyword.
|
|
90
|
+
* @param done Optional. Instructs the agent the task is done. This is helpful when child processes
|
|
91
|
+
* may still be running and prevent node from fully exiting. This argument is supported
|
|
92
|
+
* from agent version 2.142.0 or higher (otherwise will no-op).
|
|
93
|
+
* @returns void
|
|
94
|
+
*/
|
|
95
|
+
function setSanitizedResult(result, message, done) {
|
|
96
|
+
var pattern = /password|key|secret|bearer|authorization|token|pat/i;
|
|
97
|
+
var sanitizedMessage = im._truncateBeforeSensitiveKeyword(message, pattern);
|
|
98
|
+
setResult(result, sanitizedMessage, done);
|
|
99
|
+
}
|
|
100
|
+
exports.setSanitizedResult = setSanitizedResult;
|
|
84
101
|
//
|
|
85
102
|
// Catching all exceptions
|
|
86
103
|
//
|
|
@@ -240,10 +257,11 @@ function getBoolInput(name, required) {
|
|
|
240
257
|
exports.getBoolInput = getBoolInput;
|
|
241
258
|
/**
|
|
242
259
|
* Gets the value of an feature flag and converts to a bool.
|
|
243
|
-
*
|
|
260
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
244
261
|
* @param name name of the feature flag to get.
|
|
245
262
|
* @param defaultValue default value of the feature flag in case it's not found in env. (optional. Default value = false)
|
|
246
263
|
* @returns boolean
|
|
264
|
+
* @deprecated Don't use this for new development. Use getPipelineFeature instead.
|
|
247
265
|
*/
|
|
248
266
|
function getBoolFeatureFlag(ffName, defaultValue) {
|
|
249
267
|
if (defaultValue === void 0) { defaultValue = false; }
|
|
@@ -256,6 +274,24 @@ function getBoolFeatureFlag(ffName, defaultValue) {
|
|
|
256
274
|
return ffValue.toLowerCase() === "true";
|
|
257
275
|
}
|
|
258
276
|
exports.getBoolFeatureFlag = getBoolFeatureFlag;
|
|
277
|
+
/**
|
|
278
|
+
* Gets the value of an task feature and converts to a bool.
|
|
279
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
280
|
+
* @param name name of the feature to get.
|
|
281
|
+
* @returns boolean
|
|
282
|
+
*/
|
|
283
|
+
function getPipelineFeature(featureName) {
|
|
284
|
+
var variableName = im._getVariableKey("DistributedTask.Tasks." + featureName);
|
|
285
|
+
var featureValue = process.env[variableName];
|
|
286
|
+
if (!featureValue) {
|
|
287
|
+
exports.debug("Feature '" + featureName + "' not found. Returning false as default.");
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
var boolValue = featureValue.toLowerCase() === "true";
|
|
291
|
+
exports.debug("Feature '" + featureName + "' = '" + featureValue + "'. Processed as '" + boolValue + "'.");
|
|
292
|
+
return boolValue;
|
|
293
|
+
}
|
|
294
|
+
exports.getPipelineFeature = getPipelineFeature;
|
|
259
295
|
/**
|
|
260
296
|
* Gets the value of an input and splits the value using a delimiter (space, comma, etc).
|
|
261
297
|
* Empty values are removed. This function is useful for splitting an input containing a simple
|
|
@@ -708,7 +744,7 @@ function mkdirP(p) {
|
|
|
708
744
|
var testDir = p;
|
|
709
745
|
while (true) {
|
|
710
746
|
// validate the loop is not out of control
|
|
711
|
-
if (stack.length >= (process.env['TASKLIB_TEST_MKDIRP_FAILSAFE'] || 1000)) {
|
|
747
|
+
if (stack.length >= Number(process.env['TASKLIB_TEST_MKDIRP_FAILSAFE'] || 1000)) {
|
|
712
748
|
// let the framework throw
|
|
713
749
|
exports.debug('loop is out of control');
|
|
714
750
|
fs.mkdirSync(p);
|