docs: align README examples with current Pydantic API#336
Merged
Conversation
The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-ALPINE320-SQLITE-15208661 - https://snyk.io/vuln/SNYK-ALPINE320-OPENSSL-15121256 - https://snyk.io/vuln/SNYK-ALPINE320-OPENSSL-15121256 - https://snyk.io/vuln/SNYK-ALPINE320-BUSYBOX-14102403 - https://snyk.io/vuln/SNYK-ALPINE320-BUSYBOX-14102404
…6fd7 [Snyk] Security upgrade python from alpine3.20 to 3.15-rc-slim-trixie
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.
Summary
controls.isHardened:web.isHardened = Trueanddb.isHardened = Falsechanged toweb.controls.isHardened = True/db.controls.isHardened = False.isHardenedlives onControls, not onElement. BecauseElementhasextra="allow", the old form failed silently — it stored the value as an extra field and leftcontrols.isHardenedat its default.controls.hasAccessControl:my_lambda.hasAccessControl = True→my_lambda.controls.hasAccessControl = True. Same silent-failure mechanism.db.type = DatastoreType.SQL:db.isSql = True→db.type = DatastoreType.SQL. The actual field isisSQL(uppercase), notisSql;isSqlwas silently stored as an extra field. The shippedtm.pyusesDatastoreType.SQL.sourceFiles:web.sourceCodeanddb.sourceCode→web.sourceFiles = [...]/db.sourceFiles = [...].sourceFilesis aList[str]onElement;sourceCodewas silently ignored.DatastoreTypeimport: Added to the sample import list (required bydb.type = DatastoreType.SQL).--describeblock: Replaced stale hand-written output (showing pre-Pydantic fields that no longer exist) with verbatim output of./tm.py --describe Server, which shows the full inherited attribute set includingcontrols,sourceFiles,minTLSVersion, etc.--colormapto synopsis line; changedoptional arguments:tooptions:— Python 3.10+ argparse wording).f.sink.isSQL→f.sink.type == DatastoreType.SQL.isSQLis a valid bool field (still exists, defaultsTrue) but is non-discriminating for all Datastores by default;type == DatastoreType.SQLmatches the idiom in the shippedtm.py.Verified failure mode of old sample
extra="allow"on Pydantic models means every stale attribute set (web.isHardened,db.isSql,web.sourceCode, etc.) was silently stored inmodel_extrarather than raising aValidationError. No error was raised; the intended fields were simply never set.Validation
Hypotheses that turned out wrong
from pytm.pytm import; it already usedfrom pytm importcorrectly. Only the missingDatastoreTypein the import list needed fixing.docs/threats.mdhits from thegrepsweep (target.controls.isHardened,target.controls.hasAccessControl) are already in correct form — no changes needed there.Out-of-scope finding
./tm.py --describe Elementerrors with "No such class to describe: Element" becauseElementis not added to_CLASS_REGISTRYinpytm/pytm.py(only its subclasses are added via_iter_subclasses). Tracked separately.