Skip to content

Commit

Permalink
vulnerability fix bump django to 4.2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalGawor committed Oct 15, 2024
1 parent 50ac587 commit 6ee0d26
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 45 deletions.
10 changes: 9 additions & 1 deletion dogconfig/dogproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
hostname, _, ips = socket.gethostbyname_ex("localhost")
INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips]




# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
Expand All @@ -72,9 +75,11 @@
'django.contrib.staticfiles',

# 3rd party
'debug_toolbar',
'bootstrap5',
'corsheaders',
'debug_toolbar',
'drf_spectacular',
'fontawesomefree',
'rest_framework',

# CLARIN internal dependency
Expand All @@ -86,6 +91,9 @@

]

DTR_ENABLED = False


REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
Expand Down
6 changes: 4 additions & 2 deletions dogconfig/dogproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from drf_spectacular.views import SpectacularAPIView, SpectacularJSONAPIView


from dogui.views_ui import home, about
from dogui.views_ui import about, contact, dtr, home
from dogapi.views_api import (fetch, identify, sniff, is_pid, expand_datatype, get_all_repositories,
get_repositories_status)

Expand All @@ -26,5 +26,7 @@

# UI
path('', home, name='main'),
path('about', about, name='about')
path('about', about, name='about'),
path('contact', contact, name='contact'),
path('dtr', dtr, name='contact')
]
1 change: 0 additions & 1 deletion dogui/dogui/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self, *args, **kwargs):
# ('identify', 'identify'),
('fetch', 'fetch'),
('ispid', 'is pid'),
('expanddatatype', 'expand MIME data type'),
]
pid_field: PIDField = PIDField(required=True,
widget=forms.TextInput(attrs={'required': 'True'}))
Expand Down
10 changes: 5 additions & 5 deletions dogui/dogui/templates/UI/_.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
{# @formatter:on #}
</head>
<body>
{% block header %}
{% include 'UI/_header.html' %}
{% block navbar %}
{% include 'UI/_navbar.html' %}
{% endblock %}

{% block content %}{% endblock %}
{% block content %}
{% endblock %}

{% block footer %}
{% include 'UI/_footer.html' %}
{% endblock %}
</div>
</body>
</html>
</html>
9 changes: 5 additions & 4 deletions dogui/dogui/templates/UI/_about.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ <h1>About the CLARIN ERIC Digital Object Gateway</h1>
<a href='https://infra.clarin.eu/apis/?urls.primaryName=Digital%20Object%20Gateway%20API%20(alpha)'>application programming interface</a>. </p>
<h2>Source code</h2>
<h3>Source code and issue tracking</h3>
<p>The source code of the DOG library: <a href='https://github.com/clarin-eric/DOGlib'>DOGlib GitHub repository</a>.
The source code of the DOG application: <a href='https://github.com/clarin-eric/DOGapp'>DOGapp GitHub repository</a>. </p>
<p>The source code of DOG library: <a href='https://github.com/clarin-eric/DOGlib'>DOGlib GitHub repository</a>. </p>
<p>The source code of DOG application: <a href='https://github.com/clarin-eric/DOGapp'>DOGapp GitHub repository</a>. </p>
<h2>Credits</h2>
<h3>Maintainers</h3>
<ul>
<li>Michał Gawor <sup><a href='https://www.clarin.eu/applications/'>CLARIN ERIC</a></sup></li>
<li>André Moreira <sup><a href='https://www.clarin.eu/applications/'>CLARIN ERIC</a></sup></li>
</ul>
<h3>Original Developers</h3>
<h3>Developers</h3>
<ul>
<li>Michał Gawor <sup><a href='https://www.clarin.eu/applications/'>CLARIN ERIC</a></sup></li>
</ul>
Expand All @@ -26,9 +26,10 @@ <h2>Licenses</h2>
<a href='https://clarin.eu/content/development-information'>Get to work with CLARIN applications' source code and documentation</a>.
</p>
<h3>Technology used</h3>
Notable dependencies
<ul>
<li><a href='https://github.com/django/django/blob/master/LICENSE'>django</a></li>
<li><a href='https://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/LICENSE'>django-debug-toolbar</a></li>
<li><a href='https://www.django-rest-framework.org/#license'>django-rest-framework</a></li>
<li><a href='https://github.com/SeleniumHQ/selenium/blob/trunk/LICENSE'>Selenium WebDriver Python bindings</a></li>
<li><a href='https://github.com/memcached/memcached/blob/master/LICENSE'>memecache</a></li>
</ul>
Expand Down
7 changes: 7 additions & 0 deletions dogui/dogui/templates/UI/_contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends 'UI/_.html' %}
{% block content %}
<div id="content">
<h2>Contacting CLARIN ERIC about the Digital Object Gateway</h2>
<p>Contact <a href="mailto:[email protected]">by e-mail &#128231;</a></p>
</div>
{% endblock content %}
8 changes: 4 additions & 4 deletions dogui/dogui/templates/UI/_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
{% block content %}
<div id="content">
Welcome to CLARIN ERIC Digital Object Gateway. The goal of DOG is to ease access to referenced resources in metadata.
Currently, DOG supports 4 functionalities:
Currently, DOG supports {% if DTR_ENABLED %} 4 {% else %} 3 {% endif %} functionalities:
<ul>
<li>sniff - checks if input PID points to a registered repository</li>
<li>fetch - fetches all PIDs of references resources in the metadata </li>
<li>is pid - checks if input string is a DOG parsable PID</li>
<li>expand data type - returns MIME Data Type taxonomy from <a href="">Data Type Registry</a></li>
{% if DTR_ENABLED %}
<li>expand data type - expands MIME Data Type to taxonomy from <a href="">Data Type Registry</a></li>
{% endif %}
</ul>

Swagger available <a href="https://infra.clarin.eu/apis/">here</a>
Expand Down Expand Up @@ -35,5 +37,3 @@ <h4> Currently registered repositories within DOG </h4>
</div>
</div>
{% endblock content %}


9 changes: 3 additions & 6 deletions dogui/dogui/templates/UI/_fetch.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<table>
<thead>
<tr>
<th>Data type</th>
<th>PID</th>
<th>Resource type</th>
<th>PID (MIME type)</th>
</tr>
</thead>
{% for ref_resources in fetch_result.ref_files %}
Expand All @@ -48,13 +48,10 @@
</td>
<td>
{% for ref_resource in ref_resources.ref_resources %}
<a href="{{ ref_resource.pid }}">{{ ref_resource.pid }}</a>
<a href="{{ ref_resource.pid }}">{{ ref_resource.pid }}</a> {% if ref_resource.data_type %} ({{ ref_resource.data_type }}) {% else %} (unknown) {% endif %}
{% if not forloop.last %}
<br>
{% endif %}
{% comment %}
TODO INCLUDE DATA TYPE ALONG PID
{% endcomment %}
{% endfor %}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion dogui/dogui/templates/UI/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<img src="{% static 'dogui/style/CLARIN-Logo_4C14pure3_noextraneouscanvas.png' %}"
alt='CLARIN ERIC logo'></a>{# @formatter:on #}
<a title='contacting us'
href='/contacting'>&#128236; Contacting us</a>
href='/contact'>&#128236; Contacting us</a>
</div>
{% endblock footer %}
12 changes: 0 additions & 12 deletions dogui/dogui/templates/UI/_header.html

This file was deleted.

21 changes: 21 additions & 0 deletions dogui/dogui/templates/UI/_navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% block navbar %}
<div id='header'
class='periphery'
role='navigation'>
<div id='brand'>
<a href='/'><span>Digital Object Gateway</span></a>
</div>
<div id='menu'>
<a class='{% if view == "home" or view == "sniff" or view == "fetch" or view == "ispid" %}active{% endif %}'
href='/'>DOG</a>
{% if DTR_ENABLED %}
<a class='{% if view == "dtr" %}active{% endif %}'
href='/dtr'>DTR</a>
{% endif %}
<a class='{% if view == "about" %}active{% endif %}'
href='/about'>About</a>
<a class='{% if view == "contact" %}active{% endif %}'
href='/contact'>Contact</a>
</div>
</div>
{% endblock navbar %}
36 changes: 29 additions & 7 deletions dogui/dogui/views_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

logging.config.dictConfig(settings.LOGGING)
API_NETLOC = settings.API_NETLOC
DTR_ENABLED = settings.DTR_ENABLED


def home(request: HttpRequest) -> HttpResponse:
Expand All @@ -22,6 +23,7 @@ def home(request: HttpRequest) -> HttpResponse:
verify=settings.VERIFY_SSL)

context.push({"repos_status": all_repo_status_response.json()})
context.push({"DTR_ENABLED": DTR_ENABLED})

if pid_form.is_valid():
context.push({"pid_form": pid_form})
Expand All @@ -36,21 +38,41 @@ def home(request: HttpRequest) -> HttpResponse:
# api_url += "&use_dtr=" + use_dtr

api_response = requests.get(api_url, verify=settings.VERIFY_SSL)
logging.critical("API RESPONSE")
logging.critical(api_response)
if functionality == 'expanddatatype':
taxonomy_tree = TaxonomyTree(api_response.json())
context.push({"taxonomy_tree": taxonomy_tree})
else:
context.push({f"{functionality}_response": api_response.json()})

#TODO move DTR to separate application
# if functionality == 'expanddatatype':
# taxonomy_tree = TaxonomyTree(api_response.json())
# context.push({"taxonomy_tree": taxonomy_tree})
# else:
# context.push({f"{functionality}_response": api_response.json()})

context.push({f"{functionality}_response": api_response.json()})

context.push({"view": functionality})
return render(request, f"UI/_{functionality}.html", context.flatten())
else:
pid_form: PIDForm = PIDForm(initial={'functionality_field': 'sniff'})
context.push({"pid_form": pid_form})
context.push({"view": "home"})
return render(request, "UI/_content.html", context.flatten())


def about(request: HttpRequest) -> HttpResponse:
context: RequestContext = RequestContext(request)
context.push({"view": "about"})
context.push({"DTR_ENABLED": DTR_ENABLED})
return render(request, "UI/_about.html", context.flatten())


def contact(request: HttpRequest) -> HttpResponse:
context: RequestContext = RequestContext(request)
context.push({"view": "contact"})
context.push({"DTR_ENABLED": DTR_ENABLED})
return render(request, "UI/_contact.html", context.flatten())


def dtr(request: HttpRequest) -> HttpResponse:
context: RequestContext = RequestContext(request)
context.push({"view": "dtr"})
context.push({"DTR_ENABLED": DTR_ENABLED})
return render(request, "UI/_dtr.html", context.flatten())
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ homepage = ""
repository = "https://github.com/clarin-eric/DOGapp/"

[tool.poetry.dependencies]
doglib = { url = "https://github.com/clarin-eric/DOGlib/releases/download/1.0.10-a2/doglib-1.0.10a2-py3-none-any.whl" }
Django = '4.2.15'
# CLARIN DOGlib
doglib = { url = "https://github.com/clarin-eric/DOGlib/releases/download/1.0.10/doglib-1.0.10-py3-none-any.whl" }
# 3rd party
Django = '4.2.16'
django-cors-headers = '4.4.0'
django-debug-toolbar = '4.4.6'
djangorestframework = '3.15.2'
drf-spectacular = "0.27.2"
fontawesomefree = "6.6.0"
python = '>=3.11.*,<4.0'
pymemcache = '4.0.0'
requests = '2.32.3'
Expand Down

0 comments on commit 6ee0d26

Please sign in to comment.