Skip to content

fix: Update package vulnerability scanner to handle breaking PPM change#335

Merged
juleswg23 merged 8 commits intomainfrom
juleswg-package-vulnerability-scanner
Apr 15, 2026
Merged

fix: Update package vulnerability scanner to handle breaking PPM change#335
juleswg23 merged 8 commits intomainfrom
juleswg-package-vulnerability-scanner

Conversation

@juleswg23
Copy link
Copy Markdown
Collaborator

We handle the new PPM endpoint in the Package vulnerability scanner after /repos/{repo}/vulns was removed in favor of /filter/packages.

https://packagemanager.posit.co/__docs__/news/package-manager/#breaking

To test this, deploy an app that imports one of the vulnerable packages, such as beaker. The new scanner will display the vulnerability.

(Note that when deploying with Publisher, you will need to build the frontend with npm run build and include dist/ in the bundle.)

You should see:
image

closes #334

@jonkeane jonkeane requested a review from dotNomad April 10, 2026 21:12
Comment on lines -33 to +47
async with httpx.AsyncClient() as client:
url = f"https://packagemanager.posit.co/__api__/repos/{repo}/vulns"
response = await client.get(url)
async with httpx.AsyncClient() as http:
url = "https://packagemanager.posit.co/__api__/filter/packages"
payload = {
"repo": repo,
"has_vulns": True,
"omit_downloads": True,
"omit_dependencies": True,
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is https://packagemanager.posit.co/__api__/filter/packages new or has it always been available? If it's new and we were using https://packagemanager.posit.co/__api__/repos/{repo}/vulns because it existed before the new one, then maybe we need to actually use the new one and if that doesn't work fall back to the old one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter/packages is not that new (created in the 2024.11 release), but I'm not sure how that compares to when the code for the package vulnerability scanner was written.

I don't think we can fall back since https://packagemanager.posit.co/__api__/repos/{repo}/vulns doesn't exist anymore (unless I am overlooking something).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can fall back since https://packagemanager.posit.co/__api__/repos/{repo}/vulns doesn't exist anymore (unless I am overlooking something).

This would be fallen back to if https://packagemanager.posit.co/__api__/filter/packages didn't (yet) exist or doesn't have the vulnerability params. The fallback is for users who might have a version of PPM that doesn't have filter/packages (or filter/packages doesn't yet accept the params we are sending).

@jstruzik do you know the history here? Is there a period of time where PPM's filter/packages doesn't support only returning vulnerable pacakges, but it did have repos/{repo}/vulns for that info?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption was based on the URL in the example app being hardcoded to point to the public Posit Package Manager, not a user's PPM instance. In the customer case where I encountered breaking it was because they were doing just that.

But in the case that someone has customized their package vulnerability scanner to point to their own PPM instance, I understand why the fallback would be relevant.

The has_vulns query param is indeed new to the April 9th 2026 release, but there was a vulns parameter that predated it, I'm not sure how far back.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, sorry yeah if this is PPPM, it will be up to date, so that should be ok for the extension — maybe a comment in the code there about the release version and if someone is using this code against their own instance they might need to be more careful?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonkeane ah sorry I missed this. There was a thread brought up about this change in https://positpbc.slack.com/archives/C6FBRF2V7/p1776098199483349

The tldr is that we removed the /repos/{repos}/vulns endpoint due to sizing constraints. We're actively discussing if https://github.com/rstudio/package-manager/issues/17690 makes sense to temporarily add back the functionality (perhaps with pagination or streaming)

The /filters/packages endpoint should have supported vulns for awhile now

Comment on lines +41 to +53
# This fetches vulnerabilities from the public Posit Package Manager,
# which is always up to date. If customizing this to reference your
# own PPM instance, note that the has_vulns parameter requires
# PPM 2026.04 or later. Older versions may need to use the vulns
# parameter instead, or the legacy endpoint:
#
# url = f"https://your-ppm-instance/__api__/repos/{repo}/vulns"
# response = await http.get(url)
# return repo, response.json()
#
# tasks = [fetch_repo_vulns(repo) for repo in repositories]
# for repo, data in await asyncio.gather(*tasks):
# results[repo] = data
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonkeane What do you think about this as a solution to the other thread? I'm amendable to not leaving the old code and letting people sort that out on their own.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that works!

Copy link
Copy Markdown
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick check of the API docs shows that POST /__api__/filter/packages is utilizing a similar shape 👌

It looks like you are handling the newline-delimited JSON well here too.

@juleswg23
Copy link
Copy Markdown
Collaborator Author

I've held off on merging this because PPM looks like it will restore the old endpoint imminently.

@jonkeane
Copy link
Copy Markdown
Collaborator

I've held off on merging this because PPM looks like it will restore the old endpoint imminently.

Should we though? Why wait?

@juleswg23
Copy link
Copy Markdown
Collaborator Author

juleswg23 commented Apr 15, 2026

Should we though? Why wait?

I guess I assumed it was inherently preferable to fetch from the original endpoint, otherwise we would have been grabbing from /__api__/filter/packages all along.

I think the difference is negligible since the length of the response of /__api__/filter/packages is never going to be too large though, so merging now.

@juleswg23 juleswg23 merged commit 359a930 into main Apr 15, 2026
21 checks passed
@juleswg23 juleswg23 deleted the juleswg-package-vulnerability-scanner branch April 15, 2026 18:57
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.

PPM change to endpoint breaks the Package Vulnerability Scanner

4 participants