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

create loophole in webSecure=true for sysactions #101

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ function removeEmptyStringMembersFromPackages(packages: PackageSpec[]) {
// is not expected in this context. TODO return a list of errors not just the first error.
export function validateDeployConfig(arg: any, runtimesConfig: RuntimesConfig): string {
let haveActionWrap = false; let haveBucket = false
const isNimbellaDeploy = arg.targetNamespace === 'nimbella'
const slice = !!arg.slice
for (const item in arg) {
if (!arg[item]) continue
Expand Down Expand Up @@ -345,7 +346,7 @@ export function validateDeployConfig(arg: any, runtimesConfig: RuntimesConfig):
return 'packages member must be an array'
}
for (const subitem of arg[item]) {
const pkgError = validatePackageSpec(subitem, runtimesConfig, slice)
const pkgError = validatePackageSpec(subitem, runtimesConfig, slice, isNimbellaDeploy)
if (pkgError) {
return pkgError
}
Expand Down Expand Up @@ -450,7 +451,8 @@ function validateWebResource(arg: Record<string, any>): string {
}

// Validator for a PackageSpec
function validatePackageSpec(arg: Record<string, any>, runtimesConfig: RuntimesConfig, slice: boolean): string {
function validatePackageSpec(arg: Record<string, any>, runtimesConfig: RuntimesConfig, slice: boolean,
isNimbella: boolean): string {
const isDefault = arg.name === 'default'
for (const item in arg) {
if (!arg[item]) continue
Expand All @@ -463,7 +465,7 @@ function validatePackageSpec(arg: Record<string, any>, runtimesConfig: RuntimesC
return "actions member of a 'package' must be an array"
}
for (const subitem of arg[item]) {
const actionError = validateActionSpec(subitem, runtimesConfig)
const actionError = validateActionSpec(subitem, runtimesConfig, isNimbella)
if (actionError) {
return actionError
}
Expand Down Expand Up @@ -500,7 +502,7 @@ function validatePackageSpec(arg: Record<string, any>, runtimesConfig: RuntimesC
}

// Validator for ActionSpec
function validateActionSpec(arg: Record<string, any>, runtimesConfig: RuntimesConfig): string {
function validateActionSpec(arg: Record<string, any>, runtimesConfig: RuntimesConfig, isNimbella: boolean): string {
for (const item in arg) {
if (!arg[item]) continue
switch (item) {
Expand Down Expand Up @@ -535,6 +537,10 @@ function validateActionSpec(arg: Record<string, any>, runtimesConfig: RuntimesCo
}
break
case 'webSecure':
if (isNimbella && arg[item] === true) {
// allowed
continue
}
if (!(arg[item] === false || typeof arg[item] === 'string')) {
return `'${item}' member of an 'action' must be a boolean false or a string`
}
Expand Down