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(*): add timeout flag to all commands #597

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Commands/GetEntryPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export class GetEntryPoints implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
})
);
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/PollingScanStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export class PollingScanStatus implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
})
);
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/RetestScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export class RetestScan implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/RunRepeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class RunRepeater implements CommandModule {
useValue: {
uri: args.repeaterServer as string,
token: args.token as string,
connectTimeout: 10000,
connectTimeout: args.timeout as number,
proxyUrl: (args.proxyBright ?? args.proxy) as string,
insecure: args.insecure as boolean
}
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/RunScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export class RunScan implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
})
);
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/StopScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export class StopScan implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
})
);
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/UploadArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class UploadArchive implements CommandModule {
insecure: args.insecure as boolean,
baseURL: args.api as string,
apiKey: args.token as string,
proxyURL: (args.proxyBright ?? args.proxy) as string
proxyURL: (args.proxyBright ?? args.proxy) as string,
timeout: args.timeout as number
}
});
});
Expand Down
8 changes: 8 additions & 0 deletions src/Config/CliBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export class CliBuilder {
describe:
'Specify a proxy URL to route all inbound traffic through. For more information, see the --proxy option.'
})
.option('timeout', {
describe: 'Request timeout in seconds',
default: 30,
type: 'number',
coerce(arg: number) {
return arg * 1000;
}
})
.conflicts({
proxy: ['proxy-bright', 'proxy-target'],
hostname: 'cluster'
Expand Down
8 changes: 1 addition & 7 deletions src/EntryPoint/RestEntryPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ export class RestEntryPoints implements EntryPoints {
constructor(
@inject(ProxyFactory) private readonly proxyFactory: ProxyFactory,
@inject(RestProjectsOptions)
{
baseURL,
apiKey,
insecure,
proxyURL,
timeout = 10000
}: RestProjectsOptions
{ baseURL, apiKey, insecure, proxyURL, timeout }: RestProjectsOptions
) {
const {
httpAgent = new http.Agent(),
Expand Down
2 changes: 1 addition & 1 deletion src/Scan/RestScans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class RestScans implements Scans {
@inject(delay(() => CliInfo)) private readonly info: CliInfo,
@inject(ProxyFactory) private readonly proxyFactory: ProxyFactory,
@inject(RestScansOptions)
{ baseURL, apiKey, insecure, proxyURL, timeout = 10000 }: RestScansOptions
{ baseURL, apiKey, insecure, proxyURL, timeout }: RestScansOptions
) {
const {
httpAgent = new http.Agent(),
Expand Down
Loading