Skip to content

Commit 16d4f3a

Browse files
authored
Merge branch 'main' into svn-ssh-non-onteractive
2 parents f04d773 + fdf22cc commit 16d4f3a

12 files changed

Lines changed: 106 additions & 22 deletions

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Release 0.14.0 (unreleased)
22
===========================
33

4+
* Warn when a project URL uses a plaintext transport scheme (#1229)
45
* Documentation and threat-model clarifications for existing release attestation support (#1208)
56
* Report SVN externals fetched during update (#1220)
67
* Use ``.cdx.json`` as the default extension for CycloneDX SBOM reports (#1118)

dfetch/manifest/project.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,38 @@
321321
import copy
322322
from collections.abc import Sequence
323323
from dataclasses import dataclass, field
324+
from urllib.parse import urlsplit, urlunsplit
324325

325326
from typing_extensions import Required, TypedDict
326327

328+
from dfetch.log import get_logger
327329
from dfetch.manifest.remote import Remote
328330
from dfetch.manifest.version import Version
329331
from dfetch.util.util import always_str_list, str_if_possible
330332

333+
logger = get_logger(__name__)
334+
335+
_PLAINTEXT_SCHEMES = frozenset({"http", "git", "svn"})
336+
337+
338+
def plaintext_warning(url: str) -> str:
339+
"""Return a warning string if *url* uses a plaintext transport, else empty string."""
340+
parsed = urlsplit(url)
341+
scheme = parsed.scheme.lower()
342+
if scheme not in _PLAINTEXT_SCHEMES:
343+
return ""
344+
host = parsed.hostname or ""
345+
try:
346+
port = parsed.port
347+
except ValueError:
348+
port = None
349+
netloc = f"{host}:{port}" if isinstance(port, int) else host
350+
redacted_url = urlunsplit((scheme, netloc, parsed.path, "", ""))
351+
return (
352+
f"Project URL '{redacted_url}' uses plaintext transport ({scheme}://). "
353+
"Use https:// or SSH (e.g. svn+ssh://) to prevent interception."
354+
)
355+
331356

332357
@dataclass
333358
class Integrity:

dfetch/project/subproject.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Callable, Sequence
77

88
from dfetch.log import get_logger
9-
from dfetch.manifest.project import ProjectEntry
9+
from dfetch.manifest.project import ProjectEntry, plaintext_warning
1010
from dfetch.manifest.version import Version
1111
from dfetch.project.abstract_check_reporter import AbstractCheckReporter
1212
from dfetch.project.metadata import Dependency, InvalidMetadataError, Metadata
@@ -129,6 +129,8 @@ def update(
129129
f"Fetching {to_fetch}",
130130
enabled=self._show_animations,
131131
):
132+
if warning := plaintext_warning(self.__project.remote_url):
133+
logger.print_warning_line(self.__project.name, warning)
132134
actually_fetched, dependency = self._fetch_impl(to_fetch)
133135
self._log_project(f"Fetched {actually_fetched}")
134136

@@ -213,6 +215,8 @@ def check_for_update(
213215
with logger.status(
214216
self.__project.name, "Checking", enabled=self._show_animations
215217
):
218+
if warning := plaintext_warning(self.__project.remote_url):
219+
logger.print_warning_line(self.__project.name, warning)
216220
latest_version = self._check_for_newer_version()
217221

218222
if not latest_version:

doc/explanation/security.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ to reproduce a deterministic dependency state.
9696
allow exfiltration risks if upstream sources are compromised or intentionally
9797
malicious.
9898

99+
.. note::
100+
101+
dfetch warns during dependency update/check operations when a project URL uses a plaintext
102+
transport scheme (``http://``, ``git://``, or ``svn://``). Use ``https://``
103+
or SSH (e.g. ``svn+ssh://``) to protect dependency fetches against interception.
104+
99105
Threat Models
100106
-------------
101107

features/check-svn-repo.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: Checking dependencies from a svn repository
1111
1212
remotes:
1313
- name: cunit
14-
url-base: svn://svn.code.sf.net/p/cunit/code
14+
url-base: https://svn.code.sf.net/p/cunit/code
1515
1616
projects:
1717
- name: cunit-svn-rev-only
@@ -44,7 +44,7 @@ Feature: Checking dependencies from a svn repository
4444
4545
remotes:
4646
- name: cutter
47-
url-base: svn://svn.code.sf.net/p/cutter/svn/cutter
47+
url-base: https://svn.code.sf.net/p/cutter/svn/cutter
4848
4949
projects:
5050
- name: cutter-svn-tag
@@ -69,7 +69,7 @@ Feature: Checking dependencies from a svn repository
6969
7070
remotes:
7171
- name: cunit
72-
url-base: svn://svn.code.sf.net/p/cunit/code
72+
url-base: https://svn.code.sf.net/p/cunit/code
7373
default: true
7474
7575
projects:
@@ -152,7 +152,7 @@ Feature: Checking dependencies from a svn repository
152152
153153
remotes:
154154
- name: cutter
155-
url-base: svn://svn.code.sf.net/p/cutter/svn/cutter
155+
url-base: https://svn.code.sf.net/p/cutter/svn/cutter
156156
157157
projects:
158158
- name: cutter-svn-tag

features/fetch-svn-repo.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Feature: Fetching dependencies from a svn repository
1717
1818
remotes:
1919
- name: cunit
20-
url-base: svn://svn.code.sf.net/p/cunit/code
20+
url-base: https://svn.code.sf.net/p/cunit/code
2121
default: true
2222
2323
- name: cutter
24-
url-base: svn://svn.code.sf.net/p/cutter/svn/cutter
24+
url-base: https://svn.code.sf.net/p/cutter/svn/cutter
2525
2626
projects:
2727
- name: cunit-svn-rev-only

features/freeze-projects.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Feature: Freeze dependencies
4444
projects:
4545
- name: cunit-svn
4646
vcs: svn
47-
url: svn://svn.code.sf.net/p/cunit/code
47+
url: https://svn.code.sf.net/p/cunit/code
4848
4949
"""
5050
And all projects are updated
@@ -59,7 +59,7 @@ Feature: Freeze dependencies
5959
branch: trunk
6060
revision: '176'
6161
vcs: svn
62-
url: svn://svn.code.sf.net/p/cunit/code
62+
url: https://svn.code.sf.net/p/cunit/code
6363
6464
"""
6565

features/list-projects.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Feature: List dependencies
5858
5959
projects:
6060
- name: cutter-svn-tag
61-
url: svn://svn.code.sf.net/p/cutter/svn/cutter
61+
url: https://svn.code.sf.net/p/cutter/svn/cutter
6262
tag: 1.1.7
6363
vcs: svn
6464
src: acmacros
@@ -71,7 +71,7 @@ Feature: List dependencies
7171
Dfetch (0.13.0)
7272
cutter-svn-tag:
7373
- remote : <none>
74-
remote url : svn://svn.code.sf.net/p/cutter/svn/cutter
74+
remote url : https://svn.code.sf.net/p/cutter/svn/cutter
7575
branch : <none>
7676
tag : 1.1.7
7777
last fetch : 29/12/2024, 20:09:21

features/patch-after-fetch-svn.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: Patch after fetching from svn repo
1212
1313
remotes:
1414
- name: cutter
15-
url-base: svn://svn.code.sf.net/p/cutter/svn/cutter
15+
url-base: https://svn.code.sf.net/p/cutter/svn/cutter
1616
1717
projects:
1818
- name: cutter
@@ -46,7 +46,7 @@ Feature: Patch after fetching from svn repo
4646
4747
remotes:
4848
- name: cutter
49-
url-base: svn://svn.code.sf.net/p/cutter/svn/cutter
49+
url-base: https://svn.code.sf.net/p/cutter/svn/cutter
5050
5151
projects:
5252
- name: cutter

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ development = [
8383
"tomli; python_version < '3.11'", # Tomllib is default in 3.11, required for letting codespell read the pyproject.toml
8484
'pre-commit==4.6.0',
8585
'ruff==0.15.14',
86-
'hypothesis==6.152.9',
86+
'hypothesis==6.152.10',
8787
'import-linter==2.11',
8888
]
8989
docs = [

0 commit comments

Comments
 (0)