From 6e7e48874d6607e69007d9ed38c72ee4abdf5b6d Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Mon, 4 Nov 2024 20:15:48 +0000 Subject: [PATCH 01/58] Added plugin list subcommand functionality --- surfactant/__main__.py | 9 ++++++++- surfactant/cmd/plugin.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 surfactant/cmd/plugin.py diff --git a/surfactant/__main__.py b/surfactant/__main__.py index b5d70552..d422eb87 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -18,7 +18,7 @@ from surfactant.cmd.merge import merge_command from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui - +from surfactant.cmd.plugin import list @click.group() @click.version_option( @@ -52,6 +52,9 @@ def version(): def cli(): """Commandline interface used to modify SBOM entries.""" +@main.group("plugin") +def plugin(): + """ Manage plugins """ # Main Commands main.add_command(generate) @@ -61,11 +64,15 @@ def cli(): main.add_command(merge_command) main.add_command(create_config) main.add_command(ui) +main.add_command(plugin) # CLI Subcommands cli.add_command(find) cli.add_command(edit) cli.add_command(add) +# Plugin Subcommands +plugin.add_command(list) + if __name__ == "__main__": main() diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py new file mode 100644 index 00000000..e02f0028 --- /dev/null +++ b/surfactant/cmd/plugin.py @@ -0,0 +1,13 @@ +import click +from surfactant.plugin.manager import get_plugin_manager + +@click.command("list") +def list(): + pm = get_plugin_manager() + print("-------") + print("PLUGINS") + for p in pm.get_plugins(): + print("-------") + print(f"canonical name: {pm.get_canonical_name(p)}") + plugin_name = pm.get_name(p) if pm.get_name(p) else "" + print(f"name: {plugin_name}") From 45a1b6d6daff853401436efb508042f9b502eacc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 23:50:39 +0000 Subject: [PATCH 02/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/__main__.py | 7 +++++-- surfactant/cmd/plugin.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index d422eb87..6542ab2a 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,9 +16,10 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command +from surfactant.cmd.plugin import list from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui -from surfactant.cmd.plugin import list + @click.group() @click.version_option( @@ -52,9 +53,11 @@ def version(): def cli(): """Commandline interface used to modify SBOM entries.""" + @main.group("plugin") def plugin(): - """ Manage plugins """ + """Manage plugins""" + # Main Commands main.add_command(generate) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index e02f0028..74c79d58 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,6 +1,8 @@ import click + from surfactant.plugin.manager import get_plugin_manager + @click.command("list") def list(): pm = get_plugin_manager() From d141ce58dbb7c921f11f9a8e9520175ebe0da6c0 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Mon, 4 Nov 2024 23:57:44 +0000 Subject: [PATCH 03/58] changed subcommand from list to display to avoid python builtin redefinition --- surfactant/cmd/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index e02f0028..b3e2833f 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,8 +1,8 @@ import click from surfactant.plugin.manager import get_plugin_manager -@click.command("list") -def list(): +@click.command("display") +def display(): pm = get_plugin_manager() print("-------") print("PLUGINS") From 75afc0cba211ff96dca09c3c0cd934596e2cd2ea Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 00:02:27 +0000 Subject: [PATCH 04/58] changed subcommand from list to display to avoid python builtin redefinition --- surfactant/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index d422eb87..64e2318d 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -72,7 +72,7 @@ def plugin(): cli.add_command(add) # Plugin Subcommands -plugin.add_command(list) +plugin.add_command(display) if __name__ == "__main__": main() From dbd9fba9063de49bbb6197a602528b425c54495e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:07:28 +0000 Subject: [PATCH 05/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/__main__.py | 1 - surfactant/cmd/plugin.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index 72f9d261..230234d6 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,6 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import list from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 709e7007..155d0b5b 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -2,6 +2,7 @@ from surfactant.plugin.manager import get_plugin_manager + @click.command("display") def display(): pm = get_plugin_manager() From 79a3675966aa81c400d39f7a6e7274cac04e3bf8 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 00:11:21 +0000 Subject: [PATCH 06/58] fixed import function --- surfactant/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index 72f9d261..b9994609 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import list +from surfactant.cmd.plugin import display from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui From be48bb5972bbe7f60cb9ba46458daa30c06b9b24 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 16:29:43 +0000 Subject: [PATCH 07/58] changed subcommand name to list in click decorator --- surfactant/cmd/plugin.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 155d0b5b..92fb7029 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,9 +1,7 @@ import click - from surfactant.plugin.manager import get_plugin_manager - -@click.command("display") +@click.command(name="list") def display(): pm = get_plugin_manager() print("-------") From 3f911a55824513f4cd9f2ec7c64926f7d2a0a4a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:33:02 +0000 Subject: [PATCH 08/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/cmd/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 92fb7029..5b1fbc88 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,6 +1,8 @@ import click + from surfactant.plugin.manager import get_plugin_manager + @click.command(name="list") def display(): pm = get_plugin_manager() From 261cc6e72029ae9657a1ce5d585aff57d5fba832 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 20:50:42 +0000 Subject: [PATCH 09/58] Changed subcommand definition name. Added docstring description to subcommand --- surfactant/__main__.py | 6 +++--- surfactant/cmd/plugin.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index b9994609..9499e098 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import display +from surfactant.cmd.plugin import plugin_list_cmd from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui @@ -56,7 +56,7 @@ def cli(): @main.group("plugin") def plugin(): - """Manage plugins""" + """Manage plugins.""" # Main Commands @@ -75,7 +75,7 @@ def plugin(): cli.add_command(add) # Plugin Subcommands -plugin.add_command(display) +plugin.add_command(plugin_list_cmd) if __name__ == "__main__": main() diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 92fb7029..cf97245e 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -2,7 +2,8 @@ from surfactant.plugin.manager import get_plugin_manager @click.command(name="list") -def display(): +def plugin_list_cmd(): + """Lists plugins.""" pm = get_plugin_manager() print("-------") print("PLUGINS") From 5e20458fd542c02af3e8c48aa8515c060f613f9b Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 20:55:27 +0000 Subject: [PATCH 10/58] Changed subcommand definition name. Added docstring description to subcommand --- surfactant/cmd/plugin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 1e8a1fd9..9d4f60bb 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -2,7 +2,6 @@ from surfactant.plugin.manager import get_plugin_manager - @click.command(name="list") def plugin_list_cmd(): """Lists plugins.""" From b88b0e7e14595ce0fdf79c618f247f3c9e78f251 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 5 Nov 2024 22:01:11 +0000 Subject: [PATCH 11/58] Added boiler plate for disable commmand. --- surfactant/cmd/plugin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 9d4f60bb..99870732 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -13,3 +13,14 @@ def plugin_list_cmd(): print(f"canonical name: {pm.get_canonical_name(p)}") plugin_name = pm.get_name(p) if pm.get_name(p) else "" print(f"name: {plugin_name}") + + +@click.command(name="disable") +@click.argument('plugin_names', nargs=-1) +def plugin_disable_cmd(plugin_names): + """Disables one or more plugins.""" + if not plugin_names: + raise click.UsageError("At least one plugin name must be specified.") + + for plugin_name in plugin_names: + print(f"Disabling {plugin_name} plugin") From 52e0703e2ffdd741c2746eec7ee2182c484000ab Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 18:19:11 +0000 Subject: [PATCH 12/58] Added disable plugin functionality. --- surfactant/cmd/plugin.py | 45 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 99870732..d030dc9c 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,7 +1,7 @@ import click - +from surfactant.cmd.config import config from surfactant.plugin.manager import get_plugin_manager - +from surfactant.configmanager import ConfigManager @click.command(name="list") def plugin_list_cmd(): """Lists plugins.""" @@ -14,6 +14,8 @@ def plugin_list_cmd(): plugin_name = pm.get_name(p) if pm.get_name(p) else "" print(f"name: {plugin_name}") +import click +from typing import List @click.command(name="disable") @click.argument('plugin_names', nargs=-1) @@ -21,6 +23,41 @@ def plugin_disable_cmd(plugin_names): """Disables one or more plugins.""" if not plugin_names: raise click.UsageError("At least one plugin name must be specified.") - + + pm = get_plugin_manager() + config_manager = ConfigManager() + + # Debugging: Print config file path and current config + print(config_manager._get_config_file_path()) + config_manager.print_config() + + # Retrieve the current list of blocked plugins + current_blocked_plugins = config_manager.get('plugins', 'blocked', []) + + # Ensure current_blocked_plugins is a list + if isinstance(current_blocked_plugins, str): + current_blocked_plugins = [current_blocked_plugins] + for plugin_name in plugin_names: - print(f"Disabling {plugin_name} plugin") + # Check if the plugin is already blocked + if pm.is_blocked(plugin_name): + print(f"Plugin '{plugin_name}' is already disabled.") + continue + + # Unregister the plugin + plugin = pm.unregister(name=plugin_name) + if plugin is None: + print(f"Plugin '{plugin_name}' not found.") + continue + + # Block the plugin to prevent future registration + pm.set_blocked(plugin_name) + + # Add the plugin to the blocked list if not already present + if plugin_name not in current_blocked_plugins: + current_blocked_plugins.append(plugin_name) + + # Update the configuration to reflect the disabled status + if current_blocked_plugins: + config_manager.set('plugins', 'blocked', current_blocked_plugins) + click.echo(f"Updated blocked plugins: {current_blocked_plugins}") From 768574dd10a85f597d44fe71d7cdac57d1bb003c Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 18:39:34 +0000 Subject: [PATCH 13/58] Added disable subcommand to main. --- surfactant/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index 9499e098..c26e04c2 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import plugin_list_cmd +from surfactant.cmd.plugin import plugin_list_cmd, plugin_disable_cmd from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui @@ -76,6 +76,7 @@ def plugin(): # Plugin Subcommands plugin.add_command(plugin_list_cmd) +plugin.add_command(plugin_disable_cmd) if __name__ == "__main__": main() From 3a8342c762da83cf424187166f0a87e61bf6ad2d Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 19:59:09 +0000 Subject: [PATCH 14/58] Added variables for config section and key and changed section to core. --- surfactant/cmd/plugin.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index d030dc9c..65071f70 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -23,16 +23,18 @@ def plugin_disable_cmd(plugin_names): """Disables one or more plugins.""" if not plugin_names: raise click.UsageError("At least one plugin name must be specified.") - + section = 'core' + section_key = 'blocked' + pm = get_plugin_manager() config_manager = ConfigManager() # Debugging: Print config file path and current config - print(config_manager._get_config_file_path()) - config_manager.print_config() + #print(config_manager._get_config_file_path()) + #config_manager.print_config() # Retrieve the current list of blocked plugins - current_blocked_plugins = config_manager.get('plugins', 'blocked', []) + current_blocked_plugins = config_manager.get(section, section_key, []) # Ensure current_blocked_plugins is a list if isinstance(current_blocked_plugins, str): @@ -59,5 +61,5 @@ def plugin_disable_cmd(plugin_names): # Update the configuration to reflect the disabled status if current_blocked_plugins: - config_manager.set('plugins', 'blocked', current_blocked_plugins) + config_manager.set(section, section_key, current_blocked_plugins) click.echo(f"Updated blocked plugins: {current_blocked_plugins}") From da8554fb50b6d50007410687a8d44693d42a9a9e Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 20:43:11 +0000 Subject: [PATCH 15/58] Re-implemented disable command with functionality in surfactant/plugin/manager.py --- surfactant/plugin/manager.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index e1b75eda..ccb923ed 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -8,7 +8,7 @@ from loguru import logger from surfactant.plugin import hookspecs - +from surfactant.configmanager import ConfigManager def _register_plugins(pm: pluggy.PluginManager) -> None: # pylint: disable=import-outside-toplevel @@ -64,6 +64,25 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: ) for plugin in internal_plugins: pm.register(plugin) + + config_manager = ConfigManager() + + # Retrieve the current list of blocked plugins + current_blocked_plugins = config_manager.get("core", "disable_plugins", []) + for plugin_name in current_blocked_plugins: + # Check if the plugin is already blocked + if pm.is_blocked(plugin_name): + print(f"Plugin '{plugin_name}' is already disabled.") + continue + + # Unregister the plugin + plugin = pm.unregister(name=plugin_name) + if plugin is None: + print(f"Plugin '{plugin_name}' not found.") + continue + + # Block the plugin to prevent future registration + pm.set_blocked(plugin_name) def get_plugin_manager() -> pluggy.PluginManager: From be12bfa79694d2bde36b28199777c9bd7f23df49 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 20:50:07 +0000 Subject: [PATCH 16/58] Added print disabled plugins to list subcommand --- surfactant/cmd/plugin.py | 52 +++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 65071f70..c1859346 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,6 +1,4 @@ import click -from surfactant.cmd.config import config -from surfactant.plugin.manager import get_plugin_manager from surfactant.configmanager import ConfigManager @click.command(name="list") def plugin_list_cmd(): @@ -14,9 +12,22 @@ def plugin_list_cmd(): plugin_name = pm.get_name(p) if pm.get_name(p) else "" print(f"name: {plugin_name}") -import click -from typing import List + # List disabled pluginsi + config_manager = ConfigManager() + section = 'core' + section_key = 'disable_plugins' + + # Retrieve the current list of plugins that should be blocked + current_blocked_plugins = config_manager.get(section, section_key, []) + + print("-------") + print("Disabled Plugins") + for disabled_plugin in current_blocked_plugins : + print("-------") + print(f"name: {disabled_plugin}") +from typing import List +from surfactant.plugin.manager import get_plugin_manager @click.command(name="disable") @click.argument('plugin_names', nargs=-1) def plugin_disable_cmd(plugin_names): @@ -24,42 +35,23 @@ def plugin_disable_cmd(plugin_names): if not plugin_names: raise click.UsageError("At least one plugin name must be specified.") section = 'core' - section_key = 'blocked' - - pm = get_plugin_manager() - config_manager = ConfigManager() + section_key = 'disable_plugins' - # Debugging: Print config file path and current config - #print(config_manager._get_config_file_path()) - #config_manager.print_config() + config_manager = ConfigManager() - # Retrieve the current list of blocked plugins + # Retrieve the current list of plugins that should be blocked current_blocked_plugins = config_manager.get(section, section_key, []) # Ensure current_blocked_plugins is a list if isinstance(current_blocked_plugins, str): current_blocked_plugins = [current_blocked_plugins] - - for plugin_name in plugin_names: - # Check if the plugin is already blocked - if pm.is_blocked(plugin_name): - print(f"Plugin '{plugin_name}' is already disabled.") - continue - - # Unregister the plugin - plugin = pm.unregister(name=plugin_name) - if plugin is None: - print(f"Plugin '{plugin_name}' not found.") - continue - - # Block the plugin to prevent future registration - pm.set_blocked(plugin_name) - - # Add the plugin to the blocked list if not already present + + # Add the plugin to the blocked list if not already present + for plugin_name in plugin_names : if plugin_name not in current_blocked_plugins: current_blocked_plugins.append(plugin_name) - # Update the configuration to reflect the disabled status + # Update the configuration to add plugins to be disabled if current_blocked_plugins: config_manager.set(section, section_key, current_blocked_plugins) click.echo(f"Updated blocked plugins: {current_blocked_plugins}") From 4d27807127f6e15ca2d61f914b19baf73fa3228f Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 6 Nov 2024 20:51:44 +0000 Subject: [PATCH 17/58] Added print disabled plugins to list subcommand. --- surfactant/cmd/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index c1859346..ea525d49 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -21,7 +21,7 @@ def plugin_list_cmd(): current_blocked_plugins = config_manager.get(section, section_key, []) print("-------") - print("Disabled Plugins") + print("DISABLED PLUGINS") for disabled_plugin in current_blocked_plugins : print("-------") print(f"name: {disabled_plugin}") From 62657de240b59c550f29ea7c03bb63cd9798eca1 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Mon, 11 Nov 2024 15:22:34 +0000 Subject: [PATCH 18/58] Added plugin enable functionality. --- surfactant/__main__.py | 3 ++- surfactant/cmd/plugin.py | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index c26e04c2..bfd85a6d 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import plugin_list_cmd, plugin_disable_cmd +from surfactant.cmd.plugin import plugin_list_cmd, plugin_enable_cmd, plugin_disable_cmd from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui @@ -76,6 +76,7 @@ def plugin(): # Plugin Subcommands plugin.add_command(plugin_list_cmd) +plugin.add_command(plugin_enable_cmd) plugin.add_command(plugin_disable_cmd) if __name__ == "__main__": diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index ea525d49..a5f2e80f 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,5 +1,8 @@ import click +from typing import List +from surfactant.plugin.manager import get_plugin_manager from surfactant.configmanager import ConfigManager + @click.command(name="list") def plugin_list_cmd(): """Lists plugins.""" @@ -26,8 +29,34 @@ def plugin_list_cmd(): print("-------") print(f"name: {disabled_plugin}") -from typing import List -from surfactant.plugin.manager import get_plugin_manager +@click.command(name="enable") +@click.argument('plugin_names', nargs=-1) +def plugin_enable_cmd(plugin_names): + """Enables one or more plugins.""" + if not plugin_names: + raise click.UsageError("At least one plugin name must be specified.") + section = 'core' + section_key = 'disable_plugins' + + config_manager = ConfigManager() + + # Retrieve the current list of plugins that should be blocked + current_blocked_plugins = config_manager.get(section, section_key, []) + + # Ensure current_blocked_plugins is a list + if isinstance(current_blocked_plugins, str): + current_blocked_plugins = [current_blocked_plugins] + + # Remove the plugin from the blocked list if present + for plugin_name in plugin_names: + if plugin_name in current_blocked_plugins: + current_blocked_plugins.remove(plugin_name) + + # Update the configuration to remove plugins from being disabled + config_manager.set(section, section_key, current_blocked_plugins) + click.echo(f"Updated blocked plugins: {current_blocked_plugins}") + + @click.command(name="disable") @click.argument('plugin_names', nargs=-1) def plugin_disable_cmd(plugin_names): @@ -45,9 +74,9 @@ def plugin_disable_cmd(plugin_names): # Ensure current_blocked_plugins is a list if isinstance(current_blocked_plugins, str): current_blocked_plugins = [current_blocked_plugins] - + # Add the plugin to the blocked list if not already present - for plugin_name in plugin_names : + for plugin_name in plugin_names: if plugin_name not in current_blocked_plugins: current_blocked_plugins.append(plugin_name) From 7ac000a144d65b35494f04de8834147e598a8646 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:42:58 +0000 Subject: [PATCH 19/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/__main__.py | 2 +- surfactant/cmd/plugin.py | 28 +++++++++++++++------------- surfactant/plugin/manager.py | 7 ++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index bfd85a6d..661bec5e 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import plugin_list_cmd, plugin_enable_cmd, plugin_disable_cmd +from surfactant.cmd.plugin import plugin_disable_cmd, plugin_enable_cmd, plugin_list_cmd from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index a5f2e80f..3c3a7363 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,7 +1,8 @@ import click -from typing import List -from surfactant.plugin.manager import get_plugin_manager + from surfactant.configmanager import ConfigManager +from surfactant.plugin.manager import get_plugin_manager + @click.command(name="list") def plugin_list_cmd(): @@ -17,26 +18,27 @@ def plugin_list_cmd(): # List disabled pluginsi config_manager = ConfigManager() - section = 'core' - section_key = 'disable_plugins' - + section = "core" + section_key = "disable_plugins" + # Retrieve the current list of plugins that should be blocked current_blocked_plugins = config_manager.get(section, section_key, []) - + print("-------") print("DISABLED PLUGINS") - for disabled_plugin in current_blocked_plugins : + for disabled_plugin in current_blocked_plugins: print("-------") print(f"name: {disabled_plugin}") + @click.command(name="enable") -@click.argument('plugin_names', nargs=-1) +@click.argument("plugin_names", nargs=-1) def plugin_enable_cmd(plugin_names): """Enables one or more plugins.""" if not plugin_names: raise click.UsageError("At least one plugin name must be specified.") - section = 'core' - section_key = 'disable_plugins' + section = "core" + section_key = "disable_plugins" config_manager = ConfigManager() @@ -58,13 +60,13 @@ def plugin_enable_cmd(plugin_names): @click.command(name="disable") -@click.argument('plugin_names', nargs=-1) +@click.argument("plugin_names", nargs=-1) def plugin_disable_cmd(plugin_names): """Disables one or more plugins.""" if not plugin_names: raise click.UsageError("At least one plugin name must be specified.") - section = 'core' - section_key = 'disable_plugins' + section = "core" + section_key = "disable_plugins" config_manager = ConfigManager() diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index ccb923ed..243fe9bf 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -7,8 +7,9 @@ import pluggy from loguru import logger -from surfactant.plugin import hookspecs from surfactant.configmanager import ConfigManager +from surfactant.plugin import hookspecs + def _register_plugins(pm: pluggy.PluginManager) -> None: # pylint: disable=import-outside-toplevel @@ -64,9 +65,9 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: ) for plugin in internal_plugins: pm.register(plugin) - + config_manager = ConfigManager() - + # Retrieve the current list of blocked plugins current_blocked_plugins = config_manager.get("core", "disable_plugins", []) for plugin_name in current_blocked_plugins: From c0b4a0b19c84edc4838a31d7a9d9f718bfc00fe3 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Mon, 11 Nov 2024 16:56:20 -0600 Subject: [PATCH 20/58] Update surfactant/cmd/plugin.py Simpler string formatting. Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/cmd/plugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 3c3a7363..92bdfa15 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -27,8 +27,7 @@ def plugin_list_cmd(): print("-------") print("DISABLED PLUGINS") for disabled_plugin in current_blocked_plugins: - print("-------") - print(f"name: {disabled_plugin}") + print(f"\tname: {disabled_plugin}") @click.command(name="enable") From 093b047d8c94f9fffba1eb57f01fe7332c10b742 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Mon, 11 Nov 2024 16:56:38 -0600 Subject: [PATCH 21/58] Update surfactant/cmd/plugin.py Fixed typo. Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/cmd/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 92bdfa15..cbfe2b20 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -16,7 +16,7 @@ def plugin_list_cmd(): plugin_name = pm.get_name(p) if pm.get_name(p) else "" print(f"name: {plugin_name}") - # List disabled pluginsi + # List disabled plugins config_manager = ConfigManager() section = "core" section_key = "disable_plugins" From dd4b05557b11b2991d7b2bedcc5fed95104b655b Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 17:10:36 +0000 Subject: [PATCH 22/58] Save. --- surfactant/plugin/manager.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index 243fe9bf..9ba699a5 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -65,7 +65,9 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: ) for plugin in internal_plugins: pm.register(plugin) - + +def set_blocked_plugins(pm: pluggy.PluginManager) : + """Gets the current list of blocked plugins from the config manager, then blocks and unregisters them with the plugin manager.""" config_manager = ConfigManager() # Retrieve the current list of blocked plugins @@ -85,25 +87,22 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: # Block the plugin to prevent future registration pm.set_blocked(plugin_name) - def get_plugin_manager() -> pluggy.PluginManager: pm = pluggy.PluginManager("surfactant") pm.add_hookspecs(hookspecs) pm.load_setuptools_entrypoints("surfactant") _register_plugins(pm) + set_blocked_plugins(pm) pm.check_pending() return pm def print_plugins(pm: pluggy.PluginManager): - print("-------") print("PLUGINS") for p in pm.get_plugins(): - print("-------") - print(f"canonical name: {pm.get_canonical_name(p)}") + print(f"\t> canonical name: {pm.get_canonical_name(p)}") plugin_name = pm.get_name(p) if pm.get_name(p) else "" - print(f"name: {plugin_name}") - + print(f"\t name: {plugin_name}") def find_io_plugin(pm: pluggy.PluginManager, io_format: str, function_name: str): found_plugin = pm.get_plugin(io_format) From 0ec3b91003c606e44853352d15f8e39437011ba2 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 17:12:34 +0000 Subject: [PATCH 23/58] Added set_plugins function. Changed formatting of print_plugins --- surfactant/plugin/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index 9ba699a5..3738dafe 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -65,7 +65,7 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: ) for plugin in internal_plugins: pm.register(plugin) - + def set_blocked_plugins(pm: pluggy.PluginManager) : """Gets the current list of blocked plugins from the config manager, then blocks and unregisters them with the plugin manager.""" config_manager = ConfigManager() From 03355a2ac5019e93fea8ff22902648244a3f863f Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 17:17:13 +0000 Subject: [PATCH 24/58] Added print_plugins in list command and changed formatting --- surfactant/cmd/plugin.py | 45 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index 3c3a7363..a2776b40 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,22 +1,16 @@ import click - +import subprocess +import sys from surfactant.configmanager import ConfigManager -from surfactant.plugin.manager import get_plugin_manager - +from surfactant.plugin.manager import get_plugin_manager, print_plugins @click.command(name="list") def plugin_list_cmd(): """Lists plugins.""" pm = get_plugin_manager() - print("-------") - print("PLUGINS") - for p in pm.get_plugins(): - print("-------") - print(f"canonical name: {pm.get_canonical_name(p)}") - plugin_name = pm.get_name(p) if pm.get_name(p) else "" - print(f"name: {plugin_name}") - - # List disabled pluginsi + print_plugins(pm) + + # List disabled plugins config_manager = ConfigManager() section = "core" section_key = "disable_plugins" @@ -24,11 +18,9 @@ def plugin_list_cmd(): # Retrieve the current list of plugins that should be blocked current_blocked_plugins = config_manager.get(section, section_key, []) - print("-------") - print("DISABLED PLUGINS") + print("\nDISABLED PLUGINS") for disabled_plugin in current_blocked_plugins: - print("-------") - print(f"name: {disabled_plugin}") + print(f"\tname: {disabled_plugin}") @click.command(name="enable") @@ -86,3 +78,24 @@ def plugin_disable_cmd(plugin_names): if current_blocked_plugins: config_manager.set(section, section_key, current_blocked_plugins) click.echo(f"Updated blocked plugins: {current_blocked_plugins}") + +@click.command(name="install") +@click.argument("plugin_name") +def plugin_install_cmd(plugin_name): + """Installs a plugin.""" + try: + subprocess.check_call([sys.executable, "-m", "pip", "install", plugin_name]) + click.echo(f"Successfully installed {plugin_name}.") + except subprocess.CalledProcessError as e: + click.echo(f"Failed to install {plugin_name}: {e}", err=True) + + +@click.command(name="uninstall") +@click.argument("plugin_name") +def plugin_uninstall_cmd(plugin_name): + """Uninstalls a plugin.""" + try: + subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", plugin_name]) + click.echo(f"Successfully uninstalled {plugin_name}.") + except subprocess.CalledProcessError as e: + click.echo(f"Failed to uninstall {plugin_name}: {e}", err=True) From c827e8820f317694cb914a62b0e383813aecb56b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:28:41 +0000 Subject: [PATCH 25/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/cmd/plugin.py | 6 +++++- surfactant/plugin/manager.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/surfactant/cmd/plugin.py b/surfactant/cmd/plugin.py index a2776b40..bb429ffa 100644 --- a/surfactant/cmd/plugin.py +++ b/surfactant/cmd/plugin.py @@ -1,9 +1,12 @@ -import click import subprocess import sys + +import click + from surfactant.configmanager import ConfigManager from surfactant.plugin.manager import get_plugin_manager, print_plugins + @click.command(name="list") def plugin_list_cmd(): """Lists plugins.""" @@ -79,6 +82,7 @@ def plugin_disable_cmd(plugin_names): config_manager.set(section, section_key, current_blocked_plugins) click.echo(f"Updated blocked plugins: {current_blocked_plugins}") + @click.command(name="install") @click.argument("plugin_name") def plugin_install_cmd(plugin_name): diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index 3738dafe..0c31c608 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -66,7 +66,8 @@ def _register_plugins(pm: pluggy.PluginManager) -> None: for plugin in internal_plugins: pm.register(plugin) -def set_blocked_plugins(pm: pluggy.PluginManager) : + +def set_blocked_plugins(pm: pluggy.PluginManager): """Gets the current list of blocked plugins from the config manager, then blocks and unregisters them with the plugin manager.""" config_manager = ConfigManager() @@ -87,6 +88,7 @@ def set_blocked_plugins(pm: pluggy.PluginManager) : # Block the plugin to prevent future registration pm.set_blocked(plugin_name) + def get_plugin_manager() -> pluggy.PluginManager: pm = pluggy.PluginManager("surfactant") pm.add_hookspecs(hookspecs) @@ -104,6 +106,7 @@ def print_plugins(pm: pluggy.PluginManager): plugin_name = pm.get_name(p) if pm.get_name(p) else "" print(f"\t name: {plugin_name}") + def find_io_plugin(pm: pluggy.PluginManager, io_format: str, function_name: str): found_plugin = pm.get_plugin(io_format) From 6b78b8d6e25f688ce5aeb4b0cc1763f13d988d05 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 11:32:30 -0600 Subject: [PATCH 26/58] Update surfactant/plugin/manager.py Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/plugin/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index 0c31c608..f3cba5cb 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -82,7 +82,7 @@ def set_blocked_plugins(pm: pluggy.PluginManager): # Unregister the plugin plugin = pm.unregister(name=plugin_name) if plugin is None: - print(f"Plugin '{plugin_name}' not found.") + logger.info(f"Disabled plugin '{plugin_name}' not found.") continue # Block the plugin to prevent future registration From 4a9f74422e2a6a732c188d2b32db7b9c2fbedc78 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 17:38:31 +0000 Subject: [PATCH 27/58] Updating local --- surfactant/plugin/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/plugin/manager.py b/surfactant/plugin/manager.py index f3cba5cb..fd534d3e 100644 --- a/surfactant/plugin/manager.py +++ b/surfactant/plugin/manager.py @@ -76,7 +76,7 @@ def set_blocked_plugins(pm: pluggy.PluginManager): for plugin_name in current_blocked_plugins: # Check if the plugin is already blocked if pm.is_blocked(plugin_name): - print(f"Plugin '{plugin_name}' is already disabled.") + logger.info(f"Plugin '{plugin_name}' is already disabled.") continue # Unregister the plugin From ddebfef926faf2cd051c9da364298b71354e447d Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 12 Nov 2024 19:22:08 +0000 Subject: [PATCH 28/58] Added command declarations in main. --- surfactant/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index 661bec5e..0625c022 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,7 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command -from surfactant.cmd.plugin import plugin_disable_cmd, plugin_enable_cmd, plugin_list_cmd +from surfactant.cmd.plugin import plugin_disable_cmd, plugin_enable_cmd, plugin_list_cmd, plugin_install_cmd, plugin_uninstall_cmd from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui @@ -78,6 +78,8 @@ def plugin(): plugin.add_command(plugin_list_cmd) plugin.add_command(plugin_enable_cmd) plugin.add_command(plugin_disable_cmd) +plugin.add_command(plugin_install_cmd) +plugin.add_command(plugin_uninstall_cmd) if __name__ == "__main__": main() From 5881d17bd3631c56cd146b0b54da35f4d179134b Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 15:51:18 +0000 Subject: [PATCH 29/58] Added shortname hook to js_file plugin. --- surfactant/infoextractors/js_file.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 780ef282..bbca849e 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -67,3 +67,8 @@ def match_by_attribute(attribute: str, content: str, database: Dict) -> List[Dic # skip remaining patterns, move on to the next library break return libs + + +@surfactant.plugin.hookimpl +def short_name(): + return "js_file" From be4b66277b3f352cf2d32a166798eb774f2da996 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 16:18:47 +0000 Subject: [PATCH 30/58] Moved update js db script to updatedb hook implementation for js_file plugin. Deleted original script. --- scripts/js_libraries/get_retirejs_db.py | 41 ------------------------- surfactant/infoextractors/js_file.py | 40 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 42 deletions(-) delete mode 100644 scripts/js_libraries/get_retirejs_db.py diff --git a/scripts/js_libraries/get_retirejs_db.py b/scripts/js_libraries/get_retirejs_db.py deleted file mode 100644 index d557715f..00000000 --- a/scripts/js_libraries/get_retirejs_db.py +++ /dev/null @@ -1,41 +0,0 @@ -import json - -import requests - - -def load_database() -> dict: - url = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-master.json" - response = requests.get(url) - if response.status_code == 200: - return json.loads(response.text) - return None - - -def strip_irrelevant_data(retirejs_db: dict) -> dict: - clean_db = {} - reg_temp = "\u00a7\u00a7version\u00a7\u00a7" - version_regex = r"\d+(?:\.\d+)*" - for library, lib_entry in retirejs_db.items(): - if "extractors" in lib_entry: - clean_db[library] = {} - patterns = lib_entry["extractors"] - possible_entries = [ - "filename", - "filecontent", - "hashes", - ] - for entry in possible_entries: - if entry in patterns: - entry_list = [] - for reg in patterns[entry]: - entry_list.append(reg.replace(reg_temp, version_regex)) - clean_db[library][entry] = entry_list - return clean_db - - -retirejs = load_database() - -if retirejs is not None: - cleaned = strip_irrelevant_data(retirejs) - with open("js_library_patterns.json", "w") as f: - json.dump(cleaned, f, indent=4) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index bbca849e..c15486a7 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -11,7 +11,7 @@ import surfactant.plugin from surfactant.sbomtypes import SBOM, Software - +import requests def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" @@ -68,6 +68,44 @@ def match_by_attribute(attribute: str, content: str, database: Dict) -> List[Dic break return libs +def load_database() -> dict: + url = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-master.json" + response = requests.get(url) + if response.status_code == 200: + return json.loads(response.text) + return None + + +def strip_irrelevant_data(retirejs_db: dict) -> dict: + clean_db = {} + reg_temp = "\u00a7\u00a7version\u00a7\u00a7" + version_regex = r"\d+(?:\.\d+)*" + for library, lib_entry in retirejs_db.items(): + if "extractors" in lib_entry: + clean_db[library] = {} + patterns = lib_entry["extractors"] + possible_entries = [ + "filename", + "filecontent", + "hashes", + ] + for entry in possible_entries: + if entry in patterns: + entry_list = [] + for reg in patterns[entry]: + entry_list.append(reg.replace(reg_temp, version_regex)) + clean_db[library][entry] = entry_list + return clean_db + + +@surfactant.plugin.hookimpl +def update_db(): + retirejs = load_database() + if retirejs is not None: + cleaned = strip_irrelevant_data(retirejs) + with open("js_library_patterns.json", "w") as f: + json.dump(cleaned, f, indent=4) + @surfactant.plugin.hookimpl def short_name(): From 4c63005505364441fc6cb038a31a6e83b73c89ad Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 17:19:30 +0000 Subject: [PATCH 31/58] Added comments to js_file plugin updatedb hook implementation. --- surfactant/infoextractors/js_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index c15486a7..afa4e936 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -100,6 +100,9 @@ def strip_irrelevant_data(retirejs_db: dict) -> dict: @surfactant.plugin.hookimpl def update_db(): +""" Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. + +The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""":x! retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) From 37614548a2464831c84df59416712858b4933783 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:31:02 +0000 Subject: [PATCH 32/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/__main__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/surfactant/__main__.py b/surfactant/__main__.py index 832f2174..9f3927bf 100755 --- a/surfactant/__main__.py +++ b/surfactant/__main__.py @@ -16,7 +16,6 @@ from surfactant.cmd.createconfig import create_config from surfactant.cmd.generate import sbom as generate from surfactant.cmd.merge import merge_command - from surfactant.cmd.plugin import ( plugin_disable_cmd, plugin_enable_cmd, @@ -25,7 +24,6 @@ plugin_uninstall_cmd, plugin_update_db_cmd, ) - from surfactant.cmd.stat import stat from surfactant.cmd.ui import ui From 85d3266341701a538b5eba5e96dd2d788d335b2c Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 17:51:46 +0000 Subject: [PATCH 33/58] Fixed typo. --- surfactant/infoextractors/js_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index afa4e936..0fa4adcd 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -100,9 +100,9 @@ def strip_irrelevant_data(retirejs_db: dict) -> dict: @surfactant.plugin.hookimpl def update_db(): -""" Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. + """ Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. -The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""":x! +The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""" retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) From 6582af20ecfc3d5632abab37d60813660a136d6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:53:52 +0000 Subject: [PATCH 34/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 0fa4adcd..7bc202d8 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -7,11 +7,12 @@ import re from typing import Any, Dict, List +import requests from loguru import logger import surfactant.plugin from surfactant.sbomtypes import SBOM, Software -import requests + def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" @@ -68,6 +69,7 @@ def match_by_attribute(attribute: str, content: str, database: Dict) -> List[Dic break return libs + def load_database() -> dict: url = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-master.json" response = requests.get(url) @@ -100,9 +102,9 @@ def strip_irrelevant_data(retirejs_db: dict) -> dict: @surfactant.plugin.hookimpl def update_db(): - """ Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. + """Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. -The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""" + The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""" retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) From 4028b382655c39737dc34174694a2010e5032f68 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 20:09:40 +0000 Subject: [PATCH 35/58] Added requests to dependencies. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0b87d1af..9c3d3eb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dependencies = [ "loguru==0.7.*", "flask==3.*", "tomlkit==0.13.*", + "requests>=2.32.3", ] dynamic = ["version"] From b66f7fa5ed2f96a559d208a561c41a0a1716ff70 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 21:27:14 +0000 Subject: [PATCH 36/58] Added user feedback during js_file plugin database. --- surfactant/infoextractors/js_file.py | 8 +++++- .../infoextractors/js_library_patterns.json | 26 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 7bc202d8..9419492b 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -12,7 +12,7 @@ import surfactant.plugin from surfactant.sbomtypes import SBOM, Software - +import click def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" @@ -74,7 +74,12 @@ def load_database() -> dict: url = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-master.json" response = requests.get(url) if response.status_code == 200: + click.echo("Request successful!") return json.loads(response.text) + elif response.status_code == 404: + click.echo("Resource not found.") + else: + click.echo("An error occurred.") return None @@ -110,6 +115,7 @@ def update_db(): cleaned = strip_irrelevant_data(retirejs) with open("js_library_patterns.json", "w") as f: json.dump(cleaned, f, indent=4) + return "Update complete." @surfactant.plugin.hookimpl diff --git a/surfactant/infoextractors/js_library_patterns.json b/surfactant/infoextractors/js_library_patterns.json index 1a227dee..78a1f184 100644 --- a/surfactant/infoextractors/js_library_patterns.json +++ b/surfactant/infoextractors/js_library_patterns.json @@ -400,7 +400,9 @@ "'(\\d+(?:\\.\\d+)*)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(\\d+(?:\\.\\d+)*)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(\\d+(?:\\.\\d+)*)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", - "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(\\d+(?:\\.\\d+)*)\"," + "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(\\d+(?:\\.\\d+)*)\",", + "let [A-Za-z]+=\"(\\d+(?:\\.\\d+)*)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(\\d+(?:\\.\\d+)*)\"" ] }, "ExtJS": { @@ -421,6 +423,7 @@ ], "filecontent": [ "generated by Svelte v\\$\\{['\"](\\d+(?:\\.\\d+)*)['\"]\\}", + "generated by Svelte v(\\d+(?:\\.\\d+)*) \\*/", "version: '(\\d+(?:\\.\\d+)*)' [\\s\\S]{80,200}'SvelteDOMInsert'", "VERSION = '(\\d+(?:\\.\\d+)*)'[\\s\\S]{21,200}parse\\$[0-9][\\s\\S]{10,80}preprocess", "var version\\$[0-9] = \"(\\d+(?:\\.\\d+)*)\";[\\s\\S]{10,30}normalizeOptions\\(options\\)[\\s\\S]{80,200}'SvelteComponent.html'" @@ -474,7 +477,8 @@ "nextjs": { "filecontent": [ "version=\"(\\d+(?:\\.\\d+)*)\".{1,1500}document\\.getElementById\\(\"__NEXT_DATA__\"\\)\\.textContent", - "document\\.getElementById\\(\"__NEXT_DATA__\"\\)\\.textContent\\);window\\.__NEXT_DATA__=.;.\\.version=\"(\\d+(?:\\.\\d+)*)\"" + "document\\.getElementById\\(\"__NEXT_DATA__\"\\)\\.textContent\\);window\\.__NEXT_DATA__=.;.\\.version=\"(\\d+(?:\\.\\d+)*)\"", + "=\"(\\d+(?:\\.\\d+)*)\"[\\s\\S]{10,100}Component[\\s\\S]{1,10}componentDidCatch[\\s\\S]{10,30}componentDidMount" ] }, "chart.js": { @@ -546,5 +550,21 @@ "MathJax\\.version=\"(\\d+(?:\\.\\d+)*)\";" ] }, + "pdf.js": { + "filecontent": [ + "(?:const|var) pdfjsVersion = ['\"](\\d+(?:\\.\\d+)*)['\"];", + "PDFJS.version ?= ?['\"](\\d+(?:\\.\\d+)*)['\"]", + "apiVersion: ?['\"](\\d+(?:\\.\\d+)*)['\"][\\s\\S]*,data(:[a-zA-Z.]{1,6})?,[\\s\\S]*password(:[a-zA-Z.]{1,10})?,[\\s\\S]*disableAutoFetch(:[a-zA-Z.]{1,22})?,[\\s\\S]*rangeChunkSize", + "messageHandler\\.sendWithPromise\\(\"GetDocRequest\",\\{docId:[a-zA-Z],apiVersion:\"(\\d+(?:\\.\\d+)*)\"" + ] + }, + "pdfobject": { + "filecontent": [ + "\\* +PDFObject v(\\d+(?:\\.\\d+)*)", + "/*[\\s]+PDFObject v(\\d+(?:\\.\\d+)*)", + "let pdfobjectversion = \"(\\d+(?:\\.\\d+)*)\";", + "pdfobjectversion:\"(\\d+(?:\\.\\d+)*)\"" + ] + }, "dont check": {} -} +} \ No newline at end of file From 5b2b43f00d485014dbe09746b5f2b775c96b1c40 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:27:58 +0000 Subject: [PATCH 37/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 3 ++- surfactant/infoextractors/js_library_patterns.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 9419492b..07eaf4e2 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -7,12 +7,13 @@ import re from typing import Any, Dict, List +import click import requests from loguru import logger import surfactant.plugin from surfactant.sbomtypes import SBOM, Software -import click + def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" diff --git a/surfactant/infoextractors/js_library_patterns.json b/surfactant/infoextractors/js_library_patterns.json index 78a1f184..1b68cd38 100644 --- a/surfactant/infoextractors/js_library_patterns.json +++ b/surfactant/infoextractors/js_library_patterns.json @@ -567,4 +567,4 @@ ] }, "dont check": {} -} \ No newline at end of file +} From dbf9464e22c3485e9c7d4fd73ab746df53c807b0 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 21:59:08 +0000 Subject: [PATCH 38/58] Made if statement less redundant. --- surfactant/infoextractors/js_file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 07eaf4e2..0d5fe450 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -77,10 +77,12 @@ def load_database() -> dict: if response.status_code == 200: click.echo("Request successful!") return json.loads(response.text) - elif response.status_code == 404: + + if response.status_code == 404: click.echo("Resource not found.") else: click.echo("An error occurred.") + return None From e1d8ede44a4f2ffc244dbceed1fc13ffa6f8e67e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:00:08 +0000 Subject: [PATCH 39/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 0d5fe450..5e4cdedf 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -77,12 +77,12 @@ def load_database() -> dict: if response.status_code == 200: click.echo("Request successful!") return json.loads(response.text) - + if response.status_code == 404: click.echo("Resource not found.") else: click.echo("An error occurred.") - + return None From e0e3c4fba1cc5d992548466e6ac805d1d26f60b4 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 11 Dec 2024 22:05:11 +0000 Subject: [PATCH 40/58] Fixed return inconsistency. --- surfactant/infoextractors/js_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 0d5fe450..69363c02 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -119,7 +119,7 @@ def update_db(): with open("js_library_patterns.json", "w") as f: json.dump(cleaned, f, indent=4) return "Update complete." - + return "No update occurred." @surfactant.plugin.hookimpl def short_name(): From b61ca4471c9a9445d4bef9a29cf802d4b72c9951 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:07:51 +0000 Subject: [PATCH 41/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 6e8a86ec..ba9f12e8 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -121,6 +121,7 @@ def update_db(): return "Update complete." return "No update occurred." + @surfactant.plugin.hookimpl def short_name(): return "js_file" From 3f063252258e3dec7be6d44a1db6e3d6b203ad0a Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 17 Dec 2024 00:09:32 +0000 Subject: [PATCH 42/58] Changed configmanager.get_dataDir_path to return expanded user. Create and load js database when module is loaded and when update-db is called. --- surfactant/configmanager.py | 2 +- surfactant/infoextractors/js_file.py | 28 +- .../infoextractors/js_library_patterns.json | 570 ------------------ 3 files changed, 27 insertions(+), 573 deletions(-) delete mode 100644 surfactant/infoextractors/js_library_patterns.json diff --git a/surfactant/configmanager.py b/surfactant/configmanager.py index 7ee69b3a..36ebfc28 100644 --- a/surfactant/configmanager.py +++ b/surfactant/configmanager.py @@ -153,4 +153,4 @@ def get_data_dir_path(self) -> Path: else: data_dir = Path(os.getenv("XDG_DATA_HOME", str(Path("~/.local/share")))) data_dir = data_dir / self.app_name - return data_dir + return data_dir.expanduser() diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index ba9f12e8..99e6e559 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -14,6 +14,9 @@ import surfactant.plugin from surfactant.sbomtypes import SBOM, Software +from surfactant.configmanager import ConfigManager +import os +from pathlib import Path def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" @@ -28,10 +31,12 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - js_lib_file = pathlib.Path(__file__).parent / "js_library_patterns.json" + js_lib_file = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" # Load expressions from retire.js, should move this file elsewhere try: + path = ConfigManager().get_data_dir_path() / "infoextractors" + path.mkdir(parents=True, exist_ok=True) with open(js_lib_file, "r") as regex: database = json.load(regex) except FileNotFoundError: @@ -116,7 +121,10 @@ def update_db(): retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) - with open("js_library_patterns.json", "w") as f: + path = ConfigManager().get_data_dir_path() / "infoextractors" + path.mkdir(parents=True, exist_ok=True) + json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + with open(json_file_path, "w") as f: json.dump(cleaned, f, indent=4) return "Update complete." return "No update occurred." @@ -125,3 +133,19 @@ def update_db(): @surfactant.plugin.hookimpl def short_name(): return "js_file" + +def load_db(): + path = ConfigManager().get_data_dir_path() / "infoextractors" + path.mkdir(parents=True, exist_ok=True) + # os.makedirs(os.path.dirname(ConfigManager().get_data_dir_path() / "infoextractors"), exist_ok=True) + retirejs = load_database() + if retirejs is not None: + cleaned = strip_irrelevant_data(retirejs) + json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + with open(json_file_path, "w") as f: + json.dump(cleaned, f, indent=4) + logger.info(f"Javascript library CVE database loaded.") + else: + logger.warning(f"javascript library CVE database did not load.") + +load_db() \ No newline at end of file diff --git a/surfactant/infoextractors/js_library_patterns.json b/surfactant/infoextractors/js_library_patterns.json deleted file mode 100644 index 1b68cd38..00000000 --- a/surfactant/infoextractors/js_library_patterns.json +++ /dev/null @@ -1,570 +0,0 @@ -{ - "retire-example": { - "filename": [ - "retire-example-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/\\*!? Retire-example v(\\d+(?:\\.\\d+)*)" - ], - "hashes": [ - "07f8b94c8d601a24a1914a1a92bec0e4fafda964" - ] - }, - "jquery": { - "filename": [ - "jquery-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*!? jQuery v(\\d+(?:\\.\\d+)*)", - "\\* jQuery JavaScript Library v(\\d+(?:\\.\\d+)*)", - "\\* jQuery (\\d+(?:\\.\\d+)*) - New Wave Javascript", - "/\\*![\\s]+\\* jQuery JavaScript Library v(\\d+(?:\\.\\d+)*)", - "// \\$Id: jquery.js,v (\\d+(?:\\.\\d+)*)", - "/\\*! jQuery v(\\d+(?:\\.\\d+)*)", - "[^a-z]f=\"(\\d+(?:\\.\\d+)*)\",.*[^a-z]jquery:f,", - "[^a-z]m=\"(\\d+(?:\\.\\d+)*)\",.*[^a-z]jquery:m,", - "[^a-z.]jquery:[ ]?\"(\\d+(?:\\.\\d+)*)\"", - "\\$\\.documentElement,Q=e.jQuery,Z=e\\.\\$,ee=\\{\\},te=\\[\\],ne=\"(\\d+(?:\\.\\d+)*)\"", - "=\"(\\d+(?:\\.\\d+)*)\",.{50,300}(.)\\.fn=(\\2)\\.prototype=\\{jquery:" - ], - "hashes": [] - }, - "jquery-migrate": { - "filename": [ - "jquery-migrate-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/\\*!?(?:\n \\*)? jQuery Migrate(?: -)? v(\\d+(?:\\.\\d+)*)", - "\\.migrateVersion ?= ?\"(\\d+(?:\\.\\d+)*)\"[\\s\\S]{10,150}(migrateDisablePatches|migrateWarnings|JQMIGRATE)", - "jQuery\\.migrateVersion ?= ?\"(\\d+(?:\\.\\d+)*)\"" - ], - "hashes": [] - }, - "jquery-validation": { - "filename": [ - "jquery.validat(?:ion|e)-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/\\*!?(?:\n \\*)?[\\s]*jQuery Validation Plugin -? ?v(\\d+(?:\\.\\d+)*)", - "Original file: /npm/jquery-validation@(\\d+(?:\\.\\d+)*)/dist/jquery.validate.js" - ], - "hashes": [] - }, - "jquery-mobile": { - "filename": [ - "jquery.mobile-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/\\*!?[\\s*]*jQuery Mobile(?: -)? v?(\\d+(?:\\.\\d+)*)", - "// Version of the jQuery Mobile Framework[\\s]+version: *[\"'](\\d+(?:\\.\\d+)*)[\"']," - ], - "hashes": [] - }, - "jquery-ui": { - "filecontent": [ - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)", - "/\\*!?[\n *]+jQuery UI (\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "jquery-ui-dialog": { - "filecontent": [ - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)(.*\n){1,3}.*jquery\\.ui\\.dialog\\.js", - "/\\*!?[\n *]+jQuery UI (\\d+(?:\\.\\d+)*)(.*\n)*.*\\.ui\\.dialog", - "/\\*!?[\n *]+jQuery UI Dialog (\\d+(?:\\.\\d+)*)", - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)(.*\n){1,3}\\* Includes: .* dialog\\.js" - ], - "hashes": [] - }, - "jquery-ui-autocomplete": { - "filecontent": [ - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)(.*\n){1,3}.*jquery\\.ui\\.autocomplete\\.js", - "/\\*!?[\n *]+jQuery UI (\\d+(?:\\.\\d+)*)(.*\n)*.*\\.ui\\.autocomplete", - "/\\*!?[\n *]+jQuery UI Autocomplete (\\d+(?:\\.\\d+)*)", - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)(.*\n){1,3}\\* Includes: .* autocomplete\\.js" - ], - "hashes": [] - }, - "jquery-ui-tooltip": { - "filecontent": [ - "/\\*!? jQuery UI - v(\\d+(?:\\.\\d+)*)(.*\n){1,3}.*jquery\\.ui\\.tooltip\\.js", - "/\\*!?[\n *]+jQuery UI (\\d+(?:\\.\\d+)*)(.*\n)*.*\\.ui\\.tooltip", - "/\\*!?[\n *]+jQuery UI Tooltip (\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "jquery.prettyPhoto": { - "filecontent": [ - "/\\*[\r\n -]+Class: prettyPhoto(?:.*\n){1,3}[ ]*Version: (\\d+(?:\\.\\d+)*)", - "\\.prettyPhoto[ ]?=[ ]?\\{version:[ ]?(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")\\}" - ], - "hashes": [] - }, - "jquery.terminal": { - "filecontent": [ - "version (\\d+(?:\\.\\d+)*)[\\s]+\\*[\\s]+\\* This file is part of jQuery Terminal.", - "\\$\\.terminal=\\{version:\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "jquery-deparam": { - "hashes": [ - "61c9d49ae64331402c3bde766c9dc504ed2ca509", - "10a68e5048995351a01b0ad7f322bb755a576a02", - "b8f063c860fa3aab266df06b290e7da648f9328d", - "851bc74dc664aa55130ecc74dd6b1243becc3242", - "2aae12841f4d00143ffc1effa59fbd058218c29f", - "967942805137f9eb0ae26005d94e8285e2e288a0", - "fbf2e115feae7ade26788e38ebf338af11a98bb2" - ] - }, - "tableexport.jquery.plugin": { - "filecontent": [ - "/\\*[\\s]+tableExport.jquery.plugin[\\s]+Version (\\d+(?:\\.\\d+)*)", - "/\\*![\\s]+\\* TableExport.js v(\\d+(?:\\.\\d+)*)" - ] - }, - "jPlayer": { - "filecontent": [ - "/\\*!?[\n *]+jPlayer Plugin for jQuery (?:.*\n){1,10}[ *]+Version: (\\d+(?:\\.\\d+)*)", - "/\\*!? jPlayer (\\d+(?:\\.\\d+)*) for jQuery" - ], - "hashes": [] - }, - "knockout": { - "filename": [ - "knockout-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "(?:\\*|//) Knockout JavaScript library v(\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "sessvars": { - "filename": [ - "sessvars-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "sessvars ver (\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "swfobject": { - "filename": [ - "swfobject_(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "SWFObject v(\\d+(?:\\.\\d+)*) " - ], - "hashes": [] - }, - "tinyMCE": { - "filecontent": [ - "// (\\d+(?:\\.\\d+)*) \\([0-9\\-]+\\)[\n\r]+.{0,1200}l=.tinymce/geom/Rect.", - "/\\*\\*[\\s]*\\* TinyMCE version (\\d+(?:\\.\\d+)*)" - ] - }, - "YUI": { - "filename": [ - "yui-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/*\nYUI (\\d+(?:\\.\\d+)*)", - "/yui/license.(?:html|txt)\nversion: (\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "prototypejs": { - "filename": [ - "prototype-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "Prototype JavaScript framework, version (\\d+(?:\\.\\d+)*)", - "Prototype[ ]?=[ ]?\\{[ \r\n\t]*Version:[ ]?(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")" - ], - "hashes": [] - }, - "ember": { - "filename": [ - "ember-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "Project: Ember -(?:.*\n){9,11}// Version: v(\\d+(?:\\.\\d+)*)", - "// Version: v(\\d+(?:\\.\\d+)*)(.*\n){10,15}(Ember Debug|@module ember|@class ember)", - "Ember.VERSION[ ]?=[ ]?(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")", - "meta\\.revision=\"Ember@(\\d+(?:\\.\\d+)*)\"", - "e\\(\"ember/version\",\\[\"exports\"\\],function\\(e\\)\\{\"use strict\";?[\\s]*e(?:\\.|\\[\")default(?:\"\\])?=\"(\\d+(?:\\.\\d+)*)\"", - "\\(\"ember/version\",\\[\"exports\"\\],function\\(e\\)\\{\"use strict\";.{1,70}\\.default=\"(\\d+(?:\\.\\d+)*)\"", - "/\\*![\\s]+\\* @overview Ember - JavaScript Application Framework[\\s\\S]{0,400}\\* @version (\\d+(?:\\.\\d+)*)", - "// Version: (\\d+(?:\\.\\d+)*)[\\s]+\\(function\\(\\) *\\{[\\s]*/\\*\\*[\\s]+@module ember[\\s]" - ], - "hashes": [] - }, - "dojo": { - "filename": [ - "dojo-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "hashes": [ - "73cdd262799aab850abbe694cd3bfb709ea23627", - "c8c84eddc732c3cbf370764836a7712f3f873326", - "d569ce9efb7edaedaec8ca9491aab0c656f7c8f0", - "ad44e1770895b7fa84aff5a56a0f99b855a83769", - "8fc10142a06966a8709cd9b8732f7b6db88d0c34", - "a09b5851a0a3e9d81353745a4663741238ee1b84", - "2ab48d45abe2f54cdda6ca32193b5ceb2b1bc25d", - "12208a1e649402e362f528f6aae2c614fc697f8f", - "72a6a9fbef9fa5a73cd47e49942199147f905206" - ] - }, - "angularjs": { - "filename": [ - "angular(?:js)?-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "/\\*[\\*\\s]+(?:@license )?AngularJS v(\\d+(?:\\.\\d+)*)", - "http://errors\\.angularjs\\.org/(\\d+(?:\\.\\d+)*)/" - ], - "hashes": [] - }, - "@angular/core": {}, - "backbone.js": { - "filename": [ - "backbone(?:js)?-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "//[ ]+Backbone.js (\\d+(?:\\.\\d+)*)", - "a=t.Backbone=\\{\\}\\}a.VERSION=\"(\\d+(?:\\.\\d+)*)\"", - "Backbone\\.VERSION *= *[\"'](\\d+(?:\\.\\d+)*)[\"']" - ], - "hashes": [] - }, - "mustache.js": { - "filename": [ - "mustache(?:js)?-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "name:\"mustache.js\",version:\"(\\d+(?:\\.\\d+)*)\"", - "name=\"mustache.js\"[;,].\\.version=\"(\\d+(?:\\.\\d+)*)\"", - "[^a-z]mustache.version[ ]?=[ ]?(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")", - "exports.name[ ]?=[ ]?\"mustache.js\";[\n ]*exports.version[ ]?=[ ]?(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\");" - ], - "hashes": [] - }, - "handlebars": { - "filename": [ - "handlebars(?:js)?-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "Handlebars.VERSION = \"(\\d+(?:\\.\\d+)*)\";", - "Handlebars=\\{VERSION:(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")", - "this.Handlebars=\\{\\};[\n\r \t]+\\(function\\([a-z]\\)\\{[a-z].VERSION=(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")", - "exports.HandlebarsEnvironment=[\\s\\S]{70,120}exports.VERSION=(?:'|\")(\\d+(?:\\.\\d+)*)(?:'|\")", - "/\\*+![\\s]+(?:@license)?[\\s]+handlebars v+(\\d+(?:\\.\\d+)*)", - "window\\.Handlebars=.,.\\.VERSION=\"(\\d+(?:\\.\\d+)*)\"", - ".\\.HandlebarsEnvironment=.;var .=.\\(.\\),.=.\\(.\\),.=\"(\\d+(?:\\.\\d+)*)\";.\\.VERSION=" - ], - "hashes": [] - }, - "easyXDM": { - "filename": [ - "easyXDM-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - " \\* easyXDM\n \\* http://easyxdm.net/(?:\r|\n|.)+version:\"(\\d+(?:\\.\\d+)*)\"", - "@class easyXDM(?:.|\r|\n)+@version (\\d+(?:\\.\\d+)*)(\r|\n)" - ], - "hashes": [ - "cf266e3bc2da372c4f0d6b2bd87bcbaa24d5a643" - ] - }, - "plupload": { - "filename": [ - "plupload-(\\d+(?:\\.\\d+)*)(.min)?\\.js" - ], - "filecontent": [ - "\\* Plupload - multi-runtime File Uploader(?:\r|\n)+ \\* v(\\d+(?:\\.\\d+)*)", - "var g=\\{VERSION:\"(\\d+(?:\\.\\d+)*)\",.*;window.plupload=g\\}" - ], - "hashes": [] - }, - "DOMPurify": { - "filecontent": [ - "DOMPurify.version = '(\\d+(?:\\.\\d+)*)';", - "DOMPurify.version=\"(\\d+(?:\\.\\d+)*)\"", - "DOMPurify=.[^\\r\\n]{10,850}?\\.version=\"(\\d+(?:\\.\\d+)*)\"", - "/\\*! @license DOMPurify (\\d+(?:\\.\\d+)*)", - "var .=\"dompurify\"+.{10,550}?\\.version=\"(\\d+(?:\\.\\d+)*)\"" - ], - "hashes": [] - }, - "react": { - "filecontent": [ - "/\\*\\*\n +\\* React \\(with addons\\) ?v(\\d+(?:\\.\\d+)*)", - "/\\*\\*\n +\\* React v(\\d+(?:\\.\\d+)*)", - "/\\*\\* @license React v(\\d+(?:\\.\\d+)*)[\\s]*\\* react(-jsx-runtime)?\\.", - "\"\\./ReactReconciler\":[0-9]+,\"\\./Transaction\":[0-9]+,\"fbjs/lib/invariant\":[0-9]+\\}\\],[0-9]+:\\[function\\(require,module,exports\\)\\{\"use strict\";module\\.exports=\"(\\d+(?:\\.\\d+)*)\"\\}", - "ReactVersion\\.js[\\*! \\\\/\n\r]{0,100}function\\(e,t\\)\\{\"use strict\";e\\.exports=\"(\\d+(?:\\.\\d+)*)\"", - "expected a ReactNode.[\\s\\S]{0,1800}?function\\(e,t\\)\\{\"use strict\";e\\.exports=\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "react-dom": { - "filecontent": [ - "version:\"(\\d+(?:\\.\\d+)*)[a-z0-9\\-]*\"[\\s,]*rendererPackageName:\"react-dom\"", - "/\\*\\* @license React v(\\d+(?:\\.\\d+)*)[\\s]*\\* react-dom\\." - ] - }, - "react-is": { - "filecontent": [ - "/\\*\\* @license React v(\\d+(?:\\.\\d+)*)[\\s]*\\* react-is\\." - ] - }, - "scheduler": { - "filecontent": [ - "/\\*\\* @license React v(\\d+(?:\\.\\d+)*)[\\s]*\\* scheduler\\." - ] - }, - "flowplayer": { - "filename": [ - "flowplayer-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ] - }, - "DWR": { - "filecontent": [ - " dwr-(\\d+(?:\\.\\d+)*).jar" - ] - }, - "moment.js": { - "filename": [ - "moment(?:-|\\.)(\\d+(?:\\.\\d+)*)(?:-min)?\\.js" - ], - "filecontent": [ - "//!? moment.js(?:[\n\r]+)//!? version : (\\d+(?:\\.\\d+)*)", - "/\\* Moment.js +\\| +version : (\\d+(?:\\.\\d+)*) \\|", - "\\.version=\"(\\d+(?:\\.\\d+)*)\".{20,60}\"isBefore\".{20,60}\"isAfter\".{200,500}\\.isMoment=", - "\\.version=\"(\\d+(?:\\.\\d+)*)\".{20,300}duration.{2,100}\\.isMoment=", - "\\.isMoment\\(.{50,400}_isUTC.{50,400}=\"(\\d+(?:\\.\\d+)*)\"", - "=\"(\\d+(?:\\.\\d+)*)\".{300,1000}Years:31536e6.{60,80}\\.isMoment", - "// Moment.js is freely distributable under the terms of the MIT license.[\\s]+//[\\s]+// Version (\\d+(?:\\.\\d+)*)" - ] - }, - "underscore.js": { - "filecontent": [ - "//[\\s]*Underscore.js (\\d+(?:\\.\\d+)*)", - "// *Underscore\\.js[\\s\\S]{1,2500}_\\.VERSION *= *['\"](\\d+(?:\\.\\d+)*)['\"]" - ] - }, - "bootstrap": { - "filename": [ - "bootstrap-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*!? Bootstrap v(\\d+(?:\\.\\d+)*)", - "\\* Bootstrap v(\\d+(?:\\.\\d+)*)", - "/\\*! Bootstrap v(\\d+(?:\\.\\d+)*)", - "this\\.close\\)\\};.\\.VERSION=\"(\\d+(?:\\.\\d+)*)\"(?:,.\\.TRANSITION_DURATION=150)?,.\\.prototype\\.close" - ], - "hashes": [] - }, - "bootstrap-select": { - "filecontent": [ - "/\\*![\\s]+\\*[\\s]+Bootstrap-select[\\s]+v(\\d+(?:\\.\\d+)*)", - ".\\.data\\(\"selectpicker\",.=new .\\(this,.\\)\\)\\}\"string\"==typeof .&&\\(.=.\\[.\\]instanceof Function\\?.\\[.\\]\\.apply\\(.,.\\):.\\.options\\[.\\]\\)\\}\\}\\);return void 0!==.\\?.:.\\}.\\.VERSION=\"(\\d+(?:\\.\\d+)*)\"," - ] - }, - "ckeditor": { - "filename": [ - "ckeditor-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "ckeditor..js.{4,30}=\\{timestamp:\"[^\"]+\",version:\"(\\d+(?:\\.\\d+)*)", - "window\\.CKEDITOR=function\\(\\)\\{var [a-z]=\\{timestamp:\"[^\"]+\",version:\"(\\d+(?:\\.\\d+)*)" - ], - "hashes": [] - }, - "ckeditor5": { - "filename": [ - "ckeditor5-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "const .=\"(\\d+(?:\\.\\d+)*)\";.{0,140}?\\.CKEDITOR_VERSION=.;", - "CKEDITOR_VERSION=\"(\\d+(?:\\.\\d+)*)\"" - ], - "hashes": [] - }, - "vue": { - "filename": [ - "vue-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*!\\n \\* Vue.js v(\\d+(?:\\.\\d+)*)", - "Vue.version = '(\\d+(?:\\.\\d+)*)';", - "'(\\d+(?:\\.\\d+)*)'[^\\n]{0,8000}Vue compiler", - "\\* Original file: /npm/vue@(\\d+(?:\\.\\d+)*)/dist/vue.(global|common).js", - "const version[ ]*=[ ]*\"(\\d+(?:\\.\\d+)*)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", - "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(\\d+(?:\\.\\d+)*)\",", - "let [A-Za-z]+=\"(\\d+(?:\\.\\d+)*)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "ExtJS": { - "filename": [ - "/ext-all-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js", - "/ext-all-debug-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js", - "/ext-base-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/*!\n * Ext JS Library (\\d+(?:\\.\\d+)*)", - "Ext = \\{[\\s]*/\\*[^/]+/[\\s]*version *: *['\"](\\d+(?:\\.\\d+)*)['\"]", - "var version *= *['\"](\\d+(?:\\.\\d+)*)['\"], *Version;[\\s]*Ext.Version *= *Version *= *Ext.extend" - ] - }, - "svelte": { - "filename": [ - "svelte[@\\-](\\d+(?:\\.\\d+)*)(.min)?\\.m?js" - ], - "filecontent": [ - "generated by Svelte v\\$\\{['\"](\\d+(?:\\.\\d+)*)['\"]\\}", - "generated by Svelte v(\\d+(?:\\.\\d+)*) \\*/", - "version: '(\\d+(?:\\.\\d+)*)' [\\s\\S]{80,200}'SvelteDOMInsert'", - "VERSION = '(\\d+(?:\\.\\d+)*)'[\\s\\S]{21,200}parse\\$[0-9][\\s\\S]{10,80}preprocess", - "var version\\$[0-9] = \"(\\d+(?:\\.\\d+)*)\";[\\s\\S]{10,30}normalizeOptions\\(options\\)[\\s\\S]{80,200}'SvelteComponent.html'" - ] - }, - "axios": { - "filename": [ - "axios-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\* *axios v(\\d+(?:\\.\\d+)*) ", - "// Axios v(\\d+(?:\\.\\d+)*) C", - "return\"\\[Axios v(\\d+(?:\\.\\d+)*)\\] Transitional", - "\\\"axios\\\",\\\"version\\\":\\\"(\\d+(?:\\.\\d+)*)\\\"" - ] - }, - "markdown-it": { - "filename": [ - "markdown-it-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*! markdown-it(?:-ins)? (\\d+(?:\\.\\d+)*)" - ] - }, - "jszip": { - "filename": [ - "jszip-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*![\\s]+JSZip v(\\d+(?:\\.\\d+)*) " - ] - }, - "AlaSQL": { - "filename": [ - "alasql-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "/\\*!?[ \n]*AlaSQL v(\\d+(?:\\.\\d+)*)" - ] - }, - "jquery.datatables": { - "filename": [ - "jquery.dataTables-(\\d+(?:\\.\\d+)*)(\\.min)?\\.js" - ], - "filecontent": [ - "http://www.datatables.net\n +DataTables (\\d+(?:\\.\\d+)*)", - "/\\*! DataTables (\\d+(?:\\.\\d+)*)", - ".\\.version=\"(\\d+(?:\\.\\d+)*)\";[\\s]*.\\.settings=\\[\\];[\\s]*.\\.models=\\{[\\s]*\\};[\\s]*.\\.models.oSearch" - ] - }, - "nextjs": { - "filecontent": [ - "version=\"(\\d+(?:\\.\\d+)*)\".{1,1500}document\\.getElementById\\(\"__NEXT_DATA__\"\\)\\.textContent", - "document\\.getElementById\\(\"__NEXT_DATA__\"\\)\\.textContent\\);window\\.__NEXT_DATA__=.;.\\.version=\"(\\d+(?:\\.\\d+)*)\"", - "=\"(\\d+(?:\\.\\d+)*)\"[\\s\\S]{10,100}Component[\\s\\S]{1,10}componentDidCatch[\\s\\S]{10,30}componentDidMount" - ] - }, - "chart.js": { - "filecontent": [ - "var version=\"(\\d+(?:\\.\\d+)*)\";const KNOWN_POSITIONS=\\[\"top\",\"bottom\",\"left\",\"right\",\"chartArea\"\\]", - "/\\*![\\s]+\\* Chart.js v(\\d+(?:\\.\\d+)*)", - "/\\*![\\s]+\\* Chart.js[\\s]+\\* http://chartjs.org/[\\s]+\\* Version: (\\d+(?:\\.\\d+)*)" - ] - }, - "froala": { - "filecontent": [ - "/\\*![\\s]+\\* froala_editor v(\\d+(?:\\.\\d+)*)", - "VERSION:\"(\\d+(?:\\.\\d+)*)\",INSTANCES:\\[\\],OPTS_MAPPING:\\{\\}" - ] - }, - "pendo": { - "filecontent": [ - "// Pendo Agent Wrapper\n//[\\s]+Environment:[\\s]+[^\n]+\n// Agent Version:[\\s]+(\\d+(?:\\.\\d+)*)" - ] - }, - "highcharts": { - "filecontent": [ - "product:\"Highcharts\",version:\"(\\d+(?:\\.\\d+)*)\"", - "product=\"Highcharts\"[,;].\\.version=\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "select2": { - "filecontent": [ - "/\\*!(?:[\\s]+\\*)? Select2 (\\d+(?:\\.\\d+)*)", - "/\\*[\\s]+Copyright 20[0-9]{2} [I]gor V[a]ynberg[\\s]+Version: (\\d+(?:\\.\\d+)*)[\\s\\S]{1,5000}(\\.attr\\(\"class\",\"select2-sizer\"|\\.data\\(document, *\"select2-lastpos\"|document\\)\\.data\\(\"select2-lastpos\"|SingleSelect2, *MultiSelect2|window.Select2 *!== *undefined)" - ] - }, - "blueimp-file-upload": { - "filecontent": [ - "/\\*[\\s*]+jQuery File Upload User Interface Plugin (\\d+(?:\\.\\d+)*)[\\s*]+https://github.com/blueimp" - ] - }, - "c3": { - "filecontent": [ - "[\\s]+var c3 ?= ?\\{ ?version: ?['\"](\\d+(?:\\.\\d+)*)['\"] ?\\};[\\s]+var c3_chart_fn," - ] - }, - "lodash": { - "filecontent": [ - "/\\*[\\s*!]+(?:@license)?[\\s*]+(?:Lo-Dash|lodash|Lodash) v?(\\d+(?:\\.\\d+)*)[\\s\\S]{1,200}Build: `lodash modern -o", - "/\\*[\\s*!]+(?:@license)?[\\s*]+(?:Lo-Dash|lodash|Lodash) v?(\\d+(?:\\.\\d+)*) <", - "/\\*[\\s*!]+(?:@license)?[\\s*]+(?:Lo-Dash|lodash|Lodash) v?(\\d+(?:\\.\\d+)*) lodash.com/license", - "=\"(\\d+(?:\\.\\d+)*)\"[\\s\\S]{1,300}__lodash_hash_undefined__", - "/\\*[\\s*]+@license[\\s*]+(?:Lo-Dash|lodhash|Lodash)[\\s\\S]{1,500}var VERSION *= *['\"](\\d+(?:\\.\\d+)*)['\"]", - "var VERSION=\"(\\d+(?:\\.\\d+)*)\";var BIND_FLAG=1,BIND_KEY_FLAG=2,CURRY_BOUND_FLAG=4,CURRY_FLAG=8" - ] - }, - "ua-parser-js": { - "filecontent": [ - "/\\* UAParser.js v(\\d+(?:\\.\\d+)*)", - "/\\*[*!](?:@license)?[\\s]+\\* UAParser.js v(\\d+(?:\\.\\d+)*)", - "// UAParser.js v(\\d+(?:\\.\\d+)*)", - ".\\.VERSION=\"(\\d+(?:\\.\\d+)*)\",.\\.BROWSER=\\{NAME:.,MAJOR:\"major\",VERSION:.\\},.\\.CPU=\\{ARCHITECTURE:", - ".\\.VERSION=\"(\\d+(?:\\.\\d+)*)\",.\\.BROWSER=.\\(\\[[^\\]]{1,20}\\]\\),.\\.CPU=", - "LIBVERSION=\"(\\d+(?:\\.\\d+)*)\",EMPTY=\"\",UNKNOWN=\"\\?\",FUNC_TYPE=\"function\",UNDEF_TYPE=\"undefined\"", - ".=\"(\\d+(?:\\.\\d+)*)\",.=\"\",.=\"\\?\",.=\"function\",.=\"undefined\",.=\"object\",(.=\"string\",)?.=\"major\",.=\"model\",.=\"name\",.=\"type\",.=\"vendor\"" - ] - }, - "mathjax": { - "filecontent": [ - "\\.MathJax\\.config\\.startup;{10,100}.\\.VERSION=\"(\\d+(?:\\.\\d+)*)\"", - "\\.MathJax=\\{version:\"(\\d+(?:\\.\\d+)*)\"", - "MathJax.{0,100}.\\.VERSION=void 0,.\\.VERSION=\"(\\d+(?:\\.\\d+)*)\"", - "MathJax\\.version=\"(\\d+(?:\\.\\d+)*)\";" - ] - }, - "pdf.js": { - "filecontent": [ - "(?:const|var) pdfjsVersion = ['\"](\\d+(?:\\.\\d+)*)['\"];", - "PDFJS.version ?= ?['\"](\\d+(?:\\.\\d+)*)['\"]", - "apiVersion: ?['\"](\\d+(?:\\.\\d+)*)['\"][\\s\\S]*,data(:[a-zA-Z.]{1,6})?,[\\s\\S]*password(:[a-zA-Z.]{1,10})?,[\\s\\S]*disableAutoFetch(:[a-zA-Z.]{1,22})?,[\\s\\S]*rangeChunkSize", - "messageHandler\\.sendWithPromise\\(\"GetDocRequest\",\\{docId:[a-zA-Z],apiVersion:\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "pdfobject": { - "filecontent": [ - "\\* +PDFObject v(\\d+(?:\\.\\d+)*)", - "/*[\\s]+PDFObject v(\\d+(?:\\.\\d+)*)", - "let pdfobjectversion = \"(\\d+(?:\\.\\d+)*)\";", - "pdfobjectversion:\"(\\d+(?:\\.\\d+)*)\"" - ] - }, - "dont check": {} -} From a0fb868be8aa0c7ac6622c9754791b41c6a8955a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:10:54 +0000 Subject: [PATCH 43/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 99e6e559..4fec9c75 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: MIT import json -import pathlib import re from typing import Any, Dict, List @@ -12,11 +11,9 @@ from loguru import logger import surfactant.plugin +from surfactant.configmanager import ConfigManager from surfactant.sbomtypes import SBOM, Software -from surfactant.configmanager import ConfigManager -import os -from pathlib import Path def supports_file(filetype) -> bool: return filetype == "JAVASCRIPT" @@ -31,7 +28,9 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - js_lib_file = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + js_lib_file = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) # Load expressions from retire.js, should move this file elsewhere try: @@ -123,7 +122,9 @@ def update_db(): cleaned = strip_irrelevant_data(retirejs) path = ConfigManager().get_data_dir_path() / "infoextractors" path.mkdir(parents=True, exist_ok=True) - json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + json_file_path = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) with open(json_file_path, "w") as f: json.dump(cleaned, f, indent=4) return "Update complete." @@ -134,6 +135,7 @@ def update_db(): def short_name(): return "js_file" + def load_db(): path = ConfigManager().get_data_dir_path() / "infoextractors" path.mkdir(parents=True, exist_ok=True) @@ -141,11 +143,14 @@ def load_db(): retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) - json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + json_file_path = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) with open(json_file_path, "w") as f: json.dump(cleaned, f, indent=4) - logger.info(f"Javascript library CVE database loaded.") + logger.info("Javascript library CVE database loaded.") else: - logger.warning(f"javascript library CVE database did not load.") + logger.warning("javascript library CVE database did not load.") + -load_db() \ No newline at end of file +load_db() From 3a223e2cccce68de48dba5d130331e96b69387ce Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 17 Dec 2024 18:24:05 +0000 Subject: [PATCH 44/58] Updated js match script to use file path generated with ConfigManager().get_data_dir_path() instead of hardcoded path that no longer exists. --- scripts/js_libraries/match_javascript.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/js_libraries/match_javascript.py b/scripts/js_libraries/match_javascript.py index 03128fa6..1e1353c4 100644 --- a/scripts/js_libraries/match_javascript.py +++ b/scripts/js_libraries/match_javascript.py @@ -3,6 +3,8 @@ import requests +from surfactant.configmanager import ConfigManager + def get_test_file(): url = "https://cdnjs.cloudflare.com/ajax/libs/select2/3.5.4/select2.min.js" @@ -32,8 +34,8 @@ def find_js_match(expressions: dict, filename: str) -> str: get_test_file() - -with open("js_library_patterns.json", "r") as f: +json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" +with open(json_file_path, "r") as f: patterns = json.load(f) library_name = find_js_match(patterns, "testFile.js") From a7ccf73a9e0824c8fac22cacd6764050cbe5acf5 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 17 Dec 2024 19:02:30 +0000 Subject: [PATCH 45/58] Removed redundant parenthesis --- surfactant/infoextractors/js_file.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 4fec9c75..ca073cff 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -28,9 +28,7 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - js_lib_file = ( - ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" - ) + js_lib_file = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" # Load expressions from retire.js, should move this file elsewhere try: @@ -143,9 +141,7 @@ def load_db(): retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) - json_file_path = ( - ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" - ) + json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" with open(json_file_path, "w") as f: json.dump(cleaned, f, indent=4) logger.info("Javascript library CVE database loaded.") From a361e09225040d6aead2f808db3197e58c0b55df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:03:00 +0000 Subject: [PATCH 46/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index ca073cff..4fec9c75 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -28,7 +28,9 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - js_lib_file = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + js_lib_file = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) # Load expressions from retire.js, should move this file elsewhere try: @@ -141,7 +143,9 @@ def load_db(): retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) - json_file_path = ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + json_file_path = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) with open(json_file_path, "w") as f: json.dump(cleaned, f, indent=4) logger.info("Javascript library CVE database loaded.") From 497f585120eae13399e8b69b5b094fe1a1e37768 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Tue, 17 Dec 2024 19:20:08 +0000 Subject: [PATCH 47/58] Removed commented out code. --- surfactant/infoextractors/js_file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index ca073cff..6d54b450 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -137,7 +137,6 @@ def short_name(): def load_db(): path = ConfigManager().get_data_dir_path() / "infoextractors" path.mkdir(parents=True, exist_ok=True) - # os.makedirs(os.path.dirname(ConfigManager().get_data_dir_path() / "infoextractors"), exist_ok=True) retirejs = load_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) From 349c187e2578b14d7ec61479154099cf43566137 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 11:46:27 -0600 Subject: [PATCH 48/58] Update surfactant/infoextractors/js_file.py Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/infoextractors/js_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 2f725c83..85ca1dd1 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -75,7 +75,7 @@ def match_by_attribute(attribute: str, content: str, database: Dict) -> List[Dic return libs -def load_database() -> dict: +def download_database() -> dict: url = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-master.json" response = requests.get(url) if response.status_code == 200: From d87e953af8be3fc45a6f285a3913618b12d2bc2c Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 11:47:05 -0600 Subject: [PATCH 49/58] Update surfactant/infoextractors/js_file.py Increase readability of the code. Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/infoextractors/js_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 85ca1dd1..9d052441 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -117,7 +117,7 @@ def update_db(): """Retrieves the javascript library CVE database used by retire.js (https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository-master.json) and only keeps the contents under each library's "extractors" section, which contains file hashes and regexes relevant for detecting a specific javascript library by its file name or contents. The resulting smaller json is written to js_library_patterns.json in the same directory. This smaller file will be read from to make the checks later on.""" - retirejs = load_database() + retirejs = download_database() if retirejs is not None: cleaned = strip_irrelevant_data(retirejs) path = ConfigManager().get_data_dir_path() / "infoextractors" From 726cdb87513fe43f6b30ea78877f3e6ab591958f Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 11:54:03 -0600 Subject: [PATCH 50/58] Update surfactant/infoextractors/js_file.py Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/infoextractors/js_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 9d052441..bcfed0b4 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -152,4 +152,4 @@ def load_db(): logger.warning("javascript library CVE database did not load.") -load_db() +js_lib_database = load_db() From e1816c9d5e4046d8997118bc6dd33c17d3e5cfdc Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 13:10:54 -0600 Subject: [PATCH 51/58] Update surfactant/infoextractors/js_file.py Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- surfactant/infoextractors/js_file.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index bcfed0b4..db283443 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -137,19 +137,20 @@ def short_name(): def load_db(): - path = ConfigManager().get_data_dir_path() / "infoextractors" - path.mkdir(parents=True, exist_ok=True) - retirejs = load_database() - if retirejs is not None: - cleaned = strip_irrelevant_data(retirejs) - json_file_path = ( - ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" - ) - with open(json_file_path, "w") as f: - json.dump(cleaned, f, indent=4) - logger.info("Javascript library CVE database loaded.") - else: - logger.warning("javascript library CVE database did not load.") + js_lib_file = ( + ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" + ) + + # Load expressions from retire.js, should move this file elsewhere + try: + path = ConfigManager().get_data_dir_path() / "infoextractors" + path.mkdir(parents=True, exist_ok=True) + with open(js_lib_file, "r") as regex: + database = json.load(regex) + except FileNotFoundError: + logger.warning(f"Javascript library pattern database database could not be loaded. Run `surfactant plugin update js_file` to fetch the pattern database.") + return None + return database js_lib_database = load_db() From d8b4c938ea44c72ef22e1f2e368604b9e1ac5a61 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:11:50 +0000 Subject: [PATCH 52/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index db283443..f0f5dce2 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -148,7 +148,9 @@ def load_db(): with open(js_lib_file, "r") as regex: database = json.load(regex) except FileNotFoundError: - logger.warning(f"Javascript library pattern database database could not be loaded. Run `surfactant plugin update js_file` to fetch the pattern database.") + logger.warning( + "Javascript library pattern database database could not be loaded. Run `surfactant plugin update js_file` to fetch the pattern database." + ) return None return database From 62e8a12fa871ceee5d3b0376259a00ae8ada3da5 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 13:12:15 -0600 Subject: [PATCH 53/58] Update js_file.py Removed old comment. --- surfactant/infoextractors/js_file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index f0f5dce2..97202ace 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -141,7 +141,6 @@ def load_db(): ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" ) - # Load expressions from retire.js, should move this file elsewhere try: path = ConfigManager().get_data_dir_path() / "infoextractors" path.mkdir(parents=True, exist_ok=True) From ecebd1c5db92bdee9936cfe1f2ae857efd8b7a52 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 19:29:02 +0000 Subject: [PATCH 54/58] Removed dir creation and file load with preloaded database. --- surfactant/infoextractors/js_file.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 97202ace..c9bff0e9 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -28,22 +28,15 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - js_lib_file = ( - ConfigManager().get_data_dir_path() / "infoextractors" / "js_library_patterns.json" - ) - - # Load expressions from retire.js, should move this file elsewhere - try: - path = ConfigManager().get_data_dir_path() / "infoextractors" - path.mkdir(parents=True, exist_ok=True) - with open(js_lib_file, "r") as regex: - database = json.load(regex) - except FileNotFoundError: - logger.warning(f"File not found: {js_lib_file}") + + if js_lib_database is None: + logger.warning( + "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." + ) return None # Try to match file name - libs = match_by_attribute("filename", filename, database) + libs = match_by_attribute("filename", filename, js_lib_database) if len(libs) > 0: js_info["jsLibraries"] = libs return js_info @@ -52,7 +45,7 @@ def extract_js_info(filename: str) -> object: try: with open(filename, "r") as js_file: filecontent = js_file.read() - libs = match_by_attribute("filecontent", filecontent, database) + libs = match_by_attribute("filecontent", filecontent, js_lib_database) js_info["jsLibraries"] = libs except FileNotFoundError: logger.warning(f"File not found: {filename}") @@ -148,7 +141,7 @@ def load_db(): database = json.load(regex) except FileNotFoundError: logger.warning( - "Javascript library pattern database database could not be loaded. Run `surfactant plugin update js_file` to fetch the pattern database." + "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." ) return None return database From 1d66b528fa8ac3376e58a71e640c06e699b03d4d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:30:19 +0000 Subject: [PATCH 55/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index c9bff0e9..1e87b896 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -28,7 +28,7 @@ def extract_file_info(sbom: SBOM, software: Software, filename: str, filetype: s def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} - + if js_lib_database is None: logger.warning( "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." From c05b82aa282018b0da689115c5d2c95e261cea50 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 19:58:26 +0000 Subject: [PATCH 56/58] Added warning flag to only show warning once. Removed redundant dir creation. --- surfactant/infoextractors/js_file.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index 1e87b896..b0caf453 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -30,9 +30,10 @@ def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} if js_lib_database is None: - logger.warning( - "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." - ) + if already_showed_install_message: + logger.warning( + "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." + ) return None # Try to match file name @@ -135,16 +136,15 @@ def load_db(): ) try: - path = ConfigManager().get_data_dir_path() / "infoextractors" - path.mkdir(parents=True, exist_ok=True) with open(js_lib_file, "r") as regex: database = json.load(regex) except FileNotFoundError: logger.warning( "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." ) + already_showed_install_message = True return None return database - +already_showed_install_message = False js_lib_database = load_db() From b9f2fae2864c5eaf6b470389303e71df167124f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:58:49 +0000 Subject: [PATCH 57/58] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- surfactant/infoextractors/js_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index b0caf453..c9aa1456 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -146,5 +146,6 @@ def load_db(): return None return database + already_showed_install_message = False js_lib_database = load_db() From fa4829c4aa77a3d323cde02b14a35593a3a0c713 Mon Sep 17 00:00:00 2001 From: Willis Berrios Date: Wed, 18 Dec 2024 20:05:03 +0000 Subject: [PATCH 58/58] Removed flag. --- surfactant/infoextractors/js_file.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/surfactant/infoextractors/js_file.py b/surfactant/infoextractors/js_file.py index b0caf453..c3659912 100644 --- a/surfactant/infoextractors/js_file.py +++ b/surfactant/infoextractors/js_file.py @@ -30,10 +30,6 @@ def extract_js_info(filename: str) -> object: js_info: Dict[str, Any] = {"jsLibraries": []} if js_lib_database is None: - if already_showed_install_message: - logger.warning( - "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." - ) return None # Try to match file name @@ -142,9 +138,8 @@ def load_db(): logger.warning( "Javascript library pattern database database could not be loaded. Run `surfactant plugin update-db js_file` to fetch the pattern database." ) - already_showed_install_message = True return None return database -already_showed_install_message = False + js_lib_database = load_db()