{"id":316848,"date":"2021-01-24T15:00:29","date_gmt":"2021-01-24T15:00:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316848"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316848","title":{"rendered":"\u0420\u0435\u043b\u0438\u0437 ruleguard v0.3.0"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u044f \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u0447\u0442\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u044b \u0434\u043b\u044f Go \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c?<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func alwaysTrue(m dsl.Matcher) {     m.Match(`strings.Count($_, $_) &gt;= 0`).Report(`always evaluates to true`)     m.Match(`bytes.Count($_, $_) &gt;= 0`).Report(`always evaluates to true`) }  func replaceAll() {     m.Match(`strings.Replace($s, $d, $w, $n)`).         Where(m[&quot;n&quot;].Value.Int() &lt;= 0).         Suggest(`strings.ReplaceAll($s, $d, $w)`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0413\u043e\u0434 \u043d\u0430\u0437\u0430\u0434 \u044f \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043e\u0431 \u0443\u0442\u0438\u043b\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\" rel=\"nofollow noopener noreferrer\">ruleguard<\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/golang\/go\/wiki\/Modules\" rel=\"nofollow noopener noreferrer\">Go \u043c\u043e\u0434\u0443\u043b\u0438<\/a> (bundles)<\/li>\n<li>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b (\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434)<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432<\/li>\n<li>\u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b: <a href=\"https:\/\/go-ruleguard.github.io\/by-example\/\" rel=\"nofollow noopener noreferrer\">ruleguard by example<\/a><\/li>\n<li>\u0423 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c <a href=\"https:\/\/github.com\/grafana\/grafana\/pull\/28419\" rel=\"nofollow noopener noreferrer\">\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438<\/a> \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/dgryski\/semgrep-go\" rel=\"nofollow noopener noreferrer\">\u043d\u0430\u0431\u043e\u0440\u044b \u043f\u0440\u0430\u0432\u0438\u043b<\/a><\/li>\n<li><a href=\"https:\/\/go-ruleguard.github.io\/play\/\" rel=\"nofollow noopener noreferrer\">\u041e\u043d\u043b\u0430\u0439\u043d \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c ruleguard \u043f\u0440\u044f\u043c\u043e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" title=\"\u0410\u0432\u0442\u043e\u0440 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438: \u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0423\u0444\u0438\u043c\u0446\u0435\u0432\u0430 @leased_line\" src=\"https:\/\/habrastorage.org\/webt\/jb\/iy\/a0\/jbiya0ab6njechtwp9dwtxhmw24.jpeg\"><a name=\"habracut\"><\/a>  <\/p>\n<hr>\n<p>  <\/p>\n<h2 id=\"nebolshoe-vvedenie\">\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p><code>ruleguard<\/code> \u2014 \u044d\u0442\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a. \u0427\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u043d\u0430 DSL \u0441\u0432\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b (\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b) \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <code>ruleguard<\/code>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yy\/fj\/wk\/yyfjwkkjfg6tm_8hekskud3c63o.jpeg\"><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/4c\/r3\/7x\/4cr37xaaochgqrqogyvne2vud4s.png\"><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <strong>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f<\/strong> \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 <a href=\"https:\/\/github.com\/golangci\/golangci-lint\" rel=\"nofollow noopener noreferrer\">golangci-lint<\/a>. \u0411\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>golangci-lint<\/code> \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043a \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0442\u043e \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 <code>CodeQL<\/code> \u0438 <code>Semgrep<\/code>. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f <a href=\"https:\/\/speakerdeck.com\/quasilyte\/ruleguard-vs-semgrep-vs-codeql\" rel=\"nofollow noopener noreferrer\">\u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/a>, \u0445\u043e\u0442\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0442\u043e\u0433\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430 (\u0432\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u0444\u0438\u0447\u0438).<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u044f \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430 \u0433\u043e\u0434 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u0430\u043a\u0438\u043c\u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0438\u043c\u0438. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0444\u043e\u0440\u043c\u0430\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0422\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<hr>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u0438\u043d\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0443\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044e, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043e\u043a.<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>EN<\/th>\n<th>RU<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Rule<\/td>\n<td>\u041f\u0440\u0430\u0432\u0438\u043b\u043e<\/td>\n<td>AST-\u0448\u0430\u0431\u043b\u043e\u043d, \u0441\u043e\u0432\u043c\u0435\u0449\u0451\u043d\u043d\u044b\u0439 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 (\u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f).<\/td>\n<\/tr>\n<tr>\n<td>Rules group<\/td>\n<td>\u0413\u0440\u0443\u043f\u043f\u0430 \u043f\u0440\u0430\u0432\u0438\u043b<\/td>\n<td>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b &quot;\u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430\u043c\u0438&quot;, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043b\u0438\u043d\u0442\u0435\u0440\u0430\u0445, \u043d\u043e \u0433\u0440\u0443\u043f\u043f\u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443.<\/td>\n<\/tr>\n<tr>\n<td>Rule set<\/td>\n<td>\u041d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b<\/td>\n<td>\u0421\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f \u043f\u0440\u0430\u0432\u0438\u043b.<\/td>\n<\/tr>\n<tr>\n<td>Rule bundle<\/td>\n<td>\u0411\u0430\u043d\u0434\u043b (\u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435)<\/td>\n<td>\u041d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b, \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043a Go \u043c\u043e\u0434\u0443\u043b\u044c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u043f\u0440\u0430\u0432\u0438\u043b.<\/td>\n<\/tr>\n<tr>\n<td>Module<\/td>\n<td>\u041c\u043e\u0434\u0443\u043b\u044c<\/td>\n<td>\u041c\u043e\u0434\u0443\u043b\u0438 Go; \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u043d\u0434\u043b \u2014 \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u043e \u0441\u0430\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u0438 \u043a \u0431\u0430\u043d\u0434\u043b\u0430\u043c \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u0430\u0441 \u0442\u0435\u0440\u043c\u0438\u043d, \u0441\u0442\u043e\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<hr>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"problema-pereispolzovanie-naborov-pravil\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 <a href=\"http:\/\/twitter.com\/dgryski\" rel=\"nofollow noopener noreferrer\">Damian Gryski<\/a>. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u2014 \u044d\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e: \u0432\u0441\u0451 \u043b\u0438\u0448\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0430 \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u044d\u0442\u043e\u0442 \u0436\u0435 \u0444\u0430\u0439\u043b. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0430\u0449\u0435 \u043b\u044e\u0434\u0438 \u0445\u043e\u0442\u044f\u0442 \u0432\u0437\u044f\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e\u0432\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0431\u0430\u043d\u0434\u043b\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u0430\u043d\u0434\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>go get<\/code><\/li>\n<li>\u0412\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Go \u043c\u043e\u0434\u0443\u043b\u0435\u0439: \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u043b\u0438\u0437\u044b \u0438 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e<\/li>\n<li>\u041a\u0443\u043b\u044c\u0442\u0443\u0440\u0430 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u043c\u043e\u0434\u0443\u043b\u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e ruleguard \u0444\u0430\u0439\u043b\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Go \u043a\u043e\u0434 (\u043f\u043e \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 autocomplete \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u043e\u0432).<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0430\u0432\u0438\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0441\u0432\u043e\u0438\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package gorules  import (     &quot;github.com\/quasilyte\/go-ruleguard\/dsl&quot;     damianrules &quot;github.com\/dgryski\/semgrep-go&quot; )  func init() {     \/\/ \u0418\u043c\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u0431\u0435\u0437 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430.     dsl.ImportRules(&quot;&quot;, damianrules.Bundle) }  func emptyStringTest(m dsl.Matcher) {     m.Match(`len($s) == 0`).         Where(m[&quot;s&quot;].Type.Is(&quot;string&quot;)).         Report(`maybe use $s == &quot;&quot; instead?`)      m.Match(`len($s) != 0`).         Where(m[&quot;s&quot;].Type.Is(&quot;string&quot;)).         Report(`maybe use $s != &quot;&quot; instead?`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>-disable<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"problema-nedostatochnaya-vyrazitelnost-dsl\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c DSL<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/pkg.go.dev\/github.com\/quasilyte\/go-ruleguard\/dsl#Matcher\" rel=\"nofollow noopener noreferrer\"><code>dsl.Matcher<\/code><\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u044b \u0432 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0434\u043b\u044f <code>ruleguard<\/code> \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438\u043b\u0438 \u0444\u0438\u043b\u044c\u0442\u0440, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/pkg.go.dev\/github.com\/quasilyte\/go-ruleguard\/dsl#Var.Filter\" rel=\"nofollow noopener noreferrer\"><code>Filter()<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 Go \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package gorules  import (     &quot;github.com\/quasilyte\/go-ruleguard\/dsl&quot;     &quot;github.com\/quasilyte\/go-ruleguard\/dsl\/types&quot; )  \/\/ implementsStringer \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c. \/\/ \u042d\u0442\u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043b\u0438 T \u0438\u043b\u0438 *T \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 `fmt.Stringer`. func implementsStringer(ctx *dsl.VarFilterContext) bool {     stringer := ctx.GetInterface(`fmt.Stringer`)     return types.Implements(ctx.Type, stringer) ||         types.Implements(types.NewPointer(ctx.Type), stringer) }  func sprintStringer(m dsl.Matcher) {     \/\/ \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 m[&quot;x&quot;].Type.Implements(`fmt.Stringer`), \u0442\u043e\u0433\u0434\u0430     \/\/ \u043c\u044b \u0431\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b: \u0435\u0441\u043b\u0438 \u0442\u0438\u043f $x \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442     \/\/ fmt.Stringer \u043a\u0430\u043a *T, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 T \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438.     \/\/ \u041d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u0440\u0438\u043c\u0435\u0440\u044f\u0435\u0442 \u043e\u0431\u0435 \u0432\u0435\u0440\u0441\u0438\u0438: \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u0431\u0435\u0437 \u0443\u043a\u0430\u0442\u0430\u0442\u0435\u043b\u044f.     m.Match(`fmt.Sprint($x)`).         Where(m[&quot;x&quot;].Filter(implementsStringer) &amp;&amp; m[&quot;x&quot;].Addressable).         Report(`can use $x.String() directly`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import &quot;fmt&quot;  func main() {     fooPtr := &amp;Foo{}     foo := Foo{}      println(fmt.Sprint(foo))     println(fmt.Sprint(fooPtr))      println(fmt.Sprint(0))    \/\/ \u041d\u0435 fmt.Stringer     println(fmt.Sprint(&amp;foo)) \/\/ \u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c addressable }  type Foo struct{}  func (*Foo) String() string { return &quot;Foo&quot; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ ruleguard -rules rules.go main.go main.go:9:10: can use foo.String() directly main.go:10:10: can use fooPtr.String() directly<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u043b\u0430\u0433 <code>-debug-filter<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0432\u043e \u0447\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/t2\/td\/c3\/t2tdc3gmpwnumqbairmh1y91y6s.png\"><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u043e \u0434\u0430\u0436\u0435 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <a href=\"https:\/\/github.com\/traefik\/yaegi\" rel=\"nofollow noopener noreferrer\">yaegi<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"problema-pravila-slozhno-otlazhivat\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 <a href=\"https:\/\/pkg.go.dev\/github.com\/quasilyte\/go-ruleguard\/dsl#Matcher.Where\" rel=\"nofollow noopener noreferrer\"><code>Where()<\/code><\/a> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0445 \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u043b\u0430\u0433 <code>debug-group<\/code>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0445 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func offBy1(m dsl.Matcher) {     m.Match(`$s[len($s)]`).         Where(m[&quot;s&quot;].Type.Is(`[]$elem`) &amp;&amp; m[&quot;s&quot;].Pure).         Report(`index expr always panics; maybe you wanted $s[len($s)-1]?`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0435\u0433\u043e \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func lastByte(s string) byte {     return s[len(s)] }  func f() byte {     return randString()[len(randString())] }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f\u2026 \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043f\u0435\u0447\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ ruleguard -rules rules.go -debug-group offBy1 test.go test.go:6: [rules.go:6] rejected by m[&quot;s&quot;].Type.Is(`[]$elem`)   $s string: s test.go:10: [rules.go:6] rejected by m[&quot;s&quot;].Pure   $s []byte: randBytes()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 <code>Where()<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0434\u0430\u043b\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0443. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u0432\u0441\u0435 \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 Go \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 AST \u0448\u0430\u0431\u043b\u043e\u043d\u0430 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>$s<\/code>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u0442\u0438\u043f.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0442\u0438\u043f\u0430 <code>[]$elem<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u0430\u0439\u0441\u0430, \u0430 \u0432 \u043a\u043e\u0434\u0435 \u2014 \u0441\u0442\u0440\u043e\u043a\u0430. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437-\u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>pure<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0443\u0431\u0438\u0440\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u0432\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f <code>string<\/code> \u0432 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0443 \u043c\u043e\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"diff\">- Where(m[&quot;s&quot;].Type.Is(`[]$elem`) &amp;&amp; m[&quot;s&quot;].Pure). + Where((m[&quot;s&quot;].Type.Is(`[]$elem`) || m[&quot;s&quot;].Type.Is(`string`)) &amp;&amp; m[&quot;s&quot;].Pure).<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043d\u0430\u0439\u0434\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">test.go:6:9: offBy1: index expr always panics; maybe you wanted s[len(s)-1]?<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"problema-trudnosti-izucheniya-dsl\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f DSL<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u043d\u0430 \u0440\u0443\u043a\u0430\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u0441 \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b, \u0442\u043e \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0445 \u0443\u0441\u0438\u043b\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434 <a href=\"https:\/\/gobyexample.com\/\" rel=\"nofollow noopener noreferrer\">Go by Example<\/a>. \u0412 \u043d\u0451\u043c \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u043e\u043c\u0443. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043a\u0430\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c, \u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0449\u0438\u043c.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/go-ruleguard.github.io\/by-example\/\" rel=\"nofollow noopener noreferrer\">Ruleguard by Example<\/a> \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0441\u0442\u0438\u043b\u0435. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uw\/mt\/en\/uwmtenp4kuw9-mdit3imh4nht8e.png\"><\/p>\n<p>  <\/p>\n<h2 id=\"kak-nachat-ispolzovat-ruleguard\">\u041a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ruleguard?<\/h2>\n<p>  <\/p>\n<blockquote><p>\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435! \u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e ruleguard \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 Go \u043c\u043e\u0434\u0443\u043b\u0438.<\/p><\/blockquote>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432 <a href=\"https:\/\/github.com\/golangci\/golangci-lint\" rel=\"nofollow noopener noreferrer\">golangci-lint<\/a> \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <code>golangci-lint<\/code> \u0438\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a <code>ruleguard<\/code> \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0435\u043b\u0438\u0437\u0430 {<a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/releases\/download\/v0.3.0\/ruleguard-linux-amd64.zip\" rel=\"nofollow noopener noreferrer\">linux\/amd64<\/a>, <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/releases\/download\/v0.3.0\/ruleguard-linux-arm64.zip\" rel=\"nofollow noopener noreferrer\">linux\/arm64<\/a>, <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/releases\/download\/v0.3.0\/ruleguard-darwin-amd64.zip\" rel=\"nofollow noopener noreferrer\">darwin\/amd64<\/a>, <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/releases\/download\/v0.3.0\/ruleguard-windows-amd64.zip\" rel=\"nofollow noopener noreferrer\">windows\/amd64<\/a>}.<\/p>\n<p>  <\/p>\n<p>\u0412\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b. \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/tree\/master\/rules\" rel=\"nofollow noopener noreferrer\"><code>github.com\/quasilyte\/go-ruleguard\/rules<\/code><\/a> \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/dgryski\/semgrep-go\" rel=\"nofollow noopener noreferrer\"><code>github.com\/dgryski\/semgrep-go<\/code><\/a>. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0431\u0430\u043d\u0434\u043b\u0430 \u0438\u043b\u0438 \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0441\u0432\u043e\u0438 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <code>github.com\/quasilyte\/go-ruleguard\/rules<\/code>, \u0442\u043e\u0433\u0434\u0430:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c <code>ruleguard<\/code> \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b (\u0438\u043b\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432)<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>go get -v github.com\/quasilyte\/go-ruleguard\/dsl<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>go get -v github.com\/quasilyte\/go-ruleguard\/rules<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0430\u0432\u0438\u043b <code>rules.go<\/code>, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u043b<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>ruleguard<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>-rules rules.go<\/code> \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ ruleguard -rules rules.go .\/...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0438\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 <code>ruleguard<\/code>, <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/issues\/new\" rel=\"nofollow noopener noreferrer\">\u0441\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"sozdayom-svoy-bandl\">\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u0439 \u0431\u0430\u043d\u0434\u043b<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0411\u0430\u043d\u0434\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c Go \u043c\u043e\u0434\u0443\u043b\u0435\u043c<\/li>\n<li>\u041f\u0430\u043a\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>Bundle<\/code><\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0431\u0430\u043d\u0434\u043b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0430\u043d\u0434\u043b.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0431\u0430\u043d\u0434\u043b\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e Go \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u041f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0430\u043d\u0434\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 Go \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">package gorules  import &quot;github.com\/quasilyte\/go-ruleguard\/dsl&quot;  \/\/ Bundle \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043d\u0430\u0431\u043e\u0440\u0435 \u043f\u0440\u0430\u0432\u0438\u043b. var Bundle = dsl.Bundle{}  func boolComparison(m dsl.Matcher) {     m.Match(`$x == true`,         `$x != true`,         `$x == false`,         `$x != false`).         Report(`omit bool literal in expression`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/quasilyte\/ruleguard-rules-test\" rel=\"nofollow noopener noreferrer\">ruleguard-rules-test<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"testiruem-svoy-bandl\">\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0432\u043e\u0439 \u0431\u0430\u043d\u0434\u043b<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 <a href=\"https:\/\/godoc.org\/golang.org\/x\/tools\/go\/analysis\" rel=\"nofollow noopener noreferrer\">go\/analysis<\/a> \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435 <a href=\"https:\/\/godoc.org\/golang.org\/x\/tools\/go\/analysis\/analysistest\" rel=\"nofollow noopener noreferrer\">analysistest<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0420\u044f\u0434\u043e\u043c \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f <code>testdata<\/code>, \u043a\u0443\u0434\u0430 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f Go \u0444\u0430\u0439\u043b\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432\u0430\u0448\u0438 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ file rules_test.go  package gorules_test  import (     &quot;testing&quot;      &quot;github.com\/quasilyte\/go-ruleguard\/analyzer&quot;     &quot;golang.org\/x\/tools\/go\/analysis\/analysistest&quot; )  func TestRules(t *testing.T) {     \/\/ \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e &quot;rules.go&quot;     \/\/ \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &quot;style.go,perf.go&quot;.     if err := analyzer.Analyzer.Flags.Set(&quot;rules&quot;, &quot;rules.go&quot;); err != nil {         t.Fatalf(&quot;set rules flag: %v&quot;, err)     }     analysistest.Run(t, analysistest.TestData(), analyzer.Analyzer, &quot;.\/...&quot;) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u043d\u0434\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">mybundle\/   go.mod        -- \u0444\u0430\u0439\u043b, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 &quot;go mod init&quot;   rules.go      -- \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0438\u043d\u0430\u0447\u0435)   rules_test.go -- \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u0435\u043b\u044c \u0442\u0435\u0441\u0442\u043e\u0432   testdata\/     -- \u0444\u0430\u0439\u043b\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437     target1.go     target2.go     ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ file testdata\/target1.go  package test  func f(cond bool) {     if cond == true { \/\/ want `omit bool literal in expression`     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 <code>want<\/code> \u0438\u0434\u0451\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043c\u0430\u0442\u0447\u0438\u0442\u044c \u0432\u044b\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435. \u041c\u043e\u0433\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>\\Q<\/code> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c <code>go test<\/code> \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0431\u0430\u043d\u0434\u043b\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"ssylki-i-dopolnitelnye-materialy\">\u0421\u0441\u044b\u043b\u043a\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ni\/hn\/rh\/nihnrhigipwqd1z4ulqf032owo4.png\"><\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/issues\/36\" rel=\"nofollow noopener noreferrer\">\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/go-ruleguard.github.io\/\" rel=\"nofollow noopener noreferrer\">\u0421\u0430\u0439\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 ruleguard<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/go_critic_ru\" rel=\"nofollow noopener noreferrer\">\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0447\u0430\u0442\u0438\u043a, \u0433\u0434\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f go-critic \u0438 ruleguard<\/a><\/li>\n<li><a href=\"https:\/\/quasilyte.dev\/blog\/post\/ruleguard\/#using-from-the-golangci-lint\" rel=\"nofollow noopener noreferrer\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 ruleguard \u0438\u0437 golangci-lint<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\/blob\/master\/_docs\/dsl.md\" rel=\"nofollow noopener noreferrer\">DSL \u043c\u0430\u043d\u0443\u0430\u043b<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/go-critic\/go-critic\" rel=\"nofollow noopener noreferrer\">go-critic<\/a> \u2014 \u043b\u0438\u043d\u0442\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d ruleguard<\/li>\n<li><a href=\"https:\/\/quasilyte.dev\/blog\/post\/ruleguard-modules\/\" rel=\"nofollow noopener noreferrer\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0431\u0430\u043d\u0434\u043b\u044b<\/a><\/li>\n<\/ul>\n<\/div>\n<p> \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\/post\/538930\/\"> https:\/\/habr.com\/ru\/post\/538930\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u044f \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u0447\u0442\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u044b \u0434\u043b\u044f Go \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c?<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func alwaysTrue(m dsl.Matcher) {     m.Match(`strings.Count($_, $_) &gt;= 0`).Report(`always evaluates to true`)     m.Match(`bytes.Count($_, $_) &gt;= 0`).Report(`always evaluates to true`) }  func replaceAll() {     m.Match(`strings.Replace($s, $d, $w, $n)`).         Where(m[&quot;n&quot;].Value.Int() &lt;= 0).         Suggest(`strings.ReplaceAll($s, $d, $w)`) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0413\u043e\u0434 \u043d\u0430\u0437\u0430\u0434 \u044f \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043e\u0431 \u0443\u0442\u0438\u043b\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/quasilyte\/go-ruleguard\" rel=\"nofollow noopener noreferrer\">ruleguard<\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/golang\/go\/wiki\/Modules\" rel=\"nofollow noopener noreferrer\">Go \u043c\u043e\u0434\u0443\u043b\u0438<\/a> (bundles)<\/li>\n<li>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b (\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434)<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432<\/li>\n<li>\u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b: <a href=\"https:\/\/go-ruleguard.github.io\/by-example\/\" rel=\"nofollow noopener noreferrer\">ruleguard by example<\/a><\/li>\n<li>\u0423 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c <a href=\"https:\/\/github.com\/grafana\/grafana\/pull\/28419\" rel=\"nofollow noopener noreferrer\">\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438<\/a> \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/dgryski\/semgrep-go\" rel=\"nofollow noopener noreferrer\">\u043d\u0430\u0431\u043e\u0440\u044b \u043f\u0440\u0430\u0432\u0438\u043b<\/a><\/li>\n<li><a href=\"https:\/\/go-ruleguard.github.io\/play\/\" rel=\"nofollow noopener noreferrer\">\u041e\u043d\u043b\u0430\u0439\u043d \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c ruleguard \u043f\u0440\u044f\u043c\u043e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" title=\"\u0410\u0432\u0442\u043e\u0440 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438: \u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0423\u0444\u0438\u043c\u0446\u0435\u0432\u0430 @leased_line\" src=\"https:\/\/habrastorage.org\/webt\/jb\/iy\/a0\/jbiya0ab6njechtwp9dwtxhmw24.jpeg\"><\/p>\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-316848","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316848","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=316848"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316848\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}