Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell committed Nov 7, 2024
1 parent 1d8639b commit 8f99e70
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion secator/celery_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,6 @@ def get_task_ids(result, ids=[]):
if hasattr(result, 'parent') and result.parent:
CeleryData.get_task_ids(result.parent, ids=ids)

except kombu.exceptions.DecodeError as e:
except kombu.exceptions.DecodeError:
debug('kombu decode error', sub='celery.data.get_task_ids')
return
2 changes: 1 addition & 1 deletion secator/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_command_options(config):
# Check if opt already defined in config
if opt_value_in_config:
if conf.get('required', False):
debug('OPT (skipped: opt is required and defined in config)', obj={'opt': opt}, sub=f'cli.{config.name}', verbose=True)
debug('OPT (skipped: opt is required and defined in config)', obj={'opt': opt}, sub=f'cli.{config.name}', verbose=True) # noqa: E501
continue
if opt_default is not None and opt_value_in_config != opt_default and opt_is_flag:
conf['reverse'] = True
Expand Down
6 changes: 3 additions & 3 deletions secator/hooks/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from celery import shared_task

from secator.config import CONFIG
from secator.output_types import FINDING_TYPES, EXECUTION_TYPES
from secator.output_types import FINDING_TYPES
from secator.runners import Scan, Task, Workflow
from secator.utils import debug, escape_mongodb_url, should_update
from secator.utils import debug, escape_mongodb_url

# import gevent.monkey
# gevent.monkey.patch_all()
Expand Down Expand Up @@ -45,7 +45,7 @@ def update_runner(self):
update = self.toDict()
chunk = update.get('chunk')
_id = self.context.get(f'{type}_chunk_id') if chunk else self.context.get(f'{type}_id')
debug('to_update', sub='hooks.mongodb', id=_id, obj=get_runner_dbg(self), obj_after=True, obj_breaklines=False, verbose=True)
debug('to_update', sub='hooks.mongodb', id=_id, obj=get_runner_dbg(self), obj_after=True, obj_breaklines=False, verbose=True) # noqa: E501
start_time = time.time()
if _id:
db = client.main
Expand Down
14 changes: 7 additions & 7 deletions secator/runners/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _print_item(self, item, force=False):

# Item is an output type
if isinstance(item, OutputType):
self.debug(repr(item), sub=f'item', allow_no_process=False, verbose=True)
self.debug(repr(item), sub='item', allow_no_process=False, verbose=True)
_type = item._type
print_this_type = getattr(self, f'print_{_type}', True)
if not print_this_type:
Expand Down Expand Up @@ -348,7 +348,7 @@ def _print_item(self, item, force=False):

# Item is a line
elif isinstance(item, str):
self.debug(item, sub=f'line', allow_no_process=False, verbose=True)
self.debug(item, sub='line', allow_no_process=False, verbose=True)
if self.print_line or force:
self._print(item, out=sys.stderr, end='\n')

Expand Down Expand Up @@ -471,16 +471,16 @@ def run_hooks(self, hook_type, *args):
fun = self.get_func_path(hook)
try:
if hook_type == 'on_interval' and not should_update(CONFIG.runners.backend_update_frequency, self.last_updated_db):
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim gray11]skipped[/]'}, id=_id, sub='hooks.db', verbose=True)
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim gray11]skipped[/]'}, id=_id, sub='hooks.db', verbose=True) # noqa: E501
return
if not self.enable_hooks or self.no_process:
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim gray11]skipped[/]'}, id=_id, sub='hooks', verbose=True)
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim gray11]skipped[/]'}, id=_id, sub='hooks', verbose=True) # noqa: E501
continue
# self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim yellow]started[/]'}, id=_id, sub='hooks', verbose=True)
# self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim yellow]started[/]'}, id=_id, sub='hooks', verbose=True) # noqa: E501
result = hook(self, *args)
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim green]success[/]'}, id=_id, sub='hooks', verbose=True)
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim green]success[/]'}, id=_id, sub='hooks', verbose=True) # noqa: E501
except Exception as e:
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim red]failed[/]'}, id=_id, sub='hooks', verbose=True)
self.debug('', obj={f'{name} [dim yellow]->[/] {fun}': '[dim red]failed[/]'}, id=_id, sub='hooks', verbose=True) # noqa: E501
error = Error.from_exception(e)
error.message = f'Hook "{fun}" execution failed.'
error._source = self.unique_name
Expand Down
1 change: 0 additions & 1 deletion secator/runners/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from secator.output_types import Error, Target, Stat
from secator.runners import Runner
from secator.template import TemplateLoader
from secator.utils import debug


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion secator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import ifaddr
import yaml

from secator.definitions import (DEBUG, DEBUG_COMPONENT, VERSION, DEV_PACKAGE)
from secator.definitions import (DEBUG_COMPONENT, VERSION, DEV_PACKAGE)
from secator.config import CONFIG, ROOT_FOLDER, LIB_FOLDER
from secator.rich import console

Expand Down

0 comments on commit 8f99e70

Please sign in to comment.