-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RuntimeValidator - 16777 - Added SDK version validation (#185)
- Loading branch information
1 parent
c6478f6
commit 1e683b3
Showing
32 changed files
with
896 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEFAULT_TIMEOUT = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/.CHECKSUM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"spec": "7b971f1ccf8214be1b140fe212ade68d", | ||
"manifest": "c4fe1b5757c0fbf72a28679cc6303e30", | ||
"setup": "9d01465bd990dde0f93e26a9fbda8a33", | ||
"schemas": [ | ||
{ | ||
"identifier": "decode/schema.py", | ||
"hash": "e8816b23112cbb301c9255c29323c4a8" | ||
}, | ||
{ | ||
"identifier": "encode/schema.py", | ||
"hash": "70afbd79bd72035de62b32983ee57ba3" | ||
}, | ||
{ | ||
"identifier": "connection/schema.py", | ||
"hash": "da5382221ca2a33a2f854e17b068d502" | ||
}, | ||
{ | ||
"identifier": "test_task/schema.py", | ||
"hash": "930a8c07873126927dbcaf6d8e5226fa" | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
unit_test/**/* | ||
unit_test | ||
examples/**/* | ||
examples | ||
tests | ||
tests/**/* | ||
**/*.json | ||
**/*.tar | ||
**/*.gz |
21 changes: 21 additions & 0 deletions
21
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM rapid7/insightconnect-python-3-plugin:4 | ||
LABEL organization=komand | ||
LABEL sdk=python | ||
LABEL type=plugin | ||
|
||
ENV SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt | ||
ENV SSL_CERT_DIR /etc/ssl/certs | ||
ENV REQUESTS_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt | ||
|
||
ADD ./plugin.spec.yaml /plugin.spec.yaml | ||
ADD . /python/src | ||
|
||
WORKDIR /python/src | ||
# Add any package dependencies here | ||
|
||
# End package dependencies | ||
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
RUN python setup.py build && python setup.py install | ||
|
||
|
||
ENTRYPOINT ["/usr/local/bin/komand_base64"] |
53 changes: 53 additions & 0 deletions
53
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Include other Makefiles for improved functionality | ||
INCLUDE_DIR = ../../tools/Makefiles | ||
MAKEFILES := $(wildcard $(INCLUDE_DIR)/*.mk) | ||
# We can't guarantee customers will have the include files | ||
# - prefix to ignore Makefiles when not present | ||
# https://www.gnu.org/software/make/manual/html_node/Include.html | ||
-include $(MAKEFILES) | ||
|
||
ifneq ($(MAKEFILES),) | ||
$(info [$(YELLOW)*$(NORMAL)] Use ``make menu`` for available targets) | ||
$(info [$(YELLOW)*$(NORMAL)] Including available Makefiles: $(MAKEFILES)) | ||
$(info --) | ||
else | ||
$(warning Makefile includes directory not present: $(INCLUDE_DIR)) | ||
endif | ||
|
||
VERSION?=$(shell grep '^version: ' plugin.spec.yaml | sed 's/version: //') | ||
NAME?=$(shell grep '^name: ' plugin.spec.yaml | sed 's/name: //') | ||
VENDOR?=$(shell grep '^vendor: ' plugin.spec.yaml | sed 's/vendor: //') | ||
CWD?=$(shell basename $(PWD)) | ||
_NAME?=$(shell echo $(NAME) | awk '{ print toupper(substr($$0,1,1)) tolower(substr($$0,2)) }') | ||
PKG=$(VENDOR)-$(NAME)-$(VERSION).tar.gz | ||
|
||
# Set default target explicitly. Make's default behavior is the first target in the Makefile. | ||
# We don't want that behavior due to includes which are read first | ||
.DEFAULT_GOAL := default # Make >= v3.80 (make -version) | ||
|
||
|
||
default: image tarball | ||
|
||
tarball: | ||
$(info [$(YELLOW)*$(NORMAL)] Creating plugin tarball) | ||
rm -rf build | ||
rm -rf $(PKG) | ||
tar -cvzf $(PKG) --exclude=$(PKG) --exclude=tests --exclude=run.sh * | ||
|
||
image: | ||
$(info [$(YELLOW)*$(NORMAL)] Building plugin image) | ||
docker build --pull -t $(VENDOR)/$(NAME):$(VERSION) . | ||
docker tag $(VENDOR)/$(NAME):$(VERSION) $(VENDOR)/$(NAME):latest | ||
|
||
regenerate: | ||
$(info [$(YELLOW)*$(NORMAL)] Regenerating schema from plugin.spec.yaml) | ||
icon-plugin generate python --regenerate | ||
|
||
export: image | ||
$(info [$(YELLOW)*$(NORMAL)] Exporting docker image) | ||
@printf "\n ---> Exporting Docker image to ./$(VENDOR)_$(NAME)_$(VERSION).tar\n" | ||
@docker save $(VENDOR)/$(NAME):$(VERSION) | gzip > $(VENDOR)_$(NAME)_$(VERSION).tar | ||
|
||
# Make will not run a target if a file of the same name exists unless setting phony targets | ||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html | ||
.PHONY: default tarball image regenerate |
50 changes: 50 additions & 0 deletions
50
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/bin/komand_base64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python | ||
# GENERATED BY KOMAND SDK - DO NOT EDIT | ||
import os | ||
import json | ||
from sys import argv | ||
|
||
Name = "Base64" | ||
Vendor = "rapid7" | ||
Version = "1.1.2" | ||
Description = "Encode and decode data using the base64 alphabet" | ||
|
||
|
||
def main(): | ||
if 'http' in argv: | ||
if os.environ.get("GUNICORN_CONFIG_FILE"): | ||
with open(os.environ.get("GUNICORN_CONFIG_FILE")) as gf: | ||
gunicorn_cfg = json.load(gf) | ||
if gunicorn_cfg.get("worker_class", "sync") == "gevent": | ||
from gevent import monkey | ||
monkey.patch_all() | ||
elif 'gevent' in argv: | ||
from gevent import monkey | ||
monkey.patch_all() | ||
|
||
import insightconnect_plugin_runtime | ||
from komand_base64 import connection, actions, triggers, tasks | ||
|
||
class ICONBase64(insightconnect_plugin_runtime.Plugin): | ||
def __init__(self): | ||
super(self.__class__, self).__init__( | ||
name=Name, | ||
vendor=Vendor, | ||
version=Version, | ||
description=Description, | ||
connection=connection.Connection() | ||
) | ||
self.add_action(actions.Decode()) | ||
|
||
self.add_action(actions.Encode()) | ||
|
||
self.add_task(tasks.TestTask()) | ||
|
||
|
||
"""Run plugin""" | ||
cli = insightconnect_plugin_runtime.CLI(ICONBase64()) | ||
cli.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Binary file added
BIN
+16.6 KB
unit_test/plugin_examples/good_plugin_with_task_sdk_not_latest/extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.