Validate Before Bake#3148
Merged
Merged
Conversation
Previously bake() coerced config and called validate() itself, and from_dict validated the raw dict up front -- so coercion (a 'bake step') effectively ran before bake(), and the programmatic/bbot.yml entry points were never validated. Invert it: - Preset.validate() is now the precondition: coerces custom_config toward its declared types AND validates it, sets self._validated, returns self. - bake() ENFORCES it: raises if the preset isn't validated (it no longer coerces or validates itself). - merge() / mutations reset _validated, so a changed preset must be revalidated. - Scanner.__init__, the CLI, and from_dict call validate() before baking. Side effects: - config is now validated on every entry point (programmatic Preset(config=)/ Scanner(config=), bbot.yml, presets, CLI), closing the validation-asymmetry gap. - surfaced a missing internal-module toggle: 'unarchive' was absent from BBOTConfig (so 'bbot -c unarchive=false' was rejected); added it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Direct preset.bake() -> preset.validate().bake() (validate() returns self);
bake() now requires a validated preset.
- test_config: the programmatic path is now strictly validated, so the old
sentinel keys ('plumbus', module 'test_option') are correctly rejected as
typos; rewritten to verify config propagation with real keys
(status_frequency, ipneighbor.num_bits, module_timeout).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ion was pushed upstream.
from_dict reads a preset's top-level keys with .get(), so a typo'd or
unknown top-level key (e.g. `modlues:`) was silently dropped instead of
surfaced. And per the validate-before-bake contract, validate() should be
the single comprehensive gate for everything a preset declares.
- validate.py: add prevalidate_preset(), a thorough top-level KEY check
that reports every unknown/typo'd key with a closest-match hint. Keys
only -- it does not coerce or validate config values.
- preset.py from_dict(): auto-run prevalidate_preset() up front, and stop
calling validate() itself -- it now returns an explicitly unvalidated
preset. Coercion + full validation remain the caller's step before
bake() (Scanner and the CLI already do this).
- preset.py validate(): also validate the declared scan/output module
names (reusing _is_valid_module), so an unknown module name fails here
instead of only at bake().
- tests: top-level typo -> from_dict raises; config-value typo and unknown
module name -> validate() raises.
bake() is unchanged and still trusts an already-validated preset.
- Add 'recursive' to scan name adjectives (how was this missing?) - Both easter eggs now require exact name match (recursive_thetechromancer, golden_gus) instead of endswith - Skip easter eggs entirely when NO_COLOR is set
Contributor
🚀 Performance Benchmark Report
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## preset-validation #3148 +/- ##
==================================================
+ Coverage 90% 90% +1%
==================================================
Files 451 447 -4
Lines 39806 40444 +638
==================================================
+ Hits 35675 36285 +610
- Misses 4131 4159 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.