public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Mark Raynsford <list+org.sourceware.kawa@io7m.com>, kawa@sourceware.org
Subject: Re: Sandboxing Kawa
Date: Wed, 22 Nov 2017 19:58:00 -0000	[thread overview]
Message-ID: <d89e7045-90b7-5435-234c-d13c85b207de@bothner.com> (raw)
In-Reply-To: <20171122111055.21383f32@copperhead.int.arc7.info>

On 11/22/2017 12:10 PM, Mark Raynsford wrote:
> I have the following questions after playing with the Kawa API a bit:
> 
> 1. Is it possible to restrict the initially available symbols in a
> kawa.standard.Scheme instance to a tiny core subset (such as lambda,
> if, define, begin, etc)? A default Scheme instance in Kawa has 807
> symbols in the environment.

The default Kawa environment is defined by the (two) calls to
loadClass("kawa.lib.kawa.base", xxx) in kawa/standard/Scheme.java.
So all of the initially visible names are defined by kawa.lib.kawa.base
(defined in kawa/lib/kawa/base.scm).  So you can replace kawa.lib.kawa.base
to a "smaller" initial library.

I suggested creating sub-classes of kawa.standard,Scheme and
kawa.standard.SchemeCompilation.

In addition you need to override checkDefaultBinding from
SchemeCompilation.  The easiest and most reliable is just have it return null.

> 2. Is it possible to restrict the interpreter to only working with a
> single java.nio.file.FileSystem? I'd like it if any attempt to do I/O
> went through a given filesystem instance. I don't mind if I have to
> implement my own I/O library to do this.
> 
> 3. Is it possible to restrict the classes that the interpreter is
> allowed to access or import? For example, right now nothing stops the
> someone from writing (java.lang.System:exit 0).

Both of these require disabling "backdoors" to Java classes, methods,
fields.  Overriding ,checkDefaultBidning and maybe the colon
operator should do that.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2017-11-22 19:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 11:11 Mark Raynsford
2017-11-22 19:58 ` Per Bothner [this message]
2017-11-22 20:58   ` Mark Raynsford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d89e7045-90b7-5435-234c-d13c85b207de@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    --cc=list+org.sourceware.kawa@io7m.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).