check-msdefender 1.1.0__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/PKG-INFO +47 -13
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/README.md +36 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/check_msdefender.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/alerts.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/detail.py +1 -6
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/lastseen.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/machines.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/onboarding.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/vulnerabilities.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/decorators.py +1 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/handlers.py +0 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/alerts_service.py +2 -2
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/machines_service.py +1 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/models.py +1 -1
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/pyproject.toml +59 -11
- check_msdefender-1.1.2/tests/fixtures/alerts_data.json +72 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/mock_defender_client.py +1 -1
- check_msdefender-1.1.2/tests/fixtures/test_alerts_service.py +150 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/test_lastseen_service.py +3 -3
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/integration/test_cli_integration.py +1 -2
- check_msdefender-1.1.2/tests/unit/test_alerts_service.py +267 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/unit/test_detail_service.py +4 -3
- check_msdefender-1.1.0/.claude/settings.local.json +0 -19
- check_msdefender-1.1.0/.env.example +0 -10
- check_msdefender-1.1.0/.github/workflows/python-package.yml +0 -40
- check_msdefender-1.1.0/.github/workflows/python-publish.yml +0 -70
- check_msdefender-1.1.0/.gitignore +0 -6
- check_msdefender-1.1.0/.idea/.gitignore +0 -5
- check_msdefender-1.1.0/.idea/check_msdefender.iml +0 -13
- check_msdefender-1.1.0/.idea/dictionaries/project.xml +0 -7
- check_msdefender-1.1.0/.idea/encodings.xml +0 -4
- check_msdefender-1.1.0/.idea/inspectionProfiles/profiles_settings.xml +0 -6
- check_msdefender-1.1.0/.idea/misc.xml +0 -7
- check_msdefender-1.1.0/.idea/modules.xml +0 -8
- check_msdefender-1.1.0/.idea/runConfigurations/Integration_Tests.xml +0 -23
- check_msdefender-1.1.0/.idea/vcs.xml +0 -6
- check_msdefender-1.1.0/check_msdefender.egg-info/PKG-INFO +0 -396
- check_msdefender-1.1.0/check_msdefender.egg-info/SOURCES.txt +0 -85
- check_msdefender-1.1.0/check_msdefender.egg-info/dependency_links.txt +0 -1
- check_msdefender-1.1.0/check_msdefender.egg-info/entry_points.txt +0 -2
- check_msdefender-1.1.0/check_msdefender.egg-info/requires.txt +0 -12
- check_msdefender-1.1.0/check_msdefender.egg-info/top_level.txt +0 -1
- check_msdefender-1.1.0/check_msdefender.ini.example +0 -18
- check_msdefender-1.1.0/doc/Feat-Click-Decorators-ErrorHandlers-Formatters.md +0 -66
- check_msdefender-1.1.0/doc/Feat-Click-Groups.md +0 -126
- check_msdefender-1.1.0/doc/Feat-Enhance-MsDefender-Vulnerabilities-Output.md +0 -35
- check_msdefender-1.1.0/doc/Feat-Fixture-Tests.md +0 -40
- check_msdefender-1.1.0/doc/Feat-Integration-Tests.md +0 -21
- check_msdefender-1.1.0/doc/Feat-MsDefender-Alerts.md +0 -116
- check_msdefender-1.1.0/doc/Feat-MsDefender-DetailMachine.md +0 -78
- check_msdefender-1.1.0/doc/Feat-MsDefender-ListMachines.md +0 -87
- check_msdefender-1.1.0/doc/Feat-MsDefender.md +0 -110
- check_msdefender-1.1.0/doc/Feat-Nagios-Detailed-Output.md +0 -31
- check_msdefender-1.1.0/doc/Feat-Nagios-Exit-Code.md +0 -21
- check_msdefender-1.1.0/doc/Feat-Nagios-Output.md +0 -53
- check_msdefender-1.1.0/doc/Feat-Pypi-Package.md +0 -306
- check_msdefender-1.1.0/doc/Feat-Verbose.md +0 -39
- check_msdefender-1.1.0/pytest.ini +0 -6
- check_msdefender-1.1.0/requirements-dev.txt +0 -9
- check_msdefender-1.1.0/requirements.txt +0 -3
- check_msdefender-1.1.0/setup.cfg +0 -4
- check_msdefender-1.1.0/test_verbose.py +0 -29
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/LICENSE +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/__main__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/__main__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/cli/commands/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/auth.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/config.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/defender.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/exceptions.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/logging_config.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/core/nagios.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/detail_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/lastseen_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/onboarding_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/vulnerabilities_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/machine_data.json +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/test_detail_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/test_onboarding_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/test_vulnerabilities_service.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/fixtures/vulnerability_data.json +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/integration/__init__.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/integration/test_lastseen_integration.py +0 -0
- {check_msdefender-1.1.0 → check_msdefender-1.1.2}/tests/unit/__init__.py +0 -0
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: check-msdefender
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: A Nagios plugin for monitoring Microsoft Defender API endpoints
|
|
5
|
-
Author-email: ldvchosal <ldvchosal@github.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/lduchosal/check_msdefender
|
|
8
|
-
Project-URL: Bug Reports, https://github.com/lduchosal/check_msdefender/issues
|
|
9
|
-
Project-URL: Source, https://github.com/lduchosal/check_msdefender
|
|
10
|
-
Project-URL: Documentation, https://github.com/lduchosal/check_msdefender/blob/main/README.md
|
|
11
5
|
Keywords: nagios,monitoring,microsoft,graph,api,azure
|
|
6
|
+
Author-Email: ldvchosal <ldvchosal@github.com>
|
|
7
|
+
License: MIT
|
|
12
8
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
9
|
Classifier: Intended Audience :: System Administrators
|
|
14
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -19,9 +15,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
19
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
16
|
Classifier: Topic :: System :: Monitoring
|
|
21
17
|
Classifier: Topic :: System :: Systems Administration
|
|
18
|
+
Project-URL: Homepage, https://github.com/lduchosal/check_msdefender
|
|
19
|
+
Project-URL: Bug Reports, https://github.com/lduchosal/check_msdefender/issues
|
|
20
|
+
Project-URL: Source, https://github.com/lduchosal/check_msdefender
|
|
21
|
+
Project-URL: Documentation, https://github.com/lduchosal/check_msdefender/blob/main/README.md
|
|
22
22
|
Requires-Python: >=3.9
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
License-File: LICENSE
|
|
25
23
|
Requires-Dist: nagiosplugin>=1.4.0
|
|
26
24
|
Requires-Dist: azure-identity>=1.12.0
|
|
27
25
|
Requires-Dist: click<9.0,>=8.0
|
|
@@ -33,7 +31,8 @@ Requires-Dist: black>=21.0; extra == "dev"
|
|
|
33
31
|
Requires-Dist: flake8>=3.8; extra == "dev"
|
|
34
32
|
Requires-Dist: mypy>=0.800; extra == "dev"
|
|
35
33
|
Requires-Dist: twine>=6.2.0; extra == "dev"
|
|
36
|
-
|
|
34
|
+
Requires-Dist: pdm>=2.0.0; extra == "dev"
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
37
36
|
|
|
38
37
|
# 🛡️ Check MS Defender
|
|
39
38
|
|
|
@@ -46,7 +45,7 @@ A comprehensive **Nagios plugin** for monitoring Microsoft Defender for Endpoint
|
|
|
46
45
|
## ✨ Features
|
|
47
46
|
|
|
48
47
|
- 🔐 **Dual Authentication** - Support for Client Secret and Certificate-based authentication
|
|
49
|
-
- 🎯 **Multiple Endpoints** - Monitor onboarding status, last seen, vulnerabilities, and machine details
|
|
48
|
+
- 🎯 **Multiple Endpoints** - Monitor onboarding status, last seen, vulnerabilities, alerts, and machine details
|
|
50
49
|
- 📊 **Nagios Compatible** - Standard exit codes and performance data output
|
|
51
50
|
- 🏗️ **Clean Architecture** - Modular design with testable components
|
|
52
51
|
- 🔧 **Flexible Configuration** - File-based configuration with sensible defaults
|
|
@@ -78,6 +77,9 @@ check_msdefender lastseen -d machine.domain.tld -W 7 -C 30
|
|
|
78
77
|
# Check vulnerabilities
|
|
79
78
|
check_msdefender vulnerabilities -d machine.domain.tld -W 10 -C 100
|
|
80
79
|
|
|
80
|
+
# Check alerts
|
|
81
|
+
check_msdefender alerts -d machine.domain.tld -W 1 -C 5
|
|
82
|
+
|
|
81
83
|
# List all machines
|
|
82
84
|
check_msdefender machines
|
|
83
85
|
|
|
@@ -92,6 +94,7 @@ check_msdefender detail -d machine.domain.tld
|
|
|
92
94
|
| `onboarding` | Check machine onboarding status | W:1, C:2 |
|
|
93
95
|
| `lastseen` | Days since machine last seen | W:7, C:30 |
|
|
94
96
|
| `vulnerabilities` | Vulnerability score calculation | W:10, C:100 |
|
|
97
|
+
| `alerts` | Count of unresolved alerts | W:1, C:0 |
|
|
95
98
|
| `machines` | List all machines | W:10, C:25 |
|
|
96
99
|
| `detail` | Get detailed machine information | - |
|
|
97
100
|
|
|
@@ -103,6 +106,14 @@ The vulnerability score is calculated as:
|
|
|
103
106
|
- **Medium vulnerabilities** × 5
|
|
104
107
|
- **Low vulnerabilities** × 1
|
|
105
108
|
|
|
109
|
+
### Alert Monitoring
|
|
110
|
+
|
|
111
|
+
The alerts command monitors unresolved security alerts for a machine:
|
|
112
|
+
- **Counts only unresolved alerts** (status ≠ "Resolved")
|
|
113
|
+
- **Excludes informational alerts** when critical/warning alerts exist
|
|
114
|
+
- **Shows alert details** including creation time, title, and severity
|
|
115
|
+
- **Default thresholds**: Warning at 1 alert, Critical at 0 (meaning any alert triggers warning)
|
|
116
|
+
|
|
106
117
|
### Onboarding Status Values
|
|
107
118
|
|
|
108
119
|
- `0` - Onboarded ✅
|
|
@@ -145,6 +156,7 @@ timeout = 5
|
|
|
145
156
|
- `Machine.Read.All`
|
|
146
157
|
- `Vulnerability.Read`
|
|
147
158
|
- `Vulnerability.Read.All`
|
|
159
|
+
- `Alert.Read.All`
|
|
148
160
|
3. **Create Authentication** (Secret or Certificate)
|
|
149
161
|
4. **Note Credentials** (Client ID, Tenant ID, Secret/Certificate)
|
|
150
162
|
|
|
@@ -182,6 +194,11 @@ define command {
|
|
|
182
194
|
command_name check_defender_vulnerabilities
|
|
183
195
|
command_line $USER1$/check_msdefender/bin/check_msdefender vulnerabilities -d $HOSTALIAS$ -W 10 -C 100
|
|
184
196
|
}
|
|
197
|
+
|
|
198
|
+
define command {
|
|
199
|
+
command_name check_defender_alerts
|
|
200
|
+
command_line $USER1$/check_msdefender/bin/check_msdefender alerts -d $HOSTALIAS$ -W 1 -C 5
|
|
201
|
+
}
|
|
185
202
|
```
|
|
186
203
|
|
|
187
204
|
### Service Definitions
|
|
@@ -208,6 +225,13 @@ define service {
|
|
|
208
225
|
check_command check_defender_vulnerabilities
|
|
209
226
|
hostgroup_name msdefender
|
|
210
227
|
}
|
|
228
|
+
|
|
229
|
+
define service {
|
|
230
|
+
use generic-service
|
|
231
|
+
service_description DEFENDER_ALERTS
|
|
232
|
+
check_command check_defender_alerts
|
|
233
|
+
hostgroup_name msdefender
|
|
234
|
+
}
|
|
211
235
|
```
|
|
212
236
|
|
|
213
237
|
## 🏗️ Architecture
|
|
@@ -221,6 +245,7 @@ check_msdefender/
|
|
|
221
245
|
│ │ ├── onboarding.py # Onboarding status command
|
|
222
246
|
│ │ ├── lastseen.py # Last seen command
|
|
223
247
|
│ │ ├── vulnerabilities.py # Vulnerabilities command
|
|
248
|
+
│ │ ├── alerts.py # Alerts monitoring command
|
|
224
249
|
│ │ ├── machines.py # List machines command
|
|
225
250
|
│ │ └── detail.py # Machine detail command
|
|
226
251
|
│ ├── decorators.py # Common CLI decorators
|
|
@@ -236,6 +261,7 @@ check_msdefender/
|
|
|
236
261
|
│ ├── onboarding_service.py # Onboarding business logic
|
|
237
262
|
│ ├── lastseen_service.py # Last seen business logic
|
|
238
263
|
│ ├── vulnerabilities_service.py # Vulnerability business logic
|
|
264
|
+
│ ├── alerts_service.py # Alerts monitoring business logic
|
|
239
265
|
│ ├── machines_service.py # Machines business logic
|
|
240
266
|
│ ├── detail_service.py # Detail business logic
|
|
241
267
|
│ └── models.py # Data models
|
|
@@ -317,6 +343,14 @@ DEFENDER WARNING - Last seen: 10 days ago | lastseen=10;7;30;0;
|
|
|
317
343
|
DEFENDER CRITICAL - Vulnerability score: 150 (1 Critical, 5 High) | vulnerabilities=150;10;100;0;
|
|
318
344
|
```
|
|
319
345
|
|
|
346
|
+
### Alerts Warning
|
|
347
|
+
```
|
|
348
|
+
DEFENDER WARNING - Unresolved alerts for machine.domain.com | alerts=2;1;5;0;
|
|
349
|
+
Unresolved alerts for machine.domain.com
|
|
350
|
+
2025-09-14T10:22:14.12Z - Suspicious activity detected (New high)
|
|
351
|
+
2025-09-14T12:00:00.00Z - Malware detection (InProgress medium)
|
|
352
|
+
```
|
|
353
|
+
|
|
320
354
|
## 🔧 Troubleshooting
|
|
321
355
|
|
|
322
356
|
### Common Issues
|
|
@@ -393,4 +427,4 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
|
|
|
393
427
|
|
|
394
428
|
[🐛 Report Bug](https://github.com/lduchosal/check_msdefender/issues) • [💡 Request Feature](https://github.com/lduchosal/check_msdefender/issues) • [📖 Documentation](https://github.com/lduchosal/check_msdefender/blob/main/README.md)
|
|
395
429
|
|
|
396
|
-
</div>
|
|
430
|
+
</div>
|
|
@@ -9,7 +9,7 @@ A comprehensive **Nagios plugin** for monitoring Microsoft Defender for Endpoint
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
11
11
|
- 🔐 **Dual Authentication** - Support for Client Secret and Certificate-based authentication
|
|
12
|
-
- 🎯 **Multiple Endpoints** - Monitor onboarding status, last seen, vulnerabilities, and machine details
|
|
12
|
+
- 🎯 **Multiple Endpoints** - Monitor onboarding status, last seen, vulnerabilities, alerts, and machine details
|
|
13
13
|
- 📊 **Nagios Compatible** - Standard exit codes and performance data output
|
|
14
14
|
- 🏗️ **Clean Architecture** - Modular design with testable components
|
|
15
15
|
- 🔧 **Flexible Configuration** - File-based configuration with sensible defaults
|
|
@@ -41,6 +41,9 @@ check_msdefender lastseen -d machine.domain.tld -W 7 -C 30
|
|
|
41
41
|
# Check vulnerabilities
|
|
42
42
|
check_msdefender vulnerabilities -d machine.domain.tld -W 10 -C 100
|
|
43
43
|
|
|
44
|
+
# Check alerts
|
|
45
|
+
check_msdefender alerts -d machine.domain.tld -W 1 -C 5
|
|
46
|
+
|
|
44
47
|
# List all machines
|
|
45
48
|
check_msdefender machines
|
|
46
49
|
|
|
@@ -55,6 +58,7 @@ check_msdefender detail -d machine.domain.tld
|
|
|
55
58
|
| `onboarding` | Check machine onboarding status | W:1, C:2 |
|
|
56
59
|
| `lastseen` | Days since machine last seen | W:7, C:30 |
|
|
57
60
|
| `vulnerabilities` | Vulnerability score calculation | W:10, C:100 |
|
|
61
|
+
| `alerts` | Count of unresolved alerts | W:1, C:0 |
|
|
58
62
|
| `machines` | List all machines | W:10, C:25 |
|
|
59
63
|
| `detail` | Get detailed machine information | - |
|
|
60
64
|
|
|
@@ -66,6 +70,14 @@ The vulnerability score is calculated as:
|
|
|
66
70
|
- **Medium vulnerabilities** × 5
|
|
67
71
|
- **Low vulnerabilities** × 1
|
|
68
72
|
|
|
73
|
+
### Alert Monitoring
|
|
74
|
+
|
|
75
|
+
The alerts command monitors unresolved security alerts for a machine:
|
|
76
|
+
- **Counts only unresolved alerts** (status ≠ "Resolved")
|
|
77
|
+
- **Excludes informational alerts** when critical/warning alerts exist
|
|
78
|
+
- **Shows alert details** including creation time, title, and severity
|
|
79
|
+
- **Default thresholds**: Warning at 1 alert, Critical at 0 (meaning any alert triggers warning)
|
|
80
|
+
|
|
69
81
|
### Onboarding Status Values
|
|
70
82
|
|
|
71
83
|
- `0` - Onboarded ✅
|
|
@@ -108,6 +120,7 @@ timeout = 5
|
|
|
108
120
|
- `Machine.Read.All`
|
|
109
121
|
- `Vulnerability.Read`
|
|
110
122
|
- `Vulnerability.Read.All`
|
|
123
|
+
- `Alert.Read.All`
|
|
111
124
|
3. **Create Authentication** (Secret or Certificate)
|
|
112
125
|
4. **Note Credentials** (Client ID, Tenant ID, Secret/Certificate)
|
|
113
126
|
|
|
@@ -145,6 +158,11 @@ define command {
|
|
|
145
158
|
command_name check_defender_vulnerabilities
|
|
146
159
|
command_line $USER1$/check_msdefender/bin/check_msdefender vulnerabilities -d $HOSTALIAS$ -W 10 -C 100
|
|
147
160
|
}
|
|
161
|
+
|
|
162
|
+
define command {
|
|
163
|
+
command_name check_defender_alerts
|
|
164
|
+
command_line $USER1$/check_msdefender/bin/check_msdefender alerts -d $HOSTALIAS$ -W 1 -C 5
|
|
165
|
+
}
|
|
148
166
|
```
|
|
149
167
|
|
|
150
168
|
### Service Definitions
|
|
@@ -171,6 +189,13 @@ define service {
|
|
|
171
189
|
check_command check_defender_vulnerabilities
|
|
172
190
|
hostgroup_name msdefender
|
|
173
191
|
}
|
|
192
|
+
|
|
193
|
+
define service {
|
|
194
|
+
use generic-service
|
|
195
|
+
service_description DEFENDER_ALERTS
|
|
196
|
+
check_command check_defender_alerts
|
|
197
|
+
hostgroup_name msdefender
|
|
198
|
+
}
|
|
174
199
|
```
|
|
175
200
|
|
|
176
201
|
## 🏗️ Architecture
|
|
@@ -184,6 +209,7 @@ check_msdefender/
|
|
|
184
209
|
│ │ ├── onboarding.py # Onboarding status command
|
|
185
210
|
│ │ ├── lastseen.py # Last seen command
|
|
186
211
|
│ │ ├── vulnerabilities.py # Vulnerabilities command
|
|
212
|
+
│ │ ├── alerts.py # Alerts monitoring command
|
|
187
213
|
│ │ ├── machines.py # List machines command
|
|
188
214
|
│ │ └── detail.py # Machine detail command
|
|
189
215
|
│ ├── decorators.py # Common CLI decorators
|
|
@@ -199,6 +225,7 @@ check_msdefender/
|
|
|
199
225
|
│ ├── onboarding_service.py # Onboarding business logic
|
|
200
226
|
│ ├── lastseen_service.py # Last seen business logic
|
|
201
227
|
│ ├── vulnerabilities_service.py # Vulnerability business logic
|
|
228
|
+
│ ├── alerts_service.py # Alerts monitoring business logic
|
|
202
229
|
│ ├── machines_service.py # Machines business logic
|
|
203
230
|
│ ├── detail_service.py # Detail business logic
|
|
204
231
|
│ └── models.py # Data models
|
|
@@ -280,6 +307,14 @@ DEFENDER WARNING - Last seen: 10 days ago | lastseen=10;7;30;0;
|
|
|
280
307
|
DEFENDER CRITICAL - Vulnerability score: 150 (1 Critical, 5 High) | vulnerabilities=150;10;100;0;
|
|
281
308
|
```
|
|
282
309
|
|
|
310
|
+
### Alerts Warning
|
|
311
|
+
```
|
|
312
|
+
DEFENDER WARNING - Unresolved alerts for machine.domain.com | alerts=2;1;5;0;
|
|
313
|
+
Unresolved alerts for machine.domain.com
|
|
314
|
+
2025-09-14T10:22:14.12Z - Suspicious activity detected (New high)
|
|
315
|
+
2025-09-14T12:00:00.00Z - Malware detection (InProgress medium)
|
|
316
|
+
```
|
|
317
|
+
|
|
283
318
|
## 🔧 Troubleshooting
|
|
284
319
|
|
|
285
320
|
### Common Issues
|
|
@@ -16,7 +16,6 @@ def register_detail_commands(main_group: Any) -> None:
|
|
|
16
16
|
"""Register detail commands with the main CLI group."""
|
|
17
17
|
|
|
18
18
|
@main_group.command("detail")
|
|
19
|
-
@click.option("-i", "--id", "machine_id_alt", help="Machine ID (GUID)")
|
|
20
19
|
@common_options
|
|
21
20
|
def detail_cmd(
|
|
22
21
|
config: str,
|
|
@@ -25,7 +24,6 @@ def register_detail_commands(main_group: Any) -> None:
|
|
|
25
24
|
dns_name: Optional[str],
|
|
26
25
|
warning: Optional[float],
|
|
27
26
|
critical: Optional[float],
|
|
28
|
-
machine_id_alt: Optional[str],
|
|
29
27
|
) -> None:
|
|
30
28
|
"""Get detailed machine information from Microsoft Defender."""
|
|
31
29
|
try:
|
|
@@ -44,9 +42,6 @@ def register_detail_commands(main_group: Any) -> None:
|
|
|
44
42
|
# Create custom Nagios plugin for detail output
|
|
45
43
|
plugin = NagiosPlugin(service, "detail")
|
|
46
44
|
|
|
47
|
-
# Use -i option if provided, otherwise fallback to -m
|
|
48
|
-
final_machine_id = machine_id_alt or machine_id
|
|
49
|
-
|
|
50
45
|
# Set default thresholds for detail command to show proper performance data
|
|
51
46
|
# Based on expected test output patterns
|
|
52
47
|
if warning is not None and critical is None:
|
|
@@ -58,7 +53,7 @@ def register_detail_commands(main_group: Any) -> None:
|
|
|
58
53
|
|
|
59
54
|
# Execute check
|
|
60
55
|
result = plugin.check(
|
|
61
|
-
machine_id=
|
|
56
|
+
machine_id=machine_id,
|
|
62
57
|
dns_name=dns_name,
|
|
63
58
|
warning=warning,
|
|
64
59
|
critical=critical,
|
|
@@ -10,7 +10,7 @@ def common_options(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
10
10
|
"-c", "--config", default="check_msdefender.ini", help="Configuration file path"
|
|
11
11
|
)(func)
|
|
12
12
|
func = click.option("-v", "--verbose", count=True, help="Increase verbosity")(func)
|
|
13
|
-
func = click.option("-m", "--machine-id", help="Machine ID (GUID)")(func)
|
|
13
|
+
func = click.option("-m", "--machine-id", "-i", "--id", help="Machine ID (GUID)")(func)
|
|
14
14
|
func = click.option("-d", "--dns-name", help="Computer DNS Name (FQDN)")(func)
|
|
15
15
|
func = click.option("-W", "--warning", type=float, help="Warning threshold")(func)
|
|
16
16
|
func = click.option("-C", "--critical", type=float, help="Critical threshold")(func)
|
{check_msdefender-1.1.0 → check_msdefender-1.1.2}/check_msdefender/services/alerts_service.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Alerts service implementation."""
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
|
|
3
|
+
from typing import Dict, Optional, Any
|
|
4
|
+
|
|
5
5
|
from check_msdefender.core.exceptions import ValidationError
|
|
6
6
|
from check_msdefender.core.logging_config import get_verbose_logger
|
|
7
7
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = [
|
|
3
|
-
|
|
2
|
+
requires = [
|
|
3
|
+
"pdm-backend",
|
|
4
|
+
]
|
|
5
|
+
build-backend = "pdm.backend"
|
|
4
6
|
|
|
5
7
|
[project]
|
|
6
8
|
name = "check-msdefender"
|
|
7
|
-
version = "1.1.
|
|
9
|
+
version = "1.1.2"
|
|
8
10
|
authors = [
|
|
9
|
-
{name = "ldvchosal", email = "ldvchosal@github.com"},
|
|
11
|
+
{ name = "ldvchosal", email = "ldvchosal@github.com" },
|
|
10
12
|
]
|
|
11
13
|
description = "A Nagios plugin for monitoring Microsoft Defender API endpoints"
|
|
12
14
|
readme = "README.md"
|
|
13
|
-
license = {text = "MIT"}
|
|
14
15
|
requires-python = ">=3.9"
|
|
15
16
|
classifiers = [
|
|
16
17
|
"Development Status :: 5 - Production/Stable",
|
|
@@ -24,13 +25,23 @@ classifiers = [
|
|
|
24
25
|
"Topic :: System :: Monitoring",
|
|
25
26
|
"Topic :: System :: Systems Administration",
|
|
26
27
|
]
|
|
27
|
-
keywords = [
|
|
28
|
+
keywords = [
|
|
29
|
+
"nagios",
|
|
30
|
+
"monitoring",
|
|
31
|
+
"microsoft",
|
|
32
|
+
"graph",
|
|
33
|
+
"api",
|
|
34
|
+
"azure",
|
|
35
|
+
]
|
|
28
36
|
dependencies = [
|
|
29
37
|
"nagiosplugin>=1.4.0",
|
|
30
38
|
"azure-identity>=1.12.0",
|
|
31
|
-
"click>=8.0,<9.0"
|
|
39
|
+
"click>=8.0,<9.0",
|
|
32
40
|
]
|
|
33
41
|
|
|
42
|
+
[project.license]
|
|
43
|
+
text = "MIT"
|
|
44
|
+
|
|
34
45
|
[project.optional-dependencies]
|
|
35
46
|
dev = [
|
|
36
47
|
"pytest>=6.0",
|
|
@@ -40,6 +51,7 @@ dev = [
|
|
|
40
51
|
"flake8>=3.8",
|
|
41
52
|
"mypy>=0.800",
|
|
42
53
|
"twine>=6.2.0",
|
|
54
|
+
"pdm>=2.0.0",
|
|
43
55
|
]
|
|
44
56
|
|
|
45
57
|
[project.urls]
|
|
@@ -52,11 +64,15 @@ Documentation = "https://github.com/lduchosal/check_msdefender/blob/main/README.
|
|
|
52
64
|
check_msdefender = "check_msdefender.cli:main"
|
|
53
65
|
|
|
54
66
|
[tool.setuptools.package-data]
|
|
55
|
-
"*" = [
|
|
67
|
+
"*" = [
|
|
68
|
+
"*.ini",
|
|
69
|
+
]
|
|
56
70
|
|
|
57
71
|
[tool.black]
|
|
58
72
|
line-length = 100
|
|
59
|
-
target-version = [
|
|
73
|
+
target-version = [
|
|
74
|
+
"py39",
|
|
75
|
+
]
|
|
60
76
|
|
|
61
77
|
[tool.mypy]
|
|
62
78
|
python_version = "3.9"
|
|
@@ -65,8 +81,40 @@ warn_unused_configs = true
|
|
|
65
81
|
disallow_untyped_defs = true
|
|
66
82
|
|
|
67
83
|
[tool.pytest.ini_options]
|
|
68
|
-
testpaths = [
|
|
84
|
+
testpaths = [
|
|
85
|
+
"tests",
|
|
86
|
+
]
|
|
69
87
|
python_files = "test_*.py"
|
|
70
88
|
python_classes = "Test*"
|
|
71
89
|
python_functions = "test_*"
|
|
72
|
-
addopts = "-v"
|
|
90
|
+
addopts = "-v"
|
|
91
|
+
|
|
92
|
+
[tool.pdm.scripts]
|
|
93
|
+
format = "black ."
|
|
94
|
+
typecheck = "mypy check_msdefender/"
|
|
95
|
+
lint = "flake8 check_msdefender/"
|
|
96
|
+
build = "python -m build"
|
|
97
|
+
publish = "python -m twine upload dist/* --verbose"
|
|
98
|
+
test = "pytest -v tests/"
|
|
99
|
+
msdhelp = "check_msdefender --help"
|
|
100
|
+
msdmachines = "check_msdefender machines"
|
|
101
|
+
msdlastseen = "check_msdefender lastseen -d $MACHINE"
|
|
102
|
+
msddetail = "check_msdefender detail -d $MACHINE"
|
|
103
|
+
msdalerts = "check_msdefender alerts -d $MACHINE"
|
|
104
|
+
msdvulnerabilities = "check_msdefender vulnerabilities -d $MACHINE"
|
|
105
|
+
msdonboarding = "check_msdefender onboarding -d $MACHINE"
|
|
106
|
+
|
|
107
|
+
[tool.pdm.scripts.all]
|
|
108
|
+
composite = [
|
|
109
|
+
"format",
|
|
110
|
+
"build",
|
|
111
|
+
"test",
|
|
112
|
+
"typecheck",
|
|
113
|
+
"lint",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
[tool.pdm.scripts.msdall]
|
|
117
|
+
composite = [
|
|
118
|
+
"msdhelp",
|
|
119
|
+
"msdmachines",
|
|
120
|
+
]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"alerts": {
|
|
3
|
+
"value": [
|
|
4
|
+
{
|
|
5
|
+
"severity": "High",
|
|
6
|
+
"status": "New",
|
|
7
|
+
"title": "Suspicious activity detected",
|
|
8
|
+
"alertCreationTime": "2025-09-14T10:22:14.12Z",
|
|
9
|
+
"firstEventTime": "2025-09-14T10:22:13.7175652Z",
|
|
10
|
+
"lastEventTime": "2025-09-14T10:22:13.7175652Z",
|
|
11
|
+
"lastUpdateTime": "2025-09-14T10:24:04.42Z",
|
|
12
|
+
"machineId": "test-machine-1",
|
|
13
|
+
"computerDnsName": "test-machine-1.domain.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"severity": "Informational",
|
|
17
|
+
"status": "New",
|
|
18
|
+
"title": "Automated investigation started manually",
|
|
19
|
+
"alertCreationTime": "2025-09-12T21:22:14.12Z",
|
|
20
|
+
"firstEventTime": "2025-09-12T21:22:13.7175652Z",
|
|
21
|
+
"lastEventTime": "2025-09-12T21:22:13.7175652Z",
|
|
22
|
+
"lastUpdateTime": "2025-09-13T01:24:04.42Z",
|
|
23
|
+
"machineId": "test-machine-1",
|
|
24
|
+
"computerDnsName": "test-machine-1.domain.com"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"severity": "Medium",
|
|
28
|
+
"status": "Resolved",
|
|
29
|
+
"title": "Malware detected and remediated",
|
|
30
|
+
"alertCreationTime": "2025-09-10T15:30:45.67Z",
|
|
31
|
+
"firstEventTime": "2025-09-10T15:30:44.1234567Z",
|
|
32
|
+
"lastEventTime": "2025-09-10T15:30:44.1234567Z",
|
|
33
|
+
"lastUpdateTime": "2025-09-11T09:15:22.89Z",
|
|
34
|
+
"machineId": "test-machine-1",
|
|
35
|
+
"computerDnsName": "test-machine-1.domain.com"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"severity": "Informational",
|
|
39
|
+
"status": "Resolved",
|
|
40
|
+
"title": "Automated investigation completed",
|
|
41
|
+
"alertCreationTime": "2025-09-11T15:25:38.54Z",
|
|
42
|
+
"firstEventTime": "2025-09-11T15:25:38.1183588Z",
|
|
43
|
+
"lastEventTime": "2025-09-11T15:25:38.1183588Z",
|
|
44
|
+
"lastUpdateTime": "2025-09-12T11:05:46.9966667Z",
|
|
45
|
+
"machineId": "test-machine-2",
|
|
46
|
+
"computerDnsName": "test-machine-2.domain.com"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"severity": "Low",
|
|
50
|
+
"status": "New",
|
|
51
|
+
"title": "Suspicious file execution",
|
|
52
|
+
"alertCreationTime": "2025-09-13T08:15:22.33Z",
|
|
53
|
+
"firstEventTime": "2025-09-13T08:15:21.9876543Z",
|
|
54
|
+
"lastEventTime": "2025-09-13T08:15:21.9876543Z",
|
|
55
|
+
"lastUpdateTime": "2025-09-13T08:20:11.11Z",
|
|
56
|
+
"machineId": "test-machine-3",
|
|
57
|
+
"computerDnsName": "test-machine-3.domain.com"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"severity": "Informational",
|
|
61
|
+
"status": "InProgress",
|
|
62
|
+
"title": "Manual investigation in progress",
|
|
63
|
+
"alertCreationTime": "2025-09-14T12:45:30.77Z",
|
|
64
|
+
"firstEventTime": "2025-09-14T12:45:29.1111111Z",
|
|
65
|
+
"lastEventTime": "2025-09-14T12:45:29.1111111Z",
|
|
66
|
+
"lastUpdateTime": "2025-09-14T13:00:15.55Z",
|
|
67
|
+
"machineId": "test-machine-2",
|
|
68
|
+
"computerDnsName": "test-machine-2.domain.com"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|