{"id":88422,"date":"2021-06-28T08:13:17","date_gmt":"2021-06-27T23:13:17","guid":{"rendered":"https:\/\/softantenna.com\/wp\/?p=88422"},"modified":"2021-06-28T08:13:17","modified_gmt":"2021-06-27T23:13:17","slug":"git-secrets","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/git-secrets\/","title":{"rendered":"git-secrets - \u6a5f\u5bc6\u60c5\u5831\u306e\u6f0f\u6d29\u3092\u4e8b\u524d\u306b\u9632\u3050\u5b89\u5fc3\u5b89\u5168\u306e\u305f\u3081\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2021\/06\/s_20210623_120229.jpg\" alt=\"S 20210623 120229\" title=\"s_20210623_120229.jpg\" border=\"0\" width=\"860\" height=\"560\" \/><\/p>\n<p>GitHub\u3084GitLab\u306a\u3069\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u30b5\u30fc\u30d3\u30b9\u304c\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u30b5\u30fc\u30d3\u30b9\u306b\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u306e\u7ba1\u7406\u304c\u5fc5\u8981\u306a\u3044\u3068\u3044\u3046\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3046\u3063\u304b\u308a\u30d1\u30d6\u30ea\u30c3\u30af\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u516c\u958b\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u4e2d\u306b\u542b\u307e\u308c\u308b\u6a5f\u5bc6\u60c5\u5831\u304c\u5168\u4e16\u754c\u306b\u77e5\u3089\u308c\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u5371\u967a\u6027\u3082\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7279\u306bAWS\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306a\u3069\u5404\u7a2e\u6709\u6599\u30b5\u30fc\u30d3\u30b9\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u8a8d\u8a3c\u60c5\u5831\u304c\u6d41\u51fa\u3059\u308b\u3068\u3001\u60aa\u610f\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u4e0d\u6b63\u306b\u4f7f\u7528\u3055\u308c\u3066\u3001\u30af\u30e9\u30a6\u30c9\u7834\u7523\u306b\u3064\u306a\u304c\u308b\u5371\u967a\u6027\u3055\u3048\u5b58\u5728\u3059\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300c<a href=\"https:\/\/github.com\/awslabs\/git-secrets\">git-secrets<\/a>\u300d\u306f\u3053\u306e\u3088\u3046\u306a\u6a5f\u5bc6\u60c5\u5831\u306e\u6f0f\u6d29\u3092\u4e8b\u524d\u306b\u9632\u3050\u305f\u3081\u306e\u5c02\u7528\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<p>\u8a8d\u8a3c\u60c5\u5831\u306e\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u304c\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u3001git\u306e\u30b3\u30df\u30c3\u30c8\u3092\u9632\u3050\u3053\u3068\u3067\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u5371\u967a\u306a\u60c5\u5831\u304c\u5165\u308a\u8fbc\u3080\u3053\u3068\u3092\u4e8b\u524d\u306b\u9632\u3044\u3067\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u4f7f\u7528\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>git-secrets\u306e\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>git-secrets\u306f\u5358\u306a\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002\u300cgit-secrets\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u30d1\u30b9\u304c\u901a\u3063\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3059\u308b\u3060\u3051\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u307e\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u306e\u304c\u6b63\u5f0f\u3068\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\ngit clone https:\/\/github.com\/awslabs\/git-secrets.git\r\ncd git-secrets\r\nmake install\r\n<\/pre>\n<p>Mac\u3067Homebrew\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3082\u4f7f\u7528\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre>\r\nbrew install git-secrets\r\n<\/pre>\n<p>\u5b9f\u969b\u306b\u4f7f\u3044\u59cb\u3081\u308b\u306b\u306fgit\u30ea\u30dd\u30b8\u30c8\u30ea\u5185\u3067\u300cgit secrets --install\u300d\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\ncd \/path\/to\/my\/repo\r\ngit secrets --install\r\ngit secrets --register-aws\r\n<\/pre>\n<p>\u3053\u306e\u72b6\u614b\u3067\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u6a5f\u5bc6\u60c5\u5831\u3092\u542b\u3080secret.txt\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\naws_secret_access_key = WJalrXUtnFEMI\/K7MDENG\/bPxRfiCYEXAMPLEKEY\r\n<\/pre>\n<p>git commit\u3092\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc\u3067\u5f3e\u304b\u308c\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\n$ git commit -a\r\nsecret.txt:1:aws_secret_access_key = WJalrXUtnFEMI\/K7MDENG\/bPxRfiCYEXAMPLEKEY\r\n\r\n[ERROR] Matched one or more prohibited patterns\r\n\r\nPossible mitigations:\r\n- Mark false positives as allowed using: git config --add secrets.allowed ...\r\n- Mark false positives as allowed by adding regular expressions to .gitallowed at repository's root directory\r\n- List your configured patterns: git config --get-all secrets.patterns\r\n- List your configured allowed patterns: git config --get-all secrets.allowed\r\n- List your configured allowed patterns in .gitallowed at repository's root directory\r\n- Use --no-verify if this is a one-time false positive\r\n<\/pre>\n<p>\u30b3\u30df\u30c3\u30c8\u6642\u3060\u3051\u3067\u306f\u306a\u304f\u4efb\u610f\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\ngit secrets --scan --no-index\r\n<\/pre>\n<p>\u73fe\u5728\u306e\u8a2d\u5b9a\u306f\u300cgit secrets --list\u300d\u30b3\u30de\u30f3\u30c9\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\n $ git secrets --list\r\nsecrets.providers git secrets --aws-provider\r\nsecrets.patterns (A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\r\nsecrets.patterns (\"|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)(\"|')?\\s*(:|=>|=)\\s*(\"|')?[A-Za-z0-9\/\\+=]{40}(\"|')?\r\nsecrets.patterns (\"|')?(AWS|aws|Aws)?_?(ACCOUNT|account|Account)_?(ID|id|Id)?(\"|')?\\s*(:|=>|=)\\s*(\"|')?[0-9]{4}\\-?[0-9]{4}\\-?[0-9]{4}(\"|')?\r\nsecrets.allowed AKIAIOSFODNN7EXAMPLE\r\nsecrets.allowed wJalrXUtnFEMI\/K7MDENG\/bPxRfiCYEXAMPLEKEY\r\n<\/pre>\n<p>\u3059\u306a\u308f\u3061\u3001\u5148\u307b\u3069\u5b9f\u884c\u3057\u305f\u300cgit secrets --register-aws\u300d\u3067\u3001AWS\u7528\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u9664\u5916\u30d1\u30bf\u30fc\u30f3\u300csecrets.patterns\u300d\u304a\u3088\u3073\u300csecrets.allowed\u300d\u304c\u7d44\u307f\u8fbc\u307e\u308c\u3066\u3044\u305f\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u624b\u52d5\u3067\u9664\u5916\u30d1\u30bf\u30fc\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\ngit secrets --add --global '[A-Z0-9]{20}'\r\n<\/pre>\n<p>\u305d\u306e\u4ed6\u3001\u9664\u5916\u8a2d\u5b9a\u3092\u30ea\u30dd\u30b8\u30c8\u30ea\u5358\u4f4d\u3067\u306f\u306a\u304f\u3001\u5168\u3066\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u6709\u52b9\u306b\u3057\u305f\u308a\u3001git\u306e\u5c65\u6b74\u3092\u542b\u3081\u3066\u6a5f\u5bc6\u60c5\u5831\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u308a\u3068\u3044\u3063\u305f\u52d5\u4f5c\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u8a73\u3057\u304f\u306f<a href=\"https:\/\/github.com\/awslabs\/git-secrets\">\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\u3067\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>git-secrets\u3092\u5229\u7528\u3059\u308c\u3070git\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u6a5f\u5bc6\u60c5\u5831\u304c\u7d1b\u308c\u8fbc\u3080\u306e\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002AWS\u3084\u5404\u7a2e\u30b5\u30fc\u30d3\u30b9\u306e\u8a8d\u8a3c\u60c5\u5831\u3001DB\u3084\u30b7\u30b9\u30c6\u30e0\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6d41\u51fa\u3059\u308b\u306e\u3092\u9632\u304e\u305f\u3044\u65b9\u306f\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GitHub\u3084GitLab\u306a\u3069\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u30b5\u30fc\u30d3\u30b9\u304c\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u30b5\u30fc\u30d3\u30b9\u306b\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u306e\u7ba1\u7406\u304c\u5fc5\u8981\u306a\u3044\u3068\u3044\u3046\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3046\u3063\u304b\u308a\u30d1\u30d6\u30ea\u30c3\u30af\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u516c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":88558,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3459],"tags":[159],"class_list":["post-88422","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","tag-git"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/88422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=88422"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/88422\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/88558"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=88422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=88422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=88422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}