Skip to content

Commit

Permalink
SWI-3723 [Snyk] Security upgrade axios from 0.27.2 to 1.6.0 (#83)
Browse files Browse the repository at this point in the history
* fix: package.json & package-lock.json to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-6032459

* fix typings for axios 1.6.0

* update package json to fix import issue

---------

Co-authored-by: snyk-bot <[email protected]>
Co-authored-by: ckoegel <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2023
1 parent 2dedf67 commit bf28953
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
34 changes: 23 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@
"@apimatic/core": "^0.7.6",
"@apimatic/schema": "^0.6.0",
"@types/node": "^14.18.21",
"axios": "^0.27.2",
"axios": "^1.6.0",
"detect-node": "^2.0.4",
"form-data": "^3.0.0",
"lodash.flatmap": "^4.5.0",
"tiny-warning": "^1.0.3",
"xmlbuilder": "^15.1.1"
},
"jest": {
"moduleNameMapper": {
"axios": "axios/dist/node/axios.cjs"
}
},
"bugs": {
"email": "[email protected]"
}
Expand Down
10 changes: 5 additions & 5 deletions src/http/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
*/

import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios, { AxiosHeaders, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import isNode from 'detect-node';
import FormData from 'form-data';
import { isBlob } from '../apiHelper';
Expand Down Expand Up @@ -91,14 +91,14 @@ export class HttpClient {
}

newRequest.data = form;
mergeHeaders(newRequest.headers || {} , form.getHeaders());
mergeHeaders(newRequest.headers as AxiosHeaders || {} , form.getHeaders());
} else if (
requestBody?.type === 'form-data' ||
requestBody?.type === 'form'
) {
// Create form-urlencoded request
setHeader(
newRequest.headers || {},
newRequest.headers as AxiosHeaders || {},
CONTENT_TYPE_HEADER,
FORM_URLENCODED_CONTENT_TYPE
);
Expand All @@ -112,7 +112,7 @@ export class HttpClient {
// Otherwise, use the content type if available.
contentType = requestBody.content.options.contentType;
}
setHeaderIfNotSet(newRequest.headers || {}, CONTENT_TYPE_HEADER, contentType);
setHeaderIfNotSet(newRequest.headers as AxiosHeaders || {}, CONTENT_TYPE_HEADER, contentType);
newRequest.data = requestBody.content.file;
}
else if (requestBody && typeof(requestBody['type']) !== 'undefined') {
Expand All @@ -139,7 +139,7 @@ export class HttpClient {
public convertHttpResponse(resp: AxiosResponse): HttpResponse {
return {
body: resp.data,
headers: resp.headers,
headers: resp.headers as AxiosHeaders,
statusCode: resp.status,
};
}
Expand Down

0 comments on commit bf28953

Please sign in to comment.