-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ADO-2365-update-design-system
* master: fix(editor): Add workflow scopes when initializing workflow (#10455) feat(editor): Improve node label readability in new canvas (no-changelog) (#10432) fix(editor): Fix lazy loaded component not using suspense (no-changelog) (#10454) fix(editor): Buffer json chunks in stream response (#10439) refactor(editor): Remove `id` param from PATCH /me calls (no-changelog) (#10449) fix(core): Fix XSS validation and separate URL validation (#10424) fix(Respond to Webhook Node): Fix issue preventing the chat trigger from working (#9886) feat(editor): Add `registerCustomAction` to new canvas (no-changelog) (#10359)
- Loading branch information
Showing
31 changed files
with
555 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow'; | ||
|
||
const WorkflowPage = new WorkflowPageClass(); | ||
|
||
describe('PAY-1858 context menu', () => { | ||
it('can use context menu on saved workflow', () => { | ||
WorkflowPage.actions.visit(); | ||
cy.createFixtureWorkflow('Test_workflow_filter.json', 'test'); | ||
|
||
WorkflowPage.getters.canvasNodes().should('have.length', 5); | ||
WorkflowPage.actions.deleteNodeFromContextMenu('Then'); | ||
WorkflowPage.getters.canvasNodes().should('have.length', 4); | ||
|
||
WorkflowPage.actions.hitSaveWorkflow(); | ||
|
||
cy.reload(); | ||
WorkflowPage.getters.canvasNodes().should('have.length', 4); | ||
WorkflowPage.actions.deleteNodeFromContextMenu('Code'); | ||
WorkflowPage.getters.canvasNodes().should('have.length', 3); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
packages/cli/src/databases/utils/__tests__/customValidators.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/cli/src/validators/__tests__/no-url.validator.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { NoUrl } from '../no-url.validator'; | ||
import { validate } from 'class-validator'; | ||
|
||
describe('NoUrl', () => { | ||
class Entity { | ||
@NoUrl() | ||
name = ''; | ||
} | ||
|
||
const entity = new Entity(); | ||
|
||
describe('URLs', () => { | ||
const URLS = ['http://google.com', 'www.domain.tld']; | ||
|
||
for (const str of URLS) { | ||
test(`should block ${str}`, async () => { | ||
entity.name = str; | ||
const errors = await validate(entity); | ||
expect(errors).toHaveLength(1); | ||
const [error] = errors; | ||
expect(error.property).toEqual('name'); | ||
expect(error.constraints).toEqual({ NoUrl: 'Potentially malicious string' }); | ||
}); | ||
} | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
packages/cli/src/validators/__tests__/no-xss.validator.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { NoXss } from '../no-xss.validator'; | ||
import { validate } from 'class-validator'; | ||
|
||
describe('NoXss', () => { | ||
class Entity { | ||
@NoXss() | ||
name = ''; | ||
|
||
@NoXss() | ||
timestamp = ''; | ||
|
||
@NoXss() | ||
version = ''; | ||
} | ||
|
||
const entity = new Entity(); | ||
|
||
describe('Scripts', () => { | ||
const XSS_STRINGS = ['<script src/>', "<script>alert('xss')</script>"]; | ||
|
||
for (const str of XSS_STRINGS) { | ||
test(`should block ${str}`, async () => { | ||
entity.name = str; | ||
const errors = await validate(entity); | ||
expect(errors).toHaveLength(1); | ||
const [error] = errors; | ||
expect(error.property).toEqual('name'); | ||
expect(error.constraints).toEqual({ NoXss: 'Potentially malicious string' }); | ||
}); | ||
} | ||
}); | ||
|
||
describe('Names', () => { | ||
const VALID_NAMES = [ | ||
'Johann Strauß', | ||
'Вагиф Сәмәдоғлу', | ||
'René Magritte', | ||
'সুকুমার রায়', | ||
'མགོན་པོ་རྡོ་རྗེ།', | ||
'عبدالحليم حافظ', | ||
]; | ||
|
||
for (const name of VALID_NAMES) { | ||
test(`should allow ${name}`, async () => { | ||
entity.name = name; | ||
expect(await validate(entity)).toBeEmptyArray(); | ||
}); | ||
} | ||
}); | ||
|
||
describe('ISO-8601 timestamps', () => { | ||
const VALID_TIMESTAMPS = ['2022-01-01T00:00:00.000Z', '2022-01-01T00:00:00.000+02:00']; | ||
|
||
for (const timestamp of VALID_TIMESTAMPS) { | ||
test(`should allow ${timestamp}`, async () => { | ||
entity.timestamp = timestamp; | ||
await expect(validate(entity)).resolves.toBeEmptyArray(); | ||
}); | ||
} | ||
}); | ||
|
||
describe('Semver versions', () => { | ||
const VALID_VERSIONS = ['1.0.0', '1.0.0-alpha.1']; | ||
|
||
for (const version of VALID_VERSIONS) { | ||
test(`should allow ${version}`, async () => { | ||
entity.version = version; | ||
await expect(validate(entity)).resolves.toBeEmptyArray(); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { ValidationOptions, ValidatorConstraintInterface } from 'class-validator'; | ||
import { registerDecorator, ValidatorConstraint } from 'class-validator'; | ||
|
||
const URL_REGEX = /^(https?:\/\/|www\.)/i; | ||
|
||
@ValidatorConstraint({ name: 'NoUrl', async: false }) | ||
class NoUrlConstraint implements ValidatorConstraintInterface { | ||
validate(value: string) { | ||
return !URL_REGEX.test(value); | ||
} | ||
|
||
defaultMessage() { | ||
return 'Potentially malicious string'; | ||
} | ||
} | ||
|
||
export function NoUrl(options?: ValidationOptions) { | ||
return function (object: object, propertyName: string) { | ||
registerDecorator({ | ||
name: 'NoUrl', | ||
target: object.constructor, | ||
propertyName, | ||
options, | ||
validator: NoUrlConstraint, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { ValidationOptions, ValidatorConstraintInterface } from 'class-validator'; | ||
import { registerDecorator, ValidatorConstraint } from 'class-validator'; | ||
import sanitizeHtml from 'sanitize-html'; | ||
|
||
@ValidatorConstraint({ name: 'NoXss', async: false }) | ||
class NoXssConstraint implements ValidatorConstraintInterface { | ||
validate(value: string) { | ||
return value === sanitizeHtml(value, { allowedTags: [], allowedAttributes: {} }); | ||
} | ||
|
||
defaultMessage() { | ||
return 'Potentially malicious string'; | ||
} | ||
} | ||
|
||
export function NoXss(options?: ValidationOptions) { | ||
return function (object: object, propertyName: string) { | ||
registerDecorator({ | ||
name: 'NoXss', | ||
target: object.constructor, | ||
propertyName, | ||
options, | ||
validator: NoXssConstraint, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.