master
1// ________ _________
2// \________\--------___ ___ ____----------/_________/
3// \_______\----\\\\\\ //_ _ \\ //////-------/________/
4// \______\----\\|| (( ~|~ ))) ||//------/________/
5// \_____\---\\ ((\ = / ))) //----/_____/
6// \____\--\_))) \ _)))---/____/
7// \__/ ((( (((_/
8// ヾღ彡 | -))) - ))
9// =================================================================
10// _wrapper.js
11// -----------------------------------------------------------------
12// author: @soron, @archangel
13// SEC LVL: 4
14// Chars: 447
15// Descr: Test the security level of given script and warms the user
16// if it is not FULLSEC. If the script is FULLSEC it is called
17// immediatly, else the user is prompted to override the warning.
18// Syntax: _wrapper {target:#s.user.script , <passthrough:scripts_args> , <override: true>}
19// =================================================================
20
21// This is WIP and not working 100% as intended. I'm still trying to
22// figure out how the passthrough can work and how you should syntax it.
23
24function (context, args)
25{
26 var target = args.target;
27 // scripts.get_level returns a number inside scripts, or a string like 'FULLSEC' or 'MIDSEC' on command line
28 var sec_level = #s.scripts.get_level({name:target.name});
29
30 var l = #s.scripts.lib();
31
32 // is it less than FULLSEC? if so, warn the user
33 if (sec_level < 4 && !args.override) {
34 var sec_level_name = l.security_level_names[sec_level];
35 return {
36 ok: false,
37 msg: "The script you have passed is " + sec_level_name + ". Are you sure you want to continue? If so, pass override:true"
38 };
39 }
40
41 var result = target.call(args.passthrough);
42
43 return {
44 ok: true,
45 msg: "Target called. See 'debug' below to inspect the output.",
46 debug: result,
47 }
48}