diff --git a/plugins/dig/.CHECKSUM b/plugins/dig/.CHECKSUM index d2a674f571..d25056bef5 100644 --- a/plugins/dig/.CHECKSUM +++ b/plugins/dig/.CHECKSUM @@ -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" } ] } \ No newline at end of file diff --git a/plugins/dig/Dockerfile b/plugins/dig/Dockerfile index feb718b20b..6d63982df7 100755 --- a/plugins/dig/Dockerfile +++ b/plugins/dig/Dockerfile @@ -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 @@ -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"] diff --git a/plugins/dig/bin/komand_dig b/plugins/dig/bin/komand_dig index 3011c8ad45..92de0e36a5 100755 --- a/plugins/dig/bin/komand_dig +++ b/plugins/dig/bin/komand_dig @@ -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(): @@ -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): @@ -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()) diff --git a/plugins/dig/help.md b/plugins/dig/help.md index b933b12488..ab12c22d6c 100644 --- a/plugins/dig/help.md +++ b/plugins/dig/help.md @@ -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: ``` @@ -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" } ``` @@ -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: ``` @@ -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: ``` { @@ -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 @@ -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 @@ -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) diff --git a/plugins/dig/komand_dig/actions/__init__.py b/plugins/dig/komand_dig/actions/__init__.py index c28a0565ba..147d933ee4 100755 --- a/plugins/dig/komand_dig/actions/__init__.py +++ b/plugins/dig/komand_dig/actions/__init__.py @@ -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 + diff --git a/plugins/dig/komand_dig/actions/forward/__init__.py b/plugins/dig/komand_dig/actions/forward/__init__.py index a9829a6cf0..51631c5070 100755 --- a/plugins/dig/komand_dig/actions/forward/__init__.py +++ b/plugins/dig/komand_dig/actions/forward/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import Forward diff --git a/plugins/dig/komand_dig/actions/forward/schema.py b/plugins/dig/komand_dig/actions/forward/schema.py index 33fac67e33..27042a17a3 100755 --- a/plugins/dig/komand_dig/actions/forward/schema.py +++ b/plugins/dig/komand_dig/actions/forward/schema.py @@ -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" @@ -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", @@ -53,7 +51,6 @@ class ForwardInput(insightconnect_plugin_runtime.Input): }, "resolver": { "type": "string", - "title": "Resolver", "description": "Resolver. Leave blank to use default resolver for the system", "order": 2 } @@ -61,7 +58,8 @@ class ForwardInput(insightconnect_plugin_runtime.Input): "required": [ "domain", "query" - ] + ], + "definitions": {} } """) @@ -70,7 +68,7 @@ def __init__(self): class ForwardOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -120,7 +118,8 @@ class ForwardOutput(insightconnect_plugin_runtime.Output): "description": "Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]", "order": 2 } - } + }, + "definitions": {} } """) diff --git a/plugins/dig/komand_dig/actions/reverse/__init__.py b/plugins/dig/komand_dig/actions/reverse/__init__.py index 33da800e80..3d93a6ad15 100755 --- a/plugins/dig/komand_dig/actions/reverse/__init__.py +++ b/plugins/dig/komand_dig/actions/reverse/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import Reverse diff --git a/plugins/dig/komand_dig/actions/reverse/schema.py b/plugins/dig/komand_dig/actions/reverse/schema.py index 451543996f..7994a17099 100755 --- a/plugins/dig/komand_dig/actions/reverse/schema.py +++ b/plugins/dig/komand_dig/actions/reverse/schema.py @@ -1,16 +1,16 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json class Component: - DESCRIPTION = "Reverse DNS Query" + DESCRIPTION = "This action is used to request a reverse lookup for an IP address" class Input: ADDRESS = "address" RESOLVER = "resolver" - + class Output: ANSWER = "answer" @@ -18,30 +18,29 @@ class Output: NAMESERVER = "nameserver" QUESTION = "question" STATUS = "status" - + class ReverseInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", "properties": { "address": { "type": "string", - "title": "Address", "description": "Internet address to resolve", "order": 2 }, "resolver": { "type": "string", - "title": "Resolver", "description": "Resolver. Leave blank to use default resolver for the system", "order": 1 } }, "required": [ "address" - ] + ], + "definitions": {} } """) @@ -50,7 +49,7 @@ def __init__(self): class ReverseOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -85,7 +84,8 @@ class ReverseOutput(insightconnect_plugin_runtime.Output): "description": "Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...]", "order": 2 } - } + }, + "definitions": {} } """) diff --git a/plugins/dig/komand_dig/connection/__init__.py b/plugins/dig/komand_dig/connection/__init__.py index a515dcf6b0..c78d3356be 100755 --- a/plugins/dig/komand_dig/connection/__init__.py +++ b/plugins/dig/komand_dig/connection/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .connection import Connection diff --git a/plugins/dig/komand_dig/connection/schema.py b/plugins/dig/komand_dig/connection/schema.py index b93c5a7c44..10cc2e684f 100755 --- a/plugins/dig/komand_dig/connection/schema.py +++ b/plugins/dig/komand_dig/connection/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -6,8 +6,9 @@ class Input: pass + class ConnectionSchema(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" {} """) diff --git a/plugins/dig/komand_dig/tasks/__init__.py b/plugins/dig/komand_dig/tasks/__init__.py new file mode 100644 index 0000000000..7020c9a4ad --- /dev/null +++ b/plugins/dig/komand_dig/tasks/__init__.py @@ -0,0 +1,2 @@ +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT + diff --git a/plugins/dig/komand_dig/triggers/__init__.py b/plugins/dig/komand_dig/triggers/__init__.py index bace8db897..7020c9a4ad 100755 --- a/plugins/dig/komand_dig/triggers/__init__.py +++ b/plugins/dig/komand_dig/triggers/__init__.py @@ -1 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT + diff --git a/plugins/dig/plugin.spec.yaml b/plugins/dig/plugin.spec.yaml index 50f14803f3..dff53037e6 100644 --- a/plugins/dig/plugin.spec.yaml +++ b/plugins/dig/plugin.spec.yaml @@ -3,11 +3,16 @@ extension: plugin products: [insightconnect] name: dig title: DNS -description: DNS is used for forward and reverse DNS lookups -version: 2.0.0 +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 +version: 2.0.1 vendor: rapid7 support: community +supported_versions: ["2023-10-12"] status: [] +sdk: + type: full + version: 5 + user: nobody cloud_ready: true resources: source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/plugins/dig @@ -19,10 +24,13 @@ hub_tags: use_cases: [threat_detection_and_response, offensive_security] keywords: [dig, dns, cloud_enabled] features: [] +key_features: ["Forward DNS lookup to find an IP address from a domain name", "Reverse DNS lookup to find a domain name from an IP address"] +references: ["[Dig](https://linux.die.net/man/1/dig)", "[DNS Status Code](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml)"] +requirements: [] actions: forward: title: Forward Lookup - description: Forward DNS Query + description: This action is used to request a forward lookup for a domain input: domain: type: string @@ -54,40 +62,47 @@ actions: title: Full Output type: string required: false + example: \n; <<>> DiG 9.12.4-P2 <<>> google.com A\n;; global ... status: title: Query Status description: Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...] type: string required: false + example: NOERROR nameserver: title: Nameserver description: Nameserver that fulfilled request type: string required: false + example: 192.168.65.1 answer: description: Answer received title: Answer type: string required: false + example: 172.217.6.14 question: description: Question asked title: Question type: string required: false + example: google.com all_answers: title: All Answers type: '[]string' description: A list of all answers found required: false + example: '["172.217.6.14"]' last_answer: title: Last Answer type: string description: The last answer found in the answers section required: false + example: 172.217.6.14 reverse: title: Reverse Lookup - description: Reverse DNS Query + description: This action is used to request a reverse lookup for an IP address input: resolver: type: string @@ -105,24 +120,29 @@ actions: title: Full Output type: string required: false + example: '\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: title: Query Status description: Query status [ NOERROR | FORMERR | NXDOMAIN | SERVFAIL | REFUSED ...] type: string required: false + example: NOERROR nameserver: title: Nameserver description: Nameserver that fulfilled request type: string required: false + example: 10.0.2.3 answer: title: Answer description: Answer received type: string required: false + example: google-public-dns-a.google.com question: title: Question description: Question asked type: string required: false + example: 8.8.8.8 diff --git a/plugins/dig/requirements.txt b/plugins/dig/requirements.txt index d0674c75e2..252e0d4a6c 100755 --- a/plugins/dig/requirements.txt +++ b/plugins/dig/requirements.txt @@ -1,3 +1,4 @@ # List third-party dependencies here, separated by newlines. # All dependencies must be version-pinned, eg. requests==1.2.0 -# See: https://pip.pypa.io/en/stable/user_guide/#requirements-files \ No newline at end of file +# See: https://pip.pypa.io/en/stable/user_guide/#requirements-files +parameterized == 0.8.1 \ No newline at end of file diff --git a/plugins/dig/setup.py b/plugins/dig/setup.py index f23b4d8cd9..1cf79628c1 100755 --- a/plugins/dig/setup.py +++ b/plugins/dig/setup.py @@ -1,10 +1,10 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from setuptools import setup, find_packages setup(name="dig-rapid7-plugin", - 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", author="rapid7", author_email="", url="", diff --git a/plugins/dig/unit_test/__init__.py b/plugins/dig/unit_test/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/dig/unit_test/expected/forward.json.exp b/plugins/dig/unit_test/expected/forward.json.exp new file mode 100644 index 0000000000..bbaf261457 --- /dev/null +++ b/plugins/dig/unit_test/expected/forward.json.exp @@ -0,0 +1,15 @@ +{ + "fulloutput":"\n; <<>> DiG 9.16.20 <<>> @8.8.8.8 rapid7.com MX\n; (1 server found)\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18691\n;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;rapid7.com.\t\t\tIN\tMX\n\n;; ANSWER SECTION:\nrapid7.com.\t\t8\tIN\tMX\t1 aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t10 alt3.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t10 alt4.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t5 alt1.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t5 alt2.aspmx.l.google.com.\n\n;; Query time: 34 msec\n;; SERVER: 8.8.8.8#53(8.8.8.8)\n;; WHEN: Wed Oct 25 13:35:49 UTC 2023\n;; MSG SIZE rcvd: 154\n\n", + "question":"rapid7.com", + "nameserver":"8.8.8.8", + "status":"NOERROR", + "answer":"aspmx.l.google.com", + "last_answer":"alt2.aspmx.l.google.com", + "all_answers":[ + "aspmx.l.google.com", + "alt3.aspmx.l.google.com", + "alt4.aspmx.l.google.com", + "alt1.aspmx.l.google.com", + "alt2.aspmx.l.google.com" + ] +} \ No newline at end of file diff --git a/plugins/dig/unit_test/expected/forward_no_resolver.json.exp b/plugins/dig/unit_test/expected/forward_no_resolver.json.exp new file mode 100644 index 0000000000..fa86d1e22d --- /dev/null +++ b/plugins/dig/unit_test/expected/forward_no_resolver.json.exp @@ -0,0 +1,12 @@ +{ + "fulloutput":"\n; <<>> DiG 9.16.20 <<>> rapid7.com MX\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28119\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n; COOKIE: eea7f9fd1edc0167 (echoed)\n;; QUESTION SECTION:\n;rapid7.com.\t\t\tIN\tMX\n\n;; ANSWER SECTION:\nrapid7.com.\t\t377\tIN\tMX\t20 smtp002.rapid7.com.\nrapid7.com.\t\t377\tIN\tMX\t40 smtp001.rapid7.com.\n\n;; Query time: 112 msec\n;; SERVER: 192.168.65.7#53(192.168.65.7)\n;; WHEN: Thu Oct 26 09:14:07 UTC 2023\n;; MSG SIZE rcvd: 139\n\n", + "question":"rapid7.com", + "nameserver":"192.168.65.7", + "status":"NOERROR", + "answer":"smtp002.rapid7.com", + "last_answer":"smtp001.rapid7.com", + "all_answers":[ + "smtp002.rapid7.com", + "smtp001.rapid7.com" + ] +} \ No newline at end of file diff --git a/plugins/dig/unit_test/expected/forward_raise_error.json.exp b/plugins/dig/unit_test/expected/forward_raise_error.json.exp new file mode 100644 index 0000000000..298e581f5d --- /dev/null +++ b/plugins/dig/unit_test/expected/forward_raise_error.json.exp @@ -0,0 +1,9 @@ +{ + "all_answers": ["Not found"], + "answer": "Not found", + "fulloutput": "Resolution failed, nameserver NO MATCHES FOUND returned NO MATCHES FOUND status", + "last_answer": "Not found", + "nameserver": "NO MATCHES FOUND", + "question": "rapid7.com", + "status": "NO MATCHES FOUND" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/expected/reverse.json.exp b/plugins/dig/unit_test/expected/reverse.json.exp new file mode 100644 index 0000000000..04f86d212d --- /dev/null +++ b/plugins/dig/unit_test/expected/reverse.json.exp @@ -0,0 +1,7 @@ +{ + "fulloutput":"\n; <<>> DiG 9.16.20 <<>> @8.8.8.8 -x 13.33.252.129\n; (1 server found)\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28936\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;129.252.33.13.in-addr.arpa.\tIN\tPTR\n\n;; ANSWER SECTION:\n129.252.33.13.in-addr.arpa. 21600 IN\tPTR\tserver-13-33-252-129.den50.r.cloudfront.net.\n\n;; Query time: 107 msec\n;; SERVER: 8.8.8.8#53(8.8.8.8)\n;; WHEN: Tue Oct 31 09:12:29 UTC 2023\n;; MSG SIZE rcvd: 112\n\n", + "question":"13.33.252.129", + "nameserver":"8.8.8.8", + "status":"NOERROR", + "answer":"server-13-33-252-129.den50.r.cloudfront.net" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/expected/reverse_no_resolver.json.exp b/plugins/dig/unit_test/expected/reverse_no_resolver.json.exp new file mode 100644 index 0000000000..75a14b1dc0 --- /dev/null +++ b/plugins/dig/unit_test/expected/reverse_no_resolver.json.exp @@ -0,0 +1,7 @@ +{ + "fulloutput":"\n; <<>> DiG 9.16.20 <<>> -x 13.33.252.129\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58301\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n; COOKIE: cacd97b822b897c7 (echoed)\n;; QUESTION SECTION:\n;129.252.33.13.in-addr.arpa.\tIN\tPTR\n\n;; ANSWER SECTION:\n129.252.33.13.in-addr.arpa. 4502 IN\tPTR\tserver-13-33-252-129.den50.r.cloudfront.net.\n\n;; Query time: 35 msec\n;; SERVER: 192.168.65.7#53(192.168.65.7)\n;; WHEN: Tue Oct 31 09:34:15 UTC 2023\n;; MSG SIZE rcvd: 150\n\n", + "question":"13.33.252.129", + "nameserver":"192.168.65.7", + "status":"NOERROR", + "answer":"server-13-33-252-129.den50.r.cloudfront.net" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/expected/reverse_raise_error.json.exp b/plugins/dig/unit_test/expected/reverse_raise_error.json.exp new file mode 100644 index 0000000000..ccff1d736c --- /dev/null +++ b/plugins/dig/unit_test/expected/reverse_raise_error.json.exp @@ -0,0 +1,7 @@ +{ + "fulloutput":"Resolution failed, nameserver NO MATCHES FOUND returned NO MATCHES FOUND status", + "question":"13.33.252.129", + "nameserver":"NO MATCHES FOUND", + "status":"NO MATCHES FOUND", + "answer":"Not found" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/forward.json.inp b/plugins/dig/unit_test/inputs/forward.json.inp new file mode 100644 index 0000000000..150546ac5e --- /dev/null +++ b/plugins/dig/unit_test/inputs/forward.json.inp @@ -0,0 +1,5 @@ +{ + "domain": "rapid7.com", + "resolver": "8.8.8.8", + "query": "MX" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/forward_no_resolver.json.inp b/plugins/dig/unit_test/inputs/forward_no_resolver.json.inp new file mode 100644 index 0000000000..a9b7456214 --- /dev/null +++ b/plugins/dig/unit_test/inputs/forward_no_resolver.json.inp @@ -0,0 +1,4 @@ +{ + "domain": "rapid7.com", + "query": "MX" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/forward_raise_error.json.inp b/plugins/dig/unit_test/inputs/forward_raise_error.json.inp new file mode 100644 index 0000000000..85f0cce09c --- /dev/null +++ b/plugins/dig/unit_test/inputs/forward_raise_error.json.inp @@ -0,0 +1,5 @@ +{ + "domain": "rapid7.com", + "resolver": "8", + "query": "MX" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/reverse.json.inp b/plugins/dig/unit_test/inputs/reverse.json.inp new file mode 100644 index 0000000000..ea22bff588 --- /dev/null +++ b/plugins/dig/unit_test/inputs/reverse.json.inp @@ -0,0 +1,4 @@ +{ + "resolver": "8.8.8.8", + "address": "13.33.252.129" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/reverse_no_resolver.json.inp b/plugins/dig/unit_test/inputs/reverse_no_resolver.json.inp new file mode 100644 index 0000000000..3a78f7c449 --- /dev/null +++ b/plugins/dig/unit_test/inputs/reverse_no_resolver.json.inp @@ -0,0 +1,4 @@ +{ + "resolver": "", + "address": "13.33.252.129" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/inputs/reverse_raise_error.json.inp b/plugins/dig/unit_test/inputs/reverse_raise_error.json.inp new file mode 100644 index 0000000000..701e28bea8 --- /dev/null +++ b/plugins/dig/unit_test/inputs/reverse_raise_error.json.inp @@ -0,0 +1,4 @@ +{ + "resolver": "8", + "address": "13.33.252.129" + } \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/forward.json.resp b/plugins/dig/unit_test/responses/forward.json.resp new file mode 100644 index 0000000000..89f8c9102f --- /dev/null +++ b/plugins/dig/unit_test/responses/forward.json.resp @@ -0,0 +1,5 @@ +{ + "stdout":"\n; <<>> DiG 9.16.20 <<>> @8.8.8.8 rapid7.com MX\n; (1 server found)\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18691\n;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;rapid7.com.\t\t\tIN\tMX\n\n;; ANSWER SECTION:\nrapid7.com.\t\t8\tIN\tMX\t1 aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t10 alt3.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t10 alt4.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t5 alt1.aspmx.l.google.com.\nrapid7.com.\t\t8\tIN\tMX\t5 alt2.aspmx.l.google.com.\n\n;; Query time: 34 msec\n;; SERVER: 8.8.8.8#53(8.8.8.8)\n;; WHEN: Wed Oct 25 13:35:49 UTC 2023\n;; MSG SIZE rcvd: 154\n\n", + "stderr":"", + "rcode":"" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/forward_no_resolver.json.resp b/plugins/dig/unit_test/responses/forward_no_resolver.json.resp new file mode 100644 index 0000000000..5b41915cef --- /dev/null +++ b/plugins/dig/unit_test/responses/forward_no_resolver.json.resp @@ -0,0 +1,5 @@ +{ + "stdout":"\n; <<>> DiG 9.16.20 <<>> rapid7.com MX\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28119\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n; COOKIE: eea7f9fd1edc0167 (echoed)\n;; QUESTION SECTION:\n;rapid7.com.\t\t\tIN\tMX\n\n;; ANSWER SECTION:\nrapid7.com.\t\t377\tIN\tMX\t20 smtp002.rapid7.com.\nrapid7.com.\t\t377\tIN\tMX\t40 smtp001.rapid7.com.\n\n;; Query time: 112 msec\n;; SERVER: 192.168.65.7#53(192.168.65.7)\n;; WHEN: Thu Oct 26 09:14:07 UTC 2023\n;; MSG SIZE rcvd: 139\n\n", + "stderr":"", + "rcode":"" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/forward_raise_error.json.resp b/plugins/dig/unit_test/responses/forward_raise_error.json.resp new file mode 100644 index 0000000000..530255c7dc --- /dev/null +++ b/plugins/dig/unit_test/responses/forward_raise_error.json.resp @@ -0,0 +1,5 @@ +{ + "stdout": "{'all_answers': ['Not found'],'answer': 'Not found','fulloutput': 'Resolution failed, nameserver NO MATCHES FOUND returned NO MATCHES FOUND status','last_answer': 'Not found','nameserver': 'NO MATCHES FOUND','question': 'rapid7.com','status': 'NO MATCHES FOUND'}", + "stderr": "", + "rcode": "" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/reverse.json.resp b/plugins/dig/unit_test/responses/reverse.json.resp new file mode 100644 index 0000000000..82f6f13997 --- /dev/null +++ b/plugins/dig/unit_test/responses/reverse.json.resp @@ -0,0 +1,5 @@ +{ + "stdout":"\n; <<>> DiG 9.16.20 <<>> @8.8.8.8 -x 13.33.252.129\n; (1 server found)\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28936\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;129.252.33.13.in-addr.arpa.\tIN\tPTR\n\n;; ANSWER SECTION:\n129.252.33.13.in-addr.arpa. 21600 IN\tPTR\tserver-13-33-252-129.den50.r.cloudfront.net.\n\n;; Query time: 107 msec\n;; SERVER: 8.8.8.8#53(8.8.8.8)\n;; WHEN: Tue Oct 31 09:12:29 UTC 2023\n;; MSG SIZE rcvd: 112\n\n", + "stderr":"", + "rcode": "" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/reverse_no_resolver.json.resp b/plugins/dig/unit_test/responses/reverse_no_resolver.json.resp new file mode 100644 index 0000000000..6d0f706e56 --- /dev/null +++ b/plugins/dig/unit_test/responses/reverse_no_resolver.json.resp @@ -0,0 +1,5 @@ +{ + "stdout":"\n; <<>> DiG 9.16.20 <<>> -x 13.33.252.129\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58301\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n; COOKIE: cacd97b822b897c7 (echoed)\n;; QUESTION SECTION:\n;129.252.33.13.in-addr.arpa.\tIN\tPTR\n\n;; ANSWER SECTION:\n129.252.33.13.in-addr.arpa. 4502 IN\tPTR\tserver-13-33-252-129.den50.r.cloudfront.net.\n\n;; Query time: 35 msec\n;; SERVER: 192.168.65.7#53(192.168.65.7)\n;; WHEN: Tue Oct 31 09:34:15 UTC 2023\n;; MSG SIZE rcvd: 150\n\n", + "stderr":"", + "rcode":"" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/responses/reverse_raise_error.json.resp b/plugins/dig/unit_test/responses/reverse_raise_error.json.resp new file mode 100644 index 0000000000..6f3c6fb838 --- /dev/null +++ b/plugins/dig/unit_test/responses/reverse_raise_error.json.resp @@ -0,0 +1,5 @@ +{ + "stdout":"\n; <<>> DiG 9.16.20 <<>> @8 -x 13.33.252.129\n; (1 server found)\n;; global options: +cmd\n;; connection timed out; no servers could be reached\n\n", + "stderr":"", + "rcode":"9" +} \ No newline at end of file diff --git a/plugins/dig/unit_test/test_forward.py b/plugins/dig/unit_test/test_forward.py new file mode 100644 index 0000000000..ed711e3a19 --- /dev/null +++ b/plugins/dig/unit_test/test_forward.py @@ -0,0 +1,50 @@ +import sys +import os + +sys.path.append(os.path.abspath("../")) + +from komand_dig.connection.connection import Connection +from unittest import TestCase +from unittest.mock import patch, MagicMock +from parameterized import parameterized +from util import Util +from komand_dig.actions.forward import Forward +from insightconnect_plugin_runtime.exceptions import PluginException + + +@patch("insightconnect_plugin_runtime.helper.exec_command", side_effect=Util.mock_dig) +class TestForward(TestCase): + @classmethod + def setUpClass(cls) -> None: + cls.action = Util.default_connector(Forward()) + + @parameterized.expand( + [ + [ + "forward", + Util.read_file_to_dict("inputs/forward.json.inp"), + Util.read_file_to_dict("expected/forward.json.exp"), + ], + [ + "forward_no_resolver", + Util.read_file_to_dict("inputs/forward_no_resolver.json.inp"), + Util.read_file_to_dict("expected/forward_no_resolver.json.exp"), + ], + ] + ) + def test_forward(self, _mock_request: MagicMock, _test_name: str, input_params: dict, expected: dict): + actual = self.action.run(input_params) + self.assertEqual(actual, expected) + + @parameterized.expand( + [ + [ + "forward_raise_error", + Util.read_file_to_dict("inputs/forward_raise_error.json.inp"), + Util.read_file_to_dict("expected/forward_raise_error.json.exp"), + ] + ] + ) + def test_error(self, _mock_request: MagicMock, _test_name: str, input_params: dict, exp: dict): + actual = self.action.run(input_params) + self.assertEqual(actual, exp) diff --git a/plugins/dig/unit_test/test_reverse.py b/plugins/dig/unit_test/test_reverse.py new file mode 100644 index 0000000000..ea60fcee7c --- /dev/null +++ b/plugins/dig/unit_test/test_reverse.py @@ -0,0 +1,52 @@ +import sys +import os + +sys.path.append(os.path.abspath("../")) + +from komand_dig.connection.connection import Connection +from unittest import TestCase +from unittest.mock import patch, MagicMock +from parameterized import parameterized +from util import Util +from komand_dig.actions.reverse import Reverse +from insightconnect_plugin_runtime.exceptions import PluginException + + +@patch("insightconnect_plugin_runtime.helper.exec_command", side_effect=Util.mock_dig) +class TestReverse(TestCase): + @classmethod + def setUpClass(cls) -> None: + cls.action = Util.default_connector(Reverse()) + + @parameterized.expand( + [ + [ + "reverse", + Util.read_file_to_dict("inputs/reverse.json.inp"), + Util.read_file_to_dict("expected/reverse.json.exp"), + ], + [ + "reverse_no_resolver", + Util.read_file_to_dict("inputs/reverse_no_resolver.json.inp"), + Util.read_file_to_dict("expected/reverse_no_resolver.json.exp"), + ], + ] + ) + def test_reverse(self, _mock_request: MagicMock, _test_name: str, input_params: dict, expected: dict): + print(f"{input_params}") + print(f"{expected}") + actual = self.action.run(input_params) + self.assertEqual(actual, expected) + + @parameterized.expand( + [ + [ + "reverse_raise_error", + Util.read_file_to_dict("inputs/reverse_raise_error.json.inp"), + Util.read_file_to_dict("expected/reverse_raise_error.json.exp"), + ] + ] + ) + def test_error(self, _mock_request: MagicMock, _test_name: str, input_params: dict, exp: dict): + actual = self.action.run(input_params) + self.assertEqual(actual, exp) diff --git a/plugins/dig/unit_test/util.py b/plugins/dig/unit_test/util.py new file mode 100644 index 0000000000..1b1e7e63f9 --- /dev/null +++ b/plugins/dig/unit_test/util.py @@ -0,0 +1,63 @@ +import json +import os +import sys +import logging + +import insightconnect_plugin_runtime +from komand_dig.connection.connection import Connection + + +sys.path.append(os.path.abspath("../")) + + +class Util: + @staticmethod + def default_connector(action: insightconnect_plugin_runtime.Action, params: dict = None): + default_connection = Connection() + default_connection.logger = logging.getLogger("connection logger") + default_connection.connect(params) + action.connection = default_connection + action.logger = logging.getLogger("action logger") + return action + + @staticmethod + def read_file_to_dict(filename: str, encodingenabled: bool = False) -> dict: + with open( + os.path.join(os.path.dirname(os.path.realpath(__file__)), filename), "r", encoding="utf-8" + ) as file_reader: + data = json.load(file_reader) + if encodingenabled: + encodeddata = {} + for key, value in data.items(): + encodeddata[key] = value.encode("utf-8") + return encodeddata + else: + return data + + @staticmethod + def mock_dig(*args, **kwargs): + cmd = args[0] + if cmd == f"/usr/bin/dig @8.8.8.8 rapid7.com MX": + filename = "forward.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data + elif cmd == f"/usr/bin/dig rapid7.com MX": + filename = "forward_no_resolver.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data + elif cmd == f"/usr/bin/dig @8 rapid7.com MX": + filename = "forward_raise_error.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data + elif cmd == f"/usr/bin/dig @8.8.8.8 -x 13.33.252.129": + filename = "reverse.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data + elif cmd == f"/usr/bin/dig -x 13.33.252.129": + filename = "reverse_no_resolver.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data + elif cmd == f"/usr/bin/dig @8 -x 13.33.252.129": + filename = "reverse_raise_error.json.resp" + test_data = Util.read_file_to_dict(f"responses/{filename}", encodingenabled=True) + return test_data