Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes issue #1 #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rewanthtammana
Copy link

In PR #3 , we were parsing a file every time when the user tries to autocomplete --script-args command, it is very ineffective as we have to access the file frequently, the reason why we can't use this approach is well explained in PR #3 .
I developed a new code which doesn't waste its time on I/O operations and instead the new code is directly connected to the kernel.

Working of my code

The script-args.db file is a db file which contains all the available --script-args options along with script-name.

  • Create this folder $NMAPDIR/scripts/script-args/ which will be storing all the files required by the autocomplete feature.
  • script-args.db is located in "$NMAPDIR/scripts/script-args/script-args.db".
  • Execute the script.sh script.
    On executing the above script, it parses the script-args.db and creates empty directories for all scripts which are present in script-args.db file. The empty directories are created inside scripts/script-args/ folder and name of these empty folders is same as the name of the available scripts.Each folder also contains empty files named with the options available for that script.

Let me illustrate this with an example.
Assume there are only two lines in the script-args.db file

$ cat script-args.db
acarsd-info: acarsd-info.timeout acarsd-info.bytes
ajp-auth: ajp-auth.path

Format of the script-args file is as follows,
<scriptname>: <arg1> <arg2> <arg3> ....

On executing the script.sh file, it extracts the script-name and the available options for every script.
So the directory structure would be something like this,

|- acarsd-info/
	|- acarsd-info.timeout
 	|- acarsd-info.bytes
|- ajp-auth/
	|- ajp-auth.path

So, here I'm using the name of the files to autocomplete --script-args . This is a way faster than the previous method as there are no I/O operations involved and it is directly associated with the kernel itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant