@@ -47,10 +47,7 @@ const okResponse = () =>
4747
4848const SOURCE_ID = 'text_indicator_list:maltrail-cobaltstrike' ;
4949
50- const makeSource = (
51- id = SOURCE_ID ,
52- name = 'Maltrail — CobaltStrike C2 indicators'
53- ) : SourceHit => ( {
50+ const makeSource = ( id = SOURCE_ID , name = 'Maltrail — CobaltStrike C2 indicators' ) : SourceHit => ( {
5451 _id : id ,
5552 _source : {
5653 adapter_type : 'text_indicator_list' ,
@@ -105,10 +102,7 @@ describe('textIndicatorListAdapter', () => {
105102 parseIndicatorListMock . mockReturnValue ( BLOCKS_FIXTURE ) ;
106103 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
107104
108- const reports = await textIndicatorListAdapter . run (
109- makeSource ( ) ,
110- makeContext ( fetchMock )
111- ) ;
105+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
112106
113107 expect ( reports ) . toHaveLength ( 1 ) ;
114108 expect ( ( ) => normalizedReportSchema . parse ( reports [ 0 ] ) ) . not . toThrow ( ) ;
@@ -118,10 +112,7 @@ describe('textIndicatorListAdapter', () => {
118112 parseIndicatorListMock . mockReturnValue ( BLOCKS_FIXTURE ) ;
119113 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
120114
121- const [ report ] = await textIndicatorListAdapter . run (
122- makeSource ( ) ,
123- makeContext ( fetchMock )
124- ) ;
115+ const [ report ] = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
125116
126117 expect ( report . lineage . extraction_method ) . toBe ( 'text_indicator_list' ) ;
127118 expect ( report . lineage . extracted_at ) . toBe ( '2024-01-15T12:00:00.000Z' ) ;
@@ -132,10 +123,7 @@ describe('textIndicatorListAdapter', () => {
132123 parseIndicatorListMock . mockReturnValue ( BLOCKS_FIXTURE ) ;
133124 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
134125
135- const [ report ] = await textIndicatorListAdapter . run (
136- makeSource ( ) ,
137- makeContext ( fetchMock )
138- ) ;
126+ const [ report ] = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
139127
140128 expect ( report . content . title ) . toBe ( 'cobaltstrike' ) ;
141129 expect ( report . lineage . source_doc_ref ?. id ) . toBe ( 'cobaltstrike' ) ;
@@ -146,10 +134,7 @@ describe('textIndicatorListAdapter', () => {
146134 parseIndicatorListMock . mockReturnValue ( BLOCKS_FIXTURE ) ;
147135 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
148136
149- const [ report ] = await textIndicatorListAdapter . run (
150- makeSource ( ) ,
151- makeContext ( fetchMock )
152- ) ;
137+ const [ report ] = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
153138
154139 const iocs = report . extracted ?. iocs ?? [ ] ;
155140
@@ -196,10 +181,7 @@ describe('textIndicatorListAdapter', () => {
196181 parseIndicatorListMock . mockReturnValue ( BLOCKS_FIXTURE ) ;
197182 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
198183
199- const [ report ] = await textIndicatorListAdapter . run (
200- makeSource ( ) ,
201- makeContext ( fetchMock )
202- ) ;
184+ const [ report ] = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
203185
204186 const values = ( report . extracted ?. iocs ?? [ ] ) . map ( ( i ) => i . value ) ;
205187 expect ( values . filter ( ( v ) => v === '1.2.3.4' ) ) . toHaveLength ( 1 ) ;
@@ -210,10 +192,7 @@ describe('textIndicatorListAdapter', () => {
210192 parseIndicatorListMock . mockReturnValue ( [ ] ) ;
211193 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
212194
213- const reports = await textIndicatorListAdapter . run (
214- makeSource ( ) ,
215- makeContext ( fetchMock )
216- ) ;
195+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
217196
218197 expect ( reports ) . toHaveLength ( 0 ) ;
219198 } ) ;
@@ -229,10 +208,7 @@ describe('textIndicatorListAdapter', () => {
229208 parseIndicatorListMock . mockReturnValue ( emptyIocBlocks ) ;
230209 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
231210
232- const reports = await textIndicatorListAdapter . run (
233- makeSource ( ) ,
234- makeContext ( fetchMock )
235- ) ;
211+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
236212
237213 expect ( reports ) . toHaveLength ( 0 ) ;
238214 } ) ;
@@ -243,10 +219,7 @@ describe('textIndicatorListAdapter', () => {
243219 . mockResolvedValue ( new Response ( '' , { status : 404 , statusText : 'Not Found' } ) ) ;
244220
245221 await expect (
246- textIndicatorListAdapter . run (
247- makeSource ( ) ,
248- makeContext ( fetchMock )
249- )
222+ textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) )
250223 ) . rejects . toThrow ( / H T T P 4 0 4 / ) ;
251224 } ) ;
252225
@@ -294,10 +267,7 @@ describe('textIndicatorListAdapter', () => {
294267 parseIndicatorListMock . mockReturnValue ( blocks ) ;
295268 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
296269
297- const reports = await textIndicatorListAdapter . run (
298- makeSource ( ) ,
299- makeContext ( fetchMock )
300- ) ;
270+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
301271
302272 // Two blocks exceed the per-document IOC limit, so at least two reports are required.
303273 expect ( reports . length ) . toBeGreaterThanOrEqual ( 2 ) ;
@@ -326,10 +296,7 @@ describe('textIndicatorListAdapter', () => {
326296 parseIndicatorListMock . mockReturnValue ( blocks ) ;
327297 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
328298
329- const reports = await textIndicatorListAdapter . run (
330- makeSource ( ) ,
331- makeContext ( fetchMock )
332- ) ;
299+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
333300
334301 expect ( reports . length ) . toBeGreaterThan ( 1 ) ;
335302 const fps = reports . map ( ( r ) => r . content_fingerprint ) ;
@@ -351,10 +318,7 @@ describe('textIndicatorListAdapter', () => {
351318 parseIndicatorListMock . mockReturnValue ( blocks ) ;
352319 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
353320
354- const reports = await textIndicatorListAdapter . run (
355- makeSource ( ) ,
356- makeContext ( fetchMock )
357- ) ;
321+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
358322
359323 expect ( reports . length ) . toBeGreaterThanOrEqual ( 3 ) ;
360324
@@ -375,10 +339,7 @@ describe('textIndicatorListAdapter', () => {
375339 parseIndicatorListMock . mockReturnValue ( [ bigBlock , ...smallBlocks ] ) ;
376340 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
377341
378- const reports = await textIndicatorListAdapter . run (
379- makeSource ( ) ,
380- makeContext ( fetchMock )
381- ) ;
342+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
382343
383344 for ( const report of reports ) {
384345 expect ( report . extracted ?. iocs ?. length ?? 0 ) . toBeLessThanOrEqual ( MAX_NESTED_PER_DOC ) ;
@@ -414,10 +375,7 @@ describe('textIndicatorListAdapter', () => {
414375 ] ) ;
415376 const fetchMock = jest . fn ( ) . mockResolvedValue ( okResponse ( ) ) ;
416377
417- const reports = await textIndicatorListAdapter . run (
418- makeSource ( ) ,
419- makeContext ( fetchMock )
420- ) ;
378+ const reports = await textIndicatorListAdapter . run ( makeSource ( ) , makeContext ( fetchMock ) ) ;
421379
422380 const allValues = reports . flatMap ( ( r ) => ( r . extracted ?. iocs ?? [ ] ) . map ( ( i ) => i . value ) ) ;
423381 expect ( allValues . filter ( ( v ) => v === '1.1.1.1' ) ) . toHaveLength ( 1 ) ;
@@ -499,8 +457,6 @@ describe('textIndicatorListAdapter — attribution and credentials', () => {
499457 . mockResolvedValue ( new Response ( 'nope' , { status : 503 , statusText : 'Service Unavailable' } ) )
500458 ) ;
501459
502- await expect ( textIndicatorListAdapter . run ( makeSource ( ) , failing ) ) . rejects . toThrow (
503- / H T T P 5 0 3 /
504- ) ;
460+ await expect ( textIndicatorListAdapter . run ( makeSource ( ) , failing ) ) . rejects . toThrow ( / H T T P 5 0 3 / ) ;
505461 } ) ;
506462} ) ;
0 commit comments