Skip to content

Commit

Permalink
DT-1144 Adds cryptography into report component info
Browse files Browse the repository at this point in the history
  • Loading branch information
agustingroh committed Jan 2, 2024
1 parent 82056d3 commit 3de6d27
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit 3de6d27

Please sign in to comment.