Skip to content

Commit b0a3d87

Browse files
authored
Merge pull request #64 from SAP/develop
Release v0.3.0
2 parents c5006da + fcdfdb2 commit b0a3d87

55 files changed

Lines changed: 1408 additions & 340 deletions

Some content is hidden

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

.github/workflows/changelog-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121

2222
- name: Run Changelog CI
23-
uses: saadmk11/changelog-ci@v1.1.2
23+
uses: saadmk11/changelog-ci@v1.2.0
2424
with:
2525
# Optional, you can provide any name for your changelog file,
2626
# changelog_filename: CHANGELOG.md

.github/workflows/installation-test.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ jobs:
3131
cache-dependency-path: backend-agent/requirements.txt
3232
- run: pip install -r backend-agent/requirements.txt
3333

34-
- name: Start server
34+
- name: Start server and check health
3535
run: |
3636
cd backend-agent
37-
DISABLE_AGENT=1 python main.py &
38-
sleep 10
39-
40-
- name: Check server health
41-
run: |
42-
curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health
37+
DISABLE_AGENT=1 DB_PATH=${RUNNER_TEMP}/data.db python main.py > server.log 2>&1 &
38+
for i in {1..20}; do
39+
sleep 1
40+
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health || true)
41+
if [ "$status" -eq 200 ]; then
42+
echo "Health check succeeded"
43+
cat server.log
44+
exit 0
45+
fi
46+
done
47+
echo "Health check failed after waiting"
48+
cat server.log
49+
exit 1

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ venv/
8989
ENV/
9090
env.bak/
9191
venv.bak/
92+
venv310
93+
cache
94+
95+
# Frontend Environments
96+
frontend/src/environments/environment.ts
9297

9398
# Spyder project settings
9499
.spyderproject
@@ -138,6 +143,3 @@ prompt_success.txt
138143
result_gptfuzz.txt
139144
codeattack_success.txt
140145
artprompt_success.json
141-
142-
# Frontend Environments
143-
frontend/src/environments

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Version: v0.3.0
2+
3+
* [#46](https://github.com/SAP/STARS/pull/46): Risk dashboard UI
4+
* [#51](https://github.com/SAP/STARS/pull/51): Bump requests from 2.32.3 to 2.32.4 in /backend-agent
5+
* [#52](https://github.com/SAP/STARS/pull/52): Update pyrit.py implementation to ensure comatibility with pyrit 0.9.0
6+
* [#54](https://github.com/SAP/STARS/pull/54): Align langchain and pyrit dependencies
7+
* [#55](https://github.com/SAP/STARS/pull/55): Fix garak, langchain, and pyrit dependency conflicts
8+
* [#56](https://github.com/SAP/STARS/pull/56): Update models with June 2025 availabilities
9+
* [#59](https://github.com/SAP/STARS/pull/59): Fix db usage with attacks
10+
* [#60](https://github.com/SAP/STARS/pull/60): Merge develop into docker
11+
* [#61](https://github.com/SAP/STARS/pull/61): Dockerize services
12+
* [#63](https://github.com/SAP/STARS/pull/63): aligned frontend with db
13+
14+
115
# Version: v0.2.1
216

317
* [#34](https://github.com/SAP/STARS/pull/34): Support aicore-mistralai models

backend-agent/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
cache
44

55
# Libraries
6-
venv
6+
venv*
7+
.venv*
78

89
# Logs
910
traces

backend-agent/.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,18 @@ API_KEY=super-secret-change-me
1212
DEBUG=True
1313

1414
RESULT_SUMMARIZE_MODEL=gpt-4
15+
16+
# Models for agent.py
17+
AGENT_MODEL=gpt-4
18+
EMBEDDING_MODEL=text-embedding-ada-002
19+
20+
# Database path
21+
DB_PATH=/path_to/database.db
22+
23+
# AICORE configuration for backend (in case there is no configuration in
24+
# ~/.aicore/config.json). When using docker, these variables need to be set
25+
# AICORE_AUTH_URL=
26+
# AICORE_CLIENT_ID=
27+
# AICORE_CLIENT_SECRET=
28+
# AICORE_BASE_URL=
29+
# AICORE_RESOURCE_GROUP=

backend-agent/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ FROM python:3.11
33
WORKDIR /app
44

55
COPY requirements.txt .
6-
RUN --mount=type=ssh pip install -r requirements.txt --no-cache-dir
6+
RUN pip install -r requirements.txt --no-cache-dir
77

88
COPY . .
99

1010
EXPOSE 8080
1111
CMD [ "python", "main.py" ]
12-

backend-agent/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ Before running the tool, make sure to have an account configured and fully
1717
working on SAP AI Core (requires a SAP BTP subaccount with a running AI Core service instance).
1818

1919
Please note that the agent requires `gpt-4` LLM and `text-embedding-ada-002`
20-
embedding function. For the default attack suite, additional the model
21-
`mistralai--mixtral-8x7b-instruct-v01` is used.
20+
embedding function.
2221
They must be already **deployed and running in SAP AI Core** before running this
2322
tool.
24-
Refer [to the official documentation](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub) for what other models it is possible to deploy.
23+
Refer [to the official documentation](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub) for what other models it is possible to deploy and to the [official SAP note](https://me.sap.com/notes/3437766) for models and regions availability.
2524

2625
### Support for non-SAP AI Core models
27-
In general, the pentest tools integrated in the agent can be run on LLMs deployed in SAP AI Core, but also custom inference servers (e.g., vllm or a local ollama) are supported.
26+
In general, the pentest tools integrated in the agent can be run on LLMs deployed in SAP AI Core, but also custom inference servers (e.g., vllm and ollama) are supported.
2827

2928

3029
## Installation

backend-agent/agent.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
3+
from dotenv import load_dotenv
14
from gen_ai_hub.proxy.core.proxy_clients import set_proxy_version
25
from gen_ai_hub.proxy.langchain.init_models import (
36
init_llm, init_embedding_model)
@@ -10,6 +13,11 @@
1013
from langchain_community.document_loaders import DirectoryLoader
1114
from langchain_community.vectorstores import FAISS
1215

16+
17+
# load env variables
18+
load_dotenv()
19+
AGENT_MODEL = os.environ.get('AGENT_MODEL', 'gpt-4')
20+
EMBEDDING_MODEL = os.environ.get('EMBEDDING_MODEL', 'text-embedding-ada-002')
1321
# Use models deployed in SAP AI Core
1422
set_proxy_version('gen-ai-hub')
1523

@@ -29,7 +37,7 @@
2937
###############################################################################
3038
# SAP-compliant embedding models
3139
# https://github.tools.sap/AI-Playground-Projects/llm-commons#embedding-models
32-
underlying_embeddings = init_embedding_model('text-embedding-ada-002')
40+
underlying_embeddings = init_embedding_model(EMBEDDING_MODEL)
3341
# Initialize local cache for faster loading of subsequent executions
3442
fs = LocalFileStore('./cache')
3543
# Link the embedding and the local cache system, and define a namespace
@@ -131,7 +139,7 @@ def get_retriever(document_path: str,
131139

132140
# Initialize the LLM model to use, among the ones provided by SAP
133141
# The max token count needs to be increased so that responses are not cut off.
134-
llm = init_llm(model_name='gpt-4', max_tokens=1024)
142+
llm = init_llm(model_name=AGENT_MODEL, max_tokens=4096)
135143

136144
# Chain
137145
# https://python.langchain.com/docs/modules/chains

backend-agent/app/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
3+
from dotenv import load_dotenv
4+
from flask import Flask
5+
6+
from .db.models import db
7+
8+
9+
load_dotenv()
10+
11+
db_path = os.getenv('DB_PATH')
12+
13+
if not db_path:
14+
raise EnvironmentError(
15+
'Missing DB_PATH environment variable. Please set DB_PATH in your '
16+
'.env file to a valid SQLite file path.'
17+
)
18+
19+
20+
def create_app():
21+
app = Flask(__name__)
22+
# Database URI configuration
23+
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{db_path}'
24+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
25+
26+
# Create every SQLAlchemy tables defined in models.py
27+
with app.app_context():
28+
db.init_app(app)
29+
db.create_all()
30+
31+
return app

0 commit comments

Comments
 (0)