airmdr 0.1.0__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.
- airmdr-0.1.0/PKG-INFO +175 -0
- airmdr-0.1.0/README.md +158 -0
- airmdr-0.1.0/pyproject.toml +39 -0
- airmdr-0.1.0/setup.cfg +4 -0
- airmdr-0.1.0/src/airmdr/__init__.py +33 -0
- airmdr-0.1.0/src/airmdr/__main__.py +3 -0
- airmdr-0.1.0/src/airmdr/_demo.json +95 -0
- airmdr-0.1.0/src/airmdr/_http.py +104 -0
- airmdr-0.1.0/src/airmdr/_version.py +1 -0
- airmdr-0.1.0/src/airmdr/cli.py +592 -0
- airmdr-0.1.0/src/airmdr/client.py +105 -0
- airmdr-0.1.0/src/airmdr/credentials.py +104 -0
- airmdr-0.1.0/src/airmdr/demo.py +76 -0
- airmdr-0.1.0/src/airmdr/errors.py +77 -0
- airmdr-0.1.0/src/airmdr/render.py +113 -0
- airmdr-0.1.0/src/airmdr/run.py +145 -0
- airmdr-0.1.0/src/airmdr/steps.py +96 -0
- airmdr-0.1.0/src/airmdr.egg-info/PKG-INFO +175 -0
- airmdr-0.1.0/src/airmdr.egg-info/SOURCES.txt +20 -0
- airmdr-0.1.0/src/airmdr.egg-info/dependency_links.txt +1 -0
- airmdr-0.1.0/src/airmdr.egg-info/entry_points.txt +2 -0
- airmdr-0.1.0/src/airmdr.egg-info/top_level.txt +1 -0
airmdr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: airmdr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Investigate a security alert with AirMDR's AI SOC agent, from your terminal or from Python.
|
|
5
|
+
Author: AirMDR
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://fast.airmdr.com
|
|
8
|
+
Project-URL: Documentation, https://fast.airmdr.com/docs
|
|
9
|
+
Keywords: security,soc,mdr,alert triage,incident response,ai soc
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Information Technology
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# airmdr
|
|
19
|
+
|
|
20
|
+
Investigate a security alert with AirMDR's AI SOC agent, from your
|
|
21
|
+
terminal or from Python. You get a verdict, the reasoning behind it, and
|
|
22
|
+
a case you can open in the browser.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
pip install airmdr
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.9 or later. The package has no dependencies.
|
|
29
|
+
|
|
30
|
+
## From install to your first verdict
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
airmdr demo # watch a recorded investigation; no account
|
|
34
|
+
airmdr login # free trial, in your browser
|
|
35
|
+
airmdr investigate alert.json # any alert JSON, from any tool
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 1. Watch the demo
|
|
39
|
+
|
|
40
|
+
`airmdr demo` plays a recorded investigation. It runs offline and needs
|
|
41
|
+
no account, so you can see what a result looks like before you sign up.
|
|
42
|
+
|
|
43
|
+
### 2. Sign in
|
|
44
|
+
|
|
45
|
+
`airmdr login` opens your browser. Sign in, or start a free trial with
|
|
46
|
+
your email, then approve the code the terminal shows. The terminal
|
|
47
|
+
receives an API key and saves it to `~/.airmdr/credentials`, readable by
|
|
48
|
+
you only.
|
|
49
|
+
|
|
50
|
+
### 3. Investigate your first alert
|
|
51
|
+
|
|
52
|
+
`airmdr investigate alert.json` needs only the alert, as your tool
|
|
53
|
+
exported it. No source has to be connected first. The result says what
|
|
54
|
+
the agent could read and what it could not.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
$ airmdr investigate alert.json
|
|
58
|
+
Recognised as Crowdstrike · Suspicious scheduled task created
|
|
59
|
+
Watch live at https://fast.airmdr.com/investigate/QX7M2A-CROWDSTRIKE-1
|
|
60
|
+
Stored in your trial workspace for 30 days.
|
|
61
|
+
|
|
62
|
+
✓ Read the alert 0:07
|
|
63
|
+
✓ Is 203.0.113.47 a Tor exit node or known-malicious? 1:21
|
|
64
|
+
✓ Wrote the case 1:43
|
|
65
|
+
|
|
66
|
+
Verdict Malicious · confidence 78%
|
|
67
|
+
Summary Hidden encoded-PowerShell scheduled task on FIN-LT-0077
|
|
68
|
+
with a Tor exit node address; treat as compromise.
|
|
69
|
+
Checked the alert, AbuseIPDB lookup, IP IOC scorer
|
|
70
|
+
Not checked Crowdstrike is not connected, so the agent had only the
|
|
71
|
+
alert itself to go on
|
|
72
|
+
Case https://fast.airmdr.com/case/QX7M2A-CROWDSTRIKE-1
|
|
73
|
+
|
|
74
|
+
Next Connect Crowdstrike in your workspace: https://fast.airmdr.com/onboarding
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Every command ends with one next step. Here it is connecting the
|
|
78
|
+
alert's own source, which lets the next investigation read your
|
|
79
|
+
telemetry and not only the alert.
|
|
80
|
+
|
|
81
|
+
## What the trial includes
|
|
82
|
+
|
|
83
|
+
- **100 free investigations**, up to 10 a day, one at a time.
|
|
84
|
+
- **60+ integrations** included.
|
|
85
|
+
- **Read-only.** The trial does not write back to your tools, open
|
|
86
|
+
tickets or take response actions.
|
|
87
|
+
- Most investigations finish in under 5 minutes.
|
|
88
|
+
|
|
89
|
+
The SDK trial differs from the free plan on airmdr.com in two ways: it
|
|
90
|
+
allows at most 10 investigations a day, and after the 100 free
|
|
91
|
+
investigations the next step is a demo of the platform, not a price per
|
|
92
|
+
investigation. [Your data](https://fast.airmdr.com/docs/data) says what happens to the alerts
|
|
93
|
+
you send.
|
|
94
|
+
|
|
95
|
+
## Commands
|
|
96
|
+
|
|
97
|
+
| Command | What it does |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `airmdr demo` | Plays a recorded investigation. Offline, no account. |
|
|
100
|
+
| `airmdr login` | Signs in or starts a free trial in your browser, then saves a key. |
|
|
101
|
+
| `airmdr investigate <file>` | Investigates one alert. `-` reads the alert from stdin. |
|
|
102
|
+
| `airmdr watch [id]` | Follows an investigation; the last one by default. |
|
|
103
|
+
| `airmdr stop [id]` | Cancels an investigation. |
|
|
104
|
+
| `airmdr status` | Who is signed in and what is left of today's trial limit. |
|
|
105
|
+
| `airmdr quickstart` | The steps from install to your first verdict, as a checklist. |
|
|
106
|
+
| `airmdr upgrade` | Opens the page to book a demo of the AirMDR platform. |
|
|
107
|
+
| `airmdr logout` | Revokes this machine's key and removes it. |
|
|
108
|
+
|
|
109
|
+
The [CLI reference](https://fast.airmdr.com/docs/cli) has each command's output, its JSON and
|
|
110
|
+
the exit codes.
|
|
111
|
+
|
|
112
|
+
## For scripts and agents
|
|
113
|
+
|
|
114
|
+
Every command takes `--json` and then prints exactly one JSON object on
|
|
115
|
+
stdout. The next step is a field, so a script or an AI agent is guided
|
|
116
|
+
the same way a person is.
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
$ airmdr investigate alert.json --json
|
|
120
|
+
{
|
|
121
|
+
"id": "QX7M2A-CROWDSTRIKE-1",
|
|
122
|
+
"status": "completed",
|
|
123
|
+
"verdict": "malicious",
|
|
124
|
+
"confidence": 78,
|
|
125
|
+
"checked": ["the alert", "AbuseIPDB lookup", "IP IOC scorer"],
|
|
126
|
+
"not_checked": [{"source": "crowdstrike", "reason": "not connected"}],
|
|
127
|
+
"case_url": "https://fast.airmdr.com/case/QX7M2A-CROWDSTRIKE-1",
|
|
128
|
+
"next": "Connect Crowdstrike in your workspace: https://fast.airmdr.com/onboarding",
|
|
129
|
+
"runs_today": 1,
|
|
130
|
+
"runs_per_day": 10
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Exit codes: `0` done, `1` error, `2` usage, `3` not signed in, `4` a
|
|
135
|
+
limit or capacity refused the request, `5` the investigation ended
|
|
136
|
+
without finishing, `130` interrupted.
|
|
137
|
+
|
|
138
|
+
## From Python
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from airmdr import AirMDR
|
|
142
|
+
|
|
143
|
+
client = AirMDR() # reads AIRMDR_API_KEY, or the saved key
|
|
144
|
+
run = client.investigate(alert) # a dict, a list, or a file path
|
|
145
|
+
|
|
146
|
+
for step in run.stream(): # live progress
|
|
147
|
+
print(step.title)
|
|
148
|
+
|
|
149
|
+
case = run.result() # waits for the case
|
|
150
|
+
print(case.verdict, case.confidence, case.url)
|
|
151
|
+
print(case.checked, case.not_checked)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The [Python reference](https://fast.airmdr.com/docs/python) covers the client, a run, its case
|
|
155
|
+
and the exceptions.
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
| Variable | Meaning |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `AIRMDR_API_KEY` | The key to use. Wins over the one `airmdr login` saved. |
|
|
162
|
+
| `AIRMDR_BASE_URL` | The server to talk to. Default `https://fast.airmdr.com`. |
|
|
163
|
+
| `AIRMDR_HOME` | Where the key is kept. Default `~/.airmdr`. |
|
|
164
|
+
| `NO_COLOR` | Set to turn color off. |
|
|
165
|
+
|
|
166
|
+
## More
|
|
167
|
+
|
|
168
|
+
- [CLI reference](https://fast.airmdr.com/docs/cli)
|
|
169
|
+
- [Python reference](https://fast.airmdr.com/docs/python)
|
|
170
|
+
- [Errors](https://fast.airmdr.com/docs/errors): each message and its fix
|
|
171
|
+
- [Your data](https://fast.airmdr.com/docs/data): what is stored, who sees it, how long it is kept
|
|
172
|
+
|
|
173
|
+
## Documentation
|
|
174
|
+
|
|
175
|
+
https://fast.airmdr.com/docs
|
airmdr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# airmdr
|
|
2
|
+
|
|
3
|
+
Investigate a security alert with AirMDR's AI SOC agent, from your
|
|
4
|
+
terminal or from Python. You get a verdict, the reasoning behind it, and
|
|
5
|
+
a case you can open in the browser.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install airmdr
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Python 3.9 or later. The package has no dependencies.
|
|
12
|
+
|
|
13
|
+
## From install to your first verdict
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
airmdr demo # watch a recorded investigation; no account
|
|
17
|
+
airmdr login # free trial, in your browser
|
|
18
|
+
airmdr investigate alert.json # any alert JSON, from any tool
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 1. Watch the demo
|
|
22
|
+
|
|
23
|
+
`airmdr demo` plays a recorded investigation. It runs offline and needs
|
|
24
|
+
no account, so you can see what a result looks like before you sign up.
|
|
25
|
+
|
|
26
|
+
### 2. Sign in
|
|
27
|
+
|
|
28
|
+
`airmdr login` opens your browser. Sign in, or start a free trial with
|
|
29
|
+
your email, then approve the code the terminal shows. The terminal
|
|
30
|
+
receives an API key and saves it to `~/.airmdr/credentials`, readable by
|
|
31
|
+
you only.
|
|
32
|
+
|
|
33
|
+
### 3. Investigate your first alert
|
|
34
|
+
|
|
35
|
+
`airmdr investigate alert.json` needs only the alert, as your tool
|
|
36
|
+
exported it. No source has to be connected first. The result says what
|
|
37
|
+
the agent could read and what it could not.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
$ airmdr investigate alert.json
|
|
41
|
+
Recognised as Crowdstrike · Suspicious scheduled task created
|
|
42
|
+
Watch live at https://fast.airmdr.com/investigate/QX7M2A-CROWDSTRIKE-1
|
|
43
|
+
Stored in your trial workspace for 30 days.
|
|
44
|
+
|
|
45
|
+
✓ Read the alert 0:07
|
|
46
|
+
✓ Is 203.0.113.47 a Tor exit node or known-malicious? 1:21
|
|
47
|
+
✓ Wrote the case 1:43
|
|
48
|
+
|
|
49
|
+
Verdict Malicious · confidence 78%
|
|
50
|
+
Summary Hidden encoded-PowerShell scheduled task on FIN-LT-0077
|
|
51
|
+
with a Tor exit node address; treat as compromise.
|
|
52
|
+
Checked the alert, AbuseIPDB lookup, IP IOC scorer
|
|
53
|
+
Not checked Crowdstrike is not connected, so the agent had only the
|
|
54
|
+
alert itself to go on
|
|
55
|
+
Case https://fast.airmdr.com/case/QX7M2A-CROWDSTRIKE-1
|
|
56
|
+
|
|
57
|
+
Next Connect Crowdstrike in your workspace: https://fast.airmdr.com/onboarding
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Every command ends with one next step. Here it is connecting the
|
|
61
|
+
alert's own source, which lets the next investigation read your
|
|
62
|
+
telemetry and not only the alert.
|
|
63
|
+
|
|
64
|
+
## What the trial includes
|
|
65
|
+
|
|
66
|
+
- **100 free investigations**, up to 10 a day, one at a time.
|
|
67
|
+
- **60+ integrations** included.
|
|
68
|
+
- **Read-only.** The trial does not write back to your tools, open
|
|
69
|
+
tickets or take response actions.
|
|
70
|
+
- Most investigations finish in under 5 minutes.
|
|
71
|
+
|
|
72
|
+
The SDK trial differs from the free plan on airmdr.com in two ways: it
|
|
73
|
+
allows at most 10 investigations a day, and after the 100 free
|
|
74
|
+
investigations the next step is a demo of the platform, not a price per
|
|
75
|
+
investigation. [Your data](https://fast.airmdr.com/docs/data) says what happens to the alerts
|
|
76
|
+
you send.
|
|
77
|
+
|
|
78
|
+
## Commands
|
|
79
|
+
|
|
80
|
+
| Command | What it does |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `airmdr demo` | Plays a recorded investigation. Offline, no account. |
|
|
83
|
+
| `airmdr login` | Signs in or starts a free trial in your browser, then saves a key. |
|
|
84
|
+
| `airmdr investigate <file>` | Investigates one alert. `-` reads the alert from stdin. |
|
|
85
|
+
| `airmdr watch [id]` | Follows an investigation; the last one by default. |
|
|
86
|
+
| `airmdr stop [id]` | Cancels an investigation. |
|
|
87
|
+
| `airmdr status` | Who is signed in and what is left of today's trial limit. |
|
|
88
|
+
| `airmdr quickstart` | The steps from install to your first verdict, as a checklist. |
|
|
89
|
+
| `airmdr upgrade` | Opens the page to book a demo of the AirMDR platform. |
|
|
90
|
+
| `airmdr logout` | Revokes this machine's key and removes it. |
|
|
91
|
+
|
|
92
|
+
The [CLI reference](https://fast.airmdr.com/docs/cli) has each command's output, its JSON and
|
|
93
|
+
the exit codes.
|
|
94
|
+
|
|
95
|
+
## For scripts and agents
|
|
96
|
+
|
|
97
|
+
Every command takes `--json` and then prints exactly one JSON object on
|
|
98
|
+
stdout. The next step is a field, so a script or an AI agent is guided
|
|
99
|
+
the same way a person is.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
$ airmdr investigate alert.json --json
|
|
103
|
+
{
|
|
104
|
+
"id": "QX7M2A-CROWDSTRIKE-1",
|
|
105
|
+
"status": "completed",
|
|
106
|
+
"verdict": "malicious",
|
|
107
|
+
"confidence": 78,
|
|
108
|
+
"checked": ["the alert", "AbuseIPDB lookup", "IP IOC scorer"],
|
|
109
|
+
"not_checked": [{"source": "crowdstrike", "reason": "not connected"}],
|
|
110
|
+
"case_url": "https://fast.airmdr.com/case/QX7M2A-CROWDSTRIKE-1",
|
|
111
|
+
"next": "Connect Crowdstrike in your workspace: https://fast.airmdr.com/onboarding",
|
|
112
|
+
"runs_today": 1,
|
|
113
|
+
"runs_per_day": 10
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Exit codes: `0` done, `1` error, `2` usage, `3` not signed in, `4` a
|
|
118
|
+
limit or capacity refused the request, `5` the investigation ended
|
|
119
|
+
without finishing, `130` interrupted.
|
|
120
|
+
|
|
121
|
+
## From Python
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from airmdr import AirMDR
|
|
125
|
+
|
|
126
|
+
client = AirMDR() # reads AIRMDR_API_KEY, or the saved key
|
|
127
|
+
run = client.investigate(alert) # a dict, a list, or a file path
|
|
128
|
+
|
|
129
|
+
for step in run.stream(): # live progress
|
|
130
|
+
print(step.title)
|
|
131
|
+
|
|
132
|
+
case = run.result() # waits for the case
|
|
133
|
+
print(case.verdict, case.confidence, case.url)
|
|
134
|
+
print(case.checked, case.not_checked)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The [Python reference](https://fast.airmdr.com/docs/python) covers the client, a run, its case
|
|
138
|
+
and the exceptions.
|
|
139
|
+
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
| Variable | Meaning |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `AIRMDR_API_KEY` | The key to use. Wins over the one `airmdr login` saved. |
|
|
145
|
+
| `AIRMDR_BASE_URL` | The server to talk to. Default `https://fast.airmdr.com`. |
|
|
146
|
+
| `AIRMDR_HOME` | Where the key is kept. Default `~/.airmdr`. |
|
|
147
|
+
| `NO_COLOR` | Set to turn color off. |
|
|
148
|
+
|
|
149
|
+
## More
|
|
150
|
+
|
|
151
|
+
- [CLI reference](https://fast.airmdr.com/docs/cli)
|
|
152
|
+
- [Python reference](https://fast.airmdr.com/docs/python)
|
|
153
|
+
- [Errors](https://fast.airmdr.com/docs/errors): each message and its fix
|
|
154
|
+
- [Your data](https://fast.airmdr.com/docs/data): what is stored, who sees it, how long it is kept
|
|
155
|
+
|
|
156
|
+
## Documentation
|
|
157
|
+
|
|
158
|
+
https://fast.airmdr.com/docs
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "airmdr"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Investigate a security alert with AirMDR's AI SOC agent, from your terminal or from Python."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "Proprietary" }
|
|
12
|
+
authors = [{ name = "AirMDR" }]
|
|
13
|
+
keywords = ["security", "soc", "mdr", "alert triage", "incident response", "ai soc"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Information Technology",
|
|
18
|
+
"Topic :: Security",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
]
|
|
21
|
+
# No dependencies, on purpose: `pip install airmdr` is one small wheel
|
|
22
|
+
# that cannot conflict with anything already in the environment.
|
|
23
|
+
dependencies = []
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://fast.airmdr.com"
|
|
27
|
+
Documentation = "https://fast.airmdr.com/docs"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
airmdr = "airmdr.cli:main"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.dynamic]
|
|
33
|
+
version = { attr = "airmdr._version.__version__" }
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.packages.find]
|
|
36
|
+
where = ["src"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.package-data]
|
|
39
|
+
airmdr = ["_demo.json"]
|
airmdr-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""AirMDR: investigate a security alert from your terminal or from
|
|
2
|
+
Python.
|
|
3
|
+
|
|
4
|
+
pip install airmdr
|
|
5
|
+
airmdr demo # watch a recorded investigation, no account
|
|
6
|
+
airmdr login # free trial
|
|
7
|
+
airmdr investigate alert.json
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from airmdr._version import __version__
|
|
11
|
+
from airmdr.client import AirMDR
|
|
12
|
+
from airmdr.errors import (
|
|
13
|
+
AirMDRError,
|
|
14
|
+
ConnectionFailed,
|
|
15
|
+
LimitReached,
|
|
16
|
+
NotFound,
|
|
17
|
+
NotSignedIn,
|
|
18
|
+
)
|
|
19
|
+
from airmdr.run import Case, Run
|
|
20
|
+
from airmdr.steps import Step
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"AirMDR",
|
|
24
|
+
"AirMDRError",
|
|
25
|
+
"Case",
|
|
26
|
+
"ConnectionFailed",
|
|
27
|
+
"LimitReached",
|
|
28
|
+
"NotFound",
|
|
29
|
+
"NotSignedIn",
|
|
30
|
+
"Run",
|
|
31
|
+
"Step",
|
|
32
|
+
"__version__",
|
|
33
|
+
]
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"alert": {
|
|
3
|
+
"source": "SOC Radar",
|
|
4
|
+
"title": "Dark web data leak: genomiq.io credentials exposed"
|
|
5
|
+
},
|
|
6
|
+
"duration_seconds": 150,
|
|
7
|
+
"verdict": "benign",
|
|
8
|
+
"confidence": 92,
|
|
9
|
+
"summary": "genomiq.io keyword found in Meridian Partners ransomware leak (DataShadow) — GenomIQ is a listed client, not the breached party; no sensitive data exposed.",
|
|
10
|
+
"events": [
|
|
11
|
+
{
|
|
12
|
+
"type": "status",
|
|
13
|
+
"ts": 0
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "tool_result",
|
|
17
|
+
"name": "read",
|
|
18
|
+
"call_id": "toolu_013eCtHpbwfobd8CNZYDqgCU",
|
|
19
|
+
"ts": 2505
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "tool_result",
|
|
23
|
+
"name": "read",
|
|
24
|
+
"call_id": "toolu_01XMLFKaYEB9a2CyLJSBqkBX",
|
|
25
|
+
"ts": 2783
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "tool_result",
|
|
29
|
+
"name": "read",
|
|
30
|
+
"call_id": "toolu_01R1zhEhSLJumyd5KQ4sGqDT",
|
|
31
|
+
"ts": 3061
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "tool_call",
|
|
35
|
+
"name": "sub_agent",
|
|
36
|
+
"call_id": "toolu_01WrJiztakuwvQrN6GgYvqmG",
|
|
37
|
+
"input": {
|
|
38
|
+
"title": "What the leaked file contains"
|
|
39
|
+
},
|
|
40
|
+
"ts": 12523
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "tool_call",
|
|
44
|
+
"name": "sub_agent",
|
|
45
|
+
"call_id": "toolu_01NvCJ6BJmegV8aExZcSLRiD",
|
|
46
|
+
"input": {
|
|
47
|
+
"title": "Who hosts the leak site"
|
|
48
|
+
},
|
|
49
|
+
"ts": 12801
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "tool_call",
|
|
53
|
+
"name": "sub_agent",
|
|
54
|
+
"call_id": "toolu_01AaDx7MzvVMvCyASKZZ81M7",
|
|
55
|
+
"input": {
|
|
56
|
+
"title": "What SOC Radar knows about this alarm"
|
|
57
|
+
},
|
|
58
|
+
"ts": 13080
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"type": "tool_result",
|
|
62
|
+
"name": "sub_agent",
|
|
63
|
+
"call_id": "toolu_01AaDx7MzvVMvCyASKZZ81M7",
|
|
64
|
+
"ts": 103525
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "tool_result",
|
|
68
|
+
"name": "sub_agent",
|
|
69
|
+
"call_id": "toolu_01WrJiztakuwvQrN6GgYvqmG",
|
|
70
|
+
"ts": 119388
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"type": "tool_result",
|
|
74
|
+
"name": "sub_agent",
|
|
75
|
+
"call_id": "toolu_01NvCJ6BJmegV8aExZcSLRiD",
|
|
76
|
+
"ts": 139147
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "tool_result",
|
|
80
|
+
"name": "read",
|
|
81
|
+
"call_id": "toolu_017ZpnBwn5STPRzZw2himZtL",
|
|
82
|
+
"ts": 145826
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"type": "tool_result",
|
|
86
|
+
"name": "create_case",
|
|
87
|
+
"call_id": "toolu_01BCBit4mZ1T5He9ms4jzP4j",
|
|
88
|
+
"ts": 146939
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"type": "agent_result",
|
|
92
|
+
"ts": 149722
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""The one place this package talks to the network. Standard library
|
|
2
|
+
only, so installing ``airmdr`` pulls in nothing else."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import urllib.error
|
|
8
|
+
import urllib.request
|
|
9
|
+
from collections.abc import Iterator
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from airmdr import errors
|
|
13
|
+
from airmdr._version import __version__
|
|
14
|
+
|
|
15
|
+
API = "/api/sdk/v1"
|
|
16
|
+
# The stream sends a heartbeat every 15 seconds; a minute of silence
|
|
17
|
+
# means the connection is gone.
|
|
18
|
+
_STREAM_TIMEOUT = 60
|
|
19
|
+
_TIMEOUT = 90
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Transport:
|
|
23
|
+
"""Sends requests to an AirMDR server. ``surface`` says what is
|
|
24
|
+
calling (``cli`` or ``python``); it is logged, and gates nothing."""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self, base_url: str, key: str | None = None, surface: str = "python"
|
|
28
|
+
) -> None:
|
|
29
|
+
self.base_url = base_url.rstrip("/")
|
|
30
|
+
self.key = key
|
|
31
|
+
self.surface = surface
|
|
32
|
+
|
|
33
|
+
def _headers(self, *, auth: bool, body: bool) -> dict[str, str]:
|
|
34
|
+
headers = {
|
|
35
|
+
"Accept": "application/json",
|
|
36
|
+
"User-Agent": f"airmdr-{self.surface}/{__version__}",
|
|
37
|
+
"X-AirMDR-Client": f"{self.surface}/{__version__}",
|
|
38
|
+
}
|
|
39
|
+
if body:
|
|
40
|
+
headers["Content-Type"] = "application/json"
|
|
41
|
+
if auth:
|
|
42
|
+
if not self.key:
|
|
43
|
+
raise errors.NotSignedIn(
|
|
44
|
+
"Not signed in. Run: airmdr login", code="missing_key"
|
|
45
|
+
)
|
|
46
|
+
headers["Authorization"] = f"Bearer {self.key}"
|
|
47
|
+
return headers
|
|
48
|
+
|
|
49
|
+
def _open(
|
|
50
|
+
self, method: str, path: str, payload: Any, auth: bool, timeout: int
|
|
51
|
+
):
|
|
52
|
+
data = None if payload is None else json.dumps(payload).encode("utf-8")
|
|
53
|
+
req = urllib.request.Request(
|
|
54
|
+
self.base_url + path,
|
|
55
|
+
data=data,
|
|
56
|
+
method=method,
|
|
57
|
+
headers=self._headers(auth=auth, body=data is not None),
|
|
58
|
+
)
|
|
59
|
+
try:
|
|
60
|
+
return urllib.request.urlopen(req, timeout=timeout) # noqa: S310
|
|
61
|
+
except urllib.error.HTTPError as exc:
|
|
62
|
+
raw = exc.read()
|
|
63
|
+
try:
|
|
64
|
+
body = json.loads(raw.decode("utf-8") or "{}")
|
|
65
|
+
except ValueError:
|
|
66
|
+
body = {}
|
|
67
|
+
raise errors.from_response(exc.code, body) from None
|
|
68
|
+
except (TimeoutError, urllib.error.URLError, OSError) as exc:
|
|
69
|
+
reason = getattr(exc, "reason", exc)
|
|
70
|
+
raise errors.ConnectionFailed(
|
|
71
|
+
f"Could not reach AirMDR at {self.base_url} ({reason}). "
|
|
72
|
+
"Check your connection and try again.",
|
|
73
|
+
code="unreachable",
|
|
74
|
+
) from None
|
|
75
|
+
|
|
76
|
+
def request(
|
|
77
|
+
self, method: str, path: str, payload: Any = None, *, auth: bool = True
|
|
78
|
+
) -> dict[str, Any]:
|
|
79
|
+
with self._open(method, path, payload, auth, _TIMEOUT) as resp:
|
|
80
|
+
raw = resp.read()
|
|
81
|
+
try:
|
|
82
|
+
body = json.loads(raw.decode("utf-8") or "{}")
|
|
83
|
+
except ValueError:
|
|
84
|
+
body = {}
|
|
85
|
+
return body if isinstance(body, dict) else {}
|
|
86
|
+
|
|
87
|
+
def stream(self, path: str) -> Iterator[dict[str, Any]]:
|
|
88
|
+
"""A server-sent event stream, one parsed event at a time."""
|
|
89
|
+
with self._open("GET", path, None, True, _STREAM_TIMEOUT) as resp:
|
|
90
|
+
try:
|
|
91
|
+
for raw in resp:
|
|
92
|
+
line = raw.decode("utf-8", "replace").strip()
|
|
93
|
+
if not line.startswith("data:"):
|
|
94
|
+
continue
|
|
95
|
+
try:
|
|
96
|
+
event = json.loads(line[5:].strip())
|
|
97
|
+
except ValueError:
|
|
98
|
+
continue
|
|
99
|
+
if isinstance(event, dict):
|
|
100
|
+
yield event
|
|
101
|
+
except (TimeoutError, OSError):
|
|
102
|
+
# The connection dropped mid-run. The caller decides
|
|
103
|
+
# whether to reconnect; the run itself is unaffected.
|
|
104
|
+
return
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|