[tor-bugs] #31241 [Core Tor/Tor]: Refactor config validation

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Oct 25 00:33:50 UTC 2019


#31241: Refactor config validation
-----------------------------------------+---------------------------------
 Reporter:  nickm                        |          Owner:  nickm
     Type:  task                         |         Status:  needs_revision
 Priority:  Medium                       |      Milestone:  Tor:
                                         |  0.4.3.x-final
Component:  Core Tor/Tor                 |        Version:
 Severity:  Normal                       |     Resolution:
 Keywords:  network-team-roadmap-august  |  Actual Points:
Parent ID:  #29211                       |         Points:  1.5
 Reviewer:                               |        Sponsor:  Sponsor31-can
-----------------------------------------+---------------------------------

Comment (by nickm):

 Here is the design change for this branch; please ignore description
 earlier on the ticket.

 Previously, options_validate() was a function that we called in several
 places, as was options_transition_allowed().

 With this change, the above functions are now callbacks associated with a
 configuration format.  Each format or subformat can have its own set of
 validation callbacks.  Calling config_validate() on a top-level
 configuration object invokes all of the callbacks as appropriate.

 There are 5 kinds of validation/normalization callbacks:
   * pre-normalization: allowed to change the object, before validation.
   * validation: inspects the object for correctness.
   * "legacy" validation: provides backward compatibility for functions
 like options_validate_cb that mix normalization, validation, and
 transition checking.
   * transition checking: compares the object to its old value ot see if
 the transition is permissible.
   * post-normalization: allowed to change the object, after validation.

 I've uploaded a new `ticket31241_v3` branch with PR at
 https://github.com/torproject/tor/pull/1473 .  I'm checking that it passes
 with `make test-stem`.  I think it can be needs_review once CI passes.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31241#comment:11>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list