Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/api csv report #63

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand All @@ -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")
Expand Down
10 changes: 10 additions & 0 deletions hammer/reporting-remediation/bot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)