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

Unable to reference files in a sibling directory using .. #303

Open
jamesottaway opened this issue Apr 24, 2020 · 5 comments · Fixed by #304 · May be fixed by #305
Open

Unable to reference files in a sibling directory using .. #303

jamesottaway opened this issue Apr 24, 2020 · 5 comments · Fixed by #304 · May be fixed by #305

Comments

@jamesottaway
Copy link
Contributor

jamesottaway commented Apr 24, 2020

I have a repo with a shared secrets/ directory at the top-level, alongside many others. If I'm in one of the other directories I cannot, for example, blackbox_cat ../secrets/fake-secret.sh .gpg:

❯ ls -al ../secrets
.rw-rw-r-- 4.0k james 24 Apr 21:38 fake-secret.sh.gpg

❯ blackbox_cat ../secrets/fake-secret.sh.gpg
========== PLAINFILE "../secrets/fake-secret.sh"
ERROR: ../secrets/fake-secret.sh not found in /home/james/src/cosmos/keyrings/live/blackbox-files.txt
PWD=/home/james/src/cosmos/repro
Exiting...

I traced the problem to vcs_relative_path which doesn't try to resolve the ../ part of the relative path, meaning it doesn't exactly match the line in blackbox-files.txt. One solution would be to call realpath on the argument, but I'm not sure whether that's sufficiently cross-platform.

@tlimoncelli
Copy link
Contributor

Yeah, vcs_relative_path is pretty simplistic. realpath would be a solution but it isn't on macOS.

The workaround is to cd to the correct directory first.

I'd love a PR to fix this.

@jamesottaway
Copy link
Contributor Author

Which platforms does Blackbox support, so I can think of how to solve it for all?

@jamesottaway
Copy link
Contributor Author

jamesottaway commented Apr 25, 2020

Another related issue is that Blackbox can't refer to encrypted files using their absolute path, which I realised when trying to use that as a workaround for this issue.

If vcs_relative_path changes to resolve .. it's also probably worth changing it to strip $REPOBASE off the absolute path in order to match the relative path in blackbox-files.txt.

Upon closer inspection, I see that vcs_relative_path is doing this already, but only because it prefixes the argument with $PWD. As part of fixing the relative path resolution I think this will also make it work for absolute paths too.

@tlimoncelli
Copy link
Contributor

Hi @jamesottaway !

Sadly I had to revert 87b7cd0. "make test" fails. Can you take a look. A file at the base of the repo adds "/" to .gitignore instead of "/filename".

========== CREATED: secret.txt.gpg
========== UPDATING REPO:
NOTE: "already tracked!" messages are safe to ignore.
[master 67cf029] registered in blackbox: secret.txt
 3 files changed, 2 insertions(+)
 create mode 100644 secret.txt.gpg
========== UPDATING VCS: DONE
Local repo updated.  Please push when ready.
    git push
ASSERT FAILED: line '/secret.txt' should exist in file .gitignore
==== file contents: START .gitignore
/
/var/folders/qw/qp8v2j353wz7q57_jymyxj0h0000gn/T/SO.p8wByYEg
==== file contents: END .gitignore

@tlimoncelli tlimoncelli reopened this Apr 29, 2020
@jamesottaway
Copy link
Contributor Author

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants