Beispiel #1
0
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)
Beispiel #2
0
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, "")
                  })
Beispiel #3
0
def loadaccounts(request):
    response = ScoutView.Accounts()
    return {'loadaccounts': response}
Beispiel #4
0
def parsereport(request):
    if request.method == "PUT":
        ScoutView.ParseReport(request.body)
    return HttpResponse(status=201)
Beispiel #5
0
def getreport(request, report):
    return render(request, 'report.html', context=ScoutView.Report(report))
Beispiel #6
0
def getaccount(request, account):
    return render(request, 'account.html', context=ScoutView.View(account))
Beispiel #7
0
def index(request):
    context = {'dashboard': 'active'}
    return render(request, 'index.html', context=ScoutView.View())
Beispiel #8
0
def home(request):
    return render(request, 'core/index.html', context=ScoutView.View())