def config(request): context = {'aws_account': 'active'} if request.method == 'POST': try: session = boto3.Session( aws_access_key_id=request.POST['access_key'], aws_secret_access_key=request.POST['secret_key']) sts_client = session.client('sts') account_id = sts_client.get_caller_identity()["Account"] if account_id in ScoutView.Accounts(): messages.warning(request, 'Account Already Exists') else: created = Account.objects.create( user=request.user, nickname=request.POST.get('nickname', ''), aws_access_key=request.POST.get('access_key'), aws_secret_key=request.POST.get('secret_key'), account_id=account_id, last_scan_time=timezone.now(), ) runscan.delay(request.POST['access_key'], request.POST['secret_key']) messages.success(request, 'Credentials Valid!') return redirect('/config') except Exception as e: messages.warning(request, '%s' % e) return redirect('/config') return render(request, 'config.html', context=context)
def service(request, service): if request.method == "POST": try: newticket = issue(request.POST['board'], request.POST['title'], request.POST['description']) messages.success(request, 'JIRA Created: %s' % newticket) except Exception as e: messages.warning(request, '%s' % e) return render(request, 'findings.html', context={ "service": service, "response": ScoutView.Service(service, "") })
def loadaccounts(request): response = ScoutView.Accounts() return {'loadaccounts': response}
def parsereport(request): if request.method == "PUT": ScoutView.ParseReport(request.body) return HttpResponse(status=201)
def getreport(request, report): return render(request, 'report.html', context=ScoutView.Report(report))
def getaccount(request, account): return render(request, 'account.html', context=ScoutView.View(account))
def index(request): context = {'dashboard': 'active'} return render(request, 'index.html', context=ScoutView.View())
def home(request): return render(request, 'core/index.html', context=ScoutView.View())