从API获取Nuget软件包漏洞信息

发布于 2025-01-27 17:51:25 字数 400 浏览 2 评论 0原文

我们一直在寻找可以扫描代码中有脆弱性或已弃用的Nuget软件包的方法。

我们已经考虑使用dotnet列表包 - Vulnerable,但这似乎对我们的Xamarin项目表现不佳。它引发了与缺少项目导入的错误有关的错误,我们还没有找到一种方法来忽略错误的工具。

我认为问题与此相关: https://github.com/nuget.com/nuget/home/home/issues/issues/issues /9035

是否可以通过调用Nuget API来复制CLI工具正在做什么?

We have been looking at ways that we can scan our code for NuGet packages that have vulnerabilities or are deprecated.

We have looked into using dotnet list package --vulnerable but this doesn't seem to be playing nicely with our Xamarin projects. It throws errors relating to missing project imports and we haven't found a way to get the tools to ignore the errors.

I think the issue is related to this: https://github.com/NuGet/Home/issues/9035

Is it possible to replicate what the CLI tool is doing by calling NuGet APIs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

快乐很简单 2025-02-03 17:51:25

对于我们使用packages.config(dotnet list不支持),我必须检查一下,这是我写的powershell函数,在我的情况下它有所帮助:

function Check-Package()
{
    param([string]$id ,[string]$version)
    $packages = Invoke-RestMethod "https://azuresearch-usnc.nuget.org/query?q=$id"
    $packageDetailsUrl = $packages.data | ? { $_.id -eq $id} | %{ $_.versions } |  ?{$_.version -eq $version } | %{ $_."@id"}
    if($packageDetailsUrl)
    {
        $packageDetails = Invoke-RestMethod $packageDetailsUrl
        
        $packageSuperDetails = Invoke-RestMethod $packageDetails.catalogEntry
        if($packageSuperDetails.vulnerabilities -or $packageSuperDetails.deprecation)
        {
            if($packageSuperDetails.deprecation)
            {
                $deprectaion = "is deprecated"
            }

            if($packageSuperDetails.vulnerabilities)
            {
                $vulnerability = "has vulnerabilities"
            }
            Write-Host $id $version $deprectaion $vulnerability
        }
    }
    else
    {
        Write-Host $id $version no longer listed on nuget.org
    }
}

我使用它:

nuget list -source。\ packages \ | %{check -package -id $_。split(“”)[0] - version $_。split(“”)[1]

I have had to check that for an old project of ours that was using packages.config (not supported by dotnet list) This is a powershell function that I have written and it helped in my case:

function Check-Package()
{
    param([string]$id ,[string]$version)
    $packages = Invoke-RestMethod "https://azuresearch-usnc.nuget.org/query?q=$id"
    $packageDetailsUrl = $packages.data | ? { $_.id -eq $id} | %{ $_.versions } |  ?{$_.version -eq $version } | %{ $_."@id"}
    if($packageDetailsUrl)
    {
        $packageDetails = Invoke-RestMethod $packageDetailsUrl
        
        $packageSuperDetails = Invoke-RestMethod $packageDetails.catalogEntry
        if($packageSuperDetails.vulnerabilities -or $packageSuperDetails.deprecation)
        {
            if($packageSuperDetails.deprecation)
            {
                $deprectaion = "is deprecated"
            }

            if($packageSuperDetails.vulnerabilities)
            {
                $vulnerability = "has vulnerabilities"
            }
            Write-Host $id $version $deprectaion $vulnerability
        }
    }
    else
    {
        Write-Host $id $version no longer listed on nuget.org
    }
}

I use it like that:

nuget list -source .\packages\ | %{Check-Package -id $_.Split(" ")[0] -version $_.Split(" ")[1]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文