From 84f75af123185dcbf9b60e5066823b8f66ddf8c0 Mon Sep 17 00:00:00 2001 From: Adam Wilson Date: Sat, 3 May 2025 12:00:18 -0600 Subject: [PATCH] add initial Garak tests --- .github/workflows/llmsecops-cicd.yml | 4 ++-- tests/tools/garak.config.yml | 5 +++++ tests/tools/garak.rest.json | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/tools/garak.config.yml create mode 100644 tests/tools/garak.rest.json diff --git a/.github/workflows/llmsecops-cicd.yml b/.github/workflows/llmsecops-cicd.yml index b4e74013a..6806a60f1 100644 --- a/.github/workflows/llmsecops-cicd.yml +++ b/.github/workflows/llmsecops-cicd.yml @@ -37,5 +37,5 @@ jobs: nohup python -m tests.api.server > server.log 2>&1 & sleep 2 curl -X POST -i localhost:9999 -d '{ "prompt": "describe a random planet in our solar system in 10 words or less" }' || true - cat server.log - garak --list_probes \ No newline at end of file + garak -v --config ${{ github.workspace }}/tests/tools/garak.config.yml --generator_option_file ${{ github.workspace }}/tests/tools/garak.rest.json --model_type=rest + cat server.log \ No newline at end of file diff --git a/tests/tools/garak.config.yml b/tests/tools/garak.config.yml new file mode 100644 index 000000000..ae210483c --- /dev/null +++ b/tests/tools/garak.config.yml @@ -0,0 +1,5 @@ +run: + generations: 1 + +plugins: + probe_spec: promptinject.HijackHateHumansMini \ No newline at end of file diff --git a/tests/tools/garak.rest.json b/tests/tools/garak.rest.json new file mode 100644 index 000000000..99a0707c7 --- /dev/null +++ b/tests/tools/garak.rest.json @@ -0,0 +1,19 @@ +{ + "rest": { + "RestGenerator": { + "name": "Microsoft ONNX Phi-3 LLM/GenAI REST API Service", + "uri": "http://localhost:9999/", + "method": "post", + "headers": { + "Content-Type": "application/json" + }, + "req_template_json_object": { + "prompt": "$INPUT" + }, + "response_json": true, + "response_json_field": "response", + "request_timeout": 120, + "verify_ssl": false + } + } +} \ No newline at end of file