Skip to content

Commit

Permalink
fix: web app xccdf import logic (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
csmig authored Feb 14, 2022
1 parent 22cbfe7 commit a93f6fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions client/src/js/SM/Parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ const reviewsFromScc = function (sccFileContent, options = {}) {
ruleId: ruleResult.idref.replace('xccdf_mil.disa.stig_rule_', ''),
result: ruleResult.result,
detail: `SCC Reviewed at ${ruleResult.time}`,
comment: null,
autoResult: true,
status: 'saved'
})
Expand Down
31 changes: 24 additions & 7 deletions client/src/js/SM/ReviewsImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -1386,12 +1386,25 @@ async function showImportResultFiles(collectionId, fieldSettings) {
throw ('Event is missing the dataTransfer property')
}
entries = await getAllFileEntries(e.dataTransfer.items, e.currentTarget)
for (const entry of entries) {
files.push(await entryFilePromise(entry))
if (!entries.length) {
showErrors({
errors: [{
file: {
name: '[UNSUPPORTED FILES]'
},
error: 'No .ckl or .xml files were dropped'
}],
stopWizard: true
})
}
else {
for (const entry of entries) {
files.push(await entryFilePromise(entry))
}
files.sort((a, b) => a.lastModified - b.lastModified)
Object.assign(cklParseOptions, cklOptions)
warnOnExcessFiles(files)
}
files.sort((a, b) => a.lastModified - b.lastModified)
Object.assign(cklParseOptions, cklOptions)
warnOnExcessFiles(files)
}
catch (e) {
alert(e)
Expand All @@ -1410,7 +1423,7 @@ async function showImportResultFiles(collectionId, fieldSettings) {
while (queue.length > 0) {
let entry = queue.shift()
searched++
if (entry.isFile && entry.name.toLowerCase().endsWith('.ckl')) {
if (entry.isFile && (entry.name.toLowerCase().endsWith('.ckl') || entry.name.toLowerCase().endsWith('.xml'))) {
fileEntries.push(entry)
found++
el.innerText = `Searching... Searched ${searched} files, found ${found} results files`
Expand Down Expand Up @@ -1678,7 +1691,7 @@ async function showImportResultFiles(collectionId, fieldSettings) {
let pePanel = new SM.ReviewsImport.ParseErrorsPanel({
errors: results.errors.length > 0 ? results.errors : null,
duplicates: results.hasDuplicates ? results.dupedRows : null,
continueHandler: onContinue,
continueHandler: results.stopWizard ? onAbort : onContinue,
backHandler: onBack
})
fpwindow.removeAll()
Expand All @@ -1690,6 +1703,10 @@ async function showImportResultFiles(collectionId, fieldSettings) {
showOptions(results)
}

function onAbort() {
fpwindow.close()
}

function onBack() {

}
Expand Down

0 comments on commit a93f6fe

Please sign in to comment.