Skip to content

Commit 0d95df3

Browse files
authored
CVE-2024-57965 | updated axios to 1.7.9 (#825)
* updated axios to 1.7.9 Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * revert elliptic Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * updated elliptic to 6.6.1 Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * elliptic to 6.6.1 in apollo Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * parse-duration to 2.1.3 Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * syntax error for importing parse Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * added type = module for parse-duration error Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * revert back to parse-duration": "^1.1.0", Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * updated parse-duration and code syntax Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * removed "type": "module", Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * syntax update Signed-off-by: Ketul Shah <shah.ketul@ibm.com> * replaced parse-duration with wrapper Signed-off-by: Ketul Shah <shah.ketul@ibm.com> --------- Signed-off-by: Ketul Shah <shah.ketul@ibm.com>
1 parent d5677bf commit 0d95df3

File tree

11 files changed

+136
-73
lines changed

11 files changed

+136
-73
lines changed

packages/apollo/package-lock.json

Lines changed: 50 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/apollo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"lodash": "^4.17.20",
3333
"material-ui-chip-input-v5": "^1.0.0",
3434
"node-stdlib-browser": "^1.2.0",
35-
"parse-duration": "^1.1.0",
35+
"parse-duration": "^2.1.3",
3636
"prop-types": "^15.8.1",
3737
"query-string": "^9.0.0",
3838
"react": "^18.3.1",

packages/apollo/src/components/ChannelModal/ChannelModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import _ from 'lodash';
18-
import parse from 'parse-duration';
1918
import PropTypes from 'prop-types';
2019
import React, { Component } from 'react';
2120
import { withTranslation } from 'react-i18next';
@@ -52,6 +51,8 @@ const acl_resources = require('../../utils/acl/resources.json');
5251
const bytes = require('bytes');
5352
const semver = require('semver');
5453
const url = require('url');
54+
//const parse = require('parse-duration');
55+
import parse from "../../utils/parseDuration";
5556

5657
const SCOPE = 'channelModal';
5758
const Log = new Logger(SCOPE);

packages/apollo/src/components/ChannelModal/Wizard/BlockCuttingParams/BlockCuttingParams.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import { withTranslation } from 'react-i18next';
2323
import TranslateLink from '../../../TranslateLink/TranslateLink';
2424
import * as constants from '../../../../utils/constants';
2525
import { Checkbox } from "@carbon/react";
26-
import parse from 'parse-duration';
2726
import Form from '../../../Form/Form';
2827

2928
const bytes = require('bytes');
3029
const SCOPE = 'channelModal';
30+
// const parse = require('parse-duration');
31+
import parse from "../../../../utils/parseDuration";
3132

3233
// This is step "block_cutting_params"
3334
//

packages/apollo/src/components/OrdererModal/OrdererModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
import { Button, CodeSnippet, Loading, SkeletonText, Toggle, Checkbox } from "@carbon/react";
1717
import _ from 'lodash';
18-
import parse from 'parse-duration';
1918
import PropTypes from 'prop-types';
2019
import React from 'react';
2120
import { withTranslation } from 'react-i18next';
@@ -53,6 +52,8 @@ const naturalSort = require('javascript-natural-sort');
5352

5453
const bytes = require('bytes');
5554
const semver = require('semver');
55+
// const parse = require('parse-duration');
56+
import parse from "../../utils/parseDuration";
5657

5758
const SCOPE = 'ordererModal';
5859
const Log = new Logger(SCOPE);

packages/apollo/src/components/SignatureDetailModal/SignatureDetailModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
import { Checkbox, CodeSnippet, TextInput } from "@carbon/react";
1717
import _ from 'lodash';
18-
import parse from 'parse-duration';
1918
import PropTypes from 'prop-types';
2019
import React from 'react';
2120
import { withTranslation, Trans } from 'react-i18next';
@@ -40,6 +39,8 @@ const semver = require('semver');
4039
const SCOPE = 'signatureDetailModal';
4140
const Log = new Logger(SCOPE);
4241
const bytes = require('bytes');
42+
// const parse = require('parse-duration');
43+
import parse from "../../utils/parseDuration";
4344

4445
class SignatureDetailModal extends React.Component {
4546
componentDidMount() {

packages/apollo/src/rest/ChannelApi.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const org_template = require('../utils/configtx/org_template.json');
3333
const bytes = require('bytes');
3434
const diff = require('deep-diff');
3535
const urlParser = require('url');
36+
import parse from "../utils/parseDuration";
3637

3738
const Log = new Logger('ChannelApi');
3839

@@ -742,7 +743,7 @@ class ChannelApi {
742743

743744
let timeout = block_params.timeout;
744745
if (timeout) {
745-
const parse = require('parse-duration');
746+
// const parse = require('parse-duration');
746747
let time_ms = parse(timeout);
747748
if (time_ms < parse(constants.TIMEOUT_MIN) || time_ms > parse(constants.TIMEOUT_MAX)) {
748749
return '\'BatchTimeout\' out of range';
@@ -790,7 +791,7 @@ class ChannelApi {
790791

791792
let tick_interval = raft_params.tick_interval;
792793
if (tick_interval) {
793-
const parse = require('parse-duration');
794+
// const parse = require('parse-duration');
794795
let time_ms = parse(tick_interval);
795796
if (time_ms < parse(constants.TICK_INTERVAL_MIN) || time_ms > parse(constants.TICK_INTERVAL_MAX)) {
796797
return '\'Tick Interval\' out of range';

packages/apollo/src/rest/OrdererRestApi.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Log = new Logger('OrdererRestApi');
3030

3131
const ORDERER_TYPE = 'fabric-orderer';
3232
const LEGACY_ORDERER_TYPE = 'orderer';
33+
import parse from "../utils/parseDuration";
3334

3435
class OrdererRestApi {
3536
static systemChannel = 'testchainid';
@@ -751,7 +752,7 @@ class OrdererRestApi {
751752

752753
let timeout = block_params.timeout;
753754
if (timeout) {
754-
const parse = require('parse-duration');
755+
// const parse = require('parse-duration');
755756
let time_ms = parse(timeout);
756757
if (time_ms < parse(constants.TIMEOUT_MIN) || time_ms > parse(constants.TIMEOUT_MAX)) {
757758
throw new Error('\'BatchTimeout\' out of range');
@@ -858,7 +859,7 @@ class OrdererRestApi {
858859

859860
let tick_interval = raft_params.tick_interval;
860861
if (tick_interval) {
861-
const parse = require('parse-duration');
862+
// const parse = require('parse-duration');
862863
let time_ms = parse(tick_interval);
863864
if (time_ms < parse(constants.TICK_INTERVAL_MIN) || time_ms > parse(constants.TICK_INTERVAL_MAX)) {
864865
throw new Error('\'Tick Interval\' out of range');
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const unit = Object.create(null)
2+
const m = 60000, h = m * 60, d = h * 24, y = d * 365.25
3+
4+
unit.year = unit.yr = unit.y = y
5+
unit.month = unit.mo = unit.mth = y / 12
6+
unit.week = unit.wk = unit.w = d * 7
7+
unit.day = unit.d = d
8+
unit.hour = unit.hr = unit.h = h
9+
unit.minute = unit.min = unit.m = m
10+
unit.second = unit.sec = unit.s = 1000
11+
unit.millisecond = unit.millisec = unit.ms = 1
12+
unit.microsecond = unit.microsec = unit.us = unit.µs = 1e-3
13+
unit.nanosecond = unit.nanosec = unit.ns = 1e-6
14+
15+
unit.group = ','
16+
unit.decimal = '.'
17+
unit.placeholder = ' _'
18+
19+
20+
21+
const durationRE = /((?:\d{1,16}(?:\.\d{1,16})?|\.\d{1,16})(?:[eE][-+]?\d{1,4})?)\s?([\p{L}]{0,14})/gu
22+
23+
parse.unit = unit;
24+
25+
/**
26+
* convert `str` to ms
27+
*
28+
* @param {string} str
29+
* @param {string} format
30+
* @return {number}
31+
*/
32+
export default function parse(str = '', format = 'ms') {
33+
let result = null, prevUnits
34+
35+
String(str)
36+
.replace(new RegExp(`(\\d)[${parse.unit.placeholder}${parse.unit.group}](\\d)`, 'g'), '$1$2') // clean up group separators / placeholders
37+
.replace(parse.unit.decimal, '.') // normalize decimal separator
38+
.replace(durationRE, (_, n, units) => {
39+
// if no units, find next smallest units or fall back to format value
40+
// eg. 1h30 -> 1h30m
41+
if (!units) {
42+
if (prevUnits) {
43+
for (const u in parse.unit) if (parse.unit[u] < prevUnits) { units = u; break }
44+
}
45+
else units = format
46+
}
47+
else units = units.toLowerCase()
48+
49+
prevUnits = units = parse.unit[units] || parse.unit[units.replace(/s$/, '')]
50+
51+
if (units) result = (result || 0) + n * units
52+
})
53+
54+
return result && ((result / (parse.unit[format] || 1)) * (str[0] === '-' ? -1 : 1))
55+
}

0 commit comments

Comments
 (0)