Skip to content

Commit b88897f

Browse files
committed
Merge branch 'feature/improved_findings_search' of https://github.com/red-kite-solutions/stalker into feature/319_refactor-seach-suggestions
2 parents bfcfe17 + 6762424 commit b88897f

File tree

220 files changed

+7426
-995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+7426
-995
lines changed

.github/workflows/main.yml

+17-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
test:
1717
name: E2E Tests
1818
# The type of runner that the job will run on
19-
runs-on: ubuntu-latest
19+
runs-on: Linux
2020
timeout-minutes: 30
2121

2222
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -37,17 +37,23 @@ jobs:
3737
kubectl-install: true
3838

3939
- name: Create namespace
40-
run: kubectl create namespace stalker
41-
42-
- name: Make room in the container
40+
run: kubectl create namespace stalker --dry-run=client -o yaml | kubectl apply -f -
41+
42+
# Deactivated while on self-hosted runner
43+
# - name: Make room in the container
44+
# run: |-
45+
# rm -rf /opt/hostedtoolcache/CodeQL
46+
# rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
47+
# rm -rf /opt/hostedtoolcache/PyPy
48+
# rm -rf /opt/hostedtoolcache/Python
49+
# rm -rf /opt/hostedtoolcache/Ruby
50+
# rm -rf /opt/hostedtoolcache/go
51+
# rm -rf /opt/hostedtoolcache/node
52+
- name: Create certificates
4353
run: |-
44-
rm -rf /opt/hostedtoolcache/CodeQL
45-
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
46-
rm -rf /opt/hostedtoolcache/PyPy
47-
rm -rf /opt/hostedtoolcache/Python
48-
rm -rf /opt/hostedtoolcache/Ruby
49-
rm -rf /opt/hostedtoolcache/go
50-
rm -rf /opt/hostedtoolcache/node
54+
bash setup_mongo_test.sh
55+
bash setup_kafka_test.sh
56+
bash setup_secrets_test.sh
5157
5258
- name: Build test containers
5359
run: devspace -p e2e --var="RK_ENVIRONMENT=tests" run-pipeline build -n stalker

devspace.tests.yaml

+3-30
Large diffs are not rendered by default.

devspace.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ deployments:
503503
name: kafka
504504
repo: https://charts.bitnami.com/bitnami
505505
version: "28.0.0"
506+
upgradeArgs:
507+
- --timeout
508+
- 1200s
506509
values:
507510
controller:
508511
nodeSelector: $(echo ${KAFKA_K8S_NODE_SELECTOR})
@@ -553,6 +556,7 @@ deployments:
553556
value: "no"
554557
provisioning:
555558
enabled: true
559+
parallel: 1
556560
nodeSelector: $(echo ${KAFKA_K8S_NODE_SELECTOR})
557561
auth:
558562
tls:
@@ -587,15 +591,23 @@ deployments:
587591
config:
588592
max.message.bytes: 64000
589593
flush.messages: 1
594+
- name: stalker.jobs.management
595+
partitions: 1
596+
replicationFactor: 1
597+
config:
598+
max.message.bytes: 64000
599+
flush.messages: 1
590600
extraProvisioningCommands: # Setting the ACLs
591601
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation write --operation describe --topic stalker.jobs.findings"
592602
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation write --operation describe --topic stalker.jobs.requests"
593603
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation describe --topic stalker.jobs.logs"
594604
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation write --operation describe --topic stalker.jobs.models"
605+
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation write --operation describe --topic stalker.jobs.management"
595606
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation write --operation describe --topic stalker.jobs.findings"
596607
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation read --operation describe --topic stalker.jobs.requests"
597608
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation write --operation describe --topic stalker.jobs.logs"
598609
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation read --operation describe --topic stalker.jobs.models"
610+
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation read --operation describe --topic stalker.jobs.management"
599611
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation describe --group jobs-manager"
600612
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:jobs-manager --operation read --operation describe --group jobs-manager-job-logs"
601613
- "/opt/bitnami/kafka/bin/kafka-acls.sh --bootstrap-server $KAFKA_SERVICE --command-config $CLIENT_CONF --add --allow-principal User:orchestrator --operation read --operation describe --group stalker"

docs/docs/concepts/findings.md

+129-42
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ log_finding(
6363
)
6464
```
6565

66+
### Attaching information to a domain
67+
68+
Adding fields and using a custom finding type will add a finding to the domain resource.
69+
70+
```python
71+
from stalker_job_sdk import DomainFinding, log_finding, TextField
72+
73+
hostname = "example.com"
74+
log_finding(
75+
DomainFinding(
76+
"MyCustomHostnameFinding", hostname, None, "Domain info", [
77+
TextField("myfield", "Field Title", "Finding data")
78+
]
79+
)
80+
)
81+
```
82+
6683
## IpFinding
6784

6885
An ip finding creates a new host. IP addresses are in the IPv4 format.
@@ -93,9 +110,26 @@ log_finding(
93110
)
94111
```
95112

113+
### Attaching information to a host
114+
115+
Adding fields and using a custom finding type will add a finding to the host resource.
116+
117+
```python
118+
from stalker_job_sdk import IpFinding, log_finding, TextField
119+
ip = "0.0.0.0"
120+
mask = 16
121+
log_finding(
122+
IpFinding(
123+
"MyCustomIpFinding", ip, "New Info", [
124+
TextField("myfield", "Field Title", "Finding data")
125+
]
126+
)
127+
)
128+
```
129+
96130
## IpRangeFinding
97131

98-
An ip range finding creates a new ip range for a project. IP addresses are in the IPv4 format.
132+
An ip range finding creates a new ip range for a project. IP addresses are in the IPv4 format. `IpRangeFindings` can also be used to attach information to an IP Range resource.
99133

100134
| Field | Type | Description |
101135
| ------ | ------ | -------------------------------------------------------------------------------------------------------- |
@@ -116,19 +150,32 @@ Example:
116150
Using the python SDK, you can emit this finding with the following code:
117151

118152
```python
119-
from stalker_job_sdk import IpFinding, log_finding
153+
from stalker_job_sdk import IpRangeFinding, log_finding
120154
ip = "0.0.0.0"
121155
mask = 16
122156
log_finding(
123157
IpRangeFinding(
124-
ip, mask
158+
'IpRangeFinding', ip, mask, None, [], "IpRangeFinding"
125159
)
126160
)
127161
```
128162

129-
> You can't attach fields to an IP range as they are different than other ressources.
163+
### Attaching information to an IP range
130164

131-
Which is equivalent to the following python code, but with more metadata:
165+
Adding fields and using a custom finding type will add a finding to the IP range resource.
166+
167+
```python
168+
from stalker_job_sdk import IpRangeFinding, log_finding, TextField
169+
ip = "0.0.0.0"
170+
mask = 16
171+
log_finding(
172+
IpRangeFinding(
173+
'IpRangeFinding', ip, mask, "Finding title", [
174+
TextField("myfield", "Field Title", "Finding data")
175+
]
176+
)
177+
)
178+
```
132179

133180
## HostnameIpFinding
134181

@@ -192,7 +239,7 @@ Example:
192239
Using the python SDK, you can emit this finding with the following code:
193240

194241
```python
195-
from stalker_job_sdk import PortFinding, log_finding
242+
from stalker_job_sdk import PortFinding, log_finding, TextField
196243
port = 80
197244
ip = "1.2.3.4"
198245
log_finding(
@@ -208,6 +255,29 @@ log_finding(
208255
)
209256
```
210257

258+
### Attaching information to a port
259+
260+
Adding fields and using a custom finding type will add a finding to the port resource.
261+
262+
```python
263+
from stalker_job_sdk import PortFinding, log_finding, TextField
264+
port = 80
265+
ip = "1.2.3.4"
266+
log_finding(
267+
PortFinding(
268+
"MyCustomPortFinding",
269+
ip,
270+
port,
271+
"tcp",
272+
"New port data",
273+
[
274+
TextField("protocol", "This is a TCP port", "tcp"),
275+
TextField("myfield", "Field Title", "Finding data")
276+
],
277+
)
278+
)
279+
```
280+
211281
## WebsiteFinding
212282

213283
The `WebsiteFinding` will create a website resource. Websites are made from 4 characteristics: an IP address, a domain name, a port number
@@ -269,57 +339,74 @@ log_finding(
269339
)
270340
```
271341

342+
### Attaching information to a website
343+
344+
Adding fields and using a custom finding type will add a finding to the website resource.
345+
346+
```python
347+
from stalker_job_sdk import WebsiteFinding, log_finding, TextField
348+
port = 80
349+
ip = "1.2.3.4"
350+
domain = "example.com"
351+
path = "/"
352+
ssl = False
353+
354+
log_finding(
355+
WebsiteFinding(
356+
"MyCustomWebsiteFinding",
357+
ip,
358+
port,
359+
domain,
360+
path,
361+
ssl,
362+
"New website data",
363+
[
364+
TextField("myfield", "Field Title", "Finding data")
365+
],
366+
)
367+
)
368+
```
369+
272370
## CustomFinding
273371

274-
Dynamic findings allow jobs to attach custom data to resources.
372+
Custom findings attach finding field information to a resource. There are custom findings for every type of resources. When you do not specify the _type of finding_ that you are logging, you are creating a custom finding for the associated resource type.
275373

276-
| Field | Description |
277-
| ------------ | --------------------------------------------------------------- |
278-
| `domainName` | The domain to which to attach the custom finding |
279-
| `host` | The host to which to attach the custom finding |
280-
| `port` | The port to which to attach the custom finding |
281-
| `fields` | A list of [fields](#dynamic-fields) containing the finding data |
374+
| SDK finding class | Resources |
375+
| ----------------- | --------- |
376+
| HostnameFinding | Domains |
377+
| IpFinding | Hosts |
378+
| IpRangeFinding | IP ranges |
379+
| PortFinding | Ports |
380+
| WebsiteFinding | Websites |
282381

283-
Examples:
284382

285-
```json
286-
{
287-
"type": "CustomFinding",
288-
"host": "1.2.3.4",
289-
"port": 80,
290-
"fields": [
291-
{
292-
"type": "image",
293-
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII"
294-
}
295-
]
296-
}
297-
```
383+
Here is an example of a **custom finding** for a port with the python SDK. In this example, the port will show the custom information _This port
384+
runs an HTTP server_, with a text field attached to it:
298385

299-
```json
300-
{
301-
"type": "CustomFinding",
302-
"domainName": "red-kite.io",
303-
"fields": [
304-
{
305-
"type": "text",
306-
"label": "Domain greatness level",
307-
"data": "This domain is great, would recommend"
308-
}
309-
]
310-
}
386+
```python
387+
from stalker_job_sdk import PortFinding, log_finding, TextField
388+
port = 80
389+
ip = "0.0.0.0"
390+
log_finding(
391+
PortFinding(
392+
"PortFunFact", ip, port, "tcp", "This is a fun fact about a port", [
393+
TextField('myfieldkey', 'My field title', 'My field data')
394+
]
395+
)
396+
)
311397
```
312398

313-
Here is an example of a custom finding for a port with the python SDK. In this example, the port will show the custom information _This port
314-
runs an HTTP server_:
399+
Notice how the key `PortFunFact` can be anything, how information is provided through `TextField`s and how the finding type is not provided to use the default value.
400+
401+
To compare, here is an example of how to create a port with the `PortFinding` class, which here is **not** used as a custom finding. You will see that the key is `PortFinding`, no fields are provided, and the type is `PortFinding` as well:
315402

316403
```python
317404
from stalker_job_sdk import PortFinding, log_finding
318405
port = 80
319406
ip = "0.0.0.0"
320407
log_finding(
321408
PortFinding(
322-
"PortFunFact", ip, port, "tcp", "This is a fun fact about a port"
409+
"PortFinding", ip, port, "tcp", None, None, "PortFinding"
323410
)
324411
)
325412
```

docs/docs/concepts/project.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ description: Organizing your data through projects
66

77
# Projects
88

9-
Projects are the way to organize and centralize resources. Resources are unique per project, and deleting the project will delete all its
9+
Projects are the way to organize and centralize [resources](./resources.md). Resources are unique per project, and deleting the project will delete all its
1010
resources and related information.
1111

1212
The project's name must be unique, but it can always be changed. You can also add a logo for display purposes, but it is not mandatory.
1313

14-
## Subnets
15-
16-
In the case where a target owns a public subnet, you can add the different subnets in the projects page.
17-
18-
For a subnet of `127.0.0.1/24`, you would simply add `127.0.0.1` in the _IP Address_ field, and the `/24` in the _Short Mask_ field.
14+
> Red Kite allows to work on multiple projects at once, but using the global project filter in the navigation bar, you can also focus your work on a single project at a time. It will pre-filter data in displays such as tables and metrics.

0 commit comments

Comments
 (0)