Skip to content

Commit 0a0460b

Browse files
authored
Merge pull request #998 from nexB/fix-csrf
Fix csrf
2 parents d4d2672 + 2c29973 commit 0a0460b

File tree

6 files changed

+53
-17
lines changed

6 files changed

+53
-17
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ Release notes
33

44

55

6+
Version v30.3.1
7+
----------------
8+
9+
This is a minor bug fix release.
10+
11+
- We enabled proper CSRF configuration for deployments
12+
13+
614
Version v30.3.0
715
----------------
816

17+
This is a feature update release including minor bug fixes and the introduction
18+
of API keys and API throttling.
19+
920
- We enabled API throttling for a basic user and for a staff user
1021
they can have unlimited access on API.
1122

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = vulnerablecode
3-
version = 30.3.0
3+
version = 30.3.1
44
license = Apache-2.0 AND CC-BY-SA-4.0
55

66
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390

vulnerabilities/templates/navbar.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@
4444
<div class="dropdown-menu navbar-hover-div" role="menu">
4545
<div class="dropdown-content">
4646
<div class="dropdown-item about-hover-div">
47-
A free and open vulnerabilities database and the packages they impact.
48-
And the tools to aggregate and correlate these vulnerabilities.
47+
48+
VulnerableCode is a free and open database of software package vulnerabilities.
4949
<ul>
5050
<li>
51-
Sponsored by NLnet <a href="https://nlnet.nl/project/vulnerabilitydatabase/">
52-
https://nlnet.nl/project/vulnerabilitydatabase/</a> for
53-
<a href="https://www.aboutcode.org/">https://www.aboutcode.org/</a>
51+
Live chat at <a href="https://gitter.im/aboutcode-org/vulnerablecode">
52+
https://gitter.im/aboutcode-org/vulnerablecode</a>
5453
</li>
5554
<li>
56-
Chat at <a href="https://gitter.im/aboutcode-org/vulnerablecode">
57-
https://gitter.im/aboutcode-org/vulnerablecode</a>
55+
Source code and support at <a href="https://github.com/nexB/vulnerablecode">https://github.com/nexB/vulnerablecode</a>
5856
</li>
5957
<li>
6058
Docs at <a href=https://vulnerablecode.readthedocs.org/>
6159
https://vulnerablecode.readthedocs.org/</a>
6260
</li>
6361
<li>
64-
Source code and issues at <a href="https://github.com/nexB/vulnerablecode">https://github.com/nexB/vulnerablecode</a>
62+
Sponsored by NLnet <a href="https://nlnet.nl/project/vulnerabilitydatabase/">
63+
https://nlnet.nl/project/vulnerabilitydatabase/</a> for
64+
<a href="https://www.aboutcode.org/">https://www.aboutcode.org/</a>
6565
</li>
6666
</ul>
6767
</div>

vulnerabilities/views.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,33 @@ def get(self, request):
141141
return render(request=request, template_name=self.template_name, context=context)
142142

143143

144+
email_template = """
145+
Dear VulnerableCode.io user:
146+
147+
We have received a request to send a VulnerableCode.io API key to this email address.
148+
Here is your API key:
149+
150+
Token {auth_token}
151+
152+
If you did NOT request this API key, you can either ignore this email or contact us at [email protected] and let us know in the forward that you did not request an API key.
153+
154+
The API root is at https://public.vulnerablecode.io/api
155+
To learn more about using the VulnerableCode.io API, please refer to the live API documentation at https://public.vulnerablecode.io/api/docs
156+
To learn about VulnerableCode, refer to the general documentation at https://vulnerablecode.readthedocs.io
157+
158+
--
159+
Sincerely,
160+
The nexB support Team.
161+
162+
VulnerableCode is a free and open database of software package vulnerabilities
163+
and the tools to aggregate and correlate these vulnerabilities.
164+
165+
Chat at https://gitter.im/aboutcode-org/vulnerablecode
166+
Docs at https://vulnerablecode.readthedocs.org/
167+
Source code and issues at https://github.com/nexB/vulnerablecode
168+
"""
169+
170+
144171
class ApiUserCreateView(generic.CreateView):
145172
model = models.ApiUser
146173
form_class = ApiUserCreationForm
@@ -155,15 +182,15 @@ def form_valid(self, form):
155182
return redirect(self.get_success_url())
156183

157184
send_mail(
158-
subject="VulnerableCode.io API key token",
159-
message=f"Here is your VulnerableCode.io API key token: {self.object.auth_token}",
185+
subject="VulnerableCode.io API key request",
186+
message=email_template.format(auth_token=self.object.auth_token),
160187
from_email=env.str("FROM_EMAIL", default=""),
161188
recipient_list=[self.object.email],
162189
fail_silently=True,
163190
)
164191

165192
messages.success(
166-
self.request, f"API key token sent to your email address {self.object.email}."
193+
self.request, f"Your API key token has been sent to your email: {self.object.email}."
167194
)
168195

169196
return response

vulnerablecode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
from pathlib import Path
1414

15-
__version__ = "30.3.0"
15+
__version__ = "30.3.1"
1616

1717

1818
def command_line():

vulnerablecode/settings.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@
3434

3535
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[".localhost", "127.0.0.1", "[::1]"])
3636

37-
VULNERABLECODE_REQUIRE_AUTHENTICATION = env.bool(
38-
"VULNERABLECODE_REQUIRE_AUTHENTICATION", default=False
39-
)
40-
4137
VULNERABLECODE_PASSWORD_MIN_LENGTH = env.int("VULNERABLECODE_PASSWORD_MIN_LENGTH", default=14)
4238

39+
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])
40+
4341
# SECURITY WARNING: do not run with debug turned on in production
4442
DEBUG = env.bool("VULNERABLECODE_DEBUG", default=False)
4543

0 commit comments

Comments
 (0)