Commit Graph
179 Commits
Author SHA1 Message Date
Lauri Ojansivu a0f3681961 List Sync's rule replay skips an action into a list that refuses the actor's role.
Decided by the maintainer on 2026-11-18 (TODO.md). The ordinary rules
engine already skips such an action; the journaled List Sync replay
(server/notifications/storedRulePlans.js) still wrote with board write
access only.

Each list-writing runner - move, move to another board, move all,
move all to another board, copy, link, create card, sort list and
archive - now decides before it saves its command: a list refusing the
actor's role (#4527) records a durable skip (listSyncRuleListSkips) and
the runner returns the invocation id, which executeRulePlan confirms
like any finished action, so the rest of the plan runs. A replay reads
the saved skip first, so it never re-decides; a saved command is never
skipped and a skipped action never gets a command. The skip shows in
Admin Panel / Problems as ListLockRule (detected, low).

tests/listSyncRuleListSkip.test.cjs runs the skipper and pins every
runner's order.

Thanks to xet7 !
2026-11-18 23:46:00 +02:00
Lauri Ojansivu bf7520f972 Activity notification failures say which check failed.
"Activity notification delivery incomplete; pending intent retained" was
logged for nearly every activity - 1,080 times in one test-server run,
and on a production server one line after another - and never said why:
the .catch() dropped the error. It and the recovery and both cleanup
lines now carry the failure's code (activity-notification-intent-invalid,
sync-busy, ...). Only a code is logged as it is; any other error gives its
name and numeric or short code, never its message, which may carry an
address or a card title. tests/notificationFailureReason.test.cjs pins
that, and fails when a notification failure line in server/ drops its
reason again.

Thanks to xet7 !
2026-10-25 03:18:15 +03:00
Lauri Ojansivu 696b5b073f Comments, reactions, text notes and attachments follow a card moved to another board.
The board publication finds a board's comments, comment reactions, text
notes, checklists, checklist items and attachments by the board id each
row carries (#6480), but a card that changed board re-homed only its
checklists and checklist items. Its comments stayed published to the
board it left, and came back when the card was moved back. Attachments
followed only when Card.move() ran on the server, and the REST card
move, a hook-less write, re-homed nothing at all.

One list (models/lib/cardChildrenBoard.js) now names every such
collection, and one helper (server/lib/cardChildrenBoardSync.js)
re-homes them from the Cards.after.update hook, the REST move and the
durable rule move. The startup schema upgrade step card-children-boardid
moves rows that a move already left behind to their card's board.

Thanks to fabiosalles and xet7 !

Fixes #6793.
2026-10-21 15:30:41 +03:00
Lauri Ojansivu b01c233269 Moving a card with an outgoing webhook no longer counts as HookBleed or disables the mover's account.
The activity hook delivered webhooks through Meteor.call('outgoingWebhooks'),
and that method trusted a call without this.connection as the server's own.
Meteor gives a server-side Meteor.call the userId AND connection of the method
it runs in (ddp-server applyAsync), and a card moved from a browser runs in
that browser's method. So the server's own act-moveCard delivery arrived as a
client forging one: it was recorded as ssrf.webhook-forge (high) with the
mover's userId, and blockOnSecurityEvent set loginDisabled.

- deliverActivityWebhook() in server/notifications/outgoing.js is the server's
  delivery: a function, not a method, so no client reaches it and no inherited
  context changes it. It reads the integration again (enabled) and names the
  activity's actor. server/models/activities.js calls it through safeDeliver.
- The outgoingWebhooks method treats every call as a client's: only the
  card-opened notification, rebuilt from the card, as before for clients.
- Server deliveries no longer need the actor to be a member of the hook's
  board, which also skipped a global webhook ('_global' is no board) and an
  activity with no method behind it (REST, timers).
- securityLog.record() now passes the catalog key and blocksAccount to the
  block decision. The stored row carries neither, so every 'high' blocked row
  disabled whoever it named: a hook refused for its own internal address
  disabled the mover too, and ssrf.redirect/ssrf.attachment's
  blocksAccount: false never applied. ssrf.webhook is now blocksAccount:
  false - the person whose move sent it did not write the hook's URL.

tests/hookBleedServerDelivery.test.cjs: the move delivered with nothing
logged, in an inherited context too; a forged call still refused, logged and
blocking; the card-opened notification; failing and internal hooks blocking
nobody, through record() itself; and a whole-tree scan that no server code
calls a this.connection-gated method from inside a client's method without
clearing the invocation. tests/playwright/specs/hook-bleed.e2e.js moves a
card through the Move dialog with a webhook enabled.

Thanks to do4me and xet7 !

Fixes #6782.
2026-10-18 14:28:19 +03:00
Lauri Ojansivu 5b2ed17e6b Board role permissions apply to every board view and every path to a card.
AssignedBleed follow-up, GHSA-r4gm-mjj9-g3x8. An assigned-only member
(isNormalAssignedOnly, isCommentAssignedOnly, isReadAssignedOnly, and custom
roles through those flags) sees only the cards assigned to them. The Board
Email View checked board.isVisibleBy() alone, so it published the title,
description and email metadata of every card in a list or label, counted
them, and searched them. It now merges assignedOnlyCardScope into its folder
and search selector for the page and the count, and a reply on another card
is refused.

An audit of every path that returns or changes a card found the same shape -
"a member of the board, so every card of it" - elsewhere, all fixed here:

- reads: the board publication's ancestor cards, linked source cards with
  their subtasks and dependency targets, and comment reactions; All Boards
  tile counts; a board's activities from linked boards; the Chat view and
  the All Boards feed, which also let card MEMBERS through (assignees is the
  rule); My Attachments' card; GET /api/user/cards; position history of a
  card; the cross-board subtask picker; Scrum rollover counts; and the
  notification publications, which kept sending the full documents of cards
  named in old notifications - also to members removed from the board;
- writes on a card the member cannot see: the canonical
  canEditCardOrLinkedCard / editableCardIds (every Cards.allow update,
  checklists, items, attachments, text notes, custom fields, the shared
  description, card methods) now ask the card - the role's `write` is a
  board answer, and the card is read when a caller passed it without
  assignees; DDP and REST comments, button rules on a card, checklist moves,
  issue state, watching, the card-opened webhook, moveBoardObjects,
  moveSwimlane and attachment moves;
- REST writes: checkBoardWriteAccess refuses assigned-only members, as
  checkBoardAccess already does for reads - those routes act on any card,
  list or swimlane by id. The GHSA-f396 canary still fires for a role
  without the write capability.

A refusal no view would produce is recorded under AssignedBleed in Admin
Panel -> Problems (authz.assigned, medium: never disables); opening a view,
searching and REST calls are narrowed or refused without a record.

tests/boardRoleViews.test.cjs runs the Email View selector, pins every path
above, and fails when any server file that serves card data has no role
rule and no stated exemption; the "assignee or card member" rule is
rejected anywhere in server/ and models/. server/lib/tests/editableCardIds
adds an assigned-only case for both edit checks (meteor test; not run here).
Seven guards that pinned the old lines now pin the new ones.

Thanks to crypto-nidh, binary-lover and xet7 !
2026-10-16 13:03:34 +03:00
Lauri Ojansivu 349d6dc5e6 Webhooks: also send a Mattermost direct message to the card's people.
A saved outgoing webhook gets "Also send a Mattermost direct message to
the card's members and assignees". With it ticked, every message about a
card also goes to each of its members and assignees as the webhook's own
message with channel "@username" - Mattermost's direct-message channel -
so they hear about their cards without following the channel. The person
who made the change is not messaged, nobody twice, a name that is not a
valid Mattermost user name is skipped, and a card stops at 50. A board
webhook does this only for its own board's cards. The direct messages go
at once, best effort, through webhookFetch; the channel message keeps its
grouping and schedule. Two-way webhooks are left as they are.

models/lib/mattermostDirectMessages.js picks the people and builds the
messages; tests/mattermostDirectMessages.test.cjs covers them, the actor,
bad names, the bound, and that it is off unless ticked and sent through
the SSRF guard. docs/Features/Webhooks/Chat/Mattermost.md says what
Mattermost needs. The two new strings are English placeholders until the
next translation pass.

Thanks to xet7 !

Fixes #1297.
2026-10-14 14:54:38 +03:00
Lauri Ojansivu d873af70e8 ntfy as a notification channel, per member.
Member Settings / Notification Settings gets "ntfy phone notifications":
a member pastes their ntfy topic's address, and an access token if the
topic needs one, and each notification they get in WeKan - the same
recipients, watching and muted activity kinds - also arrives in the ntfy
app, with the board and card as the title, what happened as the message
and a tap opening the card.

It uses ntfy's JSON publishing, so a title in any language needs no
header encoding, and goes through webhookFetch: the SSRF guard, Internal
destinations for a self-hosted ntfy, the Powerbox on Sandstorm. An
admin-only custom field value still reaches only board admins. One read
per activity finds the recipients who turned it on; sending is deferred
and best effort, so ntfy being down never touches e-mail or the tray.
The address and token are a top-level user field, saved and read only
through the member's own methods, not client-writable and never
published.

models/lib/ntfy.js parses topic addresses and builds the request;
tests/ntfy.test.cjs covers the request, bad addresses, tokens with header
injection, javascript: links, off, and that the setting is unpublished
and sent only through webhookFetch. Documented in
docs/Features/Notifications/ntfy.md. The new strings are English
placeholders until the next translation pass.

Thanks to xet7 !

Fixes #5148.
2026-10-14 14:37:00 +03:00
Lauri Ojansivu e0317a9ff3 Drain the activity notification recovery list; index synced-cron's lookup.
#6768: the recovery scan retried every pending activity notification each
round, and one whose delivery fails for good - its activity deleted or
changed since, a recipient who lost access, a plan with nothing or too much
to send - failed the same way every round, forever, so the list only grew.
Such an error is terminal now: after a ten-minute grace (an activity being
written is never touched) the scan cancels that notification through the
same cancellation an administrator uses, as the system, which compacts it
to a cancelled receipt. A pending notification older than
ACTIVITY_NOTIFICATION_MAX_AGE_DAYS (7) is cancelled as expired instead of
being delivered a week late. Network and other transient failures are still
retried. Admin Panel -> Problems gets "Retry all" and "Cancel older..." for
the whole list at once, site administrators only.

#6769: before each run synced-cron asks whether a job of that name is still
running - { name, finishedAt: { $exists: false } } - every minute for every
job on every instance, and only { intendedAt, name } and the TTL on
startedAt were indexed, so it scanned the job history. { name, finishedAt }
is created at startup with WeKan's ensureIndex.

The new strings are translated in every locale.

Thanks to Raymond-Voogt and xet7 !

Fixes #6768,
Fixes #6769.
2026-10-14 14:00:21 +03:00
Lauri Ojansivu 2cc0b59a51 On Sandstorm, send webhooks through the Powerbox, and accept the REST API with a grain API key.
A grain has no network but the bridge proxy, so an outgoing webhook now
leaves only through an API a board admin approved in the Powerbox for that
webhook's address: each saved webhook offers "Allow this grain to reach this
address". The grant belongs to the destination, not to a person, is found
by the URL being sent to, and is approved as the address's parent path so
the bridge delivers to the exact address. Every sender - immediate, grouped
and stored - goes through webhookFetch, which off Sandstorm, or for an
address no grant covers, is exactly the SSRF-guarded fetchSafe.

The REST API called with a Sandstorm API key acts as the key's user: in a
grain the bridge sets X-Sandstorm-User-Id itself. Only in a grain, only
after a WeKan token, only for an existing enabled account, and a key without
participate reads only.

New strings translated in all languages.

Thanks to xet7 !
2026-10-14 09:49:42 +03:00
Lauri Ojansivu ab785acd1e Choose what notifications contain, and group and schedule them, for e-mail, the tray and webhooks.
One delivery model (models/lib/notificationDelivery.js) for every channel -
e-mail, the notification tray and outgoing webhooks - set in the
Notifications popup at Admin Panel, board and Member Settings scope, and in
each one-way webhook's form:

- Content. Webhooks: the text on or off, and which property groups are sent
  (standard, ids, names, links, actor, people, details), with checklist,
  list, swimlane and board names, before/after values, the card description
  and links added as opt-in groups. E-mail and tray: the classic sentence or
  a clear layout - the board as a link first, the actor and card in bold -
  and which parts are shown.
- Grouping: one message per event, per card, per board, or all together.
- Scheduling: immediately, every 5 minutes to 24 hours, or once a day, with
  optional quiet hours, in the time zone of whoever set it.

The most specific explicit setting wins: member, then board, then Admin
Panel for e-mail and tray; the webhook, then its board, then Admin Panel for
webhooks. A member can only leave their own name out of outgoing webhooks.
The built-in defaults keep today's behaviour. Grouped and scheduled webhooks
and e-mail go through durable queues that survive restarts; queued webhooks
use the SSRF guard and log a blocked address in Admin Panel - Problems.
Values of admin-only custom fields now reach only board admins in e-mail and
tray, and never a webhook.

The new strings are in English in every locale, pending Transifex.

Thanks to HaKePlan, Meeques and xet7 !

Fixes #3695,
Fixes #5171.
2026-10-10 15:28:26 +03:00
Lauri Ojansivu d1de4a1fe6 Stored Sync rules bring a card's labels to another board as Card.copy and Card.move do.
Since #1759 a card copied or moved to another board brings its labels: a
label that board lacks is created there when the actor is its admin. The
stored (durable) rule copyCard, move to another board and move-all onto
another board still matched by name only and dropped the rest, so the
durable copy or move was no longer the ordinary one - the parity three
server tests check - and the card lost a label a direct copy would keep.

The durable plans now use the same planCrossBoardLabels with the rule's
actor. The labels to create are saved in the command (copy) or move
(single move, and each move-all unit), so a replay creates nothing twice:
each is pushed only when no label with its id is on that board yet, before
the card that names it is written. In a move-all, a label created for one
card is that board's label for the next, as when Card.move moves them one
by one. Commands saved before this, without the labels, still validate.

The server tests now expect the created label, once across a replay, and
the ordinary copy or move finding it; the card-move test gains the negative
of a mover who is not the new board's admin, where the label is dropped and
its activity removed. The command tests cover the new field, its validation
and an older command without it.

Thanks to xet7 !
2026-10-10 11:44:19 +03:00
Lauri Ojansivu 727ceedd01 Let a card be in more than one release.
A card had exactly one release, scrum.releaseId. Jira import kept only the
first fix version of an issue and reported the rest as lost, Jira export
wrote no fix versions at all, and the card UI could not show or pick more
than one release.

A card's releases are now a list, scrum.releaseIds, with releaseId kept as
its first entry so older servers, importers and REST readers still see one.
Existing cards are not migrated: every reader goes through cardReleaseIds(),
which reads the list and the old single field the same way, so cards saved
either way work side by side, and a card moves to the new form on its next
Scrum save. A save with releaseIds replaces the list; a save with only
releaseId, from an older client, replaces the first release and keeps the
others, and null clears them. Every release must belong to the board,
checked in one query; duplicates collapse and a releaseId that contradicts
the list is refused.

Copies and moves to another board link each release by name. The native
transfer writes one release exactly as before and adds releaseIds only for
cards with several, and remaps each of them on import. Jira import maps every
fix version and Jira export writes them all as fixVersions. Board View /
Sprints shows each release's cards and how many are done, counting a card in
each of its releases. Scrum History checks and guards every release, and
rule e-mails name them all. The Product Backlog and card details use a
multiple select.

tests/scrumMultipleReleases.test.cjs covers the rules and fails if any code
reads the single field directly; a Playwright spec drives the UI. New text is
in English, pending Transifex.

Thanks to xet7 !
2026-10-08 11:51:44 +03:00
Lauri Ojansivu 5f413c12eb Send names, the card link and the assigned person in outgoing webhooks.
An outgoing webhook carried mostly ids: the card title and the acting user,
but not the list, board or swimlane names, not the link, and nothing about
the person a join or an assignment was about. For an assignment the payload
said who assigned, but not who was assigned, which is what a chat
integration needs in order to tell that person.

The default payload now also has list, board, swimlane and url, member and
memberUsername for joining or leaving a card, and assigneeId, assignee and
assigneeUsername for joinAssignee/unjoinAssignee, which no param carried
before. The fields are additive, and WEBHOOKS_ATTRIBUTES still replaces the
default list wholesale. docs/Features/Webhooks/Webhook-data.md shows an
assignment payload.

Thanks to chrisi51 and xet7 !

Fixes #3297.
2026-10-08 11:44:40 +03:00
Lauri Ojansivu b7084fdc06 A rule's email follows the card to the board the rule's own move took it to.
A rule that moved a card to another board and then sent an email sent nothing:
the email source check refused a card that had left the activity's board, in
both engines. As decided, the email now reads the card on the destination
board, but only when this run of the rule made the move, the destination
opted into Sync effects, and the card is still there. The ordinary engine
remembers its run's own move (RulesHelper.emailActivity), durable Sync proves
it from a saved move of the same plan (ruleEmailActivity, ruleCardNow) and
rechecks it before sending. The stored source binding (version 6) records the
board the card left. Any other card off the board is refused as before, and
an email may now follow a move to another board in a durable plan.

Tests: binding positive and negative cases, a shape guard that nothing else
can claim a followed move, and a server test of both engines that sends once
from the destination and refuses a card nobody's run moved, a move to another
board, and a destination that opted out.

Thanks to xet7 !
2026-10-03 14:26:15 +03:00
Lauri Ojansivu 5fad29a254 Copy only the subtasks the copier may copy (AssignedBleed copy sibling).
A copy of a card took every subtask of it. An assigned-only member who
copied a card assigned to them got copies of its subtasks assigned to
others, and any member got copies of its subtasks on boards they cannot
read - a parent may have subtasks on another board (#3626). Card.copy and
the durable rule copy now carry only the subtasks the copier could read and
copy themselves (models/lib/boardCardScope.js copyableSubtasks); a copy
with no acting user, made inside the server, keeps them all as before.

Not recorded in Admin Panel / Problems: copying a card with subtasks is
ordinary use, and the copy simply leaves out what the copier may not have.

Tests: tests/copySubtaskScope.test.cjs (the decision, and a scan that every
place copying subtasks filters them) and a server test through copyCard,
which without the fix gave an assigned-only member copies of another
member's subtask and of one on a private board.

Thanks to xet7 !
2026-10-03 10:05:47 +03:00
Lauri Ojansivu 64489c5a2a Let a rule's move-all onto another board follow a move to another board, durably.
The ordinary engine takes a move-all's list from the board the rule's card
is on now (RulesHelper.ruleBoards); the durable move-all onto another board
took it from the plan's board, so it could not follow a move to another
board. It now takes the list from where the card is, saves that board as
`fromBoard` - only when it is not the plan's, so saved commands still
validate - and each unit leaves from it. A move-all onto the board the card
is already on is refused. Only an email now keeps such a plan on direct Sync.

A server test moves the card from A to B, then every card of B's list to C,
durably and with the ordinary engine, with the same result.

Thanks to xet7 !
2026-10-03 09:59:43 +03:00
Lauri Ojansivu b07a8a421b Let a rule move its card on to a third board after a move to another, durably.
A rule whose card had been moved to another board could not move it on to
yet another one through durable Sync: the cross-board move command took
the card from the plan's board only. It now takes it from where it is -
the plan's board, or where an earlier move of the same plan took it
(ruleCardNow) - and saves that board as `fromBoard`, written only when it
is not the plan's, so every command saved before still validates. The
board the card leaves, its dependencies and the deferred hook records
follow the saved move's own before-place. A move onto the board the card
is already on is refused.

Such a further move may now follow a move to another board; every board
the chain reaches must have opted in, as the first. A move-all onto
another board still may not follow, since it moves a list of the rule's
board. A server test runs A to B to C and a later colour, durably and with
the ordinary engine on a twin card, and refuses the chain while C has not
opted in.

Thanks to xet7 !
2026-10-03 09:56:00 +03:00
Lauri Ojansivu acb2c0786a Resolve a rule's later move, sort, move-all and archive on the board its card went to.
As decided on 2026-10-03, after a rule moved its card to another board, a
later action that names the rule's own board works where the card is now,
in the ordinary engine and in durable Sync alike:

- RulesHelper.ruleBoards gives the board the card is on and the board an
  action works on. A move to the top or bottom, a sort and a move-all
  resolve their list and swimlane names there; the write-access check
  covers that board. Before this, a move to "*" after a move to another
  board took the card's new list and swimlane but the old board, leaving
  the card split across two boards.
- The durable move, sort, move-all and archive commands find the card
  through ruleCardNow and save the board it is on as `onBoard`, written
  only when it is not the plan's, so every command saved before still
  validates; the archive's cascade takes the children on that board.
- These actions may now follow a move to another board, so such a plan
  stays durable. An email still may not, nor a second move to yet another
  board.

The archive reservation and follower guards follow the decision; the
cross-board move test now expects sorting and archiving to follow and
refuses an email instead, and a new server test runs the whole chain
durably and with the ordinary engine on a twin card, with the same result.

Thanks to xet7 !
2026-10-03 09:44:45 +03:00
Lauri Ojansivu 12e98cdbfe Let a rule's later actions follow its card to another board, so a cross-board move need not be last.
The ordinary rule engine reads the card by id for every action, so the
actions after a move to another board act on the card there. The
durable commands that can do the same now find the card where a saved
move of the same plan put it, and record their writes, History rows and
activities on that board: card fields, checklist toggles, adding and
removing checklists, linking, and the title variables of a new card or
swimlane. A copy refuses, as the ordinary copy does. A move to another
board is no longer required to be the plan's last action. It is lifted
when every action that can follow it in a plan, in its own rule or in a
rule of the same trigger type, is one of these. Moves, sorting and
moving all cards are resolved against the board the card left, and
archiving cascades to child cards there, so with any of those the board
keeps direct Sync.

Thanks to xet7 !
2026-10-03 00:22:57 +03:00
Lauri Ojansivu 2df3e9a8b7 Deliver board-level activities durably: a rule's new swimlane and cross-board moves.
Durable delivery identified every activity by a card and a list, so a
rule's createSwimlane activity, which names neither, and a cross-board
move's moveCardBoard activity, which names no list, were written once
but delivered the ordinary way: their notifications and webhooks were
not replayed after a crash. Durable delivery now takes activities
without a list, and without a card. Recipients and webhook senders are
checked against the board, plus the card when one is named. A card or
list the activity does not name is refused. An assigned-only member
never receives a board-level event, since its scope cannot be checked
against their assignments. The rule stage has nothing to run for these
types, because no trigger exists for them, and it refuses a list-less
activity whose type has one.

Thanks to xet7 !
2026-10-03 00:08:13 +03:00
Lauri Ojansivu 823dc94715 Link a copied or moved item to the other board's sprint and release of the same name.
As decided on 2026-10-02, a card or swimlane copied or moved to another
board now takes that board's sprint and release of the same name when
exactly one matches: a planned or active sprint, or a release that is
not cancelled. Otherwise they are dropped, as before. Past sprints and
backlog rank always go. This applies to card and swimlane copies,
subtasks copied with their parent, the server hooks behind every move,
and the durable rule copy and move. A move that sets the Scrum revision
itself, as the durable rule move does, is left alone by the hook.

Thanks to xet7 !
2026-10-02 20:53:38 +03:00
Lauri Ojansivu b09eaaa4d0 Make moving all cards of a list to another board durable when both boards opted in.
A moveAllCardsInList rule onto another board now saves one unit per
card of the list. Each unit is a whole move to another board, with the
same mappings and records as a single rule move there. As in the
ordinary action, each card keeps its sort and lands in that board's
default swimlane. Like a single move to another board, it must end its
rule plan, because the rule's own card may be among those moved. The
rule guard follows a card to where its unit put it. The single-move and
move-all runners share one apply step.

Thanks to xet7 !
2026-10-02 19:14:29 +03:00
Lauri Ojansivu 32d1abeffe Make rule moves to another board durable when both boards opted in.
A moveCardToTop or moveCardToBottom rule onto another board now runs its
saved command. The card is updated once, conditionally, with every hook
record deferred, and each record is written from the command: History
rows, the legacy undo row, re-homed checklists, the dependencies left
behind on the old board, attachment placement, re-pointed label
activities, the moveCardBoard activity and the custom-field activities.
The server test compares the result with the ordinary Card.move.

Every other durable command acts on the card on the plan's board, so
such a move must end its rule plan. The command refuses any other
position before writing anything. Eligibility counts the move only when
it is the last action of its rule and no other rule on that board fires
on the same activity type; the destination must have opted in too.

The rule guard follows the card to the board this plan moved it to. The
activity's notification and webhook stages judge recipients on the card
as placed for the activity. Before, they refused a card that a rule had
moved, which would have failed any run whose moved card had a watcher
or a webhook, also for moves on the same board.

Moving all cards of a list to another board stays on direct Sync.

Thanks to xet7 !
2026-10-02 19:10:32 +03:00
Lauri Ojansivu d82a54944a Finish a durable Sync run whose rule moved or archived the card it synced.
A Sync step's rules run after its card write, and since rules may move a
card to another list or archive it, the card can afterwards match
neither the step's before-state nor its after-state. Two things then
failed:

- An interrupted run never recovered. The replay retried the step's
  write, which could not be confirmed, so the run failed on every replay.
  The journal now treats a stored planned activity as proof that the
  write happened (activities are stored only after it is confirmed) and
  finishes the effects, which are idempotent.
- Even an uninterrupted run failed whenever a durable rule moved the card
  out of the list. The activity's notification and webhook stages ran
  after the rule and refused a card that was no longer in the activity's
  list. They now also accept the card where a saved move of that
  activity's own rules put it, and nowhere else.

A failed replay now logs why. The durable Sync server test runs a rule
that moves each new card out of the synced list, crashes after the move,
and checks that the replay completes the run with one move.

Thanks to xet7 !
2026-10-02 18:19:02 +03:00
Lauri Ojansivu 52a2ed7386 Make rule copies to another board durable when both boards opted into Sync effects.
A copyCard rule that copies onto another board now uses the same saved
command, with that board as its target: the copy takes that board's
labels of the same name, its custom fields as Card.copy maps them, its
card number and the dependencies that stay on it. Its checklists, items,
subtasks, comments and attachments are all placed on that board. As
with links, eligibility requires the destination to have opted in and
to have only durable rules of its own, and the runner checks it again.
The server test compares the result with the ordinary Card.copy to the
same board.

Thanks to xet7 !
2026-10-02 18:09:48 +03:00
Lauri Ojansivu ab611bcd79 Make rule links to another board durable when both boards opted into Sync effects.
As decided on 2026-10-02, a linkCard rule that links onto another board
keeps durable Sync only when that board has Sync effects enabled too and
the actor may write there. Eligibility now follows every board such a
rule reaches, because the link's creation activity runs that board's own
rules through the same stored stages; any action there without a durable
adapter keeps the source board on direct Sync. The runner checks the
destination again before each write.

A card-field rule acting on a linked card now writes the card it links
to, as the ordinary setters do through getRealId. Before, the durable
command refused a linked card, so a durable link followed by such a rule
would have failed its Sync run on every replay.

Thanks to xet7 !
2026-10-02 18:04:14 +03:00
Lauri Ojansivu 9cc42caac9 Make rule moves to another list or swimlane, and move-all, durable on the card's own board.
The rule stage's guard now accepts the card where a saved move of the
SAME rule plan put it (maintainer decision of 2026-10-02), so the rule's
later actions act on the moved card once. Each move is a saved command
with Card.move's effects: the update, the position History row, the
legacy undo row, the attachments' placement and the moveCard activity.
moveAllCardsInList saves one unit per card. Moves, copies and links to
another board stay on the direct path.

Thanks to xet7 !
2026-10-02 17:53:05 +03:00
Lauri Ojansivu 4764b8aa42 Run the addSwimlane rule action through durable Sync.
An addSwimlane rule now has a saved command: the title is resolved once
by RulesHelper.ruleSwimlaneTitle, the swimlane is inserted once under an
id derived from the rule invocation, and the insert hook's
createSwimlane activity is written once, by a derived id, by the command
itself. A swimlane activity has no card, and WeKan's durable activity
delivery is keyed by a card, so that activity is delivered the way every
board-level activity is; what the command guarantees is that the
swimlane and its activity each exist exactly once across replays.

The stored-rule tests now use moveAllCardsInList as their example of an
action with no durable adapter.

Thanks to xet7 !
2026-10-02 17:14:15 +03:00
Lauri Ojansivu 044454e6d0 Run the linkCard rule action through durable Sync on the card's own board.
A linkCard rule that links onto the card's own board now has a saved
command: the linked card is built once as Card.link builds it (a copy
without id and labels, of type cardType-linkedCard pointing at the
original), under an id derived from the rule invocation so a replay
inserts it once, and its creation activity is saved and delivered
durably. The target is resolved by RulesHelper.linkCardTarget, which the
ordinary action now uses too. A link to another board keeps the board
on direct Sync.

Thanks to xet7 !
2026-10-02 17:11:47 +03:00
Lauri Ojansivu 22311feaf4 Run the copyCard rule action through durable Sync on the card's own board.
A copyCard rule that copies onto the card's own board now has a saved
command. What the copy contains is decided once, with the ordinary
copy's own helpers: the card as Card.copy builds it (the custom fields
the actor may read, its dependencies on the board, its Scrum metadata,
a new card number, the bottom of the list), its live attachments, its
checklists and items, its subtasks with their checklists, and its
comments. Every document gets an id derived from the rule invocation,
so a replay inserts each once. The copy's and its subtasks' creation
activities are saved and delivered durably; each attachment file is
copied once (copyFile can now be given the id) and its History row is
written from the stored attachment; checklists, items and comments are
direct inserts, as Card.copy makes them. The cover is remapped to the
copied attachment by its derived id. Like the ordinary copy chain
guard, a copy whose own creation triggers the same action is not copied
again. A copy to another board keeps the board on direct Sync.

The server test copies a card with all of those, replays it, checks the
chain guard, and compares the result with the ordinary Card.copy.

Thanks to xet7 !
2026-10-02 17:09:16 +03:00
Lauri Ojansivu d2629161fe Run the createCard rule action through durable Sync.
A createCard rule now has a saved command. Its list, swimlane and title
are resolved once by RulesHelper.createCardTarget - which the ordinary
action uses too, so the two cannot drift - and the new card's id is
derived from the rule invocation, so a replay inserts it once. The
creation hook's createCard activity is known before the insert and is
saved with the command, then delivered durably, which runs the new
card's own rules. A target that does not exist is refused, as the
ordinary insert fails at its activity.

Thanks to xet7 !
2026-10-02 16:58:24 +03:00
Lauri Ojansivu d8c904b94a Run the sortList rule action through durable Sync.
A sortList rule re-sorts the cards of the rule card's list, or a named
list on the same board, and gives each card its index as its sort; the
hook records one position History row per changed card and there is no
activity. It now has a saved command: the order is decided once, by the
same sort keys the ordinary action uses (moved to the pure
models/lib/ruleSortList.js so the two cannot drift), and each changed
card is a unit written conditionally on its saved sort with its planned
position row. Replays change nothing more.

Thanks to xet7 !
2026-10-02 16:55:19 +03:00
Lauri Ojansivu d69cde2ecf Run the addChecklistWithItems rule action through durable Sync.
The checklist lifecycle command now also covers addChecklistWithItems:
the checklist and one item per comma-separated title, both with ids
derived from the rule invocation so a replay inserts them once. After
the inserts it records, from the stored documents and in the order the
hooks write them, the checklist's activity and History row and then each
item's addChecklistItem activity and 'added' row. The item hooks are
deferred only for items of the checklist the command names. The item
titles are resolved by the same RulesHelper call the ordinary action
uses.

Thanks to xet7 !
2026-10-02 16:52:15 +03:00
Lauri Ojansivu 21d7848d47 Run rule checklist creation and removal through durable Sync.
addChecklist and removeChecklist rule actions now have saved commands,
like the other durable rule actions. addChecklist inserts a checklist
whose id is derived from the rule invocation, so a replay inserts it
once, and records the hook's addChecklist activity and History lifecycle
row from the document as it was stored. removeChecklist saves every
checklist the ordinary selector matches, one unit each, and for each
writes the removeChecklist activity before the removal and the 'removed'
History row after it, refusing a checklist that changed since capture.
The checklist hooks are deferred only for the checklist a command names.

Thanks to xet7 !
2026-10-02 15:40:57 +03:00
Lauri Ojansivu b3b4962414 Run rule moves to the top or bottom of the card's own list through durable Sync.
A moveCardToTop or moveCardToBottom rule whose list and swimlane are '*'
on the card's own board only changes the card's sort. It now has a saved
command, like the card-field actions: the sort is computed once at
capture as the ordinary action computes it, the write is conditional on
the saved sort, the hook's position History row is planned and written
once, and the legacy UserPositionHistory row that Ctrl+Z reads is
written once with trackChange's redo-stack clearing. Replays apply the
saved command and change nothing more.

A move to another list, swimlane or board is reported to eligibility as
'<type>:elsewhere', so a board with such a rule keeps direct Sync.

Thanks to xet7 !
2026-10-02 15:34:18 +03:00
Lauri Ojansivu 06e186a0d0 Send act-editCard to webhooks that opt in.
A webhook whose activity list names act-editCard now receives that event
for card title and description edits, with a `field` parameter saying
which one changed. A webhook on `all` or on the per-field events keeps
receiving act-a-changedTitle / act-a-changedDescription as before, and
every webhook still gets one delivery per edit, so no receiver sees the
same edit twice. Ordinary dispatch and stored Sync webhook plans make the
same per-webhook choice. The English event text is pending Transifex.

Thanks to Rishats and xet7 !

Fixes #4912.
2026-10-02 15:09:58 +03:00
Lauri Ojansivu 8ddce924ec Record the Problems keys nothing recorded.
Nine catalog keys had no caller, so their Hall of Fame names could never
appear in Admin Panel -> Problems. Now recorded: a hostname resolving to an
internal address (DnsBleed) and a webhook refused by the SSRF guard
(IntegrationBleed), a Trello import carrying a non-http source URL
(SourceBleed), a client call of the OIDC-login-only org/team methods
(OIDCBleed), a sign-up with a wrong invitation code (InviteBleed), and a
read-only member writing over REST (ReadOnlyBleed). The three keys that
nothing can attribute are listed with their reasons in the test.

Thanks to xet7 !
2026-10-02 11:50:37 +03:00
Lauri Ojansivu 4af54face7 Publish a board's webhook URLs to its admins only.
A chat incoming-webhook URL carries its secret in the path, and the board
publication sent it to every reader of the board, anonymous visitors of a
public board included. Other readers now get only the fields the
card-opened hook needs, and outgoingWebhooks finds the integration by _id.

Thanks to xet7 !
2026-10-02 11:40:22 +03:00
Lauri Ojansivu 047bde7546 Fix HookBleed: a member cannot make WeKan post their own message through a board webhook.
The outgoingWebhooks method checked that the integration exists and the caller
is a board member, then built the request from the CALLER's integration object
- whose type decided two-way, whose token was sent - and the caller's own
description and params. Any member, read-only included, could post arbitrary
text to the board's Slack, Matrix or other chat webhook as WeKan, without a
rate limit, or turn a one-way hook into a two-way one whose answer rewrites
comments. The request is now built from the stored integration; from a client
the only call allowed is the card-opened notification, with its params rebuilt
on the server from a card on that board. Anything else is refused and recorded
as HookBleed. Unit tests (including the forged call) and a browser test; two
tests whose stub integration lacked a url and type now stub the stored one.

Thanks to xet7 !
2026-10-02 11:25:52 +03:00
Lauri Ojansivu a9e8bda47b Fix the MailTitleBleed regression: member-written values are escaped in templated HTML notification mail.
With an admin-defined activity e-mail body template (#2022), the HTML body was
the substituted template, and the values substituted into it - card, board and
list titles, the username, a comment - are written by members, so markup in a
card title reached other members' HTML mail. The template stays trusted and may
carry HTML; the HTML body now substitutes escaped values, and the text body is
unchanged. Rule e-mails and invitations are text only. The test drives the
substitution with hostile values; an assertion that had pinned the vulnerable
form now pins the fixed one.

Thanks to xet7 !
2026-10-02 10:45:11 +03:00
Lauri Ojansivu af1b1bee2d Make the checklist rule actions durable in Sync.
checkAll, uncheckAll, checkItem and uncheckItem join the durable rule
actions. The command is captured with performAction's own lookups - the
checklist by title on the card, the items in the order ReactiveCache returns
them, the bulk selection, and checkItem's item query as it is - so a replay
acts on the same items with the same outcome, including the ordinary
action's no-ops.

The ordinary action writes each item in turn, and the checklist item hooks
record on every write, changed or not: uncompleteChecklist before it when
the whole checklist was finished, checkedItem or uncheckedItem after it, and
completeChecklist when the whole checklist is finished - plus a History row
on the item when isFinished changed. The command simulates exactly that on
the captured items and saves one unit per item. The runner goes item by item:
the before-write activity, the conditional write with the item's three hooks
deferred, its History, its after-write activities - each delivered durably -
so a rule triggered by one item runs before the next, as ordinarily.

The History planner now accepts checklist-item rows (entity and card kept
apart), and the recording deferral can name one checklist item. Unit tests
cover the hook sequence for check-all, uncheck-all and hidden-all lists,
no-ops and tampering; a full-app test runs a "check every item" rule through
the stored rule stage - two checkedItem, one completeChecklist, two History
rows, and nothing more on replay. 566 server tests pass.

Thanks to xet7 !
2026-09-30 12:17:20 +03:00
Lauri Ojansivu 0395989d01 Make the member rule actions durable in Sync.
addMember and removeMember join the durable card-field actions. The people
are resolved at capture exactly as performAction resolves them - the acting
user for the #2522 option, username tokens through buildRuleVars (#4294),
and the card's assignees for "remove every member" (#2674) - by a new
RulesHelper.resolveMemberTargets beside it, and saved with their usernames,
so a replay acts on the same people. The ordinary action's one $addToSet or
$pull per person becomes one planned change of `members`, with a joinMember
or unjoinMember activity for each person who really joined or left, as the
members hook writes it, and one members History row.

The new helper phrases its conditions so the source guards that locate
performAction's member branch still find it, and the recording-isolation
test now uses assignees as its example of a field that is never deferred.
Unit tests cover resolution being saved, joins and leaves, nobody resolved
and tampered targets; the full-app durable Sync test adds a member to every
created card through a rule - one joinMember activity and one members
History row. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:09:24 +03:00
Lauri Ojansivu ad4ccd5c38 Make the date rule actions durable in Sync.
setDate, updateDate, setDateRelative and removeDate join the durable
card-field actions. Their semantics follow the ordinary actions exactly:
setDate only fills a date that is unset, updateDate always sets it,
setDateRelative offsets from "now", removeDate unsets - with "now" fixed at
the command's capture time, so a replay makes the same change.

A full-app probe of the ordinary writes showed what they record: a dates
History row (added, edited or removed) and the timing hook's a-<field>
activity with username, card title, time key and the old value ('' when
there was none) - and no timeValue when the date is removed. The command
plans exactly that. The timing hook in server/models/cards.js gains a
'timing' deferral kind so the saved activity is written instead of the
hook's own, never both; the runner can now unset a field as well as set it.

Unit tests cover all four actions, setDate on a filled date, the timing
activity's shape for set and unset, and a replay-stable relative date; the
full-app durable Sync test gives every created card a due date through a
rule - one a-dueAt activity and one dates History row. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:05:03 +03:00
Lauri Ojansivu ff86170f35 Make colour, label and completion rule actions durable in Sync.
Boards with any rule action other than email and archive stayed on direct
Sync. Six more now take the durable path: setColor, addLabel, removeLabel,
removeAllLabels, markCardComplete and markCardIncomplete.

Each rule invocation saves one command (server/lib/syncRuleCardCommand.js)
with its card field's value before and after the action - with the ordinary
action's semantics: $addToSet/$pull for single labels, a missing field stays
missing on removeLabel, 'white' is stored as null - and the effects the
ordinary hooks would write: one History row for the field and, for
addLabel/removeLabel, the addedLabel/removedLabel activity only when the
label really changed (removeAllLabels writes none, as ordinarily). The runner
applies the saved change conditionally with ordinary History deferred for
that one write, then writes the planned History rows and activities, each
activity delivered durably with its own rules and notifications, and returns
the invocation only when all of it is confirmed. Replays use the saved
command, never the rule's current configuration.

The History planner is parameterized by allowed fields (Sync's own, or these
three), and the recording deferral covers labelIds, color and dueComplete.
Unit tests cover every action, the effects, absent-versus-null selectors and
tampering; the full-app durable Sync test labels every created card through
a rule - one History row, one activity, nothing more on replay. The rule
selection test's example of an action without an adapter is now
moveCardToTop. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:00:47 +03:00
Lauri Ojansivu 023090a65d Compact finished rule archive commands and their effects after 90 days.
With archive now a durable Sync action, the stored archive runner writes
commands that keep up to 1000 cards' titles and placement, and effects rows
that keep the History and activity content written for them - forever, with
only a timeless final receipt to say they finished.

The runner now writes a completion receipt with its time after it finishes.
SYNC_RECEIPT_METADATA_DAYS (90) later the sweep removes the effects row - read
only while the command is unfinished - and replaces the command in place by
its id, checksum, invocation and plan. A late replay of the rule action
returns the invocation as done when the runner's own final receipt confirms
it; card and final receipts stay.

A MongoDB test covers compaction, the untouched recent and unfinished
commands and the refusals; the full-app durable Sync test compacts the real
archive command from its rule run and replays it. 565 server tests pass.

Thanks to xet7 !
2026-09-30 11:52:30 +03:00
Lauri Ojansivu f06ecdee09 Share guard results within one check, and make rule archive a durable Sync action.
Stored Sync stages nest - a rule archive's delivery inside the rule stage,
inside activity delivery, inside the Sync journal - and every layer's guard
checks before and after by calling the guard below it twice. One innermost
check therefore re-ran every outer guard 2^depth times, and one Sync-created
card archived by a rule took 36 s, which is why archive was held back from
durable Sync (1e40e7e06).

reuseWithinEvaluation (server/lib/syncGuardWindow.js) runs each guard at most
once per evaluation: calls made while another guard's check is running share
the results of guards already checked in it. A call from ordinary work -
between stages, after an adapter or a write - starts a new evaluation and
checks everything afresh, so a policy change or a lost lease between stages
still stops the next one. A first attempt with a 100 ms reuse window missed
exactly that and was dropped. Failures never carry over, a guard reached
again through its own check runs fresh instead of waiting on itself, and the
journal's ownership read is left as it was.

With that, archive and unarchive are registered as durable rule adapters
through the stored archive runner, and boards whose rules archive or
unarchive now take durable Sync. The full-app durable Sync test runs an
"archive every created card" rule end to end: 1.1 s for the whole test. The
rule selection test's example of an action without an adapter is now
moveCardToTop. 565 server tests pass.

Thanks to xet7 !
2026-09-30 11:50:04 +03:00
Lauri Ojansivu fbea673a1b Compact finished Sync rule plans after 90 days.
Maintainer decision of 2026-09-30: receipts are compacted after 90 days to
a permanent minimal id and outcome. A stored rule plan keeps the whole
documents of the rules and actions it matched - a send-email action's
recipients and text among them - and was kept forever; its 'rules' receipt
had no time, so it could not be told old.

runStoredSyncRules now writes a completion receipt with its time once every
action is done, and the shared plan retention compacts the plan in place
SYNC_RECEIPT_METADATA_DAYS (90) later. A replay of the compact form returns as
done; every other stage that needs the whole plan - email command capture,
archive capture - refuses the stub, and the legacy email review treats a
command whose plan is compacted as finished, never rebindable. Action
receipts stay, and rule email commands keep their own schedule.

A MongoDB test covers compaction, the untouched unfinished plan, replay and
the legacy review; the full-app rule test compacts a finished plan and
replays it. 565 server tests pass.

Thanks to xet7 !
2026-09-30 11:42:51 +03:00
Lauri Ojansivu 5a7b74bd1d Compact delivered Sync webhook plans, with their URLs and tokens, after 90 days.
Maintainer decision of 2026-09-30: receipts are compacted after 90 days to
a permanent minimal id and outcome. A stored webhook plan keeps each
target's URL, its X-Wekan-Token credential and the request body; a response
row keeps the receiver's reply and a comment plan the comment text - all
forever, and the plan had no completion evidence of its own.

The notification plan retention becomes a shared kit (syncPlanRetention.js)
and webhooks use it: once every target's delivery is confirmed, a completion
receipt with its time is written. After SYNC_RECEIPT_METADATA_DAYS (90) the
sweep first removes the plan's response and comment-plan rows - read only
while a delivery receipt is missing - then compacts the plan in place. A late
replay of the compact form returns as delivered; delivery and comment
receipts, already minimal, stay.

A MongoDB test covers what is removed and what an undelivered plan keeps,
replay of the compact form and its refusals; the full-app webhook test
compacts a really delivered plan, checks the URL and token are gone, and
replays it without touching the comment. 565 server tests pass.

Thanks to xet7 !
2026-09-30 11:39:05 +03:00
Lauri Ojansivu bb591c448a Compact delivered Sync notification plans after 90 days.
Maintainer decision of 2026-09-30: receipts are compacted after 90 days to a
permanent minimal id and outcome, notification plans included. A stored Sync
notification plan keeps every recipient's rendered subject and HTML, and had
no completion evidence of its own, so it could never be told finished and
was kept forever.

Delivery now writes a receipt once it is confirmed - planId, activity hash,
plan checksum and completedAt; the first stored receipt wins. After
SYNC_RECEIPT_METADATA_DAYS (90) an hourly sweep replaces the exact plan the
receipt was written for with { _id, activityHash, checksum,
compactReceiptVersion } in place, so its id stays taken. A replay that finds
the compact form returns as delivered and never rebuilds or resends; within
the period a replay still re-checks every recipient, as before. A compact
plan without its matching receipt, or for changed activity content, is
refused.

The other receipt rows named in the decision - Scrum completions and
requests, Sync operation intents and completions - already hold only ids,
hashes and timestamps, so there is nothing in them to compact.

MongoDB tests cover what is compacted and what is not, idempotence, replay
of the compact form and the refusals; the full-app delivery test compacts a
real delivered plan and replays it without sending.

Thanks to xet7 !
2026-09-30 11:12:25 +03:00
Lauri Ojansivu 3151f8a815 Fix ReplyBleed: attribute email replies to the recipient the address was sent to.
The reply-by-email token signed only the card, so every recipient of a
card's notification held the same Reply-To address, and the webhook took the
comment author from the reply's From address - a field the sender controls.
Anyone holding one card's reply address could comment on it as any user
(GHSA-mc7c-cv99-64h7, CWE-346).

Validation also found that server/routes/inboundEmail.js was never imported
by server/imports.js, so released versions did not register
/api/inbound-email: the documented feature did not work and the flaw could
not be reached. The endpoint is registered now, together with the fix.

The reply address is now reply+<cardId>.<userId>.<expiry>.<mac>: an
HMAC-SHA256 over the card, the recipient and the last valid day
(INBOUND_EMAIL_REPLY_DAYS, default 30). The author is that recipient; the
From address must be one of the recipient's own addresses; the recipient must
be enabled and still allowed to comment on the card, including the
assigned-only restriction. INBOUND_EMAIL_WEBHOOK_SECRET, when set, must be
presented by the provider (X-WeKan-Inbound-Secret header or ?secret=) and is
compared in constant time. The old card-only token is refused.

A forged token, a spoofed sender and a wrong provider secret are recorded as
ReplyBleed in Admin Panel -> Problems; expired and pre-fix tokens and lost
access are refused quietly, since real users replying to old mail reach them.

Tests: token round trip, per-recipient addresses, tampering, expiry and
legacy tokens; the author decision reproducing the advisory's attack; a
tree-wide negative that no code picks an author from a From address; and a
full-app HTTP test against /api/inbound-email.

Thanks to alex131125 and xet7 !
2026-09-30 10:52:45 +03:00