dale tan | 1 Aug 2011 01:28
Picon
Gravatar

Re: Re: Can I get feedback?

you can check out a node style guide here:

http://nodeguide.com/style.html

On Sun, Jul 31, 2011 at 6:02 PM, Jaime Bueza <jbueza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Try: change the function signature to be more consistent with Node's file IO, mongo, couch by passing the error as a parameter first:

blog.text({limit: 2}, function(err, response) { //now we can do consistent error checking if (err) throw ... console.log(response.posts); });

Awesome work though, looks very easy to use and great documentation!

Jaime Bueza Software Engineer
LinkedIn | Twitter | Google Plus | Blog 




On Sun, Jul 31, 2011 at 2:12 PM, Alexey Simonenko <dwarfman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Thank you, already done this.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
-- 
CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or previous e-mail messages attached to it may contain confidential
information that is legally privileged and is intended for the designated
recipient only. If you have received it in error, please notify the sender
immediately and delete the original. Any other use of the email by you is
STRICTLY PROHIBITED.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
falcon | 1 Aug 2011 02:04
Picon

How to protect environment from hostile scripts -- disallow('fs')

Is there a way to 'disallow' a node script access to operating system services such as file system, network, etc?

Say I am running a server where I let users send me scripts to execute. It could be a giant public map/reduce
server, perhaps a video game where users can contribute their own character behaviors, Netflix type
company which let's you train your AI models on their servers on their data.

In all such instances, the host wants to run someone else's logic in a 'controlled' way. To start with, the
host should be able to disallow direct access to libraries such as fs and net. When the script does need to
communicate with the outside world, it uses custom services provided by the host.

Is there a way to do such a thing in the node environment?

--

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@...
To unsubscribe from this group, send email to
nodejs+unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Marak Squires | 1 Aug 2011 02:13
Picon
Gravatar

Re: How to protect environment from hostile scripts -- disallow('fs')

Is there a way to 'disallow' a node script access to operating system services such as file system, network, etc?

Short answer, yes. 

Check out https://github.com/matthewfl/node-host/ for some ideas on sandboxing. 

On Sun, Jul 31, 2011 at 5:04 PM, falcon <shahbazc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Is there a way to 'disallow' a node script access to operating system services such as file system, network, etc?

Say I am running a server where I let users send me scripts to execute. It could be a giant public map/reduce server, perhaps a video game where users can contribute their own character behaviors, Netflix type company which let's you train your AI models on their servers on their data.

In all such instances, the host wants to run someone else's logic in a 'controlled' way. To start with, the host should be able to disallow direct access to libraries such as fs and net. When the script does need to communicate with the outside world, it uses custom services provided by the host.

Is there a way to do such a thing in the node environment?

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Marak Squires | 1 Aug 2011 03:00
Picon
Gravatar

Re: How to protect environment from hostile scripts -- disallow('fs')

Really though, you should probably just let node run unrestricted and setup the sandboxing through virtualization of the operating system. 



On Sun, Jul 31, 2011 at 5:13 PM, Marak Squires <marak.squires-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Is there a way to 'disallow' a node script access to operating system services such as file system, network, etc?

Short answer, yes. 

Check out https://github.com/matthewfl/node-host/ for some ideas on sandboxing. 

On Sun, Jul 31, 2011 at 5:04 PM, falcon <shahbazc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Is there a way to 'disallow' a node script access to operating system services such as file system, network, etc?

Say I am running a server where I let users send me scripts to execute. It could be a giant public map/reduce server, perhaps a video game where users can contribute their own character behaviors, Netflix type company which let's you train your AI models on their servers on their data.

In all such instances, the host wants to run someone else's logic in a 'controlled' way. To start with, the host should be able to disallow direct access to libraries such as fs and net. When the script does need to communicate with the outside world, it uses custom services provided by the host.

Is there a way to do such a thing in the node environment?

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Marcel Laverdet | 1 Aug 2011 03:15
Gravatar

fibers 0.5; say "no" callbacks (when it makes sense in your application)

Hey guys I finished up on some new work on Fibers over the past week or so and wanted to get some feedback. For those of you who have missed the ongoing holy wars, fibers are a simplified implementation of coroutines for NodeJS. These work similar to threads, except only one is running at a time and the programmer explicitly chooses when to switch to another coroutine (thus, there are no locking & race condition issues).


Anyway the biggest change is that I decided to include an implementation of futures along with the package. I've been saying that since day 1 that using fibers without some kind of abstraction is foolish, but I didn't actually provide any example abstraction out of the box. As a result it was really hard to get started with fibers or see the advantages of them. I was reluctant to include this library because it's possible to build all kinds of interesting abstractions on fibers and I didn't want to stifle anyone's creativity. But alas I want to make it easier for people to try out fibers so I'm including Futures alongside Fibers (without changing the core Fiber API).

Futures is the library I've been using in my project with support from Fibers. They are very similar to existing "promises" implementations with the addition of a "wait" method which will yield the current fiber until a future has resolved. What I like about Futures is that it's really easy to mix and match callback-based code with "blocking" fiber code whenever a particular style makes more sense.

Quick example (some bootstrapping abbreviated):
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}

// Future.wrap takes an existing callback-based function and make a function

// which returns a Future

var readdir = Future.wrap(require('fs').readdir);

var dir = readdir('.');


// Once you have a Future you can either resolve it asynchronously

dir.resolve(function(err, val) {

  if (err) throw err;

  console.log('Files in this directory: '+ val.join(', '));

});


// Or you can yield your current fiber synchronously (the wait() call is the

// important part):

console.log('Files in this directory: '+ dir.wait().join(', '));


Using fibers here gives you some cool advantages:


- Reasonable stack traces: Sometimes it can be difficult to find bugs that occur in callback-based code because you lose your stack with every tick. But since each fiber is a stack, traces are maintained even past asynchronous calls. Additionally line numbers are not mangled like they are with the existing rewriting solutions.


- Exceptions are usable again: Using fibers you no longer have to manually propagate exceptions, this is all taken care for you. In the example above, wait() will throw if readdir() resolved an error.


- Avoid excessive callbacks without sacrificing parallelism: Even though wait() blocks execution of Javascript it's important to note that Node is never actually blocked. Each Fiber you create is a whole new stack which can be switched into and out of appropriately. So while many stacks of JS are blocking, another is running. You can even use wait() to wait on many Futures at the same time via Future.wait(future1, future2, future3, ...) or Future.wait(arrayOfFutures).


- Choose when to use callbacks and when not to: To be honest I use callbacks about as often as I use blocking fibers in my applications. Sometimes callbacks just make more sense (especially with streams of data), but when I do use Fibers I am really really glad I have them available.


Fibers are compatible in 32-bit and 64-bit modes on Linux & OS X (Lion supported as of fibers 0.5). Windows is unfortunately not supported but if there is strong interest it could be built in without too much work.


Check out the documentation on github:

https://github.com/laverdet/node-fibers

(see "FUTURES" for new stuff)


Thanks for reading,

Marcel

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
TipTop | 1 Aug 2011 03:53
Picon

Re: Can I get feedback?

The node guide was what I was talking about. Also you might want to
look at the node source for ideas.

On Jul 31, 4:28 pm, dale tan <wtd...@...> wrote:
> you can check out a node style guide here:http://nodeguide.com/style.html
>
>
>
>
>
>
>
>
>
> On Sun, Jul 31, 2011 at 6:02 PM, Jaime Bueza <jbu...@...> wrote:
> > Try: change the function signature to be more consistent with Node's file
> > IO, mongo, couch by passing the error as a parameter first:
>
> > blog.text({limit: 2}, function(err, response) {
> >     //now we can do consistent error checking
> >     if (err) throw ...
>
> >     console.log(response.posts);
> > });
>
> > Awesome work though, looks very easy to use and great documentation!
>
> > *Jaime Bueza* Software Engineer
> > LinkedIn <http://www.linkedin.com/in/jbueza> | Twitter<http://www.twitter.com/jbueza>| Google
> > Plus <https://plus.google.com/115842419815311819079/about> | Blog<http://jbueza.blogspot.com>
>
> > On Sun, Jul 31, 2011 at 2:12 PM, Alexey Simonenko <dwarf...@...>wrote:
>
> >> Thank you, already done this.
>
> >> --
> >> Job Board:http://jobs.nodejs.org/
> >> Posting guidelines:
> >>https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> >> You received this message because you are subscribed to the Google
> >> Groups "nodejs" group.
> >> To post to this group, send email to nodejs@...
> >> To unsubscribe from this group, send email to
> >> nodejs+unsubscribe@...
> >> For more options, visit this group at
> >>http://groups.google.com/group/nodejs?hl=en?hl=en
>
> >  --
> > Job Board:http://jobs.nodejs.org/
> > Posting guidelines:
> >https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> > You received this message because you are subscribed to the Google
> > Groups "nodejs" group.
> > To post to this group, send email to nodejs@...
> > To unsubscribe from this group, send email to
> > nodejs+unsubscribe@...
> > For more options, visit this group at
> >http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> --
> CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents,
> files or previous e-mail messages attached to it may contain confidential
> information that is legally privileged and is intended for the designated
> recipient only. If you have received it in error, please notify the sender
> immediately and delete the original. Any other use of the email by you is
> STRICTLY PROHIBITED.

--

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@...
To unsubscribe from this group, send email to
nodejs+unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

wewe.tom | 1 Aug 2011 04:04
Picon

node.exe Windows executable fs.watch does not work

when I exute the code below :


var fs = require("fs");

fs.watchFile("test.js",function(){
    
});


I got error

TypeError: undefined is not a function
    at CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
    at Object.watchFile (fs.js:611:30)
    at Object.<anonymous> (d:\node\test.js:3:4)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at Array.<anonymous> (module.js:463:10)
    at EventEmitter._tickCallback (node.js:181:26)

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
mscdex | 1 Aug 2011 06:36
Picon
Gravatar

Re: How to protect environment from hostile scripts -- disallow('fs')

On Jul 31, 8:04 pm, falcon <shahb...@...> wrote:
> Is there a way to do such a thing in the node environment?

I'd run the scripts using the vm module in a child process.

--

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@...
To unsubscribe from this group, send email to
nodejs+unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Marak Squires | 1 Aug 2011 06:55
Picon
Gravatar

Re: Re: How to protect environment from hostile scripts -- disallow('fs')

I'd run the scripts using the vm module in a child process.

What is stopping the child process from killing it's parent process, spawning up new processes, spawning up new services, messing with the file space of it's parent process, etc ?

The only thing running your code using the vm module in a child process will do is isolate the execute code from the scope of the current running process. 

If you can't virtualize at an operating system level, and really want to spawn restricted child processes, you should use https://github.com/nodejitsu/haibu-carapace which allows for a plugin system for spawning up child processes ( such as chroot ) . It would be fairly easy to create some plugins for mocking out / disabling / extending node's core modules.

On Sun, Jul 31, 2011 at 9:36 PM, mscdex <mscdex-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On Jul 31, 8:04 pm, falcon <shahb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Is there a way to do such a thing in the node environment?

I'd run the scripts using the vm module in a child process.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Dave Elkan | 1 Aug 2011 07:11
Favicon

Re: Re: Node.js in New Zealand / Australia

Just a heads up that SydJS is on August 17. No node.js specific talks this month, but it's a great place to chat to other node users.


Register for free here before all slots are taken: http://sydjs.com/

Cheers.

~Dave

On Tue, Jul 12, 2011 at 4:32 PM, Marc Fasel <cookie.rebel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Dear Melbourinan Node.js people,

have a look here at Meetup:


if you have a Meetup account and add nodeJS to your alerts - the things that you are interested in - we can get a better picture whether it is worthwhile creating a Node.js Meetup group ... or work together with the existing #MelbJS Eventbrite group? Any thoughts on that?

Cheers

Marc

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines

You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
http://www.edave.net
https://github.com/dave-elkan
Twitter: <at> edave

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
nodejs+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Gmane