Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export interface PluginReportJson {
*/
readonly metadata?: { readonly [key: string]: string };

/**
* Any preamble text that the plugin wants to include in the report that is not a violation itself.
*
* @default - no preamble
*/
readonly preamble?: string;

/**
* Violations found by this plugin.
*/
Expand Down Expand Up @@ -261,6 +268,8 @@ export interface SuppressedViolationJson extends PolicyViolationJson {
export interface CloudFormationResourceJson {
/**
* The path to the CloudFormation template containing this resource.
*
* This path is relative to the Cloud Assembly root directory.
*/
readonly templatePath: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function formatValidationReports(fileRoot: string, reports: PluginReportJ

return [
...pluginFailures.map(formatPluginFailure),
...successfullyExecutedPlugins.flatMap((r) => r.preamble ? [`${chalk.underline(sanitize(r.pluginName))}: ${sanitize(r.preamble)}`] : []),
...violations.map((v) => formatViolationBlock(fileRoot, v)),
];
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ describe('formatValidateResult', () => {
expect(output).toContain('Fake passed message');
expect(output).toContain('Evil');
});

test('preambles are printed', () => {
const result = makeResult([{
pluginName: 'Some Plugin',
conclusion: 'success',
preamble: 'OMG there are warnings',
violations: [{
ruleName: 'RULE',
description: 'Make sure you fix this',
severity: 'warning',
violatingConstructs: [{
constructPath: 'Stack/Resource',
}],
}],
}]);

const output = formatValidateResult(result);
expect(output).toMatchSnapshot();
});
});

function formatValidateResult(result: ValidateResult) {
Expand Down
Loading