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

DT-1144 Adds cryptography into report component info #654

Merged
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
17 changes: 17 additions & 0 deletions src/main/services/ReportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class ReportService {
// Crypto
const crypto = await modelProvider.model.cryptography.findAllIdentifiedMatched();

this.addCryptoToComponent(licenses, crypto);

// Dependencies
const dependenciesSummary = await modelProvider.model.dependency.getIdentifiedSummary();

Expand Down Expand Up @@ -134,6 +136,8 @@ class ReportService {
// Dependencies
const dependenciesSummary = await modelProvider.model.dependency.getDetectedSummary();

this.addCryptoToComponent(licenses, crypto);

return {
licenses, crypto, vulnerabilities: vulnerabilityReport, dependencies: dependenciesSummary,
};
Expand All @@ -142,6 +146,19 @@ class ReportService {
}
}

private addCryptoToComponent(licenses: Array<LicenseEntry>, crypto: Array<Cryptography>) {
const cryptoMapper = new Map<string, Cryptography>();
crypto.forEach((c) => cryptoMapper.set(`${c.purl}@${c.version}`, c));

licenses.forEach((l) => {
l.components.forEach((c) => {
if (!cryptoMapper.has(`${c.purl}@${c.version}`)) {
c.cryptography = [];
} else { c.cryptography = cryptoMapper.get(`${c.purl}@${c.version}`).algorithms; }
});
});
}

private getLicenseReportFromResults(results: any): Array<LicenseEntry> {
const licenses: Record<string, LicenseEntry> = results.reduce(
(acc, curr) => {
Expand Down
Loading