immich icon indicating copy to clipboard operation
immich copied to clipboard

feat(server): support for read-only assets and importing existing items in the filesystem

Open alex-phillips opened this issue 2 years ago • 14 comments

alex-phillips avatar Jun 10 '23 15:06 alex-phillips

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2023 2:21am

vercel[bot] avatar Jun 10 '23 15:06 vercel[bot]

Should we add a check that prevents a user from importing a path that is in another users folder? The existing structure uses /usr/src/app/upload/library/label or UUID/...

There could be some security issue where a user could gain access to another file using this import method with a valid path of another users file and then accessing or deleting it.

jrasm91 avatar Jun 11 '23 13:06 jrasm91

Hmm, not sure here. It could be a security issue, but if the person doing the importing also has access to the files, wouldn't it be ok?

alex-phillips avatar Jun 11 '23 15:06 alex-phillips

Well they don't have access to them per se, hence the security issue. Relying on them just not knowing the path isn't security imo

jrasm91 avatar Jun 11 '23 16:06 jrasm91

Well they don't have access to them per se, hence the security issue. Relying on them just not knowing the path isn't security imo

Good point - added in a new method and duplicate check in the importFile method call.

alex-phillips avatar Jun 11 '23 17:06 alex-phillips

Can you please help outline the steps on how to test the PR?

alextran1502 avatar Jun 13 '23 12:06 alextran1502

Can you please help outline the steps on how to test the PR?

You can test with this branch of the CLI: https://github.com/immich-app/CLI/tree/import-photos This adds in support for the --import flag. Everything else should work the exact same way, but this will trigger the server to perform an 'import' instead of uploading the files.

alex-phillips avatar Jun 14 '23 12:06 alex-phillips

Could you add a bit more description to the PR? I want to try it but it's not obvious what paths can be imported

etnoy avatar Jun 16 '23 12:06 etnoy

Deployment failed with the following error:

Resource is limited - try again in 4 hours (more than 100, code: "api-deployments-free-per-day").

vercel[bot] avatar Jun 16 '23 19:06 vercel[bot]

It appears the code doesn't build right now so I can't test it

etnoy avatar Jun 17 '23 06:06 etnoy

@jrasm91 When you have time, can you help me look at the failed tests?

alextran1502 avatar Jun 18 '23 04:06 alextran1502

We should also include a column with checkmark of user that has import path in this table image

alextran1502 avatar Jun 18 '23 05:06 alextran1502

My first round of testing resulted in the following behavior. Let me know what did I do wrong here.

In the Administration page, I have the External Path for the user as the following image.

image

And this is how I created the folder in the location of UPLOAD_LOCATION

image

image

This is the CLI command I use the error I get

image

alextran1502 avatar Jun 19 '23 03:06 alextran1502

First, problem is that external path for the user must be an absolute path. If you are mounting that folder into the container at /mnt/immich_data/aleximport then your external path must be /mnt/immich_data/aleximport. Alternatively, if you were creating a new mountpoint inside the container at /aleximport, then the external path would be /aleximport. The external path needs to be absolute inside the container, beginning with a /.

Second, could you share your docker-compose for adding this new mount? The error says file doesn't exist, so I would be interested if it's not mounted properly. You can also create a container in the shell and do an ls on one of the expected files. Since you are running the CLI agains the /mnt/immich_data/aleximport directory, you should be able to ls that path inside the container as well.

alex-phillips avatar Jun 19 '23 11:06 alex-phillips