Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
maksadbek committed Aug 26, 2024
2 parents 5b4eed4 + 62cff9b commit 35c4406
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
7 changes: 0 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ RUN set -eux; \
chmod -R g+rwX /home/node; \
chown -R 1000 /home/node

RUN set -eux; \
apk upgrade --no-cache; \
apk add --no-cache libcap; \
rm -rf /var/cache/apk/*

RUN setcap 'cap_net_raw+ep' $(which node)

# change workgin dir
WORKDIR $HOME/

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brightsec/cli",
"version": "12.3.0",
"version": "12.4.0-next.1",
"private": false,
"repository": {
"type": "git",
Expand Down
22 changes: 20 additions & 2 deletions src/Commands/GetEntryPoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import 'reflect-metadata';
import { Logger, logger } from '../Utils';
import { GetEntryPoints } from './GetEntryPoints';
import { EntryPoints } from '../EntryPoint';
import { mock, reset, spy, instance, when, anything, verify } from 'ts-mockito';
import {
mock,
reset,
spy,
instance,
when,
anything,
verify,
objectContaining
} from 'ts-mockito';
import { container } from 'tsyringe';
import { Arguments } from 'yargs';

Expand Down Expand Up @@ -34,14 +43,23 @@ describe('GetEntryPoints', () => {
it('should correctly pass config from args', async () => {
const args = {
project: '1',
limit: 10,
verbose: true,
pretty: true,
connectivity: ['connected', 'ok'],
status: ['open', 'closed', 'failed'],
_: [],
$0: ''
} as Arguments;

when(processSpy.exit(anything())).thenReturn(undefined);
when(
mockedEntryPoints.entrypoints({ projectId: '1', limit: 10 })
mockedEntryPoints.entrypoints(
objectContaining({
projectId: '1',
limit: 10
})
)
).thenResolve([
{
id: '1',
Expand Down
25 changes: 14 additions & 11 deletions src/Commands/GetEntryPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export class GetEntryPoints implements CommandModule {
describe: 'Limit the number of entrypoints',
default: 10
})
.option('pretty', {
describe: 'Pretty print the output',
boolean: true,
default: false
})
.option('connectivity', {
describe: 'Filter by connectivity',
array: true,
Expand Down Expand Up @@ -70,20 +75,18 @@ export class GetEntryPoints implements CommandModule {
status: args.status as string[]
});

if (args.verbose) {
// eslint-disable-next-line no-console
console.log('%j', entryPoints);
} else {
// eslint-disable-next-line no-console
console.log(
'%j',
entryPoints.map((entryPoint) => ({
const ep = args.verbose
? entryPoints
: entryPoints.map((entryPoint) => ({
id: entryPoint.id,
method: entryPoint.method,
url: entryPoint.url
}))
);
}
}));

// eslint-disable-next-line no-console
console.log(
args.pretty ? JSON.stringify(ep, null, 2) : JSON.stringify(ep)
);

process.exitCode = 0;
} catch (e) {
Expand Down

0 comments on commit 35c4406

Please sign in to comment.