Commit graph

3,961 commits

Author SHA1 Message Date
Goffi
d9f5f4c8f8 plugin pubsub signing: fix gpg_provider instanciation:
the instance was set at the class level while it is client dependant, resulting in the
instance being overwritten on each client connexion.

rel 381
2022-10-30 01:06:35 +02:00
Goffi
f74e555c23 plugin XEP-0373: minor renaming + set gpg_provider in client:
- `sat` and `self.__sat` have been renamed to `host` and `self.host` for consistency with
other plugins.

- `gpg_provider` is set in client while profile is connecting, so the instance is easily
  accessible to plugins depending on XEP-0373

rel 381
2022-10-30 01:06:32 +02:00
Goffi
8ec64e41fd cli (pubsub): new signature subcommands:
A first `check` command can be used to check signature using the signature JSON data.
More commands should follow to check or sign items.

rel 381
2022-10-28 18:47:17 +02:00
Goffi
c400bc8217 cli (blog/set): new --sign argument:
rel 381
2022-10-28 18:47:17 +02:00
Goffi
cc8b5aa554 plugin XEP-0277: signed flag can now be used in extra to use sign the blog post:
rel 381
2022-10-28 18:47:17 +02:00
Goffi
4f13a79f87 plugin pubsub signing: pubsub items signature implementation:
- this is based on a protoXEP, not yet an official XEP: https://github.com/xsf/xeps/pull/1228
- XEP-0470: `set` attachment handler can now be async

rel 381
2022-10-28 18:47:17 +02:00
Goffi
6255985262 tools (xml_tools): domish_elt_2_et_elt and et_elt_2_domish_elt now handle lxml.etree 2022-10-28 18:47:17 +02:00
Goffi
966d3cc6f4 plugin XEP-0373: typos 2022-10-28 18:47:17 +02:00
Goffi
f7fdde6dce tools (utils): fix parse_xmpp_date timezone:
rel 381
2022-10-28 18:47:17 +02:00
Goffi
14b115358e plugin OXPS: fix triggers return values:
rel 381
2022-10-28 18:47:17 +02:00
Goffi
39181f0bff doc (blog, pubsub): documentation on new e2ee arguments for pubsub, and shared secrets handling:
fix 380
2022-10-15 20:38:33 +02:00
Goffi
3ead662a51 doc: new doc giving an overview on how e2ee is working in Libervia/XMPP:
the doc explain pubsub e2ee for now

rel 380
2022-10-15 20:38:33 +02:00
Goffi
836a621a0b plugin XEP-0277: add encryption flag to MB data:
MB data are individually flagged with the new `encryption` key if they were e2ee, the key
contain encryption metadata (for now, just the algorithm used).

rel 380
2022-10-15 20:38:33 +02:00
Goffi
7b9e785c13 plugin OXPS, XEP-0060: indicate which items were e2ee:
the new `encryption` key is added to `getItems` metadata if items were e2ee, it contains a
map from item ID to encryption metadata.

rel  380
2022-10-15 20:38:33 +02:00
Goffi
48d1f2fc21 cli (pubsub/set, edit): add --encrypt flag:
rel 380
2022-10-15 20:38:33 +02:00
Goffi
2e46d08225 tests (e2e/cli): add test for pubsub encryption:
test encryption and keys sharing.

rel 380
2022-10-15 20:38:33 +02:00
Goffi
9f047d311c plugin XEP-0470: fix autocreate in create_attachments_node:
Due to config check, `create_attachments_node` was failing when the target node was not
already existing. However, this is the case when an item is published and `autocreate` is
expected, thus the node is now created if not already existing and new `autocreate`
argument is set.
2022-10-15 20:38:33 +02:00
Goffi
a7f94cf875 plugin XEP-0374, XEP-0384: handle cases where "to" is not set in <message> for feedback_jid 2022-10-15 20:38:33 +02:00
Goffi
224cffde8d plugin XEP-0384: continue workflow and log error in case of issue in self.__prepare_for_profile:
an exception while preparing profile should not stop the message to be propagated
2022-10-15 20:38:33 +02:00
Goffi
39576b806f plugin XEP-0373: download public keys if they are not found in local storage:
public keys were only obtained from PEP notifications, however this wasn't working if the
entity was not in our roster.

Now if no public key is retrieved from local storage, the public key node is requested,
and an error is raised if nothing is found. This allows the use of OX with entities which
are not in roster.

rel 380
2022-10-15 20:38:33 +02:00
Goffi
dbbdcd04bb plugin pubsub cache: avoid race condition by retrying node request:
When retrieving items, there may be a race condition if a node is not found in cache, then
created before `setPubsubNode` is called. This patch handle this case by retrying in case
of UNIQUE constraint violation.
2022-10-15 20:38:33 +02:00
Goffi
8097e04747 docker: update images to include new OMEMO libraries and OpenPGP packages:
rel 380
2022-10-15 20:38:33 +02:00
Goffi
b9f5c6b844 cli (pubsub): new secret subcommands:
commands are added to `share`, `revoke` and `rotate` secrets of an encrypted pubsub node.

rel 380
2022-10-15 20:38:30 +02:00
Goffi
f99544e881 cli (pubsub/get): add --no-decrypt flag to disable automatic decryption:
rel 380
2022-10-15 20:37:00 +02:00
Goffi
ba9a4ef31b cli (blog): add --encrypt argument on publication commands to e2ee a blog post:
rel 380
2022-10-15 20:37:00 +02:00
Goffi
7f0e230af4 tools (common/async_utils): set default maxsize to 50 in async_lru 2022-10-15 20:37:00 +02:00
Goffi
b91bc6fa2d plugin XEP-0374: exluce openpgp element from XEP-0373 on send trigger:
the `openpgp` element is excluded to avoid useless double encryption.

rel 380
2022-10-15 20:37:00 +02:00
Goffi
da9725479b plugin OXPS: OpenPGP for XMPP Pubsub implementation:
OpenPGP for XMPP Pubsub (https://xmpp.org/extensions/inbox/pubsub-encryption.html,
currently a protoXEP) is implemented and activated when `encrypted` is set to `True` in
pubsub's `extra` data.

On item retrieval, the decryption is transparent if the key is known, except if the
`decrypt` key in `extra` is set to `False` (notably useful when one wants to checks that
data is well encrypted).

Methods and corresponding bridge methods have been implemented to manage shared secrets
(to share, revoke or rotate the secrets).

plugin XEP-0060's `XEP-0060_publish` trigger point as been move before actual publish so
item can be modified (here e2ee) by the triggers. A new `XEP-0060_items` trigger point has
also been added.

`encrypted` flag can be used with plugin XEP-0277's microblog data

rel 380
2022-10-15 20:36:53 +02:00
Syndace
6d1e942f43 plugin XEP-0373 and XEP-0374: Implementation of OX and OXIM:
GPGME is used as the GPG provider.

rel 374
2022-09-20 16:22:18 +02:00
Goffi
f160577a65 core: fix and renamed getLocalPath -> get_local_path:
- renaming is following global methods renaming to use snake_case
- for reasons lost in the mists of time, a `profile` argument was used while checking if
  `client` is set is enough, and `client.profile` was escaped but actually not used in the
  path.
2022-10-10 15:23:59 +02:00
Goffi
0cd676115c plugins (forums, lists, import, XEP-0277): remove invalid max_items values 2022-10-07 22:22:13 +02:00
Goffi
8414475285 plugin lists: fix double deserialisation 2022-10-06 17:50:54 +02:00
Syndace
8daec13fbb plugin XEP-0384: proper handling of exceptions in prepare_for_profile 2022-10-06 17:25:37 +02:00
Goffi
3896e091fd plugin lists: fix deserialisation on listSet 2022-10-06 17:22:21 +02:00
Goffi
8f204aba8f plugin XEP-0448: Encryption for stateless file sharing implementation:
- registered as a source handle for XEP-0447
- can be used as an attachment
- registered as a download handler
- only usable when OMEMO2 is active, as we been SCE to hide encryption data

fix 379
2022-10-06 16:02:05 +02:00
Goffi
cb44cb1991 cli (file/get): handle full JSON attachment following change in backend:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
d557e06fbd cli (message/send): new --attach argument to send an attachment:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
0f20af88f1 tools (stream): log error when a SatFile is closed:
error where only sent on `ProgressError`, but it is necessary to log the error as it may
happen before any progression is started.
2022-10-06 16:02:05 +02:00
Goffi
aea64e7b87 plugin XEP-0334: avoid adding twice the same hint:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
a8fc70fca6 plugin XEP-0447: handle attachment and download:
- plugin XEP-0447 can now be used in message attachments and to retrieve an attachment
- plugin attach: `attachment` being processed is added to `extra` so the handler can inspect it
- plugin attach: `size` is added to attachment
- plugin download: a whole attachment dict is now used in `download` and
  `file_download`/`file_download_complete`. `download_uri` can be used as a shortcut when
  just a URI is used. In addition to URI scheme handler, whole attachment handlers can now
  be registered with `register_download_handler`
- plugin XEP-0363: `file_http_upload` `XEP-0363_upload_size` triggers have been renamed to
  `XEP-0363_upload_pre_slot` and is now using a dict with arguments, allowing for the size
  but also the filename to be modified, which is necessary for encryption (filename may
  be hidden from URL this way).
- plugin XEP-0446: fix wrong element name
- plugin XEP-0447: source handler can now be registered (`url-data` is registered by
  default)
- plugin XEP-0447: source parsing has been put in a separated `parse_sources_elt` method,
  as it may be useful to do it independently (notably with XEP-0448)
- plugin XEP-0447: parse received message and complete attachments when suitable
- plugin XEP-0447: can now be used with message attachments
- plugin XEP-0447: can now be used with attachments download
- renamed `options` arguments to `extra` for consistency
- some style change (progressive move from legacy camelCase to PEP8 snake_case)
- some typing

rel 379
2022-10-06 16:02:05 +02:00
Goffi
11f16fc2d0 core (memory/encryption): helper method to get currently utilised e2ee algorithm's namespace:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
5b40d71f40 core (xmpp): check presence of some keys in attachment before using them:
in `completeAttachments` `url` was used to complete a missing name, but it may be missing
with some attachments, thus its presence is now checked.
2022-10-06 16:02:05 +02:00
Goffi
4b498cffe0 plugin XEP-0384: temporarily disable <iq> stanza encryption:
`<iq>` stanza encryption is implemented, but the `send` trigger doesn't catch all `iq`
stanza send (which are often sent directly with `xmlstream.send`), and some stanza
encryption may cause trouble (happened with disco on a bare jid).

It is temporarily disabled but should be reactivated before `0.9` release.
2022-10-06 16:02:05 +02:00
Goffi
7d415c705d plugin XEP-0384: expose OLDMEMO and TWOMEMO namespaces:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
a68564e68f plugin XEP-0420: fix exception on missing from or to:
fix exception raised on missing `from` or `to` attribute when the policy doesn't require
them.

Patch made by Syndace <me@syndace.dev>
2022-10-06 16:02:00 +02:00
Goffi
1fd553db40 plugin XEP-0300: type hints 2022-10-06 15:19:08 +02:00
Goffi
131096ed53 plugin events: fix bad import 2022-10-06 14:59:49 +02:00
Goffi
8444115262 plugin XEP-0384, xml_tools: avoid getItems timeout + fix empty node crash + parsing:
- use `max_items` in `getItems` calls for bundles, as otherwise some pubsub service may
  return full nodes, which may be huge is `max_items=1` is not set on the node, possibly
  resulting in timeouts.

- the plugin was crashing when TWOMEMO devices list node has no items at all. This is not
  the case anymore.

- a naive parsing method has been implemented in `xml_tools` to replace the
  serialisation/deserialisation method. This should be more efficient and will avoid
  annoying `ns0:` prefixes in XML logs.
2022-09-24 16:37:46 +02:00
Goffi
ee5784811e core (xmpp): make send a blocking method, fix sendMessageData calls:
original `send` method is blocking, and it is used as such by Wokkel and thus can't be
changed to an async method easily. However, an Async method is necessary to have an async
trigger at the very end of the send workflow for end-to-end encryption. To workaround
that, `send` is an async method which call `a_send`, an async method which actually does
the sending. This way legacy method can still call `send` while `a_send` can be await
otherwise.

Fix calls to `sendMessageData`: the method now being an `async` one, `ensureDeferred` had
to be used in some calls.
2022-09-24 16:31:39 +02:00
Goffi
d9a04a36ca core (main): OrderedDict is not necesasry here anymore, as dict are now ordered 2022-09-24 16:08:26 +02:00