Merge branch 'master' into revert-12934-revert-12930-revert-12929-revert-12769-isolated-vm

This commit is contained in:
Adria Navarro 2024-02-08 18:15:36 +01:00 committed by GitHub
commit 573096e869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 96 additions and 62 deletions

View File

@ -43,7 +43,8 @@
"no-useless-escape": "off", "no-useless-escape": "off",
"no-undef": "off", "no-undef": "off",
"no-prototype-builtins": "off", "no-prototype-builtins": "off",
"local-rules/no-budibase-imports": "error" "local-rules/no-budibase-imports": "error",
"local-rules/no-test-com": "error"
} }
}, },
{ {

View File

@ -18,4 +18,37 @@ module.exports = {
} }
}, },
}, },
"no-test-com": {
meta: {
type: "problem",
docs: {
description:
"disallow the use of 'test.com' in strings and replace it with 'example.com'",
category: "Possible Errors",
recommended: false,
},
schema: [], // no options
fixable: "code", // Indicates that this rule supports automatic fixing
},
create: function (context) {
return {
Literal(node) {
if (
typeof node.value === "string" &&
node.value.includes("test.com")
) {
context.report({
node,
message:
"test.com is a privately owned domain and could point anywhere, use example.com instead.",
fix: function (fixer) {
const newText = node.raw.replace(/test\.com/g, "example.com")
return fixer.replaceText(node, newText)
},
})
}
},
}
},
},
} }

View File

@ -44,11 +44,11 @@ describe("utils", () => {
it("gets appId from url", async () => { it("gets appId from url", async () => {
await config.doInTenant(async () => { await config.doInTenant(async () => {
const url = "http://test.com" const url = "http://example.com"
env._set("PLATFORM_URL", url) env._set("PLATFORM_URL", url)
const ctx = structures.koa.newContext() const ctx = structures.koa.newContext()
ctx.host = `${config.tenantId}.test.com` ctx.host = `${config.tenantId}.example.com`
const expected = db.generateAppID(config.tenantId) const expected = db.generateAppID(config.tenantId)
const app = structures.apps.app(expected) const app = structures.apps.app(expected)
@ -89,7 +89,7 @@ describe("utils", () => {
const ctx = structures.koa.newContext() const ctx = structures.koa.newContext()
const expected = db.generateAppID() const expected = db.generateAppID()
ctx.request.headers = { ctx.request.headers = {
referer: `http://test.com/builder/app/${expected}/design/screen_123/screens`, referer: `http://example.com/builder/app/${expected}/design/screen_123/screens`,
} }
const actual = await utils.getAppIdFromCtx(ctx) const actual = await utils.getAppIdFromCtx(ctx)
@ -100,7 +100,7 @@ describe("utils", () => {
const ctx = structures.koa.newContext() const ctx = structures.koa.newContext()
const appId = db.generateAppID() const appId = db.generateAppID()
ctx.request.headers = { ctx.request.headers = {
referer: `http://test.com/foo/app/${appId}/bar`, referer: `http://example.com/foo/app/${appId}/bar`,
} }
const actual = await utils.getAppIdFromCtx(ctx) const actual = await utils.getAppIdFromCtx(ctx)

View File

@ -3,5 +3,5 @@ import { v4 as uuid } from "uuid"
export { v4 as uuid } from "uuid" export { v4 as uuid } from "uuid"
export const email = () => { export const email = () => {
return `${uuid()}@test.com` return `${uuid()}@example.com`
} }

View File

@ -61,7 +61,7 @@ export function ssoProfile(user?: User): SSOProfile {
}, },
_json: { _json: {
email: user.email, email: user.email,
picture: "http://test.com", picture: "http://example.com",
}, },
provider: generator.string(), provider: generator.string(),
} }

View File

@ -25,7 +25,7 @@ export const user = (userProps?: Partial<Omit<User, "userId">>): User => {
roles: { app_test: "admin" }, roles: { app_test: "admin" },
firstName: generator.first(), firstName: generator.first(),
lastName: generator.last(), lastName: generator.last(),
pictureUrl: "http://test.com", pictureUrl: "http://example.com",
tenantId: tenant.id(), tenantId: tenant.id(),
...userProps, ...userProps,
} }

@ -1 +1 @@
Subproject commit 9b14e5d5182bf5e5ee98f717997e7352e5904799 Subproject commit 336bf2184cf632fdc2bffbad5628e8b15dd381bd

View File

@ -11,7 +11,7 @@ module SendgridMock {
} }
async send(msg: any) { async send(msg: any) {
if (msg.to === "invalid@test.com") { if (msg.to === "invalid@example.com") {
throw "Invalid" throw "Invalid"
} }
return msg return msg

View File

@ -60,7 +60,7 @@ module AwsMock {
// @ts-ignore // @ts-ignore
this.getSignedUrl = (operation, params) => { this.getSignedUrl = (operation, params) => {
return `http://test.com/${params.Bucket}/${params.Key}` return `http://example.com/${params.Bucket}/${params.Key}`
} }
// @ts-ignore // @ts-ignore

View File

@ -36,8 +36,8 @@ module FetchMock {
if (url.includes("/api/global")) { if (url.includes("/api/global")) {
const user = { const user = {
email: "test@test.com", email: "test@example.com",
_id: "us_test@test.com", _id: "us_test@example.com",
status: "active", status: "active",
roles: {}, roles: {},
builder: { builder: {
@ -58,7 +58,7 @@ module FetchMock {
url: "/app1", url: "/app1",
}, },
}) })
} else if (url.includes("test.com")) { } else if (url.includes("example.com")) {
return json({ return json({
body: opts.body, body: opts.body,
url, url,

View File

@ -367,7 +367,7 @@
"value": { "value": {
"data": { "data": {
"_id": "us_693a73206518477283a8d5ae31103252", "_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com", "email": "test@example.com",
"roles": { "roles": {
"app_957b12f943d348faa61db7e18e088d0f": "BASIC" "app_957b12f943d348faa61db7e18e088d0f": "BASIC"
}, },
@ -397,7 +397,7 @@
"data": [ "data": [
{ {
"_id": "us_693a73206518477283a8d5ae31103252", "_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com", "email": "test@example.com",
"roles": { "roles": {
"app_957b12f943d348faa61db7e18e088d0f": "BASIC" "app_957b12f943d348faa61db7e18e088d0f": "BASIC"
}, },

View File

@ -256,7 +256,7 @@ components:
value: value:
data: data:
_id: us_693a73206518477283a8d5ae31103252 _id: us_693a73206518477283a8d5ae31103252
email: test@test.com email: test@example.com
roles: roles:
app_957b12f943d348faa61db7e18e088d0f: BASIC app_957b12f943d348faa61db7e18e088d0f: BASIC
builder: builder:
@ -278,7 +278,7 @@ components:
value: value:
data: data:
- _id: us_693a73206518477283a8d5ae31103252 - _id: us_693a73206518477283a8d5ae31103252
email: test@test.com email: test@example.com
roles: roles:
app_957b12f943d348faa61db7e18e088d0f: BASIC app_957b12f943d348faa61db7e18e088d0f: BASIC
builder: builder:

View File

@ -3,7 +3,7 @@ import Resource from "./utils/Resource"
const user = { const user = {
_id: "us_693a73206518477283a8d5ae31103252", _id: "us_693a73206518477283a8d5ae31103252",
email: "test@test.com", email: "test@example.com",
roles: { roles: {
app_957b12f943d348faa61db7e18e088d0f: "BASIC", app_957b12f943d348faa61db7e18e088d0f: "BASIC",
}, },

View File

@ -12,7 +12,7 @@ describe("/api/applications/:appId/sync", () => {
app = await config.init() app = await config.init()
// create some users which we will use throughout the tests // create some users which we will use throughout the tests
await config.createUser({ await config.createUser({
email: "sync1@test.com", email: "sync1@example.com",
roles: { roles: {
[app._id!]: roles.BUILTIN_ROLE_IDS.BASIC, [app._id!]: roles.BUILTIN_ROLE_IDS.BASIC,
}, },

View File

@ -77,7 +77,7 @@ describe("/datasources", () => {
const { datasource, query } = await config.dynamicVariableDatasource() const { datasource, query } = await config.dynamicVariableDatasource()
// preview once to cache variables // preview once to cache variables
await preview(datasource, { await preview(datasource, {
path: "www.test.com", path: "www.example.com",
queryString: "test={{ variable3 }}", queryString: "test={{ variable3 }}",
}) })
// check variables in cache // check variables in cache

View File

@ -80,7 +80,7 @@ describe("/static", () => {
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body.signedUrl).toEqual("http://test.com/foo/bar") expect(res.body.signedUrl).toEqual("http://example.com/foo/bar")
expect(res.body.publicUrl).toEqual( expect(res.body.publicUrl).toEqual(
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}` `https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
) )

View File

@ -9,7 +9,7 @@ function user() {
_id: "user", _id: "user",
_rev: "rev", _rev: "rev",
createdAt: Date.now(), createdAt: Date.now(),
email: "test@test.com", email: "test@example.com",
roles: {}, roles: {},
tenantId: "default", tenantId: "default",
status: "active", status: "active",

View File

@ -11,7 +11,7 @@ describe("test the outgoing webhook action", () => {
await config.init() await config.init()
inputs = { inputs = {
username: "joe_bloggs", username: "joe_bloggs",
url: "http://www.test.com", url: "http://www.example.com",
} }
}) })
@ -19,7 +19,7 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action", async () => { it("should be able to run the action", async () => {
const res = await setup.runStep(setup.actions.discord.stepId, inputs) const res = await setup.runStep(setup.actions.discord.stepId, inputs)
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("post") expect(res.response.method).toEqual("post")
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
}) })

View File

@ -12,9 +12,9 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action", async () => { it("should be able to run the action", async () => {
const res = await runStep(actions.integromat.stepId, { const res = await runStep(actions.integromat.stepId, {
value1: "test", value1: "test",
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("post") expect(res.response.method).toEqual("post")
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
}) })
@ -30,9 +30,9 @@ describe("test the outgoing webhook action", () => {
body: { body: {
value: payload, value: payload,
}, },
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("post") expect(res.response.method).toEqual("post")
expect(res.response.body).toEqual(payload) expect(res.response.body).toEqual(payload)
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
@ -45,7 +45,7 @@ describe("test the outgoing webhook action", () => {
body: { body: {
value: payload, value: payload,
}, },
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.httpStatus).toEqual(400) expect(res.httpStatus).toEqual(400)
expect(res.response).toEqual("Invalid payload JSON") expect(res.response).toEqual("Invalid payload JSON")

View File

@ -11,7 +11,7 @@ describe("test the outgoing webhook action", () => {
await config.init() await config.init()
inputs = { inputs = {
requestMethod: "POST", requestMethod: "POST",
url: "www.test.com", url: "www.example.com",
requestBody: JSON.stringify({ requestBody: JSON.stringify({
a: 1, a: 1,
}), }),
@ -26,7 +26,7 @@ describe("test the outgoing webhook action", () => {
inputs inputs
) )
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("POST") expect(res.response.method).toEqual("POST")
expect(JSON.parse(res.response.body).a).toEqual(1) expect(JSON.parse(res.response.body).a).toEqual(1)
}) })

View File

@ -33,7 +33,7 @@ describe("test the outgoing webhook action", () => {
jest jest
.spyOn(workerRequests, "sendSmtpEmail") .spyOn(workerRequests, "sendSmtpEmail")
.mockImplementationOnce(async () => .mockImplementationOnce(async () =>
generateResponse("user1@test.com", "admin@test.com") generateResponse("user1@example.com", "admin@example.com")
) )
const invite = { const invite = {
startTime: new Date(), startTime: new Date(),
@ -43,8 +43,8 @@ describe("test the outgoing webhook action", () => {
url: "url", url: "url",
} }
inputs = { inputs = {
to: "user1@test.com", to: "user1@example.com",
from: "admin@test.com", from: "admin@example.com",
subject: "hello", subject: "hello",
contents: "testing", contents: "testing",
cc: "cc", cc: "cc",
@ -61,8 +61,8 @@ describe("test the outgoing webhook action", () => {
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
expect(workerRequests.sendSmtpEmail).toHaveBeenCalledTimes(1) expect(workerRequests.sendSmtpEmail).toHaveBeenCalledTimes(1)
expect(workerRequests.sendSmtpEmail).toHaveBeenCalledWith({ expect(workerRequests.sendSmtpEmail).toHaveBeenCalledWith({
to: "user1@test.com", to: "user1@example.com",
from: "admin@test.com", from: "admin@example.com",
subject: "hello", subject: "hello",
contents: "testing", contents: "testing",
cc: "cc", cc: "cc",

View File

@ -12,9 +12,9 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action", async () => { it("should be able to run the action", async () => {
const res = await runStep(actions.zapier.stepId, { const res = await runStep(actions.zapier.stepId, {
value1: "test", value1: "test",
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("post") expect(res.response.method).toEqual("post")
expect(res.success).toEqual(true) expect(res.success).toEqual(true)
}) })
@ -30,9 +30,9 @@ describe("test the outgoing webhook action", () => {
body: { body: {
value: payload, value: payload,
}, },
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.response.url).toEqual("http://www.test.com") expect(res.response.url).toEqual("http://www.example.com")
expect(res.response.method).toEqual("post") expect(res.response.method).toEqual("post")
expect(res.response.body).toEqual( expect(res.response.body).toEqual(
`{"platform":"budibase","value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}` `{"platform":"budibase","value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
@ -47,7 +47,7 @@ describe("test the outgoing webhook action", () => {
body: { body: {
value: payload, value: payload,
}, },
url: "http://www.test.com", url: "http://www.example.com",
}) })
expect(res.httpStatus).toEqual(400) expect(res.httpStatus).toEqual(400)
expect(res.response).toEqual("Invalid payload JSON") expect(res.response).toEqual("Invalid payload JSON")

View File

@ -46,7 +46,7 @@ export const smtp = (conf?: SMTPConfig): SMTPConfig => {
config: { config: {
port: 12345, port: 12345,
host: "smtptesthost.com", host: "smtptesthost.com",
from: "testfrom@test.com", from: "testfrom@example.com",
subject: "Hello!", subject: "Hello!",
secure: false, secure: false,
...conf, ...conf,

View File

@ -94,8 +94,8 @@ function buildRoles() {
} }
describe("app user/group sync", () => { describe("app user/group sync", () => {
const groupEmail = "test2@test.com", const groupEmail = "test2@example.com",
normalEmail = "test@test.com" normalEmail = "test@example.com"
async function checkEmail( async function checkEmail(
email: string, email: string,
opts?: { group?: boolean; notFound?: boolean } opts?: { group?: boolean; notFound?: boolean }
@ -131,7 +131,7 @@ describe("app user/group sync", () => {
}) })
it("should be able to handle builder users", async () => { it("should be able to handle builder users", async () => {
await createUser("test3@test.com", {}, true) await createUser("test3@example.com", {}, true)
await checkEmail("test3@test.com") await checkEmail("test3@example.com")
}) })
}) })

View File

@ -76,7 +76,7 @@ describe.each([tableWithUserCol, tableWithUsersCol])(
}) })
it("shouldn't change any other input", () => { it("shouldn't change any other input", () => {
const email = "test@test.com" const email = "test@example.com"
const params: SearchParams = { const params: SearchParams = {
tableId, tableId,
query: { query: {

View File

@ -2,7 +2,7 @@
"user":{ "user":{
"_id":"ro_ta_users_us_b0bc7ba0ce304294accc1ced8165dd23", "_id":"ro_ta_users_us_b0bc7ba0ce304294accc1ced8165dd23",
"_rev":"1-e9199d92e7286005a9c11c614fdbcc51", "_rev":"1-e9199d92e7286005a9c11c614fdbcc51",
"email":"test2@test.com", "email":"test2@example.com",
"status":"active", "status":"active",
"roleId":"PUBLIC", "roleId":"PUBLIC",
"test-Created By_text":"", "test-Created By_text":"",

View File

@ -448,7 +448,7 @@ describe("Cover a few complex use cases", () => {
it("getting a nice date from the user", async () => { it("getting a nice date from the user", async () => {
const input = { text: `{{ date user.subscriptionDue "DD-MM" }}` } const input = { text: `{{ date user.subscriptionDue "DD-MM" }}` }
const context = JSON.parse( const context = JSON.parse(
`{"user":{"email":"test@test.com","roleId":"ADMIN","type":"user","tableId":"ta_users","subscriptionDue":"2021-01-12T12:00:00.000Z","_id":"ro_ta_users_us_test@test.com","_rev":"2-24cc794985eb54183ecb93e148563f3d"}}` `{"user":{"email":"test@example.com","roleId":"ADMIN","type":"user","tableId":"ta_users","subscriptionDue":"2021-01-12T12:00:00.000Z","_id":"ro_ta_users_us_test@example.com","_rev":"2-24cc794985eb54183ecb93e148563f3d"}}`
) )
const output = await processObject(input, context) const output = await processObject(input, context)
expect(output.text).toBe("12-01") expect(output.text).toBe("12-01")

View File

@ -23,27 +23,27 @@ const USERS = [
password: "test", password: "test",
}, },
{ {
email: "loadtest2@test.com", email: "loadtest2@example.com",
password: "test", password: "test",
}, },
{ {
email: "loadtest3@test.com", email: "loadtest3@example.com",
password: "test", password: "test",
}, },
{ {
email: "loadtest4@test.com", email: "loadtest4@example.com",
password: "test", password: "test",
}, },
{ {
email: "loadtest5@test.com", email: "loadtest5@example.com",
password: "test", password: "test",
}, },
{ {
email: "loadtest6@test.com", email: "loadtest6@example.com",
password: "test", password: "test",
}, },
{ {
email: "loadtest7@test.com", email: "loadtest7@example.com",
password: "test", password: "test",
}, },
] ]

View File

@ -80,7 +80,7 @@ describe("/api/global/auth", () => {
it("should return 403 when user doesn't exist", async () => { it("should return 403 when user doesn't exist", async () => {
const tenantId = config.tenantId! const tenantId = config.tenantId!
const email = "invaliduser@test.com" const email = "invaliduser@example.com"
const password = "password" const password = "password"
const response = await config.api.auth.login( const response = await config.api.auth.login(

View File

@ -490,7 +490,7 @@ describe("/api/global/users", () => {
it("should not be able to update email address", async () => { it("should not be able to update email address", async () => {
const email = structures.email() const email = structures.email()
const user = await config.createUser(structures.users.user({ email })) const user = await config.createUser(structures.users.user({ email }))
user.email = "new@test.com" user.email = "new@example.com"
const response = await config.api.users.saveUser(user, 400) const response = await config.api.users.saveUser(user, 400)

View File

@ -10,7 +10,7 @@ export class EmailAPI extends TestAPI {
return this.request return this.request
.post(`/api/global/email/send`) .post(`/api/global/email/send`)
.send({ .send({
email: "test@test.com", email: "test@example.com",
purpose, purpose,
tenantId: this.config.getTenantId(), tenantId: this.config.getTenantId(),
userId: this.config.user?._id!, userId: this.config.user?._id!,

View File

@ -45,7 +45,7 @@ export function smtp(conf?: any): SMTPConfig {
config: { config: {
port: 12345, port: 12345,
host: "smtptesthost.com", host: "smtptesthost.com",
from: "testfrom@test.com", from: "testfrom@example.com",
subject: "Hello!", subject: "Hello!",
secure: false, secure: false,
...conf, ...conf,
@ -59,7 +59,7 @@ export function smtpEthereal(): SMTPConfig {
config: { config: {
port: 587, port: 587,
host: "smtp.ethereal.email", host: "smtp.ethereal.email",
from: "testfrom@test.com", from: "testfrom@example.com",
secure: false, secure: false,
auth: { auth: {
user: "wyatt.zulauf29@ethereal.email", user: "wyatt.zulauf29@ethereal.email",