Updated fontello (added block and doc-inv icons).

Upload results will now show either doc or block icon on top of the
file name depending on the status of the upload
(unless the uploads are images, in which case they will still show
thumbnails instead).

Added support for customizable timeout and chunkSize options for ClamAV
scanning to the config file.

Bumped v1 and v3 version strings.
This commit is contained in:
Bobby Wibowo 2019-04-18 16:06:14 +07:00
parent 9b1cb06825
commit ecb8afbe40
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
12 changed files with 58 additions and 26 deletions

View File

@ -173,7 +173,9 @@ module.exports = {
scan: {
enabled: false,
ip: '127.0.0.1',
port: 3310
port: 3310,
timeout: 180 * 1000,
chunkSize: 64 * 1024
},
/*

View File

@ -567,22 +567,23 @@ uploadsController.formatInfoMap = (req, res, user, infoMap) => {
uploadsController.scanFiles = (req, infoMap) => {
return new Promise(async (resolve, reject) => {
const scanner = req.app.get('clam-scanner')
const timeout = config.uploads.scan.timeout || 5000
const chunkSize = config.uploads.scan.chunkSize || 64 * 1024
let iteration = 0
for (const info of infoMap)
scanner.scanFile(info.path).then(reply => {
scanner.scanFile(info.path, timeout, chunkSize).then(reply => {
iteration++
const lastIteration = iteration === infoMap.length
if (!reply.includes('OK') || reply.includes('FOUND')) {
// eslint-disable-next-line no-control-regex
const virus = reply.replace(/^stream: /, '').replace(/ FOUND\u0000$/, '')
console.log(`ClamAV: ${info.data.filename}: ${virus} FOUND.`)
return resolve(virus)
return resolve({ virus, lastIteration })
}
iteration++
if (iteration === infoMap.length)
resolve(null)
if (lastIteration) resolve(null)
}).catch(reject)
}).then(virus => {
if (!virus) return false
}).then(result => {
if (!result) return false
// If there is at least one dirty file, then delete all files
const set = req.app.get('uploads-set')
infoMap.forEach(info => {
@ -595,10 +596,10 @@ uploadsController.scanFiles = (req, infoMap) => {
})
// Unfortunately, we will only be returning name of the first virus
// even if the current session was made up by multiple virus types
return `Virus detected: ${virus}.`
return `Threat found: ${result.virus}${result.lastIteration ? '' : ', and maybe more'}.`
}).catch(error => {
console.error(`ClamAV: ${error.toString()}.`)
return `ClamAV: ${error.code}, please contact site owner.`
return `ClamAV: ${error.code !== undefined ? `${error.code} , p` : 'P'}lease contact the site owner.`
})
}

View File

@ -120,6 +120,14 @@
margin-bottom: 0;
}
.uploads .icon:not(.icon-block) {
color: #3794d2;
}
.uploads .icon.icon-block {
color: #da4453;
}
.uploads progress {
margin-top: .5rem;
margin-bottom: 1rem;

View File

@ -272,6 +272,7 @@ page.prepareDropzone = function () {
})
page.dropzone.on('error', function (file, error) {
page.updateTemplateIcon(file.previewElement, 'icon-block')
file.previewElement.querySelector('.progress').style.display = 'none'
file.previewElement.querySelector('.name').innerHTML = file.name
file.previewElement.querySelector('.error').innerHTML = error.description || error
@ -312,6 +313,7 @@ page.uploadUrls = function (button) {
previewTemplate.innerHTML = page.previewTemplate.trim()
const previewElement = previewTemplate.content.firstChild
previewElement.querySelector('.name').innerHTML = url
previewElement.querySelector('.progress').removeAttribute('value')
previewsContainer.appendChild(previewElement)
return {
url,
@ -326,11 +328,12 @@ page.uploadUrls = function (button) {
function posted (result) {
file.previewElement.querySelector('.progress').style.display = 'none'
if (result.success)
if (result.success) {
page.updateTemplate(file, result.files[0])
else
} else {
page.updateTemplateIcon(file.previewElement, 'icon-block')
file.previewElement.querySelector('.error').innerHTML = result.description
}
return post(i + 1)
}
@ -355,6 +358,13 @@ page.uploadUrls = function (button) {
return run()
}
page.updateTemplateIcon = function (templateElement, iconClass) {
const iconElement = templateElement.querySelector('.icon')
if (!iconElement) return
iconElement.classList.add(iconClass)
iconElement.style.display = ''
}
page.updateTemplate = function (file, response) {
if (!response.url) return
@ -368,12 +378,16 @@ page.updateTemplate = function (file, response) {
const img = file.previewElement.querySelector('img')
img.setAttribute('alt', response.name || '')
img.dataset['src'] = response.url
img.style.display = ''
img.onerror = function () {
// Hide images that failed to load
// Consequently also WEBP in browsers that do not have WEBP support (Firefox/IE)
// Hide image elements that fail to load
// Consequently include WEBP in browsers that do not have WEBP support (Firefox/IE)
this.style.display = 'none'
file.previewElement.querySelector('.icon').style.display = ''
}
page.lazyLoad.update(file.previewElement.querySelectorAll('img'))
} else {
page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')
}
}

View File

@ -1,11 +1,11 @@
@font-face {
font-family: 'fontello';
src: url('fontello.eot?94642010');
src: url('fontello.eot?94642010#iefix') format('embedded-opentype'),
url('fontello.woff2?94642010') format('woff2'),
url('fontello.woff?94642010') format('woff'),
url('fontello.ttf?94642010') format('truetype'),
url('fontello.svg?94642010#fontello') format('svg');
src: url('fontello.eot?13682569');
src: url('fontello.eot?13682569#iefix') format('embedded-opentype'),
url('fontello.woff2?13682569') format('woff2'),
url('fontello.woff?13682569') format('woff'),
url('fontello.ttf?13682569') format('truetype'),
url('fontello.svg?13682569#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
@ -15,7 +15,7 @@
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'fontello';
src: url('fontello.svg?94642010#fontello') format('svg');
src: url('fontello.svg?13682569#fontello') format('svg');
}
}
*/
@ -77,11 +77,13 @@
.icon-help-circled:before { content: '\e80f'; } /* '' */
.icon-terminal:before { content: '\e810'; } /* '' */
.icon-hammer:before { content: '\e811'; } /* '' */
.icon-block:before { content: '\e812'; } /* '' */
.icon-privatebin:before { content: '\e817'; } /* '' */
.icon-github-circled:before { content: '\f09b'; } /* '' */
.icon-filter:before { content: '\f0b0'; } /* '' */
.icon-docs:before { content: '\f0c5'; } /* '' */
.icon-gauge:before { content: '\f0e4'; } /* '' */
.icon-doc-inv:before { content: '\f15b'; } /* '' */
.icon-paper-plane-empty:before { content: '\f1d9'; } /* '' */
.icon-user-plus:before { content: '\f234'; } /* '' */
.icon-chrome:before { content: '\f268'; } /* '' */

Binary file not shown.

View File

@ -42,6 +42,8 @@
<glyph glyph-name="hammer" unicode="&#xe811;" d="M988-7q0-30-20-50l-60-61q-22-20-51-20-29 0-50 20l-203 204q-21 20-21 50 0 29 24 53l-143 143-70-70q-8-8-19-8t-19 8q1-1 7-7t7-7 6-6 5-8 4-8 3-9 0-10q0-21-15-38-2-1-9-10t-11-11-10-9-13-9-12-5-14-3q-23 0-38 16l-228 228q-16 15-16 38 0 7 3 14t5 12 9 13 9 10 11 11 10 9q17 15 38 15 6 0 10 0t9-3 8-4 8-5 6-6 7-7 7-7q-8 8-8 19t8 19l194 194q8 8 19 8t19-8q-1 1-7 7t-7 7-6 7-5 7-3 8-4 9 0 10q0 21 15 38 2 2 9 10t11 11 10 10 13 8 12 5 14 3q23 0 38-16l228-228q16-15 16-38 0-7-3-14t-5-12-8-13-10-10-11-11-10-9q-17-15-38-15-6 0-10 0t-9 4-8 3-7 5-7 6-7 7-7 7q8-8 8-19t-8-19l-70-70 143-143q24 24 53 24 29 0 51-21l203-202q20-22 20-51z" horiz-adv-x="1000" />
<glyph glyph-name="block" unicode="&#xe812;" d="M732 352q0 90-48 164l-421-420q76-50 166-50 62 0 118 25t96 65 65 97 24 119z m-557-167l421 421q-75 50-167 50-83 0-153-40t-110-111-41-153q0-91 50-167z m682 167q0-88-34-168t-91-137-137-92-166-34-167 34-137 92-91 137-34 168 34 167 91 137 137 91 167 34 166-34 137-91 91-137 34-167z" horiz-adv-x="857.1" />
<glyph glyph-name="privatebin" unicode="&#xe817;" d="M484-131c-7 4-107 58-221 121-151 82-209 115-211 118-2 4-2 48-1 245 1 221 2 240 5 243 2 2 101 57 221 122 151 82 220 118 224 118 4 0 15-4 27-11 12-7 110-61 219-120 143-78 199-109 201-113 2-4 2-48 1-245-1-221-1-240-5-243-3-4-436-239-442-241-2 0-9 2-18 6z m138 213c0 1-8 31-17 67-31 119-46 187-48 216l-2 19 21 21c37 39 56 74 58 105 0 13 0 18-4 28-9 25-37 53-67 67-50 24-102 18-142-16-34-28-51-62-48-96 2-28 17-55 49-87 11-11 21-22 21-25 2-9 0-38-6-67-7-34-29-123-46-184-7-26-13-48-13-49 0 0 55-1 122-1 78 0 122 1 122 2z" horiz-adv-x="1000" />
<glyph glyph-name="github-circled" unicode="&#xf09b;" d="M429 779q116 0 215-58t156-156 57-215q0-140-82-252t-211-155q-15-3-22 4t-7 17q0 1 0 43t0 75q0 54-29 79 32 3 57 10t53 22 45 37 30 58 11 84q0 67-44 115 21 51-4 114-16 5-46-6t-51-25l-21-13q-52 15-107 15t-108-15q-8 6-23 15t-47 22-47 7q-25-63-5-114-44-48-44-115 0-47 12-83t29-59 45-37 52-22 57-10q-21-20-27-58-12-5-25-8t-32-3-36 12-31 35q-11 18-27 29t-28 14l-11 1q-12 0-16-2t-3-7 5-8 7-6l4-3q12-6 24-21t18-29l6-13q7-21 24-34t37-17 39-3 31 1l13 3q0-22 0-50t1-30q0-10-8-17t-22-4q-129 43-211 155t-82 252q0 117 58 215t155 156 216 58z m-267-616q2 4-3 7-6 1-8-1-1-4 4-7 5-3 7 1z m18-19q4 3-1 9-6 5-9 2-4-3 1-9 5-6 9-2z m16-25q6 4 0 11-4 7-9 3-5-3 0-10t9-4z m24-23q4 4-2 10-7 7-11 2-5-5 2-11 6-6 11-1z m32-14q1 6-8 9-8 2-10-4t7-9q8-3 11 4z m35-3q0 7-10 6-9 0-9-6 0-7 10-6 9 0 9 6z m32 5q-1 7-10 5-9-1-8-8t10-4 8 7z" horiz-adv-x="857.1" />
@ -52,6 +54,8 @@
<glyph glyph-name="gauge" unicode="&#xf0e4;" d="M214 207q0 30-21 51t-50 21-51-21-21-51 21-50 51-21 50 21 21 50z m107 250q0 30-20 51t-51 21-50-21-21-51 21-50 50-21 51 21 20 50z m239-268l57 213q3 14-5 27t-21 16-27-3-17-22l-56-213q-33-3-60-25t-35-55q-11-43 11-81t66-50 81 11 50 66q9 33-4 65t-40 51z m369 18q0 30-21 51t-51 21-50-21-21-51 21-50 50-21 51 21 21 50z m-358 357q0 30-20 51t-51 21-50-21-21-51 21-50 50-21 51 21 20 50z m250-107q0 30-20 51t-51 21-50-21-21-51 21-50 50-21 51 21 20 50z m179-250q0-145-79-269-10-17-30-17h-782q-20 0-30 17-79 123-79 269 0 102 40 194t106 160 160 107 194 39 194-39 160-107 106-160 40-194z" horiz-adv-x="1000" />
<glyph glyph-name="doc-inv" unicode="&#xf15b;" d="M571 564v264q13-8 21-16l227-228q8-7 16-20h-264z m-71-18q0-22 16-37t38-16h303v-589q0-23-15-38t-38-16h-750q-23 0-38 16t-16 38v892q0 23 16 38t38 16h446v-304z" horiz-adv-x="857.1" />
<glyph glyph-name="paper-plane-empty" unicode="&#xf1d9;" d="M984 844q19-13 15-36l-142-857q-3-16-18-25-8-5-18-5-6 0-13 3l-294 120-166-182q-10-12-27-12-7 0-12 2-11 4-17 13t-6 21v252l-264 108q-20 8-22 30-2 22 18 33l928 536q20 12 38-1z m-190-837l123 739-800-462 187-76 482 356-267-444z" horiz-adv-x="1000" />
<glyph glyph-name="user-plus" unicode="&#xf234;" d="M393 350q-89 0-152 63t-62 151 62 152 152 63 151-63 63-152-63-151-151-63z m536-71h196q7 0 13-6t5-12v-107q0-8-5-13t-13-5h-196v-197q0-7-6-12t-12-6h-107q-8 0-13 6t-5 12v197h-197q-7 0-12 5t-6 13v107q0 7 6 12t12 6h197v196q0 7 5 13t13 5h107q7 0 12-5t6-13v-196z m-411-125q0-29 21-51t50-21h143v-133q-38-28-95-28h-488q-67 0-108 39t-41 106q0 30 2 58t8 61 15 60 24 55 34 45 48 30 62 11q11 0 22-10 44-34 86-51t92-17 92 17 86 51q11 10 22 10 73 0 121-54h-125q-29 0-50-21t-21-50v-107z" horiz-adv-x="1142.9" />

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,9 +16,9 @@
v3: CSS and JS files (libs such as bulma, lazyload, etc).
v4: Renders in /public/render/* directories (to be used by render.js).
#}
{% set v1 = "ix1PYPhEvh" %}
{% set v1 = "DKoamSTKbO" %}
{% set v2 = "hiboQUzAzp" %}
{% set v3 = "hiboQUzAzp" %}
{% set v3 = "DKoamSTKbO" %}
{% set v4 = "dplQUZqTnf" %}
{#

View File

@ -109,7 +109,8 @@
<div id="tpl" style="display: none">
<div class="field">
<img class="is-unselectable">
<i class="icon" style="display: none"></i>
<img class="is-unselectable" style="display: none">
<p class="name is-unselectable"></p>
<progress class="progress is-small is-danger" value="0" max="100">0%</progress>
<p class="error"></p>