Skip to content

Commit

Permalink
Greynoise unit test fix (#2983)
Browse files Browse the repository at this point in the history
* Fix unit tests

* Update SDK

* Fix final unit test

* Last unit tests fix hopefully
  • Loading branch information
cmcnally-r7 authored and Dympna Laverty committed Dec 11, 2024
1 parent 6f839b7 commit c713fa2
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 174 deletions.
2 changes: 1 addition & 1 deletion plugins/greynoise/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "e8f3a3060f1800fcad0ffc216c09d193",
"spec": "408dee8094333da675fded694bdef341",
"manifest": "9d3f4a959fda3eb80588c86648597b40",
"setup": "7d0148b4efc7745f17003a77e9e73c55",
"schemas": [
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.2.0
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.2.2

LABEL organization=greynoise
LABEL sdk=python
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/plugin.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ connection_version: 2
cloud_ready: false
sdk:
type: slim
version: 6.2.0
version: 6.2.2
user: nobody
supported_versions: ["GreyNoise API v1/2/3"]
vendor: greynoise
Expand Down
Empty file.
66 changes: 32 additions & 34 deletions plugins/greynoise/unit_test/payloads/similar_ip.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
[
{
"ip": {
"actor": "Acme Inc",
{
"ip": {
"actor": "Acme Inc",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"first_seen": "2019-07-29",
"ip": "1.2.3.4",
"last_seen": "2024-11-04",
"organization": "Acme Inc"
},
"similar_ips": [
{
"actor": "Alpha Strike Labs",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"first_seen": "2019-07-29",
"ip": "1.2.3.4",
"features": [
"hassh_fp",
"mass_scan_bool",
"os",
"ports",
"useragents",
"web_paths"
],
"first_seen": "2019-07-11",
"ip": "2.3.4.5",
"last_seen": "2024-11-04",
"organization": "Acme Inc"
},
"similar_ips": [
{
"actor": "Alpha Strike Labs",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"features": [
"hassh_fp",
"mass_scan_bool",
"os",
"ports",
"useragents",
"web_paths"
],
"first_seen": "2019-07-11",
"ip": "2.3.4.5",
"last_seen": "2024-11-04",
"organization": "Acme Inc",
"score": 0.98933446
}
],
"total": 1
}
]
"organization": "Acme Inc",
"score": 0.98933446
}
],
"total": 1
}
114 changes: 56 additions & 58 deletions plugins/greynoise/unit_test/payloads/timeline_ip.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
[
{
"activity": [
{
"asn": "AS12345",
"category": "hosting",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"destinations": [
{
"country": "South Africa",
"country_code": "ZA"
}
],
"hassh_fingerprints": [],
"http_paths": [
"/favicon.ico"
],
"http_user_agents": [
"Mozilla/5.0"
],
"ja3_fingerprints": [
"04b3f524166caafd433b6864250945be"
],
"organization": "Alpha Strike Labs GmbH",
"protocols": [
{
"port": 80,
"transport_protocol": "TCP"
}
],
"rdns": "",
"region": "Berlin",
"spoofable": true,
"tags": [
{
"category": "actor",
"description": "description.",
"intention": "benign",
"name": "Acme, Inc."
}
],
"timestamp": "2024-11-03T00:00:00Z",
"tor": false,
"vpn": false,
"vpn_service": ""
}
],
"ip": "1.2.3.4",
"metadata": {
"end_time": "2024-11-04T19:13:35.892189739Z",
"ip": "1.2.3.4",
"limit": 50,
"next_cursor": "",
"start_time": "2024-11-03T00:00:00Z"
{
"activity": [
{
"asn": "AS12345",
"category": "hosting",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"destinations": [
{
"country": "South Africa",
"country_code": "ZA"
}
],
"hassh_fingerprints": [],
"http_paths": [
"/favicon.ico"
],
"http_user_agents": [
"Mozilla/5.0"
],
"ja3_fingerprints": [
"04b3f524166caafd433b6864250945be"
],
"organization": "Alpha Strike Labs GmbH",
"protocols": [
{
"port": 80,
"transport_protocol": "TCP"
}
],
"rdns": "",
"region": "Berlin",
"spoofable": true,
"tags": [
{
"category": "actor",
"description": "description.",
"intention": "benign",
"name": "Acme, Inc."
}
],
"timestamp": "2024-11-03T00:00:00Z",
"tor": false,
"vpn": false,
"vpn_service": ""
}
],
"ip": "1.2.3.4",
"metadata": {
"end_time": "2024-11-04T19:13:35.892189739Z",
"ip": "1.2.3.4",
"limit": 50,
"next_cursor": "",
"start_time": "2024-11-03T00:00:00Z"
}
]
}
2 changes: 1 addition & 1 deletion plugins/greynoise/unit_test/test_community_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.community_lookup import CommunityLookup

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestCommunityLookup(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/unit_test/test_context_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.context_lookup import ContextLookup

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestContextLookup(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/unit_test/test_get_tag_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.get_tag_details import GetTagDetails

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestGetTagDetails(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions plugins/greynoise/unit_test/test_gnql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.gnql_query import GnqlQuery

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestGnqlQuery(TestCase):
Expand Down Expand Up @@ -61,7 +61,6 @@ def test_gnql_query(self, mock_get):
],
"message": "ok",
"query": "query",
"scroll": "token",
}

self.assertNotEqual({}, results, "returns non - empty results")
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/unit_test/test_quick_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.quick_lookup import QuickLookup

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestQuickLookup(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion plugins/greynoise/unit_test/test_riot_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.riot_lookup import RiotLookup

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestRiotLookup(TestCase):
Expand Down
52 changes: 25 additions & 27 deletions plugins/greynoise/unit_test/test_similar_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from icon_greynoise.actions.similar_lookup import SimilarLookup

from unit_test.util import MockConnection, mocked_requests_get
from util import MockConnection, mocked_requests_get


class TestSimilarLookup(TestCase):
Expand All @@ -16,39 +16,37 @@ def test_similar_lookup(self, mock_get):

working_params = {"ip_address": "similar_lookup"}
results = test_similar.run(working_params)
expected = [
{
"ip": {
"actor": "Acme Inc",
expected = {
"ip": {
"actor": "Acme Inc",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"first_seen": "2019-07-29",
"ip": "1.2.3.4",
"last_seen": "2024-11-04",
"organization": "Acme Inc",
},
"similar_ips": [
{
"actor": "Alpha Strike Labs",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"first_seen": "2019-07-29",
"ip": "1.2.3.4",
"features": ["hassh_fp", "mass_scan_bool", "os", "ports", "useragents", "web_paths"],
"first_seen": "2019-07-11",
"ip": "2.3.4.5",
"last_seen": "2024-11-04",
"organization": "Acme Inc",
},
"similar_ips": [
{
"actor": "Alpha Strike Labs",
"asn": "AS12345",
"city": "Berlin",
"classification": "benign",
"country": "Germany",
"country_code": "DE",
"features": ["hassh_fp", "mass_scan_bool", "os", "ports", "useragents", "web_paths"],
"first_seen": "2019-07-11",
"ip": "2.3.4.5",
"last_seen": "2024-11-04",
"organization": "Acme Inc",
"score": 0.98933446,
}
],
"total": 1,
}
]
"score": 0.98933446,
}
],
"total": 1,
}

self.assertNotEqual({}, results, "returns non - empty results")
self.assertEqual(expected, results)
Loading

0 comments on commit c713fa2

Please sign in to comment.