You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
;(()=>{consttestPlugins=(plugins,mimeTypes)=>{constlies=[]// collect lie typesconstpluginsOwnPropertyNames=Object.getOwnPropertyNames(plugins).filter(name=>isNaN(+name))constmimeTypesOwnPropertyNames=Object.getOwnPropertyNames(mimeTypes).filter(name=>isNaN(+name))constpluginsArray=plugins// cast to arrayplugins=[...plugins]mimeTypes=[...mimeTypes]// get intitial trusted mimeType namesconsttrustedMimeTypes=newSet(mimeTypesOwnPropertyNames)// get initial trusted plugin namesconstexcludeDuplicates=arr=>[...newSet(arr)]constmimeTypeEnabledPlugins=excludeDuplicates(mimeTypes.map(mimeType=>mimeType.enabledPlugin))consttrustedPluginNames=newSet(pluginsOwnPropertyNames)constmimeTypeEnabledPluginsNames=mimeTypeEnabledPlugins.map(plugin=>plugin.name)consttrustedPluginNamesArray=[...trustedPluginNames]trustedPluginNamesArray.forEach(name=>{constvalidName=newSet(mimeTypeEnabledPluginsNames).has(name)if(!validName){trustedPluginNames.delete(name)}})// 1. Expect plugin name to be in plugins own property namesplugins.forEach(plugin=>{if(!trustedPluginNames.has(plugin.name)){lies.push('missing plugin name')}})// 2. Expect MimeType Plugins to match PluginsconstgetPluginPropertyValues=plugin=>{return[plugin.description,plugin.filename,plugin.length,plugin.name]}constpluginList=plugins.map(getPluginPropertyValues).sort()constenabledpluginList=mimeTypeEnabledPlugins.map(getPluginPropertyValues).sort()constmismatchingPlugins=''+pluginList!=''+enabledpluginListif(mismatchingPlugins){lies.push('mismatching plugins')}// 3. Expect MimeType object in pluginsconstinvalidPlugins=plugins.filter(plugin=>{try{constvalidMimeType=Object.getPrototypeOf(plugin[0]).constructor.name=='MimeType'if(!validMimeType){trustedPluginNames.delete(plugin.name)}return!validMimeType}catch(error){trustedPluginNames.delete(plugin.name)returntrue// sign of tampering}})if(invalidPlugins.length){lies.push('missing mimetype')}// 4. Expect valid MimeType(s) in pluginconstpluginMimeTypes=plugins.map(plugin=>Object.values(plugin)).flat()constpluginMimeTypesNames=pluginMimeTypes.map(mimetype=>mimetype.type)consttrustedMimeTypesArray=[...trustedMimeTypes]pluginMimeTypesNames.forEach(name=>{constvalidName=trustedMimeTypes.has(name)if(!validName){trustedMimeTypes.delete(name)}})plugins.forEach(plugin=>{constpluginMimeTypes=Object.values(plugin).map(mimetype=>mimetype.type)returnpluginMimeTypes.forEach(mimetype=>{if(!trustedMimeTypes.has(mimetype)){lies.push('invalid mimetype')returntrustedPluginNames.delete(plugin.name)}})})return{
mimeTypes,
plugins,validPlugins: plugins.filter(plugin=>trustedPluginNames.has(plugin.name)),validMimeTypes: mimeTypes.filter(mimeType=>trustedMimeTypes.has(mimeType.type)),lies: [...newSet(lies)]// remove duplicates}}constresult=testPlugins(navigator.plugins,navigator.mimeTypes)returnconsole.log(result)})()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Beta Was this translation helpful? Give feedback.
All reactions