diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-18 11:32:49 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-18 11:32:59 -0400 |
commit | 5e81ebbd1a6f8911acd537923f2f3c1df4971bbc (patch) | |
tree | dbfef37014fbe73930ddd4655ca3234337ca7c0a | |
parent | 5916c8406367b9033094359d6da2e079440d8f1c (diff) | |
download | debug-me-5e81ebbd1a6f8911acd537923f2f3c1df4971bbc.tar.gz |
fix backlog truncation bug
That I was stuck on for hours yesterday, oops!
This commit was sponsored by Bruno BEAUFILS on Patreon.
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | debug-me.hs | 15 |
2 files changed, 14 insertions, 5 deletions
@@ -1,4 +1,3 @@ -* Typing "top" causes only "to" to be accepted. * Improve JSON, removing use of "tag" * potential DOS where developer sends Activity Entered that all refer back to the first Activity Seen. This requires the user @@ -17,6 +16,9 @@ unlikely that a Activity Entered will legitimately refer to an old backlog item. * Encryption! +* Add random nonce to start message, to avoid replay issues. + (Or perhaps the encryption derives a RSA key in a way that avoids + replay..) * Network! * Server! * gpg key downloading, web of trust checking, prompting diff --git a/debug-me.hs b/debug-me.hs index 9332270..7a9f527 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -278,19 +278,26 @@ sendPtyInput ichan ochan p backlog logger = go go -- | Truncate the Backlog to remove entries older than the one --- that the Activity refers to. +-- that the Activity Entered refers to, but only if the referred +-- to Activity is an Activity Seen. -- --- If the activity refers to an item not in the backlog, no truncation is +-- Once the developer has referred to a given Activity Seen in +-- their Activity Entered, they cannot refer backwards to anything +-- that came before it. +-- +-- If the Activity refers to an item not in the backlog, no truncation is -- done. truncateBacklog :: Backlog -> Activity Entered -> Backlog truncateBacklog (Backlog (b :| l)) (Activity _ hp _) - | Just (activityLogHash b) == hp = Backlog (b :| []) + | truncationpoint b = Backlog (b :| []) | otherwise = Backlog (b :| go [] l) where go c [] = reverse c go c (x:xs) - | Just (activityLogHash x) == hp = reverse (x:c) + | truncationpoint x = reverse (x:c) | otherwise = go (x:c) xs + truncationpoint x@(ActivitySeen {}) = Just (activityLogHash x) == hp + truncationpoint _ = False -- | Entered activity is legal when it points to the last Seen activvity, -- because this guarantees that the person who entered it saw |