Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/events/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ const sentValidationErrors = new QuickLRU({
maxAge: 1000 * 60,
})

// We use a LRU cache & a hash of the error message
// to prevent sending multiple validation errors that can spam requests to Hydro
const getValidationErrorHash = (validateErrors: ErrorObject[]) => {
// limit to 10 second windows
const window: Number = Math.floor(new Date().getTime() / 10000)
return `${window}:${(validateErrors || [])
.map((error: ErrorObject) => error.message + error.instancePath + JSON.stringify(error.params))
.join(':')}`
}

router.post(
'/',
catchMiddlewareError(async function postEvents(req: ExtendedRequest, res: Response) {
Expand All @@ -47,15 +57,6 @@ router.post(
const validEvents: any[] = []
const validationErrors: any[] = []

// We use a LRU cache & a hash of the request IP + error message
// to prevent sending multiple validation errors per user that can spam requests to Hydro
const getValidationErrorHash = (validateErrors: ErrorObject[]) =>
`${req.ip}:${(validateErrors || [])
.map(
(error: ErrorObject) => error.message + error.instancePath + JSON.stringify(error.params),
)
.join(':')}`

for (const eventBody of eventsToProcess) {
try {
// Skip event if it doesn't have a type or if the type is not in the allowed types
Expand Down
1 change: 0 additions & 1 deletion src/frame/middleware/render-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default async function renderPage(req: ExtendedRequest, res: Response) {

statsd.increment(STATSD_KEY_404, 1, [
`url:${req.url}`,
`ip:${req.ip}`,
`path:${req.path}`,
`referer:${req.headers.referer || ''}`,
])
Expand Down
8 changes: 7 additions & 1 deletion src/search/components/input/SearchOverlay.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
width: searchVariables.$smSearchOverlayWidth !important;
max-width: 100%;
height: auto;
max-height: 90vh;
max-height: 95vh;
overflow-y: auto;

display: flex;
Expand Down Expand Up @@ -67,6 +67,12 @@
padding: 5px 16px 13px 16px;
width: 100%;
background-color: var(--overlay-bgColor);
overflow-y: auto;
min-height: 15vh;

@include breakpoint(sm) {
min-height: fit-content !important;
}
}

.betaToken {
Expand Down
2 changes: 1 addition & 1 deletion src/shielding/middleware/handle-invalid-nextjs-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function handleInvalidNextPaths(
) {
defaultCacheControl(res)

const tags = [`ip:${req.ip}`, `path:${req.path}`]
const tags = [`path:${req.path}`]
statsd.increment(STATSD_KEY, 1, tags)

return res.status(404).type('text').send('Not found')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ export default function handleInvalidQuerystringValues(
if (sp.toString()) newURL += `?${sp}`
res.redirect(302, newURL)

const tags = [
'response:302',
`url:${req.url}`,
`ip:${req.ip}`,
`path:${req.path}`,
`key:${key}`,
]
const tags = ['response:302', `url:${req.url}`, `path:${req.path}`, `key:${key}`]
statsd.increment(STATSD_KEY, 1, tags)

return
Expand Down
2 changes: 0 additions & 2 deletions src/shielding/middleware/handle-invalid-query-strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default function handleInvalidQuerystrings(
const tags = [
'response:400',
`url:${req.url}`,
`ip:${req.ip}`,
`path:${req.path}`,
`keys:${originalKeys.length}`,
]
Expand Down Expand Up @@ -123,7 +122,6 @@ export default function handleInvalidQuerystrings(
const tags = [
'response:302',
`url:${req.url}`,
`ip:${req.ip}`,
`path:${req.path}`,
`keys:${originalKeys.length}`,
]
Expand Down
Loading