Compare commits

..

2 Commits
v1.0.1 ... main

Author SHA1 Message Date
344f282495
1.1.0 2024-04-02 18:29:23 +02:00
3d255dcfc5
update format to use clean code 2024-04-02 18:26:27 +02:00
2 changed files with 31 additions and 18 deletions

View File

@ -25,40 +25,53 @@ async function readAudit() {
const severities = {
info: 'INFO',
low: 'MINOR',
moderate: 'MINOR',
high: 'CRITICAL',
critical: 'BLOCKER',
info: 'LOW',
low: 'LOW',
moderate: 'MEDIUM',
high: 'MEDIUM',
critical: 'HIGH',
};
async function main() {
const pnpmAudit = await readAudit()
const rules = []
const issues = []
for (const advice of Object.values(pnpmAudit.advisories || [])) {
issues.push({
"engineId": "pnpm-audit",
"ruleId": advice.id,
"severity": severities[advice.severity],
"type": "VULNERABILITY",
"efforMinutes": 0,
"primaryLocation": {
"message": `${advice.module_name} ${advice.vulnerable_versions}
${advice.title || ''}
rules.push({
id: `${advice.id}`,
name: advice.github_advisory_id || advice.npm_advisory_id || `rule_${advice.id}`,
description: `<h1>${advice.module_name} ${advice.vulnerable_versions}</h1>
<h2>${advice.title || ''}</h2>
Overview:
<pre>
${advice.overview || ''}
</pre>
References:
<pre>
${advice.references || ''}
</pre>
`,
"filePath": "pnpm-lock.yaml",
cleanCodeAttribute: "TRUSTWORTHY",
engineId: "pnpm-audit",
impacts: [{
softwareQuality: "SECURITY",
severity: severities[advice.severity],
}]
})
issues.push({
ruleId: `${advice.id}`,
efforMinutes: 0,
primaryLocation: {
message: advice.title,
filePath: "pnpm-lock.yaml",
},
"secondaryLocations": []
secondaryLocations: []
})
}
console.log(JSON.stringify({ issues }, null, 2))
console.log(JSON.stringify({ rules, issues }, null, 2))
}
main()

View File

@ -1,6 +1,6 @@
{
"name": "pnpm-audit-sonar",
"version": "1.0.1",
"version": "1.1.0",
"description": "Convert PNPM audit to Sonar compatible format",
"main": "index.js",
"scripts": {