이경수

dynamic.html 추가

......@@ -18,14 +18,14 @@ from django.contrib import admin
from django.contrib.auth import views
from VulnNotti.views import *
from django.conf import settings
from myapp.views import *
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', HomeView.as_view(), name='home'),
url(r'^home/', HomeView.as_view(), name='home'),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
url(r'^myapp/static', StaticView.as_view(), name='static'),
url(r'^edit/', EditView.as_view(), name='edit'),
url(r'^accounts/', include('django.contrib.auth.urls')),
......
from django.contrib import admin
from myapp.models import *
# Register your models here.
class UploadFileAdmin(admin.ModelAdmin):
list_display = ('title', 'file')
admin.site.register(UploadFileModel, UploadFileAdmin)
......@@ -47,15 +47,16 @@
<h1 class="text-uppercase mb-0">동적 분석 페이지입니다.</h1>
<hr class="star-light">
<h2 class="font-weight-light mb-0">툴을 다운로드 받은 후 결과 파일을 업로드 해주세요.</h2>
<a href="{% static 'img/profile.png' %}" download>
</div>
<div>
<a href="{% static 'img/linux_vuln_check_script.sh' %}" download>
<button class="btn btn-success">Download!</button>
</a>
<button class="btn btn-warning">Upload!</button>
<form method="post" enctype="multipart/form-data">{% csrf_token %}
<input type="file" name="sentFile" />
<input type="submit" name="submit" value="Upload" />
<!-- <button class="btn btn-warning">Upload!</button> -->
<form method="post" style="display: inline;" enctype="multipart/form-data">{% csrf_token %}
<input class="btn btn-warning" style="background-color: #fcc;"value="Select File" type="file" name="sentFile" />
<input class="btn btn-warning" style="color: white;" type="submit" name="submit" value="Upload!" />
</form>
</div>
</header>
......@@ -89,7 +90,7 @@
<th>분류</th>
<th>점검항목</th>
<th>항목 중요도</th>
<th>결과</th>
<th style="width: 50%;">결과</th>
</tr>
<tbody>
{% for object in object_list %}
......
This diff is collapsed. Click to expand it.
from django.conf.urls import url, include
from myapp.views import *
app_name = 'myapp'
urlpatterns = [
url(r'^static/', StaticView.as_view(), name='static'),
url(r'^dynamic/', DynamicView.as_view(), name='dynamic'),
]
......
......@@ -3,6 +3,7 @@ from django.views.generic import FormView
from django.views.generic import View
from django.db import connection
from django.shortcuts import render
from django.http import JsonResponse
from django.http import HttpResponseRedirect
from .forms import UploadFileForm
import re
......@@ -53,7 +54,7 @@ class DynamicView(TemplateView):
# print(str(line, 'UTF-8'))
# r = re.compile('\@.+\@', )
r = re.compile(r'\@(.+)\@', re.MULTILINE)
r = re.compile(r'\@(.*?)\@', re.DOTALL)
results = r.findall(temp)
result_list = dict(enumerate(results, 0))
......@@ -87,10 +88,18 @@ class StaticView(TemplateView):
template_name = 'static.html'
def get(self, request, *args, **kwargs):
context = {}
context['form'] = testform
query = 'SELECT * FROM vuln.vulnInfo'
if request.is_ajax():
data = 1
idx = request.GET.get('idx')
method = request.GET.get('method')
print(idx)
print(method)
return JsonResponse(data, safe=False)
context = {}
query = 'SELECT * FROM vuln.vulnInfo LIMIT 50'
param_list = []
......@@ -99,6 +108,8 @@ class StaticView(TemplateView):
columns = [column[0] for column in cursor.description]
print(columns)
object_list = []
for row in cursor.fetchall():
......@@ -125,27 +136,27 @@ class StaticView(TemplateView):
print(text)
return render(self.request, self.template_name, context)
class ServerList(View):
template_name = 'test.html'
def get(self, request, *args, **kwargs):
query = 'SELECT * FROM vuln.vulnInfo'
param_list = []
with connection.cursor() as cursor:
cursor.execute(query, param_list)
columns = [column[0] for column in cursor.description]
for row in cursor.fetchall():
object_list.append(dict(zip(columns, row)))
context = {}
object_list = []
context['object_list'] = object_list
return render(self.request, self.template_name, context)
class TableView(TemplateView):
template_name = 'myapp_table.html'
# class ServerList(View):
# template_name = 'test.html'
#
# def get(self, request, *args, **kwargs):
#
# query = 'SELECT * FROM vuln.vulnInfo'
# param_list = []
#
# with connection.cursor() as cursor:
# cursor.execute(query, param_list)
#
# columns = [column[0] for column in cursor.description]
#
# for row in cursor.fetchall():
# object_list.append(dict(zip(columns, row)))
#
# context = {}
# object_list = []
# context['object_list'] = object_list
#
# return render(self.request, self.template_name, context)
#
# class TableView(TemplateView):
# template_name = 'myapp_table.html'
......
This diff is collapsed. Click to expand it.