9.5.10. plugins/plugin_trendmicro.pyΒΆ

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
from collections import OrderedDict

VERSION = "1.1.0"
"""Version of this set of plugin definitions."""

MINIMUM_THAT_VERSION = "1.1.0"
"""Minimum THAT version required to run these plugin definitions."""

NAME = "trendmicro"
PRIORITY = 5
ANALYZE_DATA = OrderedDict()
GET_TANIUM_DATA = OrderedDict()

GET_INTERNET_DATA = [
]

# ask the question 'Get Installed Applications contains "trend micro" from all machines'
# and store results in "trendmicro.csv"
GET_TANIUM_DATA["trendmicro.csv"] = {
    "filters": [],
    "sensors": ["Installed Applications, that contains:trend micro"],
}

# ask the question 'Get Online from all machines'
# and store results in "trendmicrotargets.csv"
GET_TANIUM_DATA["trendmicrotargets.csv"] = {
    "filters": ["Is Windows, that contains:True"],
    "sensors": ["Online"],
}

# ask the question 'Get Trend Micro Client Version from all machines'
# and store results in "trendversion.csv"
GET_TANIUM_DATA["trendversion.csv"] = {
    "filters": [],
    "sensors": ["Trend Micro Client Version"],
}

# ask the question 'Get Trend Micro Pattern Days Old from all machines'
# and store results in "trendpatdaysold.csv"
GET_TANIUM_DATA["trendpatdaysold.csv"] = {
    "filters": [],
    "sensors": ["Trend Micro Pattern Days Old"],
}

# ask the question 'Get Trend Micro Pattern Version from all machines'
# and store results in "trendpatver.csv"
GET_TANIUM_DATA["trendpatver.csv"] = {
    "filters": [],
    "sensors": ["Trend Micro Pattern Version"],
}

ANALYZE_DATA["cleaned_trend_df"] = """
# clean out noise from trendmicro.csv

csv = "trendmicro.csv"
df = self.load_csv_as_df(csv)

result = self.clean_df(df, columns=["Name"])
"""

ANALYZE_DATA["cleaned_trendversion_df"] = """
# clean out noise from trendversion.csv

csv = "trendversion.csv"
df = self.load_csv_as_df(csv)

result = self.clean_df(df, columns=["Trend Micro Client Version"])
"""

ANALYZE_DATA["cleaned_trendpatdaysold_df"] = """
# clean out noise from trendpatdaysold.csv

csv = "trendpatdaysold.csv"
df = self.load_csv_as_df(csv)

result = self.clean_df(df, columns=["Trend Micro Pattern Days Old"])
"""

ANALYZE_DATA["cleaned_trendpatver_df"] = """
# clean out noise from trendpatver.csv

csv = "trendpatver.csv"
df = self.load_csv_as_df(csv)

result = self.clean_df(df, columns=["Trend Micro Pattern Version"])
"""

ANALYZE_DATA["trendmicro_targets"] = """
# Total Number of Scanned Endpoints for TrendMicro Products

csv = "trendmicrotargets.csv"
df = self.load_csv_as_df(csv)

result = self.force_int(df['Count'].sum(), 0)
"""

ANALYZE_DATA["product_count"] = """
# get total count of TrendMicro products installed across endpoints

df = self.get_result("cleaned_trend_df")

result = self.force_int(len(df['Name'].unique()), 0)
"""

ANALYZE_DATA["install_count"] = """
# get total number of times TrendMicro products installed across all endpoints

df = self.get_result("cleaned_trend_df")

result = self.force_int(df['Count'].sum(), 0)
"""

ANALYZE_DATA["install_avg"] = """
# average TrendMicro installs per endpoint

trendmicro_targets = self.get_result("trendmicro_targets")

install_count = self.get_result("install_count")

if trendmicro_targets > 0:
    if (float(install_count) / float(trendmicro_targets)) < 1:
        result = math.ceil(float(install_count) / float(trendmicro_targets))
    else:
        result = float(install_count) / float(trendmicro_targets)
else:
    result = 0

result = self.force_int(int(result), 0)
"""

ANALYZE_DATA["not_installed"] = """
# total number endpoints missing TrendMicro (Not Installed)

df = self.get_result("cleaned_trendversion_df")
col = 'Trend Micro Client Version'

result = self.force_int(df.loc[df[col] == 'Not installed', 'Count'].sum(), 0)
"""

ANALYZE_DATA["versions_installed"] = """
# number of TrendMicro Versions Detected

df = self.get_result("cleaned_trendversion_df")
col = 'Trend Micro Client Version'

result = self.force_int(len(df.loc[df[col] != 'Not installed']), 0)
"""

ANALYZE_DATA["oldest_pat_days"] = """
# TrendMicro Patterns Days Old (Oldest)

df = self.get_result("cleaned_trendpatdaysold_df")
col = 'Trend Micro Pattern Days Old'

val = df.loc[df[col] != 'Not installed', col].max()
result = self.force_int(val, 0) if val is not numpy.nan else "N/A"
"""

ANALYZE_DATA["pat_versions"] = """
# Number of Detected TrendMicro Pattern Versions

df = self.get_result("cleaned_trendpatver_df")
col = 'Trend Micro Pattern Version'

result = self.force_int(len(df.loc[df[col] != 'Not installed']), 0)
"""

ANALYZE_DATA["versions_installed_df"] = """
# Data frame with all versions installed

df = self.get_result("cleaned_trendpatver_df")
col = 'Trend Micro Pattern Version'

result = df.loc[df[col] != 'Not installed']
"""

ANALYZE_DATA["newest_version"] = """
# Latest version of version installed

df = self.get_result("versions_installed_df")
col = 'Trend Micro Pattern Version'

val = df[col].max()
result = val if val is not numpy.nan else "N/A"
"""

ANALYZE_DATA["old_pat_versions_ep"] = """
# Number of Endpoints with "older" TrendMicro Pattern Versions

df = self.get_result("versions_installed_df")
newest_ver = self.get_result("newest_version")
col = 'Trend Micro Pattern Version'

result = self.force_int(df.loc[df[col] != newest_ver, 'Count'].sum(), 0)
"""