This commit is contained in:
Karsten Jeppesen
2026-09-28 10:21:34 +02:00
parent 4757d36a4a
commit 2e13823624
3 changed files with 24 additions and 12 deletions
+15 -10
View File
@@ -1,15 +1,20 @@
Jenkinsfile with AI provisions Jenkinsfile with AI provisions
The Build Agent should provide the following environment (in alphabetical order): The Build Agent should provide the following environment (in alphabetical order):
- GITEA_AGENT in clear text - GITEA_AGENT in clear text
- GITEA_API_URL in clear text - GITEA_API_URL https://gitea.a.ucnit.eu/api/v1 in clear text
- GITEA_API_KEY in clear text - GITEA_API_KEY 046xxxxxxxxxxf76 in clear text
- GIT_USER in clear text - GIT_USER in clear text
- MAX_FILE_BYTES in clear text - MAX_FILE_BYTES 20000 in clear text
- OLLAMA_API_KEY through credentials:secret text - OLLAMA_API_KEY sk-b5844exxxxx01 in clear text
- OLLAMA_API_URI in clear text - OLLAMA_API_URI https://ollama.a.ucnit.eu/ollama/v1 in clear text
- OLLAMA_MODEL in clear text - OLLAMA_MODEL llama3.1:8b in clear text
- REQUEST_TIMEOUT_SEC through credentials:secret text - REQUEST_TIMEOUT_SEC 3600 in clear text
- FILE_EXTS in clear text (cshtml,cs,js,json) - FILE_EXTS cshtml,cs,js,json in clear text
And the following settings
- Remote root directory ./jenkins
- Labels builder
- Launch method Launch agents via ssh
- Host Key Verification Strategy Not verifying
+2
View File
@@ -16,6 +16,8 @@ if [[ -z "$HAS_FINDINGS" ]]; then
exit 0 exit 0
fi fi
GITEA_AGENT="CICD-SYSTEM" # temporarily set this
: "${GITEA_API_URL:?Missing GITEA_API_URL}" : "${GITEA_API_URL:?Missing GITEA_API_URL}"
: "${GITEA_API_KEY:?Missing GITEA_API_KEY}" : "${GITEA_API_KEY:?Missing GITEA_API_KEY}"
: "${GITEA_AGENT:?Missing GITEA_AGENT}" : "${GITEA_AGENT:?Missing GITEA_AGENT}"
+7 -2
View File
@@ -13,8 +13,9 @@ if [[ ! -s "$FILES_LIST" ]]; then
exit 0 exit 0
fi fi
TMP_DIR="$(mktemp -d)" TMP_DIR=".workflow/scan"
trap 'rm -rf "$TMP_DIR"' EXIT [ -d $TMP_DIR ] && rm -rf $TMP_DIR
mkdir -p $TMP_DIR
SYS_PROMPT=$'You are a precise secure code scanning assistant. Analyze the provided file content and return findings as STRICT JSON only with this schema:\n{\n "findings": [\n {\n "severity": "LOW|MEDIUM|HIGH|CRITICAL",\n "rule_id": "string-identifier",\n "line": number|null,\n "description": "short human-readable description",\n "recommendation": "concise fix guidance",\n "references": ["optional references URLs or identifiers"]\n }\n ]\n}\nRules:\n- Output ONLY JSON. No markdown, no code fences, no commentary.\n- If no issues, output {\"findings\":[]}.\n- Prefer concrete, reproducible findings over theoretical. Highlight secrets, insecure configs, vulnerable patterns, risky dependencies (if visible), command injection, path traversal, deserialization, SSRF, XSS, SQLi, hardcoded credentials, bad crypto, weak TLS, etc.\n- Provide line numbers when confidently known; otherwise null.\n' SYS_PROMPT=$'You are a precise secure code scanning assistant. Analyze the provided file content and return findings as STRICT JSON only with this schema:\n{\n "findings": [\n {\n "severity": "LOW|MEDIUM|HIGH|CRITICAL",\n "rule_id": "string-identifier",\n "line": number|null,\n "description": "short human-readable description",\n "recommendation": "concise fix guidance",\n "references": ["optional references URLs or identifiers"]\n }\n ]\n}\nRules:\n- Output ONLY JSON. No markdown, no code fences, no commentary.\n- If no issues, output {\"findings\":[]}.\n- Prefer concrete, reproducible findings over theoretical. Highlight secrets, insecure configs, vulnerable patterns, risky dependencies (if visible), command injection, path traversal, deserialization, SSRF, XSS, SQLi, hardcoded credentials, bad crypto, weak TLS, etc.\n- Provide line numbers when confidently known; otherwise null.\n'
@@ -82,6 +83,10 @@ $code + "
echo "[INFO] [$idx] Scanning $file (${bytes} bytes) with model=$OLLAMA_MODEL ..." echo "[INFO] [$idx] Scanning $file (${bytes} bytes) with model=$OLLAMA_MODEL ..."
resp_json="$TMP_DIR/resp_$idx.json" resp_json="$TMP_DIR/resp_$idx.json"
set +e set +e
# HERE BE DRAGONS
echo "[DEBUG] endpoint=[${OLLAMA_API_URI%/}/chat/completions]"
echo "[DEBUG] Authorization: Bearer ${OLLAMA_API_KEY}"
http_code=$(curl -sS -w "%{http_code}" -o "$resp_json" \ http_code=$(curl -sS -w "%{http_code}" -o "$resp_json" \
--max-time "$REQUEST_TIMEOUT_SEC" --connect-timeout 10 \ --max-time "$REQUEST_TIMEOUT_SEC" --connect-timeout 10 \
-H "Authorization: Bearer ${OLLAMA_API_KEY}" \ -H "Authorization: Bearer ${OLLAMA_API_KEY}" \