Fixing Broxygen indexing confusion for plugins.

Because plugins register their script directories with the BROPATH,
Broxygen stripped them out from plugin script paths it was indexing.
That then led to multiple plugins ending up with the same script
paths, triggering warnings about duplicates.

I fixed this by checking if a script comes out of a plugin. If so, it
gets an artifcial index prefix "<plugin-name>:", followed by the
script's relative path inside the plugin's top-level directory. For
example, "/opt/bro/lib/bro/plugins/Bro_Netmap/scripts/init.bro" now
turns into "Bro::Netmap:scripts/init.bro" for Broxygen purposes
(whereas it used to be just "init.bro").

Addresses BIT-1663.

(Can't think of a good way to add a test for this unfortunately.)
This commit is contained in:
Robin Sommer 2016-09-29 16:06:43 -07:00
parent b6a0802227
commit 8acf995361
3 changed files with 61 additions and 10 deletions

View file

@ -149,6 +149,13 @@ public:
*/
template<class T> std::list<T *> Components() const;
/**
* Returns the (dynamic) plugin associated with a given filesytem
* path. The path can be the plugin directory itself, or any path
* inside it.
*/
Plugin* LookupPluginByPath(std::string path);
/**
* Returns true if there's at least one plugin interested in a given
* hook.
@ -329,6 +336,9 @@ private:
// of that type enabled.
hook_list** hooks;
// A map of all the top-level plugin directories.
std::map<std::string, Plugin*> plugins_by_path;
// Helpers providing access to current state during dlopen().
static Plugin* current_plugin;
static const char* current_dir;