Hi Edmond,<div><br></div><div>This is exactly what I'm working on with my patches. But as it is the first time I've poked around these particular parts of the guts of erlang, I am hopeful someone can confirm where the best place to do such dangerous things is :)</div>
<div><br></div><div>Dave<br><br><div class="gmail_quote">On Tue, Sep 27, 2011 at 12:31 PM, Edmond Begumisa <span dir="ltr"><<a href="mailto:ebegumisa@hysteria-tech.com">ebegumisa@hysteria-tech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi there,<br>
<br>
Late on this and the preceding thread, but I've been *very* interested in something like this for a while now and raised it once...<br>
<br>
<a href="http://erlang.org/pipermail/erlang-questions/2011-May/058871.html" target="_blank">http://erlang.org/pipermail/<u></u>erlang-questions/2011-May/<u></u>058871.html</a><br>
<a href="http://erlang.org/pipermail/erlang-questions/2011-May/058904.html" target="_blank">http://erlang.org/pipermail/<u></u>erlang-questions/2011-May/<u></u>058904.html</a><br>
<br>
I personally would really like (c) below. Mainly because it would render packaging tools "less" useful and make deployment really easy.<br>
<br>
I think one can draw inspiration from others like Mozilla XULRunner for both locating code and how they make use of web-style deployment...<br>
<br>
* Support for hardcoded locations based on URIs...<br>
-location("<a href="http://erlang.org/foo.erl" target="_blank">http://erlang.org/<u></u>foo.erl</a>").<br>
-location("file://./foo.erl").<br>
<br>
* Support for centralising locations...<br>
-location("erlang://my_otp_<u></u>app/foo.erl")<br>
where the actual location is picked up from "erlang.manifest" that maps "my_app" to some ebin dir similar to "chrome.manifest" in Mozilla.<br>
<br>
* Support for custom file streams...<br>
-location("riak://my_server/<u></u>foo.erl")<br>
where loader would expect "riak.manifest" to tell it how to fetch the file (possibly an {M,F,A} entry)<br>
<br>
* Enforce security restrictions for unsigned code<br>
<br>
On that last point: I wonder for example how possible it would be to restrict code loaded from remote locations to the "same-source" rule. Also (probably more tricky), how difficult it would be enforce a rule that code coming from remote unsigned sources cannot have access to the local filesystem or erlang ports.<br>
<br>
Mozilla makes two broad categories for code loaded from URIs -- chrome:// (call it erlang:// for our case) that has access to everything, and everything else (http://, file://, etc) that mustn't access the (full) local file system or external processes. This would be nice to have, because code signing can get tedious.<br>
<br>
- Edmond -<div><div></div><div class="h5"><br>
<br>
<br>
On Tue, 27 Sep 2011 19:47:22 +1000, Joe Armstrong <<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Sep 21, 2011 at 7:40 PM, David Goehrig <<a href="mailto:dave@nexttolast.com" target="_blank">dave@nexttolast.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Last night I began hacking on code.erl, code_server.erl, and looking to extend load_file(Module :: atom()) to include a load_file(Module, Url) function that would look for the module at the associated URL rather than searching for the file via abs path. It would then compare the sha256 hash of the file against the copy in cache and bail if they are different (no hash in cache adds it and uses as the baseline).<br>
<br>
I was wondering if there was a good way to verify that a .beam has not been modified since last load.<br>
<br>
For example:<br>
<br>
-module(my_mod)<br>
-require(daves_mod,"<a href="http://erlang.dloh.org/" target="_blank">http://<u></u>erlang.dloh.org/</a>")<br>
<br>
Could then look for <a href="http://erlang.dloh.org/daves_mod.erl" target="_blank">http://erlang.dloh.org/daves_<u></u>mod.erl</a> and download and compile a local beam. Once I have that beam, I can just load from cache, but what happens if the beam is modified after compilation?<br>
</blockquote>
<br>
I don't really understand. The only (legal) way to modify the beam<br>
is to change the source and recompile. I think you have to<br>
decide exactly what the semantics of require are. There are several<br>
possible meanings:<br>
<br>
a) We check the require targets *before* compilation with<br>
a separate program<br>
<br>
ie image a program:<br>
<br>
> check_dependencies *.erl<br>
<br>
This parses all erlang files (*.erl) extract the require information<br>
then it check the cache to see if it has all the necessary files<br>
<br>
Even this program could have two modes:<br>
a1) always check with the origonal source for new versions<br>
a2) check once every N days (or minutes or hours or something)<br>
<br>
b) we check at compile time<br>
<br>
c) we check at usage time. The first time we call daves_module and find<br>
it has not been loaded we check the cache and so on<br>
<br>
a) represents an early binding scenario, c) very-late binding<br>
<br>
If you are in a development scenario I'd favor a) because have code<br>
changing rapidly under my feet would worry me. (actually a) is the<br>
easiest to implement<br>
<br>
If I am in a deployment scenario I might choose c) I might even want to<br>
*push* changes rather than reply on polling or some other way of<br>
finding out that the code has changed.<br>
<br>
The point is that you have to have a clear idea of which of these<br>
particular problems you are solving.<br>
<br>
Doing a really good job on the a) scenario interest me - I'd just like<br>
to type "make" and be told - "foo123.erl on http:/..../ has changed from the<br>
cached version, do you want to update?" ....<br>
<br>
Only a) fits nicely with unit testing/type checking etc. delayering<br>
to load time makes testing difficult. If things can change under your feet<br>
without you knowing, life might become difficult.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The other thing I would like to add is DNS TXT records that could be published sha256 hashes of each source module.<br>
<br>
<a href="http://erlang.dloh.org/daves_mod.erl" target="_blank">http://erlang.dloh.org/daves_<u></u>mod.erl</a> 45663AFDA....<br>
<br>
Adding a<br>
<br>
-signature("<a href="http://erlang.dlog.org/daves_mod.erl" target="_blank">http://erlang.<u></u>dlog.org/daves_mod.erl</a>","<u></u>45663AFDA....")<br>
<br>
Would allow a 3 part verification of the source:<br>
<br>
1.) I can compute the source has the right hash<br>
2.) I can look up that the module has the same published signature<br>
3.) I can verify against the original at the specified URL<br>
<br>
In this scenario it is not enough to modify the source and rehash, nor enough to replace the upsteam file, but also replace the DNS entry without anyone noticing.<br>
<br>
Thoughts?<br>
</blockquote>
<br>
Good stuff - needs some thought though. I was thinking of signing/validating<br>
the source with an RSA public/private keypair.<br>
<br>
I'd like to see this as part of the build process, if I did "make" I<br>
might like to see:<br>
<br>
$ make<br>
module foo123.erl is up to date. Written by joearms *validated*<br>
module bar23.erl has a newer version<br>
module bingo23.erl is up to date written by cleverperson *untrusted*<br>
...<br>
etc.<br>
<br>
<br>
/Joe<br>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Dave<br>
-=-=- <a href="mailto:dave@nexttolast.com" target="_blank">dave@nexttolast.com</a> -=-=-<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
<br>
</blockquote>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote>
<br>
<br></div></div><font color="#888888">
-- <br>
Using Opera's revolutionary e-mail client: <a href="http://www.opera.com/mail/" target="_blank">http://www.opera.com/mail/</a><br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>-=-=-=-=-=-=-=-=-=-=- <a href="http://blog.dloh.org/">http://blog.dloh.org/</a><br>
</div>