{"id":459294,"date":"2025-05-12T09:00:21","date_gmt":"2025-05-12T09:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459294"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459294","title":{"rendered":"<span>Webhook \u0443 Harbor \u0438\u043b\u0438 \u043a\u0430\u043a \u044f \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e \u043f\u0443\u0448\u0430\u0445 docker images \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043b\u0430\u043b \u0447\u0430\u0441\u0442\u044c \u2014 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u0443\u0448\u0438 \u0432 Harbor. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0433\u043e webhook. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432\u0441\u0435 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0438\u0436\u0435:  <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/36f\/0d4\/7bc\/36f0d47bcac6efe95ef5496f40f64452.png\" alt=\"\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f webhook\" title=\"\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f webhook\" width=\"571\" height=\"179\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/36f\/0d4\/7bc\/36f0d47bcac6efe95ef5496f40f64452.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/36f\/0d4\/7bc\/36f0d47bcac6efe95ef5496f40f64452.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f webhook<\/figcaption><\/div>\n<\/figure>\n<div class=\"floating-image\">\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.  <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f webhook<\/strong><\/p>\n<\/div>\n<ol>\n<li>\n<p><strong>SCANNING_STOPPED<\/strong> \u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430. <\/p>\n<\/li>\n<li>\n<p><strong>PULL_ARTIFACT<\/strong> \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 ( pulls ) \u043e\u0431\u0440\u0430\u0437.  <\/p>\n<\/li>\n<li>\n<p><strong>SCANNING_COMPLETED<\/strong> \u0421\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445. <\/p>\n<\/li>\n<li>\n<p><strong>DELETE_ARTIFACT<\/strong> \u0421\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ol>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.  <\/p>\n<pre><code class=\"yaml\"># conf.toml  [telegram] bot_token        = \"YOUR_BOT_TOKEN\" chat_id          = \"-1001234567890\" message_thread_id = \"1234\"      # \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0443\u0441\u0442\u044b\u043c\/\u0443\u0434\u0430\u043b\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e  [markdown] # \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c escape_chars = [\"\\\\\", \"_\", \"*\", \"[\", \"]\", \"(\", \")\", \"~\", \"`\", \"&gt;\", \"#\", \"+\", \"-\", \"=\", \"|\", \"{\", \"}\", \"!\"]  [events] # \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 PUSH_ARTIFACT        = true PULL_ARTIFACT        = true DELETE_ARTIFACT      = true SCANNING_STOPPED     = true SCANNING_COMPLETED   = true<\/code><\/pre>\n<h4>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f  <\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043e\u0431\u0449\u0438\u0439 JSON \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439:  <\/p>\n<pre><code class=\"json\">[   {     \"type\": \"SCANNING_STOPPED\",     \"occur_at\": 1746597835,     \"operator\": \"auto\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"1.1.1\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.1.1\",           \"scan_overview\": {             \"application\/vnd.security.vulnerability.report; version=1.1\": {               \"report_id\": \"ec84315d-3f08-42cc-bdc7-491953540cda\",               \"scan_status\": \"Stopped\",               \"severity\": \"\",               \"duration\": 13,               \"summary\": null,               \"start_time\": \"2025-05-07T06:03:42Z\",               \"end_time\": \"2025-05-07T06:03:55Z\",               \"complete_percent\": 0             }           }         }       ],       \"repository\": {         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"PULL_ARTIFACT\",     \"occur_at\": 1746597854,     \"operator\": \"robot$repo+Trivy-16c5e31b-2b09-11f0-87be-0242ac180003\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:@sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\"         }       ],       \"repository\": {         \"date_created\": 1733465413,         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"SCANNING_COMPLETED\",     \"occur_at\": 1746597860,     \"operator\": \"auto\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"1.1.1\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.1.1\",           \"scan_overview\": {             \"application\/vnd.security.vulnerability.report; version=1.1\": {               \"report_id\": \"39ba459d-3642-4de6-aaac-865b94cdb006\",               \"scan_status\": \"Success\",               \"severity\": \"Critical\",               \"duration\": 12,               \"summary\": {                 \"total\": 1005,                 \"fixable\": 7,                 \"summary\": {                   \"Critical\": 2,                   \"High\": 73,                   \"Low\": 422,                   \"Medium\": 506,                   \"Unknown\": 2                 }               },               \"start_time\": \"2025-05-07T06:04:08Z\",               \"end_time\": \"2025-05-07T06:04:20Z\",               \"scanner\": {                 \"name\": \"Trivy\",                 \"vendor\": \"Aqua Security\",                 \"version\": \"v0.45.0\"               },               \"complete_percent\": 100             }           }         }       ],       \"repository\": {         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"DELETE_ARTIFACT\",     \"occur_at\": 1746597914,     \"operator\": \"Admin\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf123123123123123123\",           \"tag\": \"1.0.0\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.0.0\"         }       ],       \"repository\": {         \"date_created\": 1733465413,         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   } ]<\/code><\/pre>\n<h2>PULL_ARTIFACT<\/h2>\n<p>PULL_ARTIFACT &#8212; \u044d\u0442\u043e \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0437. \u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u2014 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043f\u0430\u043b \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"PULL_ARTIFACT\":         for r in resources:             tag = escape_markdown(r.get(\"tag\", \"\u2014\"))             url = r.get(\"resource_url\", \"\u2014\")             msg = (                 \"\ud83d\udce5 *Pull \u0432 Harbor*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<h2>DELETE_ARTIFACT<\/h2>\n<p>DELETE_ARTIFACT &#8212; \u044d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u043a\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0437\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e Harbor-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:   <\/p>\n<pre><code class=\"python\">    elif event_type == \"DELETE_ARTIFACT\":         for r in resources:             tag = escape_markdown(r.get(\"tag\", \"\u2014\"))             url = r.get(\"resource_url\", \"\u2014\")             msg = (                 \"\ud83d\uddd1\ufe0f *\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 \u0432 Harbor*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<p> \u0425\u043e\u0442\u044f \u0441\u043c\u0430\u0439\u043b\u0438\u043a\u0438 \u2014 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0440\u0443\u0436\u0435\u043b\u044e\u0431\u043d\u044b\u043c\u0438. <\/p>\n<h2>SCANNING_STOPPED<\/h2>\n<p>SCANNING_STOPPED &#8212; \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043c\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u2014 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e, \u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043e\u0431\u0440\u0430\u0437\u0430.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"SCANNING_STOPPED\":         for r in resources:             tag     = escape_markdown(r.get(\"tag\", \"\u2014\"))             url     = r.get(\"resource_url\", \"\u2014\")             overview = r.get(\"scan_overview\", {})             detail  = next(iter(overview.values()), {})             status  = escape_markdown(detail.get(\"scan_status\", \"\u2014\"))             duration = detail.get(\"duration\", 0)             msg = (                 \"\ud83d\udd0d *\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u0421\u0442\u0430\u0442\u0443\u0441 \u0441\u043a\u0430\u043d\u0430:* {status}\\n\"                 f\"*\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:* {duration}s\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<h2>SCANNING_COMPLETED<\/h2>\n<p>SCANNING_COMPLETED &#8212; \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Harbor \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432). \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"SCANNING_COMPLETED\":         for r in resources:             tag      = escape_markdown(r.get(\"tag\", \"\u2014\"))             url      = r.get(\"resource_url\", \"\u2014\")             overview = r.get(\"scan_overview\", {})             detail   = next(iter(overview.values()), {})             status   = escape_markdown(detail.get(\"scan_status\", \"\u2014\"))             duration = detail.get(\"duration\", 0)             severity = escape_markdown(detail.get(\"severity\", \"\u2014\"))             summary  = detail.get(\"summary\", {}) or {}             total    = summary.get(\"total\", 0)             fixable  = summary.get(\"fixable\", 0)             counts   = summary.get(\"summary\", {})              # \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0443 \u043f\u043e \u0443\u0440\u043e\u0432\u043d\u044f\u043c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438             counts_lines = \"\"             for lvl, cnt in counts.items():                 lvl_esc = escape_markdown(lvl)                 counts_lines += f\"*{lvl_esc}:* {cnt}\\n\"              scanner = detail.get(\"scanner\", {})             sc_name = escape_markdown(scanner.get(\"name\", \"\u2014\"))             sc_ver  = escape_markdown(scanner.get(\"version\", \"\u2014\"))              msg = (                 \"\ud83d\udd0d *\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u0421\u0442\u0430\u0442\u0443\u0441 \u0441\u043a\u0430\u043d\u0430:* {status}\\n\"                 f\"*\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:* {duration}s\\n\"                 f\"*\u041a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c (\u043c\u0430\u043a\u0441):* {severity}\\n\"                 f\"*\u0412\u0441\u0435\u0433\u043e \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439:* {total}\\n\"                 f\"*\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c\u043e:* {fixable}\\n\"                 f\"{counts_lines}\"                 f\"*\u0421\u043a\u0430\u043d\u0435\u0440:* {sc_name} {sc_ver}\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043c\u0435\u0440\u044b. <\/p>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u043b\u0430\u043d\u044b<\/strong> <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c webhook. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0445\u043e\u0447\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u044f\u043c\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u2014 \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443.  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0421\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438! \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, <a href=\"https:\/\/github.com\/sergey-akhmineev\/webhook-harbor-telegram\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908460\/\"> https:\/\/habr.com\/ru\/articles\/908460\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u0443\u0448\u0438 \u0432 Harbor. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0433\u043e webhook. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432\u0441\u0435 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0438\u0436\u0435:  <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f webhook<\/figcaption><\/div>\n<\/figure>\n<div class=\"floating-image\">\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.  <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f webhook<\/strong><\/p>\n<\/div>\n<ol>\n<li>\n<p><strong>SCANNING_STOPPED<\/strong> \u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430. <\/p>\n<\/li>\n<li>\n<p><strong>PULL_ARTIFACT<\/strong> \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 ( pulls ) \u043e\u0431\u0440\u0430\u0437.  <\/p>\n<\/li>\n<li>\n<p><strong>SCANNING_COMPLETED<\/strong> \u0421\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445. <\/p>\n<\/li>\n<li>\n<p><strong>DELETE_ARTIFACT<\/strong> \u0421\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ol>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.  <\/p>\n<pre><code class=\"yaml\"># conf.toml  [telegram] bot_token        = \"YOUR_BOT_TOKEN\" chat_id          = \"-1001234567890\" message_thread_id = \"1234\"      # \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0443\u0441\u0442\u044b\u043c\/\u0443\u0434\u0430\u043b\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e  [markdown] # \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c escape_chars = [\"\\\\\", \"_\", \"*\", \"[\", \"]\", \"(\", \")\", \"~\", \"`\", \"&gt;\", \"#\", \"+\", \"-\", \"=\", \"|\", \"{\", \"}\", \"!\"]  [events] # \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 PUSH_ARTIFACT        = true PULL_ARTIFACT        = true DELETE_ARTIFACT      = true SCANNING_STOPPED     = true SCANNING_COMPLETED   = true<\/code><\/pre>\n<h4>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f  <\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043e\u0431\u0449\u0438\u0439 JSON \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439:  <\/p>\n<pre><code class=\"json\">[   {     \"type\": \"SCANNING_STOPPED\",     \"occur_at\": 1746597835,     \"operator\": \"auto\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"1.1.1\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.1.1\",           \"scan_overview\": {             \"application\/vnd.security.vulnerability.report; version=1.1\": {               \"report_id\": \"ec84315d-3f08-42cc-bdc7-491953540cda\",               \"scan_status\": \"Stopped\",               \"severity\": \"\",               \"duration\": 13,               \"summary\": null,               \"start_time\": \"2025-05-07T06:03:42Z\",               \"end_time\": \"2025-05-07T06:03:55Z\",               \"complete_percent\": 0             }           }         }       ],       \"repository\": {         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"PULL_ARTIFACT\",     \"occur_at\": 1746597854,     \"operator\": \"robot$repo+Trivy-16c5e31b-2b09-11f0-87be-0242ac180003\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:@sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\"         }       ],       \"repository\": {         \"date_created\": 1733465413,         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"SCANNING_COMPLETED\",     \"occur_at\": 1746597860,     \"operator\": \"auto\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf\",           \"tag\": \"1.1.1\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.1.1\",           \"scan_overview\": {             \"application\/vnd.security.vulnerability.report; version=1.1\": {               \"report_id\": \"39ba459d-3642-4de6-aaac-865b94cdb006\",               \"scan_status\": \"Success\",               \"severity\": \"Critical\",               \"duration\": 12,               \"summary\": {                 \"total\": 1005,                 \"fixable\": 7,                 \"summary\": {                   \"Critical\": 2,                   \"High\": 73,                   \"Low\": 422,                   \"Medium\": 506,                   \"Unknown\": 2                 }               },               \"start_time\": \"2025-05-07T06:04:08Z\",               \"end_time\": \"2025-05-07T06:04:20Z\",               \"scanner\": {                 \"name\": \"Trivy\",                 \"vendor\": \"Aqua Security\",                 \"version\": \"v0.45.0\"               },               \"complete_percent\": 100             }           }         }       ],       \"repository\": {         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   },   {     \"type\": \"DELETE_ARTIFACT\",     \"occur_at\": 1746597914,     \"operator\": \"Admin\",     \"event_data\": {       \"resources\": [         {           \"digest\": \"sha256:280b85260a6613bf08bd1234512341234123412341234123412gvsdfgdf123123123123123123\",           \"tag\": \"1.0.0\",           \"resource_url\": \"127.0.0.1\/repo\/repo_image:1.0.0\"         }       ],       \"repository\": {         \"date_created\": 1733465413,         \"name\": \"repo_image\",         \"namespace\": \"repo\",         \"repo_full_name\": \"repo\/repo_image\",         \"repo_type\": \"public\"       }     }   } ]<\/code><\/pre>\n<h2>PULL_ARTIFACT<\/h2>\n<p>PULL_ARTIFACT &#8212; \u044d\u0442\u043e \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0437. \u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u2014 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043f\u0430\u043b \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"PULL_ARTIFACT\":         for r in resources:             tag = escape_markdown(r.get(\"tag\", \"\u2014\"))             url = r.get(\"resource_url\", \"\u2014\")             msg = (                 \"\ud83d\udce5 *Pull \u0432 Harbor*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<h2>DELETE_ARTIFACT<\/h2>\n<p>DELETE_ARTIFACT &#8212; \u044d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u043a\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0437\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e Harbor-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:   <\/p>\n<pre><code class=\"python\">    elif event_type == \"DELETE_ARTIFACT\":         for r in resources:             tag = escape_markdown(r.get(\"tag\", \"\u2014\"))             url = r.get(\"resource_url\", \"\u2014\")             msg = (                 \"\ud83d\uddd1\ufe0f *\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 \u0432 Harbor*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<p> \u0425\u043e\u0442\u044f \u0441\u043c\u0430\u0439\u043b\u0438\u043a\u0438 \u2014 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0440\u0443\u0436\u0435\u043b\u044e\u0431\u043d\u044b\u043c\u0438. <\/p>\n<h2>SCANNING_STOPPED<\/h2>\n<p>SCANNING_STOPPED &#8212; \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043c\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u2014 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e, \u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043e\u0431\u0440\u0430\u0437\u0430.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"SCANNING_STOPPED\":         for r in resources:             tag     = escape_markdown(r.get(\"tag\", \"\u2014\"))             url     = r.get(\"resource_url\", \"\u2014\")             overview = r.get(\"scan_overview\", {})             detail  = next(iter(overview.values()), {})             status  = escape_markdown(detail.get(\"scan_status\", \"\u2014\"))             duration = detail.get(\"duration\", 0)             msg = (                 \"\ud83d\udd0d *\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u0421\u0442\u0430\u0442\u0443\u0441 \u0441\u043a\u0430\u043d\u0430:* {status}\\n\"                 f\"*\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:* {duration}s\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<h2>SCANNING_COMPLETED<\/h2>\n<p>SCANNING_COMPLETED &#8212; \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Harbor \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432). \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438.  <\/p>\n<pre><code class=\"python\">    elif event_type == \"SCANNING_COMPLETED\":         for r in resources:             tag      = escape_markdown(r.get(\"tag\", \"\u2014\"))             url      = r.get(\"resource_url\", \"\u2014\")             overview = r.get(\"scan_overview\", {})             detail   = next(iter(overview.values()), {})             status   = escape_markdown(detail.get(\"scan_status\", \"\u2014\"))             duration = detail.get(\"duration\", 0)             severity = escape_markdown(detail.get(\"severity\", \"\u2014\"))             summary  = detail.get(\"summary\", {}) or {}             total    = summary.get(\"total\", 0)             fixable  = summary.get(\"fixable\", 0)             counts   = summary.get(\"summary\", {})              # \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0443 \u043f\u043e \u0443\u0440\u043e\u0432\u043d\u044f\u043c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438             counts_lines = \"\"             for lvl, cnt in counts.items():                 lvl_esc = escape_markdown(lvl)                 counts_lines += f\"*{lvl_esc}:* {cnt}\\n\"              scanner = detail.get(\"scanner\", {})             sc_name = escape_markdown(scanner.get(\"name\", \"\u2014\"))             sc_ver  = escape_markdown(scanner.get(\"version\", \"\u2014\"))              msg = (                 \"\ud83d\udd0d *\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e*\\n\"                 f\"*\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:* {repo_name}\\n\"                 f\"*\u0422\u0435\u0433:* {tag}\\n\"                 f\"*URL:* `{url}`\\n\"                 f\"*\u0421\u0442\u0430\u0442\u0443\u0441 \u0441\u043a\u0430\u043d\u0430:* {status}\\n\"                 f\"*\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:* {duration}s\\n\"                 f\"*\u041a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c (\u043c\u0430\u043a\u0441):* {severity}\\n\"                 f\"*\u0412\u0441\u0435\u0433\u043e \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439:* {total}\\n\"                 f\"*\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c\u043e:* {fixable}\\n\"                 f\"{counts_lines}\"                 f\"*\u0421\u043a\u0430\u043d\u0435\u0440:* {sc_name} {sc_ver}\\n\"                 f\"*\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c:* {operator}\"             )             messages.append(msg)<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043c\u0435\u0440\u044b. <\/p>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u043b\u0430\u043d\u044b<\/strong> <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c webhook. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0445\u043e\u0447\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-459294","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459294"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459294\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}