Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(entrypoints): filter entrypoints by connectivity and status #588

Merged
merged 8 commits into from
Aug 21, 2024
21 changes: 20 additions & 1 deletion src/Commands/GetEntryPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(RestProjectsOptions, {
useValue: {
Expand All @@ -48,7 +65,9 @@ export class GetEntryPoints implements CommandModule {
try {
const entryPoints: EntryPoint[] = await entryPointsManager.entrypoints(
args.project as string,
args.limit as number
args.limit as number,
args.connectivity as string[],
args.status as string[]
);

if (args.verbose) {
Expand Down
5 changes: 2 additions & 3 deletions src/Commands/RunScan.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
Exclusions,
Module,
Scans,
ScanWarning,
TestType
ScanWarning
} from '../Scan';
import {
anything,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/EntryPoint/EntryPoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export interface EntryPoints {
entrypoints(projectId: string, limit: number): Promise<EntryPoint[]>;
entrypoints(
projectId: string,
limit?: number,
connectivity?: string[],
status?: string[]
): Promise<EntryPoint[]>;
}

export const EntryPoints: unique symbol = Symbol('EntryPoints');
Expand Down
8 changes: 6 additions & 2 deletions src/EntryPoint/RestEntryPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export class RestEntryPoints implements EntryPoints {

public async entrypoints(
projectId: string,
limit: number = 10
limit: number = 10,
connectivity?: string[],
status?: string[]
derevnjuk marked this conversation as resolved.
Show resolved Hide resolved
): Promise<EntryPoint[]> {
let remaining = limit;
const data: EntryPoint[] = [];
Expand All @@ -68,7 +70,9 @@ export class RestEntryPoints implements EntryPoints {
params: {
nextId,
nextCreatedAt,
limit: Math.min(remaining, this.entrypointsPaginationBatchSize)
limit: Math.min(remaining, this.entrypointsPaginationBatchSize),
connectivity,
status
}
});

Expand Down
Loading