diff --git a/src/Commands/GetEntryPoints.spec.ts b/src/Commands/GetEntryPoints.spec.ts index 4dee1104..62976718 100644 --- a/src/Commands/GetEntryPoints.spec.ts +++ b/src/Commands/GetEntryPoints.spec.ts @@ -40,7 +40,9 @@ describe('GetEntryPoints', () => { } as Arguments; when(processSpy.exit(anything())).thenReturn(undefined); - when(mockedEntryPoints.entrypoints('1', 10)).thenResolve([ + when( + mockedEntryPoints.entrypoints({ projectId: '1', limit: 10 }) + ).thenResolve([ { id: '1', method: 'GET', diff --git a/src/Commands/GetEntryPoints.ts b/src/Commands/GetEntryPoints.ts index 389faa84..8336f728 100644 --- a/src/Commands/GetEntryPoints.ts +++ b/src/Commands/GetEntryPoints.ts @@ -30,6 +30,23 @@ export class GetEntryPoints implements CommandModule { describe: 'Limit the number of entrypoints', default: 10 }) + .option('connectivity', { + describe: 'Filter by connectivity', + array: true, + choices: [ + 'ok', + 'unreachable', + 'problem', + 'skipped', + 'unauthorized', + 'unavailable' + ] + }) + .option('status', { + describe: 'Filter by status', + array: true, + choices: ['new', 'changed', 'tested', 'vulnerable'] + }) .middleware((args: Arguments) => container.register(RestProjectsOptions, { useValue: { @@ -46,10 +63,12 @@ export class GetEntryPoints implements CommandModule { const entryPointsManager: EntryPoints = container.resolve(EntryPoints); try { - const entryPoints: EntryPoint[] = await entryPointsManager.entrypoints( - args.project as string, - args.limit as number - ); + const entryPoints: EntryPoint[] = await entryPointsManager.entrypoints({ + projectId: args.project as string, + limit: args.limit as number, + connectivity: args.connectivity as string[], + status: args.status as string[] + }); if (args.verbose) { // eslint-disable-next-line no-console diff --git a/src/Commands/RunScan.spec.ts b/src/Commands/RunScan.spec.ts index 7f119d93..ab7665d0 100644 --- a/src/Commands/RunScan.spec.ts +++ b/src/Commands/RunScan.spec.ts @@ -6,8 +6,7 @@ import { Exclusions, Module, Scans, - ScanWarning, - TestType + ScanWarning } from '../Scan'; import { anything, @@ -128,7 +127,7 @@ describe('RunScan', () => { when( mockedScans.create( objectContaining({ - tests: args.test as TestType[], + tests: args.test as string[], name: args.name as string, module: args.module as Module, authObjectId: args.auth as string, diff --git a/src/EntryPoint/EntryPoints.ts b/src/EntryPoint/EntryPoints.ts index a2156f52..d79ebea2 100644 --- a/src/EntryPoint/EntryPoints.ts +++ b/src/EntryPoint/EntryPoints.ts @@ -1,5 +1,12 @@ +export interface EntryPointsListOptions { + projectId: string; + limit?: number; + connectivity?: string[]; + status?: string[]; +} + export interface EntryPoints { - entrypoints(projectId: string, limit: number): Promise; + entrypoints(filter: EntryPointsListOptions): Promise; } export const EntryPoints: unique symbol = Symbol('EntryPoints'); diff --git a/src/EntryPoint/RestEntryPoints.spec.ts b/src/EntryPoint/RestEntryPoints.spec.ts index e8c11d93..3cdc0d5e 100644 --- a/src/EntryPoint/RestEntryPoints.spec.ts +++ b/src/EntryPoint/RestEntryPoints.spec.ts @@ -38,7 +38,10 @@ describe('RestEntryPoints', () => { .get('/api/v2/projects/1/entry-points?limit=10') .reply(200, { items: [{ id: 1, name: 'entrypoint1' }] }); - const result = await restEntryPoints.entrypoints('1', 10); + const result = await restEntryPoints.entrypoints({ + projectId: '1', + limit: 10 + }); expect(result).toEqual([{ id: 1, name: 'entrypoint1' }]); }); @@ -94,7 +97,10 @@ describe('RestEntryPoints', () => { ] }); - const result = await restEntryPoints.entrypoints('1', 111); + const result = await restEntryPoints.entrypoints({ + projectId: '1', + limit: 111 + }); expect(result).toEqual([ { id: 1, name: 'entrypoint1', createdAt: '2024-08-06T09:40:50.226Z' }, diff --git a/src/EntryPoint/RestEntryPoints.ts b/src/EntryPoint/RestEntryPoints.ts index 8d114d45..dfc052ad 100644 --- a/src/EntryPoint/RestEntryPoints.ts +++ b/src/EntryPoint/RestEntryPoints.ts @@ -1,4 +1,4 @@ -import { EntryPoints, EntryPoint } from './EntryPoints'; +import { EntryPoints, EntryPoint, EntryPointsListOptions } from './EntryPoints'; import { ProxyFactory } from '../Utils'; import axios, { Axios } from 'axios'; import { inject, injectable } from 'tsyringe'; @@ -52,10 +52,11 @@ export class RestEntryPoints implements EntryPoints { }); } - public async entrypoints( - projectId: string, - limit: number = 10 - ): Promise { + public async entrypoints({ + limit = 10, + projectId, + ...filters + }: EntryPointsListOptions): Promise { let remaining = limit; const data: EntryPoint[] = []; let nextId: string; @@ -68,6 +69,7 @@ export class RestEntryPoints implements EntryPoints { params: { nextId, nextCreatedAt, + ...filters, limit: Math.min(remaining, this.entrypointsPaginationBatchSize) } });