Skip to content

Commit 4508786

Browse files
piyushroshandhruv-singhal-githubgithub-advanced-security[bot]keyurdoshi03
authored
Chatbot impl (#295)
* Implement chatbot UI * added llm chatbot service (#242) * added llm chatbot service * Llm chatbot (#243) * removed unused imports * Integration * Lint * Minor fixes * Fix ssl issue * Fix docker * Fix entrypoint * increase timeout * Implement helm * Fix entrypoint * Store user state for chatbot * resolved segmentation fault error in chatbot (#245) * Add release workflow * Instructions * Fix tag publish * Strip tag prefix * String tag prefix for docker tags * Fix entrypoint.sh * Session based chat * Fix UI * Lint * Fix configmap * Update requirements * Fix dockerfile * Fix UX * Seperate prompts * Change to ChatOpenAI * Change to ChatOpenAI * Return messages * Save chat history * Cleanup * Cleanup * Preserve X-Forwarded-For * Add mongo dependency for chatbot * Use old turbo model * FSession logs not clearer debug * Add ssn * Fix gateway service health * Chatbot typescript * Upgrade packages * Dummy commit * Lint * lint * Reduce max mem * Update chatbot * Update chatbot * Potential fix for code scanning alert no. 21: Flask app is run in debug mode Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Chatbot mcp impl * spotless * Fix chatbot * Spotless * Fix usage * MCP server fix (#303) * Remove errors * Remove variables not needed * Add management scripts * Make executable * Fix config * Fix config * Add init for chatbot * Add retry for apikey * Add retry for apikey * Chatbot UX fix * update tool versions * Lint fix * Upgrade golangci-lint * Npm lint fix --------- Co-authored-by: Dhruv Singhal <dhruv.singhal@traceable.ai> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: keyurdoshi03 <keyur.doshi@harness.io>
1 parent 9cdb8b9 commit 4508786

File tree

103 files changed

+14576
-5589
lines changed

Some content is hidden

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

103 files changed

+14576
-5589
lines changed

.github/workflows/pr-build.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
- name: Get branch name
3636
id: branch-name
3737
uses: tj-actions/branch-names@v8
38+
with:
39+
strip_tag_prefix: 'v'
3840

3941
- name: Current branch name
4042
run: |
@@ -46,7 +48,7 @@ jobs:
4648
if: steps.branch-name.outputs.is_tag == 'true'
4749
run: |
4850
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
49-
echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
51+
echo "TAG_LATEST=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
5052
5153
- name: Running on a branch and merge.
5254
if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main'
@@ -96,6 +98,17 @@ jobs:
9698
cache-from: type=gha,scope=workshop-service
9799
cache-to: type=gha,mode=max,scope=workshop-service
98100

101+
- name: Build crapi-chatbot image
102+
uses: docker/build-push-action@v3
103+
with:
104+
context: ./services/chatbot
105+
tags: crapi/crapi-chatbot:${{ env.TAG_LATEST }},crapi/crapi-chatbot:${{ env.TAG_NAME }}
106+
push: false
107+
load: true
108+
platforms: linux/amd64
109+
cache-from: type=gha,scope==chatbot-service
110+
cache-to: type=gha,mode=max,scope=chatbot-service
111+
99112
- name: Build crapi-community image
100113
uses: docker/build-push-action@v3
101114
with:
@@ -190,7 +203,7 @@ jobs:
190203
- name: Setup Python
191204
uses: actions/setup-python@v5
192205
with:
193-
python-version: '3.10'
206+
python-version: '3.11'
194207

195208
- name: Setup Java
196209
uses: actions/setup-java@v4
@@ -201,7 +214,7 @@ jobs:
201214
- name: Setup Go
202215
uses: actions/setup-go@v5
203216
with:
204-
go-version: '1.21'
217+
go-version: '1.23'
205218

206219
- name: Start the database
207220
run: docker compose -f services/docker-database.yml up -d
@@ -219,12 +232,12 @@ jobs:
219232
go run gotest.tools/gotestsum@latest --format testname --junitfile test-results/unit-tests.xml
220233
221234
- name: golangci-lint
222-
uses: golangci/golangci-lint-action@v3
235+
uses: golangci/golangci-lint-action@v8.0.0
223236
with:
224237
# Require: The version of golangci-lint to use.
225238
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
226239
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
227-
version: v1.54
240+
version: v2.2.1
228241
working-directory: services/community
229242

230243

.github/workflows/publish.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
- name: Get branch name
3838
id: branch-name
3939
uses: tj-actions/branch-names@v8
40+
with:
41+
strip_tag_prefix: 'v'
4042

4143
- name: Current branch name
4244
run: |
@@ -48,7 +50,7 @@ jobs:
4850
if: steps.branch-name.outputs.is_tag == 'true'
4951
run: |
5052
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
51-
echo "TAG_LATEST=latest" >> ${GITHUB_ENV}
53+
echo "TAG_LATEST=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
5254
5355
- name: Running on a branch and merge.
5456
if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main'
@@ -102,6 +104,16 @@ jobs:
102104
cache-from: type=gha,scope=workshop-service
103105
cache-to: type=gha,mode=max,scope=workshop-service
104106

107+
- name: Build crapi-chatbot all platforms and push to Docker Hub
108+
uses: docker/build-push-action@v3
109+
with:
110+
context: ./services/chatbot
111+
tags: crapi/crapi-chatbot:${{ env.TAG_LATEST }},crapi/crapi-chatbot:${{ env.TAG_NAME }}
112+
platforms: ${{ env.PLATFORMS }}
113+
push: true
114+
cache-from: type=gha,scope=chatbot-service
115+
cache-to: type=gha,mode=max,scope=chatbot-service
116+
105117
- name: Build crapi-community all platforms and push to Docker Hub
106118
uses: docker/build-push-action@v3
107119
with:
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: Release Publish
2+
on: workflow_dispatch
3+
4+
jobs:
5+
build-context:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Dump GitHub context
9+
env:
10+
GITHUB_CONTEXT: ${{ toJson(github) }}
11+
run: echo "$GITHUB_CONTEXT"
12+
build:
13+
needs: build-context
14+
strategy:
15+
matrix:
16+
include:
17+
- runner: ubuntu-latest
18+
platform: linux/amd64
19+
arch_alias: 'amd64'
20+
- runner: ubuntu-latest-arm64
21+
platform: linux/arm64
22+
arch_alias: 'arm64'
23+
runs-on: ${{ matrix.runner }}
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Env seen prerun
29+
run: env
30+
31+
- name: Get branch metadata
32+
id: branch-name
33+
uses: tj-actions/branch-names@v8
34+
35+
- name: Current tag name
36+
run: |
37+
echo "Tag if exist: ${{ steps.branch-name.outputs.tag }}"
38+
39+
- name: If not a tag, terminate the workflow
40+
if: steps.branch-name.outputs.is_tag != 'true'
41+
run: exit 1
42+
43+
- name: Running on a tag.
44+
run: |
45+
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV}
46+
echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" > tag_name.txt
47+
48+
# Archive the tag name
49+
- name: Archive tag name
50+
uses: actions/upload-artifact@v2
51+
with:
52+
name: tag_name
53+
path: tag_name.txt
54+
55+
# setup Docker build action
56+
- name: Set up Docker Buildx
57+
id: buildx
58+
uses: docker/setup-buildx-action@v3
59+
- name: Set up QEMU
60+
id: qemu
61+
uses: docker/setup-qemu-action@v3
62+
63+
- name: Login to DockerHub
64+
uses: docker/login-action@v3
65+
with:
66+
username: ${{ secrets.DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}
68+
69+
- name: Build crapi-identity all platforms and push to Docker Hub
70+
uses: docker/build-push-action@v3
71+
with:
72+
context: ./services/identity
73+
tags: crapi/crapi-identity:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
74+
platforms: ${{ matrix.platform }}
75+
push: true
76+
cache-from: type=gha,scope=identity-service
77+
cache-to: type=gha,mode=max,scope=identity-service
78+
79+
- name: Build crapi-workshop all platforms and push to Docker Hub
80+
uses: docker/build-push-action@v3
81+
with:
82+
context: ./services/workshop
83+
tags: crapi/crapi-workshop:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
84+
platforms: ${{ matrix.platform }}
85+
push: true
86+
cache-from: type=gha,scope=workshop-service
87+
cache-to: type=gha,mode=max,scope=workshop-service
88+
89+
- name: Build crapi-chatbot all platforms and push to Docker Hub
90+
uses: docker/build-push-action@v3
91+
with:
92+
context: ./services/chatbot
93+
tags: crapi/crapi-chatbot:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
94+
platforms: ${{ matrix.platform }}
95+
push: true
96+
cache-from: type=gha,scope=chatbot-service
97+
cache-to: type=gha,mode=max,scope=chatbot-service
98+
99+
- name: Build crapi-community all platforms and push to Docker Hub
100+
uses: docker/build-push-action@v3
101+
with:
102+
context: ./services/community
103+
tags: crapi/crapi-community:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
104+
platforms: ${{ matrix.platform }}
105+
push: true
106+
cache-from: type=gha,scope=community-service
107+
cache-to: type=gha,mode=max,scope=community-service
108+
109+
- name: Build crapi-web all platforms and push to Docker Hub
110+
uses: docker/build-push-action@v3
111+
with:
112+
context: ./services/web
113+
tags: crapi/crapi-web:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
114+
platforms: ${{ matrix.platform }}
115+
push: true
116+
cache-from: type=gha,scope=web-service
117+
cache-to: type=gha,mode=max,scope=web-service
118+
119+
- name: Build gateway-service all platforms and push to Docker Hub
120+
uses: docker/build-push-action@v3
121+
with:
122+
context: ./services/gateway-service
123+
tags: crapi/gateway-service:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
124+
platforms: ${{ matrix.platform }}
125+
push: true
126+
cache-from: type=gha,scope=gateway-service
127+
cache-to: type=gha,mode=max,scope=gateway-service
128+
129+
- name: Build mailhog all platforms and push to Docker Hub
130+
uses: docker/build-push-action@v3
131+
with:
132+
context: ./services/mailhog
133+
tags: crapi/mailhog:${{ env.TAG_NAME }}-${{ matrix.arch_alias }}
134+
platforms: ${{ matrix.platform }}
135+
push: true
136+
cache-from: type=gha,scope=mailhog-service
137+
cache-to: type=gha,mode=max,scope=mailhog-service
138+
139+
publish-manifests:
140+
needs: build
141+
runs-on: ubuntu-latest
142+
steps:
143+
- name: Checkout code
144+
uses: actions/checkout@v4
145+
146+
- name: Download tag name
147+
uses: actions/download-artifact@v2
148+
with:
149+
name: tag_name
150+
path: .
151+
152+
- name: Read tag name
153+
id: tag_name
154+
run: |
155+
echo "TAG_NAME=$(cat tag_name.txt)" >> $GITHUB_ENV
156+
157+
- name: Create and push manifest images for crapi-identity
158+
uses: Noelware/docker-manifest-action@v1
159+
with:
160+
inputs: |
161+
crapi/crapi-identity:${{ env.TAG_NAME }}-amd64
162+
crapi/crapi-identity:${{ env.TAG_NAME }}-arm64
163+
outputs: |
164+
crapi/crapi-identity:${{ env.TAG_NAME }}
165+
push: true
166+
167+
- name: Create and push manifest images for crapi-workshop
168+
uses: Noelware/docker-manifest-action@v1
169+
with:
170+
inputs: |
171+
crapi/crapi-workshop:${{ env.TAG_NAME }}-amd64
172+
crapi/crapi-workshop:${{ env.TAG_NAME }}-arm64
173+
outputs: |
174+
crapi/crapi-workshop:${{ env.TAG_NAME }}
175+
push: true
176+
177+
- name: Create and push manifest images for crapi-chatbot
178+
uses: Noelware/docker-manifest-action@v1
179+
with:
180+
inputs: |
181+
crapi/crapi-chatbot:${{ env.TAG_NAME }}-amd64
182+
crapi/crapi-chatbot:${{ env.TAG_NAME }}-arm64
183+
outputs: |
184+
crapi/crapi-chatbot:${{ env.TAG_NAME }}
185+
push: true
186+
187+
- name: Create and push manifest images for crapi-community
188+
uses: Noelware/docker-manifest-action@v1
189+
with:
190+
inputs: |
191+
crapi/crapi-community:${{ env.TAG_NAME }}-amd64
192+
crapi/crapi-community:${{ env.TAG_NAME }}-arm64
193+
outputs: |
194+
crapi/crapi-community:${{ env.TAG_NAME }}
195+
push: true
196+
197+
- name: Create and push manifest images for crapi-web
198+
uses: Noelware/docker-manifest-action@v1
199+
with:
200+
inputs: |
201+
crapi/crapi-web:${{ env.TAG_NAME }}-amd64
202+
crapi/crapi-web:${{ env.TAG_NAME }}-arm64
203+
outputs: |
204+
crapi/crapi-web:${{ env.TAG_NAME }}
205+
push: true
206+
207+
- name: Create and push manifest images for gateway-service
208+
uses: Noelware/docker-manifest-action@v1
209+
with:
210+
inputs: |
211+
crapi/gateway-service:${{ env.TAG_NAME }}-amd64
212+
crapi/gateway-service:${{ env.TAG_NAME }}-arm64
213+
outputs: |
214+
crapi/gateway-service:${{ env.TAG_NAME }}
215+
push: true
216+
217+
- name: Create and push manifest images for mailhog
218+
uses: Noelware/docker-manifest-action@v1
219+
with:
220+
inputs: |
221+
crapi/mailhog:${{ env.TAG_NAME }}-amd64
222+
crapi/mailhog:${{ env.TAG_NAME }}-arm64
223+
outputs: |
224+
crapi/mailhog:${{ env.TAG_NAME }}
225+
push: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ deploy/vagrant/.vagrant
33
.secrets
44
.vscode/
55
*.local
6+
services/chatbot/db
7+
services/certs/
8+
docker-compose.local.yml

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,5 @@ To know more about challenges in crAPI. Visit [challenges]
163163
164164
## Troubleshooting guide for general issues while installing and running crAPI
165165
If you need any help with installing and running crAPI you can check out this guide: [Troubleshooting guide crAPI](https://github.com/OWASP/crAPI/blob/main/docs/troubleshooting.md). If this doesn't solve your problem, please create an issue in Github Issues.
166+
167+

deploy/docker/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
IDENTITY_SERVER_PORT=8080
22
COMMUNITY_SERVER_PORT=8087
33
WORKSHOP_SERVER_PORT=8000
4+
CHATBOT_SERVER_PORT=5002
45
ENABLE_SHELL_INJECTION=false
56
ENABLE_LOG4J=false
67
LISTEN_IP="127.0.0.1"

deploy/docker/docker-compose.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
crapi-identity:
1616
container_name: crapi-identity
1717
image: crapi/crapi-identity:${VERSION:-latest}
18-
#ports:
18+
# ports:
1919
# - "${LISTEN_IP:-127.0.0.1}:8080:8080"
2020
volumes:
2121
- ./keys:/app/keys
@@ -150,6 +150,31 @@ services:
150150
cpus: '0.3'
151151
memory: 128M
152152

153+
crapi-chatbot:
154+
container_name: crapi-chatbot
155+
image: crapi/crapi-chatbot:${VERSION:-latest}
156+
environment:
157+
- TLS_ENABLED=${TLS_ENABLED:-false}
158+
- SERVER_PORT=${CHATBOT_SERVER_PORT:-5002}
159+
- DB_NAME=crapi
160+
- DB_USER=admin
161+
- DB_PASSWORD=crapisecretpassword
162+
- DB_HOST=postgresdb
163+
- DB_PORT=5432
164+
- MONGO_DB_HOST=mongodb
165+
- MONGO_DB_PORT=27017
166+
- MONGO_DB_USER=admin
167+
- MONGO_DB_PASSWORD=crapisecretpassword
168+
- MONGO_DB_NAME=crapi
169+
# - CHATBOT_OPENAI_API_KEY=
170+
depends_on:
171+
mongodb:
172+
condition: service_healthy
173+
crapi-identity:
174+
condition: service_healthy
175+
# ports:
176+
# - "${LISTEN_IP:-127.0.0.1}:5002:5002"
177+
153178
crapi-web:
154179
container_name: crapi-web
155180
image: crapi/crapi-web:${VERSION:-latest}
@@ -162,6 +187,7 @@ services:
162187
- COMMUNITY_SERVICE=crapi-community:${COMMUNITY_SERVER_PORT:-8087}
163188
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
164189
- WORKSHOP_SERVICE=crapi-workshop:${WORKSHOP_SERVER_PORT:-8000}
190+
- CHATBOT_SERVICE=crapi-chatbot:${CHATBOT_SERVER_PORT:-5002}
165191
- MAILHOG_WEB_SERVICE=mailhog:8025
166192
- TLS_ENABLED=${TLS_ENABLED:-false}
167193
depends_on:

0 commit comments

Comments
 (0)