Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert-beginning: Files outside of the repository can be added to the repository #260

Closed
CervEdin opened this issue Jun 15, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@CervEdin
Copy link

It appears one can add a file outside of the repo using the insert-beginning demo.

Steps to reproduce

mkdir insert-outside && cd insert-outside
git init && git commit --allow-empty -m init
echo outside! > ../an-outside-file
insert-beginning --file ../an-outside-file

This will result in something like

$ git log -p
commit 61116276d40336ab23974003597ed167d36bf2d6 (HEAD -> main)
Author: Erik Cervin Edin <[email protected]>
Date:   Tue Jun 15 16:34:50 2021 +0200

    init

diff --git a/../an-outside-file b/../an-outside-file
new file mode 100755
index 0000000..b454f01
--- /dev/null
+++ b/../an-outside-file
@@ -0,0 +1 @@
+outside!

Trying to undo results in

$ git filter-repo --paths ../an-outside-file --invert
Parsed 1 commitserror: invalid path '../an-outside-file'
fatal: Could not reset index file to revision 'HEAD'.

or

$ git filter-repo --path-rename "../an-outside-file:an-outside-file"
Error: Invalid path component '..' found in '../an-outside-file:an-outside-file'

It seems possible to really mess up a repository doing this.

@newren newren added the bug Something isn't working label Jun 15, 2021
@newren
Copy link
Owner

newren commented Jun 15, 2021

Wow, that looks bad! I don't have time at the moment to investigate, but thanks for reporting. I'll try to look at it soon.

@newren
Copy link
Owner

newren commented Nov 24, 2024

Fixed with ad7b5b8 (insert-beginning: add some sanity checking on the passed filename, 2024-11-23). Also created a patch to have fast-import reject such paths; see gitgitgadget/git#1831

@newren newren closed this as completed Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants