Skip to content

Commit

Permalink
[PLGN-654] [PLGN-655] SQL - bumping version of SQLAlchemy and SDK used (
Browse files Browse the repository at this point in the history
#2212) (#2214)

* PLGN-654_655-bumping version of SQLAlchemy and SDK used

* PLGN-654_655-bumping version of SQLAlchemy and SDK used
  • Loading branch information
rbowden-r7 authored Jan 9, 2024
1 parent d02392b commit f5b809b
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 84 deletions.
10 changes: 5 additions & 5 deletions plugins/sql/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"spec": "ce3511ffd8e98051a98c26d3af0878aa",
"manifest": "1b6650465b4b888c2629db489e77977d",
"setup": "0d462ae92ec8f34edcf6fac21f329bec",
"spec": "318b640fa99101297941ad7837fac52b",
"manifest": "74ac90f8de35dc56e5d60e4c93a135b7",
"setup": "fa08b073c2fcd742510da31ed0a3c48a",
"schemas": [
{
"identifier": "query/schema.py",
"hash": "d58182a875e9e416627804d5ed3709ae"
"hash": "bdd1ccd7baccfebd25b71fe4b79a0515"
},
{
"identifier": "connection/schema.py",
"hash": "49f7eb7bca29f5fdc004af1f13ee1a3a"
"hash": "f49cbb13c885d7d625e1d1d38cd98f9d"
}
]
}
17 changes: 8 additions & 9 deletions plugins/sql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
FROM rapid7/insightconnect-python-3-38-plugin:4
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:5

# Add any custom package dependencies here
# NOTE: Add pip packages to requirements.txt
LABEL organization=rapid7
LABEL sdk=python

# End package dependencies
ENV TDSVER=8.0
RUN pip install --upgrade pip
RUN apt-get update && apt-get install -y libxslt-dev libxml2-dev unixodbc unixodbc-dev freetds-dev tdsodbc default-libmysqlclient-dev libpq-dev
RUN sed -i.bak 's/# TDS protocol version/tds version = 8.0/' /etc/freetds/freetds.conf
RUN sed -i.bak '/tds version = 8.0/a\ \tclient charset = UTF-8' /etc/freetds/freetds.conf

# Add source code
WORKDIR /python/src

ADD ./plugin.spec.yaml /plugin.spec.yaml
ADD . /python/src
ADD ./requirements.txt /python/src/requirements.txt

# Install pip dependencies
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# Install plugin
RUN python setup.py build && python setup.py install
ADD . /python/src

RUN python setup.py build && python setup.py install

# User to run plugin code. The two supported users are: root, nobody
USER nobody
Expand Down
8 changes: 4 additions & 4 deletions plugins/sql/bin/komand_sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
import os
import json
from sys import argv

Name = "SQL"
Vendor = "rapid7"
Version = "3.0.6"
Version = "3.0.7"
Description = "The SQL plugin allows you to run SQL queries"


Expand All @@ -23,7 +23,7 @@ def main():
monkey.patch_all()

import insightconnect_plugin_runtime
from komand_sql import connection, actions, triggers
from komand_sql import connection, actions, triggers, tasks

class ICONSql(insightconnect_plugin_runtime.Plugin):
def __init__(self):
Expand All @@ -35,7 +35,7 @@ def main():
connection=connection.Connection()
)
self.add_action(actions.Query())


"""Run plugin"""
cli = insightconnect_plugin_runtime.CLI(ICONSql())
Expand Down
74 changes: 36 additions & 38 deletions plugins/sql/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ This plugin allows users to run and execute queries against a SQL database.
# Documentation

## Setup

The connection configuration accepts the following parameters:
The connection configuration accepts the following parameters:

|Name|Type|Default|Required|Description|Enum|Example|
|----|----|-------|--------|-----------|----|-------|
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|credentials|credential_username_password|None|True|Database username and password|None|{ "username": "user@example.com", "password": "mypassword"}|
|db|string|None|True|Database name|None|database_name|
|host|string|None|True|Database hostname|None|198.51.100.1|
|port|string|None|False|Database port|None|1433|
|type|string|None|True|Database type (MSSQL, MySQL, PostgreSQL)|['MSSQL', 'MySQL', 'PostgreSQL']|MySQL|

Example input:

```
{
"credentials": {
"username": "user@example.com",
"password": "mypassword"
"password": "mypassword",
"username": "user@example.com"
},
"db": "database_name",
"host": "198.51.100.1",
Expand All @@ -53,17 +53,18 @@ Example input:

### Actions

#### Query

This action is used to run an arbitrary SQL query against the connected database.
#### Query

This action is used to run an arbitrary SQL query against the connected database

##### Input

|Name|Type|Default|Required|Description|Enum|Example|
|----|----|-------|--------|-----------|----|-------|
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|parameters|object|None|False|Parameters for query|None|{ "name": "user" }|
|query|string|None|True|Query to run|None|SELECT * FROM example WHERE name=:name|

Example input:

```
Expand All @@ -77,48 +78,43 @@ Example input:

##### Output

|Name|Type|Required|Description|
|----|----|--------|-----------|
|header|[]string|False|Array of header fields for the columns|
|results|[]object|False|Result rows, each as an object with header keys|
|status|string|True|Status message|

|Name|Type|Required|Description|Example|
| :--- | :--- | :--- | :--- | :--- |
|header|[]string|False|Array of header fields for the columns|["name", "surname", "index", "alias"]|', '|results|[]object|False|Result rows, each as an object with header keys|[{"name": "User", "index": "1", "Surname": "Example", "alias": "Test"}]|
|status|string|True|Status message|operation success|

Example output:

```
{
"header": [
"name",
"surname",
"index",
"alias"
],
"results": [
{
"name": "User",
"index": "1",
"Surname": "Example",
"alias": "Test"
}
],
"header": "name",
"results": {
"Surname": "Example",
"alias": "Test",
"index": "1",
"name": "User"
},
"status": "operation success"
}
```

### Triggers

*This plugin does not contain any triggers.*
### Tasks

*This plugin does not contain any tasks.*

_This plugin does not contain any triggers._

### Custom Output Types

_This plugin does not contain any custom output types._
### Custom Types

*This plugin does not contain any custom output types.*

## Troubleshooting

For the SQL query action, be sure that your query is valid SQL.
*There is no troubleshooting for this plugin.*

# Version History

* 3.0.7 - Bumped version of SQLAlchemy used to version 1.2.18 | bump version of SDK used to version 5
* 3.0.6 - Update plugin runtime to InsightConnect
* 3.0.5 - Update pymssql version library to support latest MSSQL update 2019 15.0.4223.1
* 3.0.4 - Fix issue with get method's keyword argument in Query action
Expand All @@ -139,6 +135,8 @@ For the SQL query action, be sure that your query is valid SQL.

# Links

* [SQLAlchemy](http://docs.sqlalchemy.org/en/latest/)

## References

* [SQLAlchemy](http://docs.sqlalchemy.org/en/latest/)
4 changes: 3 additions & 1 deletion plugins/sql/komand_sql/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT

from .query.action import Query

2 changes: 1 addition & 1 deletion plugins/sql/komand_sql/actions/query/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
from .action import Query
18 changes: 10 additions & 8 deletions plugins/sql/komand_sql/actions/query/schema.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
import insightconnect_plugin_runtime
import json


class Component:
DESCRIPTION = "SQL query"
DESCRIPTION = "Run an arbitrary SQL query against the connected database"


class Input:
PARAMETERS = "parameters"
QUERY = "query"


class Output:
HEADER = "header"
RESULTS = "results"
STATUS = "status"


class QueryInput(insightconnect_plugin_runtime.Input):
schema = json.loads("""
schema = json.loads(r"""
{
"type": "object",
"title": "Variables",
Expand All @@ -39,7 +39,8 @@ class QueryInput(insightconnect_plugin_runtime.Input):
},
"required": [
"query"
]
],
"definitions": {}
}
""")

Expand All @@ -48,7 +49,7 @@ def __init__(self):


class QueryOutput(insightconnect_plugin_runtime.Output):
schema = json.loads("""
schema = json.loads(r"""
{
"type": "object",
"title": "Variables",
Expand Down Expand Up @@ -80,7 +81,8 @@ class QueryOutput(insightconnect_plugin_runtime.Output):
},
"required": [
"status"
]
],
"definitions": {}
}
""")

Expand Down
2 changes: 1 addition & 1 deletion plugins/sql/komand_sql/connection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
from .connection import Connection
22 changes: 11 additions & 11 deletions plugins/sql/komand_sql/connection/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
import insightconnect_plugin_runtime
import json

Expand All @@ -9,10 +9,10 @@ class Input:
HOST = "host"
PORT = "port"
TYPE = "type"


class ConnectionSchema(insightconnect_plugin_runtime.Input):
schema = json.loads("""
schema = json.loads(r"""
{
"type": "object",
"title": "Variables",
Expand Down Expand Up @@ -62,23 +62,23 @@ class ConnectionSchema(insightconnect_plugin_runtime.Input):
"definitions": {
"credential_username_password": {
"id": "credential_username_password",
"type": "object",
"title": "Credential: Username and Password",
"description": "A username and password combination",
"type": "object",
"properties": {
"username": {
"type": "string",
"title": "Username",
"description": "The username to log in with",
"order": 1
},
"password": {
"type": "string",
"title": "Password",
"displayType": "password",
"description": "The password",
"format": "password",
"displayType": "password",
"order": 2
},
"username": {
"type": "string",
"title": "Username",
"description": "The username to log in with",
"order": 1
}
},
"required": [
Expand Down
2 changes: 2 additions & 0 deletions plugins/sql/komand_sql/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT

3 changes: 2 additions & 1 deletion plugins/sql/komand_sql/triggers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT

Loading

0 comments on commit f5b809b

Please sign in to comment.