Giter Site home page Giter Site logo

Comments (4)

lukpueh avatar lukpueh commented on July 28, 2024 1

Just discovered another documented, albeit (to me) unexpected behavior:

  • Unrecognized keys in an object schema are allowed
>>> from securesystemslib import schema
>>> FOO_SCHEMA = schema.Object("FOO_SCHEMA", foo=schema.AnyString())
>>> FOO_SCHEMA.matches({"foo": "ABC", "bar": "interesting..."}) # Would expect to return False due to "bar"
True

from securesystemslib.

lukpueh avatar lukpueh commented on July 28, 2024
  • The error messages from checking schemas with the check_match method are often not helpful, because they usually don't show the value of the checked variable or lack context.

Similar observations were made in theupdateframework/python-tuf#243

from securesystemslib.

lukpueh avatar lukpueh commented on July 28, 2024

The many check_match-calls also have an impact on performance. E.g. when delegating 16K hashed bins for warehouse, >5% of the execution time was just check_match-ing.

from securesystemslib.

lukpueh avatar lukpueh commented on July 28, 2024

While testing a format errors on different Python versions, I just discovered another issue with the Object(Schema):

Given that in Python <3.7 the dict key order is not guaranteed, iterating over the "required" fields ...

self._required = list(required.items())

... of a schema object in check_match may yield different error messages, if multiple required fields are missing.

for key, schema in self._required:
# Check if 'object' has all the required dict keys. If not one of the
# required keys, check if it is an Optional().
try:
item = object[key]
except KeyError:
# If not an Optional schema, raise an exception.
if not isinstance(schema, Optional):
message = 'Missing key ' + repr(key) + ' in ' + repr(self._object_name)

from securesystemslib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.