(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d215cd3"],{c06f:function(t,e,s){"use strict";s.r(e);var a=function(){var t=this,e=t._self._c;return e("div",{staticClass:"backend-content",attrs:{id:"content"}},[e("div",{staticClass:"column col-8 col-xs-12"},[e("h3",{staticClass:"s-title"},[t._v("Manage whitelisted elements")]),e("ul",{staticClass:"tab tab-block"},[e("li",{staticClass:"tab-item"},[e("a",{class:{active:t.tabs.bulk},attrs:{href:"#"},on:{click:function(e){return t.switch_tab("bulk")}}},[t._v("Bulk elements import")])]),e("li",{staticClass:"tab-item"},[e("a",{class:{active:t.tabs.file},attrs:{href:"#"},on:{click:function(e){return t.switch_tab("file")}}},[t._v("Import from file")])]),e("li",{staticClass:"tab-item"},[e("a",{class:{active:t.tabs.export},attrs:{href:"#"},on:{click:function(e){return t.switch_tab("export")}}},[t._v("Export elements")])])]),t.tabs.export?e("div",[e("iframe",{staticClass:"frame-export",attrs:{src:t.export_url}})]):t._e(),t.tabs.file?e("div",[e("label",{staticClass:"form-upload empty",attrs:{for:"upload"}},[e("input",{staticClass:"upload-field",attrs:{type:"file",id:"upload"},on:{change:t.import_from_file}}),e("p",{staticClass:"empty-title h5"},[t._v("Drop or select a file to import.")]),e("p",{staticClass:"empty-subtitle"},[t._v("The file needs to be an whitelist file export from a SpyGuard instance.")])])]):t._e(),t.tabs.bulk?e("div",[e("div",{staticClass:"form-group"},[e("select",{directives:[{name:"model",rawName:"v-model",value:t.type,expression:"type"}],staticClass:"form-select width-full",attrs:{placeholder:"test"},on:{change:function(e){var s=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.type=e.target.multiple?s:s[0]}}},[e("option",{attrs:{value:""}},[t._v("Elements Type")]),e("option",{attrs:{value:"unknown"}},[t._v("Multiple (regex parsing)")]),t._l(t.types,(function(s){return e("option",{key:s.type,domProps:{value:s.type}},[t._v(" "+t._s(s.name)+" ")])}))],2)]),e("div",{staticClass:"form-group"},[e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.elements,expression:"elements"}],staticClass:"form-input",attrs:{id:"input-example-3",placeholder:"Paste the elements to be whitelisted here",rows:"15"},domProps:{value:t.elements},on:{input:function(e){e.target.composing||(t.elements=e.target.value)}}})]),e("div",{staticClass:"form-group"},[e("button",{staticClass:"btn-primary btn col-12",on:{click:function(e){return t.import_from_bulk()}}},[t._v("Whitelist elements")])])]):t._e(),t.imported.length>0?e("div",{staticClass:"form-group"},[e("div",{staticClass:"toast toast-success"},[t._v(" ✓ "+t._s(t.imported.length)+" IOC"),t.errors.length>1?e("span",[t._v("s")]):t._e(),t._v(" imported successfully. ")])]):t._e(),t.errors.length>0?e("div",[e("div",{staticClass:"form-group"},[e("div",{staticClass:"toast toast-error"},[t._v(" ✗ "+t._s(t.errors.length)+" IOC"),t.errors.length>1?e("span",[t._v("s")]):t._e(),t._v(" not imported, see details below. ")])]),e("div",{staticClass:"form-group"},[e("table",{staticClass:"table table-striped table-hover"},[t._m(0),e("tbody",t._l(t.errors,(function(s){return e("tr",{key:s.element},[e("td",[t._v(t._s(s.element))]),e("td",[t._v(t._s(s.message))])])})),0)])])]):1==t.type_tag_error?e("div",[t._m(1),t._m(2)]):t._e()])])},i=[function(){var t=this,e=t._self._c;return e("thead",[e("tr",[e("th",[t._v("Element")]),e("th",[t._v("Importation error")])])])},function(){var t=this,e=t._self._c;return e("div",{staticClass:"form-group"},[e("div",{staticClass:"toast toast-error"},[t._v(" ✗ IOC(s) not imported, see details below. ")])])},function(){var t=this,e=t._self._c;return e("div",{staticClass:"form-group"},[e("div",{staticClass:"empty"},[e("p",{staticClass:"empty-title h5"},[t._v("Please select a tag and a type.")]),e("p",{staticClass:"empty-subtitle"},[t._v('If different IOCs types, select "Unknown (regex parsing)".')])])])}],r=(s("14d9"),s("bc3a")),o=s.n(r),l={name:"manageiocs",data(){return{type:"",elements:"",types:[],errors:[],imported:[],wrong_wh_file:!1,tabs:{bulk:!0,file:!1,export:!1},jwt:"",export_url:""}},props:{},methods:{import_from_bulk:function(){this.errors=[],this.imported=[],""!=this.type?(this.elements.match(/[^\r\n]+/g).forEach(t=>{this.import_element(this.type,t)}),this.elements=""):this.type_tag_error=!0},import_element:function(t,e){""!=e&&"#"!=e.slice(0,1)&&o.a.get(`/api/whitelist/add/${t.trim()}/${e.trim()}`,{timeout:1e4,headers:{"X-Token":this.jwt}}).then(t=>{t.data.status?this.imported.push(t.data):t.data.message&&this.errors.push(t.data)}).catch(t=>console.log(t))},enrich_types:function(){o.a.get("/api/whitelist/get/types",{timeout:1e4,headers:{"X-Token":this.jwt}}).then(t=>{t.data.types&&(this.types=t.data.types)}).catch(t=>console.log(t))},switch_tab:function(t){this.errors=[],this.imported=[],Object.keys(this.tabs).forEach(e=>{this.tabs[e]=e==t})},import_from_file:function(t){this.errors=[],this.imported=[];const e=t.target.files[0],s=new FileReader;s.onload=t=>this.$emit("load",t.target.result),s.onload=()=>{try{JSON.parse(s.result).elements.forEach(t=>{this.import_element(t["type"],t["element"])})}catch(t){this.wrong_wh_file=!0}},s.readAsText(e)},async get_jwt(){await o.a.get("/api/get-token",{timeout:1e4}).then(t=>{t.data.token&&(this.jwt=t.data.token)}).catch(t=>console.log(t))}},created:function(){this.get_jwt().then(()=>{this.enrich_types(),this.export_url="/api/whitelist/export?token="+this.jwt})}},n=l,c=s("2877"),p=Object(c["a"])(n,a,i,!1,null,null,null);e["default"]=p.exports}}]); //# sourceMappingURL=chunk-2d215cd3.f0d8ba06.js.map