Skip to content

Commit a68fa08

Browse files
committed
Update action following security fixes
1 parent a2998d5 commit a68fa08

File tree

1 file changed

+93
-21
lines changed

1 file changed

+93
-21
lines changed

dist/index.js

Lines changed: 93 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,32 @@ const windowsRelease = release => {
18751875
module.exports = windowsRelease;
18761876

18771877

1878+
/***/ }),
1879+
1880+
/***/ 82:
1881+
/***/ (function(__unusedmodule, exports) {
1882+
1883+
"use strict";
1884+
1885+
// We use any as a valid input type
1886+
/* eslint-disable @typescript-eslint/no-explicit-any */
1887+
Object.defineProperty(exports, "__esModule", { value: true });
1888+
/**
1889+
* Sanitizes an input into a string so it can be passed into issueCommand safely
1890+
* @param input input to sanitize into a string
1891+
*/
1892+
function toCommandValue(input) {
1893+
if (input === null || input === undefined) {
1894+
return '';
1895+
}
1896+
else if (typeof input === 'string' || input instanceof String) {
1897+
return input;
1898+
}
1899+
return JSON.stringify(input);
1900+
}
1901+
exports.toCommandValue = toCommandValue;
1902+
//# sourceMappingURL=utils.js.map
1903+
18781904
/***/ }),
18791905

18801906
/***/ 87:
@@ -1884,6 +1910,42 @@ module.exports = require("os");
18841910

18851911
/***/ }),
18861912

1913+
/***/ 102:
1914+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
1915+
1916+
"use strict";
1917+
1918+
// For internal use, subject to change.
1919+
var __importStar = (this && this.__importStar) || function (mod) {
1920+
if (mod && mod.__esModule) return mod;
1921+
var result = {};
1922+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1923+
result["default"] = mod;
1924+
return result;
1925+
};
1926+
Object.defineProperty(exports, "__esModule", { value: true });
1927+
// We use any as a valid input type
1928+
/* eslint-disable @typescript-eslint/no-explicit-any */
1929+
const fs = __importStar(__webpack_require__(747));
1930+
const os = __importStar(__webpack_require__(87));
1931+
const utils_1 = __webpack_require__(82);
1932+
function issueCommand(command, message) {
1933+
const filePath = process.env[`GITHUB_${command}`];
1934+
if (!filePath) {
1935+
throw new Error(`Unable to find environment variable for file command ${command}`);
1936+
}
1937+
if (!fs.existsSync(filePath)) {
1938+
throw new Error(`Missing file at path: ${filePath}`);
1939+
}
1940+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
1941+
encoding: 'utf8'
1942+
});
1943+
}
1944+
exports.issueCommand = issueCommand;
1945+
//# sourceMappingURL=file-command.js.map
1946+
1947+
/***/ }),
1948+
18871949
/***/ 118:
18881950
/***/ (function(module, __unusedexports, __webpack_require__) {
18891951

@@ -3496,6 +3558,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
34963558
};
34973559
Object.defineProperty(exports, "__esModule", { value: true });
34983560
const os = __importStar(__webpack_require__(87));
3561+
const utils_1 = __webpack_require__(82);
34993562
/**
35003563
* Commands
35013564
*
@@ -3549,28 +3612,14 @@ class Command {
35493612
return cmdStr;
35503613
}
35513614
}
3552-
/**
3553-
* Sanitizes an input into a string so it can be passed into issueCommand safely
3554-
* @param input input to sanitize into a string
3555-
*/
3556-
function toCommandValue(input) {
3557-
if (input === null || input === undefined) {
3558-
return '';
3559-
}
3560-
else if (typeof input === 'string' || input instanceof String) {
3561-
return input;
3562-
}
3563-
return JSON.stringify(input);
3564-
}
3565-
exports.toCommandValue = toCommandValue;
35663615
function escapeData(s) {
3567-
return toCommandValue(s)
3616+
return utils_1.toCommandValue(s)
35683617
.replace(/%/g, '%25')
35693618
.replace(/\r/g, '%0D')
35703619
.replace(/\n/g, '%0A');
35713620
}
35723621
function escapeProperty(s) {
3573-
return toCommandValue(s)
3622+
return utils_1.toCommandValue(s)
35743623
.replace(/%/g, '%25')
35753624
.replace(/\r/g, '%0D')
35763625
.replace(/\n/g, '%0A')
@@ -4324,6 +4373,12 @@ function convertBody(buffer, headers) {
43244373
// html4
43254374
if (!res && str) {
43264375
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
4376+
if (!res) {
4377+
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
4378+
if (res) {
4379+
res.pop(); // drop last quote
4380+
}
4381+
}
43274382

43284383
if (res) {
43294384
res = /charset=(.*)/i.exec(res.pop());
@@ -5331,7 +5386,7 @@ function fetch(url, opts) {
53315386
// HTTP fetch step 5.5
53325387
switch (request.redirect) {
53335388
case 'error':
5334-
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
5389+
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
53355390
finalize();
53365391
return;
53375392
case 'manual':
@@ -5370,7 +5425,8 @@ function fetch(url, opts) {
53705425
method: request.method,
53715426
body: request.body,
53725427
signal: request.signal,
5373-
timeout: request.timeout
5428+
timeout: request.timeout,
5429+
size: request.size
53745430
};
53755431

53765432
// HTTP-redirect fetch step 9
@@ -5685,6 +5741,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
56855741
};
56865742
Object.defineProperty(exports, "__esModule", { value: true });
56875743
const command_1 = __webpack_require__(431);
5744+
const file_command_1 = __webpack_require__(102);
5745+
const utils_1 = __webpack_require__(82);
56885746
const os = __importStar(__webpack_require__(87));
56895747
const path = __importStar(__webpack_require__(622));
56905748
/**
@@ -5711,9 +5769,17 @@ var ExitCode;
57115769
*/
57125770
// eslint-disable-next-line @typescript-eslint/no-explicit-any
57135771
function exportVariable(name, val) {
5714-
const convertedVal = command_1.toCommandValue(val);
5772+
const convertedVal = utils_1.toCommandValue(val);
57155773
process.env[name] = convertedVal;
5716-
command_1.issueCommand('set-env', { name }, convertedVal);
5774+
const filePath = process.env['GITHUB_ENV'] || '';
5775+
if (filePath) {
5776+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
5777+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
5778+
file_command_1.issueCommand('ENV', commandValue);
5779+
}
5780+
else {
5781+
command_1.issueCommand('set-env', { name }, convertedVal);
5782+
}
57175783
}
57185784
exports.exportVariable = exportVariable;
57195785
/**
@@ -5729,7 +5795,13 @@ exports.setSecret = setSecret;
57295795
* @param inputPath
57305796
*/
57315797
function addPath(inputPath) {
5732-
command_1.issueCommand('add-path', {}, inputPath);
5798+
const filePath = process.env['GITHUB_PATH'] || '';
5799+
if (filePath) {
5800+
file_command_1.issueCommand('PATH', inputPath);
5801+
}
5802+
else {
5803+
command_1.issueCommand('add-path', {}, inputPath);
5804+
}
57335805
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
57345806
}
57355807
exports.addPath = addPath;

0 commit comments

Comments
 (0)