Merge pull request #105 from fjogeleit/main

master sync
This commit is contained in:
Frank Jogeleit 2023-06-26 12:44:39 +02:00 committed by GitHub
commit 0a8bc3c016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 120 additions and 52 deletions

View file

@ -42,10 +42,14 @@ request({
data: argv.data,
method: argv.method,
instanceConfig,
preventFailureOnNoResponse: false,
escapeData: false,
files: argv.files,
file: argv.file,
ignoredCodes: [],
actions: new LogActions()
actions: new LogActions(),
options: {
ignoredCodes: [],
escapeData: false,
preventFailureOnNoResponse: false,
retry: 0,
retryWait: 0
}
})

109
dist/index.js vendored
View file

@ -1726,6 +1726,10 @@ function checkBypass(reqUrl) {
if (!reqUrl.hostname) {
return false;
}
const reqHost = reqUrl.hostname;
if (isLoopbackAddress(reqHost)) {
return true;
}
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
if (!noProxy) {
return false;
@ -1751,13 +1755,24 @@ function checkBypass(reqUrl) {
.split(',')
.map(x => x.trim().toUpperCase())
.filter(x => x)) {
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
if (upperNoProxyItem === '*' ||
upperReqHosts.some(x => x === upperNoProxyItem ||
x.endsWith(`.${upperNoProxyItem}`) ||
(upperNoProxyItem.startsWith('.') &&
x.endsWith(`${upperNoProxyItem}`)))) {
return true;
}
}
return false;
}
exports.checkBypass = checkBypass;
function isLoopbackAddress(host) {
const hostLower = host.toLowerCase();
return (hostLower === 'localhost' ||
hostLower.startsWith('127.') ||
hostLower.startsWith('[::1]') ||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
}
//# sourceMappingURL=proxy.js.map
/***/ }),
@ -5261,7 +5276,7 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
const response = await retry(execRequest, {
actions,
retry: options.retry || 0,
sleep: options.retryWait // wait 3s after each retry
sleep: options.retryWait // wait time after each retry
})
if (!response) {
@ -5489,7 +5504,7 @@ module.exports = require("zlib");
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
// Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
// Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors
const FormData$1 = __nccwpck_require__(4334);
@ -5707,12 +5722,16 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
* @returns {boolean} True if value is an FormData, otherwise false
*/
const isFormData = (thing) => {
const pattern = '[object FormData]';
let kind;
return thing && (
(typeof FormData === 'function' && thing instanceof FormData) ||
toString.call(thing) === pattern ||
(isFunction(thing.toString) && thing.toString() === pattern)
);
(typeof FormData === 'function' && thing instanceof FormData) || (
isFunction(thing.append) && (
(kind = kindOf(thing)) === 'formdata' ||
// detect form-data instance
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
)
)
)
};
/**
@ -6177,6 +6196,11 @@ const toJSONObject = (obj) => {
return visit(obj, 0);
};
const isAsyncFn = kindOfTest('AsyncFunction');
const isThenable = (thing) =>
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
const utils = {
isArray,
isArrayBuffer,
@ -6226,7 +6250,9 @@ const utils = {
ALPHABET,
generateString,
isSpecCompliantForm,
toJSONObject
toJSONObject,
isAsyncFn,
isThenable
};
/**
@ -7068,9 +7094,7 @@ function parseTokens(str) {
return tokens;
}
function isValidHeaderName(str) {
return /^[-_a-zA-Z]+$/.test(str.trim());
}
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
if (utils.isFunction(filter)) {
@ -7443,7 +7467,7 @@ function buildFullPath(baseURL, requestedURL) {
return requestedURL;
}
const VERSION = "1.3.4";
const VERSION = "1.4.0";
function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@ -7913,6 +7937,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
const callbackify = (fn, reducer) => {
return utils.isAsyncFn(fn) ? function (...args) {
const cb = args.pop();
fn.apply(this, args).then((value) => {
try {
reducer ? cb(null, ...reducer(value)) : cb(null, value);
} catch (err) {
cb(err);
}
}, cb);
} : fn;
};
const callbackify$1 = callbackify;
const zlibOptions = {
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
@ -8035,13 +8074,24 @@ const wrapAsync = (asyncExecutor) => {
/*eslint consistent-return:0*/
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
let {data} = config;
let {data, lookup, family} = config;
const {responseType, responseEncoding} = config;
const method = config.method.toUpperCase();
let isDone;
let rejected = false;
let req;
if (lookup && utils.isAsyncFn(lookup)) {
lookup = callbackify$1(lookup, (entry) => {
if(utils.isString(entry)) {
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4];
} else if (!utils.isArray(entry)) {
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
}
return entry;
});
}
// temporary internal emitter until the AxiosRequest class will be implemented
const emitter = new EventEmitter__default["default"]();
@ -8265,6 +8315,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
agents: { http: config.httpAgent, https: config.httpsAgent },
auth,
protocol,
family,
lookup,
beforeRedirect: dispatchBeforeRedirect,
beforeRedirects: {}
};
@ -8694,8 +8746,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
}
}
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
requestHeaders.setContentType(false); // Let the browser set it
if (utils.isFormData(requestData)) {
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
requestHeaders.setContentType(false); // Let the browser set it
} else {
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
}
}
let request = new XMLHttpRequest();
@ -9101,7 +9157,7 @@ function mergeConfig(config1, config2) {
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
};
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
const merge = mergeMap[prop] || mergeDeepProperties;
const configValue = merge(config1[prop], config2[prop], prop);
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@ -9245,11 +9301,17 @@ class Axios {
}, false);
}
if (paramsSerializer !== undefined) {
validator.assertOptions(paramsSerializer, {
encode: validators.function,
serialize: validators.function
}, true);
if (paramsSerializer != null) {
if (utils.isFunction(paramsSerializer)) {
config.paramsSerializer = {
serialize: paramsSerializer
};
} else {
validator.assertOptions(paramsSerializer, {
encode: validators.function,
serialize: validators.function
}, true);
}
}
// Set config.method
@ -9748,7 +9810,8 @@ if (!!core.getInput('customHeaders')) {
try {
customHeaders = JSON.parse(core.getInput('customHeaders'));
} catch(error) {
core.error('Could not parse customHeaders string value')
core.debug(`Invalid customHeaders string: ${core.getInput('customHeaders')}`)
core.error(`Could not parse customHeaders string value: ${error}`)
}
}

40
package-lock.json generated
View file

@ -13,9 +13,9 @@
},
"devDependencies": {
"@vercel/ncc": "^0.36.1",
"axios": "^1.3",
"axios": "^1.4",
"form-data": "^4.0.0",
"yargs": "^17.7.1"
"yargs": "^17.7.2"
},
"engines": {
"node": ">=16.0.0"
@ -31,9 +31,9 @@
}
},
"node_modules/@actions/http-client": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
"dependencies": {
"tunnel": "^0.0.6"
}
@ -78,9 +78,9 @@
"dev": true
},
"node_modules/axios": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.15.0",
@ -313,9 +313,9 @@
}
},
"node_modules/yargs": {
"version": "17.7.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz",
"integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==",
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"dependencies": {
"cliui": "^8.0.1",
@ -351,9 +351,9 @@
}
},
"@actions/http-client": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
"requires": {
"tunnel": "^0.0.6"
}
@ -386,9 +386,9 @@
"dev": true
},
"axios": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dev": true,
"requires": {
"follow-redirects": "^1.15.0",
@ -553,9 +553,9 @@
"dev": true
},
"yargs": {
"version": "17.7.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz",
"integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==",
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"requires": {
"cliui": "^8.0.1",

View file

@ -1,6 +1,6 @@
{
"name": "http-request-action",
"version": "1.11.2",
"version": "1.14.1",
"description": "",
"main": "src/index.js",
"private": false,
@ -20,9 +20,9 @@
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
"devDependencies": {
"@vercel/ncc": "^0.36.1",
"axios": "^1.3",
"axios": "^1.4",
"form-data": "^4.0.0",
"yargs": "^17.7.1"
"yargs": "^17.7.2"
},
"dependencies": {
"@actions/core": "^1.10.0"

View file

@ -112,7 +112,7 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
const response = await retry(execRequest, {
actions,
retry: options.retry || 0,
sleep: options.retryWait // wait 3s after each retry
sleep: options.retryWait // wait time after each retry
})
if (!response) {

View file

@ -13,7 +13,8 @@ if (!!core.getInput('customHeaders')) {
try {
customHeaders = JSON.parse(core.getInput('customHeaders'));
} catch(error) {
core.error('Could not parse customHeaders string value')
core.debug(`Invalid customHeaders string: ${core.getInput('customHeaders')}`)
core.error(`Could not parse customHeaders string value: ${error}`)
}
}