Code Monkey home page Code Monkey logo

microcule's People

Contributors

fedot avatar marak avatar mikaelkaron avatar pyhedgehog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microcule's Issues

throw new Error('service is undefined')

/usr/local/lib/node_modules/microcule/node_modules/run-service/index.js:16
    throw new Error('service is undefined');
    ^
service is undefined

I was just trying to run the express-simple.js example

$ microcule express-simple.js
javascript microcule started at: http://0.0.0.0:3000
running service /

Populate $_GET and $_POST scope for PHP services

Currently PHP services use $Hook['params'] scope for merged get and post variables.

It would be somewhat less surprising for PHP users if we also populated PHP's $_GET and $_POST scopes with incoming service parameters.

Discrepancy in Github and npm installation

I have run in to a problem, trying to use microcule with python 3.5.3 in virtualenv.

I am currently on Debian 9 Stretch (stable).
My version of npm was installed from https://deb.nodesource.com/setup_9.x And not from the official apt repository, as it wasn't properly maintained, and therefore isn't present in the official apt repo.

When trying to use use Microcule with python3, i was presented with the following error.

Traceback (most recent call last):
  File "/usr/lib/node_modules/microcule/bin/binaries/micro-python3", line 16, in <module>
    __prepare()
  File "/usr/lib/node_modules/microcule/bin/binaries/micro-python3", line 12, in __prepare
    import microcule
  File "/usr/lib/node_modules/microcule/bin/binaries/lib/python/microcule/__init__.py", line 10, in <module>
    fd3 = os.fdopen(3, 'w+')
  File "/home/morten/.virtualenvs/DSEnv/lib/python3.5/os.py", line 1072, in fdopen
    return io.open(fd, *args, **kwargs)
io.UnsupportedOperation: File or stream is not seekable.

Looking in to it a little, i found that, there seems to be a discrepancy in the content of the file microcule/bin/binaries/lib/python/microcule/__init__.py
on github, and the file one gets when microcule is installed according to the recommended "npm install -g microcule"

On Github there is an if else statement, distinguishing between python versions < 3 and others.

# open incoming connection from fd3
if sys.version_info[0] < 3:
  fd3 = os.fdopen(3, 'w+')
else:
  fd3 = os.fdopen(3, 'wb+', buffering=0)

This if else statement is not present in the microcule installed by npm, the first lines of my local file looks like this instead.

# open incoming connection from fd3
fd3 = os.fdopen(3, 'w+')

spawn EACCESS

I'm trying to run microcule on an Ubuntu Server, I had it working but now I only get:
Which looks like Node doesn't have some read or write permission maybe.
I've emptied the hook to just contain:
`module['exports'] = function fakeData (hook) {

}`

Error: spawn EACCES at exports._errnoException (util.js:1050:11) at ChildProcess.spawn (internal/child_process.js:319:11) at Object.exports.spawn (child_process.js:378:9) at spawn (/var/www/db/node_modules/cross-spawn/index.js:17:18) at _spawnService (/var/www/db/node_modules/microcule/lib/plugins/spawn/index.js:376:12) at spawnServiceMiddleware (/var/www/db/node_modules/microcule/lib/plugins/spawn/index.js:157:7) at spawnService (/var/www/db/node_modules/microcule/bin/microcule:280:13) at watchSpawn (/var/www/db/node_modules/microcule/bin/microcule:238:9) at Layer.handle [as handle_request] (/var/www/db/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/var/www/db/node_modules/express/lib/router/index.js:317:13)

Ensure that lua variable names and values are escaped

Just saw an instance where an environment or http params variable name containing - was causing the lua codegen to crash.

We need to ensure that the lua code won't crash on variable names with - or any other values that need to be escaped. Pretty sure we can do something like: [[lua string with escape codes]]

Improve bash escape code

It seems it's possible to execute arbitrary bash commands through HTTP parameters when using bash services ( and other possible languages too ).

This isn't intended behavior and should be fixed.

The actual security implications would be determined by the configuration of the server environment microcule is running on. For hook.io, it's not really a problem ( since workers running code are secure on the operating system level ), but it could cause issues for on non-secure systems running untrusted source code.

Switch `coffee-script` and `babel` to new compiled languages plugin

Now that we have a good way to compile source code into binaries, we should update the coffee-script and babel code paths to use the new compiled language plugin / API.

The main reason for this change will be unifying the code paths for compile / transpile steps and being able to use the new provider API and shasum checksums.

Medium priority as current performance seeks OK.

Consider merging `in-process-node` branch

Currently, all Node.js services are spawned in a new process using the micro-node binary, which is called via microcule.spawn. This ensures process level isolation of the untrusted source code.

Inside micro-node we are using the run-service module, which provides Node.js in-processvm based isolation of the untrusted source code.

Technically ( and previously ) run-service could be executed in-process where microcule.spawn is called ( instead of spawning a new micro-node process ). This could be dangerous as a memory leak or CPU leak in the untrusted source code could affect other running services. It could also be advantageous because it would significantly reduce the amount of resources needed to run Node services, as well as reduce response times by 150+ milliseconds.

We should consider merging the in-process-node branch as a configurable option. Depending on the server environment and intended use-case, being able to spawn in-process Node scripts may be better than enforcing process isolation per Node service.

NPM package broken

I consistently run into errors with the npm package version, however installing from GitHub works. I suspect the npm package needs updating.

DeprecationWarnings are written out on the console

When running a hook with deprecated api usage you can see:

(node:13604) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`,
 `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.

if you try to use a package like trumpet things get even weirder.

Possible solutions would be to somehow set the process the same way as passing --no-deprecation in the cli, perhaps nodejs/node@c6656db can shed some light on that.

Implement JSON support for `golang` and `rust`

Right now we are sending all HTTP params for golang and rust as individual argv arguments.

It would be better if we sent the HTTP params as JSON and updated the examples to dump the JSON, similar to how JavaScript / Ruby / Python / Lua / etc all currently work.

Update node.js function signature

Currently, the signature for Node.js functions is: function (hook).

It would be more clear to users and node.js friendly if the signature was: function(req, res).

The new function signature would actually be backwards compatible, so this wouldn't break any existing services. Update will be required in run-service npm package.

We could also consider function(req, res, next), but implementing next correctly might be non-trivial.

Add remote source code plugin

In some cases, the source code for a service may be stored in a remote location and is not immediately available.

Examples include source code as gist, git repo, vfs, or any remote location.

We should have a plugin available that will parse the incoming service object for potential remote sources and fetch them asynchronously. There should also be a built in cache provider ( redis and in-memory ) that can optionally cache the remote source codes.

Detecting client abort inside hook

I was wondering how one would go about detecting when a user closes / clicks stop in a loading tab? I found a stack overflow thread on how to do it in vanilla express:

req.on("close", function() {
  // request closed unexpectedly
});

req.on("end", function() {
  // request ended normally
}):

Granted I never tested this myself but I did test it inside a hook but to no avail.

Rename project

We've gotten a bit of feedback regarding the project name.

All things aside, we have a conflict with Haskell's stack binary, so we must change this project's core binary at the least. Will probably take this opportunity to rename the project to something more unique / easier to find.

Implement associative arrays for bash services

Right now, bash services are still injecting all request and env parameters into separate unique bash variables ( like how Lua use to work prior to #18 )

It would be better if we used bash 4 feature of associative arrays for creating two objects, Hook.params and Hook.env, which are populated with many items ( instead of creating many unique variable names )

microcule + x-ray + docker streaming error

While trying to implement a microcule powered scraper I've run in to what looks like a broken stream problem, but only if the whole thing is hosted in a docker container (I know, there's a few deps here that could be the root cause but I figured asking for help can't hurt).

To reproduce clone the gist from above:

git clone https://gist.github.com/d10ee3863a6f0773c5386b77abea77fa.git

Build the docker image:

docker build -t microcule-docker

Run the docker image in interactive terminal:

docker run -it -p 3000:3000 microcule-docker

After this hit the following URL's:

http://localhost:3000/request/hook
http://localhost:3000/scrape/hook
http://localhost:3000/scrape/middleware

The second URL breaks in the middle of the JSON. However if you just try a simple npm start and repeat it all runs fine.

One thing to note here is the /request/hook URL works fine in both native/docker so I guess I'm wondering what x-ray does to the stream internally to just close in the middle.

Part of the problem is that debugging this with docker + microcule is a bit tricky and since I suspect that @Marak know a thing or two about hosting hooks inside docker I decided it could be worth filing an issue.

Test failed

Build badge in the README file is showing build | failing, and as travis-ci log indicates, the test suite has been failing for a long time. 8 of the tests in test/rate-limit-test.js does not pass.

Remove dependency on `resource-http`

resource-http is too full featured to be included in microcule. The only place resource-http is being used is in the microcule binary itself, and should be able to be replaced with or express or stack ( maybe even just core node http module )

The primary reason for this switch will be to reduce the amount of dependencies in microcule.

We shouldn't lose any features here. Developers could still use resource-http separately and use microcule as a middleware.

Implement cache provider for Github source plugins

Ideally, we wouldn't want to be requesting the service's source from Github on every request.

It would be better if the plugins for Github remote sources were able to accept a cache provider ( similar to how the rate limiter works ) in order to provide the option of caching the source code ( for fast retrieval ).

We'd also want to accept an option to indicate that the cache should be invalidated ( on request ).

This project really need a gh-page.

This project is legit and deserves more traction!

I think a first step is to think about how the content above the fold in the README could be simplified so that noobs like me would understand why this is amazing within 10 seconds.

I would then use this simplified copy and create a gh-page. This page should preferably have a live demo, where you can play around with a microservice, similar to hook.io's web editor.

To further drive interested, I think it would be dope if the CLI supported creations of microservices.

Support https connections

I was trying to use microcule to run a google assistant example that was designed to run on GCF. However, the API.AI webhooks require an https connection. Looks like microcule is hard coded to start only http servers. Could it be enhanced to have the option of using the https module for starting the server?

This link documents the API.AI webhook requirements.

How to support logging (console.log) statement in microcule example java script index.js file?

I am not able to find the log statement added with console.log() in microcule js example index,js. also,In microcule any Js example index.js file am adding console.log() ,but that log statement is not displaying in my command prompt.If i use res.write('') that logs displaying in browser,any possibilities to support logging statement using console.log that will display in console not browser?

Can't require local files

When trying to require('./lib/file.js') I get a "module not found" error. Is there a special way to require a module when using microcule?

Ruby ENV variables should be present in ENV scope

The default behavior for Ruby is to populate the ENV scope.

We are currently populating Hook.env scope for Ruby.

I believe the path of least surprise for Ruby users will be to use the ENV scope ( as it's already expected ). We can keep both APIs for backwards compatibility.

Refactor `spawn` plugin into separate module

The core spawning logic at https://github.com/Stackvana/microcule/blob/master/lib/plugins/spawn/index.js currently has two concerns coupled together: preparing the service options for spawning, and managing the spawned service.

microcule's spawning logic should only be concerned with preparing the service options. The actual spawning and managing of STDIO communications should be handled in a separate module.

To start, we can separate these concerns into separate files within this project. If it makes sense to then move the spawn logic itself to a separate package, we will.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.