mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
9 years ago
13 changed files with 126 additions and 40 deletions
@ -0,0 +1,15 @@ |
|||
define: DUK_USE_PARANOID_ERRORS |
|||
feature_enables: DUK_OPT_PARANOID_ERRORS |
|||
introduced: 1.4.0 |
|||
default: false |
|||
tags: |
|||
- ecmascript |
|||
- sandbox |
|||
description: > |
|||
When enabled, error messages won't involve summarization of keys or values. |
|||
Summaries may be an issue in some security sensitive environments because |
|||
error messages will include e.g. property keys. |
|||
|
|||
The default is to summarize offending base value and key for property access |
|||
errors such as "null.foo = 123;", invalid calls such as "undefined()", etc. |
|||
Base values and keys are summarized using duk_push_string_tval_readable(). |
@ -1,14 +0,0 @@ |
|||
define: DUK_USE_VERBOSE_PROP_ERRORS |
|||
feature_enables: DUK_OPT_VERBOSE_PROP_ERRORS |
|||
introduced: 1.4.0 |
|||
default: true |
|||
tags: |
|||
- ecmascript |
|||
- sandbox |
|||
description: > |
|||
Summarize offending base value and key for property operation errors |
|||
such as "null.foo = 123;". Base values and keys are summarized using |
|||
duk_push_string_tval_readable(). |
|||
|
|||
The key/value summary includes string data which may be an issue for some |
|||
security critical environments. Disable this option in such environments. |
@ -0,0 +1,80 @@ |
|||
/* |
|||
* Fragile testcase for testing call error messages. |
|||
*/ |
|||
|
|||
/*--- |
|||
{ |
|||
"custom": true |
|||
} |
|||
---*/ |
|||
|
|||
/*=== |
|||
TypeError: undefined not callable |
|||
TypeError: 123 not callable |
|||
TypeError: 321 not callable |
|||
TypeError: undefined not callable |
|||
TypeError: 234 not callable |
|||
"TypeError: undefined not callable" |
|||
"TypeError: null not callable" |
|||
"TypeError: true not callable" |
|||
"TypeError: false not callable" |
|||
"TypeError: 123 not callable" |
|||
"TypeError: 'a\u1234string' not callable" |
|||
"TypeError: [object Array] not callable" |
|||
"TypeError: [object Object] not callable" |
|||
===*/ |
|||
|
|||
var global = 321; |
|||
|
|||
function test() { |
|||
var tmp; |
|||
var dummy = 123; |
|||
var obj = { bar: 234 }; |
|||
|
|||
// Basic cases
|
|||
try { |
|||
(undefined)(); // literal
|
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
try { |
|||
dummy(); // register-mapped variable
|
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
try { |
|||
global(); // global variable, slow path lookup
|
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
try { |
|||
obj.foo(); // object property, nonexistent
|
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
try { |
|||
obj.bar(); // object property, exists but not callable
|
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
|
|||
// Summarization of different value types is already covered by
|
|||
// test-dev-prop-error-messages.js, but cover a few values here.
|
|||
|
|||
[ |
|||
undefined, null, true, false, 123, 'a\u1234string', [ 1, 2, 3 ], { foo: 'bar' } |
|||
].forEach(function (v) { |
|||
try { |
|||
v(); |
|||
} catch (e) { |
|||
tmp = Duktape.enc('jx', String(e)); // JX encode to get ASCII
|
|||
print(tmp); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
} |
Loading…
Reference in new issue