Skip to content

Commit 322b5ad

Browse files
committed
Remove ID from agent info
We'll make on server side Also a dependency we can drop
1 parent 2a0ae10 commit 322b5ad

File tree

10 files changed

+10
-101
lines changed

10 files changed

+10
-101
lines changed

library/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
},
4949
"dependencies": {
5050
"require-in-the-middle": "^7.2.0",
51-
"shimmer": "^1.2.1",
52-
"ulid": "^2.3.0"
51+
"shimmer": "^1.2.1"
5352
}
5453
}

library/src/agent/API.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function generateAttackEvent(): Event {
2424
metadata: {},
2525
},
2626
agent: {
27-
id: "id",
2827
version: "1.0.0",
2928
dryMode: false,
3029
hostname: "hostname",
@@ -74,7 +73,6 @@ function generateStartedEvent(): Event {
7473
type: "started",
7574
time: Date.now(),
7675
agent: {
77-
id: "id",
7876
version: "1.0.0",
7977
dryMode: false,
8078
hostname: "hostname",
@@ -121,7 +119,6 @@ function generateHeartbeatEvent(): Event {
121119
time: Date.now(),
122120
stats: {},
123121
agent: {
124-
id: "id",
125122
version: "1.0.0",
126123
dryMode: false,
127124
hostname: "hostname",

library/src/agent/API.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export class Token {
1919
}
2020

2121
export type AgentInfo = {
22-
id: string;
2322
dryMode: boolean;
2423
hostname: string;
2524
version: string;

library/src/agent/Agent.test.ts

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,22 @@ import { hostname, platform, release } from "node:os";
22
import * as t from "tap";
33
import { Agent } from "./Agent";
44
import { APIForTesting, Token } from "./API";
5-
import { IDGeneratorFixed } from "./IDGenerator";
65
import { LoggerNoop } from "./Logger";
76
import { address } from "ip";
87

98
t.test("it sends started event", async (t) => {
109
const logger = new LoggerNoop();
1110
const api = new APIForTesting();
1211
const token = new Token("123");
13-
const agent = new Agent(
14-
true,
15-
logger,
16-
api,
17-
token,
18-
new IDGeneratorFixed("id"),
19-
false,
20-
{
21-
mongodb: "1.0.0",
22-
}
23-
);
12+
const agent = new Agent(true, logger, api, token, false, {
13+
mongodb: "1.0.0",
14+
});
2415
agent.start();
2516

2617
t.match(api.getEvents(), [
2718
{
2819
type: "started",
2920
agent: {
30-
id: "id",
3121
dryMode: false,
3222
hostname: hostname(),
3323
version: "1.0.0",
@@ -52,15 +42,7 @@ t.test("when prevent prototype pollution is enabled", async (t) => {
5242
const logger = new LoggerNoop();
5343
const api = new APIForTesting();
5444
const token = new Token("123");
55-
const agent = new Agent(
56-
true,
57-
logger,
58-
api,
59-
token,
60-
new IDGeneratorFixed("id"),
61-
true,
62-
{}
63-
);
45+
const agent = new Agent(true, logger, api, token, true, {});
6446
agent.onPrototypePollutionPrevented();
6547
agent.start();
6648
t.match(api.getEvents(), [
@@ -76,15 +58,7 @@ t.test("it does not start interval in serverless mode", async () => {
7658
const logger = new LoggerNoop();
7759
const api = new APIForTesting();
7860
const token = new Token("123");
79-
const agent = new Agent(
80-
true,
81-
logger,
82-
api,
83-
token,
84-
new IDGeneratorFixed("id"),
85-
true,
86-
{}
87-
);
61+
const agent = new Agent(true, logger, api, token, true, {});
8862

8963
// This would otherwise keep the process running
9064
agent.start();
@@ -94,15 +68,7 @@ t.test("it keeps track of stats", async () => {
9468
const logger = new LoggerNoop();
9569
const api = new APIForTesting();
9670
const token = new Token("123");
97-
const agent = new Agent(
98-
true,
99-
logger,
100-
api,
101-
token,
102-
new IDGeneratorFixed("id"),
103-
true,
104-
{}
105-
);
71+
const agent = new Agent(true, logger, api, token, true, {});
10672

10773
agent.start();
10874
agent.onInspectedCall({
@@ -158,15 +124,7 @@ t.test("it keeps tracks of stats in dry mode", async () => {
158124
const logger = new LoggerNoop();
159125
const api = new APIForTesting();
160126
const token = new Token("123");
161-
const agent = new Agent(
162-
false,
163-
logger,
164-
api,
165-
token,
166-
new IDGeneratorFixed("id"),
167-
true,
168-
{}
169-
);
127+
const agent = new Agent(false, logger, api, token, true, {});
170128

171129
agent.start();
172130

library/src/agent/Agent.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { hostname, platform, release } from "node:os";
22
import { API, AgentInfo, Token, Stats, Kind } from "./API";
3-
import { IDGenerator } from "./IDGenerator";
43
import { Logger } from "./Logger";
54
import { Context } from "./Context";
65
import { resolve } from "path";
@@ -18,7 +17,6 @@ export class Agent {
1817
private readonly logger: Logger,
1918
private readonly api: API,
2019
private readonly token: Token | undefined,
21-
private readonly idGenerator: IDGenerator,
2220
private readonly serverless: boolean,
2321
private readonly wrappedPackages: Record<string, string>
2422
) {}
@@ -182,7 +180,6 @@ export class Agent {
182180

183181
private getAgentInfo(): AgentInfo {
184182
return {
185-
id: this.idGenerator.generate(),
186183
dryMode: !this.block,
187184
hostname: hostname() || "",
188185
version: this.getAgentVersion(),

library/src/agent/IDGenerator.test.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

library/src/agent/IDGenerator.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

library/src/agent/protect.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { satisfiesVersion } from "../helpers/satisfiesVersion";
55
import { Agent } from "./Agent";
66
import { getInstance, setInstance } from "./AgentSingleton";
77
import { API, APIFetch, APIThrottled, Token } from "./API";
8-
import { IDGeneratorULID } from "./IDGenerator";
98
import { Express } from "../sources/Express";
109
import { createLambdaWrapper } from "../sources/Lambda";
1110
import { MongoDB } from "../sinks/MongoDB";
@@ -109,7 +108,6 @@ function getAgent({
109108
logger,
110109
api,
111110
token,
112-
new IDGeneratorULID(),
113111
serverless,
114112
installed
115113
);
@@ -156,6 +154,7 @@ export function lambda(
156154
options: getOptions(options),
157155
serverless: true,
158156
});
157+
159158
agent.start();
160159

161160
return createLambdaWrapper(handler);

library/src/sinks/MongoDB.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as t from "tap";
22
import { Agent } from "../agent/Agent";
33
import { setInstance } from "../agent/AgentSingleton";
44
import { APIForTesting, Token } from "../agent/API";
5-
import { IDGeneratorFixed } from "../agent/IDGenerator";
65
import { LoggerNoop } from "../agent/Logger";
76
import { Context, runWithContext } from "../agent/Context";
87
import { MongoDB } from "./MongoDB";
@@ -29,7 +28,6 @@ t.test("we can highjack the MongoDB library", async (t) => {
2928
new LoggerNoop(),
3029
new APIForTesting(),
3130
new Token("123"),
32-
new IDGeneratorFixed("id"),
3331
false,
3432
{
3533
mongodb: "1.0.0",

package-lock.json

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)