Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dopecodez/pingman into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
dopecodez committed Aug 9, 2020
2 parents 9d5350d + 9a6d2b3 commit c66255c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions src/builder/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
export default linux;
12 changes: 6 additions & 6 deletions test/builder/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ 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',
arguments: ['127.0.0.1', '-c', '4']
},
LINUX_IPV6_ARGS: {
command: 'ping6',
arguments: ['127.0.0.1', '-c', '4']
arguments: ['-c', '4', '127.0.0.1']
}
}

Expand Down Expand Up @@ -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);
})
})

0 comments on commit c66255c

Please sign in to comment.