4040
4141@dataclass (frozen = True )
4242class TokenInfo :
43- token_id : str
4443 token_appleid : str
45- token_state : str
4644 token_expiration : str
45+ token_id : str
46+ token_name : str
47+ token_state : str
4748
4849
4950# Example data from special agent:
5051# <<<ms_intune_apple_vpp_tokens:sep(0)>>>
5152# [
5253# {
53- # "token_id": "00000000-0000-0000-0000-000000000000",
54- # "token_appleid": "vpp@domain.td",
55- # "token_state": "valid",
56- # "token_expiration": "2025-03-02T06:54:05Z"
57- # },
58- # {
59- # "token_id": "00000000-0000-0000-0000-000000000001",
6054# "token_appleid": "vpp@domain.td",
61- # "token_state": "valid",
6255# "token_expiration": "2025-03-02T06:54:05Z"
56+ # "token_id": "00000000-0000-0000-0000-000000000000",
57+ # "token_name": "valid",
58+ # "token_state": "Token 1",
6359# },
6460# ...
6561# ]
@@ -69,8 +65,18 @@ class TokenInfo:
6965
7066def parse_ms_intune_apple_vpp_tokens (string_table : StringTable ) -> Section :
7167 parsed = {}
68+ token_names = set ()
7269 for item in json .loads ("" .join (string_table [0 ])):
73- parsed [item ["token_id" ]] = item
70+ token_name = item ["token_name" ]
71+ # generate unique names, because token name is not unique
72+ if token_name in token_names :
73+ token_name_unique = f"{ token_name } _{ item ["token_id" ][- 4 :]} "
74+ else :
75+ token_name_unique = token_name
76+ token_names .add (token_name )
77+
78+ parsed [token_name_unique ] = item
79+
7480 return parsed
7581
7682
@@ -87,8 +93,10 @@ def check_ms_intune_apple_vpp_tokens(item: str, params: Mapping[str, Any], secti
8793 params_levels_token_expiration = params .get ("token_expiration" )
8894
8995 token_appleid = token ["token_appleid" ]
90- token_state = token ["token_state" ]
9196 token_expiration = token ["token_expiration" ]
97+ token_id = token ["token_id" ]
98+ token_name = token ["token_name" ]
99+ token_state = token ["token_state" ]
92100
93101 token_expiration_datetime = datetime .fromisoformat (token_expiration )
94102 token_expiration_timestamp = token_expiration_datetime .timestamp ()
@@ -98,8 +106,10 @@ def check_ms_intune_apple_vpp_tokens(item: str, params: Mapping[str, Any], secti
98106
99107 result_details = (
100108 f"Expiration time: { token_expiration_timestamp_render } "
101- f"\\ nState: { token_state } "
109+ f"\\ nToken name: { token_name } "
110+ f"\\ nToken ID: { token_id } "
102111 f"\\ nApple ID: { token_appleid } "
112+ f"\\ nState: { token_state } "
103113 )
104114 result_summary = f"Expiration time: { token_expiration_timestamp_render } , State: { token_state } "
105115
@@ -140,7 +150,7 @@ def check_ms_intune_apple_vpp_tokens(item: str, params: Mapping[str, Any], secti
140150
141151check_plugin_ms_intune_apple_vpp_tokens = CheckPlugin (
142152 name = "ms_intune_apple_vpp_tokens" ,
143- service_name = "Intune VPP token %s" ,
153+ service_name = "Intune Apple VPP token %s" ,
144154 discovery_function = discover_ms_intune_apple_vpp_tokens ,
145155 check_function = check_ms_intune_apple_vpp_tokens ,
146156 check_ruleset_name = "ms_intune_apple_vpp_tokens" ,
0 commit comments