diff --git a/docs/scripting.xml b/docs/scripting.xml index 6c319cb11..d450e8f49 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -880,45 +880,35 @@ that. dependencies” script variable script dependencies - In earlier versions of NSE, script authors were able to specify a - runlevel that would specify the execution order of - the scripts NSE will run. Scripts that had a smaller runlevel would - run before scripts with a larger runlevel. Scripts with an equal - runlevel would run concurrently. This method of describing an ordered - execution has been replaced by dependencies. - Dependencies specify other discrete scripts that the script depends on - for its execution. A script may need to depend on another script for - many reasons. For example, many scripts may rely on authentication - credentials discovered by brute-forcing scripts. + The dependencies field is an array containing the + names of scripts that should run before this script. This is used when + one script can make use of the results of another. For example, most of + the smb-* scripts depend on + smb-brute,smb-brute.nse + because the accounts found by smb-brute may allow + the other scripts to get more information. - Scripts may specify an array of script names that the script depends - on. When we say "depends on", we mean it in a loose sense. That is, a + When we say depend on, we mean it in a loose sense. That is, a script will still run despite missing dependencies. Given the dependencies, the script will run after all the scripts listed in the - dependencies array. We may specify a dependencies array like so: + dependencies array. This is an example of the + dependencies table from + smb-os-discovery:smb-os-discovery.nse -dependencies = {"script1", "script2"} +dependencies = {"smb-brute"} - - - The dependencies table is an optional script field. NSE will assume + The dependencies table is optional. NSE will assume the script has no dependencies if the field is omitted. - Dependencies offer many advantages over runlevels. First, and - obviously, scripts can now specify each script they depend on without - worrying about specifying an arbitrary number that is greater than - scripts it depends on. Second, scripts no longer limit NSE's ability - to intelligently schedule scripts to maximize parallelism. Having - unique runlevels would force NSE to schedule the scripts to execute - serially. - - - Runlevels are still used as an internal representation of the order of - scripts that are automatically generated by the dependencies. When - running your scripts you will see each runlevel (and the number of - runlevels) grouping of scripts run in NSE's output: + Dependencies establish an internal ordering of scripts, assigning each + one a number called a runlevelUp through + Nmap version 5.10BETA2, dependencies didn't exist and script authors + had to set a runlevel field manually..runlevel + When + running your scripts you will see the runlevel (along with the total number of + runlevels) of each grouping of scripts run in NSE's output: NSE: Script scanning 127.0.0.1. NSE: Starting runlevel 1 (of 3) scan. @@ -1834,11 +1824,9 @@ try(socket:send(result)) information to completely different scripts. For example, the snmp-brute script saves a discovered community name in the registry where it may be used by other - SNMP scripts. Scripts which leave information behind for a - second script must have a lower runlevel - than that second script, or there is no guarantee that they - will run first.run level of - scripts + SNMP scripts. Script which use the results of another script + must declare it using the dependencies + variable to make sure that the earlier script runs first. Because every script can write to the registry table, it @@ -1891,7 +1879,7 @@ try(socket:send(result)) The head of the script is essentially its meta information. This includes the - fields: description, categories, runlevel, author, and license as well as + fields: description, categories, dependencies, author, and license as well as initial NSEDoc information such as usage, args, and output tags (see ). @@ -2683,9 +2671,10 @@ and open|filteredopen|filteredaction. Next, a Lua thread is created for each of the matching script-target combinations. Each thread -is stored with pertinent information such as the runlevel, target, target port (if applicable), host and port tables +is stored with pertinent information such as its dependencies, target, target port (if applicable), host and port tables (passed to the action), and the script type (service or host script). -The mainloop function then processes each runlevel grouping of threads in order. +The mainloop function then processes each runlevelrunlevel +grouping of threads in order.