Skip to content

Feature/eng 469 integrate blockless site function in cli#79

Merged
dmikey merged 6 commits intomainfrom
feature/eng-469-integrate-blockless-site-function-in-cli
Jan 18, 2023
Merged

Feature/eng 469 integrate blockless site function in cli#79
dmikey merged 6 commits intomainfrom
feature/eng-469-integrate-blockless-site-function-in-cli

Conversation

@uditdc
Copy link
Copy Markdown
Member

@uditdc uditdc commented Jan 18, 2023

This commit includes support for blockless sites initialization, build and preview.

@uditdc uditdc requested a review from dmikey January 18, 2023 09:04
Comment on lines +100 to +129
fastify.get("*", async (request, reply) => {
const result = execSync(`echo "${decodeURIComponent(request.url.trim())}" | ${envString} ${runtimePath} ${manifestPath}`, {
cwd: path
}).toString()

if (!manifest.contentType || manifest.contentType === 'json' && result) {
try {
const resultJson = JSON.parse(result)

reply
.header("Content-Type", "application/json")
.send(resultJson)
} catch (error) { }
} else if (manifest.contentType === "html" && result) {
const body = result

if (body.startsWith("data:")) {
const data = body.split(",")[1]
const contentType = body.split(",")[0].split(":")[1].split(";")[0]
const base64data = Buffer.from(data, "base64")
reply.type(contentType).send(base64data)
} else {
reply
.header("Content-Type", "text/html")
.send(body)
}
} else {
reply.send(result)
}
})

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [a system command](1), but is not rate-limited.
Comment on lines +87 to +116
fastify.get("*", async (request, reply) => {
const result = execSync(`echo "${decodeURIComponent(request.url.trim())}" | ${envString} ${runtimePath} ${manifestPath}`, {
cwd: path
}).toString()

if (!manifest.contentType || manifest.contentType === 'json' && result) {
try {
const resultJson = JSON.parse(result)

reply
.header("Content-Type", "application/json")
.send(resultJson)
} catch (error) { }
} else if (manifest.contentType === "html" && result) {
const body = result

if (body.startsWith("data:")) {
const data = body.split(",")[1]
const contentType = body.split(",")[0].split(":")[1].split(";")[0]
const base64data = Buffer.from(data, "base64")
reply.type(contentType).send(base64data)
} else {
reply
.header("Content-Type", "text/html")
.send(body)
}
} else {
reply.send(result)
}
})

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [a system command](1), but is not rate-limited.
})

fastify.get("*", async (request, reply) => {
const result = execSync(`echo "${decodeURIComponent(request.url.trim())}" | ${envString} ${runtimePath} ${manifestPath}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3).
})
} else {
// pass in stdin to the runtime
const result = execSync(`echo "${stdinString}" | ${envString} ${runtimePath} ${manifestPath}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3).
})

fastify.get("*", async (request, reply) => {
const result = execSync(`echo "${decodeURIComponent(request.url.trim())}" | ${envString} ${runtimePath} ${manifestPath}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3).
// Pack files and generate a tempory assembly script
const { dir } = generateCompileDirectory(source)

execSync(`npm install && npm run build -- -o ${path.resolve(dest, name)}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3). This shell command depends on an uncontrolled [absolute path](4). This shell command depends on an uncontrolled [absolute path](5).
@dmikey dmikey merged commit 4d6d7f7 into main Jan 18, 2023
@dmikey dmikey deleted the feature/eng-469-integrate-blockless-site-function-in-cli branch January 18, 2023 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants