diff --git a/hammer/reporting-remediation/analytics/security_issues_csv_report.py b/hammer/reporting-remediation/analytics/security_issues_csv_report.py index 321eeee9..e2db79b3 100755 --- a/hammer/reporting-remediation/analytics/security_issues_csv_report.py +++ b/hammer/reporting-remediation/analytics/security_issues_csv_report.py @@ -57,7 +57,7 @@ def add_closed_issues_to_sheet(self, ddb_table, work_book, sheet_name, issue_cla # Adding row data to Execl sheet with DynamoDB table field values. AddRecordsToSheet.add_records(worksheet, sheet_name, account_id, account_name, issue, row_number) - def generate(self): + def generate(self, message=None): main_account_session = AssumeRole.get_session(region=self.config.aws.region) issues = [ (self.config.sg.ddb_table_name, "Insecure Services", SecurityGroupIssue), @@ -113,6 +113,8 @@ def generate(self): if self.config.slack.enabled: channel = self.config.csv.slack_channel + if message is not None: + channel = message.body['channel'] slack_obj = SlackNotification(config=self.config) logging.debug(f"Uploading CSV report to slack ({channel})") slack_obj.send_file_notification( @@ -125,7 +127,6 @@ def generate(self): channel=channel) - if __name__ == '__main__': module_name = sys.modules[__name__].__loader__.name set_logging(level=logging.DEBUG, logfile=f"/var/log/hammer/{module_name}.log") diff --git a/hammer/reporting-remediation/bot/commands.py b/hammer/reporting-remediation/bot/commands.py index 7d79a24c..16869dc3 100644 --- a/hammer/reporting-remediation/bot/commands.py +++ b/hammer/reporting-remediation/bot/commands.py @@ -4,6 +4,7 @@ import time +from analytics.security_issues_csv_report import CSVReport from slackbot.bot import listen_to, respond_to from slackbot.settings import config @@ -333,3 +334,12 @@ def handle_scan_thread_answers(message, user_response): pass except Exception as e: message.reply(str(e)) + + +@respond_to('^csv_report$', re.IGNORECASE) +def get_csv_report(message): + """ shows global modules status """ + response = "\n" + csv_report = CSVReport() + message.reply("Security issues report generation is in process. Will send reports once ready...") + csv_report.generate(message)