{"id":11153,"date":"2021-02-09T21:22:31","date_gmt":"2021-02-09T12:22:31","guid":{"rendered":"http:\/\/leavebehind.iobb.net\/wordpress\/?p=11153"},"modified":"2021-04-23T11:29:15","modified_gmt":"2021-04-23T02:29:15","slug":"electron-robust-security","status":"publish","type":"post","link":"http:\/\/leavebehind.mydns.jp\/wordpress\/2021\/02\/09\/electron-robust-security\/","title":{"rendered":"Electron\u88fd\u30a2\u30d7\u30ea\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3"},"content":{"rendered":"\n<p>electron\u3067\u306e\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u958b\u767a\u306e\u5b66\u7fd2\u3092\u4e45\u3057\u3076\u308a\u306b\u7d9a\u884c\u3057\u3088\u3046\u304b\u3068\u601d\u3044\u7acb\u3063\u3066\u3001\u6539\u3081\u3066<a href=\"https:\/\/www.electronjs.org\/docs\/tutorial\/security\">\u63a8\u5968\u3055\u308c\u308b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/a>\u3092\u8abf\u3079\u3066\u307f\u308b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"593\" src=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2021\/02\/accept_unsafe-evel.jpg\" alt=\"\" class=\"wp-image-11152\" srcset=\"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2021\/02\/accept_unsafe-evel.jpg 946w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2021\/02\/accept_unsafe-evel-700x439.jpg 700w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2021\/02\/accept_unsafe-evel-768x481.jpg 768w\" sizes=\"auto, (max-width: 946px) 100vw, 946px\" \/><\/figure><\/div>\n\n\n\n<p>\u30ea\u30e2\u30fc\u30c8\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8aad\u307f\u8fbc\u3080\u5834\u5408\u306f\u300cnodeIntegration: false\u300d\u3063\u3066\u306e\u306f\u4ee5\u524d\u304b\u3089\u3042\u3063\u305f\u3051\u3069\u300c<a href=\"https:\/\/www.electronjs.org\/docs\/tutorial\/context-isolation\">contextIsolation<\/a>: true\u300d\u306f\u521d\u8033\u3002nodeIntegration\u3092\u30aa\u30d5\u308b\u4e8b\u3067\u30d7\u30ea\u30ed\u30fc\u30c9\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u30e1\u30a4\u30f3\u30d7\u30ed\u30bb\u30b9\u3068\u30ec\u30f3\u30c0\u30e9\u30fc\u30d7\u30ed\u30bb\u30b9\u3092\u4ef2\u4ecb\u3055\u305b\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u30d7\u30ea\u30ed\u30fc\u30c9\u30b9\u30af\u30ea\u30d7\u30c8\u306fNode.js\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u30ec\u30f3\u30c0\u30e9\u30fc\u30d7\u30ed\u30bb\u30b9\u3067\u3042\u308b\u305f\u3081\u3053\u308c\u3082\u5b89\u5168\u3067\u306f\u306a\u3044\u3093\u3060\u3068\u304b\u3002\u306a\u306e\u3067contextIsolation\u3067\u30d7\u30ea\u30ed\u30fc\u30c9\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u30ec\u30f3\u30c0\u30e9\u30fc\u3082\u5206\u96e2\u3057\u3066\u3057\u307e\u3044\u3001\u4ee3\u308f\u3063\u3066API\u306fcontextBridge\u306a\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u901a\u3057\u3066\u30d7\u30ea\u30ed\u30fc\u30c9\u304b\u3089\u30ec\u30f3\u30c0\u30e9\u30fc\u3078\u516c\u958b\u3059\u308b\u3093\u3060\u3068\u3002<\/p>\n\n\n\n<p>\u306a\u3093\u304b\u3088\u3046\u5206\u304b\u3089\u3093\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u7a74\u3075\u3055\u3044\u3060\u308a\u3001\u3061\u3087\u3063\u3068\u958b\u3051\u305f\u308a\u5927\u5909\u3067\u3059\u3002contextBridge\u7d4c\u7531\u3067\u4f7f\u3044\u305f\u3044\u5206\u3060\u3051\u89e3\u653e\u3057\u3066\u306d\u3063\u3066\u4e8b\u3067\u3057\u3087\u3046\u3001\u300c\u5168\u90e8\u62d2\u5426\u3001\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u8a31\u53ef\u300d\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u30ad\u30db\u30f3\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<p><code data-enlighter-language=\"js\" class=\"EnlighterJSRAW\">contextBridge.exposeInMainWorld()<\/code>\u3067API Key\u3092\u6587\u5b57\u5217\u3067\u767b\u9332\u3057\u3066\u305d\u306e\u4e0b\u306b\u95a2\u6570\u3092\u516c\u958b\u3059\u308b\u3093\u3067\u3059\u304c\u3001\u30b3\u30fc\u30c9\u88dc\u5b8c\u304c\u52b9\u304b\u306a\u304f\u306a\u308b\u3088\u306d\u3002JavaScript\u3067\u3084\u3063\u3066\u308b\u306e\u306b\u3001\u578b\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb(*.d.ts)\u3092\u4f5c\u3089\u306a\u304d\u3083\u3044\u3051\u306a\u304f\u306a\u3063\u3066\u307e\u3042\u30e1\u30f3\u30c9\u30af\u30b5\u30a4\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u3088\u3046\u3084\u304fcontextBridge\u3092\u7406\u89e3\u3057\u3066<a href=\"https:\/\/www.electronjs.org\/docs\/tutorial\/quick-start\">electron\u306e\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8<\/a>\u3002\u305d\u3046node,chrome,electron\u306e\u5404\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u30a2\u30ec\u3092\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u5fdc\u3057\u305f\u3082\u306e\u306b\u51fa\u6765\u307e\u3057\u305f\u3002\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u3001\u8868\u793a\u3059\u308b\u3001\u3060\u3051\u3001\u306e\u306d\u3002<\/p>\n\n\n\n<p>\u30ed\u30fc\u30ab\u30eb\u3067\u5b8c\u7d50\u3059\u308b\u30a2\u30d7\u30ea\u306bcontextIsolation\u306a\u3093\u3067\u30a4\u30e9\u30f3\u3051\u3069\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/preload.js\nconst {contextBridge,ipcRenderer} =require('electron')\n\ncontextBridge.exposeInMainWorld(\n    'api', {\n        \/\/\u30d0\u30fc\u30b8\u30e7\u30f3\u3092ipcMain\u3078\u554f\u3044\u5408\u308f\u305b\u308b\u3060\u3051\uff5e\n        getVersions: () => {\n            return ipcRenderer.invoke('get-version');\n        },\n    }\n)<\/pre>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u3061\u3087\u3063\u3068\u6b32\u51fa\u3057\u3066\u3001\u3053\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u8868\u793a\u3092vue.js\u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u4e8b\u306b\u306a\u308a\u307e\u3057\u3066\u3001\u307e\u305f\u3053\u3053\u3067\u554f\u984c\u767a\u751f\u3002\u307e\u305a\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8\u306e\u30ec\u30f3\u30c0\u30e9\u30fc\u3067\u306f\u4f7f\u7528\u3059\u308bindex.html\u306b\u306f\u4ee5\u4e0b\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;meta http-equiv=\"Content-Security-Policy\" content=\"script-src 'self' 'unsafe-inline';\" \/><\/pre>\n\n\n\n<p>vue.js\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u305f\u3081\u306beval\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3001Content-Security-Policy\u3067unsafe-evel\u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u52d5\u304d\u307e\u305b\u3093\u3002\u8a2d\u5b9a\u3057\u305f\u3089\u3057\u305f\u3067electron\u304b\u3089\u6012\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u56de\u907f\u7b56\u306f\u3068\u3044\u3046\u3068vue.js\u304b\u3089\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30b3\u30f3\u30d1\u30a4\u30e9\u3092\u7701\u3044\u305fvue.runtime.js\u3092\u4f7f\u7528\u3059\u308b\u4e8b\u3067\u3059\u3002\u3060\u3060\u3057\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5b9a\u7fa9\u306b\u3088\u308b\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3001html\u3078\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u30c7\u30fc\u30bf\u3092\u8a18\u8ff0\u3067\u304d\u307e\u305b\u3093\u3002\u8868\u793a\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306erender\u95a2\u6570\u3067\u30b4\u30ea\u30b4\u30ea\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u82e6\u884c\u306e\u672b\u3001\u300cnodeIntegration: false\u300d\u300ccontextIsolation:true\u300d\u300cContent-Security-Policy\u306fscript-src &#8216;self&#8217;\u300d\u306a\u30a2\u30d7\u30ea\u304c\u51fa\u6765\u4e0a\u304c\u308a\u307e\u3057\u305f\u3002\u305d\u3046\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u3002<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2021\/02\/electron-contextbrige-master.zip\">electron-contextbrige-master<\/a><a href=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2021\/02\/electron-contextbrige-master.zip\" class=\"wp-block-file__button\" download>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/div>\n\n\n\n<p class=\"has-small-font-size\">bridge\u306e\u7db4\u308a\u307e\u3061\u3054\u30fc\u305f<\/p>\n\n\n\n<p>@vue\/cli\u3068electron-builder\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>electron\u3067\u306e\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u958b\u767a\u306e\u5b66\u7fd2\u3092\u4e45\u3057\u3076\u308a\u306b\u7d9a\u884c\u3057\u3088\u3046\u304b\u3068\u601d\u3044\u7acb\u3063\u3066\u3001\u6539\u3081\u3066\u63a8\u5968\u3055\u308c\u308b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8abf\u3079\u3066\u307f\u308b\u3002 \u30ea\u30e2\u30fc\u30c8\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8aad\u307f\u8fbc\u3080\u5834\u5408\u306f\u300cnodeIntegration: false\u300d\u3063\u3066\u306e\u306f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[456],"tags":[319,152,320],"class_list":["post-11153","post","type-post","status-publish","format-standard","hentry","category-programming","tag-electron","tag-javascript","tag-node-js"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8YSE4-2TT","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/11153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=11153"}],"version-history":[{"count":18,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/11153\/revisions"}],"predecessor-version":[{"id":11365,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/11153\/revisions\/11365"}],"wp:attachment":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=11153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=11153"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=11153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}