azure-pipelines-task-lib 4.9.0 → 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 +1 -0
- package/package.json +1 -1
- package/task.d.ts +12 -0
- package/task.js +18 -1
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
|
//-----------------------------------------------------
|
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;
|
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.getPipelineFeature = 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
|
//
|