Skip to content

Commit bd22f96

Browse files
author
Martin Vrachev
committed
Fix sslib new versions incompatibility bug
The incompatibility with newer securesystemslib versions was caused because of a new breaking change introduced in: secure-systems-lab/securesystemslib#231 Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
1 parent f0c2a20 commit bd22f96

6 files changed

Lines changed: 305 additions & 229 deletions

File tree

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ redis = "*"
1212
tuf = "==2.0.0"
1313
dynaconf = {extras = ["ini"], version = "*"}
1414
supervisor = "*"
15-
securesystemslib = "==0.23.0"
15+
securesystemslib = "*"
1616
sqlalchemy = "*"
1717
psycopg2 = "*"
1818
alembic = "*"
@@ -63,7 +63,7 @@ pyparsing = "==3.0.9"
6363
pytz = "==2022.2.1"
6464
redis = "==4.3.4"
6565
requests = "==2.28.1"
66-
securesystemslib = "==0.23.0"
66+
securesystemslib = "==0.25.0"
6767
six = "==1.16.0"
6868
toml = "==0.10.2"
6969
tomli = "==2.0.1"

Pipfile.lock

Lines changed: 255 additions & 207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

repository_service_tuf_worker/interfaces.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from abc import ABC, abstractmethod
1818
from dataclasses import dataclass
1919
from io import TextIOBase
20-
from typing import Any, Dict, List
20+
from typing import Any, Dict, List, Optional
2121

2222
from tuf.api.metadata import ( # type: ignore
2323
Metadata,
@@ -90,7 +90,12 @@ def get(self, rolename: str, version: int) -> "Metadata[T]":
9090
raise NotImplementedError # pragma: no cover
9191

9292
@abstractmethod
93-
def put(self, file_object: TextIOBase, filename: str) -> None:
93+
def put(
94+
self,
95+
file_object: TextIOBase,
96+
filename: str,
97+
restrict: Optional[bool] = False,
98+
) -> None:
9499
"""
95100
Stores file object with a specific filename.
96101
"""

repository_service_tuf_worker/services/storage/local.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import glob
66
import os
77
import shutil
8+
import stat
89
from contextlib import contextmanager
910
from io import BufferedReader, TextIOBase
10-
from typing import List
11+
from typing import List, Optional
1112

1213
from securesystemslib.exceptions import StorageError # noqa
1314

@@ -69,17 +70,36 @@ def get(self, role, version=None) -> BufferedReader:
6970
if file_object is not None:
7071
file_object.close()
7172

72-
def put(self, file_object: TextIOBase, filename: str) -> None:
73+
def put(
74+
self,
75+
file_object: TextIOBase,
76+
filename: str,
77+
restrict: Optional[bool] = False,
78+
) -> None:
7379
"""
7480
Writes passed file object to configured TUF repo path using the passed
7581
filename.
7682
"""
77-
file_path = os.path.join(self._path, filename)
83+
filename = os.path.join(self._path, filename)
7884
if not file_object.closed:
7985
file_object.seek(0)
8086

87+
if restrict:
88+
# On UNIX-based systems restricted files are created with read and
89+
# write permissions for the user only (octal value 0o600).
90+
fd = os.open(
91+
filename, os.O_WRONLY | os.O_CREAT, stat.S_IRUSR | stat.S_IWUSR
92+
)
93+
else:
94+
# Non-restricted files use the default 'mode' argument of os.open()
95+
# granting read, write, and execute for all users (mode 0o777).
96+
# NOTE: mode may be modified by the user's file mode creation mask
97+
# (umask) or on Windows limited to the smaller set of OS supported
98+
# permisssions.
99+
fd = os.open(filename, os.O_WRONLY | os.O_CREAT)
100+
81101
try:
82-
with open(file_path, "wb") as destination_file:
102+
with os.fdopen(fd, "wb") as destination_file:
83103
shutil.copyfileobj(file_object, destination_file)
84104
destination_file.flush()
85105
os.fsync(destination_file.fileno())

requirements-dev.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ click-plugins==1.1.1
1717
click-repl==0.2.0
1818
configobj==5.0.6
1919
coverage==6.4.4
20-
cryptography==38.0.4
20+
cryptography==39.0.0
2121
deprecated==1.2.13
2222
distlib==0.3.5
2323
docutils==0.17.1 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
2424
dynaconf[ini]==3.1.11
2525
filelock==3.8.0
2626
flake8==5.0.4
27-
identify==2.5.11 ; python_version >= '3.7'
27+
identify==2.5.12 ; python_version >= '3.7'
2828
idna==3.4 ; python_version >= '3.5'
2929
imagesize==1.4.1 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
3030
iniconfig==1.1.1
@@ -51,15 +51,15 @@ py==1.11.0
5151
pycodestyle==2.9.1
5252
pycparser==2.21
5353
pyflakes==2.5.0
54-
pygments==2.13.0 ; python_version >= '3.6'
54+
pygments==2.14.0 ; python_version >= '3.6'
5555
pynacl==1.5.0
5656
pyparsing==3.0.9
5757
pytest==7.1.2
5858
pytz==2022.7
5959
pyyaml==6.0 ; python_version >= '3.6'
6060
redis==4.4.0
6161
requests==2.28.1 ; python_version >= '3.7' and python_version < '4'
62-
securesystemslib==0.23.0
62+
securesystemslib==0.25.0
6363
setuptools==65.6.3 ; python_version >= '3.7'
6464
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
6565
snowballstemmer==2.2.0
@@ -80,12 +80,13 @@ typing-extensions==4.4.0 ; python_version >= '3.7'
8080
urllib3==1.26.13 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
8181
vine==5.0.0 ; python_version >= '3.6'
8282
virtualenv==20.16.3
83-
watchdog==2.2.0
83+
watchdog==2.2.1
8484
wcwidth==0.2.5
8585
wrapt==1.14.1
86-
alembic==1.8.1
86+
alembic==1.9.1
8787
greenlet==2.0.1 ; python_version >= '3' and platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))
88+
mako==1.2.4 ; python_version >= '3.7'
8889
psycopg2==2.9.5
89-
pydantic==1.10.2
90-
sqlalchemy==1.4.44
90+
pydantic==1.10.4
91+
sqlalchemy==1.4.46
9192
supervisor==4.2.5

requirements.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-i https://pypi.org/simple
2-
alembic==1.8.1
2+
alembic==1.9.1
33
amqp==5.1.1 ; python_version >= '3.6'
44
async-timeout==4.0.2 ; python_version >= '3.6'
55
billiard==3.6.4.0
@@ -12,27 +12,29 @@ click-didyoumean==0.3.0 ; python_full_version >= '3.6.2' and python_full_version
1212
click-plugins==1.1.1
1313
click-repl==0.2.0
1414
configobj==5.0.6
15-
cryptography==38.0.4
15+
cryptography==39.0.0
1616
dynaconf[ini]==3.1.11
1717
greenlet==2.0.1 ; python_version >= '3' and platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))
1818
idna==3.4 ; python_version >= '3.5'
1919
kombu==5.2.4 ; python_version >= '3.7'
20+
mako==1.2.4 ; python_version >= '3.7'
21+
markupsafe==2.1.1 ; python_version >= '3.7'
2022
prompt-toolkit==3.0.36 ; python_full_version >= '3.6.2'
2123
psycopg2==2.9.5
2224
pycparser==2.21
23-
pydantic==1.10.2
25+
pydantic==1.10.4
2426
pynacl==1.5.0
2527
pytz==2022.7
2628
redis==4.4.0
2729
requests==2.28.1 ; python_version >= '3.7' and python_version < '4'
28-
securesystemslib==0.23.0
30+
securesystemslib==0.25.0
2931
setuptools==65.6.3 ; python_version >= '3.7'
3032
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
31-
sqlalchemy==1.4.44
33+
sqlalchemy==1.4.46
3234
supervisor==4.2.5
3335
tuf==2.0.0
3436
typing-extensions==4.4.0 ; python_version >= '3.7'
3537
urllib3==1.26.13 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
3638
vine==5.0.0 ; python_version >= '3.6'
37-
watchdog==2.2.0
39+
watchdog==2.2.1
3840
wcwidth==0.2.5

0 commit comments

Comments
 (0)