|
| 1 | +{ |
| 2 | + "_metadata": { |
| 3 | + "name": "Security Scan Discord Report", |
| 4 | + "description": "Scan a container image with Trivy, build a prioritized CVE summary, post results to Discord, and save a JSON report artifact.", |
| 5 | + "category": "container-security", |
| 6 | + "tags": ["container", "cve", "trivy", "discord", "notification"], |
| 7 | + "author": "sentris-team", |
| 8 | + "version": "1.0.0" |
| 9 | + }, |
| 10 | + "manifest": { |
| 11 | + "name": "Security Scan Discord Report", |
| 12 | + "description": "Trivy image scan with Discord webhook notification and artifact report.", |
| 13 | + "version": "1.0.0", |
| 14 | + "author": "sentris-team", |
| 15 | + "category": "container-security", |
| 16 | + "tags": ["container", "cve", "trivy", "discord", "notification"], |
| 17 | + "entryPoint": "trigger_1", |
| 18 | + "nodeCount": 5, |
| 19 | + "edgeCount": 7 |
| 20 | + }, |
| 21 | + "graph": { |
| 22 | + "name": "Security Scan Discord Report", |
| 23 | + "description": "Authorized container image scan with Discord notification for triage teams.", |
| 24 | + "nodes": [ |
| 25 | + { |
| 26 | + "id": "trigger_1", |
| 27 | + "type": "core.workflow.entrypoint", |
| 28 | + "position": { "x": 100, "y": 260 }, |
| 29 | + "data": { |
| 30 | + "label": "Scan Input", |
| 31 | + "config": { |
| 32 | + "params": { |
| 33 | + "runtimeInputs": [ |
| 34 | + { |
| 35 | + "id": "imageRef", |
| 36 | + "label": "Container image reference", |
| 37 | + "type": "text", |
| 38 | + "required": true, |
| 39 | + "description": "Public or locally available container image reference, for example nginx:1.25 or node:18-alpine." |
| 40 | + } |
| 41 | + ] |
| 42 | + }, |
| 43 | + "inputOverrides": {} |
| 44 | + } |
| 45 | + } |
| 46 | + }, |
| 47 | + { |
| 48 | + "id": "trivy_image_scan", |
| 49 | + "type": "sentris.trivy.run", |
| 50 | + "position": { "x": 420, "y": 260 }, |
| 51 | + "data": { |
| 52 | + "label": "Scan Image CVEs", |
| 53 | + "config": { |
| 54 | + "params": { |
| 55 | + "scanType": "image", |
| 56 | + "severity": ["CRITICAL", "HIGH", "MEDIUM"], |
| 57 | + "format": "json" |
| 58 | + }, |
| 59 | + "inputOverrides": {} |
| 60 | + } |
| 61 | + } |
| 62 | + }, |
| 63 | + { |
| 64 | + "id": "assemble_report", |
| 65 | + "type": "core.logic.script", |
| 66 | + "position": { "x": 760, "y": 260 }, |
| 67 | + "data": { |
| 68 | + "label": "Build Scan Report", |
| 69 | + "config": { |
| 70 | + "params": { |
| 71 | + "variables": [ |
| 72 | + { "name": "imageRef", "type": "string" }, |
| 73 | + { "name": "vulnerabilities", "type": "list-json" }, |
| 74 | + { "name": "vulnerabilityCount", "type": "number" } |
| 75 | + ], |
| 76 | + "returns": [ |
| 77 | + { "name": "summaryText", "type": "string" }, |
| 78 | + { "name": "report", "type": "json" }, |
| 79 | + { "name": "attachmentContent", "type": "string" } |
| 80 | + ], |
| 81 | + "code": "export function script(input) {\n const vulnerabilities = Array.isArray(input.vulnerabilities) ? input.vulnerabilities : [];\n const severityRank = { critical: 4, high: 3, medium: 2, low: 1, info: 0, unknown: 0 };\n const normalizeSeverity = (value) => String(value || 'unknown').toLowerCase();\n const rankFor = (value) => severityRank[normalizeSeverity(value)] ?? 0;\n const priorityFindings = vulnerabilities\n .map((finding) => ({\n vulnerabilityId: finding?.vulnerabilityId,\n pkgName: finding?.pkgName,\n severity: normalizeSeverity(finding?.severity),\n title: finding?.title,\n fixedVersion: finding?.fixedVersion || null\n }))\n .filter((finding) => finding.vulnerabilityId && rankFor(finding.severity) >= 2)\n .sort((a, b) => rankFor(b.severity) - rankFor(a.severity))\n .slice(0, 25);\n const countsBySeverity = priorityFindings.reduce((acc, finding) => {\n acc[finding.severity] = (acc[finding.severity] || 0) + 1;\n return acc;\n }, {});\n const highestSeverity = priorityFindings[0]?.severity || 'none';\n const imageRef = input.imageRef || 'unknown image';\n const summaryText = `${imageRef}: ${priorityFindings.length} actionable CVEs (highest: ${highestSeverity})`;\n const report = {\n summary: {\n imageRef,\n vulnerabilityCount: Number(input.vulnerabilityCount || vulnerabilities.length),\n actionableFindings: priorityFindings.length,\n highestSeverity,\n countsBySeverity\n },\n priorityFindings\n };\n return {\n summaryText,\n report,\n attachmentContent: JSON.stringify(report, null, 2)\n };\n}" |
| 82 | + }, |
| 83 | + "inputOverrides": {} |
| 84 | + } |
| 85 | + } |
| 86 | + }, |
| 87 | + { |
| 88 | + "id": "discord_notify", |
| 89 | + "type": "core.notification.discord", |
| 90 | + "position": { "x": 1100, "y": 200 }, |
| 91 | + "data": { |
| 92 | + "label": "Post to Discord", |
| 93 | + "config": { |
| 94 | + "params": { |
| 95 | + "attachmentFileName": "scan-report.json", |
| 96 | + "attachmentContentFormat": "text", |
| 97 | + "attachmentMimeType": "application/json", |
| 98 | + "variables": [{ "name": "summaryText", "type": "string" }] |
| 99 | + }, |
| 100 | + "inputOverrides": { |
| 101 | + "webhookUrl": "{{SECRET_PLACEHOLDER}}", |
| 102 | + "content": "**Container scan complete** — {{summaryText}}", |
| 103 | + "embeds": "[{\"title\":\"CVE Scan Summary\",\"description\":\"{{summaryText}}\",\"color\":5814783}]" |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + }, |
| 108 | + { |
| 109 | + "id": "artifact_report", |
| 110 | + "type": "core.artifact.writer", |
| 111 | + "position": { "x": 1100, "y": 340 }, |
| 112 | + "data": { |
| 113 | + "label": "Save Scan Report", |
| 114 | + "config": { |
| 115 | + "params": { |
| 116 | + "fileExtension": ".json", |
| 117 | + "mimeType": "application/json", |
| 118 | + "saveToRunArtifacts": true, |
| 119 | + "publishToArtifactLibrary": false |
| 120 | + }, |
| 121 | + "inputOverrides": { |
| 122 | + "artifactName": "security-scan-discord-report-{{date}}" |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + ], |
| 128 | + "edges": [ |
| 129 | + { |
| 130 | + "id": "trigger_1-trivy_image_scan-imageRef", |
| 131 | + "source": "trigger_1", |
| 132 | + "target": "trivy_image_scan", |
| 133 | + "sourceHandle": "imageRef", |
| 134 | + "targetHandle": "target" |
| 135 | + }, |
| 136 | + { |
| 137 | + "id": "trigger_1-assemble_report-imageRef", |
| 138 | + "source": "trigger_1", |
| 139 | + "target": "assemble_report", |
| 140 | + "sourceHandle": "imageRef", |
| 141 | + "targetHandle": "imageRef" |
| 142 | + }, |
| 143 | + { |
| 144 | + "id": "trivy_image_scan-assemble_report-vulnerabilities", |
| 145 | + "source": "trivy_image_scan", |
| 146 | + "target": "assemble_report", |
| 147 | + "sourceHandle": "vulnerabilities", |
| 148 | + "targetHandle": "vulnerabilities" |
| 149 | + }, |
| 150 | + { |
| 151 | + "id": "trivy_image_scan-assemble_report-vulnerabilityCount", |
| 152 | + "source": "trivy_image_scan", |
| 153 | + "target": "assemble_report", |
| 154 | + "sourceHandle": "vulnerabilityCount", |
| 155 | + "targetHandle": "vulnerabilityCount" |
| 156 | + }, |
| 157 | + { |
| 158 | + "id": "assemble_report-discord_notify-summaryText", |
| 159 | + "source": "assemble_report", |
| 160 | + "target": "discord_notify", |
| 161 | + "sourceHandle": "summaryText", |
| 162 | + "targetHandle": "summaryText" |
| 163 | + }, |
| 164 | + { |
| 165 | + "id": "assemble_report-discord_notify-attachmentContent", |
| 166 | + "source": "assemble_report", |
| 167 | + "target": "discord_notify", |
| 168 | + "sourceHandle": "attachmentContent", |
| 169 | + "targetHandle": "attachmentContent" |
| 170 | + }, |
| 171 | + { |
| 172 | + "id": "assemble_report-artifact_report-report", |
| 173 | + "source": "assemble_report", |
| 174 | + "target": "artifact_report", |
| 175 | + "sourceHandle": "report", |
| 176 | + "targetHandle": "content" |
| 177 | + } |
| 178 | + ] |
| 179 | + }, |
| 180 | + "requiredSecrets": [ |
| 181 | + { |
| 182 | + "name": "DISCORD_WEBHOOK_URL", |
| 183 | + "type": "string", |
| 184 | + "description": "Discord Incoming Webhook URL for scan notifications" |
| 185 | + } |
| 186 | + ] |
| 187 | +} |
0 commit comments