Skip to content

Commit

Permalink
Removed wait logger debug, added logger listener
Browse files Browse the repository at this point in the history
Signed-off-by: George M Dias <gdias@mitre.org>
  • Loading branch information
georgedias committed Feb 21, 2024
1 parent 9e63d0f commit 9d1982e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,23 @@
}
},
"repository": "mitre/saf",
"scripts": {
"lint": "eslint \"src/**/*.ts\" --fix",
"lint:ci": "eslint \"src/**/*.ts\" --max-warnings 0",
"dev": "rm -rf lib && tsc && node bin/run",
"prepack": "run-script-os",
"test": "npm run test:mocha && npm run test:jest",
"tests": "npm run test",
"test:mocha": "NODE_ENV=test ts-mocha --timeout 8500 --forbid-only \"test/**/*.test.ts\"",
"test:mocha:one": "NODE_ENV=test ts-mocha --timeout 8500 --forbid-only",
"test:jest": "NODE_ENV=test jest",
"test:jest:one": "NODE_ENV=test jest --findRelatedTests",
"prepack:win32": "(IF EXIST lib rmdir /s /q lib) && tsc",
"prepack:darwin:linux": "rm -rf lib && tsc",
"pack-hdf-converters": "run-script-os",
"pack-hdf-converters:win32": "pack-hdf-converters.bat",
"pack-hdf-converters:darwin:linux": "./pack-hdf-converters.sh"
},
"scripts": {
"lint": "eslint \"src/**/*.ts\" --fix",
"lint:ci": "eslint \"src/**/*.ts\" --max-warnings 0",
"dev": "rm -rf lib && tsc && node bin/run",
"test": "npm run test:mocha && npm run test:jest",
"tests": "npm run test",
"test:mocha": "ts-mocha --timeout 8500 --forbid-only \"test/**/*.test.ts\"",
"test:mocha:one": "ts-mocha --timeout 8500 --forbid-only",
"test:jest": "jest",
"test:jest:one": "jest --findRelatedTests",
"prepack": "run-script-os",
"prepack:win32": "(IF EXIST lib rmdir /s /q lib) && tsc",
"prepack:darwin:linux": "rm -rf lib && tsc",
"pack-hdf-converters": "run-script-os",
"pack-hdf-converters:win32": "pack-hdf-converters.bat",
"pack-hdf-converters:darwin:linux": "./pack-hdf-converters.sh"
},
"types": "lib/index.d.ts",
"jest": {
"preset": "ts-jest",
Expand Down
34 changes: 17 additions & 17 deletions src/commands/generate/update_controls4delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ export default class GenerateUpdateControls extends Command {
const files = await readdir(controlsDir)

// Iterate trough all files processing ony control files, have a .rb extension
const skippedControls = []
const skippedFormatting = []
const skippedControls: string[] = []
const skippedFormatting: string[] = []
const isCorrectControlMap = new Map()
const controlsProcessedMap = new Map()

Expand Down Expand Up @@ -270,31 +270,31 @@ export default class GenerateUpdateControls extends Command {
}

let newControls = 0
const newControlsFound = []
const newControlsFound: any[] = []
for (const newControl of xccdfControlsMap.values()) {
if (!controlsProcessedMap.has(newControl) && !isCorrectControlMap.has(newControl)) {
newControls++
newControlsFound.push(newControl)
}
}

await new Promise(resolve => {
setTimeout(resolve, Math.floor(Math.random() * 100))
})
logger.on('finish', function () {
console.log(colors.yellow('\n Total skipped files - no mapping to new control Id:'), colors.green(`${skipped.toString().padStart(4)}`))
console.log(colors.yellow('Total processed files - found mapping to new control Id: '), colors.green(`${processed.toString().padStart(3)}`))

console.log(colors.yellow('\n Total skipped files - no mapping to new control Id:'), colors.green(`${skipped.toString().padStart(4)}`))
console.log(colors.yellow('Total processed files - found mapping to new control Id: '), colors.green(`${processed.toString().padStart(3)}`))
console.log(colors.yellow('\n Total controls with correct identification: '), colors.green(`${isCorrectControl.toString().padStart(3)}`))
console.log(colors.yellow('Total new controls found in the XCCDF guidance: '), colors.green(`${newControls.toString().padStart(3)}`))

console.log(colors.yellow('\n Total controls with correct identification: '), colors.green(`${isCorrectControl.toString().padStart(3)}`))
console.log(colors.yellow('Total new controls found in the XCCDF guidance: '), colors.green(`${newControls.toString().padStart(3)}`))
console.log(colors.yellow('\nSkipped control(s) - not included in XCCDF guidance: '), `${colors.green(skippedControls.toString())}`)
console.log(colors.yellow('\n New control(s) found - included in XCCDF guidance: '), `${colors.green(newControlsFound.toString())}`)

console.log(colors.yellow('\nSkipped control(s) - not included in XCCDF guidance: '), `${colors.green(skippedControls.toString())}`)
console.log(colors.yellow('\n New control(s) found - included in XCCDF guidance: '), `${colors.green(newControlsFound.toString())}`)
if (flags.formatControls && notInProfileJSON > 0) {
console.log(colors.bold.red('\nTotal skipped formatting - not found in the profile json: '), colors.green(`${notInProfileJSON.toString().padStart(3)}`))
console.log(colors.bold.red('Control(s) skipped formatting: '), colors.green(`${skippedFormatting.toString()}`))
}
})

if (flags.formatControls && notInProfileJSON > 0) {
console.log(colors.bold.red('\nTotal skipped formatting - not found in the profile json: '), colors.green(`${notInProfileJSON.toString().padStart(3)}`))
console.log(colors.bold.red('Control(s) skipped formatting: '), colors.green(`${skippedFormatting.toString()}`))
}
logger.end()
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ function saveControl(filePath: string, newXCCDFControlNumber: string, currentCon
fs.copyFileSync(filePath, destFilePath)
}

// Deleted processed (old) file
// Delete processed (old) file
} else if (renamedControl) {
fs.unlinkSync(filePath)
}
Expand Down

0 comments on commit 9d1982e

Please sign in to comment.