Skip to content

Commit bb26aec

Browse files
Proximystmacabu
andauthored
fix: remove image scaling feature (#834)
Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
1 parent f200016 commit bb26aec

File tree

6 files changed

+539
-618
lines changed

6 files changed

+539
-618
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.1.3 (2025-10-29)
2+
3+
- fix: remove image scaling feature (CVE-2023-34152), [#834](https://github.com/grafana/grafana-image-renderer/pull/834), [Proximyst](https://github.com/proximyst)
4+
15
## 4.1.2 (2025-10-24)
26

37
This release does not change the current Grafana Image Renderer, it is only issued to release new tags of the `-golang` variants for further testing.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
"@opentelemetry/sdk-node": "^0.52.1",
3636
"@opentelemetry/semantic-conventions": "^1.25.1",
3737
"@puppeteer/browsers": "^2.3.1",
38+
"body-parser": "^2.2.0",
3839
"chokidar": "^3.5.2",
40+
"content-disposition": "^0.5.4",
3941
"dompurify": "^3.2.4",
4042
"express": "^4.21.1",
4143
"express-prom-bundle": "^6.5.0",
4244
"ioredis": "^5.6.1",
43-
"jimp": "^0.22.12",
4445
"jsdom": "20.0.0",
4546
"lodash": "^4.17.21",
4647
"minimist": "^1.2.6",
@@ -52,14 +53,14 @@
5253
"puppeteer": "^22.8.2",
5354
"puppeteer-cluster": "^0.24.0",
5455
"rate-limiter-flexible": "^7.0.0",
55-
"tar-fs": "^3.1.1",
5656
"unique-filename": "^2.0.1",
5757
"winston": "^3.8.2"
5858
},
5959
"devDependencies": {
6060
"@eslint/js": "^9.31.0",
6161
"@grafana/eslint-config": "^8.1.0",
6262
"@grafana/sign-plugin": "^3.1.3",
63+
"@jest/reporters": "^30.2.0",
6364
"@stylistic/eslint-plugin-ts": "^4.4.1",
6465
"@types/content-disposition": "^0.5.9",
6566
"@types/express": "^4.17.14",
@@ -86,6 +87,7 @@
8687
"jest": "^29.7.0",
8788
"jsonwebtoken": "^9.0.2",
8889
"lint-staged": "13.0.3",
90+
"pixelmatch": "^4.0.2",
8991
"prettier": "2.7.1",
9092
"supertest": "^7.0.0",
9193
"ts-jest": "^29.1.1",

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"url": "https://github.com/grafana/grafana-image-renderer/blob/master/LICENSE"
2525
}
2626
],
27-
"version": "4.1.2",
28-
"updated": "2025-10-24"
27+
"version": "4.1.3",
28+
"updated": "2025-10-29"
2929
},
3030
"dependencies": {
3131
"grafanaDependency": ">=11.3.8"

src/browser/browser.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import chokidar from 'chokidar';
66
import path from 'path';
77
import fs from 'fs';
88
import promClient from 'prom-client';
9-
import Jimp from 'jimp';
109
import { Logger } from '../logger';
1110
import { RenderingConfig } from '../config/rendering';
1211
import { HTTPHeaders, ImageRenderOptions, RenderOptions } from '../types';
@@ -106,19 +105,7 @@ export class Browser {
106105
}
107106

108107
options.deviceScaleFactor = parseFloat(((options.deviceScaleFactor as string) || '1') as string) || 1;
109-
110-
// Scaled thumbnails
111-
if (options.deviceScaleFactor <= 0) {
112-
options.scaleImage = options.deviceScaleFactor * -1;
113-
options.deviceScaleFactor = 1;
114-
115-
if (options.scaleImage > 1) {
116-
options.width *= options.scaleImage;
117-
options.height *= options.scaleImage;
118-
} else {
119-
options.scaleImage = undefined;
120-
}
121-
} else if (options.deviceScaleFactor > this.config.maxDeviceScaleFactor) {
108+
if (options.deviceScaleFactor > this.config.maxDeviceScaleFactor) {
122109
options.deviceScaleFactor = this.config.deviceScaleFactor;
123110
}
124111
}
@@ -408,24 +395,6 @@ export class Browser {
408395
return page.screenshot({ path: options.filePath, fullPage: options.fullPageImage, captureBeyondViewport: false });
409396
});
410397

411-
if (options.scaleImage && !isPDF) {
412-
await this.performStep('imageResize', options.url, signal, async () => {
413-
const scaled = `${options.filePath}_${Date.now()}_scaled.png`;
414-
const w = +options.width / options.scaleImage!;
415-
const h = +options.height / options.scaleImage!;
416-
417-
const file = await Jimp.read(options.filePath);
418-
await file
419-
.resize(w, h)
420-
// .toFormat('webp', {
421-
// quality: 70, // 80 is default
422-
// })
423-
.writeAsync(scaled);
424-
425-
fs.renameSync(scaled, options.filePath);
426-
});
427-
}
428-
429398
return { filePath: options.filePath };
430399
}
431400

src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ export interface ImageRenderOptions extends RenderOptions {
2424

2525
// Runtime options derived from the input
2626
fullPageImage?: boolean;
27-
scaleImage?: number;
2827
}

0 commit comments

Comments
 (0)