mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(server): only allow absolute import paths (#13642)
fix: only allow absolute paths
This commit is contained in:
parent
56bebd01df
commit
b411e30796
4 changed files with 54 additions and 7 deletions
|
|
@ -633,6 +633,29 @@ describe('/libraries', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should fail if path isn't absolute", async () => {
|
||||
const pathToTest = `relative/path`;
|
||||
|
||||
const cwd = process.cwd();
|
||||
// Create directory in cwd
|
||||
utils.createDirectory(`${cwd}/${pathToTest}`);
|
||||
|
||||
const response = await utils.validateLibrary(admin.accessToken, library.id, {
|
||||
importPaths: [pathToTest],
|
||||
});
|
||||
|
||||
utils.removeDirectory(`${cwd}/${pathToTest}`);
|
||||
|
||||
expect(response.importPaths?.length).toEqual(1);
|
||||
const pathResponse = response?.importPaths?.at(0);
|
||||
|
||||
expect(pathResponse).toEqual({
|
||||
importPath: pathToTest,
|
||||
isValid: false,
|
||||
message: expect.stringMatching('Import path must be absolute, try /usr/src/app/relative/path'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail if path is a file', async () => {
|
||||
const pathToTest = `${testAssetDirInternal}/albums/nature/el_torcal_rocks.jpg`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue