Skip to content

Commit

Permalink
simplified skip message logic
Browse files Browse the repository at this point in the history
Signed-off-by: Amndeep Singh Mann <[email protected]>
  • Loading branch information
Amndeep7 committed Jul 28, 2024
1 parent a89fc34 commit 9212f36
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions libs/hdf-converters/src/gosec-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ function formatSkipMessage(input: Record<string, unknown>): string {
if (`${suppressions}` === 'null') {
return 'N/A';
}
// If test is skipped
let skipMessage = '';
if (Array.isArray(suppressions)) {
suppressions.map((suppression) => {
// If a justification is given, report; otherwise, report that none is given
skipMessage = skipMessage.concat(
`${suppression.justification ? suppression.justification : 'No reason provided'} (${suppression.kind}) `
);
});
}

return skipMessage.trim();
// If test is skipped and there are no justifications, report that none are given
if (!Array.isArray(suppressions)) {
return '';
}
// otherwise, supply the justifications
return suppressions
.map(
(suppression) =>
`${suppression.justification ? suppression.justification : 'No reason provided'} (${suppression.kind})`
)
.join(' ');
}

// Report gosec rule violation and violation location
Expand Down

0 comments on commit 9212f36

Please sign in to comment.