def run_notifiers(self): """Execute all requested notifiers.""" sys.stdout.flush() sys.stderr.flush() notifiers = get_notifiers() for notifier_name in self.notifiers: notifier_args = [self.results, self.controls] if notifier_name == 'locker': notifier_args.append(self.locker) notifier = notifiers[notifier_name](*notifier_args) notifier.notify()
def _init_arguments(self): self.add_argument('-V', '--version', help='Displays the auditree framework version.', action='version', version=f'Auditree Framework version v{__version__}') self.add_argument('-v', '--verbose', help='Displays verbose output.', action='store_const', const=2, default=1) self.add_argument('--fetch', help='Enables the fetch process.', action='store_true', default=False) self.add_argument( '--check', help=( 'Enables the check process. ' 'Check groupings can be a comma separated list without spaces.' ), metavar='chk.grp1,chk.grp2,...', nargs='?', const='') self.add_argument( '--evidence', help=( 'Defines the evidence storage mode. Defaults to %(default)s.' ), choices=['local', 'no-push', 'full-remote'], default='no-push') self.add_argument( '--fix', help='Attempts to fix check failures. Defaults to %(default)s.', choices=['off', 'on', 'dry-run'], default='off') self.add_argument( '-C', '--compliance-config', help='Specifies the path/name of the compliance config JSON file.', metavar='auditree.json', default=None) self.add_argument( '--creds-path', help=('Specifies the path/name of the credentials ini file. ' 'Defaults to %(default)s.'), metavar='/path/to/creds.ini', default='~/.credentials') notify_options = [k for k in get_notifiers().keys() if k != 'stdout'] self.add_argument( '--notify', help=('Specifies a list of notifiers for sending notifications. ' 'Valid values (can be a comma separated list - no spaces): ' f'{", ".join(notify_options)}. NOTE: In addition to those ' 'specified, the %(default)s notifier will always execute.'), metavar='[slack,gh_issues,...]', default='stdout') self.add_argument( '--force', help='Forces an evidence to be fetched, ignoring TTL.', metavar='raw/category/evidence.ext', action='append', default=[]) self.add_argument( '--include', help='Specifies the path/name of the fetcher include JSON file.', metavar='fetchers.json', default=None) self.add_argument( '--exclude', help='Specifies the path/name of the fetcher exclude JSON file.', metavar='fetchers.json', default=None)