Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
342
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
28
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
3ec00398
Verified
Commit
3ec00398
authored
1 year ago
by
Marie
Browse files
Options
Downloads
Patches
Plain Diff
fix: security with notes/show endpoint
parent
233eff48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/backend/src/server/api/endpoints/notes/show.ts
+22
-7
22 additions, 7 deletions
packages/backend/src/server/api/endpoints/notes/show.ts
with
22 additions
and
7 deletions
packages/backend/src/server/api/endpoints/notes/show.ts
+
22
−
7
View file @
3ec00398
...
...
@@ -3,10 +3,12 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
Inject
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
Endpoint
}
from
'
@/server/api/endpoint-base.js
'
;
import
{
NoteEntityService
}
from
'
@/core/entities/NoteEntityService.js
'
;
import
{
GetterService
}
from
'
@/server/api/GetterService.js
'
;
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
type
{
NotesRepository
}
from
'
@/models/_.js
'
;
import
{
QueryService
}
from
'
@/core/QueryService.js
'
;
import
{
ApiError
}
from
'
../../error.js
'
;
export
const
meta
=
{
...
...
@@ -40,14 +42,27 @@ export const paramDef = {
@
Injectable
()
export
default
class
extends
Endpoint
<
typeof
meta
,
typeof
paramDef
>
{
// eslint-disable-line import/no-default-export
constructor
(
@
Inject
(
DI
.
notesRepository
)
private
notesRepository
:
NotesRepository
,
private
noteEntityService
:
NoteEntityService
,
private
gett
erService
:
Gett
erService
,
private
qu
er
y
Service
:
Qu
er
y
Service
,
)
{
super
(
meta
,
paramDef
,
async
(
ps
,
me
)
=>
{
const
note
=
await
this
.
getterService
.
getNote
(
ps
.
noteId
).
catch
(
err
=>
{
if
(
err
.
id
===
'
9725d0ce-ba28-4dde-95a7-2cbb2c15de24
'
)
throw
new
ApiError
(
meta
.
errors
.
noSuchNote
);
throw
err
;
});
const
query
=
await
this
.
notesRepository
.
createQueryBuilder
(
'
note
'
)
.
where
(
'
note.id = :noteId
'
,
{
noteId
:
ps
.
noteId
});
this
.
queryService
.
generateVisibilityQuery
(
query
,
me
);
if
(
me
)
{
this
.
queryService
.
generateMutedUserQuery
(
query
,
me
);
this
.
queryService
.
generateBlockedUserQuery
(
query
,
me
);
}
const
note
=
await
query
.
getOne
();
if
(
note
===
null
)
{
throw
new
ApiError
(
meta
.
errors
.
noSuchNote
);
}
return
await
this
.
noteEntityService
.
pack
(
note
,
me
,
{
detail
:
true
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment