Compare commits

...
1 Commits
Author SHA1 Message Date
Karsten Jeppesen a7ca85a772 transitive
CICD-UCN/QuizSystem/pipeline/head This commit looks good
2026-11-25 08:48:46 +01:00
4 changed files with 27 additions and 6 deletions
+12 -4
View File
@@ -97,7 +97,9 @@ pipeline {
}
stage('Scan with Ollama') {
when { expression { branch 'Security' && fileExists('text_files.txt') && sh(script: "test -s text_files.txt", returnStatus: true) == 0 } }
when {
branch 'Security'
}
steps {
sh ".workflow/scan_with_ollama.sh \"$TEXT_FILES_FILE\" \"$SCAN_JSON_FILE\" \"$OLLAMA_MODEL\" \"$MAX_FILE_BYTES\" \"$REQUEST_TIMEOUT_SEC\""
archiveArtifacts artifacts: "$SCAN_JSON_FILE", allowEmptyArchive: true
@@ -105,7 +107,9 @@ pipeline {
}
stage('Build Markdown Report') {
when { expression { branch 'Security' && fileExists('text_files.txt') && sh(script: "test -s text_files.txt", returnStatus: true) == 0 } }
when {
branch 'Security'
}
steps {
sh ".workflow/build_markdown_report.sh \"$SCAN_JSON_FILE\" \"$REPORT_FILE\""
archiveArtifacts artifacts: "$REPORT_FILE", allowEmptyArchive: true
@@ -113,14 +117,18 @@ pipeline {
}
stage('Report to Gitea (Issue)') {
when { expression { branch 'Security' && fileExists('text_files.txt') && sh(script: "test -s text_files.txt", returnStatus: true) == 0 } }
when {
branch 'Security'
}
steps {
sh ".workflow/create_gitea_issue.sh \"$REPORT_FILE\""
}
}
stage('Quality Gate') {
when { expression { branch 'Security' && fileExists('text_files.txt') && sh(script: "test -s text_files.txt", returnStatus: true) == 0 } }
when {
branch 'Security'
}
steps {
sh ".workflow/evaluate_threshold.sh \"$SCAN_JSON_FILE\" \"$FAIL_ON_MEDIUM_OR_HIGH\""
}
+6
View File
@@ -12,4 +12,10 @@ The Build Agent should provide the following environment (in alphabetical order)
- REQUEST_TIMEOUT_SEC through credentials:secret text
- FILE_EXTS in clear text (cshtml,cs,js,json)
And the following settings
- Remote root directory ~/jenkins
- Labels builder
- Launch method Launch agents via ssh
- Host Key Verification Strategy Not verifying
\ No newline at end of file
+2
View File
@@ -16,6 +16,8 @@ if [[ -z "$HAS_FINDINGS" ]]; then
exit 0
fi
GITEA_AGENT="CICD-SYSTEM" # temporarily set this
: "${GITEA_API_URL:?Missing GITEA_API_URL}"
: "${GITEA_API_KEY:?Missing GITEA_API_KEY}"
: "${GITEA_AGENT:?Missing GITEA_AGENT}"
+7 -2
View File
@@ -13,8 +13,9 @@ if [[ ! -s "$FILES_LIST" ]]; then
exit 0
fi
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
TMP_DIR=".workflow/scan"
[ -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'
@@ -82,6 +83,10 @@ $code + "
echo "[INFO] [$idx] Scanning $file (${bytes} bytes) with model=$OLLAMA_MODEL ..."
resp_json="$TMP_DIR/resp_$idx.json"
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" \
--max-time "$REQUEST_TIMEOUT_SEC" --connect-timeout 10 \
-H "Authorization: Bearer ${OLLAMA_API_KEY}" \