Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Remove any error handling that may produce console.log statements #12

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ReviewParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function reviewsFromCkl(
sourceRef
}) {

const errorMessages = []

const maxCommentLength = 32767

const normalizeKeys = function (input) {
Expand Down Expand Up @@ -71,6 +73,8 @@ export function reviewsFromCkl(
if (returnObj.checklists.length === 0) {
throw (new Error("STIG_INFO element has no SI_DATA for SID_NAME == stigId"))
}
returnObj.error = errorMessages

return (returnObj)

function processAsset(assetElement) {
Expand Down Expand Up @@ -239,7 +243,7 @@ export function reviewsFromCkl(
override = parser.parse(comment)['Evaluate-STIG'][0]
}
catch (e) {
console.log(`Failed to parse Evaluate-STIG VULN XML comment for ${ruleId}`)
errorMessages.push(`Failed to parse Evaluate-STIG VULN XML comment for ${ruleId}, comment: ${comment}`)
}
override = normalizeKeys(override)
if (override.afmod?.toLowerCase() === 'true') {
Expand Down Expand Up @@ -351,7 +355,7 @@ export function reviewsFromCkl(
esIStigComment = parser.parse(comment)['Evaluate-STIG'][0]
}
catch (e) {
console.log('Failed to parse Evaluate-STIG root XML comment')
errorMessages.push(`Failed to parse Evaluate-STIG ISTIG XML comment ${comment}`)
}
esIStigComment = normalizeKeys(esIStigComment)
resultEngineIStig = {
Expand All @@ -377,7 +381,7 @@ export function reviewsFromCkl(
esRootComment = parser.parse(comment)['Evaluate-STIG'][0]
}
catch (e) {
console.log('Failed to parse Evaluate-STIG root XML comment')
errorMessages.push(`Failed to parse Evaluate-STIG root XML comment for ${comment}`)
}
esRootComment = normalizeKeys(esRootComment)
resultEngineRoot = {
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ interface ParsedChecklist {
benchmarkId: string;
reviews: ParsedReview[];
revisionStr: string;
errors: string[];
stats: ParsedChecklistStats;
sourceRef: any;
}
Expand Down
Loading