'Search shared files from a file name (either a string or a
regexp), only from scripts using the "ls" NSE module.'

def searchfile(self, fname=None, scripts=None):

    if (fname is None):
        fname = {'$exists': True}
    if (scripts is None):
        return {'ports.scripts.ls.volumes.files.filename': fname}
    if isinstance(scripts, basestring):
        scripts = [scripts]
    return {'ports.scripts': {'$elemMatch': {'id': (scripts.pop() if (len(scripts) == 1) else {'$in': scripts}), 'ls.volumes.files.filename': fname}}}
