Skip to content

Commit f1d66ba

Browse files
committed
Merge branch 'main' of https://github.com/kyma-project/busola into adjust-ai-token-flow
2 parents b7a3950 + 73e4961 commit f1d66ba

File tree

13 files changed

+408
-4267
lines changed

13 files changed

+408
-4267
lines changed

.github/workflows/accessibility-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- 'backend/**'
1515
- 'kyma/**'
1616
- 'Dockerfile*'
17+
- 'package.json'
1718

1819
jobs:
1920
run-accessibility-tests:

.github/workflows/pull-integration-cluster-k3d.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'nginx/**'
1111
- 'src/**'
1212
- 'backend/**'
13+
- 'package.json'
1314

1415
jobs:
1516
run-cluster-test:

.github/workflows/pull-integration-namespace-k3d.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'nginx/**'
1111
- 'src/**'
1212
- 'backend/**'
13+
- 'package.json'
1314

1415
jobs:
1516
run-namespace-test:

.github/workflows/pull-kyma-integration-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- 'backend/**'
1313
- 'kyma/**'
1414
- 'Dockerfile*'
15+
- 'package.json'
1516
jobs:
1617
run-integration-test:
1718
runs-on: ubuntu-latest

.github/workflows/pull-smoke-test-prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'src/**'
1212
- 'kyma/**'
1313
- 'Dockerfile*'
14+
- 'package.json'
1415

1516
jobs:
1617
run-smoke-test-prod:

.github/workflows/pull-smoke-test-stage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'src/**'
1212
- 'kyma/**'
1313
- 'Dockerfile*'
14+
- 'package.json'
1415

1516
jobs:
1617
run-smoke-test-stage:

backend/common.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const makeHandleRequest = () => {
6464
headersData = extractHeadersData(req);
6565
} catch (e) {
6666
req.log.error('Headers error:' + e.message);
67-
res.contentType('text/plain');
67+
res.contentType('text/plain; charset=utf-8');
6868
res.status(400).send('Headers are missing or in a wrong format.');
6969
return;
7070
}
@@ -73,7 +73,7 @@ export const makeHandleRequest = () => {
7373
filters.forEach(filter => filter(req, headersData));
7474
} catch (e) {
7575
req.log.error('Filters rejected the request: ' + e.message);
76-
res.contentType('text/plain');
76+
res.contentType('text/plain; charset=utf-8');
7777
res.status(400).send('Request ID: ' + escape(req.id));
7878
return;
7979
}
@@ -88,7 +88,6 @@ export const makeHandleRequest = () => {
8888
hostname: targetApiServer.hostname,
8989
path: req.originalUrl.replace(/^\/backend/, ''),
9090
headers,
91-
body: req.body,
9291
method: req.method,
9392
port: targetApiServer.port || 443,
9493
ca,
@@ -111,19 +110,31 @@ export const makeHandleRequest = () => {
111110
const statusCode =
112111
k8sResponse.statusCode === 503 ? 502 : k8sResponse.statusCode;
113112

113+
// Ensure charset is specified in content type
114+
let contentType = k8sResponse.headers['Content-Type'] || 'text/json';
115+
if (!contentType.includes('charset=')) {
116+
contentType += '; charset=utf-8';
117+
}
118+
114119
res.writeHead(statusCode, {
115-
'Content-Type': k8sResponse.headers['Content-Type'] || 'text/json',
120+
'Content-Type': contentType,
116121
'Content-Encoding': k8sResponse.headers['content-encoding'] || '',
122+
'X-Content-Type-Options': 'nosniff',
117123
});
118124
k8sResponse.pipe(res);
119125
});
120126
k8sRequest.on('error', throwInternalServerError); // no need to sanitize the error here as the http.request() will never throw a vulnerable error
121-
k8sRequest.end(Buffer.isBuffer(req.body) ? req.body : undefined);
122-
req.pipe(k8sRequest);
127+
128+
if (Buffer.isBuffer(req.body)) {
129+
k8sRequest.end(req.body);
130+
} else {
131+
// If there's no body, pipe the request (for streaming)
132+
req.pipe(k8sRequest);
133+
}
123134

124135
function throwInternalServerError(originalError) {
125136
req.log.warn(originalError);
126-
res.contentType('text/plain');
137+
res.contentType('text/plain; charset=utf-8');
127138
res
128139
.status(502)
129140
.send('Internal server error. Request ID: ' + escape(req.id));

0 commit comments

Comments
 (0)