Skip to content

Commit 67e20dc

Browse files
authored
ci: merge main to release (ietf-tools#9320)
2 parents f5df667 + 32e1fe7 commit 67e20dc

42 files changed

Lines changed: 477 additions & 198 deletions

Some content is hidden

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

dev/build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/ietf-tools/datatracker-app-base:20250624T1543
1+
FROM ghcr.io/ietf-tools/datatracker-app-base:20250807T1514
22
LABEL maintainer="IETF Tools Team <tools-discuss@ietf.org>"
33

44
ENV DEBIAN_FRONTEND=noninteractive

dev/build/TARGET_BASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250624T1543
1+
20250807T1514

docker/scripts/app-init-celery.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ fi
9292

9393
USER_BIN_PATH="/home/dev/.local/bin"
9494
WATCHMEDO="$USER_BIN_PATH/watchmedo"
95-
CELERY="$USER_BIN_PATH/celery"
95+
# Find a celery that works
96+
if [[ -x "$USER_BIN_PATH/celery" ]]; then
97+
# This branch is used for dev
98+
CELERY="$USER_BIN_PATH/celery"
99+
else
100+
# This branch is used for sandbox instances
101+
CELERY="/usr/local/bin/celery"
102+
fi
96103
trap 'trap "" TERM; cleanup' TERM
97104
# start celery in the background so we can trap the TERM signal
98105
if [[ -n "${DEV_MODE}" && -x "${WATCHMEDO}" ]]; then

ietf/api/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,26 @@ def dehydrate(self, bundle, for_list=True):
145145

146146

147147
class Serializer(tastypie.serializers.Serializer):
148+
OPTION_ESCAPE_NULLS = "datatracker-escape-nulls"
149+
148150
def format_datetime(self, data):
149151
return data.astimezone(datetime.timezone.utc).replace(tzinfo=None).isoformat(timespec="seconds") + "Z"
152+
153+
def to_simple(self, data, options):
154+
options = options or {}
155+
simple_data = super().to_simple(data, options)
156+
if (
157+
options.get(self.OPTION_ESCAPE_NULLS, False)
158+
and isinstance(simple_data, str)
159+
):
160+
# replace nulls with unicode "symbol for null character", \u2400
161+
simple_data = simple_data.replace("\x00", "\u2400")
162+
return simple_data
163+
164+
def to_etree(self, data, options=None, name=None, depth=0):
165+
# lxml does not escape nulls on its own, so ask to_simple() to do it.
166+
# This is mostly (only?) an issue when generating errors responses for
167+
# fuzzers.
168+
options = options or {}
169+
options[self.OPTION_ESCAPE_NULLS] = True
170+
return super().to_etree(data, options, name, depth)

ietf/api/tests.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import datetime
66
import json
77
import html
8-
import mock
8+
from unittest import mock
99
import os
1010
import sys
1111

@@ -41,6 +41,7 @@
4141
from ietf.utils.models import DumpInfo
4242
from ietf.utils.test_utils import TestCase, login_testing_unauthorized, reload_db_objects
4343

44+
from . import Serializer
4445
from .ietf_utils import is_valid_token, requires_api_token
4546
from .views import EmailIngestionError
4647

@@ -1496,7 +1497,7 @@ def test_good_password(self):
14961497
data = self.response_data(r)
14971498
self.assertEqual(data["result"], "success")
14981499

1499-
class TastypieApiTestCase(ResourceTestCaseMixin, TestCase):
1500+
class TastypieApiTests(ResourceTestCaseMixin, TestCase):
15001501
def __init__(self, *args, **kwargs):
15011502
self.apps = {}
15021503
for app_name in settings.INSTALLED_APPS:
@@ -1506,7 +1507,7 @@ def __init__(self, *args, **kwargs):
15061507
models_path = os.path.join(os.path.dirname(app.__file__), "models.py")
15071508
if os.path.exists(models_path):
15081509
self.apps[name] = app_name
1509-
super(TastypieApiTestCase, self).__init__(*args, **kwargs)
1510+
super().__init__(*args, **kwargs)
15101511

15111512
def test_api_top_level(self):
15121513
client = Client(Accept='application/json')
@@ -1541,6 +1542,21 @@ def test_all_model_resources_exist(self):
15411542
self.assertIn(model._meta.model_name, list(app_resources.keys()),
15421543
"There doesn't seem to be any API resource for model %s.models.%s"%(app.__name__,model.__name__,))
15431544

1545+
def test_serializer_to_etree_handles_nulls(self):
1546+
"""Serializer to_etree() should handle a null character"""
1547+
serializer = Serializer()
1548+
try:
1549+
serializer.to_etree("string with no nulls in it")
1550+
except ValueError:
1551+
self.fail("serializer.to_etree raised ValueError on an ordinary string")
1552+
try:
1553+
serializer.to_etree("string with a \x00 in it")
1554+
except ValueError:
1555+
self.fail(
1556+
"serializer.to_etree raised ValueError on a string "
1557+
"containing a null character"
1558+
)
1559+
15441560

15451561
class RfcdiffSupportTests(TestCase):
15461562

ietf/community/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright The IETF Trust 2016-2023, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

4-
import mock
4+
from unittest import mock
55
from pyquery import PyQuery
66

77
from django.test.utils import override_settings

ietf/doc/management/commands/find_github_backup_info.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

ietf/doc/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.http import HttpRequest
1111
import lxml
1212
import bibtexparser
13-
import mock
13+
from unittest import mock
1414
import json
1515
import copy
1616
import random

ietf/doc/tests_ballot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
import datetime
6-
import mock
6+
from unittest import mock
77

88
from pyquery import PyQuery
99

ietf/doc/tests_draft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import datetime
77
import io
8-
import mock
8+
from unittest import mock
99

1010
from collections import Counter
1111
from pathlib import Path

0 commit comments

Comments
 (0)