Skip to content

Commit

Permalink
[PLGN-432] Dig Version Bump To 2.0.1 (#2027)
Browse files Browse the repository at this point in the history
* Added empty init file,version bumped and minor changes in plugin.spec.yaml

* Reverting Dockerfile SDK version

* Updated SDK

* Dockerfile changes and unit tests added

* Removed apk installs

* unit test

* forward action unit tests

* reverse action unit tests

* add parameterized package to requirements
  • Loading branch information
abmccann-r7 authored and cmcnally-r7 committed Nov 1, 2023
1 parent 93d6c3b commit 5b5cf4a
Show file tree
Hide file tree
Showing 38 changed files with 412 additions and 110 deletions.
12 changes: 6 additions & 6 deletions plugins/dig/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"spec": "0d8fc06907c538dcdf234e05e620c08f",
"manifest": "564b73ad4dcf43f2060649404023f7a9",
"setup": "d7940aafd0c4c7f33c5ddb120cfd74b1",
"spec": "1ffed9a907bbf97ef055cdbd1227c1e2",
"manifest": "549bd68cd27fe3e75beb740c5dc2c2cc",
"setup": "8b25a62b1b719e9d60bf7968ffd1b418",
"schemas": [
{
"identifier": "forward/schema.py",
"hash": "d3b32f909cfe1a66d6eb1e0c367b409d"
"hash": "f4de8b6816749db57112a430f638e724"
},
{
"identifier": "reverse/schema.py",
"hash": "c9e9a35ae4fb8dbff479ae0830c97392"
"hash": "f1cff211d6f2e9824bef6fddcb8d266b"
},
{
"identifier": "connection/schema.py",
"hash": "da5382221ca2a33a2f854e17b068d502"
"hash": "bd524b567f9638ba1c6f7e0c9e45ff2e"
}
]
}
6 changes: 4 additions & 2 deletions plugins/dig/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM rapid7/insightconnect-python-3-38-slim-plugin:4
LABEL organization=komand
FROM rapid7/insightconnect-python-3-38-slim-plugin:5

LABEL organization=rapid7
LABEL sdk=python
LABEL type=plugin

Expand All @@ -19,6 +20,7 @@ WORKDIR /python/src
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
RUN python setup.py build && python setup.py install

# User to run plugin code. The two supported users are: root, nobody
USER nobody

ENTRYPOINT ["/usr/local/bin/komand_dig"]
12 changes: 6 additions & 6 deletions plugins/dig/bin/komand_dig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/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 = "DNS"
Vendor = "rapid7"
Version = "2.0.0"
Description = "DNS is used for forward and reverse DNS lookups"
Version = "2.0.1"
Description = "The DNS plugin is used for forward and reverse DNS lookups. This plugin uses [Dig](https://linux.die.net/man/1/dig), or Domain Information Groper, which is a network administration command-line tool for querying Domain Name System (DNS) name servers"


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

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

class ICONDig(insightconnect_plugin_runtime.Plugin):
def __init__(self):
Expand All @@ -35,9 +35,9 @@ def main():
connection=connection.Connection()
)
self.add_action(actions.Forward())

self.add_action(actions.Reverse())


"""Run plugin"""
cli = insightconnect_plugin_runtime.CLI(ICONDig())
Expand Down
115 changes: 55 additions & 60 deletions plugins/dig/help.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
# Description

The DNS plugin is used for forward and reverse DNS lookups. This plugin uses [Dig](https://linux.die.net/man/1/dig), or Domain Information Groper, which is a network administration command-line tool for querying Domain Name System (DNS) name servers.
The DNS plugin is used for forward and reverse DNS lookups. This plugin uses [Dig](https://linux.die.net/man/1/dig), or Domain Information Groper, which is a network administration command-line tool for querying Domain Name System (DNS) name servers

# Key Features

* Forward DNS lookup to find an IP address from a domain name
* Forward DNS lookup to find an IP address from a domain name
* Reverse DNS lookup to find a domain name from an IP address

# Requirements

_This plugin does not contain any requirements._
# Supported Product Versions

* 2023-10-12

# Documentation

## Setup

_This plugin does not contain a connection._
*This plugin does not contain a connection.*

## Technical Details

### Actions

#### Forward Lookup

This action is used to request a forward lookup for a domain.
This action is used to request a forward lookup for a domain

##### Input

It accepts a domain name of type `string` and one of the following record types:

* A
* AAAA
* ANY
* CNAME
* MX
* NS
* PTR
* SOA

|Name|Type|Default|Required|Description|Enum|Example|
|----|----|-------|--------|-----------|----|-------|
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|domain|string|None|True|Domain name to resolve|None|rapid7.com|
|query|string|None|True|Query type e.g. ANY, A, MX, NS, etc|['A', 'AAAA', 'ANY', 'CNAME', 'MX', 'NS', 'PTR', 'SOA']|MX|
|resolver|string|None|False|Resolver. Leave blank to use default resolver for the system|None|8.8.8.8|

Example input:

```
Expand All @@ -56,31 +47,29 @@ Example input:

##### Output

|Name|Type|Required|Description|
|----|----|--------|-----------|
|all_answers|[]string|False|A list of all answers found|
|answer|string|False|Answer received|
|fulloutput|string|False|Full DNS output|
|last_answer|string|False|The last answer found in the answers section|
|nameserver|string|False|Nameserver that fulfilled request|
|question|string|False|Question asked|
|status|string|False|Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]|

|Name|Type|Required|Description|Example|
| :--- | :--- | :--- | :--- | :--- |
|all_answers|[]string|False|A list of all answers found|["172.217.6.14"]|
|answer|string|False|Answer received|172.217.6.14|
|fulloutput|string|False|Full DNS output|\n; <<>> DiG 9.12.4-P2 <<>> google.com A\n;; global ...|
|last_answer|string|False|The last answer found in the answers section|172.217.6.14|
|nameserver|string|False|Nameserver that fulfilled request|192.168.65.1|
|question|string|False|Question asked|google.com|
|status|string|False|Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]|NOERROR|
On success, the raw output will look like the following:

Example output:

```
{
"last_answer": "172.217.6.14",
"nameserver": "192.168.65.1",
"question": "google.com",
"status": "NOERROR",
"all_answers": [
"172.217.6.14"
],
"answer": "172.217.6.14",
"fulloutput": "\n; <<>> DiG 9.12.4-P2 <<>> google.com A\n;; global ..."
"fulloutput": "\\n; <<>> DiG 9.12.4-P2 <<>> google.com A\\n;; global ...",
"last_answer": "172.217.6.14",
"nameserver": "192.168.65.1",
"question": "google.com",
"status": "NOERROR"
}
```

Expand All @@ -99,16 +88,16 @@ On failure, the raw output will look like the following:
```

#### Reverse Lookup

This action is used to request a reverse lookup for an IP address.
This action is used to request a reverse lookup for an IP address

##### Input

|Name|Type|Default|Required|Description|Enum|Example|
|----|----|-------|--------|-----------|----|-------|
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|address|string|None|True|Internet address to resolve|None|1.2.3.4|
|resolver|string|None|False|Resolver. Leave blank to use default resolver for the system|None|8.8.8.8|

Example input:

```
Expand All @@ -120,29 +109,28 @@ Example input:

##### Output

|Name|Type|Required|Description|
|----|----|--------|-----------|
|answer|string|False|Answer received|
|fulloutput|string|False|Full DNS output|
|nameserver|string|False|Nameserver that fulfilled request|
|question|string|False|Question asked|
|status|string|False|Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]|

|Name|Type|Required|Description|Example|
| :--- | :--- | :--- | :--- | :--- |
|answer|string|False|Answer received|google-public-dns-a.google.com|
|fulloutput|string|False|Full DNS output|\n; <<>> Dig 9.9.5-9+deb8u9-Debian <<>> -x 8.8.8.8\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59406\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;8.8.8.8.in-addr.arpa.\t\tIN\tPTR\n\n;; ANSWER SECTION:\n8.8.8.8.in-addr.arpa.\t68133\tIN\tPTR\tgoogle-public-dns-a.google.com.\n\n;; Query time: 22 msec\n;; SERVER: 10.0.2.3#53(10.0.2.3)\n;; WHEN: Thu Jan 26 23:43:43 UTC 2017\n;; MSG SIZE rcvd: 93\n\n|
|nameserver|string|False|Nameserver that fulfilled request|10.0.2.3|
|question|string|False|Question asked|8.8.8.8|
|status|string|False|Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]|NOERROR|
On success, the raw output will look like the following:

```
{
"status": "NOERROR",
"answer": "google-public-dns-a.google.com",
"fulloutput": "\\n; <<>> Dig 9.9.5-9+deb8u9-Debian <<>> -x 8.8.8.8\\n;; global options: +cmd\\n;; Got answer:\\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59406\\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\\n\\n;; OPT PSEUDOSECTION:\\n; EDNS: version: 0, flags:; udp: 512\\n;; QUESTION SECTION:\\n;8.8.8.8.in-addr.arpa.\\t\\tIN\\tPTR\\n\\n;; ANSWER SECTION:\\n8.8.8.8.in-addr.arpa.\\t68133\\tIN\\tPTR\\tgoogle-public-dns-a.google.com.\\n\\n;; Query time: 22 msec\\n;; SERVER: 10.0.2.3#53(10.0.2.3)\\n;; WHEN: Thu Jan 26 23:43:43 UTC 2017\\n;; MSG SIZE rcvd: 93\\n\\n",
"nameserver": "10.0.2.3",
"question": "8.8.8.8",
"fulloutput": "\n; <<>> Dig 9.9.5-9+deb8u9-Debian <<>> -x 8.8.8.8\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59406\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;8.8.8.8.in-addr.arpa.\t\tIN\tPTR\n\n;; ANSWER SECTION:\n8.8.8.8.in-addr.arpa.\t68133\tIN\tPTR\tgoogle-public-dns-a.google.com.\n\n;; Query time: 22 msec\n;; SERVER: 10.0.2.3#53(10.0.2.3)\n;; WHEN: Thu Jan 26 23:43:43 UTC 2017\n;; MSG SIZE rcvd: 93\n\n"
"status": "NOERROR"
}
```

Example output:
On failure, the raw output will look like the following:

```
{
Expand All @@ -155,12 +143,16 @@ Example output:
```

### Triggers

*This plugin does not contain any triggers.*

_This plugin does not contain any triggers._

### Custom Output Types
### Tasks
*This plugin does not contain any tasks.*

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

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

## Troubleshooting

Expand Down Expand Up @@ -194,6 +186,7 @@ Common examples:

# Version History

* 2.0.1 - Added `__init__.py` file to `unit_test` folder | Refreshed with new Tooling
* 2.0.0 - Rename Dig plugin to DNS
* 1.0.7 - Fix bug in `safe_parse` function | Fix bug when `answers` in function `execute_command` is str
* 1.0.6 - Upgrade to latest Python plugin runtime | Define `cloud_ready` in spec
Expand All @@ -212,7 +205,9 @@ Common examples:

# Links

## References

* [Dig](https://linux.die.net/man/1/dig)

## References

* [Dig](https://linux.die.net/man/1/dig)
* [DNS Status Code](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml)
5 changes: 4 additions & 1 deletion plugins/dig/komand_dig/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT

from .forward.action import Forward

from .reverse.action import Reverse

2 changes: 1 addition & 1 deletion plugins/dig/komand_dig/actions/forward/__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 Forward
21 changes: 10 additions & 11 deletions plugins/dig/komand_dig/actions/forward/schema.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# GENERATED BY KOMAND SDK - DO NOT EDIT
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
import insightconnect_plugin_runtime
import json


class Component:
DESCRIPTION = "Forward DNS Query"
DESCRIPTION = "This action is used to request a forward lookup for a domain"


class Input:
DOMAIN = "domain"
QUERY = "query"
RESOLVER = "resolver"


class Output:
ALL_ANSWERS = "all_answers"
Expand All @@ -21,23 +21,21 @@ class Output:
NAMESERVER = "nameserver"
QUESTION = "question"
STATUS = "status"


class ForwardInput(insightconnect_plugin_runtime.Input):
schema = json.loads("""
schema = json.loads(r"""
{
"type": "object",
"title": "Variables",
"properties": {
"domain": {
"type": "string",
"title": "Domain",
"description": "Domain name to resolve",
"order": 1
},
"query": {
"type": "string",
"title": "Query",
"description": "Query type e.g. ANY, A, MX, NS, etc",
"enum": [
"A",
Expand All @@ -53,15 +51,15 @@ class ForwardInput(insightconnect_plugin_runtime.Input):
},
"resolver": {
"type": "string",
"title": "Resolver",
"description": "Resolver. Leave blank to use default resolver for the system",
"order": 2
}
},
"required": [
"domain",
"query"
]
],
"definitions": {}
}
""")

Expand All @@ -70,7 +68,7 @@ def __init__(self):


class ForwardOutput(insightconnect_plugin_runtime.Output):
schema = json.loads("""
schema = json.loads(r"""
{
"type": "object",
"title": "Variables",
Expand Down Expand Up @@ -120,7 +118,8 @@ class ForwardOutput(insightconnect_plugin_runtime.Output):
"description": "Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]",
"order": 2
}
}
},
"definitions": {}
}
""")

Expand Down
2 changes: 1 addition & 1 deletion plugins/dig/komand_dig/actions/reverse/__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 Reverse
Loading

0 comments on commit 5b5cf4a

Please sign in to comment.