Skip to content

Commit

Permalink
feat(core): actions/hooks vm have access to host/port
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Nov 1, 2018
1 parent 42bc069 commit fc29a45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/bp/core/services/action/action-service.ts
@@ -1,5 +1,6 @@
import { Logger } from 'botpress/sdk'
import { inject, injectable, tagged } from 'inversify'
import _ from 'lodash'
import path from 'path'
import { VError } from 'verror'
import { NodeVM } from 'vm2'
Expand Down Expand Up @@ -127,7 +128,8 @@ export class ScopedActionService {
bp: api,
event: incomingEvent,
state: dialogState,
args: actionArgs
args: actionArgs,
process: _.pick(process, 'HOST', 'PORT', 'PROXY_PORT')
},
require: {
external: true,
Expand Down
5 changes: 4 additions & 1 deletion src/bp/core/services/hook/hook-service.ts
Expand Up @@ -147,7 +147,10 @@ export class HookService {
const vm = new NodeVM({
wrapper: 'none',
console: 'inherit',
sandbox: hookScript.hook.args,
sandbox: {
...hookScript.hook.args,
process: _.pick(process, 'HOST', 'PORT', 'PROXY_PORT')
},
timeout: hookScript.hook.timeout,
require: {
external: true,
Expand Down

0 comments on commit fc29a45

Please sign in to comment.