Metadata-Version: 2.5
Name: trytond_mute_import
Version: 8.0.0.3
Summary: Bootstrap imports of the DNS filtering lists of the mute group
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <issues@tryton-erp.eu>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: adblock,blocklist,dns,dnsmasq,filtering,hosts,import,rpz,tryton
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: trytond-mute<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Bootstrap Imports of the Mute Blocklist
=======================================

The ``mute_import`` module is the way into the blocklist of the mute
group.  No deployment starts from an empty list of blocked names: it
starts from what it already runs - the hosts file of a machine, the list
of a dnsmasq server, the zone of a response policy zone, the export of
the adblock filter that is being replaced - and this module reads those
shapes and files what they hold in the blocklist of the core module,
where a curator finds it in the state an import leaves a name in:
*proposed*, the backlog the curation walks.

Features
--------

- **Import profiles**: ``mute.import.profile`` is one reusable
  description of one import.  It names the shape of the file, the source
  the names are filed under, the category they are filed under, the
  group the patterns of the file land in, the certainty the import
  states, and the choices the shape of a file leaves open - its comment
  character, its encoding, the separator and the header row of a
  separated file, and the shape of a row.
- **Formats**: a reusable parser registry reads a hosts file, a plain
  file of one domain per line, the ``address`` and ``server`` lines of a
  dnsmasq configuration, the network rules of an adblock list
  (``||domain^``), a response policy zone and a separated file.  The
  registry is shared: the module that fetches a list reads it with the
  same parsers, so a name is parsed once and by one implementation.
- **Dry run**: the wizard reads the file first and reports what the run
  would do - how many names would be created, which ones would change
  category, which lines would be dropped as duplicate or invalid -
  without writing anything.  The counters of a preview are the counters
  of the run behind it.
- **Batched and streaming**: a run reads its file twice - once to count
  what it holds, once to file what it counted - in batches of a thousand
  names, so that the memory a bootstrap needs does not follow the length
  of the file and a hosts file of a million lines is imported with the
  memory of a thousand of them.
- **Answerable runs**: ``mute.import.run`` is the journal of an import:
  one execution of one profile over one file, with the counters that
  partition its lines, the report of the lines it left behind, the actor
  and the two stamps that say when it happened.  The facts it writes
  name the run they came from, so the panel of a domain answers with the
  file a name was bootstrapped from.
- **Wildcards**: a name that addresses a subtree - a wildcard, or a name
  a format anchors at a zone - is filed as a line of the group the
  profile names instead of being exploded into the names below it.

Dependencies
------------

- Tryton modules: ``ir``, ``res``, ``mute``.

The module is the leaf of the group that writes into the blocklist.
What is fetched, scheduled and kept fresh belongs to ``mute_ingest``,
which reads the profiles and the parsers from here.

Models
------

- ``mute.import.profile``: one reusable description of an import, with
  its format, its source, its category, its group, its score, its
  deduplication and the choices its shape of file leaves open.
- ``mute.import.run``: one execution of one profile over one file, with
  the counters of its lines, its report, its actor and its stamps.
- ``mute.domain.evidence`` (extended): the fact of an import names the
  run it came from in ``import_run``.

Access
------

The module carries no security group of its own: what it writes is a
write of the blocklist, which is what the curation of the core module
is for.

- **Mute** (``mute.group_mute_viewer``): reads the profiles and the runs
  and changes neither.
- **Mute Curation** (``mute.group_mute_curator``): maintains the
  profiles and runs the import.
- **Mute Administration** (``mute.group_mute_admin``): owns the module
  and removes a profile or a run.

The built-in administrator of the deployment (``res.group_admin``) holds
the module as well, so that a deployment whose administration carries
none of the three groups is never locked out of it.
