@@ -35,38 +35,29 @@ t.test(
3535 const hooks = new Hooks ( ) ;
3636
3737 let modifyCalled = false ;
38- hooks . addGlobal (
39- "fetch" ,
40- {
41- modifyArgs : ( args ) => {
42- modifyCalled = true ;
43- return args ;
44- } ,
38+ hooks . addGlobal ( "fetch" , {
39+ kind : "outgoing_http_op" ,
40+ modifyArgs : ( args ) => {
41+ modifyCalled = true ;
42+ return args ;
4543 } ,
46- "outgoing_http_op"
47- ) ;
44+ } ) ;
4845
4946 let inspectCalled = false ;
50- hooks . addGlobal (
51- "atob" ,
52- {
53- inspectArgs : ( args ) => {
54- inspectCalled = true ;
55- } ,
47+ hooks . addGlobal ( "atob" , {
48+ kind : "outgoing_http_op" ,
49+ inspectArgs : ( args ) => {
50+ inspectCalled = true ;
5651 } ,
57- "outgoing_http_op"
58- ) ;
52+ } ) ;
5953
6054 // Unknown global
61- hooks . addGlobal (
62- "unknown" ,
63- {
64- inspectArgs : ( args ) => {
65- return ;
66- } ,
55+ hooks . addGlobal ( "unknown" , {
56+ kind : "outgoing_http_op" ,
57+ inspectArgs : ( args ) => {
58+ return ;
6759 } ,
68- "outgoing_http_op"
69- ) ;
60+ } ) ;
7061
7162 // Without name
7263 // @ts -expect-error Test with invalid arguments
@@ -102,17 +93,12 @@ t.test("it ignores route if force protection off is on", async (t) => {
10293
10394 const hooks = new Hooks ( ) ;
10495 hooks . addBuiltinModule ( "dns/promises" ) . onRequire ( ( exports , pkgInfo ) => {
105- wrapExport (
106- exports ,
107- "lookup" ,
108- pkgInfo ,
109- {
110- inspectArgs : ( args , agent ) => {
111- inspectionCalls . push ( { args } ) ;
112- } ,
96+ wrapExport ( exports , "lookup" , pkgInfo , {
97+ kind : "outgoing_http_op" ,
98+ inspectArgs : ( args , agent ) => {
99+ inspectionCalls . push ( { args } ) ;
113100 } ,
114- "outgoing_http_op"
115- ) ;
101+ } ) ;
116102 } ) ;
117103
118104 applyHooks ( hooks ) ;
@@ -174,24 +160,19 @@ t.test("it ignores route if force protection off is on", async (t) => {
174160t . test ( "it does not report attack if IP is allowed" , async ( t ) => {
175161 const hooks = new Hooks ( ) ;
176162 hooks . addBuiltinModule ( "os" ) . onRequire ( ( exports , pkgInfo ) => {
177- wrapExport (
178- exports ,
179- "hostname" ,
180- pkgInfo ,
181- {
182- inspectArgs : ( args , agent ) => {
183- return {
184- operation : "os.hostname" ,
185- source : "body" ,
186- pathsToPayload : [ "path" ] ,
187- payload : "payload" ,
188- metadata : { } ,
189- kind : "path_traversal" ,
190- } ;
191- } ,
163+ wrapExport ( exports , "hostname" , pkgInfo , {
164+ kind : "path_op" ,
165+ inspectArgs : ( args , agent ) => {
166+ return {
167+ operation : "os.hostname" ,
168+ source : "body" ,
169+ pathsToPayload : [ "path" ] ,
170+ payload : "payload" ,
171+ metadata : { } ,
172+ kind : "path_traversal" ,
173+ } ;
192174 } ,
193- "path_op"
194- ) ;
175+ } ) ;
195176 } ) ;
196177
197178 applyHooks ( hooks ) ;
0 commit comments