Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4b8ecc65c3
|
|||
3696bcade2
|
|||
dea401fec0
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "fotochallenge",
|
"name": "fotochallenge",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "fotochallenge",
|
"name": "fotochallenge",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "^3.0.0",
|
"@sveltejs/adapter-auto": "^3.0.0",
|
||||||
"@sveltejs/adapter-node": "^5.2.0",
|
"@sveltejs/adapter-node": "^5.2.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fotochallenge",
|
"name": "fotochallenge",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Gabi und Hannes Fotochallenge</title>
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
@ -3,18 +3,18 @@ import { describe, it, expect } from 'vitest';
|
|||||||
|
|
||||||
describe('safe path', () => {
|
describe('safe path', () => {
|
||||||
it('reject names with ../', () => {
|
it('reject names with ../', () => {
|
||||||
expect(safePath('../foobar', './uploads')).toBe(false);
|
expect(safePath('./uplodas', '../foobar')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accept names with ./', () => {
|
it('accept names with ./', () => {
|
||||||
expect(safePath('./foobar', './uploads')).toBe(true);
|
expect(safePath('./uplodas', './foobar')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reject names with /', () => {
|
it('reject names with /', () => {
|
||||||
expect(safePath('foo/bar', './uploads')).toBe(false);
|
expect(safePath('./uplodas', 'foo/bar')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accept happy path', () => {
|
it('accept happy path', () => {
|
||||||
expect(safePath('foobar', './uploads')).toBe(true);
|
expect(safePath('./uplodas', 'foobar')).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// place files you want to import through the `$lib` alias in this folder.
|
// place files you want to import through the `$lib` alias in this folder.
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
function safePath(name: string, basePath: string): boolean {
|
function safePath(basePath: string, name: string): boolean {
|
||||||
const fullPath = `${basePath}/${name}`;
|
const fullPath = `${basePath}/${name}`;
|
||||||
const relative = path.relative(basePath, fullPath);
|
const relative = path.relative(basePath, fullPath);
|
||||||
return (
|
return (
|
||||||
|
@ -36,7 +36,7 @@ export const actions = {
|
|||||||
|
|
||||||
const name = formName as string;
|
const name = formName as string;
|
||||||
|
|
||||||
if (!safePath(name, storagePath)) {
|
if (!safePath(storagePath, name)) {
|
||||||
return fail(400, { field: 'name', name: name, incorrect: true });
|
return fail(400, { field: 'name', name: name, incorrect: true });
|
||||||
}
|
}
|
||||||
// const name = safePath(formName as string);
|
// const name = safePath(formName as string);
|
||||||
|
Reference in New Issue
Block a user