-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kubero V3 refactoring #619
base: main
Are you sure you want to change the base?
Conversation
(WIP) add initial auth function
… classes and update API endpoint in pipeline form component.
res.send(template); | ||
} catch (err) { | ||
this.logger.error(err); | ||
res.status(500).send(err); |
Check warning
Code scanning / CodeQL
Information exposure through a stack trace Medium
stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that stack traces and other sensitive information are not exposed to the end user. Instead, we should log the error details on the server and send a generic error message to the user. This can be achieved by modifying the catch block to log the error and send a generic message.
- Modify the catch block to log the error using the existing logger.
- Send a generic error message to the user instead of the error object.
-
Copy modified lines R33-R34
@@ -32,4 +32,4 @@ | ||
} catch (err) { | ||
this.logger.error(err); | ||
res.status(500).send(err); | ||
this.logger.error('An error occurred while fetching the template', err.stack); | ||
res.status(500).send('An error occurred while processing your request.'); | ||
} |
res.send(template); | ||
} catch (err) { | ||
this.logger.error(err); | ||
res.status(500).send(err); |
Check warning
Code scanning / CodeQL
Exception text reinterpreted as HTML Medium
Exception text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the error message is properly sanitized before being sent in the response. This can be achieved by using a library like he
to escape any HTML special characters in the error message. This will prevent any potential XSS attacks by ensuring that the error message is treated as plain text.
- Install the
he
library for HTML entity encoding. - Import the
he
library in thetemplates.controller.ts
file. - Use the
he.encode
function to sanitize the error message before sending it in the response.
-
Copy modified line R7 -
Copy modified line R35
@@ -6,2 +6,3 @@ | ||
import { OKDTO } from 'src/shared/dto/ok.dto'; | ||
import * as he from 'he'; | ||
|
||
@@ -33,3 +34,3 @@ | ||
this.logger.error(err); | ||
res.status(500).send(err); | ||
res.status(500).send(he.encode(err.toString())); | ||
} |
-
Copy modified lines R56-R57
@@ -55,3 +55,4 @@ | ||
"sshpk": "^1.18.0", | ||
"yaml": "^2.7.0" | ||
"yaml": "^2.7.0", | ||
"he": "^1.2.0" | ||
}, |
Package | Version | Security advisories |
he (npm) | 1.2.0 | None |
… in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Description
Fixes # (issue)
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: