Skip to content

Commit 7a512c2

Browse files
committed
Merge branch 'main' into 1228-fixed-affected-version-matching #1228
Reference: #1228 Signed-off-by: John M. Horan [email protected]
2 parents 0ec7d6c + d3f314d commit 7a512c2

File tree

8 files changed

+44
-8
lines changed

8 files changed

+44
-8
lines changed

CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ Release notes
22
=============
33

44

5+
Version v33.6.3
6+
----------------
7+
8+
- We updated RTD build configuration.
9+
- We added importer for OSS-Fuzz.
10+
- We removed vulnerabilities with empty aliases.
11+
- We fixed search encoding issue https://github.com/nexB/vulnerablecode/issues/1336.
12+
- We added middleware to ban "bytedance" user-agent.
13+
14+
515
Version v33.6.2
616
----------------
717

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 = 33.6.2
3+
version = 33.6.3
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/improvers/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#
99

1010
from vulnerabilities.improvers import valid_versions
11-
from vulnerabilities.improvers import vulnerability_status
11+
12+
# from vulnerabilities.improvers import vulnerability_status
1213

1314
IMPROVERS_REGISTRY = [
1415
valid_versions.GitHubBasicImprover,
@@ -24,7 +25,7 @@
2425
valid_versions.DebianOvalImprover,
2526
valid_versions.UbuntuOvalImprover,
2627
valid_versions.OSSFuzzImprover,
27-
vulnerability_status.VulnerabilityStatusImprover,
28+
# vulnerability_status.VulnerabilityStatusImprover,
2829
]
2930

3031
IMPROVERS_REGISTRY = {x.qualified_name: x for x in IMPROVERS_REGISTRY}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
from django.http import HttpResponseNotFound
11+
from django.utils.deprecation import MiddlewareMixin
12+
13+
14+
class BanUserAgent(MiddlewareMixin):
15+
def process_request(self, request):
16+
user_agent = request.META.get("HTTP_USER_AGENT", None)
17+
if user_agent and "bytedance" in user_agent:
18+
return HttpResponseNotFound(404)

vulnerabilities/templates/includes/pagination.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<nav class="pagination is-centered is-small" aria-label="pagination">
22
{% if page_obj.has_previous %}
3-
<a href="?page={{ page_obj.previous_page_number }}&search={{ search }}" class="pagination-previous">Previous</a>
3+
<a href="?page={{ page_obj.previous_page_number }}&search={{ search|urlencode }}" class="pagination-previous">Previous</a>
44
{% else %}
55
<a class="pagination-previous" disabled>Previous</a>
66
{% endif %}
77

88
{% if page_obj.has_next %}
9-
<a href="?page={{ page_obj.next_page_number }}&search={{ search }}" class="pagination-next">Next</a>
9+
<a href="?page={{ page_obj.next_page_number }}&search={{ search|urlencode }}" class="pagination-next">Next</a>
1010
{% else %}
1111
<a class="pagination-next" disabled>Next</a>
1212
{% endif %}
1313

1414
<ul class="pagination-list">
1515
{% if page_obj.number != 1%}
1616
<li>
17-
<a href="?page=1&search={{ search }}" class="pagination-link" aria-label="Goto page 1">1</a>
17+
<a href="?page=1&search={{ search|urlencode }}" class="pagination-link" aria-label="Goto page 1">1</a>
1818
</li>
1919
{% if page_obj.number > 2 %}
2020
<li>
@@ -32,7 +32,7 @@
3232
</li>
3333
{% endif %}
3434
<li>
35-
<a href="?page={{ page_obj.paginator.num_pages }}&search={{ search }}" class="pagination-link" aria-label="Goto page {{ page_obj.paginator.num_pages }}">{{ page_obj.paginator.num_pages }}</a>
35+
<a href="?page={{ page_obj.paginator.num_pages }}&search={{ search|urlencode }}" class="pagination-link" aria-label="Goto page {{ page_obj.paginator.num_pages }}">{{ page_obj.paginator.num_pages }}</a>
3636
</li>
3737
{% endif %}
3838
</ul>

vulnerabilities/tests/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,9 @@ def test_with_invalid_cpes(self):
743743
content_type="application/json",
744744
).json()
745745
assert response == {"Error": "Invalid CPE: CVE-2022-2022"}
746+
747+
748+
class TesBanUserAgent(TestCase):
749+
def test_ban_request_with_bytedance_user_agent(self):
750+
response = self.client.get(f"/api/packages", format="json", HTTP_USER_AGENT="bytedance")
751+
assert 404 == response.status_code

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__ = "33.6.2"
15+
__version__ = "33.6.3"
1616

1717

1818
def command_line():

vulnerablecode/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"django.contrib.auth.middleware.AuthenticationMiddleware",
9090
"django.contrib.messages.middleware.MessageMiddleware",
9191
"django.middleware.clickjacking.XFrameOptionsMiddleware",
92+
"vulnerabilities.middleware.ban_user_agent.BanUserAgent",
9293
)
9394

9495
ROOT_URLCONF = "vulnerablecode.urls"

0 commit comments

Comments
 (0)