Fix for running qualys from admin interface.

parent 1781f800
......@@ -30,6 +30,8 @@ services:
# Configure database to persist accross restarts of the development environment.
volumes:
- ./dev_db/:/var/lib/mysql/
# overwrite memory hungry default config for docker mysql
- ./etc/mysql-minimal-memory.cnf:/etc/mysql/conf.d/mysql.cnf
# task executer
worker:
......
innodb_buffer_pool_size=5M
innodb_log_buffer_size=256K
query_cache_size=0
max_connections=10
key_buffer_size=8
thread_cache_size=0
host_cache_size=0
innodb_ft_cache_size=1600000
innodb_ft_total_cache_size=32000000
# per thread or per operation settings
thread_stack=131072
sort_buffer_size=32K
read_buffer_size=8200
read_rnd_buffer_size=8200
max_heap_table_size=16K
tmp_table_size=1K
bulk_insert_buffer_size=0
join_buffer_size=128
net_buffer_length=1K
innodb_sort_buffer_size=64K
#settings that relate to the binary log (if enabled)
binlog_cache_size=4K
binlog_stmt_cache_size=4K
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-11-09 22:43
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0003_auto_20171109_1427'),
]
operations = [
migrations.AlterField(
model_name='job',
name='result_id',
field=models.CharField(blank=True, help_text='celery asyncresult ID for tracing task', max_length=255, null=True, unique=True),
),
]
......@@ -16,7 +16,8 @@ class Job(models.Model):
name = models.CharField(max_length=255, help_text="name of the job")
task = models.TextField(help_text="celery task signature in string form")
result_id = models.CharField(unique=True, max_length=255, help_text="celery asyncresult ID for tracing task")
result_id = models.CharField(unique=True, null=True, blank=True, max_length=255,
help_text="celery asyncresult ID for tracing task")
status = models.CharField(max_length=255, help_text="status of the job")
result = JSONField(help_text="output of the task as JSON", encoder_class=ResultEncoder)
......@@ -35,7 +36,7 @@ class Job(models.Model):
# publish original task which stores the result in this Job object
result_id = (task | cls.store_result.s(job_id=job.id)).apply_async(*args, **kwargs)
job.name = name
job.name = name[:255]
job.result_id = result_id.id
job.status = 'created'
job.save()
......
......@@ -196,13 +196,18 @@ class UrlAdmin(admin.ModelAdmin):
task = security_headers_scan_urls(urls=urls, execute=False)
name = "Scan Security Headers (%s) " % str(urls)
job = Job.create(task, name, request)
self.message_user(request, "%s: job created, id:%s" % (name, str(job)))
link = reverse('admin:app_job_change', args=(job.id,))
self.message_user(request, '%s: job created, id: <a href="%s">%s</a>' % (name, link, str(job)))
security_headers.short_description = "🔬 Scan Security Headers"
actions.append('security_headers')
def plain_http_scan(self, request, queryset):
plain_http_scan_urls([url for url in queryset])
self.message_user(request, "Scan Plain Http: done")
urls = list(queryset)
task = plain_http_scan_urls(urls=urls, execute=False)
name = "Scan Plain Http (%s) " % str(urls)
job = Job.create(task, name, request)
link = reverse('admin:app_job_change', args=(job.id,))
self.message_user(request, '%s: job created, id: <a href="%s">%s</a>' % (name, link, str(job)))
plain_http_scan.short_description = "🔬 Scan Plain Http"
actions.append('plain_http_scan')
......
......@@ -20,6 +20,7 @@ from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.template.response import TemplateResponse
from django.views import static
# Django 1.10 http://stackoverflow.com/questions/38744285/
# django-urls-error-view-must-be-a-callable-or-a-list-tuple-in-the-case-of-includ#38744286
......@@ -52,6 +53,8 @@ if settings.DEBUG:
except ImportError:
pass
urlpatterns.append(url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}))
# debugging
# urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment