insight-plugin 1.0.8__tar.gz → 1.2.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.
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/PKG-INFO +1 -1
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/__init__.py +1 -1
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/__main__.py +85 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/__pycache__/__init__.cpython-39.pyc +0 -0
- insight_plugin-1.2.0/insight_plugin/constants.py +58 -0
- insight_plugin-1.2.0/insight_plugin/features/analysis/controller.py +63 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/schema_util.py +13 -13
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/template_util.py +3 -3
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/util.py +55 -7
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/export/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/interactive/controller.py +14 -22
- insight_plugin-1.2.0/insight_plugin/features/linter/controller.py +34 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/refresh/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/run/bash_controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/run/run_controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/run/server_controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/samples/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/validate/controller.py +8 -8
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/version/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/view/controller.py +2 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/actions/action/action.py.jinja +8 -2
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/connection/connection.py.jinja +4 -3
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/triggers/trigger/trigger.py.jinja +7 -1
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/PKG-INFO +1 -1
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/SOURCES.txt +4 -0
- insight_plugin-1.2.0/tests/resources/export_test_base64/__init__.py +0 -0
- insight_plugin-1.2.0/tests/resources/export_test_base64/unit_test/__init__.py +0 -0
- insight_plugin-1.0.8/insight_plugin/constants.py +0 -47
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/LICENSE +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/README.md +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/common → insight_plugin-1.2.0/insight_plugin/features/analysis}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/create → insight_plugin-1.2.0/insight_plugin/features/common}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/builder.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/checksum_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/command_line_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/common_feature.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/docker_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/dockerspec.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/exceptions.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/logging_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/plugin_spec_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/temp_file_util.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/create/help → insight_plugin-1.2.0/insight_plugin/features/create}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/export → insight_plugin-1.2.0/insight_plugin/features/create/help}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/help/components.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/help/connection_help.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/help/constants.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/help/help_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/help/input_output_helpers.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/json_generation_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/create/plugin_to_helpmd.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/export/util → insight_plugin-1.2.0/insight_plugin/features/export}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/interactive → insight_plugin-1.2.0/insight_plugin/features/export/util}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/export/util/util.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/interactive/util → insight_plugin-1.2.0/insight_plugin/features/interactive}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/refresh → insight_plugin-1.2.0/insight_plugin/features/interactive/util}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/interactive/util/util.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/run → insight_plugin-1.2.0/insight_plugin/features/linter}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/samples → insight_plugin-1.2.0/insight_plugin/features/refresh}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/samples/util → insight_plugin-1.2.0/insight_plugin/features/run}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/validate → insight_plugin-1.2.0/insight_plugin/features/samples}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/version → insight_plugin-1.2.0/insight_plugin/features/samples/util}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/samples/util/constants.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/samples/util/util.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/version/util → insight_plugin-1.2.0/insight_plugin/features/validate}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/features/view → insight_plugin-1.2.0/insight_plugin/features/version}/__init__.py +0 -0
- {insight_plugin-1.0.8/insight_plugin/templates → insight_plugin-1.2.0/insight_plugin/features/version/util}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/version/util/helpmd_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/version/util/input_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/version/util/version_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/version/util/yaml_util.py +0 -0
- {insight_plugin-1.0.8/tests/resources → insight_plugin-1.2.0/insight_plugin/features/view}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/.dockerignore.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/Dockerfile.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/Makefile.jinja +0 -0
- {insight_plugin-1.0.8/tests/resources/export_test_base64 → insight_plugin-1.2.0/insight_plugin/templates}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/assessment/assessment.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/bin/plugin.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/actions/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/actions/action/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/actions/action/schema.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/connection/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/connection/schema.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/tasks/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/tasks/task/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/tasks/task/schema.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/tasks/task/task.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/triggers/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/triggers/trigger/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/triggers/trigger/schema.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/plugin/util/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/requirements.txt.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/setup.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/unit_test/__init__.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/templates/unit_test/test_action.py.jinja +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/dependency_links.txt +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/entry_points.txt +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/requires.txt +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin.egg-info/top_level.txt +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/pyproject.toml +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/setup.cfg +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/setup.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/__init__.py +0 -0
- {insight_plugin-1.0.8/tests/resources/export_test_base64/unit_test → insight_plugin-1.2.0/tests/resources}/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/decode/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/decode/action.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/decode/schema.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/encode/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/encode/action.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/actions/encode/schema.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/connection/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/connection/connection.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/connection/schema.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/triggers/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/komand_base64/util/__init__.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/setup.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/resources/export_test_base64/unit_test/test_encode.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_checksum.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_create.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_export.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_gen_samples.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_help_creation.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_interactive.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_json_generate.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_refresh.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_run.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_schema.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_semver.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_spec_order.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_temp_file_util.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/test_validate.py +0 -0
- {insight_plugin-1.0.8 → insight_plugin-1.2.0}/tests/util.py +0 -0
|
@@ -6,9 +6,11 @@ from argparse import Namespace
|
|
|
6
6
|
|
|
7
7
|
from insight_plugin import VERSION
|
|
8
8
|
|
|
9
|
+
from insight_plugin.features.analysis.controller import AnalysisController
|
|
9
10
|
from insight_plugin.features.create.controller import CreateController
|
|
10
11
|
from insight_plugin.features.samples.controller import GenSampleController
|
|
11
12
|
from insight_plugin.features.export.controller import ExportController
|
|
13
|
+
from insight_plugin.features.linter.controller import LinterController
|
|
12
14
|
from insight_plugin.features.refresh.controller import RefreshController
|
|
13
15
|
from insight_plugin.features.run.run_controller import RunController
|
|
14
16
|
from insight_plugin.features.validate.controller import ValidateController
|
|
@@ -19,6 +21,7 @@ from insight_plugin.features.common.exceptions import InsightException
|
|
|
19
21
|
from insight_plugin.features.version.controller import VersionController
|
|
20
22
|
from insight_plugin.features.view.controller import ViewController
|
|
21
23
|
from typing import List
|
|
24
|
+
from insight_plugin.constants import Color
|
|
22
25
|
|
|
23
26
|
DEFAULT_JQ_STRING = ".body.output"
|
|
24
27
|
|
|
@@ -33,10 +36,16 @@ def main():
|
|
|
33
36
|
subparsers = argparser.add_subparsers(help="Commands")
|
|
34
37
|
parsers_list = []
|
|
35
38
|
|
|
39
|
+
# Analysis
|
|
40
|
+
analysis_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
41
|
+
# Checks
|
|
42
|
+
checks_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
36
43
|
# Create
|
|
37
44
|
create_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
38
45
|
# Export
|
|
39
46
|
export_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
47
|
+
# Linter
|
|
48
|
+
linter_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
40
49
|
# Refresh
|
|
41
50
|
refresh_argparse(subparsers=subparsers, parsers_list=parsers_list)
|
|
42
51
|
# Validate
|
|
@@ -507,8 +516,8 @@ def validate(args: Namespace) -> None:
|
|
|
507
516
|
:param args: CLI args
|
|
508
517
|
:return: None
|
|
509
518
|
"""
|
|
510
|
-
controller = ValidateController.new_from_cli(**{"
|
|
511
|
-
controller.
|
|
519
|
+
controller = ValidateController.new_from_cli(**{"target_dir": args.target_dir})
|
|
520
|
+
controller.run()
|
|
512
521
|
|
|
513
522
|
|
|
514
523
|
def view_argparse(subparsers, parsers_list: List) -> None:
|
|
@@ -538,5 +547,79 @@ def view(args: Namespace) -> None:
|
|
|
538
547
|
controller.run()
|
|
539
548
|
|
|
540
549
|
|
|
550
|
+
def linter_argparse(subparsers, parsers_list: List) -> None:
|
|
551
|
+
"""
|
|
552
|
+
Handle the arg-parsing for the linter subcommand
|
|
553
|
+
:param subparsers: List to be filled with commands
|
|
554
|
+
:param parsers_list: List to be appended with parsed commands
|
|
555
|
+
:return: None
|
|
556
|
+
"""
|
|
557
|
+
command_view = subparsers.add_parser("linter", help=LinterController.HELP_MSG)
|
|
558
|
+
parsers_list.append(command_view)
|
|
559
|
+
command_view.set_defaults(func=linter)
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
def linter(args: Namespace) -> None:
|
|
563
|
+
"""
|
|
564
|
+
Run the linter
|
|
565
|
+
"""
|
|
566
|
+
controller = LinterController.new_from_cli(**{"target_dir": args.target_dir})
|
|
567
|
+
controller.run()
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
def analysis_argparse(subparsers, parsers_list: List) -> None:
|
|
571
|
+
"""
|
|
572
|
+
Handle the arg-parsing for the analysis subcommand
|
|
573
|
+
:param subparsers: List to be filled with commands
|
|
574
|
+
:param parsers_list: List to be appended with parsed commands
|
|
575
|
+
:return: None
|
|
576
|
+
"""
|
|
577
|
+
command_view = subparsers.add_parser("analysis", help=AnalysisController.HELP_MSG)
|
|
578
|
+
parsers_list.append(command_view)
|
|
579
|
+
command_view.set_defaults(func=analysis)
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def analysis(args: Namespace) -> None:
|
|
583
|
+
"""
|
|
584
|
+
Run Static Code Analysis
|
|
585
|
+
"""
|
|
586
|
+
controller = AnalysisController.new_from_cli(**{"target_dir": args.target_dir})
|
|
587
|
+
controller.run()
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
def checks_argparse(subparsers, parsers_list: List) -> None:
|
|
591
|
+
"""
|
|
592
|
+
Handle the arg-parsing for the checks subcommand
|
|
593
|
+
:param subparsers: List to be filled with commands
|
|
594
|
+
:param parsers_list: List to be appended with parsed commands
|
|
595
|
+
:return: None
|
|
596
|
+
"""
|
|
597
|
+
command_view = subparsers.add_parser(
|
|
598
|
+
"checks", help="Run Linter, code analysis & validate on the plugin"
|
|
599
|
+
)
|
|
600
|
+
parsers_list.append(command_view)
|
|
601
|
+
command_view.set_defaults(func=checks)
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def checks(args: Namespace) -> None:
|
|
605
|
+
"""
|
|
606
|
+
Run Linter, SCA & Validate
|
|
607
|
+
"""
|
|
608
|
+
analysis_controller = AnalysisController.new_from_cli(
|
|
609
|
+
**{"target_dir": args.target_dir}
|
|
610
|
+
)
|
|
611
|
+
linter_controller = LinterController.new_from_cli(**{"target_dir": args.target_dir})
|
|
612
|
+
validate_controller = ValidateController.new_from_cli(
|
|
613
|
+
**{"target_dir": args.target_dir}
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
print(Color.BOLD + "\nAnalysis \n" + Color.END)
|
|
617
|
+
analysis_controller.run()
|
|
618
|
+
print(Color.BOLD + "\nLinter\n" + Color.END)
|
|
619
|
+
linter_controller.run()
|
|
620
|
+
print(Color.BOLD + "\nValidate\n" + Color.END)
|
|
621
|
+
validate_controller.run()
|
|
622
|
+
|
|
623
|
+
|
|
541
624
|
if __name__ == "__main__":
|
|
542
625
|
main()
|
{insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/__pycache__/__init__.cpython-39.pyc
RENAMED
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
class SubcommandDescriptions:
|
|
2
|
+
ANALYSIS_DESCRIPTION = "Run static code analysis on the plugin"
|
|
3
|
+
CHECKS_DESCRIPTION = "Run Linter, code analysis & validate on the plugin"
|
|
4
|
+
LINTER_DESCRIPTION = "Run the 'black' linter on the plugin"
|
|
5
|
+
CREATE_DESCRIPTION = (
|
|
6
|
+
"Create a new plugin."
|
|
7
|
+
+ " This command will generate the skeleton folder structure and "
|
|
8
|
+
"code for a new plugin, based on the provided plugin.spec.yaml file"
|
|
9
|
+
)
|
|
10
|
+
SERVER_DESCRIPTION = (
|
|
11
|
+
"Run the plugin in HTTP mode."
|
|
12
|
+
+ " This allows an external API testing program to be "
|
|
13
|
+
"used to test a plugin "
|
|
14
|
+
)
|
|
15
|
+
SAMPLES_DESCRIPTION = (
|
|
16
|
+
"Create test samples for actions and triggers."
|
|
17
|
+
+ " This command will create new files under the 'tests' folder "
|
|
18
|
+
"which can be used to test each new action/trigger. "
|
|
19
|
+
"Note if a file already exists for a particular action/trigger, it will not be overwritten"
|
|
20
|
+
)
|
|
21
|
+
REFRESH_DESCRIPTION = (
|
|
22
|
+
"Refresh the plugin."
|
|
23
|
+
+ " This command will update the current plugin code, when updates are made in the "
|
|
24
|
+
"plugin.spec.yaml file"
|
|
25
|
+
)
|
|
26
|
+
RUN_DESCRIPTION = (
|
|
27
|
+
"Run an action/trigger from a json test file"
|
|
28
|
+
+ " (created during sample generation)"
|
|
29
|
+
)
|
|
30
|
+
SHELL_DESCRIPTION = (
|
|
31
|
+
"Run the plugin via the docker shell" + " to enable advanced debugging"
|
|
32
|
+
)
|
|
33
|
+
EXPORT_DESCRIPTION = (
|
|
34
|
+
"Export a plugin Docker image to a tarball."
|
|
35
|
+
+ " This tarball can be uploaded as a custom plugin via the import "
|
|
36
|
+
"functionality in the InsightConnect UI"
|
|
37
|
+
)
|
|
38
|
+
VALIDATE_DESCRIPTION = (
|
|
39
|
+
"Validate / Run checks against the plugin."
|
|
40
|
+
+ " This command performs quality control checks on the current "
|
|
41
|
+
"state of the plugin. This should be run before finalizing any new updates"
|
|
42
|
+
)
|
|
43
|
+
VERSION_DESCRIPTION = (
|
|
44
|
+
"Update the plugin versioning."
|
|
45
|
+
+ " This command should be run after finalizing any updates, defect fixes or "
|
|
46
|
+
"new functionality, to update the versioning"
|
|
47
|
+
)
|
|
48
|
+
VIEW_DESCRIPTION = (
|
|
49
|
+
"View plugin docker container info" + "Provides an overview of the plugin"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
VALID_IGNORE_FILES = ["help.md", "dockerfile", "unit_test"]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Color:
|
|
57
|
+
BOLD = "\033[1m"
|
|
58
|
+
END = "\033[0m"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from insight_plugin.features.common.common_feature import CommonFeature
|
|
2
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
3
|
+
import os
|
|
4
|
+
from shutil import which
|
|
5
|
+
from typing import Union
|
|
6
|
+
|
|
7
|
+
DEFAULT_PROFILE = (
|
|
8
|
+
"prospector --profile --tool bandit --tool mccabe --tool pylint --tool pyflakes"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AnalysisController(CommonFeature):
|
|
13
|
+
HELP_MSG = SubcommandDescriptions.ANALYSIS_DESCRIPTION
|
|
14
|
+
|
|
15
|
+
def __init__(self, verbose: bool, target_dir: str):
|
|
16
|
+
super().__init__(verbose=verbose, target_dir=target_dir)
|
|
17
|
+
self._verbose = verbose
|
|
18
|
+
self._target_dir = target_dir
|
|
19
|
+
self.default_profile = (
|
|
20
|
+
"prospector --tool bandit --tool mccabe --tool pylint --tool pyflakes"
|
|
21
|
+
)
|
|
22
|
+
self.current_dir = os.path.abspath(self.target_dir)
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def new_from_cli(cls, **kwargs):
|
|
26
|
+
super().new_from_cli(
|
|
27
|
+
**{
|
|
28
|
+
"verbose": kwargs.get("verbose"),
|
|
29
|
+
"target_dir": kwargs.get("target_dir"),
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
return cls(
|
|
33
|
+
kwargs.get("verbose"),
|
|
34
|
+
kwargs.get("target_dir"),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def run(self) -> Union[None, int]:
|
|
38
|
+
if which("prospector") is None:
|
|
39
|
+
print("Prospector is not installed.\nInstall via 'pip install prospector'")
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
# If its an official plugins repo
|
|
43
|
+
if "plugins" in self.current_dir:
|
|
44
|
+
self.run_prospector(
|
|
45
|
+
self.current_dir.split("/plugins")[0] + "/prospector.yaml"
|
|
46
|
+
)
|
|
47
|
+
else:
|
|
48
|
+
# If not in any plugins repo, run default prospector (no profile)
|
|
49
|
+
return self.run_prospector()
|
|
50
|
+
|
|
51
|
+
def run_prospector(self, prospector_path: str = None) -> int:
|
|
52
|
+
"""
|
|
53
|
+
Helper method to generate the os.system run command depending on prospector used.
|
|
54
|
+
|
|
55
|
+
:param prospector_path: Path to the prospector.yaml file
|
|
56
|
+
"""
|
|
57
|
+
if prospector_path:
|
|
58
|
+
return os.system( # nosec
|
|
59
|
+
f"prospector --profile {prospector_path} {self.target_dir} --tool bandit --tool "
|
|
60
|
+
f"mccabe --tool pylint --tool pyflakes "
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
return os.system(self.default_profile) # nosec
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Tuple, Dict, Union,
|
|
1
|
+
from typing import Tuple, Dict, Union, Any
|
|
2
2
|
from insight_plugin.features.common.plugin_spec_util import PluginSpecConstants
|
|
3
3
|
from insight_plugin.features.common.exceptions import InsightException
|
|
4
4
|
from insight_plugin.features.common.logging_util import BaseLoggingFeature
|
|
@@ -287,9 +287,9 @@ class SchemaUtil:
|
|
|
287
287
|
# Primitive type definitions are only either strings or dicts.
|
|
288
288
|
if isinstance(SchemaUtil.PRIMITIVE_TYPES[current_type], str):
|
|
289
289
|
# If this type definition is a string, we simply assign the value to the type property.
|
|
290
|
-
parent_object[key][
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
parent_object[key][PluginSpecConstants.TYPE] = (
|
|
291
|
+
SchemaUtil.PRIMITIVE_TYPES[current_type]
|
|
292
|
+
)
|
|
293
293
|
# This parameter's primitive type is one defined as a dict object with multiple properties.
|
|
294
294
|
elif isinstance(SchemaUtil.PRIMITIVE_TYPES[current_type], dict):
|
|
295
295
|
# Add each property of this primitive type's dict definition to the current parameter schema.
|
|
@@ -358,9 +358,9 @@ class SchemaUtil:
|
|
|
358
358
|
# Is this an array of strings?
|
|
359
359
|
if isinstance(SchemaUtil.PRIMITIVE_TYPES[final_type], str):
|
|
360
360
|
# Set this array's items: type value to string.
|
|
361
|
-
current_item[
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
current_item[PluginSpecConstants.TYPE] = (
|
|
362
|
+
SchemaUtil.PRIMITIVE_TYPES[final_type]
|
|
363
|
+
)
|
|
364
364
|
# Is this an array of dict objects?
|
|
365
365
|
elif isinstance(SchemaUtil.PRIMITIVE_TYPES[final_type], dict):
|
|
366
366
|
for primitive_key in SchemaUtil.PRIMITIVE_TYPES[final_type]:
|
|
@@ -370,9 +370,9 @@ class SchemaUtil:
|
|
|
370
370
|
# Is this parameter an array of a base type?
|
|
371
371
|
elif final_type in SchemaUtil.BASE_TYPES:
|
|
372
372
|
# Non-primitive types use $ref instead of type, here we set the definition reference.
|
|
373
|
-
current_item[
|
|
374
|
-
SchemaConstants.
|
|
375
|
-
|
|
373
|
+
current_item[SchemaConstants.REF] = (
|
|
374
|
+
f"{SchemaConstants.REF_DEF}{final_type}"
|
|
375
|
+
)
|
|
376
376
|
# Non-primitive types must be defined in the schema, here we get this base type definition.
|
|
377
377
|
if final_type not in definitions:
|
|
378
378
|
definitions[final_type] = SchemaUtil.BASE_TYPES[final_type]
|
|
@@ -382,9 +382,9 @@ class SchemaUtil:
|
|
|
382
382
|
and final_type in spec[PluginSpecConstants.TYPES]
|
|
383
383
|
):
|
|
384
384
|
# Non-primitive types use $ref instead of type, here we set the definition reference.
|
|
385
|
-
current_item[
|
|
386
|
-
SchemaConstants.
|
|
387
|
-
|
|
385
|
+
current_item[SchemaConstants.REF] = (
|
|
386
|
+
f"{SchemaConstants.REF_DEF}{final_type}"
|
|
387
|
+
)
|
|
388
388
|
# Have we not yet added this custom type definition to the schema?
|
|
389
389
|
if final_type not in definitions:
|
|
390
390
|
# We have not yet defined this custom type, prepare to recurse.
|
{insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/common/template_util.py
RENAMED
|
@@ -40,9 +40,9 @@ class Templates:
|
|
|
40
40
|
self._env.globals["upper_camel_case"] = Templates.upper_camel_case
|
|
41
41
|
self._env.globals["json_schema_connection"] = self.json_schema_connection
|
|
42
42
|
self._env.globals["json_schema_trigger_input"] = self.json_schema_trigger_input
|
|
43
|
-
self._env.globals[
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
self._env.globals["json_schema_trigger_output"] = (
|
|
44
|
+
self.json_schema_trigger_output
|
|
45
|
+
)
|
|
46
46
|
self._env.globals["json_schema_action_input"] = self.json_schema_action_input
|
|
47
47
|
self._env.globals["json_schema_action_output"] = self.json_schema_action_output
|
|
48
48
|
self._env.globals["json_schema_task_input"] = self.json_schema_task_input
|
|
@@ -11,7 +11,7 @@ from insight_plugin.features.common.template_util import Templates
|
|
|
11
11
|
from insight_plugin.features.common.temp_file_util import SafeTempDirectory
|
|
12
12
|
from insight_plugin.features.common.exceptions import InsightException
|
|
13
13
|
from insight_plugin.features.create import util
|
|
14
|
-
from insight_plugin.constants import
|
|
14
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class CreateController(CommonFeature):
|
|
@@ -20,7 +20,7 @@ class CreateController(CommonFeature):
|
|
|
20
20
|
Depends on plugin spec dictionary values to fill templates.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
HELP_MSG = CREATE_DESCRIPTION
|
|
23
|
+
HELP_MSG = SubcommandDescriptions.CREATE_DESCRIPTION
|
|
24
24
|
|
|
25
25
|
def __init__(self, spec_path: Optional[str], verbose: bool, target_dir: str):
|
|
26
26
|
super().__init__(verbose, target_dir)
|
|
@@ -3,6 +3,7 @@ from os.path import exists
|
|
|
3
3
|
from typing import List, Dict, Optional
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
+
|
|
6
7
|
from insight_plugin import (
|
|
7
8
|
ROOT_DIR,
|
|
8
9
|
FILE_ENCODING,
|
|
@@ -20,7 +21,6 @@ from insight_plugin.features.common.exceptions import InsightException
|
|
|
20
21
|
from insight_plugin.features.create.plugin_to_helpmd import ConvertPluginToHelp
|
|
21
22
|
from insight_plugin.features.common.template_util import Templates
|
|
22
23
|
from insight_plugin.constants import VALID_IGNORE_FILES
|
|
23
|
-
import shutil
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def create_checksum(spec: PluginSpecTypes.Spec, target_dir_name: str):
|
|
@@ -312,7 +312,10 @@ def create_trigger_init(trigger_name: str, trigger_dir_name: str):
|
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
def create_trigger_py(
|
|
315
|
-
|
|
315
|
+
spec: PluginSpecTypes.Spec,
|
|
316
|
+
trigger_name: str,
|
|
317
|
+
trigger_description: str,
|
|
318
|
+
trigger_dir_name: str,
|
|
316
319
|
):
|
|
317
320
|
"""
|
|
318
321
|
Creates the trigger.py for a plugin trigger.
|
|
@@ -322,6 +325,20 @@ def create_trigger_py(
|
|
|
322
325
|
:return:
|
|
323
326
|
"""
|
|
324
327
|
output_file = os.path.join(trigger_dir_name, "trigger.py")
|
|
328
|
+
|
|
329
|
+
trigger_spec_input = (
|
|
330
|
+
spec.get(Constants.TRIGGERS, {}).get(trigger_name, "").get(Constants.INPUT)
|
|
331
|
+
)
|
|
332
|
+
trigger_spec_output = (
|
|
333
|
+
spec.get(Constants.TRIGGERS, {}).get(trigger_name, "").get(Constants.OUTPUT)
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
if trigger_spec_input is None:
|
|
337
|
+
trigger_spec_input = {}
|
|
338
|
+
|
|
339
|
+
if trigger_spec_output is None:
|
|
340
|
+
trigger_spec_output = {}
|
|
341
|
+
|
|
325
342
|
if not exists(output_file):
|
|
326
343
|
create_file_from_template(
|
|
327
344
|
template_filename="plugin/triggers/trigger/trigger.py.jinja",
|
|
@@ -329,6 +346,8 @@ def create_trigger_py(
|
|
|
329
346
|
"base_module": BASE_MODULE,
|
|
330
347
|
"trigger": trigger_name,
|
|
331
348
|
"description": trigger_description,
|
|
349
|
+
"inputs": trigger_spec_input,
|
|
350
|
+
"outputs": trigger_spec_output,
|
|
332
351
|
},
|
|
333
352
|
output_filename=output_file,
|
|
334
353
|
)
|
|
@@ -380,6 +399,7 @@ def create_triggers(spec: PluginSpecTypes.Spec, triggers_dir_name: str):
|
|
|
380
399
|
# Create __init__.py, trigger.py, and schema.py under each trigger directory
|
|
381
400
|
create_trigger_init(trigger_name, trigger_dir_name)
|
|
382
401
|
create_trigger_py(
|
|
402
|
+
spec,
|
|
383
403
|
trigger_name,
|
|
384
404
|
spec.get(Constants.TRIGGERS, {})
|
|
385
405
|
.get(trigger_name, {})
|
|
@@ -403,17 +423,23 @@ def create_connection_init(connection_dir_name: str):
|
|
|
403
423
|
)
|
|
404
424
|
|
|
405
425
|
|
|
406
|
-
def create_connection_py(connection_dir_name: str):
|
|
426
|
+
def create_connection_py(spec: PluginSpecTypes.Spec, connection_dir_name: str):
|
|
407
427
|
"""
|
|
408
428
|
Creates the connection.py for the plugin connection.
|
|
429
|
+
:param spec: The plugin spec dictionary
|
|
409
430
|
:param connection_dir_name: The absolute path to the icon_{plugin}/connection directory
|
|
410
431
|
:return:
|
|
411
432
|
"""
|
|
412
433
|
output_file = os.path.join(connection_dir_name, "connection.py")
|
|
434
|
+
connection_spec = spec.get(Constants.CONNECTIONS, {})
|
|
435
|
+
|
|
436
|
+
if connection_spec is None:
|
|
437
|
+
connection_spec = {}
|
|
438
|
+
|
|
413
439
|
if not exists(output_file):
|
|
414
440
|
create_file_from_template(
|
|
415
441
|
template_filename="plugin/connection/connection.py.jinja",
|
|
416
|
-
inputs={"base_module": BASE_MODULE},
|
|
442
|
+
inputs={"base_module": BASE_MODULE, "inputs": connection_spec},
|
|
417
443
|
output_filename=output_file,
|
|
418
444
|
)
|
|
419
445
|
|
|
@@ -453,7 +479,7 @@ def create_connection(spec: PluginSpecTypes.Spec, connection_dir_name: str):
|
|
|
453
479
|
create_directory(connection_dir_name)
|
|
454
480
|
# Create __init__.py, connection.py, and schema.py under the new connection directory
|
|
455
481
|
create_connection_init(connection_dir_name)
|
|
456
|
-
create_connection_py(connection_dir_name)
|
|
482
|
+
create_connection_py(spec, connection_dir_name)
|
|
457
483
|
create_connection_schema(spec, connection_dir_name)
|
|
458
484
|
logger.info("Created connection")
|
|
459
485
|
|
|
@@ -488,15 +514,35 @@ def create_action_init(action_name: str, action_dir_name: str):
|
|
|
488
514
|
)
|
|
489
515
|
|
|
490
516
|
|
|
491
|
-
def create_action_py(
|
|
517
|
+
def create_action_py(
|
|
518
|
+
spec: PluginSpecTypes.Spec,
|
|
519
|
+
action_name: str,
|
|
520
|
+
action_description: str,
|
|
521
|
+
action_dir_name: str,
|
|
522
|
+
):
|
|
492
523
|
"""
|
|
493
524
|
Creates the action.py for a plugin action.
|
|
525
|
+
:param spec: The plugin spec dictionary
|
|
494
526
|
:param action_name: The name of this current action
|
|
495
527
|
:param action_description: The description of this current action
|
|
496
528
|
:param action_dir_name: The absolute path to the icon_{plugin}/actions/{action} directory
|
|
497
529
|
:return:
|
|
498
530
|
"""
|
|
499
531
|
output_file = os.path.join(action_dir_name, "action.py")
|
|
532
|
+
|
|
533
|
+
action_spec_input = (
|
|
534
|
+
spec.get(Constants.ACTIONS, {}).get(action_name, "").get(Constants.INPUT)
|
|
535
|
+
)
|
|
536
|
+
action_spec_output = (
|
|
537
|
+
spec.get(Constants.ACTIONS, {}).get(action_name, "").get(Constants.OUTPUT)
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
if action_spec_input is None:
|
|
541
|
+
action_spec_input = {}
|
|
542
|
+
|
|
543
|
+
if action_spec_output is None:
|
|
544
|
+
action_spec_output = {}
|
|
545
|
+
|
|
500
546
|
if not exists(output_file):
|
|
501
547
|
create_file_from_template(
|
|
502
548
|
template_filename="plugin/actions/action/action.py.jinja",
|
|
@@ -504,6 +550,8 @@ def create_action_py(action_name: str, action_description: str, action_dir_name:
|
|
|
504
550
|
"base_module": BASE_MODULE,
|
|
505
551
|
"action": action_name,
|
|
506
552
|
"description": action_description,
|
|
553
|
+
"inputs": action_spec_input,
|
|
554
|
+
"outputs": action_spec_output,
|
|
507
555
|
},
|
|
508
556
|
output_filename=output_file,
|
|
509
557
|
)
|
|
@@ -554,6 +602,7 @@ def create_actions(spec: PluginSpecTypes.Spec, actions_dir_name: str):
|
|
|
554
602
|
# Create __init__.py, action.py, and schema.py under each action directory
|
|
555
603
|
create_action_init(action_name, action_dir_name)
|
|
556
604
|
create_action_py(
|
|
605
|
+
spec,
|
|
557
606
|
action_name,
|
|
558
607
|
spec.get(Constants.ACTIONS, {})
|
|
559
608
|
.get(action_name, {})
|
|
@@ -784,7 +833,6 @@ def create_files_refresh(
|
|
|
784
833
|
:param spec: The plugin spec dictionary
|
|
785
834
|
:param dir_name: The absolute path to the target
|
|
786
835
|
:param prefix: The prefix, either icon or komand
|
|
787
|
-
:param is_create: Boolean to indicate create or refresh
|
|
788
836
|
:param ignore: List containing files to not overwrite/refresh
|
|
789
837
|
:return:
|
|
790
838
|
"""
|
|
@@ -7,7 +7,7 @@ from insight_plugin.features.common.common_feature import CommonFeature
|
|
|
7
7
|
from insight_plugin.features.common.command_line_util import CommandLineUtil
|
|
8
8
|
from insight_plugin.features.common.temp_file_util import SafeTempDirectory
|
|
9
9
|
from insight_plugin.features.common.exceptions import InsightException
|
|
10
|
-
from insight_plugin.constants import
|
|
10
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ExportController(CommonFeature):
|
|
@@ -16,7 +16,7 @@ class ExportController(CommonFeature):
|
|
|
16
16
|
Allows the user to export the plugin image to a tarball
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
HELP_MSG = EXPORT_DESCRIPTION
|
|
19
|
+
HELP_MSG = SubcommandDescriptions.EXPORT_DESCRIPTION
|
|
20
20
|
|
|
21
21
|
def __init__(
|
|
22
22
|
self,
|
{insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/interactive/controller.py
RENAMED
|
@@ -6,13 +6,7 @@ from insight_plugin.features.refresh.controller import RefreshController
|
|
|
6
6
|
from insight_plugin.features.run.run_controller import RunController
|
|
7
7
|
from insight_plugin.features.export.controller import ExportController
|
|
8
8
|
from typing import Tuple, Optional, Union
|
|
9
|
-
from insight_plugin.constants import
|
|
10
|
-
CREATE_DESCRIPTION,
|
|
11
|
-
REFRESH_DESCRIPTION,
|
|
12
|
-
RUN_DESCRIPTION,
|
|
13
|
-
EXPORT_DESCRIPTION,
|
|
14
|
-
VALIDATE_DESCRIPTION,
|
|
15
|
-
)
|
|
9
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
16
10
|
from insight_plugin.features.interactive.util.util import (
|
|
17
11
|
retrieve_bool_input,
|
|
18
12
|
retrieve_path_input,
|
|
@@ -33,15 +27,15 @@ class _Option(object):
|
|
|
33
27
|
# TODO: Make this dynamic instead of hardcoded
|
|
34
28
|
_OPTIONS = [
|
|
35
29
|
# 1
|
|
36
|
-
_Option(title="Create", description=CREATE_DESCRIPTION),
|
|
30
|
+
_Option(title="Create", description=SubcommandDescriptions.CREATE_DESCRIPTION),
|
|
37
31
|
# 2
|
|
38
|
-
_Option(title="Refresh", description=REFRESH_DESCRIPTION),
|
|
32
|
+
_Option(title="Refresh", description=SubcommandDescriptions.REFRESH_DESCRIPTION),
|
|
39
33
|
# 3
|
|
40
|
-
_Option(title="Run", description=RUN_DESCRIPTION),
|
|
34
|
+
_Option(title="Run", description=SubcommandDescriptions.RUN_DESCRIPTION),
|
|
41
35
|
# 4
|
|
42
|
-
_Option(title="Validate", description=VALIDATE_DESCRIPTION),
|
|
36
|
+
_Option(title="Validate", description=SubcommandDescriptions.VALIDATE_DESCRIPTION),
|
|
43
37
|
# 5
|
|
44
|
-
_Option(title="Export", description=EXPORT_DESCRIPTION),
|
|
38
|
+
_Option(title="Export", description=SubcommandDescriptions.EXPORT_DESCRIPTION),
|
|
45
39
|
]
|
|
46
40
|
|
|
47
41
|
|
|
@@ -201,16 +195,14 @@ class InteractiveController(object):
|
|
|
201
195
|
return path_to_spec
|
|
202
196
|
|
|
203
197
|
@staticmethod
|
|
204
|
-
def _get_run_controller_menu() ->
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
]
|
|
213
|
-
):
|
|
198
|
+
def _get_run_controller_menu() -> Tuple[
|
|
199
|
+
str,
|
|
200
|
+
Union[str, None],
|
|
201
|
+
bool,
|
|
202
|
+
bool,
|
|
203
|
+
bool,
|
|
204
|
+
Optional[str],
|
|
205
|
+
]:
|
|
214
206
|
"""
|
|
215
207
|
Method to handle the run subcommand inputs.
|
|
216
208
|
:return: User inputs for verbose, target_dir, assessment, is_test, jq & json_target
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from insight_plugin.features.common.common_feature import CommonFeature
|
|
2
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
3
|
+
import os
|
|
4
|
+
from shutil import which
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LinterController(CommonFeature):
|
|
8
|
+
HELP_MSG = SubcommandDescriptions.LINTER_DESCRIPTION
|
|
9
|
+
|
|
10
|
+
def __init__(self, verbose: bool, target_dir: str):
|
|
11
|
+
super().__init__(verbose=verbose, target_dir=target_dir)
|
|
12
|
+
self._verbose = verbose
|
|
13
|
+
self._target_dir = target_dir
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def new_from_cli(cls, **kwargs):
|
|
17
|
+
super().new_from_cli(
|
|
18
|
+
**{
|
|
19
|
+
"verbose": kwargs.get("verbose"),
|
|
20
|
+
"target_dir": kwargs.get("target_dir"),
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
return cls(
|
|
24
|
+
kwargs.get("verbose"),
|
|
25
|
+
kwargs.get("target_dir"),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def run(self) -> int:
|
|
29
|
+
if which("black") is None:
|
|
30
|
+
print("Black is not installed.\nInstall via 'pip install black'")
|
|
31
|
+
else:
|
|
32
|
+
return os.system( # nosec
|
|
33
|
+
f"black {self.target_dir} --check --force-exclude venv/"
|
|
34
|
+
)
|
|
@@ -9,7 +9,7 @@ from insight_plugin.features.common.common_feature import CommonFeature
|
|
|
9
9
|
from insight_plugin.features.common.template_util import Templates
|
|
10
10
|
from insight_plugin.features.common.exceptions import InsightException
|
|
11
11
|
from insight_plugin.features.create import util
|
|
12
|
-
from insight_plugin.constants import
|
|
12
|
+
from insight_plugin.constants import SubcommandDescriptions, VALID_IGNORE_FILES
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class RefreshController(CommonFeature):
|
|
@@ -18,7 +18,7 @@ class RefreshController(CommonFeature):
|
|
|
18
18
|
Depends on plugin spec dictionary values to fill templates.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
HELP_MSG = REFRESH_DESCRIPTION
|
|
21
|
+
HELP_MSG = SubcommandDescriptions.REFRESH_DESCRIPTION
|
|
22
22
|
|
|
23
23
|
def __init__(
|
|
24
24
|
self, spec_path: Optional[str], verbose: bool, target_dir: str, ignore: list
|
{insight_plugin-1.0.8 → insight_plugin-1.2.0}/insight_plugin/features/run/bash_controller.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from insight_plugin.features.common.common_feature import CommonFeature
|
|
2
|
-
from insight_plugin.constants import
|
|
2
|
+
from insight_plugin.constants import SubcommandDescriptions
|
|
3
3
|
from insight_plugin.features.common.docker_util import DockerUtil
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ class RunShellController(CommonFeature):
|
|
|
9
9
|
Allows the user to run the plugin via the docker shell
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
HELP_MSG = SHELL_DESCRIPTION
|
|
12
|
+
HELP_MSG = SubcommandDescriptions.SHELL_DESCRIPTION
|
|
13
13
|
|
|
14
14
|
def __init__(
|
|
15
15
|
self,
|