From 4eed2c2f4cd0d374720c4b913f79faa8aafcfa6b Mon Sep 17 00:00:00 2001 From: rhysd Date: Wed, 10 Jun 2020 22:37:12 +0900 Subject: [PATCH] v1.8.1 --- node_modules/@actions/core/package.json | 21 ++--- node_modules/@actions/http-client/RELEASES.md | 3 + node_modules/@actions/http-client/auth.js | 7 +- node_modules/@actions/http-client/index.d.ts | 3 +- node_modules/@actions/http-client/index.js | 81 +++++++++++++------ .../@actions/http-client/interfaces.d.ts | 4 +- .../@actions/http-client/interfaces.js | 1 - .../@actions/http-client/package.json | 34 ++++---- node_modules/@actions/http-client/proxy.js | 13 +-- node_modules/@types/node/package.json | 21 ++--- package-lock.json | 6 +- src/extract.js | 2 +- 12 files changed, 122 insertions(+), 74 deletions(-) diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json index 34d89e91d..fd0c8bd41 100644 --- a/node_modules/@actions/core/package.json +++ b/node_modules/@actions/core/package.json @@ -1,33 +1,36 @@ { - "_from": "@actions/core@^1.2.3", + "_args": [ + [ + "@actions/core@1.2.3", + "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark" + ] + ], + "_from": "@actions/core@1.2.3", "_id": "@actions/core@1.2.3", "_inBundle": false, "_integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==", "_location": "/@actions/core", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@actions/core@^1.2.3", + "raw": "@actions/core@1.2.3", "name": "@actions/core", "escapedName": "@actions%2fcore", "scope": "@actions", - "rawSpec": "^1.2.3", + "rawSpec": "1.2.3", "saveSpec": null, - "fetchSpec": "^1.2.3" + "fetchSpec": "1.2.3" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz", - "_shasum": "e844b4fa0820e206075445079130868f95bfca95", - "_spec": "@actions/core@^1.2.3", + "_spec": "1.2.3", "_where": "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Actions core lib", "devDependencies": { "@types/node": "^12.0.2" diff --git a/node_modules/@actions/http-client/RELEASES.md b/node_modules/@actions/http-client/RELEASES.md index c8040ed3d..79f9a5819 100644 --- a/node_modules/@actions/http-client/RELEASES.md +++ b/node_modules/@actions/http-client/RELEASES.md @@ -1,5 +1,8 @@ ## Releases +## 1.0.7 +Update NPM dependencies and add 429 to the list of HttpCodes + ## 1.0.6 Automatically sends Content-Type and Accept application/json headers for \Json() helper methods if not set in the client or parameters. diff --git a/node_modules/@actions/http-client/auth.js b/node_modules/@actions/http-client/auth.js index 98d22d66d..67a58aa78 100644 --- a/node_modules/@actions/http-client/auth.js +++ b/node_modules/@actions/http-client/auth.js @@ -6,7 +6,9 @@ class BasicCredentialHandler { this.password = password; } prepareRequest(options) { - options.headers['Authorization'] = 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64'); + options.headers['Authorization'] = + 'Basic ' + + Buffer.from(this.username + ':' + this.password).toString('base64'); } // This handler cannot handle 401 canHandleAuthentication(response) { @@ -42,7 +44,8 @@ class PersonalAccessTokenCredentialHandler { // currently implements pre-authorization // TODO: support preAuth = false where it hooks on 401 prepareRequest(options) { - options.headers['Authorization'] = 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); + options.headers['Authorization'] = + 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); } // This handler cannot handle 401 canHandleAuthentication(response) { diff --git a/node_modules/@actions/http-client/index.d.ts b/node_modules/@actions/http-client/index.d.ts index 2bbcc6a1e..7cdc11554 100644 --- a/node_modules/@actions/http-client/index.d.ts +++ b/node_modules/@actions/http-client/index.d.ts @@ -1,5 +1,5 @@ /// -import http = require("http"); +import http = require('http'); import ifm = require('./interfaces'); export declare enum HttpCodes { OK = 200, @@ -23,6 +23,7 @@ export declare enum HttpCodes { RequestTimeout = 408, Conflict = 409, Gone = 410, + TooManyRequests = 429, InternalServerError = 500, NotImplemented = 501, BadGateway = 502, diff --git a/node_modules/@actions/http-client/index.js b/node_modules/@actions/http-client/index.js index 7e553a6f3..e1930da87 100644 --- a/node_modules/@actions/http-client/index.js +++ b/node_modules/@actions/http-client/index.js @@ -28,6 +28,7 @@ var HttpCodes; HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; @@ -52,8 +53,18 @@ function getProxyUrl(serverUrl) { return proxyUrl ? proxyUrl.href : ''; } exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect]; -const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout]; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; const ExponentialBackoffCeiling = 10; const ExponentialBackoffTimeSlice = 5; @@ -178,18 +189,22 @@ class HttpClient { */ async request(verb, requestUrl, data, headers) { if (this._disposed) { - throw new Error("Client has already been disposed."); + throw new Error('Client has already been disposed.'); } let parsedUrl = url.parse(requestUrl); let info = this._prepareRequest(verb, parsedUrl, headers); // Only perform retries on reads since writes may not be idempotent. - let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1; + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; let numTries = 0; let response; while (numTries < maxTries) { response = await this.requestRaw(info, data); // Check if it's an authentication challenge - if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { let authenticationHandler; for (let i = 0; i < this.handlers.length; i++) { if (this.handlers[i].canHandleAuthentication(response)) { @@ -207,21 +222,32 @@ class HttpClient { } } let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 - && this._allowRedirects - && redirectsRemaining > 0) { - const redirectUrl = response.message.headers["location"]; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; if (!redirectUrl) { // if there's no location to redirect to, we won't break; } let parsedRedirectUrl = url.parse(redirectUrl); - if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { - throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true."); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); } // we need to finish reading the response before reassigning response // which will leak the open socket. await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } // let's make the request with the new redirectUrl info = this._prepareRequest(verb, parsedRedirectUrl, headers); response = await this.requestRaw(info, data); @@ -272,8 +298,8 @@ class HttpClient { */ requestRawWithCallback(info, data, onResult) { let socket; - if (typeof (data) === 'string') { - info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8'); + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); } let callbackCalled = false; let handleResult = (err, res) => { @@ -286,7 +312,7 @@ class HttpClient { let res = new HttpClientResponse(msg); handleResult(null, res); }); - req.on('socket', (sock) => { + req.on('socket', sock => { socket = sock; }); // If we ever get disconnected, we want the socket to timeout eventually @@ -301,10 +327,10 @@ class HttpClient { // res should have headers handleResult(err, null); }); - if (data && typeof (data) === 'string') { + if (data && typeof data === 'string') { req.write(data, 'utf8'); } - if (data && typeof (data) !== 'string') { + if (data && typeof data !== 'string') { data.on('close', function () { req.end(); }); @@ -331,31 +357,34 @@ class HttpClient { const defaultPort = usingSsl ? 443 : 80; info.options = {}; info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort; - info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); info.options.method = method; info.options.headers = this._mergeHeaders(headers); if (this.userAgent != null) { - info.options.headers["user-agent"] = this.userAgent; + info.options.headers['user-agent'] = this.userAgent; } info.options.agent = this._getAgent(info.parsedUrl); // gives handlers an opportunity to participate if (this.handlers) { - this.handlers.forEach((handler) => { + this.handlers.forEach(handler => { handler.prepareRequest(info.options); }); } return info; } _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); if (this.requestOptions && this.requestOptions.headers) { return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); } return lowercaseKeys(headers || {}); } _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); let clientHeader; if (this.requestOptions && this.requestOptions.headers) { clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; @@ -393,7 +422,7 @@ class HttpClient { proxyAuth: proxyUrl.auth, host: proxyUrl.hostname, port: proxyUrl.port - }, + } }; let tunnelAgent; const overHttps = proxyUrl.protocol === 'https:'; @@ -420,7 +449,9 @@ class HttpClient { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false }); + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); } return agent; } @@ -481,7 +512,7 @@ class HttpClient { msg = contents; } else { - msg = "Failed request: (" + statusCode + ")"; + msg = 'Failed request: (' + statusCode + ')'; } let err = new Error(msg); // attach statusCode and body obj (if available) to the error object diff --git a/node_modules/@actions/http-client/interfaces.d.ts b/node_modules/@actions/http-client/interfaces.d.ts index 7e3fc3f06..0b348dc01 100644 --- a/node_modules/@actions/http-client/interfaces.d.ts +++ b/node_modules/@actions/http-client/interfaces.d.ts @@ -1,6 +1,6 @@ /// -import http = require("http"); -import url = require("url"); +import http = require('http'); +import url = require('url'); export interface IHeaders { [key: string]: any; } diff --git a/node_modules/@actions/http-client/interfaces.js b/node_modules/@actions/http-client/interfaces.js index 04363ad2b..c8ad2e549 100644 --- a/node_modules/@actions/http-client/interfaces.js +++ b/node_modules/@actions/http-client/interfaces.js @@ -1,3 +1,2 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -; diff --git a/node_modules/@actions/http-client/package.json b/node_modules/@actions/http-client/package.json index 04020251b..8f5745e41 100644 --- a/node_modules/@actions/http-client/package.json +++ b/node_modules/@actions/http-client/package.json @@ -1,32 +1,32 @@ { "_args": [ [ - "@actions/http-client@1.0.6", + "@actions/http-client@1.0.8", "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark" ] ], - "_from": "@actions/http-client@1.0.6", - "_id": "@actions/http-client@1.0.6", + "_from": "@actions/http-client@1.0.8", + "_id": "@actions/http-client@1.0.8", "_inBundle": false, - "_integrity": "sha512-LGmio4w98UyGX33b/W6V6Nx/sQHRXZ859YlMkn36wPsXPB82u8xTVlA/Dq2DXrm6lEq9RVmisRJa1c+HETAIJA==", + "_integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==", "_location": "/@actions/http-client", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "@actions/http-client@1.0.6", + "raw": "@actions/http-client@1.0.8", "name": "@actions/http-client", "escapedName": "@actions%2fhttp-client", "scope": "@actions", - "rawSpec": "1.0.6", + "rawSpec": "1.0.8", "saveSpec": null, - "fetchSpec": "1.0.6" + "fetchSpec": "1.0.8" }, "_requiredBy": [ "/@actions/github" ], - "_resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.6.tgz", - "_spec": "1.0.6", + "_resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz", + "_spec": "1.0.8", "_where": "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark", "author": { "name": "GitHub, Inc." @@ -39,12 +39,13 @@ }, "description": "Actions Http Client", "devDependencies": { - "@types/jest": "^24.0.25", - "@types/node": "^12.12.24", - "jest": "^24.9.0", + "@types/jest": "^25.1.4", + "@types/node": "^12.12.31", + "jest": "^25.1.0", + "prettier": "^2.0.4", "proxy": "^1.0.1", - "ts-jest": "^24.3.0", - "typescript": "^3.7.4" + "ts-jest": "^25.2.1", + "typescript": "^3.8.3" }, "homepage": "https://github.com/actions/http-client#readme", "keywords": [ @@ -59,8 +60,11 @@ "url": "git+https://github.com/actions/http-client.git" }, "scripts": { + "audit-check": "npm audit --audit-level=moderate", "build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out", + "format": "prettier --write *.ts && prettier --write **/*.ts", + "format-check": "prettier --check *.ts && prettier --check **/*.ts", "test": "jest" }, - "version": "1.0.6" + "version": "1.0.8" } diff --git a/node_modules/@actions/http-client/proxy.js b/node_modules/@actions/http-client/proxy.js index 7233779e4..06936b392 100644 --- a/node_modules/@actions/http-client/proxy.js +++ b/node_modules/@actions/http-client/proxy.js @@ -9,12 +9,10 @@ function getProxyUrl(reqUrl) { } let proxyVar; if (usingSsl) { - proxyVar = process.env["https_proxy"] || - process.env["HTTPS_PROXY"]; + proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; } else { - proxyVar = process.env["http_proxy"] || - process.env["HTTP_PROXY"]; + proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; } if (proxyVar) { proxyUrl = url.parse(proxyVar); @@ -26,7 +24,7 @@ function checkBypass(reqUrl) { if (!reqUrl.hostname) { return false; } - let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || ''; + let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; if (!noProxy) { return false; } @@ -47,7 +45,10 @@ function checkBypass(reqUrl) { upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); } // Compare request host against noproxy - for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) { + for (let upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { if (upperReqHosts.some(x => x === upperNoProxyItem)) { return true; } diff --git a/node_modules/@types/node/package.json b/node_modules/@types/node/package.json index 3379fa9e0..374dd5575 100644 --- a/node_modules/@types/node/package.json +++ b/node_modules/@types/node/package.json @@ -1,20 +1,26 @@ { - "_from": "@types/node@^13.9.1", + "_args": [ + [ + "@types/node@13.9.1", + "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark" + ] + ], + "_from": "@types/node@13.9.1", "_id": "@types/node@13.9.1", "_inBundle": false, "_integrity": "sha512-E6M6N0blf/jiZx8Q3nb0vNaswQeEyn0XlupO+xN6DtJ6r6IT4nXrTry7zhIfYvFCl3/8Cu6WIysmUBKiqV0bqQ==", "_location": "/@types/node", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@types/node@^13.9.1", + "raw": "@types/node@13.9.1", "name": "@types/node", "escapedName": "@types%2fnode", "scope": "@types", - "rawSpec": "^13.9.1", + "rawSpec": "13.9.1", "saveSpec": null, - "fetchSpec": "^13.9.1" + "fetchSpec": "13.9.1" }, "_requiredBy": [ "#DEV:/", @@ -26,13 +32,11 @@ "/cheerio/parse5" ], "_resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.1.tgz", - "_shasum": "96f606f8cd67fb018847d9b61e93997dabdefc72", - "_spec": "@types/node@^13.9.1", + "_spec": "13.9.1", "_where": "/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark", "bugs": { "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Microsoft TypeScript", @@ -208,7 +212,6 @@ } ], "dependencies": {}, - "deprecated": false, "description": "TypeScript definitions for Node.js", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme", "license": "MIT", diff --git a/package-lock.json b/package-lock.json index 38cb9f0d8..9c4817f55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,9 +53,9 @@ } }, "@actions/http-client": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.6.tgz", - "integrity": "sha512-LGmio4w98UyGX33b/W6V6Nx/sQHRXZ859YlMkn36wPsXPB82u8xTVlA/Dq2DXrm6lEq9RVmisRJa1c+HETAIJA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz", + "integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==", "requires": { "tunnel": "0.0.6" } diff --git a/src/extract.js b/src/extract.js index 97ec1586e..5ee852cac 100644 --- a/src/extract.js +++ b/src/extract.js @@ -57,7 +57,7 @@ function extractCargoResult(output) { const ret = []; // Example: // test bench_fib_20 ... bench: 37,174 ns/iter (+/- 7,527) - const reExtract = /^test (\w+)\s+\.\.\. bench:\s+([0-9,]+) ns\/iter \(\+\/- ([0-9,]+)\)$/; + const reExtract = /^test ([\w/]+)\s+\.\.\. bench:\s+([0-9,]+) ns\/iter \(\+\/- ([0-9,]+)\)$/; const reComma = /,/g; for (const line of lines) { const m = line.match(reExtract);