Wednesday, 26 April 2017

Botframework (Node) - dialogData stripping out regex

Does the BotBuilder Node SDK actively strip out anything that is stored the dialogData object?

For example, I have created a simple loop and I am storing a regex in session.dialogData.questions. When I console log this after storing it, I can see that my regex is stored as expected:

  { 
    validation: /^[0-9]{19}$/,
  } 

However, when I try and log the same session.dialogData.questions object in the next step of my waterfall, then the regex seems to have been converted into an empty object:

  {
    validation: {}
  }

I presume this a deliberate attempt to prevent XSS and other types of exploitation?

The code for this example can be found below:

const builder = require('botbuilder')
const lib = new builder.Library('FormBuilder')

lib.dialog('/', [
    (session, args) => {
      session.dialogData.questions = {
        validation: /^[0-9]{19}$/
      }
      console.log(session.dialogData.questions)
      builder.Prompts.confirm(session, 'Would you like to proceed?')
    },
    (session, results) => {
      console.log(session.dialogData.questions)
    }
])

module.exports.createLibrary = () => {
  return lib.clone()
}



via tombraider

No comments:

Post a Comment