diff --git a/docs/SECURITY.md b/docs/SECURITY.md index af70a4cb2f..57d1704870 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -4,7 +4,7 @@ The Outline team takes security bugs seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions. -To report a security issue, email [hello@getoutline.com](mailto:hello@getoutline.com) and include the word "SECURITY" in the subject line. +If you discover a security vulnerability in outline, please disclose it via [our huntr page](https://huntr.dev/repos/${owner}/${repo}/). Bounty eligibility, CVE assignment, response times and past reports are all there. The Outline team will send a response indicating the next steps in handling your report. After the initial reply to your report you will be kept informed of the progress towards a fix and full announcement. diff --git a/server/routes/api/attachments.ts b/server/routes/api/attachments.ts index 095b646537..fccfc6865a 100644 --- a/server/routes/api/attachments.ts +++ b/server/routes/api/attachments.ts @@ -2,11 +2,7 @@ import Router from "koa-router"; import { v4 as uuidv4 } from "uuid"; import { bytesToHumanReadable } from "@shared/utils/files"; import { sequelize } from "@server/database/sequelize"; -import { - AuthorizationError, - NotFoundError, - ValidationError, -} from "@server/errors"; +import { AuthorizationError, ValidationError } from "@server/errors"; import auth from "@server/middlewares/authentication"; import { Attachment, Document, Event } from "@server/models"; import { authorize } from "@server/policies"; @@ -15,7 +11,7 @@ import { publicS3Endpoint, getSignedUrl, } from "@server/utils/s3"; -import { assertPresent } from "@server/validation"; +import { assertPresent, assertUuid } from "@server/validation"; const router = new Router(); const AWS_S3_ACL = process.env.AWS_S3_ACL || "private"; @@ -113,13 +109,11 @@ router.post("attachments.create", auth(), async (ctx) => { router.post("attachments.delete", auth(), async (ctx) => { const { id } = ctx.body; - assertPresent(id, "id is required"); + assertUuid(id, "id is required"); const { user } = ctx.state; - const attachment = await Attachment.findByPk(id); - - if (!attachment) { - throw NotFoundError(); - } + const attachment = await Attachment.findByPk(id, { + rejectOnEmpty: true, + }); if (attachment.documentId) { const document = await Document.findByPk(attachment.documentId, { @@ -144,13 +138,11 @@ router.post("attachments.delete", auth(), async (ctx) => { router.post("attachments.redirect", auth(), async (ctx) => { const { id } = ctx.body; - assertPresent(id, "id is required"); + assertUuid(id, "id is required"); const { user } = ctx.state; - const attachment = await Attachment.findByPk(id); - - if (!attachment) { - throw NotFoundError(); - } + const attachment = await Attachment.findByPk(id, { + rejectOnEmpty: true, + }); if (attachment.isPrivate) { if (attachment.teamId !== user.teamId) { diff --git a/server/routes/api/revisions.ts b/server/routes/api/revisions.ts index f8a94d634a..8d08f98949 100644 --- a/server/routes/api/revisions.ts +++ b/server/routes/api/revisions.ts @@ -1,23 +1,20 @@ import Router from "koa-router"; -import { NotFoundError } from "@server/errors"; import auth from "@server/middlewares/authentication"; import { Document, Revision } from "@server/models"; import { authorize } from "@server/policies"; import { presentRevision } from "@server/presenters"; -import { assertPresent, assertSort } from "@server/validation"; +import { assertPresent, assertSort, assertUuid } from "@server/validation"; import pagination from "./middlewares/pagination"; const router = new Router(); router.post("revisions.info", auth(), async (ctx) => { const { id } = ctx.body; - assertPresent(id, "id is required"); + assertUuid(id, "id is required"); const { user } = ctx.state; - const revision = await Revision.findByPk(id); - - if (!revision) { - throw NotFoundError(); - } + const revision = await Revision.findByPk(id, { + rejectOnEmpty: true, + }); const document = await Document.findByPk(revision.documentId, { userId: user.id, diff --git a/server/routes/api/searches.ts b/server/routes/api/searches.ts index 73b60bd4c9..18194c0b4e 100644 --- a/server/routes/api/searches.ts +++ b/server/routes/api/searches.ts @@ -2,7 +2,7 @@ import Router from "koa-router"; import auth from "@server/middlewares/authentication"; import { SearchQuery } from "@server/models"; import { presentSearchQuery } from "@server/presenters"; -import { assertPresent } from "@server/validation"; +import { assertPresent, assertUuid } from "@server/validation"; import pagination from "./middlewares/pagination"; const router = new Router(); @@ -28,6 +28,9 @@ router.post("searches.list", auth(), pagination(), async (ctx) => { router.post("searches.delete", auth(), async (ctx) => { const { id, query } = ctx.body; assertPresent(id || query, "id or query is required"); + if (id) { + assertUuid(id, "id is must be a uuid"); + } const { user } = ctx.state; await SearchQuery.destroy({ diff --git a/shared/editor/nodes/CodeFence.ts b/shared/editor/nodes/CodeFence.ts index ddb2034530..9d4ba1a0bd 100644 --- a/shared/editor/nodes/CodeFence.ts +++ b/shared/editor/nodes/CodeFence.ts @@ -12,6 +12,8 @@ import { Selection, TextSelection, Transaction, + Plugin, + PluginKey, } from "prosemirror-state"; import refractor from "refractor/core"; import bash from "refractor/lang/bash"; @@ -283,7 +285,26 @@ export default class CodeFence extends Node { }; get plugins() { - return [Prism({ name: this.name }), Mermaid({ name: this.name })]; + return [ + Prism({ name: this.name }), + Mermaid({ name: this.name }), + new Plugin({ + key: new PluginKey("triple-click"), + props: { + handleDOMEvents: { + mousedown(view, event) { + const { + selection: { $from, $to }, + } = view.state; + if (!isInCode(view.state)) { + return false; + } + return $from.sameParent($to) && event.detail === 3; + }, + }, + }, + }), + ]; } inputRules({ type }: { type: NodeType }) { diff --git a/shared/editor/nodes/Emoji.tsx b/shared/editor/nodes/Emoji.tsx index f07c46a5ff..2d716295dc 100644 --- a/shared/editor/nodes/Emoji.tsx +++ b/shared/editor/nodes/Emoji.tsx @@ -35,9 +35,9 @@ export default class Emoji extends Node { selectable: false, parseDOM: [ { - tag: "span.emoji", + tag: "strong.emoji", preserveWhitespace: "full", - getAttrs: (dom: HTMLDivElement) => ({ + getAttrs: (dom: HTMLElement) => ({ "data-name": dom.dataset.name, }), }, @@ -48,7 +48,7 @@ export default class Emoji extends Node { nameToEmoji[node.attrs["data-name"]] ); return [ - "span", + "strong", { class: `emoji ${node.attrs["data-name"]}`, "data-name": node.attrs["data-name"], @@ -57,7 +57,7 @@ export default class Emoji extends Node { ]; } const text = document.createTextNode(`:${node.attrs["data-name"]}:`); - return ["span", { class: "emoji" }, text]; + return ["strong", { class: "emoji" }, text]; }, toPlainText: (node) => nameToEmoji[node.attrs["data-name"]], };