AWS Lambda 설정: Snyk을 Slack에 연결하는 Lambda 함수 생성
{ "name": "snyk-webhook-handler", "version": "1.0.0", "description": "Snyk to Slack Webhook Integration", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "axios": "^1.1.3", "crypto": "^1.0.1" } }const crypto = require('crypto') const axios = require('axios') let slackWebhookUrl = '<your_slackWebhookUrl_here>' // adjust //customised messaging to Slack with issue information, modify as needed async function messageSlack( message, snykProjectUrl, snykProjectName, snykIssuePackage, snykIssueUrl, snykIssueId, severity, snykIssuePriority ) { //strings modified to avoid Axios/Slack errors snykProjectUrl = snykProjectUrl.replace(/['"]+/g, '') snykProjectName = snykProjectName.replace(/['"]+/g, '') snykIssueUrl = snykIssueUrl.replace(/['"]+/g, '') snykIssueId = snykIssueId.replace(/['"]+/g, '') snykIssuePackage = snykIssuePackage.replace(/['"]+/g, '') severity = severity.replace(/['"]+/g, '') //construct message let payload = { text: `${message}`, blocks: [ { type: 'header', text: { type: 'plain_text', text: `${message}`, }, }, { type: 'section', text: { type: 'mrkdwn', text: `Snyk has found a new vulnerability in the project:\n*<${snykProjectUrl}|${snykProjectName}>*`, }, }, { type: 'divider', }, { type: 'section', fields: [ { type: 'mrkdwn', text: `*Package name:*
Lambda 함수 생성을 위한 입력 항목이 포함된 AWS 콘솔 AWS 코드 소스 표시
Last updated