-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added transitive vulnerability (#40)
- Loading branch information
1 parent
64814eb
commit ce56e9d
Showing
13 changed files
with
247 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class SecondService { | ||
static readonly apiVersion = "1.0"; | ||
static readonly debrickedBaseUrl = "https://debricked.com"; | ||
static readonly baseUrl = `${SecondService.debrickedBaseUrl}/api/${SecondService.apiVersion}/`; | ||
|
||
static readonly dependencyUrl = "open/dependencies/get-dependencies-hierarchy"; | ||
static readonly vulnerableUrl = "open/vulnerabilities/get-vulnerabilities"; | ||
static readonly repositoryBaseUrl = "https://debricked.com/app/en/repository/"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,99 @@ | ||
import { PolicyViolation } from "types/scannedData"; | ||
import { Organization } from "../constants"; | ||
import { DependencyVulnerability } from "types/vulnerability"; | ||
import { Vulnerabilities } from "types/vulnerability"; | ||
import * as vscode from "vscode"; | ||
import { SecondService } from "../constants"; | ||
|
||
export class Template { | ||
constructor() {} | ||
public licenseContent(data: string, contents: vscode.MarkdownString) { | ||
contents.appendMarkdown(`License: **${data}**`); | ||
contents.appendText("\n______________________________\n"); | ||
|
||
private policyViolation = { | ||
failPipeline: "Pipeline failing", | ||
warnPipeline: "Pipeline warning", | ||
markUnaffected: "Mark vulnerability as unaffected", | ||
markVulnerable: "Flag vulnerability as vulnerable", | ||
sendEmail: "Notified email", | ||
triggerWebhook: "Triggered webhook", | ||
}; | ||
|
||
public licenseContent(license: string, contents: vscode.MarkdownString) { | ||
contents.appendMarkdown(`License: **${license}**`); | ||
contents.appendText(Organization.separator); | ||
} | ||
|
||
public vulnerableContent(data: DependencyVulnerability[], contents: vscode.MarkdownString): void { | ||
if (data.length === 0) { | ||
contents.appendMarkdown("No vulnerabilities found"); | ||
return; | ||
public vulnerableContent(vulnerabilities: Vulnerabilities, contents: vscode.MarkdownString): void { | ||
// direct vulnerabilities | ||
if (vulnerabilities.directVulnerabilities.length === 0) { | ||
contents.appendMarkdown("No vulnerabilities found\n\n"); | ||
} else { | ||
contents.appendMarkdown( | ||
`Direct Vulnerabilities Found: **${vulnerabilities.directVulnerabilities.length}**\n\n`, | ||
); | ||
|
||
const vulnerabilitiesToShow = vulnerabilities.directVulnerabilities.slice(0, 2); | ||
vulnerabilitiesToShow.forEach((vulnerability) => { | ||
contents.appendMarkdown( | ||
`[**${vulnerability.cveId}**](${SecondService.debrickedBaseUrl + vulnerability.name.link})`, | ||
); | ||
|
||
if (vulnerability.cvss) { | ||
contents.appendMarkdown(` - CVSS: ${vulnerability.cvss.text} (${vulnerability.cvss.type})`); | ||
} | ||
|
||
contents.appendMarkdown("\n\n"); | ||
}); | ||
} | ||
|
||
contents.appendMarkdown(`Vulnerabilities Found: **${data.length}**\n\n`); | ||
contents.appendText(Organization.separator); | ||
|
||
const vulnerabilitiesToShow = data.slice(0, 2); | ||
vulnerabilitiesToShow.forEach((vulnerability) => { | ||
// transitive vulnerabilities | ||
if (vulnerabilities.indirectVulnerabilities.length === 0) { | ||
contents.appendMarkdown("No transitive vulnerabilities found"); | ||
} else { | ||
contents.appendMarkdown( | ||
`[**${vulnerability.cveId}**](${Organization.debrickedBaseUrl + vulnerability.name.link})`, | ||
`Transitive Vulnerabilities Found: **${vulnerabilities.indirectVulnerabilities.length}**`, | ||
); | ||
contents.appendMarkdown("\n\n"); | ||
vulnerabilities.indirectVulnerabilities.forEach((indirectVulnerability) => { | ||
const vulnerabilitiesToShow = indirectVulnerability; | ||
contents.appendMarkdown(`${indirectVulnerability.dependencyName}`); | ||
contents.appendMarkdown("\n\n"); | ||
|
||
if (vulnerability.cvss) { | ||
contents.appendMarkdown(` - CVSS: ${vulnerability.cvss.text} (${vulnerability.cvss.type})`); | ||
} | ||
vulnerabilitiesToShow.transitiveVulnerabilities.forEach((vulnerability) => { | ||
contents.appendMarkdown( | ||
`[**${vulnerability.cveId}**](${SecondService.debrickedBaseUrl + vulnerability.name.link})`, | ||
); | ||
|
||
contents.appendMarkdown("\n\n"); | ||
if (vulnerability.cvss) { | ||
contents.appendMarkdown(` - CVSS: ${vulnerability.cvss.text} (${vulnerability.cvss.type})`); | ||
} | ||
|
||
contents.appendMarkdown("\n\n"); | ||
}); | ||
}); | ||
} | ||
|
||
contents.appendText(Organization.separator); | ||
} | ||
|
||
public policyViolationContent(policyViolationData: PolicyViolation[], contents: vscode.MarkdownString) { | ||
if (policyViolationData.length === 0) { | ||
contents.appendMarkdown("No policy violations found.\n"); | ||
return; | ||
} | ||
|
||
contents.appendMarkdown("Policy Violations\n\n"); | ||
|
||
policyViolationData.forEach((violation: PolicyViolation, index: number) => { | ||
contents.appendMarkdown(`Rule - ${index + 1}`); | ||
contents.appendMarkdown("\n"); | ||
violation.ruleActions.forEach((ruleAction: string, index: number) => { | ||
contents.appendMarkdown( | ||
` ${index + 1}. **${this.policyViolation[ruleAction as keyof typeof this.policyViolation]}** - [View rule](${violation.ruleLink})`, | ||
); | ||
contents.appendMarkdown("\n"); | ||
}); | ||
contents.appendMarkdown("\n"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.