Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions bakery/management/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Filesystem
from fs import path
from fs import copy
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str

# Pooling
import multiprocessing
Expand Down Expand Up @@ -128,9 +128,9 @@ def set_options(self, *args, **options):
self.build_dir = settings.BUILD_DIR

# Get the datatypes right so fs will be happy
self.build_dir = smart_text(self.build_dir)
self.static_root = smart_text(settings.STATIC_ROOT)
self.media_root = smart_text(settings.MEDIA_ROOT)
self.build_dir = smart_str(self.build_dir)
self.static_root = smart_str(settings.STATIC_ROOT)
self.media_root = smart_str(settings.MEDIA_ROOT)

# Connect the BUILD_DIR with our filesystem backend
self.app = apps.get_app_config("bakery")
Expand Down Expand Up @@ -176,7 +176,7 @@ def build_static(self, *args, **options):

# Set the target directory inside the filesystem.
target_dir = path.join(self.build_dir, settings.STATIC_URL.lstrip("/"))
target_dir = smart_text(target_dir)
target_dir = smart_str(target_dir)
if os.path.exists(self.static_root) and settings.STATIC_URL:
if getattr(settings, "BAKERY_GZIP", False):
self.copytree_and_gzip(self.static_root, target_dir)
Expand Down Expand Up @@ -210,7 +210,7 @@ def build_media(self):
if os.path.exists(self.media_root) and settings.MEDIA_URL:
target_dir = path.join(self.build_dir, settings.MEDIA_URL.lstrip("/"))
logger.debug("Copying {}{} to {}{}".format("osfs://", self.media_root, self.fs_name, target_dir))
copy.copy_dir("osfs:///", smart_text(self.media_root), self.fs, smart_text(target_dir))
copy.copy_dir("osfs:///", smart_str(self.media_root), self.fs, smart_str(target_dir))

def get_view_instance(self, view):
"""
Expand Down Expand Up @@ -294,7 +294,7 @@ def copyfile_and_gzip(self, source_path, target_path):
"osfs://", source_path, self.fs_name, target_path
)
)
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))
copy.copy_file("osfs:///", smart_str(source_path), self.fs, smart_str(target_path))

# # if the file is already gzipped
elif encoding == "gzip":
Expand All @@ -303,7 +303,7 @@ def copyfile_and_gzip(self, source_path, target_path):
"osfs://", source_path, self.fs_name, target_path
)
)
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))
copy.copy_file("osfs:///", smart_str(source_path), self.fs, smart_str(target_path))

# If it is one we want to gzip...
else:
Expand All @@ -320,6 +320,6 @@ def copyfile_and_gzip(self, source_path, target_path):
f.write(six.binary_type(source_file.read()))

# Write that buffer out to the filesystem
with self.fs.open(smart_text(target_path), "wb") as outfile:
with self.fs.open(smart_str(target_path), "wb") as outfile:
outfile.write(data_buffer.getvalue())
outfile.close()
6 changes: 3 additions & 3 deletions bakery/management/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from fs import copy
from fs_s3fs import S3FS
from fs.copy import copy_file
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str

from django.apps import apps

Expand Down Expand Up @@ -223,7 +223,7 @@ def set_options(self, options):
# Go ahead and use it
self.build_dir = settings.BUILD_DIR

self.build_dir = smart_text(self.build_dir)
self.build_dir = smart_str(self.build_dir)

# Connect the BUILD_DIR with our filesystem backend
self.app = apps.get_app_config("bakery")
Expand Down Expand Up @@ -295,7 +295,7 @@ def get_local_file_list(self):

local_key = path.combine(path.frombase(path.abspath(self.build_dir), dirpath), fname.name)
local_key = path.relpath(local_key)
file_list.append(smart_text(local_key))
file_list.append(smart_str(local_key))
return file_list

def sync_with_s3(self):
Expand Down
6 changes: 3 additions & 3 deletions bakery/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from fs import path
from django.apps import apps
from django.conf import settings
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str
from bakery import DEFAULT_GZIP_CONTENT_TYPES
from django.test.client import RequestFactory
from bakery.management.commands import get_s3_client
Expand Down Expand Up @@ -76,7 +76,7 @@ def write_file(self, target_path, html):
Writes out the provided HTML to the provided path.
"""
logger.debug("Building to {}{}".format(self.fs_name, target_path))
with self.fs.open(smart_text(target_path), "wb") as outfile:
with self.fs.open(smart_str(target_path), "wb") as outfile:
outfile.write(six.binary_type(html))
outfile.close()

Expand Down Expand Up @@ -114,7 +114,7 @@ def gzip_file(self, target_path, html):
f.write(six.binary_type(html))

# Write that buffer out to the filesystem
with self.fs.open(smart_text(target_path), "wb") as outfile:
with self.fs.open(smart_str(target_path), "wb") as outfile:
outfile.write(data_buffer.getvalue())
outfile.close()

Expand Down
26 changes: 20 additions & 6 deletions bigvince/settings_.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import environ
import urllib

import django

env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env()

Expand All @@ -56,6 +58,11 @@
# any change that requires database migrations is a minor release
VERSION = "3.0.44"

if django.VERSION >= (5, 1):
DB_BACKEND="django.db.backends.postgresql"
else:
DB_BACKEND=DB_BACKEND

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

Expand Down Expand Up @@ -192,7 +199,14 @@
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_LOCATION}/"
# Tell the staticfiles app to use S3Boto3 storage when writing the collected static files (when
# you run `collectstatic`).
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
if django.VERSION >= (5, 1):
STORAGES = {
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage"},
}
else:
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

# set to True if you want VINCE to write a contacts backup file to an S3 directory,
# you must also set ANCIENT_SRMAIL_BUCKET to S3 arn
# To reload contacts into VINCE, set INITIAL_CONTACT_FILE and
Expand Down Expand Up @@ -425,7 +439,7 @@ def get_secret(secret_arn):
DATABASES = {"default": {}}
if VINCE_NAMESPACE == "vince":
DATABASES["default"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": DB_BACKEND,
"NAME": vincetrack_db,
"USER": vincetrack_user,
"PASSWORD": vincetrack_password,
Expand All @@ -439,7 +453,7 @@ def get_secret(secret_arn):

if VINCE_NAMESPACE in ["vince", "vinny"]:
DATABASES["vincecomm"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": DB_BACKEND,
"NAME": vincecomm_db,
"USER": vincecomm_user,
"PASSWORD": vincecomm_password,
Expand All @@ -449,7 +463,7 @@ def get_secret(secret_arn):
}

DATABASES["vincepub"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": DB_BACKEND,
"NAME": vincepub_db,
"USER": vincepub_user,
"PASSWORD": vincepub_password,
Expand All @@ -462,7 +476,7 @@ def get_secret(secret_arn):
# don't enable the admin interface for kb
ADMIN_ENABLED = False
DATABASES["default"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": DB_BACKEND,
"NAME": vincepub_db,
"USER": vincepub_user,
"PASSWORD": vincepub_password,
Expand All @@ -475,7 +489,7 @@ def get_secret(secret_arn):
if VINCE_NAMESPACE == "vinny":
SESSION_COOKIE_PATH = "/vince/comm"
DATABASES["default"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": DB_BACKEND,
"NAME": vincecomm_db,
"USER": vincecomm_user,
"PASSWORD": vincecomm_password,
Expand Down
4 changes: 2 additions & 2 deletions cogauth/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from vinny.models import VinceAPIToken
from rest_framework import exceptions
from rest_framework.authentication import BaseAuthentication, TokenAuthentication, get_authorization_header
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str
from django.utils.translation import gettext as _
from bigvince.utils import get_cognito_url, get_cognito_pool_url
import traceback
Expand Down Expand Up @@ -443,7 +443,7 @@ def authenticate(self, request):
def get_jwt_token(self, request):
logger.debug(f"Collected headers for JSONWwebToken as {request.headers}")
auth = get_authorization_header(request).split()
if not auth or smart_text(auth[0].lower()) != "bearer":
if not auth or smart_str(auth[0].lower()) != "bearer":
return None

if len(auth) == 1:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
amqp==5.1.1
appdirs==1.4.4
asgiref==3.6.0
asgiref==3.8.1
asn1crypto==1.5.1
async-timeout==4.0.2
attrs==22.1.0
Expand All @@ -24,7 +24,7 @@ cryptography==50.0.0
cvelib==1.3.0
Deprecated==1.2.13
dictdiffer==0.9.0
Django==4.2.30
Django==5.2.16
django-appconf==1.0.5
django-countries==7.4.2
django-environ==0.9.0
Expand Down
4 changes: 2 additions & 2 deletions vince/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from vince.permissions import get_user_gen_queue
import traceback
import os
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down Expand Up @@ -562,7 +562,7 @@ def save(self):
logger.debug("IN FILE UPLOAD SAVE")
# create the vincecommattachment
if file.size:
filename = smart_text(file.name)
filename = smart_str(file.name)
logger.debug(filename)
try:
mime_type = file.content_type
Expand Down
4 changes: 2 additions & 2 deletions vince/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from django.core.files import File
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import timezone
from django.utils.encoding import smart_str as smart_text
from django.utils.encoding import smart_str
from django.template.loader import render_to_string, get_template
from vince.models import VulnerabilityCase

Expand Down Expand Up @@ -287,7 +287,7 @@ def process_attachments(followup, attached_files):
for attached in attached_files:
logger.debug(attached)
if attached.size:
filename = smart_text(attached.name)
filename = smart_str(attached.name)
logger.debug(filename)
try:
mime_type = attached.content_type
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/400.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}
{% load staticfiles %}
{% load static %}
{% block content %}

<div class="app-top-panel">
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/403.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}
{% load staticfiles %}
{% load static %}
{% block content %}

<div class="app-top-panel">
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/500.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}
{% load staticfiles %}
{% load static %}
{% block content %}

<div class="app-top-panel">
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/activity.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n dashboard_tags %}
<!-- site-title -->
{% block vince_title %}{% trans "Activity" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/activity_search.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/approve_all.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "vince/modal.html" %}
{% load i18n %}
{% load widget_tweaks %}
{% load staticfiles %}
{% load static %}
{% block content %}

<div class="fullmodal">
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/approve_users.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize post_tags %}
<!-- site-title -->
{% block vince_title %}{% trans "Pending Users" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/puser.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/artifacts.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize%}
{% block vince_title %}{% trans "Ticket Artifacts" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'vince/css/tabulator_bootstrap4.min.css' %}">
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/bouncemanager.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n contact_tags %}
{% block vince_title %}{% trans "VINCE Bounce Manager" %}{% endblock %}
<!-- site-title -->
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/bouncemgr.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/case.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize%}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/tickets.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/case_templates.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n %}
<!-- site-title -->
{% block vince_title %}{% trans "Case Template Management" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/case_management.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/changelog.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize%}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/diffview.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/complete_transfer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize ticket_to_link %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/transfer.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/contact.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends VINCETRACK_BASE_TEMPLATE %}
{% load i18n humanize ticket_to_link contact_tags %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
<script type="text/javascript" src="{% static 'vince/js/scontact.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/contact_assoc_list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize post_tags %}
<!-- site-title -->
{% block vince_title %}{% trans "Completed Associations" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion vince/templates/vince/contact_cases.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends VINCETRACK_BASE_TEMPLATE %}{% load i18n humanize post_tags ticket_to_link %}
<!-- site-title -->
{% block vince_title %}{% trans "Contact Cases" %}{% endblock %}
{% load staticfiles %}
{% load static %}
{% block js %}
{{ block.super }}
{% endblock %}
Expand Down
Loading
Loading