Skip to content

Commit b5e052a

Browse files
authored
Updating CountryName to CountryOrRegionName (#796)
* Updating CountryName to CountryOrRegionName Fixing test data and tests. Updating version * Remove unneeded importlib-resources from setup.py * Suppressing flake8 objections to method capitalization
1 parent 2a81450 commit b5e052a

File tree

10 files changed

+28
-17
lines changed

10 files changed

+28
-17
lines changed

msticpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version file."""
22

3-
VERSION = "2.12.0"
3+
VERSION = "2.13.0"

msticpy/analysis/syslog_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def create_host_record(
9797
ip_entity = IpAddress()
9898
ip_entity.Address = host_hb["ComputerIP"]
9999
geoloc_entity = GeoLocation()
100-
geoloc_entity.CountryName = host_hb["RemoteIPCountry"] # type: ignore
100+
geoloc_entity.CountryOrRegionName = host_hb["RemoteIPCountry"] # type: ignore
101101
geoloc_entity.Longitude = host_hb["RemoteIPLongitude"] # type: ignore
102102
geoloc_entity.Latitude = host_hb["RemoteIPLatitude"] # type: ignore
103103
ip_entity.Location = geoloc_entity # type: ignore

msticpy/context/geoip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def _create_ip_entity(ip_loc: dict, ip_entity) -> IpAddress:
301301
geo_entity = GeoLocation()
302302
geo_entity.CountryCode = ip_loc["country_code"]
303303

304-
geo_entity.CountryName = ip_loc["country_name"]
304+
geo_entity.CountryOrRegionName = ip_loc["country_name"]
305305
geo_entity.State = ip_loc["region_name"]
306306
geo_entity.City = ip_loc["city"]
307307
geo_entity.Longitude = ip_loc["longitude"]
@@ -554,7 +554,7 @@ def _create_ip_entity(
554554
ip_entity.Address = ip_address
555555
geo_entity = GeoLocation()
556556
geo_entity.CountryCode = geo_match.get("country", {}).get("iso_code", None)
557-
geo_entity.CountryName = (
557+
geo_entity.CountryOrRegionName = (
558558
geo_match.get("country", {}).get("names", {}).get("en", None)
559559
)
560560
subdivs = geo_match.get("subdivisions", [])

msticpy/context/ip_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def create_ip_record(
192192
ip_entity.VMUUID = ip_hb["VMUUID"] # type: ignore
193193
ip_entity.SubscriptionId = ip_hb["SubscriptionId"] # type: ignore
194194
geoloc_entity = GeoLocation() # type: ignore
195-
geoloc_entity.CountryName = ip_hb["RemoteIPCountry"] # type: ignore
195+
geoloc_entity.CountryOrRegionName = ip_hb["RemoteIPCountry"] # type: ignore
196196
geoloc_entity.Longitude = ip_hb["RemoteIPLongitude"] # type: ignore
197197
geoloc_entity.Latitude = ip_hb["RemoteIPLatitude"] # type: ignore
198198
ip_entity.Location = geoloc_entity # type: ignore

msticpy/context/tiproviders/ip_quality_score.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def parse_results(self: Self, response: dict) -> tuple[bool, ResultSeverity, Any
7070
"FraudScore": response["RawResult"].get("fraud_score"),
7171
"ISP": response["RawResult"].get("ISP"),
7272
"ASN": response["RawResult"].get("ASN"),
73-
"Country": response["RawResult"].get("country_code"),
73+
"CountryOrRegion": response["RawResult"].get("country_code"),
7474
"Region": response["RawResult"].get("city"),
7575
"City": response["RawResult"].get("region"),
7676
"Organization": response["RawResult"].get("organization"),

msticpy/datamodel/entities/geo_location.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class GeoLocation(Entity, ContextObject):
2626
----------
2727
CountryCode : str
2828
GeoLocation CountryCode
29-
CountryName : str
29+
CountryOrRegionName : str
3030
GeoLocation CountryName
3131
State : str
3232
GeoLocation State
@@ -62,7 +62,7 @@ def __init__(self, src_entity: Mapping[str, Any] = None, **kwargs):
6262
6363
"""
6464
self.CountryCode: Optional[str] = None
65-
self.CountryName: Optional[str] = None
65+
self.CountryOrRegionName: Optional[str] = None
6666
self.State: Optional[str] = None
6767
self.City: Optional[str] = None
6868
self.Longitude: Optional[float] = None
@@ -80,6 +80,16 @@ def name_str(self) -> str:
8080
"""Return Entity Name."""
8181
return self.CountryCode or self.__class__.__name__
8282

83+
@property
84+
def CountryName(self) -> Optional[str]: # noqa: N802
85+
"""Return CountryName."""
86+
return self.CountryOrRegionName
87+
88+
@CountryName.setter
89+
def CountryName(self, value: str): # noqa: N802
90+
"""Set CountryName."""
91+
self.CountryOrRegionName = value
92+
8393
@property
8494
def coordinates(self) -> Tuple[float, float]:
8595
"""Return Latitude/Longitude as a tuple of floats."""
@@ -91,7 +101,7 @@ def coordinates(self) -> Tuple[float, float]:
91101
# str
92102
"CountryCode": None,
93103
# str
94-
"CountryName": None,
104+
"CountryOrRegionName": None,
95105
# str
96106
"State": None,
97107
# str

msticpy/vis/foliummap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,8 @@ def icon_mapper(icon_key):
744744
tooltip_columns = _default_columns(data, [ip_column, "CountryCode", "City"])
745745
if not popup_columns:
746746
popup_columns = _default_columns(
747-
data, [ip_column, "CountryName", "City", lat_column, long_column]
747+
data,
748+
[ip_column, "CountryOrRegionName", "City", lat_column, long_column],
748749
)
749750
else:
750751
if not tooltip_columns:

tests/init/pivot/test_pivot_register.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def data_providers():
227227
pivot_func="geoloc",
228228
func_param="value",
229229
src_col="ip",
230-
exp_col="CountryName",
230+
exp_col="CountryOrRegionName",
231231
exp_val="United States",
232232
),
233233
id="IpAddress-geoip_maxmind",
@@ -243,7 +243,7 @@ def data_providers():
243243
# pivot_func="geoloc_ips",
244244
# func_param="value",
245245
# src_col="ip",
246-
# exp_col="CountryName",
246+
# exp_col="CountryOrRegionName",
247247
# exp_val="United States",
248248
# ),
249249
# id="IpAddress-geoip_ipstack",

tests/testdata/ip_locs.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
,AllExtIPs,AdditionalData,Type,CountryCode,CountryName,State,City,Longitude,Latitude,IpAddress
1+
,AllExtIPs,AdditionalData,Type,CountryCode,CountryOrRegionName,State,City,Longitude,Latitude,IpAddress
22
0,65.55.44.109,{},geolocation,US,United States,Virginia,Boydton,-78.375,36.6534,65.55.44.109
33
1,13.71.172.128,{},geolocation,CA,Canada,Ontario,Toronto,-79.4195,43.6644,13.71.172.128
44
2,13.71.172.130,{},geolocation,CA,Canada,Ontario,Toronto,-79.4195,43.6644,13.71.172.130

tests/vis/test_folium.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def create_geo_entity(row):
222222
"""Return GeoLocation entity - test helper."""
223223
# get subset of fields for GeoLocation
224224
loc_props = row[
225-
["CountryCode", "CountryName", "State", "City", "Longitude", "Latitude"]
225+
["CountryCode", "CountryOrRegionName", "State", "City", "Longitude", "Latitude"]
226226
]
227227
return GeoLocation(**loc_props.to_dict())
228228

@@ -242,7 +242,7 @@ def icon_map_func(key):
242242
_IP_COL = "AllExtIPs"
243243
_LAT_COL = "Latitude"
244244
_LONG_COL = "Longitude"
245-
_COUNTRY_COL = "CountryName"
245+
_COUNTRY_COL = "CountryOrRegionName"
246246

247247

248248
@attr.s(auto_attribs=True)
@@ -272,8 +272,8 @@ class PlotMapTest:
272272
(PlotMapTest(name="layer", **_STD_ARGS, layer_column=_COUNTRY_COL)), # type: ignore
273273
(PlotMapTest(name="icon_dict", **_STD_ARGS, icon_column=_COUNTRY_COL, icon_map=icon_map)), # type: ignore
274274
(PlotMapTest(name="icon_map", **_STD_ARGS, icon_column=_COUNTRY_COL, icon_map=icon_map_func)), # type: ignore
275-
(PlotMapTest(name="popup", **_STD_ARGS, popup_columns=["CountryName", "State", "City"])), # type: ignore
276-
(PlotMapTest(name="tooltip", **_STD_ARGS, tooltip_columns=["CountryName", "State", "City"])), # type: ignore
275+
(PlotMapTest(name="popup", **_STD_ARGS, popup_columns=["CountryOrRegionName", "State", "City"])), # type: ignore
276+
(PlotMapTest(name="tooltip", **_STD_ARGS, tooltip_columns=["CountryOrRegionName", "State", "City"])), # type: ignore
277277
]
278278

279279
_PM_IDS = [pmt.name for pmt in _PM_TEST_PARAMS]

0 commit comments

Comments
 (0)