Skip to content

Add support for "SHA256CTR" filters #29

@chrisdlangton

Description

@chrisdlangton

Add support for the filter type described in mozilla/rust-cascade#33

It seems merging this mozilla/filter-cascade#26 is first a dependency

Essentially this repo bombs out when the CRLiteDB class constructor is used, this is the root cause:
https://github.com/mozilla/filter-cascade/blob/b5469a2d0efaf150e3ce4c04b0d21b4ba2306cf7/filtercascade/__init__.py#L184

And the below is the trace:

                             ╭──────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────╮
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/src/<redacted>/util.py:939 in crlite_revoked                                                                                        │
                             │                                                                                                                                                                    │
                             │    936 │   if last_updated is not None and last_updated > grace_time:                                                                                              │
                             │    937 │   │   logger.info(f"Database was updated at {last_updated}, skipping.")                                                                                   │
                             │    938 │   │   update = False                                                                                                                                      │
                             │ ❱  939 │   crlite_db = CRLiteDB(db_path=db_path)                                                                                                                   │
                             │    940 │   if update:                                                                                                                                              │
                             │    941 │   │   crlite_db.update(                                                                                                                                   │
                             │    942 │   │   │   collection_url=constants.CRLITE_URL,                                                                                                            │
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/.venv/lib/python3.10/site-packages/crlite_query/__init__.py:215 in __init__                                                          │
                             │                                                                                                                                                                    │
                             │   212 │   │   self.coverage = None                                                                                                                                 │
                             │   213 │   │                                                                                                                                                        │
                             │   214 │   │   if self.db_path.is_dir():                                                                                                                            │
                             │ ❱ 215 │   │   │   self.__load()                                                                                                                                    │
                             │   216 │   │   else:                                                                                                                                                │
                             │   217 │   │   │   self.db_path.mkdir()                                                                                                                             │
                             │   218                                                                                                                                                              │
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/.venv/lib/python3.10/site-packages/crlite_query/__init__.py:295 in __load                                                            │
                             │                                                                                                                                                                    │
                             │   292 │   │   if not coverage:                                                                                                                                     │
                             │   293 │   │   │   return                                                                                                                                           │
                             │   294 │   │                                                                                                                                                        │
                             │ ❱ 295 │   │   self.load_filter(filter_path=filters.pop(), coverage_path=coverage.pop())                                                                            │
                             │   296 │   │   self.load_stashes(stashes=self.db_path.glob("*-diff"))                                                                                               │
                             │   297 │                                                                                                                                                            │
                             │   298 │   def cleanup(self):                                                                                                                                       │
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/.venv/lib/python3.10/site-packages/crlite_query/__init__.py:264 in load_filter                                                       │
                             │                                                                                                                                                                    │
                             │   261 │   def load_filter(self, *, filter_path, coverage_path):                                                                                                    │
                             │   262 │   │   self.filter_file = filter_path                                                                                                                       │
                             │   263 │   │   self.coverage_file = coverage_path                                                                                                                   │
                             │ ❱ 264 │   │   self.filtercascade = FilterCascade.from_buf(self.filter_file.read_bytes())                                                                           │
                             │   265 │   │   self.issuer_to_revocations = collections.defaultdict(list)                                                                                           │
                             │   266 │   │   self.stash_files = list()                                                                                                                            │
                             │   267 │   │   self.coverage = {}                                                                                                                                   │
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/.venv/lib/python3.10/site-packages/filtercascade/__init__.py:470 in from_buf                                                         │
                             │                                                                                                                                                                    │
                             │   467 │   │                                                                                                                                                        │
                             │   468 │   │   filters = []                                                                                                                                         │
                             │   469 │   │   while len(buf) > 0:                                                                                                                                  │
                             │ ❱ 470 │   │   │   (buf, f) = Bloomer.from_buf(buf, salt=salt)                                                                                                      │
                             │   471 │   │   │   filters.append(f)                                                                                                                                │
                             │   472 │   │   assert len(buf) == 0, "buffer should be consumed"                                                                                                    │
                             │   473                                                                                                                                                              │
                             │                                                                                                                                                                    │
                             │ /home/gitlab/<redacted>/.venv/lib/python3.10/site-packages/filtercascade/__init__.py:184 in from_buf                                                         │
                             │                                                                                                                                                                    │
                             │   181 │   │   │   size=size,                                                                                                                                       │
                             │   182 │   │   │   nHashFuncs=nHashFuncs,                                                                                                                           │
                             │   183 │   │   │   level=level,                                                                                                                                     │
                             │ ❱ 184 │   │   │   hashAlg=fileformats.HashAlgorithm(hashAlgInt),                                                                                                   │
                             │   185 │   │   │   salt=salt,                                                                                                                                       │
                             │   186 │   │   )                                                                                                                                                    │
                             │   187 │   │   log.debug(                                                                                                                                           │
                             │                                                                                                                                                                    │
                             │ /usr/local/lib/python3.10/enum.py:385 in __call__                                                                                                                  │
                             │                                                                                                                                                                    │
                             │    382 │   │   `type`, if set, will be mixed in as the first base class.                                                                                           │
                             │    383 │   │   """                                                                                                                                                 │
                             │    384 │   │   if names is None:  # simple value lookup                                                                                                            │
                             │ ❱  385 │   │   │   return cls.__new__(cls, value)                                                                                                                  │
                             │    386 │   │   # otherwise, functional API: we're creating a new Enum type                                                                                         │
                             │    387 │   │   return cls._create_(                                                                                                                                │
                             │    388 │   │   │   │   value,                                                                                                                                      │
                             │                                                                                                                                                                    │
                             │ /usr/local/lib/python3.10/enum.py:710 in __new__                                                                                                                   │
                             │                                                                                                                                                                    │
                             │    707 │   │   │   else:                                                                                                                                           │
                             │    708 │   │   │   │   ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))                                                                     │
                             │    709 │   │   │   │   if result is None and exc is None:                                                                                                          │
                             │ ❱  710 │   │   │   │   │   raise ve_exc                                                                                                                            │
                             │    711 │   │   │   │   elif exc is None:                                                                                                                           │
                             │    712 │   │   │   │   │   exc = TypeError(                                                                                                                        │
                             │    713 │   │   │   │   │   │   │   'error in %s._missing_: returned %r instead of None or a                                                                        │
                             │        valid member'                                                                                                                                               │
                             ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                             ValueError: 3 is not a valid HashAlgorithm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions