Skip to content

Commit

Permalink
refactor: Removing policy severity reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
rottebds committed Feb 16, 2022
1 parent 34212dd commit fc8c5ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
13 changes: 3 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.createUpgradeReport = exports.createVulnerabilityReport = exports.createLicenseReport = exports.createPolicyReport = exports.createComponentVulnerabilityReports = exports.createComponentLicenseReports = exports.createComponentReport = exports.createRapidScanReport = void 0;
exports.createUpgradeReport = exports.createVulnerabilityReport = exports.createLicenseReport = exports.createComponentVulnerabilityReports = exports.createComponentLicenseReports = exports.createComponentReport = exports.createRapidScanReport = void 0;
const core_1 = __nccwpck_require__(2186);
const blackduck_api_1 = __nccwpck_require__(7495);
const inputs_1 = __nccwpck_require__(6180);
Expand Down Expand Up @@ -328,7 +328,7 @@ function createRapidScanReport(policyViolations, blackduckApiService) {
exports.createRapidScanReport = createRapidScanReport;
function createComponentReport(violation, componentVersion, upgradeGuidance, vulnerabilities) {
return {
violatedPolicies: violation.violatingPolicyNames.map(policyName => createPolicyReport(policyName)),
violatedPolicies: violation.violatingPolicyNames,
name: `${violation.componentName} ${violation.versionName}`,
href: componentVersion === null || componentVersion === void 0 ? void 0 : componentVersion._meta.href,
licenses: createComponentLicenseReports(violation.policyViolationLicenses, componentVersion),
Expand Down Expand Up @@ -362,13 +362,6 @@ function createComponentVulnerabilityReports(policyViolatingVulnerabilities, com
return vulnerabilityReport;
}
exports.createComponentVulnerabilityReports = createComponentVulnerabilityReports;
function createPolicyReport(policyName, severity) {
return {
name: policyName,
severity: severity
};
}
exports.createPolicyReport = createPolicyReport;
function createLicenseReport(name, href, violatesPolicy) {
return {
name: name,
Expand Down Expand Up @@ -439,7 +432,7 @@ function createRapidScanReportString(policyViolations, policyCheckWillFail) {
}
exports.createRapidScanReportString = createRapidScanReportString;
function createComponentRow(component) {
const violatedPolicies = component.violatedPolicies.map(policy => `${policy.name} ${policy.severity === 'UNSPECIFIED' ? '' : `(${policy.severity})`}`).join('<br/>');
const violatedPolicies = component.violatedPolicies.join('<br/>');
const componentInViolation = (component === null || component === void 0 ? void 0 : component.href) ? `[${component.name}](${component.href})` : component.name;
const componentLicenses = component.licenses.map(license => `${license.violatesPolicy ? ':x: &nbsp; ' : ''}[${license.name}](${license.href})`).join('<br/>');
const vulnerabilities = component.vulnerabilities.map(vulnerability => `${vulnerability.violatesPolicy ? ':x: &nbsp; ' : ''}[${vulnerability.name}](${vulnerability.href})${vulnerability.cvssScore && vulnerability.severity ? ` ${vulnerability.severity}: CVSS ${vulnerability.cvssScore}` : ''}`).join('<br/>');
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions src/detect/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function createRapidScanReport(policyViolations: IRapidScanResults[
return rapidScanReport
}
export interface IComponentReport {
violatedPolicies: IPolicyReport[]
violatedPolicies: string[]
name: string
href?: string
licenses: ILicenseReport[]
Expand All @@ -56,7 +56,7 @@ export interface IComponentReport {

export function createComponentReport(violation: IRapidScanResults, componentVersion?: IComponentVersion, upgradeGuidance?: IUpgradeGuidance, vulnerabilities?: IComponentVulnerability[]): IComponentReport {
return {
violatedPolicies: violation.violatingPolicyNames.map(policyName => createPolicyReport(policyName)),
violatedPolicies: violation.violatingPolicyNames,
name: `${violation.componentName} ${violation.versionName}`,
href: componentVersion?._meta.href,
licenses: createComponentLicenseReports(violation.policyViolationLicenses, componentVersion),
Expand Down Expand Up @@ -90,18 +90,6 @@ export function createComponentVulnerabilityReports(policyViolatingVulnerabiliti
return vulnerabilityReport
}

export interface IPolicyReport {
name: string
severity?: string // Not yet implemented
}

export function createPolicyReport(policyName: string, severity?: string): IPolicyReport {
return {
name: policyName,
severity: severity
}
}

export interface ILicenseReport {
name: string
href: string
Expand Down
2 changes: 1 addition & 1 deletion src/detect/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function createRapidScanReportString(policyViolations: IRapidScanRe
}

function createComponentRow(component: IComponentReport): string {
const violatedPolicies = component.violatedPolicies.map(policy => `${policy.name} ${policy.severity === 'UNSPECIFIED' ? '' : `(${policy.severity})`}`).join('<br/>')
const violatedPolicies = component.violatedPolicies.join('<br/>')
const componentInViolation = component?.href ? `[${component.name}](${component.href})` : component.name
const componentLicenses = component.licenses.map(license => `${license.violatesPolicy ? ':x: &nbsp; ' : ''}[${license.name}](${license.href})`).join('<br/>')
const vulnerabilities = component.vulnerabilities.map(vulnerability => `${vulnerability.violatesPolicy ? ':x: &nbsp; ' : ''}[${vulnerability.name}](${vulnerability.href})${vulnerability.cvssScore && vulnerability.severity ? ` ${vulnerability.severity}: CVSS ${vulnerability.cvssScore}` : ''}`).join('<br/>')
Expand Down

0 comments on commit fc8c5ec

Please sign in to comment.