-
Notifications
You must be signed in to change notification settings - Fork 378
feat: kafka message dispatcher #1641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 170 commits
22bef44
fadfe5e
e81376a
e1b3ecc
65e97d2
feaa018
d085c68
7602aba
2d5c1a0
729e9e1
5e2e08c
742ea0f
d427aa3
5584c73
0a6f097
85438fa
15c90e0
0289915
c70f3e6
02edaa2
94951a2
c5051f9
ebfd636
fcb26dd
a28c78a
9826ff7
5571fed
bea0ad0
124d811
083f169
c8f865a
3842f06
7a2a212
59eeb84
0b88113
c965170
d304699
d303fe2
953e943
3c72b87
35c221d
0231aca
5304076
ab0ec85
2317bab
daf4789
fdbea08
f7c5abe
7dee475
fd2ac06
31af79e
b6c2a4c
3ebe71b
09f7f0f
b6a017b
a0a89db
fddd816
89cdc28
2ab447e
a70f619
d3fb2bc
3d03978
de43a35
90592b8
e827277
601fa67
685ce6d
245f95d
c7fd9b5
77dddf0
7994c7b
ea8312c
b71cfa4
eea7d43
8aa93dd
24dcb0b
7730001
65e706f
044fdb0
fe79a34
62b6407
f725709
73e91e3
26c6a23
dcbb8fd
d534183
f26dfd4
1aa37c4
d9ca00f
4f49054
a95f68a
08fc5a5
3f2e69f
85236a4
ccd4929
24d9857
1fbc358
9435451
81e4887
c314649
1cdab0c
246ea27
eecde72
50a3f96
f6fbbaa
d7926e8
df83fdc
840545b
186c83c
29d0be5
829940b
f48c46d
3107ce2
af462f5
c6cca1d
68e7b1f
aee4fd1
c55b085
0499e9a
491938c
a543cd5
45edfa4
748c450
6ce1620
96e8567
2a1ce46
ecd56ec
cc1ddb7
f05c146
4626100
c597468
0390b2a
ec420f7
a4a5563
e18ac3d
f3981e7
446fb31
f35e745
5db4e46
173d9c3
66e209b
1fa3432
52f1aab
5fe7032
43e5576
362c8cc
6fecaf6
b564cf4
81f6ca3
aaa46d7
a945010
89ea127
49d9fad
6134a16
ee31717
0c878dc
168b678
a24dc24
290e599
68eaa82
8fb4548
459a534
4e232d8
8847fe0
b7d83c0
6c2f864
0d09bb0
51226dc
82e834b
07532b9
bbf7223
a20636d
d4cb71c
d0c8ba5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
.git* | ||
.pytest* | ||
.idea* | ||
.venv | ||
.dockerignore | ||
Dockerfile | ||
db | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,38 @@ services: | |
tls /etc/caddy/cert.pem /etc/caddy/key.pem{% else %} | ||
tls internal{% endif %}{% endif %} | ||
}" > Caddyfile && caddy run' | ||
|
||
{% if kafka_dispatcher.enabled %} | ||
dispatcher: | ||
container_name: dispatcher | ||
image: ghcr.io/intuitem/ciso-assistant-community/dispatcher:latest | ||
# build: | ||
# context: ../dispatcher | ||
restart: always | ||
environment: | ||
- API_URL=http://backend:8000/api | ||
- BOOTSTRAP_SERVERS={{ kafka_dispatcher.broker_url }} | ||
- KAFKA_USE_AUTH={{ kafka_dispatcher.kafka_use_auth }} | ||
{% if kafka_dispatcher.kafka_use_auth %} | ||
- KAFKA_SASL_MECHANISM={{ kafka_dispatcher.kafka_sasl_mechanism }} | ||
- KAFKA_USERNAME={{ kafka_dispatcher.kafka_username }} | ||
- KAFKA_PASSWORD={{ kafka_dispatcher.kafka_password }} | ||
{% endif %} | ||
- OBSERVATION_TOPIC={{ kafka_dispatcher.observation_topic }} | ||
- ERRORS_TOPIC={{ kafka_dispatcher.errors_topic }} | ||
{% if kafka_dispatcher.authentication == 'credentials' %} | ||
- USER_EMAIL={{ kafka_dispatcher.credentials.user_email }} | ||
- USER_PASSWORD={{ kafka_dispatcher.credentials.user_password }} | ||
- AUTO_RENEW_SESSION={{ kafka_dispatcher.auto_renew_session }} | ||
{% elif kafka_dispatcher.authentication == 'token' %} | ||
- TOKEN={{ kafka_dispatcher.token }} | ||
{% endif %} | ||
{% if kafka_dispatcher.s3_url %} | ||
- S3_URL={{ kafka_dispatcher.s3_url }} | ||
- S3_ACCESS_KEY={{ kafka_dispatcher.s3_access_key }} | ||
- S3_SECRET_KEY={{ kafka_dispatcher.s3_secret_key }} | ||
{% endif %} | ||
Comment on lines
+105
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use environment file or secrets for sensitive credentials The current configuration embeds passwords and authentication tokens directly in environment variables, which could expose sensitive information in logs or error messages. - KAFKA_USE_AUTH={{ kafka_dispatcher.kafka_use_auth }}
{% if kafka_dispatcher.kafka_use_auth %}
- - KAFKA_SASL_MECHANISM={{ kafka_dispatcher.kafka_sasl_mechanism }}
- - KAFKA_USERNAME={{ kafka_dispatcher.kafka_username }}
- - KAFKA_PASSWORD={{ kafka_dispatcher.kafka_password }}
+ - KAFKA_SASL_MECHANISM={{ kafka_dispatcher.kafka_sasl_mechanism }}
+ env_file:
+ - ./kafka_dispatcher_credentials.env
{% endif %}
- OBSERVATION_TOPIC={{ kafka_dispatcher.observation_topic }}
- ERRORS_TOPIC={{ kafka_dispatcher.errors_topic }}
{% if kafka_dispatcher.authentication == 'credentials' %}
- - USER_EMAIL={{ kafka_dispatcher.credentials.user_email }}
- - USER_PASSWORD={{ kafka_dispatcher.credentials.user_password }}
+ - USER_EMAIL={{ kafka_dispatcher.credentials.user_email }}
+ secrets:
+ - dispatcher_api_credentials
- AUTO_RENEW_SESSION={{ kafka_dispatcher.auto_renew_session }}
{% elif kafka_dispatcher.authentication == 'token' %}
- - TOKEN={{ kafka_dispatcher.token }}
+ secrets:
+ - dispatcher_api_token
{% endif %}
{% if kafka_dispatcher.s3_url %}
- S3_URL={{ kafka_dispatcher.s3_url }}
- - S3_ACCESS_KEY={{ kafka_dispatcher.s3_access_key }}
- - S3_SECRET_KEY={{ kafka_dispatcher.s3_secret_key }}
+ secrets:
+ - dispatcher_s3_credentials
{% endif %} Add secrets and env files sections: services:
# ... existing services ...
+
+secrets:
+ {% if kafka_dispatcher.enabled %}
+ {% if kafka_dispatcher.authentication == 'credentials' %}
+ dispatcher_api_credentials:
+ file: ./dispatcher_api_credentials.txt
+ {% elif kafka_dispatcher.authentication == 'token' %}
+ dispatcher_api_token:
+ file: ./dispatcher_api_token.txt
+ {% endif %}
+ {% if kafka_dispatcher.s3_url %}
+ dispatcher_s3_credentials:
+ file: ./dispatcher_s3_credentials.txt
+ {% endif %}
+ {% endif %}
|
||
depends_on: | ||
backend: | ||
condition: service_healthy | ||
{% endif %} | ||
Comment on lines
+95
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusiveDocument when to use commented build section The commented-out build section suggests local building is supported, but it's not clear when users should uncomment it. 🏁 Script executed: #!/bin/bash
# Check for documentation on when to use the build section instead of the image
grep -r "build.*context.*dispatcher" --include="*.md" dispatcher/
grep -r "locally build" --include="*.md" dispatcher/ Length of output: 122 Document usage of the commented‑out The • In |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -112,3 +112,38 @@ services: | |||||||||
- "--providers.file.directory=/etc/traefik" | ||||||||||
- "--providers.file.watch=true"{% else %} | ||||||||||
- "--experimental.localPlugins.selfsigned.moduleName=traefik.tls"{% endif %} | ||||||||||
|
||||||||||
{% if kafka_dispatcher.enabled %} | ||||||||||
dispatcher: | ||||||||||
container_name: dispatcher | ||||||||||
image: ghcr.io/intuitem/ciso-assistant-community/dispatcher:latest | ||||||||||
# build: | ||||||||||
Comment on lines
+119
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid using 'latest' tag in production environments Using the Consider using a specific version tag instead: - image: ghcr.io/intuitem/ciso-assistant-community/dispatcher:latest
+ image: ghcr.io/intuitem/ciso-assistant-community/dispatcher:1.0.0 # Replace with appropriate version 📝 Committable suggestion
Suggested change
|
||||||||||
# context: ../dispatcher | ||||||||||
restart: always | ||||||||||
environment: | ||||||||||
- API_URL=http://backend:8000/api | ||||||||||
- BOOTSTRAP_SERVERS={{ kafka_dispatcher.broker_url }} | ||||||||||
- KAFKA_USE_AUTH={{ kafka_dispatcher.kafka_use_auth }} | ||||||||||
{% if kafka_dispatcher.kafka_use_auth %} | ||||||||||
- KAFKA_SASL_MECHANISM={{ kafka_dispatcher.kafka_sasl_mechanism }} | ||||||||||
- KAFKA_USERNAME={{ kafka_dispatcher.kafka_username }} | ||||||||||
- KAFKA_PASSWORD={{ kafka_dispatcher.kafka_password }} | ||||||||||
{% endif %} | ||||||||||
- OBSERVATION_TOPIC={{ kafka_dispatcher.observation_topic }} | ||||||||||
- ERRORS_TOPIC={{ kafka_dispatcher.errors_topic }} | ||||||||||
{% if kafka_dispatcher.authentication == 'credentials' %} | ||||||||||
- USER_EMAIL={{ kafka_dispatcher.credentials.user_email }} | ||||||||||
- USER_PASSWORD={{ kafka_dispatcher.credentials.user_password }} | ||||||||||
- AUTO_RENEW_SESSION={{ kafka_dispatcher.auto_renew_session }} | ||||||||||
{% elif kafka_dispatcher.authentication == 'token' %} | ||||||||||
- TOKEN={{ kafka_dispatcher.token }} | ||||||||||
{% endif %} | ||||||||||
{% if kafka_dispatcher.s3_url %} | ||||||||||
- S3_URL={{ kafka_dispatcher.s3_url }} | ||||||||||
- S3_ACCESS_KEY={{ kafka_dispatcher.s3_access_key }} | ||||||||||
- S3_SECRET_KEY={{ kafka_dispatcher.s3_secret_key }} | ||||||||||
{% endif %} | ||||||||||
depends_on: | ||||||||||
backend: | ||||||||||
condition: service_healthy | ||||||||||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
*.DS_Store | ||
*~$* | ||
.env | ||
.venv | ||
venv | ||
**/node_modules/ | ||
.vscode | ||
*.sqlite3 | ||
django_secret_key | ||
temp/ | ||
db/ | ||
.dccache | ||
/backend/profiles | ||
./backend/ciso_assistant/.meta | ||
caddy_data/ | ||
**/dist/ | ||
**/.meta | ||
charts/custom-values.yaml | ||
**/charts/*/charts | ||
*.bak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid using 'latest' tag in production deployments.
Using the 'latest' tag can lead to unexpected changes and inconsistent deployments, making version tracking and rollbacks difficult.
Consider either:
📝 Committable suggestion