jj/lib/tests
Yuya Nishihara ded48ff6e7 local_working_copy: do not create file or write in directory named .jj or .git
I originally considered adding deny-list-based implementation, but the Windows
compatibility rules are super confusing and I don't have a machine to find out
possible aliases. This patch instead adds directory equivalence tests.

In order to test file entity equivalence, we first need to create a file or
directory of the requested name. It's harmless to create an empty .jj or .git
directory, but materializing .git file or symlink can temporarily set up RCE
situation. That's why new empty file is created to test the path validity. We
might want to add some optimization for safe names (e.g. ASCII, not contain
"git" or "jj", not contain "~", etc.)

That being said, I'm not pretty sure if .git/.jj in sub directory must be
checked. It's not safe to cd into the directory and run "jj", but the same
thing can be said to other tools such as "cargo". Perhaps, our minimum
requirement is to protect our metadata (= the root .jj and .git) directories.

Despite the crate name (and internal use of std::fs::File),
same_file::is_same_file() can test equivalence of directories. This is
documented and tested, so I've removed my custom implementation, which was
slightly simpler but lacks Windows support.
2024-11-06 15:03:41 -08:00
..
runner.rs tests: add basic tests for annotation function 2024-10-27 22:51:54 +09:00
test_annotate.rs annotate: do not collect result lines into Vec, return Iterator instead 2024-10-29 23:33:46 +09:00
test_bad_locking.rs testutils: move load_repo_at_head() to TestEnvironment 2024-11-02 08:39:02 +09:00
test_commit_builder.rs transaction: rename mut_repo() to idiomatic repo_mut() 2024-09-07 10:51:43 -07:00
test_commit_concurrent.rs testutils: move load_repo_at_head() to TestEnvironment 2024-11-02 08:39:02 +09:00
test_conflicts.rs style: add semicolon at the end of expressions used as statements 2024-10-04 22:29:13 +02:00
test_default_revset_graph_iterator.rs revset: allow iterators to return evaluation errors 2024-10-18 17:09:35 -04:00
test_git.rs repo_path: add stub for checked to_fs_path(), rename unchecked functions 2024-11-06 15:03:41 -08:00
test_git_backend.rs transaction: rename mut_repo() to idiomatic repo_mut() 2024-09-07 10:51:43 -07:00
test_gpg.rs formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
test_id_prefix.rs id_prefix: propagate error from disambiguation index 2024-10-09 14:07:48 +09:00
test_index.rs testutils: move load_repo_at_head() to TestEnvironment 2024-11-02 08:39:02 +09:00
test_init.rs repo: remove repo_path from ReadonlyRepo and RepoLoader 2024-09-07 12:20:02 -07:00
test_load_repo.rs testutils: move default_store_factories() to TestEnvironment 2024-11-02 08:39:02 +09:00
test_local_working_copy.rs local_working_copy: do not create file or write in directory named .jj or .git 2024-11-06 15:03:41 -08:00
test_local_working_copy_concurrent.rs repo_path: add stub for checked to_fs_path(), rename unchecked functions 2024-11-06 15:03:41 -08:00
test_local_working_copy_sparse.rs repo_path: add stub for checked to_fs_path(), rename unchecked functions 2024-11-06 15:03:41 -08:00
test_merge_trees.rs repo_path: add stub for checked to_fs_path(), rename unchecked functions 2024-11-06 15:03:41 -08:00
test_merged_tree.rs style: add semicolon at the end of expressions used as statements 2024-10-04 22:29:13 +02:00
test_mut_repo.rs repo: introduce MutableRepo::reparent_descendants() 2024-09-24 09:30:28 +02:00
test_operations.rs repo: teach OpStore about the root commit id 2024-10-08 13:21:03 +09:00
test_refs.rs transaction: rename mut_repo() to idiomatic repo_mut() 2024-09-07 10:51:43 -07:00
test_revset.rs revset: inline resolve/evaluate_programmatic() in tests 2024-11-06 09:45:09 +09:00
test_rewrite.rs bookmarks: update some leftover uses of the word "branch" 2024-09-11 19:19:31 -07:00
test_rewrite_transform.rs transaction: rename mut_repo() to idiomatic repo_mut() 2024-09-07 10:51:43 -07:00
test_signing.rs transaction: rename mut_repo() to idiomatic repo_mut() 2024-09-07 10:51:43 -07:00
test_ssh_signing.rs formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
test_view.rs bookmarks: update some leftover uses of the word "branch" 2024-09-11 19:19:31 -07:00
test_workspace.rs testutils: move default_store_factories() to TestEnvironment 2024-11-02 08:39:02 +09:00