Re: statement_controlfoo()

2005-12-01 Thread Michele Dondi

On Wed, 30 Nov 2005, Piers Cawley wrote:


$fh = open '', 'quotefile' or fail;
$fh.print 'EOQ'


Hmmm... 1/sqrt(2) * ( |Perl5 + |Perl6 ) ?
;-)

(I thought ''  C. were gone...)


Michele
--
We can only see a short distance ahead, but we can see plenty there that needs 
to be done.
- Alan Turing


Capabilities in Perl6?

2005-12-01 Thread Rob Kinyon
I just read the slides about CAPerl (http://caperl.links.org/) and it's an
interesting idea. Leaving aside the question of whether this would work in
Perl5 or not, I think it would be very interesting to look at building this
concept into Perl6. Here's how I'd envision doing so:

* Any subroutine is allowed to work with the parameters it was given.
(If you didn't want it to work with those, why did you give them to it?)
Variables outside its scope are, by default, not allowed.
* When looking at a variable you're allowed to see, you are only allowed
to use the methods it exposes - no peeking!
* A subroutine may be explicitly granted access to a variable in a
parent scope through the grant keyword. (More later.)
* A subroutine may be disallowed access to a variable in a parent scope
through the revoke keyword. (More later.)
* Access to resources outside the program (files, etc) must be provided
to the subroutine through parameters or explicit grants.
* The outermost scope is completely trusted. (Someone has to be ...)

Grant/revoke (names may be changed, as needed) take the following
(pseudocode) signatures:
grant ( Sub, Var, [Var, ... ] )
revoke( Sub, Var, [Var, ... ] )

It is an error to:
* attempt to grant/revoke access to a variable you don't have access to
* attempt to grant/revoke access to a variable that isn't in scope for
the grantee

Thanks,
Rob


Re: Capabilities in Perl6?

2005-12-01 Thread Larry Wall
On Thu, Dec 01, 2005 at 10:54:14AM -0500, Rob Kinyon wrote:
: I just read the slides about CAPerl (http://caperl.links.org/) and it's an
: interesting idea. Leaving aside the question of whether this would work in
: Perl5 or not, I think it would be very interesting to look at building this
: concept into Perl6. Here's how I'd envision doing so:

We should probably think about as a potential variant of the recent
env addition to S02.

: * Any subroutine is allowed to work with the parameters it was given.
: (If you didn't want it to work with those, why did you give them to it?)

Um, maybe because you're calling a set of routines, and some of the routines
are interested in some of the initializers but not others?  Currently we
have methods implicitly all having *%_ to soak up unexpected arguments.

: Variables outside its scope are, by default, not allowed.

Maybe we need to differentiate lexical and dynamic scoping here.  The
env mechanism is only addressing dynamic scoping of lexicals.  And we
turn on $_ visibility by default.  That would be a considered a security
hole under this model.

: * When looking at a variable you're allowed to see, you are only allowed
: to use the methods it exposes - no peeking!

I'm not entirely sure what this means.  What counts as a method?
Use as an rvalue?  Use as an lvalue.  Modification?

Different scopes see different sets of methods to attributes depending
on whether the attribute is private/public, rw or readonly, native
or boxed type.  I can see a lot of times where you might be allowed
to read a native value but not write it, for instance.  (Possibly
readonly access to any externals should be the default for eval,
even if we don't go with a stronger capabilities model.)

: * A subroutine may be explicitly granted access to a variable in a
: parent scope through the grant keyword. (More later.)

More or less what the env declarator does.

: * A subroutine may be disallowed access to a variable in a parent scope
: through the revoke keyword. (More later.)

That would currently have to be done with an inner my scope to hide
the env scope.

: * Access to resources outside the program (files, etc) must be provided
: to the subroutine through parameters or explicit grants.

Hmm.  What if you want to provide part of %ENV?  I suppose one would have
to copy in your own env %ENV.

: * The outermost scope is completely trusted. (Someone has to be ...)

What's an outermost scope?  Dynamic or lexical?  What about modules that
can be executed directly?

: Grant/revoke (names may be changed, as needed) take the following
: (pseudocode) signatures:
: grant ( Sub, Var, [Var, ... ] )
: revoke( Sub, Var, [Var, ... ] )

Seems inside out to me in the use vars vs our sense.  I think
these things want to associate with the declaration, which is why
things like our and env are declarators.  Minor magical stuff
that is orthogonal to declarators ends up as traits.

: It is an error to:
: * attempt to grant/revoke access to a variable you don't have access to
: * attempt to grant/revoke access to a variable that isn't in scope for
: the grantee

More good reasons for attaching the grant to the declaration in the
first place.  If you're going to grant access by delegation then you
should *use* delegation, I expect.

Larry


Re: Capabilities in Perl6?

2005-12-01 Thread Yuval Kogman
On Thu, Dec 01, 2005 at 10:54:14 -0500, Rob Kinyon wrote:
 I just read the slides about CAPerl (http://caperl.links.org/) and it's an
 interesting idea.

The ideas I tossed around regarding the circular prelude should
make perl 6 be roughly on the same level as javascript in terms of
this security stuff.

This is a very good start towards a model where a crippled runtime
is mixed with a fully priviliged one, with grey areas in the middle.

-- 
 ()  Yuval Kogman [EMAIL PROTECTED] 0xEBD27418  perl hacker 
 /\  kung foo master: : neeyah!



pgpyPn2eh2Y9e.pgp
Description: PGP signature