Validate journal dates before vault mutations - #189
Open
levineam wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
capture.datestrings that reachedpath.join(journalDir,${date}.md), allowing../traversal and writes outside the configured journal root.YYYY-MM-DDjournal filename contract before any vault mutation and prevent untrusted input from being used to construct filesystem paths.Description
validateJournalDate(date)helper tomodules/jarvos-secondbrain/adapters/obsidian/src/vault-storage-adapter.jsthat throws unlessdatematches/^\d{4}-\d{2}-\d{2}$/.validateJournalDate(date)at the start ofensureJournalso all journal-creation and append flows validate the date before buildingjournalPathor performing any mutation.test('journal dates reject path traversal before performing a mutation', ...)tomodules/jarvos-secondbrain/tests/vault-storage-adapter-journal.test.jsthat asserts malformed/traversal dates are rejected and no storage operations occur.dateis supplied (still uses the existingtodayDate()formatting).Testing
git diff --checkto verify no whitespace/format issues and it passed.node --test modules/jarvos-secondbrain/tests/vault-storage-adapter-journal.test.js modules/jarvos-secondbrain/tests/keyword-capture-router.test.jsand all tests passed (9 tests, 0 failures).Codex Task