Created
May 29, 2018 19:45
-
-
Save phra/7691e97e2327b024dcc2ae4dc483cd89 to your computer and use it in GitHub Desktop.
fast-redact vulnerable validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
if (/〇/.test(s)) throw Error() | |
const proxy = new Proxy({}, {get: () => proxy, set: () => { throw Error() }}) | |
const expr = s.replace(/^\*/, '〇').replace(/\.\*/g, '.〇').replace(/\[\*\]/g, '[〇]') | |
if (/\/\*/.test(expr)) throw Error() | |
/* eslint-disable-next-line */ | |
new Script(` | |
o.${expr} | |
if ([o.${expr}].length !== 1) throw Error() | |
`).runInNewContext({o: proxy, 〇: null}) | |
} catch (e) { | |
throw Error(ERR_INVALID_PATH(s)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment