Skip to content

Commit e616dd7

Browse files
fix: update rules for image-proxy (#1748)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 2215a36 commit e616dd7

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

nuxt.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ export default defineNuxtConfig({
107107
allowQuery: ['color', 'labelColor', 'label', 'name', 'style'],
108108
},
109109
},
110+
'/api/registry/image-proxy': {
111+
isr: {
112+
expiration: 60 * 60 /* one hour */,
113+
passQuery: true,
114+
allowQuery: ['url', 'sig'],
115+
},
116+
},
110117
'/api/registry/downloads/**': {
111118
isr: {
112119
expiration: 60 * 60 /* one hour */,

server/api/registry/image-proxy/index.get.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ export default defineEventHandler(async event => {
156156

157157
const contentType = response.headers.get('content-type') || 'application/octet-stream'
158158

159-
// Only allow raster/vector image content types, but block SVG to prevent
160-
// embedded JavaScript execution (SVGs can contain <script> tags, event handlers, etc.)
161-
if (!contentType.startsWith('image/') || contentType.includes('svg')) {
159+
// Allow raster/vector image content types (we don't inject external content into DOM, so SVG is allowed too)
160+
if (!contentType.startsWith('image/')) {
162161
await response.body?.cancel()
163162
throw createError({
164163
statusCode: 400,

server/utils/image-proxy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ const TRUSTED_IMAGE_DOMAINS = [
4141
'repository-images.githubusercontent.com',
4242
'github.githubassets.com',
4343
'objects.githubusercontent.com',
44+
'avatars2.githubusercontent.com',
45+
'cloud.githubusercontent.com',
4446

4547
// GitLab
4648
'gitlab.com',
4749

4850
// CDNs commonly used in READMEs
4951
'cdn.jsdelivr.net',
52+
'data.jsdelivr.com',
5053
'unpkg.com',
5154

5255
// Well-known badge/shield services
@@ -63,6 +66,16 @@ const TRUSTED_IMAGE_DOMAINS = [
6366
'api.codeclimate.com',
6467
'bundlephobia.com',
6568
'packagephobia.com',
69+
'deepwiki.com',
70+
'saucelabs.github.io',
71+
'opencollective.com',
72+
'circleci.com',
73+
'www.codetriage.com',
74+
'badges.gitter.im',
75+
'nodei.co',
76+
'travis-ci.org',
77+
'secure.travis-ci.org',
78+
'img.badgesize.io',
6679
]
6780

6881
/**

0 commit comments

Comments
 (0)