update format to use clean code

This commit is contained in:
Celogeek 2024-04-02 18:26:27 +02:00
parent 4da5ece94d
commit 3d255dcfc5
Signed by: celogeek
SSH Key Fingerprint: SHA256:DEDfxIK2nUWXbslbRkww3zsauDjhWHlTXar+ak4lDJ4

View File

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