Skip to content

Commit

Permalink
fix: CKL export fails to include all rules (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
csmig authored Mar 1, 2022
1 parent 98025ce commit 0c7ecf5
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions api/source/service/mysql/AssetService.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,9 @@ exports.cklFromAssetStigs = async function cklFromAssetStigs (assetId, benchmark
VULN: []
}
let siDataArray = iStigJs.STIG_INFO.SI_DATA
siDataRefs.forEach(siDatum => {
for (const siDatum of siDataRefs) {
siDataArray.push(siDatum)
})
}

// CHECKLIST.STIGS.iSTIG.STIG_INFO.VULN
let [resultGetChecklist] = await connection.query(sqlGetChecklist, [assetId, revId])
Expand Down Expand Up @@ -820,39 +820,38 @@ exports.cklFromAssetStigs = async function cklFromAssetStigs (assetId, benchmark

// let vulnArray = cklJs.CHECKLIST.STIGS.iSTIG.VULN
let vulnArray = iStigJs.VULN
resultGetChecklist.forEach( r => {
let vulnObj = {
for (const r of resultGetChecklist) {
const vulnObj = {
STIG_DATA: [],
STATUS: r.result || 'Not_Reviewed',
FINDING_DETAILS: r.detail,
COMMENTS: r.comment,
SEVERITY_OVERRIDE: null,
SEVERITY_JUSTIFICATION: null
}
stigDataRef.forEach(stigDatum => {
for (const stigDatum of stigDataRef) {
vulnObj.STIG_DATA.push({
VULN_ATTRIBUTE: stigDatum[0],
ATTRIBUTE_DATA: r[stigDatum[1]]
})
})
}
// STIGRef
vulnObj.STIG_DATA.push({
VULN_ATTRIBUTE: 'STIGRef',
ATTRIBUTE_DATA: `${stig.title} :: Version ${stig.version}, Release: ${stig.release} Benchmark Date: ${stig.benchmarkDate}`
})
// CCI_REFs
if (r.ccis) {
let ccis = r.ccis.split(',')
ccis.forEach( cci=> {
const ccis = r.ccis.split(',')
for (const cci of ccis) {
vulnObj.STIG_DATA.push({
VULN_ATTRIBUTE: 'CCI_REF',
ATTRIBUTE_DATA: `CCI-${cci}`
})
})
vulnArray.push(vulnObj)
}
}
})

vulnArray.push(vulnObj)
}
cklJs.CHECKLIST.STIGS.iSTIG.push(iStigJs)
}

Expand All @@ -863,7 +862,7 @@ exports.cklFromAssetStigs = async function cklFromAssetStigs (assetId, benchmark
throw (e)
}
finally {
if (typeof connection !== 'undefinied') {
if (typeof connection !== 'undefined') {
await connection.release()
}
}
Expand Down

0 comments on commit 0c7ecf5

Please sign in to comment.