Exemple #1
0
 def __init__(self, profile, file_path=None, foobar=None):
     self.profile = profile
     self.file_path = file_path
     self.jsrw = JavaScriptReaderWriter(self.profile)
     self.exceptions = self.jsrw.load_from_file(config_type=EXCEPTIONS,
                                                config_path=self.file_path,
                                                first_line=True)
class RuleExceptions(object):
    def __init__(self, profile, file_path=None):
        self.profile = profile
        self.file_path = file_path
        self.jsrw = JavaScriptReaderWriter(self.profile)
        self.exceptions = self.jsrw.load_from_file(
            file_type=DEFAULT_EXCEPTIONS_FILE,
            config_path=self.file_path,
            first_line=True)

    def process(self, cloud_provider):
        for service in self.exceptions:
            for rule in self.exceptions[service]:
                filtered_items = []
                if rule not in cloud_provider.services[service]['findings']:
                    print_debug('Warning:: key error should not be happening')
                    continue
                for item in cloud_provider.services[service]['findings'][rule][
                        'items']:
                    if item not in self.exceptions[service][rule]:
                        filtered_items.append(item)
                cloud_provider.services[service]['findings'][rule][
                    'items'] = filtered_items
                cloud_provider.services[service]['findings'][rule]['flagged_items'] = \
                    len(cloud_provider.services[service]['findings'][rule]['items'])
Exemple #3
0
 def __init__(self, profile, report_dir, timestamp=False, exceptions={}):
     self.report_dir = report_dir
     self.profile = profile.replace('/', '_').replace('\\', '_')  # Issue 111
     self.current_time = datetime.datetime.now(dateutil.tz.tzlocal())
     if timestamp != False:
         self.timestamp = self.current_time.strftime("%Y-%m-%d_%Hh%M%z") if not timestamp else timestamp
         self.profile = '%s-%s' % (self.profile, self.timestamp)
     self.exceptions = exceptions
     self.scout2_report_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
     self.html_data_path = os.path.join(self.scout2_report_data_path, 'html')
     self.jsrw = JavaScriptReaderWriter(self.profile, report_dir, timestamp)