Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to the newest version of TUF #561

Merged
merged 117 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
60b8fa9
Update tuf, securesystemslib and cryptography deps
lukpueh Aug 23, 2024
f62907e
Add alternative TUF metadata repo implementation
lukpueh Aug 23, 2024
ad2b58f
Change create and add_keys API to take signers
lukpueh Aug 26, 2024
b46645b
Make sure targets is signed on add key
lukpueh Aug 26, 2024
33750eb
Assert keytype rsa in taf.tuf.keys helper
lukpueh Aug 27, 2024
42fbfac
Add signer implementation for Yubikeys
lukpueh Aug 28, 2024
25371d7
Comment out legacy imports (WIP)
lukpueh Aug 28, 2024
ec294a8
Merge branch 'feature/tuf-repositoty' into tuf-upgrade
renatav Oct 29, 2024
70927b7
Merge pull request #512 from lukpueh/tuf-upgrade
renatav Oct 29, 2024
9bf3fb9
feat: moved get threshold to the new repository class, implement dele…
renatav Oct 29, 2024
c7be3cb
refact: move get expiration date, get all targets and check expiratio…
renatav Oct 30, 2024
7601b9b
refact: move get role paths and all target files to the new repositor…
renatav Oct 30, 2024
b8d247e
refact: work on making the create repository method more flexible
renatav Oct 31, 2024
ade9af1
refact: extend creation of repositories using the new TUF, added supp…
renatav Oct 31, 2024
f1c1b6c
test: add create repository with delegations test
renatav Nov 1, 2024
ea05769
test: use repository created using create in tests
renatav Nov 1, 2024
c9857d0
test, refact: reorganize tests, implement keyid-roles mapping using t…
renatav Nov 1, 2024
b7eb34a
test: re-enabled add target test
renatav Nov 2, 2024
ccb94b8
refact: moved modify targets to the new repository class
renatav Nov 4, 2024
43af588
test: create test repos with target files and custom data
renatav Nov 5, 2024
feb7b53
refac, test: move get_all_target_files_state to the new repository cl…
renatav Nov 5, 2024
3202900
refact: move generate_roles_description to the new repository class
renatav Nov 5, 2024
af59138
test, refact: minor tests refactoring, reimplement is_valid_metadata_key
renatav Nov 6, 2024
51d63c9
refact: test: reimplement add metadata keys, enable keys tests
renatav Nov 6, 2024
e57b8e3
feat, test: implement revoke key
renatav Nov 7, 2024
abeaa2c
test, fix: minor add and revoke key improvements
renatav Nov 7, 2024
f3bc1f7
refact, test: initial work on reworking signing, add set expiration d…
renatav Nov 8, 2024
2681d4a
refact: remeve outdated imports
renatav Nov 8, 2024
0d67dd5
refact: check and set expiration date reimplemented
renatav Nov 8, 2024
ba7d3eb
refact: update key generation
renatav Nov 8, 2024
ea93127
refact: reimplement repository_at_revision
renatav Nov 9, 2024
4122100
refact: update updater and the creation of a new repository
renatav Nov 9, 2024
e21edfd
fix: bare repositories fix
renatav Nov 9, 2024
d9e5cc0
refact: reimplement addition of verification keys when creating a new…
renatav Nov 11, 2024
67fbc2b
fix: minor create repo fix
renatav Nov 11, 2024
c1cd853
refact: remove do_snapshot and timestamp from add/revoke keys
renatav Nov 11, 2024
7fe4d2f
refact: work on initializing repository and signers in api
renatav Nov 14, 2024
e77210b
fix, feat: fix add keys, add revoke key command
renatav Nov 14, 2024
947f1e4
test: add add delegated paths test
renatav Nov 14, 2024
5c56ede
refact: rework create new role
renatav Nov 15, 2024
c92c39b
refact: support adding multiple new roles
renatav Nov 15, 2024
f63a058
refact, fix: fix create delagations when no previouis delgations, rew…
renatav Nov 15, 2024
66a2742
refact: refactored remove paths
renatav Nov 16, 2024
2fe6d72
fix: minor fixes, update update-expiration-dates
renatav Nov 16, 2024
5ddb0c3
refact, test: remove unused code, remove paths test added
renatav Nov 16, 2024
dfbcde6
refact: rework targets update
renatav Nov 16, 2024
c541df8
test: add update targets roles test
renatav Nov 18, 2024
45c8c02
refact: reimplement add target repo
renatav Nov 19, 2024
4917b71
refact: rework remove target repo
renatav Nov 19, 2024
2f817d3
refact: update add/remove dependencies
renatav Nov 19, 2024
de7f5f8
test, refact: refact repository init tests, remove outdated tests
renatav Nov 19, 2024
96c7df1
test: work on refactoring test_create_repository tests
renatav Nov 20, 2024
7a787f4
test, refact: reorganize conftest
renatav Nov 20, 2024
1b7146b
test: rework test dependencies, metadata and roles api tests
renatav Nov 21, 2024
c5de6e1
chore: remove ramaining test repos
renatav Nov 21, 2024
739c014
test: refact test targets
renatav Nov 21, 2024
4fd29db
test, refact: update repositoriesdb tests, some refactoring, remove u…
renatav Nov 21, 2024
fbc0a8a
fix: fix snapshot info length/hash issue
renatav Nov 22, 2024
68fb96e
feat: initial implementation of git storage backed, which can load me…
renatav Nov 22, 2024
84a52f2
fix: bypass storage singleton
renatav Nov 22, 2024
8224179
fix: update root version number when updating snaphost. Work on updat…
renatav Nov 25, 2024
5afeaf5
test: update test_update_invalid
renatav Nov 26, 2024
6573a6a
fix: fix update expiration dates. Snapshot info was not getting updated
renatav Nov 27, 2024
959ab49
test: update remaining updater tests, minor cleanup
renatav Nov 27, 2024
16abe0c
chore: cleanup, formatting, remove unused code and imports
renatav Nov 27, 2024
4f02ce1
chore: bump yubikey-manager version
renatav Nov 27, 2024
62a8cac
chore: fixing mypy issues
renatav Nov 27, 2024
cb5b45a
chore: import and mypy issues
renatav Nov 27, 2024
2070426
chore: mypy issues
renatav Nov 27, 2024
106836c
chore: remove unused import
renatav Nov 27, 2024
896eb73
chore: comment out yubukey tests
renatav Nov 27, 2024
f262d81
test: remove generation of tests
renatav Nov 27, 2024
324e642
chore: formatting
renatav Nov 27, 2024
ea6dbf2
test: fix a number of failing tests
renatav Nov 28, 2024
32b2930
chore: remove unused import
renatav Nov 28, 2024
b37a631
test: rework keys tests
renatav Nov 28, 2024
d3d7263
test: update number of root keys in updater keys description
renatav Nov 29, 2024
3000095
fix: fix failing tests
renatav Nov 29, 2024
65c128b
refact: update yubikey cli functions
renatav Nov 29, 2024
4805128
test: refact yubikey tests
renatav Nov 30, 2024
789b591
refact: refactor creation of repositories using yubikeys
renatav Nov 30, 2024
ff146df
chore: formatting and mypy fixes
renatav Nov 30, 2024
e402196
test: add pytest-mock to test requirements
renatav Nov 30, 2024
de1bd82
Merge branch 'master' into feature/tuf-repositoty
renatav Nov 30, 2024
da5344d
chore: update changelog
renatav Nov 30, 2024
2f16959
chore: merge master
renatav Nov 30, 2024
f22da80
test: tun tests without having ykman installed
renatav Dec 4, 2024
7db3588
chore: ignore unused import
renatav Dec 4, 2024
6410f52
docs: GitStorageBackend docstring
renatav Dec 4, 2024
4ab8c48
feat: add a command for rotating keys
renatav Dec 9, 2024
dc431c5
test: add test revoke signing key test
renatav Dec 9, 2024
5ea21e7
docs: update docs related to repository classes
renatav Dec 10, 2024
bef7f8e
chore: merge master and resolve conflicts
renatav Dec 13, 2024
4490e9b
docs: add/update a number of metadata repository docstrings
renatav Dec 19, 2024
81e0799
docs: add docstrings to metadata repository
renatav Dec 19, 2024
78a91b5
docs: update docstrings, comments and docs
renatav Dec 20, 2024
cc45f38
chore: mypy and formatting fixes
renatav Dec 21, 2024
22dd4b8
refact: update validation.py imports
renatav Dec 21, 2024
8b20832
feat: introduce cli tests with click `CliRunner`
n-dusan Dec 21, 2024
005b293
test: fix failing cli tests
renatav Dec 24, 2024
6f79d2b
chore: merge master and resolve conflicts
renatav Dec 24, 2024
f496fe9
chore: formatting
renatav Dec 24, 2024
019d963
fix, tests: minor update metadata fix and additional tests
renatav Dec 24, 2024
503653b
fix: do not update snapshot and timestamp twice
renatav Dec 25, 2024
8ce54e0
fix: fix update timestamp without snapshot
renatav Dec 25, 2024
95263f0
feat, fix: add update timestamp and snapshot api function, minor fixes
renatav Dec 25, 2024
408f9bd
feat: introduce get_role_paths back to auth_repo.py
n-dusan Dec 26, 2024
061a860
feat: add create/remove target files as a separate repository function
renatav Dec 26, 2024
8f1b2e9
refact: update fake yubikey
renatav Dec 26, 2024
af0af2e
chore: mypy return type fix
renatav Dec 26, 2024
19ebb23
fix: set storage commit to None in repository at revision context man…
renatav Dec 26, 2024
61e6788
feat: add a function for syncing snapshot with the provided roles
renatav Dec 29, 2024
60e2c70
fix: set update_expiration_date in update snapshot and timestamp
n-dusan Dec 30, 2024
87394b1
chore: fix typo
n-dusan Jan 3, 2025
1a38bb3
fix: convert CRLF to LF before creating target object
n-dusan Jan 3, 2025
42771cc
feat: add an option to update certain metadata files when signing tar…
renatav Jan 4, 2025
5520204
Merge branch 'master' into feature/tuf-repositoty
renatav Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"click==8.*",
"colorama>=0.3.9",
"tuf==5.*",
# "cryptography>=40.0.0",
"cryptography==43.0.*",
"securesystemslib==1.*",
"loguru==0.7.*",
'pygit2==1.9.*; python_version < "3.11"',
'pygit2==1.14.*; python_version >= "3.11"',
"pyOpenSSL==22.1.*",
"pyOpenSSL==24.2.*",
"logdecorator==2.*",
],
"extras_require": {
Expand Down
1 change: 0 additions & 1 deletion taf/api/api_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def manage_repo_and_signers(
# restore metadata, leave targets as they might have been modified by the user
# TODO flag for also resetting targets?
# also update the CLI error handling
import pdb; pdb.set_trace()
auth_repo.restore(paths_to_reset_on_error)

raise TAFError from e
3 changes: 1 addition & 2 deletions taf/api/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def add_multiple_roles(

roles_to_add = [role_data.name for role_data in new_roles_data]
commit_msg = git_commit_message("add-roles", roles=", ".join(roles_to_add))
roles_to_load = [role_data.parent.name for role_data in new_roles_data]
roles_to_load = [role_data.parent.name for role_data in new_roles_data if role_data.parent.name not in roles_to_add]
keystore_path = roles_keys_data_new.keystore

with manage_repo_and_signers(
Expand All @@ -288,7 +288,6 @@ def add_multiple_roles(
commit=commit,
push=push,
):

all_signers = {}
for role_to_add_data in roles_to_add_data:
signers, _ = load_sorted_keys_of_new_roles(
Expand Down
11 changes: 9 additions & 2 deletions taf/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def pytest_generate_tests(metafunc):

@fixture(scope="module", autouse=True)
def repo_dir():
path = CLIENT_DIR_PATH / "repos"
path = CLIENT_DIR_PATH
if path.is_dir():
shutil.rmtree(path, onerror=on_rm_error)
path.mkdir()
yield path
shutil.rmtree(path, onerror=on_rm_error)
Expand All @@ -54,7 +56,7 @@ def keystore():
@fixture(scope="module")
def keystore_delegations():
"""Create signer from some rsa test key."""
return TEST_DATA_PATH / "keystores" / "keystore_no_delegations"
return TEST_DATA_PATH / "keystores" / "keystore_delegations"


@fixture(scope="module")
Expand All @@ -67,6 +69,11 @@ def with_delegations_no_yubikeys_input():
return json.loads(WITH_DELEGATIONS.read_text())


@fixture(scope="module")
def with_delegations_no_yubikeys_path():
return WITH_DELEGATIONS


@fixture(scope="module")
def signers(keystore):
return _load_signers_from_keystore(keystore)
Expand Down
49 changes: 45 additions & 4 deletions taf/tests/test_api/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import json

from pathlib import Path
import shutil
import uuid
from taf.api.repository import create_repository
from taf.auth_repo import AuthenticationRepository
from taf.tests.conftest import KEYSTORES_PATH, TEST_DATA_PATH
from taf.utils import on_rm_error

from pytest import fixture

Expand All @@ -21,7 +26,6 @@
INVALID_PATH_INPUT = REPOSITORY_DESCRIPTION_INPUT_DIR / "invalid_path.json"
OLD_YUBIKEY_INPUT = REPOSITORY_DESCRIPTION_INPUT_DIR / "with_old_yubikey.json"

KEYSTORE_PATH = KEYSTORES_PATH / "api_keystore"
REPOSITORIES_JSON_PATH = TEST_INIT_DATA_PATH / "repositories.json"
MIRRORS_JSON_PATH = TEST_INIT_DATA_PATH / "mirrors.json"

Expand All @@ -31,8 +35,46 @@ def _read_json(path):


@fixture
def api_keystore():
return str(KEYSTORE_PATH)
def auth_repo_path(repo_dir):
random_name = str(uuid.uuid4())
path = repo_dir / "api" / random_name / "auth"
yield path
shutil.rmtree(path.parent, onerror=on_rm_error)


@fixture
def auth_repo(auth_repo_path, keystore_delegations, no_yubikeys_path):
repo_path = str(auth_repo_path)
create_repository(
repo_path,
roles_key_infos=no_yubikeys_path,
keystore=keystore_delegations,
commit=True,
test=True,
)
auth_repo = AuthenticationRepository(path=repo_path)
yield auth_repo


@fixture
def auth_repo_with_delegations(auth_repo_path, keystore_delegations, with_delegations_no_yubikeys_path):
repo_path = str(auth_repo_path)
create_repository(
repo_path,
roles_key_infos=with_delegations_no_yubikeys_path,
keystore=keystore_delegations,
commit=True,
test=True,
)
auth_repo = AuthenticationRepository(path=repo_path)
yield auth_repo


@fixture(scope="module")
def api_repo_path(repo_dir):
path = repo_dir / "api" / "auth"
yield path
shutil.rmtree(path.parent, onerror=on_rm_error)


@fixture
Expand All @@ -59,7 +101,6 @@ def no_yubikeys_path():
def with_delegations_json_input():
return _read_json(WITH_DELEGATIONS_INPUT)


@fixture
def invalid_public_key_json_input():
return _read_json(INVALID_PUBLIC_KEY_INPUT)
Expand Down
20 changes: 4 additions & 16 deletions taf/tests/test_api/test_create_repository.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import shutil
import uuid
from pathlib import Path

from taf.constants import METADATA_DIRECTORY_NAME, TARGETS_DIRECTORY_NAME
from pytest import fixture
from typing import Dict
from taf.api.repository import create_repository
from taf.auth_repo import AuthenticationRepository
Expand All @@ -14,15 +11,6 @@
copy_repositories_json,
)
from taf.updater.updater import validate_repository
from taf.utils import on_rm_error


@fixture
def auth_repo_path(repo_dir):
random_name = str(uuid.uuid4())
path = repo_dir / random_name / "auth"
yield path
shutil.rmtree(path.parent, onerror=on_rm_error)


def _check_repo_initialization_successful(auth_repo: AuthenticationRepository, is_targets_initialized=True):
Expand All @@ -43,12 +31,12 @@ def _check_repo_initialization_successful(auth_repo: AuthenticationRepository, i


def test_create_repository_when_no_delegations(
auth_repo_path: Path, no_yubikeys_path: str, keystore_delegations: str
auth_repo_path: Path, with_delegations_no_yubikeys_path: str, keystore_delegations: str
):
repo_path = str(auth_repo_path)
create_repository(
repo_path,
roles_key_infos=no_yubikeys_path,
roles_key_infos=with_delegations_no_yubikeys_path,
keystore=keystore_delegations,
commit=True,
)
Expand All @@ -58,12 +46,12 @@ def test_create_repository_when_no_delegations(
validate_repository(repo_path)

def test_create_repository_when_no_delegations_with_test_flag(
auth_repo_path: Path, no_yubikeys_path: str, keystore_delegations: str
auth_repo_path: Path, with_delegations_no_yubikeys_path: str, keystore_delegations: str
):
repo_path = str(auth_repo_path)
create_repository(
repo_path,
roles_key_infos=no_yubikeys_path,
roles_key_infos=with_delegations_no_yubikeys_path,
keystore=keystore_delegations,
commit=True,
test=True,
Expand Down
24 changes: 12 additions & 12 deletions taf/tests/test_api/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ def parent_repo_path():
def test_setup_repositories(
child_repo_path: Path,
parent_repo_path: Path,
no_yubikeys_path: str,
api_keystore: str,
with_delegations_no_yubikeys_path: str,
keystore_delegations: str,
):
for path in (child_repo_path, parent_repo_path):
create_repository(
str(path),
roles_key_infos=no_yubikeys_path,
keystore=api_keystore,
roles_key_infos=with_delegations_no_yubikeys_path,
keystore=keystore_delegations,
commit=True,
)


def test_add_dependency_when_on_filesystem_invalid_commit(
parent_repo_path, child_repo_path, api_keystore
parent_repo_path, child_repo_path, keystore_delegations
):
auth_repo = AuthenticationRepository(path=parent_repo_path)
initial_commits_num = len(auth_repo.list_commits())
Expand All @@ -65,7 +65,7 @@ def test_add_dependency_when_on_filesystem_invalid_commit(
add_dependency(
path=str(parent_repo_path),
dependency_name=child_repository.name,
keystore=api_keystore,
keystore=keystore_delegations,
branch_name="main",
out_of_band_commit="66d7f48e972f9fa25196523f469227dfcd85c994",
no_prompt=True,
Expand All @@ -76,7 +76,7 @@ def test_add_dependency_when_on_filesystem_invalid_commit(


def test_add_dependency_when_on_filesystem(
parent_repo_path, child_repo_path, api_keystore
parent_repo_path, child_repo_path, keystore_delegations
):
auth_repo = AuthenticationRepository(path=parent_repo_path)
initial_commits_num = len(auth_repo.list_commits())
Expand All @@ -85,7 +85,7 @@ def test_add_dependency_when_on_filesystem(
add_dependency(
path=str(parent_repo_path),
dependency_name=child_repository.name,
keystore=api_keystore,
keystore=keystore_delegations,
branch_name=None,
out_of_band_commit=None,
no_prompt=True,
Expand All @@ -106,15 +106,15 @@ def test_add_dependency_when_on_filesystem(
}


def test_add_dependency_when_not_on_filesystem(parent_repo_path, api_keystore):
def test_add_dependency_when_not_on_filesystem(parent_repo_path, keystore_delegations):
auth_repo = AuthenticationRepository(path=parent_repo_path)
initial_commits_num = len(auth_repo.list_commits())
branch_name = "main"
out_of_band_commit = "66d7f48e972f9fa25196523f469227dfcd85c994"
add_dependency(
path=str(parent_repo_path),
dependency_name=DEPENDENCY_NAME,
keystore=api_keystore,
keystore=keystore_delegations,
branch_name=branch_name,
out_of_band_commit=out_of_band_commit,
no_prompt=True,
Expand All @@ -135,15 +135,15 @@ def test_add_dependency_when_not_on_filesystem(parent_repo_path, api_keystore):
}


def test_remove_dependency(parent_repo_path, child_repo_path, api_keystore):
def test_remove_dependency(parent_repo_path, child_repo_path, keystore_delegations):
auth_repo = AuthenticationRepository(path=parent_repo_path)
initial_commits_num = len(auth_repo.list_commits())
child_repository = AuthenticationRepository(path=child_repo_path)

remove_dependency(
path=str(parent_repo_path),
dependency_name=child_repository.name,
keystore=api_keystore,
keystore=keystore_delegations,
push=False,
)
commits = auth_repo.list_commits()
Expand Down
Loading
Loading