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

Add 'advices' field to the generated json report file #215

Merged
merged 4 commits into from
May 17, 2024

Conversation

r0075h3ll
Copy link
Contributor

Hi

The --report-json flag in Vet generated a comprehensive json report file. However, it missed a field that was being displayed in the console output - the 'UPDATE TO' column data, that display what version the package should be upgraded to in order to mitigate the risk.

image

This PR, with a few lines of code, adds 'advices' field to the json report suggesting the alternate package version that the vulnerable package should be upgraded to.

{
    "package":
    {
        "ecosystem": "Maven",
        "name": "com.nimbusds:nimbus-jose-jwt",
        "version": "9.22"
    },
    "manifests":
    [
        "2de911f109118e4d"
    ],
    "advices":
    [
        {
            "target_alternate_package_version": "9.39.1"
        }
    ],
    "vulnerabilities":
    [
        {
            "id": "GHSA-gvpg-vgmx-xg6w",
            "title": "Denial of Service in Connect2id Nimbus JOSE+JWT",
            "aliases":
            [
                "CVE-2023-52428"
            ]
        }
    ],
    "licenses":
    [
        {
            "id": "Apache-2.0"
        }
    ]
}

Thanks.

pkg/reporter/json_report.go Outdated Show resolved Hide resolved
pkg/reporter/json_report.go Outdated Show resolved Hide resolved
pkg/reporter/json_report.go Outdated Show resolved Hide resolved
@abhisek
Copy link
Member

abhisek commented May 17, 2024

@r0075h3ll Thank you very much for your contribution. I have added a few review comments.

@abhisek
Copy link
Member

abhisek commented May 17, 2024

@r0075h3ll I have made a small change. I am including the updated version for the package as a remediation advice in the JSON report. I am skipping the helper function from summaryReporter. The reason being, summaryReport formats the version to a form that is meant for human readability. JSON report is meant for machine parsing hence we must include only the version or nothing in case updated version is not available. We should not include strings like - or Not Available in JSON report IMHO.

@abhisek abhisek merged commit 14cde55 into safedep:main May 17, 2024
8 of 9 checks passed
@abhisek
Copy link
Member

abhisek commented May 17, 2024

@r0075h3ll Thanks for your contribution. I will trigger a release later tonight. You should have this change included in the latest version of vet by tomorrow.

@r0075h3ll
Copy link
Contributor Author

@abhisek Thanks for this project, it's really helping the community :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants