Skip to content

Commit 3d26509

Browse files
authored
Merge pull request #267 from certsocietegenerale/python3
Python3
2 parents 3f46f8f + e5b2675 commit 3d26509

File tree

89 files changed

+502
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+502
-529
lines changed

docker/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM python:2.7-alpine AS builder
1+
FROM python:3.8-alpine AS builder
22
WORKDIR /app
33
COPY . /app
4-
RUN apk add --update python-dev \
4+
RUN apk add --update git \
5+
python3-dev \
56
libxml2-dev \
67
libxslt-dev \
78
build-base \
@@ -16,7 +17,7 @@ RUN apk add --update python-dev \
1617
mv fir/config/installed_apps.txt.sample fir/config/installed_apps.txt && \
1718
deactivate
1819

19-
FROM python:2.7-alpine AS fir
20+
FROM python:3.8-alpine AS fir
2021
COPY --from=builder /app /app
2122
RUN apk add libxml2 libxslt mariadb-connector-c && \
2223
rm -rf /var/cache/apk/* && \

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ services:
6767
- fir_db
6868
- fir_redis
6969
env_file:
70-
- fir.env
70+
- fir.env
7171
networks:
7272
backend.fir:
7373

docker/fir.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ HOME=/app/FIR
44
DJANGO_SETTINGS_MODULE=fir.config.composeprod
55

66
ALLOWED_HOSTS=localhost,127.0.0.1
7-
DEBUG=true
7+
DEBUG=false
88

99
# Secret key
1010
SECRET_KEY="not so secret"

fir/config/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pkgutil import find_loader
55
from importlib import import_module
6+
from distutils.util import strtobool
67

78
BASE_DIR = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
89

910
# Django settings for fir project.
1011

1112

12-
ENFORCE_2FA = False
13+
ENFORCE_2FA = bool(strtobool(os.getenv('ENFORCE_2FA', 'False')))
1314

1415
tf_error_message = """Django two factor is not installed and ENFORCE_2FA is set to True.
1516
Either set ENFORCE_2FA to False or pip install django-two-factor-auth
@@ -71,7 +72,7 @@
7172
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
7273
)
7374

74-
MIDDLEWARE_CLASSES = (
75+
MIDDLEWARE = (
7576
'django.middleware.common.CommonMiddleware',
7677
'django.contrib.sessions.middleware.SessionMiddleware',
7778
'django.middleware.csrf.CsrfViewMiddleware',
@@ -84,7 +85,7 @@
8485

8586
if TF_INSTALLED:
8687
TF_MIDDLEWARE = ('django_otp.middleware.OTPMiddleware',)
87-
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + TF_MIDDLEWARE
88+
MIDDLEWARE = MIDDLEWARE + TF_MIDDLEWARE
8889

8990

9091
# Authentication and authorization backends

fir/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
'django.template.loaders.app_directories.Loader',
2525
)
2626

27+
# Rest framework default pagination
28+
REST_FRAMEWORK = {
29+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
30+
'PAGE_SIZE': 100
31+
}
32+
2733
# Dummy key for development
2834
SECRET_KEY = 'DUMMY_KEY_FOR_DEVELOPMENT_DO_NOT_USE_IN_PRODUCTION'
2935

fir/urls.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
from fir.config.base import INSTALLED_APPS, TF_INSTALLED
66
from incidents import views
77

8+
89
# urls for core FIR components
910
urlpatterns = [
1011
url(r'^logout/', views.user_logout, name='logout'),
11-
url(r'^incidents/', include('incidents.urls', namespace='incidents')),
12+
url(r'^incidents/', include(('incidents.urls', 'incidents'), namespace='incidents')),
1213
url(r'^search/$', views.search, name='search'),
13-
url(r'^events/', include('incidents.custom_urls.events', namespace='events')),
14-
url(r'^stats/', include('incidents.custom_urls.stats', namespace='stats')),
15-
url(r'^ajax/', include('incidents.custom_urls.ajax', namespace='ajax')),
16-
url(r'^user/', include('incidents.custom_urls.user', namespace='user')),
17-
url(r'^dashboard/', include('incidents.custom_urls.dashboard', namespace='dashboard')),
18-
url(r'^admin/', include(admin.site.urls)),
14+
url(r'^events/', include(('incidents.custom_urls.events', 'url_events'), namespace='events')),
15+
url(r'^stats/', include(('incidents.custom_urls.stats', 'stats'), namespace='stats')),
16+
url(r'^ajax/', include(('incidents.custom_urls.ajax', 'ajax'), namespace='ajax')),
17+
url(r'^user/', include(('incidents.custom_urls.user', 'user'), namespace='user')),
18+
url(r'^dashboard/', include(('incidents.custom_urls.dashboard', 'dashboard'), namespace='dashboard')),
19+
url(r'^admin/', admin.site.urls),
1920
url(r'^$', views.dashboard_main),
2021
]
2122

@@ -39,4 +40,4 @@
3940
app_name = app[4:]
4041
app_urls = '{}.urls'.format(app)
4142
if find_loader(app_urls):
42-
urlpatterns.append(url('^{}/'.format(app_name), include(app_urls, namespace=app_name)))
43+
urlpatterns.append(url('^{}/'.format(app_name), include((app_urls, app), namespace=app_name)))

fir_abuse/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class AbuseTemplate(models.Model):
99
type = models.CharField(max_length=100, blank=True)
1010
body = models.TextField()
1111
subject = models.TextField()
12-
incident_category = models.ForeignKey(IncidentCategory, blank=True, null=True)
12+
incident_category = models.ForeignKey(IncidentCategory, on_delete=models.CASCADE, blank=True, null=True)
1313

14-
def __unicode__(self):
14+
def __str__(self):
1515
return self.name
1616

1717

@@ -20,10 +20,10 @@ class AbuseContact(models.Model):
2020
to = models.CharField(max_length=100)
2121
cc = models.CharField(max_length=100, blank=True)
2222
bcc = models.CharField(max_length=100, blank=True)
23-
incident_category = models.ForeignKey(IncidentCategory, blank=True, null=True)
23+
incident_category = models.ForeignKey(IncidentCategory, on_delete=models.CASCADE, blank=True, null=True)
2424
type = models.CharField(max_length=100, blank=True)
2525

26-
def __unicode__(self):
26+
def __str__(self):
2727
return self.name
2828

2929

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{% load staticfiles %}
1+
{% load static %}
22
<script src="{% static "fir_abuse/js/abuse.js" %}"></script>
33
<link href="{% static "fir_abuse/css/abuse.css" %}" rel="stylesheet" />

fir_abuse/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from fir_abuse import views
44

5+
app_name='fir_abuse'
6+
57
urlpatterns = [
68
url(r'^(?P<incident_id>\d+)/get_template/(?P<artifact_id>\d+)/$', views.get_template, name='get_template'),
79
url(r'^emailform/$', views.emailform, name='emailform'),

fir_abuse/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def send_email(request):
3939

4040
return HttpResponse(dumps({'status': 'ok'}), content_type="application/json")
4141

42-
except Exception, e:
42+
except Exception as e:
4343
return HttpResponse(dumps({'status': 'ko', 'error': str(e)}), content_type="application/json")
4444

4545
return HttpResponseBadRequest(dumps({'status': 'ko'}), content_type="application/json")

0 commit comments

Comments
 (0)