Skip to content
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

[security] Don't use data object for Squirrelly configuration #254

Merged
merged 2 commits into from
May 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/file-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SqrlErr from './err'
import compile from './compile'
import { getConfig } from './config'
import { getPath, readFile, loadFile } from './file-utils'
import { promiseImpl, copyProps } from './utils'
import { promiseImpl } from './utils'

/* TYPES */

Expand All @@ -18,9 +18,6 @@ interface FileOptions extends SqrlConfig {
}

interface DataObj {
settings?: {
[key: string]: any
}
[key: string]: any
}

Expand All @@ -34,7 +31,6 @@ interface DataObj {
* `options.filename` so it must be set prior to calling this function.
*
* @param {Options} options compilation options
* @param {String} [template] template source
* @return {(TemplateFunction|ClientFunction)}
* Depending on the value of `options.client`, either type might be returned.
* @static
Expand Down Expand Up @@ -115,23 +111,6 @@ function renderFile (filename: string, data: DataObj, cb?: CallbackFn) {
var Config: FileOptions = getConfig((data as PartialConfig)) as FileOptions
// TODO: make sure above doesn't error. We do set filename down below

if (data.settings) {
// Pull a few things from known locations
if (data.settings.views) {
Config.views = data.settings.views
}
if (data.settings['view cache']) {
Config.cache = true
}
// Undocumented after Express 2, but still usable, esp. for
// items that are unsafe to be passed along with data, like `root`
var viewOpts = data.settings['view options']

if (viewOpts) {
copyProps(Config, viewOpts)
}
}

Config.filename = filename // Make sure filename is right

return tryHandleCache(Config, data, cb as CallbackFn)
Expand Down