Skip to content

Commit

Permalink
fix: block invalid path
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 committed Jun 18, 2024
1 parent 4580de3 commit 0700bda
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getErrorMessage } from './utils'
export const GET_PROXY_ENDPOINTS = ['/chunks/*', '/bytes/*', '/bzz/*', '/feeds/*']
export const POST_PROXY_ENDPOINTS = ['/chunks', '/bytes', '/bzz', '/soc/*', '/feeds/*']

const BAD_PATH = `bzz/${'00'.repeat(32)}`
const SWARM_STAMP_HEADER = 'swarm-postage-batch-id'
const SWARM_PIN_HEADER = 'swarm-pin'

Expand Down Expand Up @@ -57,6 +58,11 @@ export function createProxyEndpoints(app: Application, options: Options) {
}
})
app.get(GET_PROXY_ENDPOINTS, async (req, res) => {
if (req.path.includes(BAD_PATH)) {
res.status(400)
res.send({ error: 'bad path' })
return

Check failure on line 64 in src/proxy.ts

View workflow job for this annotation

GitHub Actions / check (14.x)

Expected blank line before this statement
}
await fetchAndRespond('GET', req.path, req.query, req.headers, req.body, res, options)
})
app.post(POST_PROXY_ENDPOINTS, async (req, res) => {
Expand Down

0 comments on commit 0700bda

Please sign in to comment.