insight-plugin 1.3.0__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/PKG-INFO +18 -1
  2. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/README.md +17 -0
  3. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/__init__.py +1 -1
  4. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/__main__.py +1 -10
  5. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/__pycache__/__init__.cpython-39.pyc +0 -0
  6. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/plugin_spec_util.py +0 -1
  7. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/schema_util.py +3 -1
  8. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/controller.py +1 -10
  9. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/constants.py +1 -1
  10. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/help_util.py +1 -1
  11. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/PKG-INFO +18 -1
  12. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/SOURCES.txt +0 -5
  13. insight_plugin-1.3.0/insight_plugin/features/interactive/controller.py +0 -247
  14. insight_plugin-1.3.0/insight_plugin/features/interactive/util/util.py +0 -227
  15. insight_plugin-1.3.0/tests/resources/export_test_base64/__init__.py +0 -0
  16. insight_plugin-1.3.0/tests/resources/export_test_base64/unit_test/__init__.py +0 -0
  17. insight_plugin-1.3.0/tests/test_interactive.py +0 -91
  18. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/LICENSE +0 -0
  19. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/constants.py +0 -0
  20. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/__init__.py +0 -0
  21. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/analysis/__init__.py +0 -0
  22. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/analysis/controller.py +0 -0
  23. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/__init__.py +0 -0
  24. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/builder.py +0 -0
  25. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/checksum_util.py +0 -0
  26. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/command_line_util.py +0 -0
  27. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/common_feature.py +0 -0
  28. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/docker_util.py +0 -0
  29. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/dockerspec.py +0 -0
  30. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/exceptions.py +0 -0
  31. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/logging_util.py +0 -0
  32. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/temp_file_util.py +0 -0
  33. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/common/template_util.py +0 -0
  34. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/__init__.py +0 -0
  35. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/__init__.py +0 -0
  36. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/components.py +0 -0
  37. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/connection_help.py +0 -0
  38. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/help/input_output_helpers.py +0 -0
  39. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/json_generation_util.py +0 -0
  40. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/plugin_to_helpmd.py +0 -0
  41. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/create/util.py +0 -0
  42. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/export/__init__.py +0 -0
  43. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/export/controller.py +0 -0
  44. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/export/util/__init__.py +0 -0
  45. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/export/util/util.py +0 -0
  46. {insight_plugin-1.3.0/insight_plugin/features/interactive → insight_plugin-1.4.0/insight_plugin/features/linter}/__init__.py +0 -0
  47. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/linter/controller.py +0 -0
  48. {insight_plugin-1.3.0/insight_plugin/features/interactive/util → insight_plugin-1.4.0/insight_plugin/features/refresh}/__init__.py +0 -0
  49. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/refresh/controller.py +0 -0
  50. {insight_plugin-1.3.0/insight_plugin/features/linter → insight_plugin-1.4.0/insight_plugin/features/run}/__init__.py +0 -0
  51. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/run/bash_controller.py +0 -0
  52. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/run/run_controller.py +0 -0
  53. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/run/server_controller.py +0 -0
  54. {insight_plugin-1.3.0/insight_plugin/features/refresh → insight_plugin-1.4.0/insight_plugin/features/samples}/__init__.py +0 -0
  55. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/samples/controller.py +0 -0
  56. {insight_plugin-1.3.0/insight_plugin/features/run → insight_plugin-1.4.0/insight_plugin/features/samples/util}/__init__.py +0 -0
  57. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/samples/util/constants.py +0 -0
  58. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/samples/util/util.py +0 -0
  59. {insight_plugin-1.3.0/insight_plugin/features/samples → insight_plugin-1.4.0/insight_plugin/features/validate}/__init__.py +0 -0
  60. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/validate/controller.py +0 -0
  61. {insight_plugin-1.3.0/insight_plugin/features/samples/util → insight_plugin-1.4.0/insight_plugin/features/version}/__init__.py +0 -0
  62. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/version/controller.py +0 -0
  63. {insight_plugin-1.3.0/insight_plugin/features/validate → insight_plugin-1.4.0/insight_plugin/features/version/util}/__init__.py +0 -0
  64. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/version/util/helpmd_util.py +0 -0
  65. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/version/util/input_util.py +0 -0
  66. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/version/util/version_util.py +0 -0
  67. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/version/util/yaml_util.py +0 -0
  68. {insight_plugin-1.3.0/insight_plugin/features/version → insight_plugin-1.4.0/insight_plugin/features/view}/__init__.py +0 -0
  69. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/features/view/controller.py +0 -0
  70. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/.dockerignore.jinja +0 -0
  71. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/Dockerfile.jinja +0 -0
  72. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/Makefile.jinja +0 -0
  73. {insight_plugin-1.3.0/insight_plugin/features/version/util → insight_plugin-1.4.0/insight_plugin/templates}/__init__.py +0 -0
  74. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/assessment/assessment.jinja +0 -0
  75. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/bin/plugin.jinja +0 -0
  76. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/__init__.py.jinja +0 -0
  77. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/actions/__init__.py.jinja +0 -0
  78. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/actions/action/__init__.py.jinja +0 -0
  79. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/actions/action/action.py.jinja +0 -0
  80. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/actions/action/schema.py.jinja +0 -0
  81. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/connection/__init__.py.jinja +0 -0
  82. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/connection/connection.py.jinja +0 -0
  83. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/connection/schema.py.jinja +0 -0
  84. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/tasks/__init__.py.jinja +0 -0
  85. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/tasks/task/__init__.py.jinja +0 -0
  86. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/tasks/task/schema.py.jinja +0 -0
  87. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/tasks/task/task.py.jinja +0 -0
  88. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/triggers/__init__.py.jinja +0 -0
  89. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/triggers/trigger/__init__.py.jinja +0 -0
  90. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/triggers/trigger/schema.py.jinja +0 -0
  91. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/triggers/trigger/trigger.py.jinja +0 -0
  92. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/plugin/util/__init__.py.jinja +0 -0
  93. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/requirements.txt.jinja +0 -0
  94. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/setup.py.jinja +0 -0
  95. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/unit_test/__init__.py.jinja +0 -0
  96. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin/templates/unit_test/test_action.py.jinja +0 -0
  97. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/dependency_links.txt +0 -0
  98. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/entry_points.txt +0 -0
  99. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/requires.txt +0 -0
  100. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/insight_plugin.egg-info/top_level.txt +0 -0
  101. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/pyproject.toml +0 -0
  102. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/setup.cfg +0 -0
  103. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/setup.py +0 -0
  104. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/__init__.py +0 -0
  105. {insight_plugin-1.3.0/insight_plugin/features/view → insight_plugin-1.4.0/tests/resources}/__init__.py +0 -0
  106. {insight_plugin-1.3.0/insight_plugin/templates → insight_plugin-1.4.0/tests/resources/export_test_base64}/__init__.py +0 -0
  107. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/__init__.py +0 -0
  108. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/__init__.py +0 -0
  109. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/decode/__init__.py +0 -0
  110. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/decode/action.py +0 -0
  111. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/decode/schema.py +0 -0
  112. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/encode/__init__.py +0 -0
  113. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/encode/action.py +0 -0
  114. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/actions/encode/schema.py +0 -0
  115. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/connection/__init__.py +0 -0
  116. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/connection/connection.py +0 -0
  117. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/connection/schema.py +0 -0
  118. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/triggers/__init__.py +0 -0
  119. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/komand_base64/util/__init__.py +0 -0
  120. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/setup.py +0 -0
  121. {insight_plugin-1.3.0/tests/resources → insight_plugin-1.4.0/tests/resources/export_test_base64/unit_test}/__init__.py +0 -0
  122. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/resources/export_test_base64/unit_test/test_encode.py +0 -0
  123. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test.py +0 -0
  124. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_checksum.py +0 -0
  125. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_create.py +0 -0
  126. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_export.py +0 -0
  127. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_gen_samples.py +0 -0
  128. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_help_creation.py +0 -0
  129. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_json_generate.py +0 -0
  130. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_refresh.py +0 -0
  131. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_run.py +0 -0
  132. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_schema.py +0 -0
  133. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_semver.py +0 -0
  134. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_spec_order.py +0 -0
  135. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_temp_file_util.py +0 -0
  136. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/test_validate.py +0 -0
  137. {insight_plugin-1.3.0 → insight_plugin-1.4.0}/tests/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: insight_plugin
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Plugin tooling for the Rapid7 Insight platform
5
5
  Home-page: https://github.com/rapid7/insight-plugin
6
6
  Author: Rapid7 Integrations Alliance
@@ -20,6 +20,23 @@ License-File: LICENSE
20
20
 
21
21
  ## Commands
22
22
 
23
+ ### Analysis
24
+ Run Static Code Analysis on the plugin.
25
+
26
+ This command will run the static code analysis check on the plugin.
27
+
28
+ ### Linter
29
+ Run the linter check on the plugin.
30
+
31
+ This command will run the `black` linter on the plugin and return any
32
+ formatting issues with the plugin.
33
+
34
+ ### Checks
35
+ Run analysis, linter and validate on the plugin.
36
+
37
+ This will allow you to recreate, locally, all the github checks that get run
38
+ on plugins.
39
+
23
40
  ### Create
24
41
  Create a new plugin.
25
42
 
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## Commands
4
4
 
5
+ ### Analysis
6
+ Run Static Code Analysis on the plugin.
7
+
8
+ This command will run the static code analysis check on the plugin.
9
+
10
+ ### Linter
11
+ Run the linter check on the plugin.
12
+
13
+ This command will run the `black` linter on the plugin and return any
14
+ formatting issues with the plugin.
15
+
16
+ ### Checks
17
+ Run analysis, linter and validate on the plugin.
18
+
19
+ This will allow you to recreate, locally, all the github checks that get run
20
+ on plugins.
21
+
5
22
  ### Create
6
23
  Create a new plugin.
7
24
 
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
 
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  ROOT_DIR = os.path.dirname(
6
6
  os.path.abspath(__file__)
7
7
  ) # Python module root, ex. insight-plugin/insight_plugin/
@@ -16,7 +16,6 @@ from insight_plugin.features.run.run_controller import RunController
16
16
  from insight_plugin.features.validate.controller import ValidateController
17
17
  from insight_plugin.features.run.server_controller import RunServerController
18
18
  from insight_plugin.features.run.bash_controller import RunShellController
19
- from insight_plugin.features.interactive.controller import InteractiveController
20
19
  from insight_plugin.features.common.exceptions import InsightException
21
20
  from insight_plugin.features.version.controller import VersionController
22
21
  from insight_plugin.features.view.controller import ViewController
@@ -99,7 +98,7 @@ def main():
99
98
  except InsightException as error:
100
99
  logging.exception(error)
101
100
  except AttributeError:
102
- interactive()
101
+ print("try 'insight-plugin --help' for more information")
103
102
 
104
103
 
105
104
  def create_argparse(subparsers, parsers_list: List) -> None:
@@ -175,14 +174,6 @@ def export(args: Namespace) -> None:
175
174
  controller.export()
176
175
 
177
176
 
178
- def interactive() -> None:
179
- """
180
- Start a general interactive session with the user
181
- :return: None
182
- """
183
- InteractiveController.prompt_menu()
184
-
185
-
186
177
  def refresh_argparse(subparsers, parsers_list: List) -> None:
187
178
  """
188
179
  Handle the arg-parsing for the refresh subcommand
@@ -64,7 +64,6 @@ class PluginComponent(Enum):
64
64
  class PluginSpecUtilModes(Enum):
65
65
  # Class that would later support alternate ways of getting the spec file
66
66
  SPECFILE = f"{PluginSpecConstants.FILEPATH} mode"
67
- INTERACTIVE = "interactive"
68
67
  GUI = "gui"
69
68
 
70
69
 
@@ -441,7 +441,9 @@ class SchemaUtil:
441
441
  # Set the current parameter default if one exists.
442
442
  SchemaUtil.try_add(PluginSpecConstants.DEFAULT, items, parent_object[key])
443
443
  # Set placeholder
444
- SchemaUtil.try_add(PluginSpecConstants.PLACEHOLDER, items, parent_object[key])
444
+ SchemaUtil.try_add(
445
+ PluginSpecConstants.PLACEHOLDER, items, parent_object[key]
446
+ )
445
447
  # Set tooltip
446
448
  SchemaUtil.try_add(PluginSpecConstants.TOOLTIP, items, parent_object[key])
447
449
  # If the current parameter is an array (it has items contents), set the items object dict.
@@ -38,14 +38,6 @@ class CreateController(CommonFeature):
38
38
  kwargs.get("target_dir"),
39
39
  )
40
40
 
41
- def interactive_prompt_spec(self) -> PluginSpecTypes.Spec:
42
- # TODO: Implement interactive create
43
- self.logger.warning(
44
- "Creating a plugin spec interactively is not yet supported. "
45
- "Please create a plugin.spec.yaml"
46
- )
47
- return {"": ""}
48
-
49
41
  def spec_to_file(self, spec: PluginSpecTypes.Spec, plugin_dir: str):
50
42
  with open(
51
43
  os.path.join(plugin_dir, "plugin.spec.yaml"), "w", encoding=FILE_ENCODING
@@ -75,8 +67,7 @@ class CreateController(CommonFeature):
75
67
  spec = PluginSpecUtil.get_spec_file(self._spec_path)
76
68
  else:
77
69
  # TODO
78
- # Interactively prompt the user for plugin spec configuration values
79
- spec = self.interactive_prompt_spec()
70
+ print("No spec file provided")
80
71
 
81
72
  # The target directory will CONTAIN the top-level directory containing all plugin content.
82
73
  # The target directory IS NOT the top-level plugin directory itself.
@@ -38,7 +38,7 @@ class TableHeaders:
38
38
  "Enum",
39
39
  "Example",
40
40
  "Placeholder",
41
- "Tooltip"
41
+ "Tooltip",
42
42
  ]
43
43
  OUTPUT_HEADERS = [
44
44
  "Name",
@@ -50,7 +50,7 @@ class HelpUtil:
50
50
  item.get(PluginSpecConstants.ENUM, "None"),
51
51
  item.get(PluginSpecConstants.EXAMPLE, "None"),
52
52
  item.get(PluginSpecConstants.PLACEHOLDER, "None"),
53
- item.get(PluginSpecConstants.TOOLTIP, "None")
53
+ item.get(PluginSpecConstants.TOOLTIP, "None"),
54
54
  ]
55
55
  elif table_type == TableHeaders.OUTPUT_HEADERS:
56
56
  next_row = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: insight-plugin
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Plugin tooling for the Rapid7 Insight platform
5
5
  Home-page: https://github.com/rapid7/insight-plugin
6
6
  Author: Rapid7 Integrations Alliance
@@ -20,6 +20,23 @@ License-File: LICENSE
20
20
 
21
21
  ## Commands
22
22
 
23
+ ### Analysis
24
+ Run Static Code Analysis on the plugin.
25
+
26
+ This command will run the static code analysis check on the plugin.
27
+
28
+ ### Linter
29
+ Run the linter check on the plugin.
30
+
31
+ This command will run the `black` linter on the plugin and return any
32
+ formatting issues with the plugin.
33
+
34
+ ### Checks
35
+ Run analysis, linter and validate on the plugin.
36
+
37
+ This will allow you to recreate, locally, all the github checks that get run
38
+ on plugins.
39
+
23
40
  ### Create
24
41
  Create a new plugin.
25
42
 
@@ -43,10 +43,6 @@ insight_plugin/features/export/__init__.py
43
43
  insight_plugin/features/export/controller.py
44
44
  insight_plugin/features/export/util/__init__.py
45
45
  insight_plugin/features/export/util/util.py
46
- insight_plugin/features/interactive/__init__.py
47
- insight_plugin/features/interactive/controller.py
48
- insight_plugin/features/interactive/util/__init__.py
49
- insight_plugin/features/interactive/util/util.py
50
46
  insight_plugin/features/linter/__init__.py
51
47
  insight_plugin/features/linter/controller.py
52
48
  insight_plugin/features/refresh/__init__.py
@@ -105,7 +101,6 @@ tests/test_create.py
105
101
  tests/test_export.py
106
102
  tests/test_gen_samples.py
107
103
  tests/test_help_creation.py
108
- tests/test_interactive.py
109
104
  tests/test_json_generate.py
110
105
  tests/test_refresh.py
111
106
  tests/test_run.py
@@ -1,247 +0,0 @@
1
- from insight_plugin import VERSION
2
- import sys
3
- from insight_plugin.features.create.controller import CreateController
4
- from insight_plugin.features.validate.controller import ValidateController
5
- from insight_plugin.features.refresh.controller import RefreshController
6
- from insight_plugin.features.run.run_controller import RunController
7
- from insight_plugin.features.export.controller import ExportController
8
- from typing import Tuple, Optional, Union
9
- from insight_plugin.constants import SubcommandDescriptions
10
- from insight_plugin.features.interactive.util.util import (
11
- retrieve_bool_input,
12
- retrieve_path_input,
13
- retrieve_jq_input,
14
- create_and_refresh_cli_controller,
15
- export_cli_controller,
16
- run_cli_controller,
17
- validate_cli_controller,
18
- )
19
-
20
-
21
- class _Option(object):
22
- def __init__(self, title: str, description: str):
23
- self.title = title
24
- self.description = description
25
-
26
-
27
- # TODO: Make this dynamic instead of hardcoded
28
- _OPTIONS = [
29
- # 1
30
- _Option(title="Create", description=SubcommandDescriptions.CREATE_DESCRIPTION),
31
- # 2
32
- _Option(title="Refresh", description=SubcommandDescriptions.REFRESH_DESCRIPTION),
33
- # 3
34
- _Option(title="Run", description=SubcommandDescriptions.RUN_DESCRIPTION),
35
- # 4
36
- _Option(title="Validate", description=SubcommandDescriptions.VALIDATE_DESCRIPTION),
37
- # 5
38
- _Option(title="Export", description=SubcommandDescriptions.EXPORT_DESCRIPTION),
39
- ]
40
-
41
-
42
- class InteractiveController(object):
43
- @staticmethod
44
- def prompt_menu():
45
- """
46
- This function handles the main functionality of printing
47
- the menu and retrieving the user input
48
- :return:
49
- """
50
- print(InteractiveController._get_interactive_menu_text())
51
-
52
- selection = None
53
- try:
54
- selection = int(input())
55
- except ValueError:
56
- sys.exit(1)
57
-
58
- InteractiveController._route_selection(selection=selection)
59
-
60
- @staticmethod
61
- def _route_selection(selection: int):
62
- """
63
- Handles the routing based on the user input
64
- :param selection: The users selection.
65
- :return:
66
- """
67
- if selection == 1:
68
- (
69
- path_to_spec,
70
- target_dir,
71
- verbose,
72
- ) = InteractiveController._get_create_refresh_controller_menu()
73
-
74
- controller = create_and_refresh_cli_controller(
75
- controller_name=CreateController,
76
- path_to_spec=path_to_spec,
77
- verbose=verbose,
78
- target_dir=target_dir,
79
- )
80
- controller.create()
81
-
82
- if selection == 2:
83
- (
84
- path_to_spec,
85
- target_dir,
86
- verbose,
87
- ) = InteractiveController._get_create_refresh_controller_menu()
88
-
89
- controller = create_and_refresh_cli_controller(
90
- controller_name=RefreshController,
91
- path_to_spec=path_to_spec,
92
- verbose=verbose,
93
- target_dir=target_dir,
94
- )
95
-
96
- controller.refresh()
97
-
98
- if selection == 3:
99
- (
100
- json_target,
101
- target_dir,
102
- verbose,
103
- assessment,
104
- is_test,
105
- jq,
106
- ) = InteractiveController._get_run_controller_menu()
107
-
108
- controller = run_cli_controller(
109
- controller_name=RunController,
110
- verbose=verbose,
111
- target_dir=target_dir,
112
- assessment=assessment,
113
- test=is_test,
114
- jq=jq,
115
- json_files=json_target,
116
- )
117
-
118
- controller.run()
119
-
120
- if selection == 4:
121
- path_to_spec = InteractiveController._get_validate_controller_menu()
122
-
123
- controller = validate_cli_controller(
124
- controller_name=ValidateController, path_to_spec=path_to_spec
125
- )
126
-
127
- controller.validate()
128
-
129
- if selection == 5:
130
- (
131
- no_pull,
132
- verbose,
133
- target_dir,
134
- ) = InteractiveController._get_export_controller_menu()
135
-
136
- controller = export_cli_controller(
137
- controller_name=ExportController,
138
- target_dir=target_dir,
139
- no_pull=no_pull,
140
- verbose=verbose,
141
- )
142
-
143
- controller.export()
144
-
145
- else:
146
- sys.exit(1)
147
-
148
- @staticmethod
149
- def _get_interactive_menu_text() -> str:
150
- """
151
- This method generates the initial interactive menu text.
152
- It produces a welcome statement and iterates through all
153
- potential options for the user.
154
- :return: The welcome menu
155
- :rtype: str
156
- """
157
- menu = f"Welcome to insight-plugin {VERSION}!\n\nWhat would you like to do?\n"
158
-
159
- for num, option in enumerate(_OPTIONS, start=1):
160
- menu += f"{num}. [{option.title}] - {option.description}\n"
161
-
162
- menu += "\nChoose a menu item from above or press any other key to exit: "
163
-
164
- return menu
165
-
166
- @staticmethod
167
- def _get_create_refresh_controller_menu() -> Tuple[str, Union[str, None], bool]:
168
- """
169
- A function to prompt the user to provide a path to the plugin spec
170
- file, target directory & verbose for the create & refresh subcommand.
171
- :return: Tuple containing path to spec file, target directory & verbose boolean.
172
- """
173
-
174
- # Handle path to spec file input
175
- path_to_spec = retrieve_path_input("plugin.spec.yaml")
176
-
177
- # Handle target directory input
178
- target_dir = retrieve_path_input("target directory")
179
-
180
- # Handle verbose input
181
- verbose = retrieve_bool_input("verbose")
182
-
183
- return path_to_spec, target_dir, verbose
184
-
185
- @staticmethod
186
- def _get_validate_controller_menu() -> str:
187
- """
188
- Method to handle inputs for the validate command.
189
- :return: Path to the plugin.spec.yaml file
190
- """
191
-
192
- # Handle path to spec file input
193
- path_to_spec = retrieve_path_input("plugin.spec.yaml")
194
-
195
- return path_to_spec
196
-
197
- @staticmethod
198
- def _get_run_controller_menu() -> Tuple[
199
- str,
200
- Union[str, None],
201
- bool,
202
- bool,
203
- bool,
204
- Optional[str],
205
- ]:
206
- """
207
- Method to handle the run subcommand inputs.
208
- :return: User inputs for verbose, target_dir, assessment, is_test, jq & json_target
209
- """
210
-
211
- # Handle json_files input
212
- json_target = retrieve_path_input("json_files")
213
-
214
- # Handle target directory input
215
- target_dir = retrieve_path_input("target directory")
216
-
217
- # Handle verbose input
218
- verbose = retrieve_bool_input("verbose")
219
-
220
- # Handle assessment input
221
- assessment = retrieve_bool_input("assessment")
222
-
223
- # Handle is_test input
224
- is_test = retrieve_bool_input("is_test")
225
-
226
- # Handle jq input
227
- jq = retrieve_jq_input(switch=retrieve_bool_input("jq"))
228
-
229
- return json_target, target_dir, verbose, assessment, is_test, jq
230
-
231
- @staticmethod
232
- def _get_export_controller_menu() -> Tuple[bool, bool, Union[str, None]]:
233
- """
234
- Method to handle the export subcommand inputs.
235
- :return: User inputs for no_pull, verbose & target directory
236
- """
237
-
238
- # Handle target directory input
239
- target_dir = retrieve_path_input("target directory")
240
-
241
- # Handle verbose input
242
- verbose = retrieve_bool_input("verbose")
243
-
244
- # Handle no pull input
245
- no_pull = retrieve_bool_input("--no-pull")
246
-
247
- return no_pull, verbose, target_dir
@@ -1,227 +0,0 @@
1
- from insight_plugin.features.common.exceptions import InsightException
2
- from typing import Union, Type
3
- from insight_plugin.features.create.controller import CreateController
4
- from insight_plugin.features.validate.controller import ValidateController
5
- from insight_plugin.features.refresh.controller import RefreshController
6
- from insight_plugin.features.run.run_controller import RunController
7
- from insight_plugin.features.export.controller import ExportController
8
-
9
-
10
- ####################
11
- # HELPER FUNCTIONS #
12
- ####################
13
- def retrieve_bool_input(name: str) -> bool:
14
- """
15
- This method returns True or False from a user input.
16
- Y/y = True | N/n = False
17
- :param name: Name for the variable the user is inputting.
18
- :return: True or False
19
- """
20
- input_string = messages_for_inputs(name=name)
21
- bool_input = str(input(input_string).lower().strip())
22
-
23
- if bool_input not in ("y", "n"):
24
- raise InsightException(
25
- message="Invalid input.", troubleshooting="Input must be (y) or (n)"
26
- )
27
-
28
- return bool_input == "y"
29
-
30
-
31
- def messages_for_inputs(name: str) -> str:
32
- """
33
- This method produces different menu options depending on
34
- the input required from the user
35
- :param name: Name of the input
36
- :return: Input string
37
- """
38
- input_string = ""
39
-
40
- if name == "verbose":
41
- input_string = (
42
- "\nWould you like to use (-v) flag for verbose/debugging mode? (y/n)\n"
43
- )
44
- elif name == "assessment":
45
- input_string = (
46
- "\nWould you like to use (-A) flag to generate plugin PR template output for contributions? "
47
- "(y/n)\n"
48
- )
49
- elif name == "is_test":
50
- input_string = (
51
- "\nWould you like to use (-T) flag to run a connection test? (y/n)\n"
52
- )
53
-
54
- elif name == "jq":
55
- input_string = "\nWould you like to use (-j) flag to run the JQ parser? (y/n)\n"
56
-
57
- elif name == "json_files":
58
- input_string = "\nInput the path to the .json test file you would like to run\n"
59
-
60
- elif name == "--no-pull":
61
- input_string = (
62
- "\nWould you like to use the (--no-pull) flag?\nThis flag skips pulling the latest SDK base "
63
- "image during plugin export. (y/n)\n "
64
- )
65
-
66
- elif name in ("target directory", "plugin.spec.yaml"):
67
- input_string = f"\nInput the full path to the {name}.\nPress Enter for your current directory / default.\n"
68
-
69
- return input_string
70
-
71
-
72
- def retrieve_path_input(name: str) -> str:
73
- """
74
- This function manages path inputs and handles empty path inputs accordingly.
75
- :param name: Name of the path input
76
- :return: String containing path to file or directory
77
- """
78
- input_message = messages_for_inputs(name=name)
79
- path = str(input(input_message))
80
-
81
- # Handle empty target_dir input
82
- if name == "target directory":
83
- if path == "":
84
- path = None
85
-
86
- # Handle empty plugin.spec.yaml input
87
- if name == "plugin.spec.yaml":
88
- if path == "":
89
- path = "plugin.spec.yaml"
90
-
91
- # Handle empty json files input
92
- if name == "json_files":
93
- if path == "":
94
- raise InsightException(
95
- message="No path provided.",
96
- troubleshooting="Please provide a path to the JSON test file(s)",
97
- )
98
-
99
- # Handle empty plugin spec yaml input for validate
100
- # For current dir, validate path must be '.'
101
- if name == "validate_plugin_spec":
102
- if path == "":
103
- path = ".."
104
-
105
- return path
106
-
107
-
108
- def retrieve_jq_input(switch: bool) -> Union[str, None]:
109
- """
110
- This function handles JQ input.
111
- :param name: Name of the input
112
- :param switch: Boolean value for whether input is selected or not
113
- :return:
114
- """
115
- DEFAULT_JQ_STRING = ".body.output"
116
- jq = None
117
-
118
- if switch:
119
- jq = str(
120
- input(
121
- f"JQ Parser, Pass no args to use default ({DEFAULT_JQ_STRING}), or pass one used for all test/runs."
122
- )
123
- )
124
-
125
- return jq
126
-
127
-
128
- #######################
129
- # CONTROLLER BUILDERS #
130
- #######################
131
- def create_and_refresh_cli_controller(
132
- controller_name: Type[Union[CreateController, RefreshController]],
133
- path_to_spec: str,
134
- verbose: bool,
135
- target_dir: Union[str, None],
136
- ):
137
- """
138
- This function creates a new controller for the create & refresh subcommands
139
- :param controller_name: Name of the controller
140
- :param path_to_spec: Path to the spec file
141
- :param verbose: Boolean value indicating whether to add --verbose tag
142
- :param target_dir: String or None value containing target directory
143
- :return: Controller with all inputs filled
144
- """
145
- controller = controller_name.new_from_cli(
146
- **{
147
- "spec_path": path_to_spec,
148
- "verbose": verbose,
149
- "target_dir": target_dir,
150
- }
151
- )
152
-
153
- return controller
154
-
155
-
156
- def export_cli_controller(
157
- controller_name: Type[ExportController],
158
- target_dir: Union[str, None],
159
- no_pull: bool,
160
- verbose: bool,
161
- ):
162
- """
163
- This function creates a new controller for the export subcommand
164
- :param controller_name: Name of the controller
165
- :param target_dir: Path to the target directory
166
- :param no_pull: Boolean value indicating whether to add --no-pull tag
167
- :param verbose: Boolean value indicating whether to add --verbose tag
168
- :return: Controller with all inputs filled
169
- """
170
- controller = controller_name.new_from_cli(
171
- **{
172
- "no_pull": no_pull,
173
- "verbose": verbose,
174
- "target_dir": target_dir,
175
- }
176
- )
177
-
178
- return controller
179
-
180
-
181
- def run_cli_controller(
182
- controller_name: Type[RunController],
183
- verbose: bool,
184
- target_dir: Union[str, None],
185
- assessment: bool,
186
- test: bool,
187
- jq: str,
188
- json_files: str,
189
- ):
190
- """
191
- This function creates a new controller for the run subcommand
192
- :param controller_name: Name of the controller
193
- :param verbose: Boolean value indicating whether to add --verbose tag
194
- :param target_dir: Path to the target directory
195
- :param assessment: Boolean value indicating whether to add --assessment tag
196
- :param test: Boolean value indicating whether to add --is_test flag
197
- :param jq:
198
- :param json_files: Path to json files
199
- :return: Controller with all inputs filled
200
- """
201
- controller = controller_name.new_from_cli(
202
- **{
203
- "verbose": verbose,
204
- "target_dir": target_dir,
205
- "assessment": assessment,
206
- "is_test": test,
207
- "jq_": jq,
208
- "json_target": json_files,
209
- }
210
- )
211
-
212
- return controller
213
-
214
-
215
- def validate_cli_controller(
216
- controller_name: Type[ValidateController], path_to_spec: str
217
- ):
218
- """
219
- This function creates a new controller for the run subcommand
220
- :param controller_name: Name of the controller
221
- :param path_to_spec: Path to the plugin.spec.yaml
222
- :return: Controller with all inputs filled
223
- """
224
-
225
- controller = controller_name.new_from_cli(**{"spec_path": path_to_spec})
226
-
227
- return controller