Skip to content

Commit 3f45ead

Browse files
Merge pull request #2500 from artilleryio/bernardobridge/art-1643-review-vulnerabilities-from-repo-and-resolve-pending-issues
dep: stop using ip package
2 parents db4ca95 + b48d325 commit 3f45ead

File tree

8 files changed

+71
-378
lines changed

8 files changed

+71
-378
lines changed

package-lock.json

+9-359
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/artillery-engine-playwright/test/fargate.aws.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ test('playwright typescript test works and reports data', async (t) => {
2222
const output =
2323
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput} --overrides ${configOverride} --tags ${tags} --record`;
2424

25-
t.equal(output.exitCode, 0);
25+
t.equal(
26+
output.exitCode,
27+
0,
28+
`should have exit code 0, got ${output.exitCode}`
29+
);
2630

2731
const jsonReportAggregate = JSON.parse(
2832
fs.readFileSync(playwrightOutput, 'utf8')
2933
).aggregate;
3034

3135
//Assert: should have no failed VUs
32-
t.equal(jsonReportAggregate.counters['vusers.failed'], 0);
36+
t.equal(
37+
jsonReportAggregate.counters['vusers.failed'],
38+
0,
39+
'should have no failed VUs'
40+
);
3341

3442
//Assert: should have done http_requests and reported codes
3543
t.ok(
@@ -113,7 +121,11 @@ test('playwright typescript test fails and has correct vu count when expectation
113121
try {
114122
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput} --overrides ${scenarioOverride} --tags ${tags} --record`;
115123
} catch (output) {
116-
t.equal(output.exitCode, 1);
124+
t.equal(
125+
output.exitCode,
126+
1,
127+
`should have exit code 1, got ${output.exitCode}`
128+
);
117129

118130
const jsonReportAggregate = JSON.parse(
119131
fs.readFileSync(playwrightOutput, 'utf8')

packages/artillery-engine-playwright/test/index.test.js

+30-6
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ test('playwright js test works and reports data', async (t) => {
1717
const output =
1818
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput}`;
1919

20-
t.equal(output.exitCode, 0);
20+
t.equal(
21+
output.exitCode,
22+
0,
23+
`should have exit code 0, got ${output.exitCode}`
24+
);
2125

2226
const jsonReportAggregate = JSON.parse(
2327
fs.readFileSync(playwrightOutput, 'utf8')
2428
).aggregate;
2529

2630
//Assert: should have no failed VUs
27-
t.equal(jsonReportAggregate.counters['vusers.failed'], 0);
31+
t.equal(
32+
jsonReportAggregate.counters['vusers.failed'],
33+
0,
34+
'should have no failed VUs'
35+
);
2836

2937
//Assert: should have done http_requests and reported codes
3038
t.ok(
@@ -105,7 +113,11 @@ test('playwright js test fails and has correct vu count when expectation fails',
105113
try {
106114
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput} --overrides ${scenarioOverride}`;
107115
} catch (output) {
108-
t.equal(output.exitCode, 1);
116+
t.equal(
117+
output.exitCode,
118+
1,
119+
`should have exit code 1, got ${output.exitCode}`
120+
);
109121

110122
const jsonReportAggregate = JSON.parse(
111123
fs.readFileSync(playwrightOutput, 'utf8')
@@ -131,14 +143,22 @@ test('playwright typescript test works and reports data', async (t) => {
131143
const output =
132144
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput} --overrides ${configOverride}`;
133145

134-
t.equal(output.exitCode, 0);
146+
t.equal(
147+
output.exitCode,
148+
0,
149+
`should have exit code 0, got ${output.exitCode}`
150+
);
135151

136152
const jsonReportAggregate = JSON.parse(
137153
fs.readFileSync(playwrightOutput, 'utf8')
138154
).aggregate;
139155

140156
//Assert: should have no failed VUs
141-
t.equal(jsonReportAggregate.counters['vusers.failed'], 0);
157+
t.equal(
158+
jsonReportAggregate.counters['vusers.failed'],
159+
0,
160+
'should have no failed VUs'
161+
);
142162

143163
//Assert: should have done http_requests and reported codes
144164
t.ok(
@@ -222,7 +242,11 @@ test('playwright typescript test fails and has correct vu count when expectation
222242
try {
223243
await $`../artillery/bin/run run ./test/fixtures/pw-acceptance.yml --output ${playwrightOutput} --overrides ${scenarioOverride}`;
224244
} catch (output) {
225-
t.equal(output.exitCode, 1);
245+
t.equal(
246+
output.exitCode,
247+
1,
248+
`should have exit code 1, got ${output.exitCode}`
249+
);
226250

227251
const jsonReportAggregate = JSON.parse(
228252
fs.readFileSync(playwrightOutput, 'utf8')

packages/artillery-plugin-publish-metrics/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"debug": "^4.1.1",
3434
"dogapi": "^2.8.4",
3535
"hot-shots": "^6.0.1",
36-
"libhoney": "^4.1.0",
3736
"lightstep-tracer": "^0.31.0",
3837
"mixpanel": "^0.13.0",
3938
"opentracing": "^0.14.5",

packages/artillery/lib/cmds/run.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const {
1414
const p = require('util').promisify;
1515
const csv = require('csv-parse');
1616
const debug = require('debug')('commands:run');
17-
const ip = require('ip');
1817
const dotenv = require('dotenv');
1918
const _ = require('lodash');
2019

@@ -586,21 +585,33 @@ async function sendTelemetry(script, flags, extraProps) {
586585
properties.distinctId = properties.targetHash;
587586
}
588587

589-
const ipaddr = ip.address();
590588
let macaddr;
589+
const nonInternalIpv6Interfaces = [];
591590
for (const [iface, descrs] of Object.entries(os.networkInterfaces())) {
592591
for (const o of descrs) {
593-
if (o.address === ipaddr) {
594-
macaddr = o.mac;
595-
break;
592+
if (o.internal == true) {
593+
continue;
596594
}
595+
596+
//prefer ipv4 interface when available
597+
if (o.family != 'IPv4') {
598+
nonInternalIpv6Interfaces.push(o);
599+
continue;
600+
}
601+
602+
macaddr = o.mac;
603+
break;
597604
}
598605
}
599606

607+
//default to first ipv6 interface if no ipv4 interface is available
608+
if (!macaddr && nonInternalIpv6Interfaces.length > 0) {
609+
macaddr = nonInternalIpv6Interfaces[0].mac;
610+
}
611+
600612
if (macaddr) {
601613
properties.macHash = hash(macaddr);
602614
}
603-
properties.ipHash = hash(ipaddr);
604615
properties.hostnameHash = hash(os.hostname());
605616
properties.usernameHash = hash(os.userInfo().username);
606617

packages/artillery/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"esbuild-wasm": "^0.19.8",
116116
"eventemitter3": "^4.0.4",
117117
"fs-extra": "^10.1.0",
118-
"ip": "^1.1.8",
119118
"is-builtin-module": "^2.0.0",
120119
"joi": "^17.6.0",
121120
"js-yaml": "^3.13.1",

packages/skytrace/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"cli-highlight": "^2.1.11",
3232
"debug": "^4.3.1",
3333
"gradient-string": "^2.0.2",
34-
"ip": "^1.1.8",
3534
"jmespath": "^0.16.0",
3635
"js-yaml": "^3.13.1",
3736
"mime-types": "2.1.35",

packages/skytrace/src/commands/ping.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const fs = require('fs');
55
const nodeCrypto = require('node:crypto');
66

77
const os = require('os');
8-
const ip = require('ip');
98

109
const sprintf = require('sprintf-js').sprintf;
1110
const { Command, flags } = require('@oclif/command');

0 commit comments

Comments
 (0)