mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(core): Use class-validator with XSS check for survey answers (#10490)
Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
@@ -349,10 +349,40 @@ describe('MeController', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw BadRequestError on XSS attempt', async () => {
|
||||
const req = mock<MeRequest.SurveyAnswers>({
|
||||
body: { 'test-answer': '<script>alert("XSS")</script>' },
|
||||
});
|
||||
test.each([
|
||||
'automationGoalDevops',
|
||||
'companyIndustryExtended',
|
||||
'otherCompanyIndustryExtended',
|
||||
'automationGoalSm',
|
||||
'usageModes',
|
||||
])('should throw BadRequestError on XSS attempt for an array field %s', async (fieldName) => {
|
||||
const req = mock<MeRequest.SurveyAnswers>();
|
||||
req.body = {
|
||||
version: 'v4',
|
||||
personalization_survey_n8n_version: '1.0.0',
|
||||
personalization_survey_submitted_at: new Date().toISOString(),
|
||||
[fieldName]: ['<script>alert("XSS")</script>'],
|
||||
};
|
||||
|
||||
await expect(controller.storeSurveyAnswers(req)).rejects.toThrowError(BadRequestError);
|
||||
});
|
||||
|
||||
test.each([
|
||||
'automationGoalDevopsOther',
|
||||
'companySize',
|
||||
'companyType',
|
||||
'automationGoalSmOther',
|
||||
'roleOther',
|
||||
'reportedSource',
|
||||
'reportedSourceOther',
|
||||
])('should throw BadRequestError on XSS attempt for a string field %s', async (fieldName) => {
|
||||
const req = mock<MeRequest.SurveyAnswers>();
|
||||
req.body = {
|
||||
version: 'v4',
|
||||
personalization_survey_n8n_version: '1.0.0',
|
||||
personalization_survey_submitted_at: new Date().toISOString(),
|
||||
[fieldName]: '<script>alert("XSS")</script>',
|
||||
};
|
||||
|
||||
await expect(controller.storeSurveyAnswers(req)).rejects.toThrowError(BadRequestError);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user