Skip to content

Commit

Permalink
codeql sanitize
Browse files Browse the repository at this point in the history
  • Loading branch information
acalcutt committed Jan 4, 2025
1 parent bc85d7a commit 4fe9bda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/serve_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ export const serve_style = {
*/
app.get(`/:id/sprite{/:spriteID}{@:scale}{.:format}`, (req, res, next) => {
const { spriteID = 'default', id, format, scale } = req.params;
const sanitizedId = String(id);
const sanitizedScale = scale ? String(scale) : '';
const sanitizedSpriteID = String(spriteID);
const sanitizedFormat = format ? '.' + String(format) : '';
if (verbose) {
console.log(
`Handling sprite request for: /styles/%s/sprite/%s%s%s`,
id,
sanitizedId,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedSpriteID,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedScale,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedFormat,
Expand All @@ -118,7 +119,7 @@ export const serve_style = {
if (verbose)
console.error(
`Sprite item, format, or scale not found for: /styles/%s/sprite/%s%s%s`,
id,
sanitizedId,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedSpriteID,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedScale,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedFormat,
Expand All @@ -132,7 +133,7 @@ export const serve_style = {
if (verbose)
console.error(
`Sprite not found for: /styles/%s/sprite/%s%s%s`,
id,
sanitizedId,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedSpriteID,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedScale,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedFormat,
Expand All @@ -155,7 +156,6 @@ export const serve_style = {
);
return res.sendStatus(404);
}

if (validatedFormat === 'json') {
res.header('Content-type', 'application/json');
} else if (validatedFormat === 'png') {
Expand All @@ -164,7 +164,7 @@ export const serve_style = {
if (verbose)
console.log(
`Responding with sprite data for /styles/%s/sprite/%s%s%s`,
id,
sanitizedId,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedSpriteID,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedScale,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
sanitizedFormat,

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
Expand Down

0 comments on commit 4fe9bda

Please sign in to comment.