-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28418e9
commit 2d3e20b
Showing
16 changed files
with
822 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
const {createScanner} = require('clamdjs'); | ||
const config = require('../config'); | ||
const HttpStatus = require('http-status-codes'); | ||
|
||
async function scanFilePayload(req, res, next) { | ||
const valid = await scanFile(req.body.documentData ? req.body.documentData : req.body.fileContents); | ||
|
||
if (!valid) { | ||
return res.status(HttpStatus.NOT_ACCEPTABLE).json({ | ||
status: HttpStatus.NOT_ACCEPTABLE, | ||
message: 'File has failed the virus scan' | ||
}); | ||
} | ||
|
||
// no virus found in file | ||
next(); | ||
} | ||
|
||
async function scanSecureExchangeDocumentPayload(req, res, next) { | ||
let documents = req.body.secureExchangeDocuments ? req.body.secureExchangeDocuments : []; | ||
for (const document of documents) { | ||
let valid = await scanFile(document?.documentData); | ||
if (!valid) { | ||
return res.status(HttpStatus.NOT_ACCEPTABLE).json({ | ||
status: HttpStatus.NOT_ACCEPTABLE, | ||
message: 'File has failed the virus scan' | ||
}); | ||
} | ||
} | ||
return next(); | ||
} | ||
|
||
async function scanFile(base64File){ | ||
try{ | ||
const ClamAVScanner = createScanner(config.get('clamav:host'), Number(config.get('clamav:port'))); | ||
const clamAVScanResult = await ClamAVScanner.scanBuffer(Buffer.from(base64File, 'base64'), 3000, 1024 * 1024); | ||
if (clamAVScanResult.includes('FOUND')) { | ||
console.log('ClamAV scan found possible virus'); | ||
return false; | ||
} | ||
} catch (e) { | ||
// if virus scan is not to be performed/cannot be performed | ||
console.log('ClamAV Scanner was not found: ' + e); | ||
} | ||
console.log('ClamAV scan found no virus in file, allowing upload...'); | ||
return true; | ||
} | ||
|
||
const utils = { | ||
scanFilePayload, | ||
scanSecureExchangeDocumentPayload, | ||
scanFile | ||
}; | ||
|
||
module.exports = utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
frontend/src/components/assessments/AssessmentDataExchange.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<template> | ||
<v-container class="containerSetup" :fluid="true"> | ||
<v-row class="d-flex justify-start"> | ||
<v-col> | ||
<h2 class="subjectHeading"> | ||
School Year: {{ schoolYear?.replace("-", "/") }} | ||
</h2> | ||
</v-col> | ||
</v-row> | ||
<v-row no-gutters> | ||
<v-col> | ||
<v-divider class="divider" /> | ||
</v-col> | ||
</v-row> | ||
<v-row v-if="isLoading" class="mt-0"> | ||
<v-col> | ||
<Spinner /> | ||
</v-col> | ||
</v-row> | ||
<v-row v-else> | ||
<v-col class="border"> | ||
<v-tabs v-model="tab" color="#38598a"> | ||
<v-tab :value="1">Assessment Keys</v-tab> | ||
<v-tab :value="2">Assessment Results</v-tab> | ||
</v-tabs> | ||
<v-window v-model="tab"> | ||
<v-window-item | ||
:value="1" | ||
transition="false" | ||
reverse-transition="false" | ||
> | ||
<AssessmentKeyUpload | ||
v-if="activeSessions?.length > 0" | ||
:school-year="schoolYear" | ||
:school-year-sessions="activeSessions" | ||
/> | ||
</v-window-item> | ||
<v-window-item | ||
:value="2" | ||
transition="false" | ||
reverse-transition="false" | ||
/> | ||
<v-window-item | ||
:value="3" | ||
transition="false" | ||
reverse-transition="false" | ||
/> | ||
</v-window> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
</template> | ||
<script> | ||
import Spinner from '@/components/common/Spinner.vue'; | ||
import ApiService from '../../common/apiService'; | ||
import { Routes } from '../../utils/constants'; | ||
import AssessmentKeyUpload from './data-exchange/AssessmentKeyUpload.vue'; | ||
import { DateTimeFormatter, LocalDate } from '@js-joda/core'; | ||
export default { | ||
name: 'AssessmentSessionDetail', | ||
components: { | ||
Spinner, | ||
AssessmentKeyUpload, | ||
}, | ||
mixins: [], | ||
props: {}, | ||
data() { | ||
return { | ||
activeSessions: [], | ||
schoolYear: null, | ||
isLoading: false, | ||
tab: '', | ||
}; | ||
}, | ||
computed: {}, | ||
created() { | ||
this.loading = true; | ||
this.getActiveSessions(); | ||
}, | ||
methods: { | ||
async getActiveSessions() { | ||
this.loading = true; | ||
const formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; | ||
ApiService.apiAxios | ||
.get(`${Routes.eas.EAS_ASSESSMENT_SESSIONS}`, {}) | ||
.then((response) => { | ||
const allSessions = response.data; | ||
allSessions.sort((a, b) => { | ||
const dateA = LocalDate.parse(a.activeUntilDate, formatter); | ||
const dateB = LocalDate.parse(b.activeUntilDate, formatter); | ||
return dateB.compareTo(dateA); | ||
}); | ||
this.schoolYear = allSessions?.length > 0 ? allSessions[0].schoolYear : null; | ||
this.activeSessions = allSessions.filter((session) => session.schoolYear === this.schoolYear); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}) | ||
.finally(() => { | ||
this.loading = false; | ||
}); | ||
}, | ||
backToAssesmentSessions() { | ||
this.$router.push({ name: 'assessment-sessions' }); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
<style scoped> | ||
.border { | ||
border: 2px solid grey; | ||
border-radius: 5px; | ||
padding: 35px; | ||
margin-bottom: 2em; | ||
} | ||
.divider { | ||
border-color: #fcba19; | ||
border-width: 3px; | ||
opacity: unset; | ||
} | ||
.containerSetup { | ||
padding-right: 5em !important; | ||
padding-left: 5em !important; | ||
} | ||
@media screen and (max-width: 1200px) { | ||
.containerSetup { | ||
padding-right: 3em !important; | ||
padding-left: 3em !important; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.