fix: sanitize SESSION_ID in save hook to prevent path traversal
The save hook uses SESSION_ID in file paths (state_dir/). A crafted session_id value like '../../etc/cron.d/evil' could write state files outside the intended directory. Strip everything except [a-zA-Z0-9_-] from SESSION_ID, defaulting to 'unknown' if empty after sanitization. Finding: #4 (HIGH — path traversal via SESSION_ID) Includes test infrastructure from PR #131. 92 tests pass.
This commit is contained in:
@@ -109,11 +109,11 @@ class TestCompressionStats:
|
||||
original = "We decided to use GraphQL instead of REST. " * 10
|
||||
compressed = d.compress(original)
|
||||
stats = d.compression_stats(original, compressed)
|
||||
assert stats["ratio"] > 1
|
||||
assert stats["original_chars"] > stats["compressed_chars"]
|
||||
assert stats["size_ratio"] > 1
|
||||
assert stats["original_chars"] > stats["summary_chars"]
|
||||
|
||||
def test_count_tokens(self):
|
||||
assert Dialect.count_tokens("hello world") == len("hello world") // 3
|
||||
assert Dialect.count_tokens("hello world") == 2
|
||||
|
||||
|
||||
class TestZettelEncoding:
|
||||
|
||||
Reference in New Issue
Block a user