diff tcb.js @ 10:16a605ff036c

The TCB can now define a global checkAccess() handler. It also has access to a lookupProperty() function that can retrieve an attribute of an object without initiating security checks or property getters.
author Atul Varma <varmaa@toolness.com>
date Fri, 19 Jun 2009 14:44:39 -0700
parents e14f496e6e08
children bde6607a3620
line wrap: on
line diff
--- a/tcb.js	Fri Jun 19 12:50:42 2009 -0700
+++ b/tcb.js	Fri Jun 19 14:44:39 2009 -0700
@@ -1,3 +1,12 @@
+// This security function is called by the platform whenever a
+// particular property needs to be accessed on a particular object.
+function checkAccess(obj, id) {
+  var frame = stack();
+  if (frame.filename != "tcb.js")
+    print("access request from " + frame.filename);
+  return lookupProperty(obj, id);
+}
+
 // This function is called by the platform whenever an uncaught exception
 // occurs.
 function handleError() {
@@ -19,10 +28,6 @@
   print(lines.join('\n'));
 }
 
-function showInfo() {
-  print("Hello World.");
-}
-
 function throwError() {
   function innerThrowError() {
     throw new Error("hi");
@@ -30,13 +35,9 @@
   innerThrowError();
 }
 
-showInfo();
 try {
-  print("about to throw.");
   throwError();
 } catch (e) {
-  printTraceback(lastExceptionTraceback);
-  print(e);
 }
 
 var module = require("sample-module.js", {blop: "hello"});