Valid code microservice/endpoint with V8 Virtual Machine
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 803
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
I've found some small bugs at the frontend when I try to run my own dweet, so I offer the following schema. We could create microservice or endpoint where will be created instance of V8's Virtual Machine with specified sandbox which is a canvas API stub.
So we could check valid our code or not, for example:
```
const isEqual = require('lodash.isequal')
const vm = require('vm');
const canvasStub = {
canvas: {
fillRect: function(){}
}
}
const sandbox = Object.assign({}, canvasStub)
vm.createContext(sandbox)
const code = "canvas.fillRect()"
try {
const result = vm.runInContext(code, sandbox, {
timeout: 1000
});
console.log('is code valid', isEqual(sandbox, canvasStub))
} catch (e) {
console.log('non valid code', e)
}
```
So if use will send `this.a = '1'` or `new XMLHttpRequest()` code will be not valid.
Also VM will have option for timeout that will protect against infinite loop in the code
In result if code is valid then we will create iframe with this user code
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files, tests, or entry points are named. Start by locating the existing frontend dweet execution flow and determine where a V8 VM-backed microservice or endpoint could fit. Done means the proposed sandbox validation handles the canvas stub, rejects the described mutations and XMLHttpRequest usage, enforces the timeout, and gates iframe creation on valid code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100