theupdateframework / theupdateframework/python-tuf

ngclient: Make updater.config immutable

Open
#2,471 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
304
Avg merge
1d 2h
Merged PRs (30d)
17

Description

This comes from #2363 / #2359 : we should make the config somehow immutable once it's been used by Updater. This should be a difficult mistake to make:

updater = Updater(...) 
updater.refresh()
updater.config.offline = True

(the issue is refresh() already used config.offline: the value can't be changed during lifetime of Updater. Likely this makes sense for all config)

I originally suggested reading the updater.config.offline value only once during initialization, but that still makes writing the above code possible. Would be better if it failed linting.

I suppose two possible actions:

  • Updater.config becomes a read only property (or not public at all)
  • Could make UpdaterConfig frozen=True as well

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Updater.config and UpdaterConfig through refresh(), using the issue's example to identify when configuration is read. Compare the read-only property and frozen-config options, then verify that configuration cannot be changed after Updater uses it and that the existing behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.