Skip to content

Commit

Permalink
initial user management and restructured models
Browse files Browse the repository at this point in the history
  • Loading branch information
anandtiwarics committed Jul 19, 2021
1 parent d25435b commit de8ba9a
Show file tree
Hide file tree
Showing 174 changed files with 6,243 additions and 3,228 deletions.
152 changes: 69 additions & 83 deletions archeryapi/views.py

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion archerysecurity/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
'import_export',
'compliance',
'notifications',
'rest_framework_jwt'
'rest_framework_jwt',
'user_management',
'authentication',
"rest_framework_simplejwt.token_blacklist",


]

Expand Down Expand Up @@ -155,6 +159,8 @@
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static")

AUTH_USER_MODEL = "user_management.UserProfile"

MESSAGE_TAGS = {
messages.DEBUG: "alert-info",
messages.INFO: "alert-info",
Expand Down
3 changes: 3 additions & 0 deletions archerysecurity/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@

# settings app
path("settings/", include("archerysettings.urls")),

path("archerysec/api/v1/auth/", include("authentication.urls")),
path("users/", include("user_management.urls")),
]

urlpatterns = urlpatterns + static(
Expand Down
41 changes: 20 additions & 21 deletions archerysettings/load_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

from django.core import signing

from archerysettings.models import (burp_setting_db, nmap_vulners_setting_db,
openvas_setting_db, zap_settings_db)
from archerysettings.models import (BurpSettingDb, NmapVulnersSettingDb,
OpenvasSettingDb, ZapSettingsDb)


class ArcherySettings:
def __init__(self, setting_file, username):
def __init__(self, setting_file):
self.setting_file = setting_file
self.username = username

def zap_api_key(self, username):
"""
Expand All @@ -36,35 +35,35 @@ def zap_api_key(self, username):
"""
apikey = None

all_zap = zap_settings_db.objects.filter(username=username)
all_zap = ZapSettingsDb.objects.filter()

for zap in all_zap:
apikey = zap.zap_api

return apikey

def zap_host(self, username):
def zap_host(self):
"""
Loading ZAP Host from setting file.
:return:
"""
zapath = None

all_zap = zap_settings_db.objects.filter(username=username)
all_zap = ZapSettingsDb.objects.filter()

for zap in all_zap:
zapath = zap.zap_url

return zapath

def zap_port(self, username):
def zap_port(self):
"""
Loading ZAP Port from setting file.
:return:
"""
zaport = None

all_zap = zap_settings_db.objects.filter(username=username)
all_zap = ZapSettingsDb.objects.filter()

for zap in all_zap:
zaport = zap.zap_port
Expand All @@ -78,7 +77,7 @@ def burp_api_key(self):
"""
burpapikey = None

all_burp = burp_setting_db.objects.filter(username=self.username)
all_burp = BurpSettingDb.objects.filter()

for burp in all_burp:
burpapikey = burp.burp_api_key
Expand All @@ -92,7 +91,7 @@ def burp_host(self):
"""
burphost = None

all_burp = burp_setting_db.objects.filter(username=self.username)
all_burp = BurpSettingDb.objects.filter()

for burp in all_burp:
burphost = burp.burp_url
Expand All @@ -106,7 +105,7 @@ def burp_port(self):
"""
burport = None

all_burp = burp_setting_db.objects.filter(username=self.username)
all_burp = BurpSettingDb.objects.filter()

for burp in all_burp:
burport = burp.burp_port
Expand All @@ -120,7 +119,7 @@ def openvas_host(self):
"""
openvas_host = None

all_openvas = openvas_setting_db.objects.filter(username=self.username)
all_openvas = OpenvasSettingDb.objects.filter()

for openvas in all_openvas:
openvas_host = openvas.host
Expand All @@ -141,7 +140,7 @@ def openvas_username(self):
"""
openvas_username = None

all_openvas = openvas_setting_db.objects.filter(username=self.username)
all_openvas = OpenvasSettingDb.objects.filter()

for openvas in all_openvas:
openvas_username = openvas.user
Expand All @@ -162,7 +161,7 @@ def openvas_pass(self):
"""
openvas_password = None

all_openvas = openvas_setting_db.objects.filter(username=self.username)
all_openvas = OpenvasSettingDb.objects.filter()

for openvas in all_openvas:
openvas_password = openvas.password
Expand All @@ -172,7 +171,7 @@ def openvas_pass(self):
def openvas_port(self):
openvas_port = None

all_openvas = openvas_setting_db.objects.filter(username=self.username)
all_openvas = OpenvasSettingDb.objects.filter()

for openvas in all_openvas:
openvas_port = openvas.port
Expand All @@ -183,7 +182,7 @@ def openvas_port(self):
def openvas_enabled(self):
openvas_enabled = None

all_openvas = openvas_setting_db.objects.filter(username=self.username)
all_openvas = OpenvasSettingDb.objects.filter()

for openvas in all_openvas:
openvas_enabled = openvas.enabled
Expand Down Expand Up @@ -242,7 +241,7 @@ def email_to(self):
def nv_enabled(self):
nv_enabled = False

all_nv = nmap_vulners_setting_db.objects.filter(username=self.username)
all_nv = NmapVulnersSettingDb.objects.filter()

for nv in all_nv:
nv_enabled = nv.enabled
Expand All @@ -254,7 +253,7 @@ def nv_enabled(self):
def nv_version(self):
nv_version = False

all_nv = nmap_vulners_setting_db.objects.filter(username=self.username)
all_nv = NmapVulnersSettingDb.objects.filter()

for nv in all_nv:
nv_version = nv.version
Expand All @@ -266,7 +265,7 @@ def nv_version(self):
def nv_online(self):
nv_online = False

all_nv = nmap_vulners_setting_db.objects.filter(username=self.username)
all_nv = NmapVulnersSettingDb.objects.filter()

for nv in all_nv:
nv_online = nv.online
Expand All @@ -278,7 +277,7 @@ def nv_online(self):
def nv_timing(self):
nv_timing = 0

all_nv = nmap_vulners_setting_db.objects.filter(username=self.username)
all_nv = NmapVulnersSettingDb.objects.filter()

for nv in all_nv:
nv_timing = nv.timing
Expand Down
140 changes: 55 additions & 85 deletions archerysettings/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-10-04 19:45
from __future__ import unicode_literals
# Generated by Django 3.1.12 on 2021-07-19 15:38

from django.db import migrations, models

Expand All @@ -9,112 +7,84 @@ class Migration(migrations.Migration):

initial = True

dependencies = []
dependencies = [
]

operations = [
migrations.CreateModel(
name="arachni_settings_db",
name='ArachniSettingsDb',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('arachni_url', models.TextField(blank=True, null=True)),
('arachni_port', models.TextField(blank=True, null=True)),
('arachni_user', models.TextField(blank=True, null=True)),
('arachni_pass', models.TextField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='BurpSettingDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("arachni_url", models.TextField(blank=True, null=True)),
("arachni_port", models.TextField(blank=True, null=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('burp_url', models.TextField(blank=True, null=True)),
('burp_port', models.TextField(blank=True, null=True)),
('burp_api_key', models.TextField(blank=True, null=True)),
],
),
migrations.CreateModel(
name="burp_setting_db",
name='EmailDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("burp_url", models.TextField(blank=True, null=True)),
("burp_port", models.TextField(blank=True, null=True)),
("burp_api_key", models.TextField(blank=True, null=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('subject', models.TextField(blank=True, null=True)),
('message', models.TextField(blank=True, null=True)),
('recipient_list', models.TextField(blank=True)),
],
),
migrations.CreateModel(
name="email_db",
name='NmapVulnersSettingDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("subject", models.TextField(blank=True, null=True)),
("message", models.TextField(blank=True, null=True)),
("recipient_list", models.TextField(blank=True, null=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('enabled', models.BooleanField()),
('version', models.BooleanField()),
('online', models.BooleanField()),
('timing', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name="nmap_vulners_setting_db",
name='OpenvasSettingDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("enabled", models.BooleanField()),
("version", models.BooleanField()),
("online", models.BooleanField()),
("timing", models.IntegerField(default=0)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('host', models.TextField(blank=True, null=True)),
('port', models.IntegerField(default=9390)),
('enabled', models.BooleanField()),
('user', models.TextField(blank=True, null=True)),
('password', models.TextField(blank=True, null=True)),
],
),
migrations.CreateModel(
name="openvas_setting_db",
name='SettingsDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("host", models.TextField(blank=True, null=True)),
("port", models.IntegerField(default=9390)),
("enabled", models.BooleanField()),
("user", models.TextField(blank=True, null=True)),
("password", models.TextField(blank=True, null=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('setting_name', models.TextField(blank=True, null=True)),
('setting_scanner', models.TextField(blank=True, null=True)),
('setting_status', models.BooleanField(blank=True, null=True)),
('created_time', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name="zap_settings_db",
name='ZapSettingsDb',
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("zap_url", models.TextField(default="127.0.0.1")),
("zap_api", models.TextField(default="")),
("zap_port", models.TextField(default=8080)),
("enabled", models.BooleanField()),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_id', models.UUIDField(blank=True, null=True)),
('zap_url', models.TextField(default='127.0.0.1')),
('zap_api', models.TextField(default='dwed23wdwedwwefw4rwrfw')),
('zap_port', models.IntegerField(default=8090)),
('enabled', models.BooleanField()),
],
),
]
25 changes: 0 additions & 25 deletions archerysettings/migrations/0002_auto_20191006_0519.py

This file was deleted.

Loading

0 comments on commit de8ba9a

Please sign in to comment.