Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c303454db3 | ||
|
|
3972589f76 | ||
|
|
3c5e0ad513 | ||
|
|
384fd19203 | ||
|
|
9d1a12b0d1 | ||
|
|
24e100bd7b | ||
|
|
1da4feeb89 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
|||||||
|
## [0.23.1](https://github.com/stonith404/pingvin-share/compare/v0.23.0...v0.23.1) (2024-04-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **backend:** crash on unhandled promise rejections ([1da4fee](https://github.com/stonith404/pingvin-share/commit/1da4feeb895a13d0a0ae754bd716a84e8186d081))
|
||||||
|
* changing the chunk size needed an app restart ([24e100b](https://github.com/stonith404/pingvin-share/commit/24e100bd7be8bf20778bdf2767aa35cae8d7e502))
|
||||||
|
* disable js execution on raw file view ([9d1a12b](https://github.com/stonith404/pingvin-share/commit/9d1a12b0d1812214f1fe6fa56e3848091ce4945c))
|
||||||
|
* incorrect layout on 404 page ([3c5e0ad](https://github.com/stonith404/pingvin-share/commit/3c5e0ad5134ee2d405ac420152b5825102f65bfc))
|
||||||
|
* normal shares were added to the previous reverse share ([3972589](https://github.com/stonith404/pingvin-share/commit/3972589f76519b03074d916fb2460c795b1f0737))
|
||||||
|
* redirect vulnerability on error, sign in and totp page ([384fd19](https://github.com/stonith404/pingvin-share/commit/384fd19203b63eeb4b952f83a9e1eaab1b19b90d))
|
||||||
|
|
||||||
## [0.23.0](https://github.com/stonith404/pingvin-share/compare/v0.22.2...v0.23.0) (2024-04-04)
|
## [0.23.0](https://github.com/stonith404/pingvin-share/compare/v0.22.2...v0.23.0) (2024-04-04)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
backend/package-lock.json
generated
4
backend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/cache-manager": "^2.1.0",
|
"@nestjs/cache-manager": "^2.1.0",
|
||||||
"@nestjs/common": "^10.1.2",
|
"@nestjs/common": "^10.1.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"dev": "cross-env NODE_ENV=development nest start --watch",
|
"dev": "cross-env NODE_ENV=development nest start --watch",
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export class AuthService {
|
|||||||
include: { resetPasswordToken: true },
|
include: { resetPasswordToken: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) throw new BadRequestException("User not found");
|
if (!user) return;
|
||||||
|
|
||||||
// Delete old reset password token
|
// Delete old reset password token
|
||||||
if (user.resetPasswordToken) {
|
if (user.resetPasswordToken) {
|
||||||
|
|||||||
@@ -26,7 +26,13 @@ export class FileController {
|
|||||||
@SkipThrottle()
|
@SkipThrottle()
|
||||||
@UseGuards(CreateShareGuard, ShareOwnerGuard)
|
@UseGuards(CreateShareGuard, ShareOwnerGuard)
|
||||||
async create(
|
async create(
|
||||||
@Query() query: any,
|
@Query()
|
||||||
|
query: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
chunkIndex: string;
|
||||||
|
totalChunks: string;
|
||||||
|
},
|
||||||
@Body() body: string,
|
@Body() body: string,
|
||||||
@Param("shareId") shareId: string,
|
@Param("shareId") shareId: string,
|
||||||
) {
|
) {
|
||||||
@@ -69,6 +75,7 @@ export class FileController {
|
|||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": file.metaData.mimeType,
|
"Content-Type": file.metaData.mimeType,
|
||||||
"Content-Length": file.metaData.size,
|
"Content-Length": file.metaData.size,
|
||||||
|
"Content-Security-Policy": "script-src 'none'",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (download === "true") {
|
if (download === "true") {
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import { ClassSerializerInterceptor, ValidationPipe } from "@nestjs/common";
|
import {
|
||||||
|
ClassSerializerInterceptor,
|
||||||
|
Logger,
|
||||||
|
ValidationPipe,
|
||||||
|
} from "@nestjs/common";
|
||||||
import { NestFactory, Reflector } from "@nestjs/core";
|
import { NestFactory, Reflector } from "@nestjs/core";
|
||||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||||
import * as bodyParser from "body-parser";
|
import * as bodyParser from "body-parser";
|
||||||
import * as cookieParser from "cookie-parser";
|
import * as cookieParser from "cookie-parser";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AppModule } from "./app.module";
|
import { AppModule } from "./app.module";
|
||||||
import { DATA_DIRECTORY } from "./constants";
|
|
||||||
import { ConfigService } from "./config/config.service";
|
import { ConfigService } from "./config/config.service";
|
||||||
|
import { DATA_DIRECTORY } from "./constants";
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||||
@@ -15,12 +20,14 @@ async function bootstrap() {
|
|||||||
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
|
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
|
||||||
|
|
||||||
const config = app.get<ConfigService>(ConfigService);
|
const config = app.get<ConfigService>(ConfigService);
|
||||||
app.use(
|
|
||||||
|
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||||
|
const chunkSize = config.get("share.chunkSize");
|
||||||
bodyParser.raw({
|
bodyParser.raw({
|
||||||
type: "application/octet-stream",
|
type: "application/octet-stream",
|
||||||
limit: `${config.get("share.chunkSize")}B`,
|
limit: `${chunkSize}B`,
|
||||||
}),
|
})(req, res, next);
|
||||||
);
|
});
|
||||||
|
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.set("trust proxy", true);
|
app.set("trust proxy", true);
|
||||||
@@ -42,5 +49,8 @@ async function bootstrap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await app.listen(parseInt(process.env.PORT) || 8080);
|
await app.listen(parseInt(process.env.PORT) || 8080);
|
||||||
|
|
||||||
|
const logger = new Logger("UnhandledAsyncError");
|
||||||
|
process.on("unhandledRejection", (e) => logger.error(e));
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pingvin-share-frontend",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pingvin-share-frontend",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
"@emotion/server": "^11.11.0",
|
"@emotion/server": "^11.11.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pingvin-share-frontend",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import useTranslate from "../../hooks/useTranslate.hook";
|
|||||||
import authService from "../../services/auth.service";
|
import authService from "../../services/auth.service";
|
||||||
import { getOAuthIcon, getOAuthUrl } from "../../utils/oauth.util";
|
import { getOAuthIcon, getOAuthUrl } from "../../utils/oauth.util";
|
||||||
import toast from "../../utils/toast.util";
|
import toast from "../../utils/toast.util";
|
||||||
|
import { safeRedirectPath } from "../../utils/router.util";
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
or: {
|
or: {
|
||||||
@@ -98,7 +99,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
router.replace(redirectPath);
|
router.replace(safeRedirectPath(redirectPath));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(toast.axiosError);
|
.catch(toast.axiosError);
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ import {
|
|||||||
PinInput,
|
PinInput,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { useForm, yupResolver } from "@mantine/form";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import { useState } from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
import * as yup from "yup";
|
import * as yup from "yup";
|
||||||
import useTranslate from "../../hooks/useTranslate.hook";
|
import useTranslate from "../../hooks/useTranslate.hook";
|
||||||
import { useForm, yupResolver } from "@mantine/form";
|
|
||||||
import { useState } from "react";
|
|
||||||
import authService from "../../services/auth.service";
|
|
||||||
import toast from "../../utils/toast.util";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import useUser from "../../hooks/user.hook";
|
import useUser from "../../hooks/user.hook";
|
||||||
|
import authService from "../../services/auth.service";
|
||||||
|
import { safeRedirectPath } from "../../utils/router.util";
|
||||||
|
import toast from "../../utils/toast.util";
|
||||||
|
|
||||||
function TotpForm({ redirectPath }: { redirectPath: string }) {
|
function TotpForm({ redirectPath }: { redirectPath: string }) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
@@ -46,7 +47,7 @@ function TotpForm({ redirectPath }: { redirectPath: string }) {
|
|||||||
router.query.loginToken as string,
|
router.query.loginToken as string,
|
||||||
);
|
);
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
await router.replace(redirectPath);
|
await router.replace(safeRedirectPath(redirectPath));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.axiosError(e);
|
toast.axiosError(e);
|
||||||
form.setFieldError("code", "error");
|
form.setFieldError("code", "error");
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import {
|
import { Button, Container, createStyles, Group, Title } from "@mantine/core";
|
||||||
Button,
|
|
||||||
Container,
|
|
||||||
createStyles,
|
|
||||||
Group,
|
|
||||||
Text,
|
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Meta from "../components/Meta";
|
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
import Meta from "../components/Meta";
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -21,19 +14,13 @@ const useStyles = createStyles((theme) => ({
|
|||||||
fontWeight: 900,
|
fontWeight: 900,
|
||||||
fontSize: 220,
|
fontSize: 220,
|
||||||
lineHeight: 1,
|
lineHeight: 1,
|
||||||
marginBottom: `calc(${theme.spacing.xl} * 100)`,
|
marginBottom: 20,
|
||||||
color: theme.colors.gray[2],
|
color: theme.colors.gray[2],
|
||||||
|
|
||||||
[theme.fn.smallerThan("sm")]: {
|
[theme.fn.smallerThan("sm")]: {
|
||||||
fontSize: 120,
|
fontSize: 120,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
description: {
|
|
||||||
maxWidth: 500,
|
|
||||||
margin: "auto",
|
|
||||||
marginBottom: `calc(${theme.spacing.xl} * 100)`,
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const ErrorNotFound = () => {
|
const ErrorNotFound = () => {
|
||||||
@@ -47,12 +34,7 @@ const ErrorNotFound = () => {
|
|||||||
<Title align="center" order={3}>
|
<Title align="center" order={3}>
|
||||||
<FormattedMessage id="404.description" />
|
<FormattedMessage id="404.description" />
|
||||||
</Title>
|
</Title>
|
||||||
<Text
|
<Group position="center" mt={50}>
|
||||||
color="dimmed"
|
|
||||||
align="center"
|
|
||||||
className={classes.description}
|
|
||||||
></Text>
|
|
||||||
<Group position="center">
|
|
||||||
<Button component={Link} href="/" variant="light">
|
<Button component={Link} href="/" variant="light">
|
||||||
<FormattedMessage id="404.button.home" />
|
<FormattedMessage id="404.button.home" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Meta from "../components/Meta";
|
|||||||
import useTranslate from "../hooks/useTranslate.hook";
|
import useTranslate from "../hooks/useTranslate.hook";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
import { safeRedirectPath } from "../utils/router.util";
|
||||||
|
|
||||||
const useStyle = createStyles({
|
const useStyle = createStyles({
|
||||||
title: {
|
title: {
|
||||||
@@ -39,7 +40,9 @@ export default function Error() {
|
|||||||
</Text>
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
mt="xl"
|
mt="xl"
|
||||||
onClick={() => router.push((router.query.redirect as string) || "/")}
|
onClick={() =>
|
||||||
|
router.push(safeRedirectPath(router.query.redirect as string))
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{t("error.button.back")}
|
{t("error.button.back")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { setCookie } from "cookies-next";
|
import { deleteCookie, setCookie } from "cookies-next";
|
||||||
import mime from "mime-types";
|
import mime from "mime-types";
|
||||||
import { FileUploadResponse } from "../types/File.type";
|
import { FileUploadResponse } from "../types/File.type";
|
||||||
|
|
||||||
@@ -16,7 +16,9 @@ const create = async (share: CreateShare) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const completeShare = async (id: string) => {
|
const completeShare = async (id: string) => {
|
||||||
return (await api.post(`shares/${id}/complete`)).data;
|
const response = (await api.post(`shares/${id}/complete`)).data;
|
||||||
|
deleteCookie("reverse_share_token");
|
||||||
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
const revertComplete = async (id: string) => {
|
const revertComplete = async (id: string) => {
|
||||||
|
|||||||
7
frontend/src/utils/router.util.ts
Normal file
7
frontend/src/utils/router.util.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export function safeRedirectPath(path: string | undefined) {
|
||||||
|
if (!path) return "/";
|
||||||
|
|
||||||
|
if (!path.startsWith("/")) return `/${path}`;
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pingvin-share",
|
"name": "pingvin-share",
|
||||||
"version": "0.23.0",
|
"version": "0.23.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "cd frontend && npm run format && cd ../backend && npm run format",
|
"format": "cd frontend && npm run format && cd ../backend && npm run format",
|
||||||
"lint": "cd frontend && npm run lint && cd ../backend && npm run lint",
|
"lint": "cd frontend && npm run lint && cd ../backend && npm run lint",
|
||||||
|
|||||||
Reference in New Issue
Block a user