From 4b6f0e8561aac47937a4b065217e029fecdf5787 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Fri, 17 Jul 2020 12:30:50 +0100 Subject: [PATCH 1/4] Move hostname to last argument on linux (#12) * move hostname to last argument on linux * fix hostname not being set * modify tests * remove unwanted console.log --- src/builder/linux.ts | 5 +++-- test/builder/builder.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/builder/linux.ts b/src/builder/linux.ts index bad762d..a65dead 100644 --- a/src/builder/linux.ts +++ b/src/builder/linux.ts @@ -9,10 +9,10 @@ const linux = (ip: string, options?: extendedPingOptions): commandBuilder => { command: 'ping', arguments: args }; - args.push(ip); //NO Allowing Unsanitized user input into spawn.Checking each param and assigning if (!options) { buildCommand.arguments.push('-c', defaultNumberOfEchoes); + args.push(ip); return buildCommand; } if (typeof options?.numberOfEchos === 'number') { @@ -72,8 +72,9 @@ const linux = (ip: string, options?: extendedPingOptions): commandBuilder => { if (options?.IPV6) { buildCommand.command = 'ping6' } + args.push(ip); buildCommand.arguments = args; return buildCommand; }; -export default linux; \ No newline at end of file +export default linux; diff --git a/test/builder/builder.ts b/test/builder/builder.ts index 64597f9..f4e83a6 100644 --- a/test/builder/builder.ts +++ b/test/builder/builder.ts @@ -44,19 +44,19 @@ const sampleBuildCommands = { }, LINUX_NO_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '4'] + arguments: ['-c', '4', '127.0.0.1'] }, LINUX_GENERAL_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-d', '-f', '-n', '-W', '10', '-w', '2'] + arguments: ['-c', '6', '-d', '-f', '-n', '-W', '10', '-w', '2', '127.0.0.1'] }, LINUX_EXTENDED_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-i', '100', '-I', 'testAddr', '-L', '-t', '1000'] + arguments: ['-c', '6', '-i', '100', '-I', 'testAddr', '-L', '-t', '1000', '127.0.0.1'] }, LINUX_EXTENDED_ARGS2: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-n', '-p', 'testPattern', '-q', '-s', '52', '-v'] + arguments: ['-c', '6', '-n', '-p', 'testPattern', '-q', '-s', '52', '-v', '127.0.0.1'] }, MAC_IPV6_ARGS: { command: '/sbin/ping6', @@ -64,7 +64,7 @@ const sampleBuildCommands = { }, LINUX_IPV6_ARGS: { command: 'ping6', - arguments: ['127.0.0.1', '-c', '4'] + arguments: ['-c', '4', '127.0.0.1'] } } @@ -147,4 +147,4 @@ test('Check if builder creates ping6 command for mac systems', t => { test('Check if builder creates ping6 command for linux systems', t => { let command = createBuilder('127.0.0.1', 'linux', { IPV6: true }); t.deepEqual(command, sampleBuildCommands.LINUX_IPV6_ARGS); -}) \ No newline at end of file +}) From 9061263184b76a35741922c290eb50b798838044 Mon Sep 17 00:00:00 2001 From: Govind S Date: Sat, 18 Jul 2020 12:32:50 +0530 Subject: [PATCH 2/4] Move hostname to last argument on linux (#12) (#13) * move hostname to last argument on linux * fix hostname not being set * modify tests * remove unwanted console.log Co-authored-by: Jack Baron --- src/builder/linux.ts | 5 +++-- test/builder/builder.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/builder/linux.ts b/src/builder/linux.ts index bad762d..a65dead 100644 --- a/src/builder/linux.ts +++ b/src/builder/linux.ts @@ -9,10 +9,10 @@ const linux = (ip: string, options?: extendedPingOptions): commandBuilder => { command: 'ping', arguments: args }; - args.push(ip); //NO Allowing Unsanitized user input into spawn.Checking each param and assigning if (!options) { buildCommand.arguments.push('-c', defaultNumberOfEchoes); + args.push(ip); return buildCommand; } if (typeof options?.numberOfEchos === 'number') { @@ -72,8 +72,9 @@ const linux = (ip: string, options?: extendedPingOptions): commandBuilder => { if (options?.IPV6) { buildCommand.command = 'ping6' } + args.push(ip); buildCommand.arguments = args; return buildCommand; }; -export default linux; \ No newline at end of file +export default linux; diff --git a/test/builder/builder.ts b/test/builder/builder.ts index 64597f9..f4e83a6 100644 --- a/test/builder/builder.ts +++ b/test/builder/builder.ts @@ -44,19 +44,19 @@ const sampleBuildCommands = { }, LINUX_NO_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '4'] + arguments: ['-c', '4', '127.0.0.1'] }, LINUX_GENERAL_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-d', '-f', '-n', '-W', '10', '-w', '2'] + arguments: ['-c', '6', '-d', '-f', '-n', '-W', '10', '-w', '2', '127.0.0.1'] }, LINUX_EXTENDED_ARGS: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-i', '100', '-I', 'testAddr', '-L', '-t', '1000'] + arguments: ['-c', '6', '-i', '100', '-I', 'testAddr', '-L', '-t', '1000', '127.0.0.1'] }, LINUX_EXTENDED_ARGS2: { command: 'ping', - arguments: ['127.0.0.1', '-c', '6', '-n', '-p', 'testPattern', '-q', '-s', '52', '-v'] + arguments: ['-c', '6', '-n', '-p', 'testPattern', '-q', '-s', '52', '-v', '127.0.0.1'] }, MAC_IPV6_ARGS: { command: '/sbin/ping6', @@ -64,7 +64,7 @@ const sampleBuildCommands = { }, LINUX_IPV6_ARGS: { command: 'ping6', - arguments: ['127.0.0.1', '-c', '4'] + arguments: ['-c', '4', '127.0.0.1'] } } @@ -147,4 +147,4 @@ test('Check if builder creates ping6 command for mac systems', t => { test('Check if builder creates ping6 command for linux systems', t => { let command = createBuilder('127.0.0.1', 'linux', { IPV6: true }); t.deepEqual(command, sampleBuildCommands.LINUX_IPV6_ARGS); -}) \ No newline at end of file +}) From 857be67df140411cda035a9157691c5f86d6373a Mon Sep 17 00:00:00 2001 From: Govind Date: Sat, 18 Jul 2020 12:40:54 +0530 Subject: [PATCH 3/4] 1.0.7 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9de166e..b1bf6eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pingman", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6e3aa4e..be49452 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pingman", - "version": "1.0.6", + "version": "1.0.7", "description": "A ping wrapper for node with TypeScript", "main": "dist/src", "engines": { From e16167e7a0530cda2260bc87850af7670b48ef79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 18 Jul 2020 07:21:38 +0000 Subject: [PATCH 4/4] Bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1bf6eb..1b6de08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2424,9 +2424,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, "lodash.clonedeep": {