aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/orm/management/commands/checksettings.py14
-rw-r--r--lib/orm/management/commands/lsupdates.py15
-rw-r--r--lib/orm/models.py25
3 files changed, 17 insertions, 37 deletions
diff --git a/lib/orm/management/commands/checksettings.py b/lib/orm/management/commands/checksettings.py
index c4b646d0..f5e4df02 100644
--- a/lib/orm/management/commands/checksettings.py
+++ b/lib/orm/management/commands/checksettings.py
@@ -1,9 +1,6 @@
-from django.core.management.base import BaseCommand, CommandError
-from django.db import transaction
-
+from django.core.management.base import BaseCommand
from django.core.management import call_command
from django.contrib.auth.models import Permission, Group
-from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
from orm.models import SrtSetting, DataSource
@@ -13,7 +10,6 @@ import os
import traceback
import warnings
import glob
-import sqlite3
import json
# quick development/debugging support
@@ -56,7 +52,7 @@ class Command(BaseCommand):
ds,create = DataSource.objects.get_or_create(key=datasource['key'])
for key in datasource.keys():
if key.startswith("_comment"):
- continue;
+ continue
setattr(ds, key, datasource[key])
ds.save()
@@ -77,7 +73,7 @@ class Command(BaseCommand):
ds,create = Group.objects.get_or_create(name=group['name'])
for key in group.keys():
if key.startswith("_comment"):
- continue;
+ continue
setattr(ds, key, group[key])
ds.save()
if 'group_permissions' in dct:
@@ -93,7 +89,7 @@ class Command(BaseCommand):
ds,create = SrtUser.objects.get_or_create(username=srtuser['name'])
for key in srtuser.keys():
if key.startswith("_comment"):
- continue;
+ continue
setattr(ds, key, srtuser[key])
ds.save()
if 'srtuser_groups' in dct:
@@ -228,7 +224,7 @@ class Command(BaseCommand):
create_dir("downloads")
return 0
- def handle(self, **options):
+ def handle(self, *args, **options):
retval = 0
retval += self._init_srt_directories()
retval += self._init_srt_fixtures()
diff --git a/lib/orm/management/commands/lsupdates.py b/lib/orm/management/commands/lsupdates.py
index 28ee1e5f..365c8ab4 100644
--- a/lib/orm/management/commands/lsupdates.py
+++ b/lib/orm/management/commands/lsupdates.py
@@ -21,15 +21,10 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.core.management.base import BaseCommand
-from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import Group
from orm.models import SrtSetting, DataSource
-from orm.models import Cve, CveToVulnerablility, CveReference
-from orm.models import Vulnerability
-from orm.models import CweTable, CveToCwe
-from orm.models import CpeToCve, CpeTable, CpeFilter
-from orm.models import Product, Defect
+from orm.models import CweTable, CpeFilter
from users.models import SrtUser
@@ -38,14 +33,13 @@ import sys
import re
import time
import pytz
-from datetime import datetime, date
+from datetime import datetime
import json
import xml.etree.ElementTree as ET
import csv
import logging
import threading
-import urllib
logger = logging.getLogger("srt")
@@ -327,9 +321,6 @@ class Command(BaseCommand):
logger.info("***LS UPDATES***")
- from urllib.request import urlopen, URLError
- from urllib.parse import urlparse
-
# Process the data sources in strict pk order to insure dependencies
data_sources=DataSource.objects.all().order_by('key')
for source in data_sources:
@@ -408,7 +399,7 @@ class Command(BaseCommand):
os.system('setterm -cursor on')
- def handle(self, **options):
+ def handle(self, *args, **options):
# testing shortcuts
if 'yes' == SrtSetting.objects.get(name='SRTDBG_MINIMAL_DB').value:
diff --git a/lib/orm/models.py b/lib/orm/models.py
index 8d95c319..bca7d427 100644
--- a/lib/orm/models.py
+++ b/lib/orm/models.py
@@ -22,13 +22,7 @@
from __future__ import unicode_literals
from django.db import models, IntegrityError, DataError
-from django.db.models import F, Q, Sum, Count
-from django.db import IntegrityError, transaction
-from django.utils import timezone
-from django.utils.encoding import force_bytes
-from django.contrib.auth.models import Group, AnonymousUser
-
-from django.urls import reverse
+from django.db import transaction
from django.core import validators
from django.conf import settings
@@ -39,9 +33,8 @@ from users.models import SrtUser
import sys
import os
import re
-import itertools
from signal import SIGUSR1
-from datetime import timedelta, datetime
+from datetime import datetime
import json
import logging
@@ -53,7 +46,7 @@ from srtgui.api import _log
# Sqlite support
if 'sqlite' in settings.DATABASES['default']['ENGINE']:
- from django.db import transaction, OperationalError
+ from django.db import OperationalError
from time import sleep
_base_save = models.Model.save
@@ -103,7 +96,6 @@ if 'sqlite' in settings.DATABASES['default']['ENGINE']:
# end of HACK
class GitURLValidator(validators.URLValidator):
- import re
regex = re.compile(
r'^(?:ssh|git|http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
@@ -127,7 +119,7 @@ class SrtSetting(models.Model):
helptext = models.TextField()
value = models.CharField(max_length=255)
- def __unicode__(self):
+ def __str__(self):
return "Setting %s = %s" % (self.name, self.value)
class HelpText(models.Model):
@@ -350,12 +342,12 @@ class CveDetail():
def get_cpe_list(self):
cpe_array = []
for cpe in self.cpe_list.split('|'):
- cpe_array.append(cpe.split(','))
+ cpe_array.append(cpe.split(','))
return cpe_array
def get_ref_list(self):
ref_array = []
for ref in self.ref_list.split('|'):
- ref_array.append(ref.split('\t'))
+ ref_array.append(ref.split('\t'))
return ref_array
# Local full Cve class, based on "Cve"
@@ -668,6 +660,7 @@ class Vulnerability(models.Model):
@staticmethod
def new_vulnerability_name():
# get next vulnerability name atomically
+ # FIXME ???
if True:
current_vulnerability_index,create = SrtSetting.objects.get_or_create(name='current_vulnerability_index')
if create:
@@ -1012,9 +1005,9 @@ class NotifyCategories(models.Model):
def invalidate_cache(**kwargs):
from django.core.cache import cache
try:
- cache.clear()
+ cache.clear()
except Exception as e:
- logger.warning("Problem with cache backend: Failed to clear cache: %s" % e)
+ logger.warning("Problem with cache backend: Failed to clear cache: %s" % e)
def signal_runbuilds():
"""Send SIGUSR1 to runbuilds process"""