Skip to content

Commit

Permalink
Allow users to skip initial scan
Browse files Browse the repository at this point in the history
This patch allows users to skip the initial security scan when
registering hosts with the perimeter firewall.
  • Loading branch information
lkiesow committed Nov 30, 2023
1 parent 02d7381 commit cdcd1f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ token: <api-token>
# If you want to automatically register newly added hosts
# Default: false
auto-register: false

# If you want to skip the initial security scan by default.
# Default: false
auto-skip-scan: false
```
## Usane
Expand Down
18 changes: 14 additions & 4 deletions deterrerscli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from deterrerscli import types

auto_register = False
auto_skip_scan = False


def print_format(data, format: str):
Expand All @@ -20,10 +21,12 @@ def print_format(data, format: str):
def cli():
global deterrers
global auto_register
global auto_skip_scan
with open(pathlib.Path().home() / '.deterrers.yml', 'r') as f:
config = yaml.safe_load(f)
deterrers = deterrersapi.Deterrers(config['url'], config['token'])
auto_register = config.get('auto-register', False)
auto_skip_scan = config.get('auto-skip-scana', False)


@cli.command()
Expand Down Expand Up @@ -61,13 +64,17 @@ def delete(ipv4):
@click.option('--firewall', '-f', default='', type=types.HOST_FIREWALL_TYPE)
@click.option('--register/--no-register', default=False,
help='If the added host should be registered immediately')
@click.option('--skip-scan/--no-skip-scan', default=None,
help='If the added host should get an initial security scan. '
'Only applies if it is being registered')
@click.argument('ipv4', type=types.IPV4_TYPE)
def add(ipv4, admin, profile, firewall, register):
def add(ipv4, admin, profile, firewall, register, skip_scan):
'''Add IP address to DETERRERS.
'''
deterrers.add(ipv4, admin, profile, firewall)
if profile and auto_register or register:
deterrers.action(ipv4, 'register')
skip_scan = auto_skip_scan if skip_scan is None else skip_scan
deterrers.action(ipv4, 'register', skip_scan)


@cli.command()
Expand All @@ -94,10 +101,13 @@ def action():

@action.command()
@click.argument('ipv4', type=types.IPV4_TYPE)
def register(ipv4):
@click.option('--skip-scan/--no-skip-scan', default=None,
help='If the added host should get an initial security scan')
def register(ipv4, skip_scan):
'''Activate profile in perimeter firewall.
'''
deterrers.action(ipv4, 'register')
skip_scan = auto_skip_scan if skip_scan is None else skip_scan
deterrers.action(ipv4, 'register', skip_scan)


@action.command()
Expand Down

0 comments on commit cdcd1f5

Please sign in to comment.