Repository navigation
ppm: switch vulnerability lookup to filter/packages - #17602
Conversation
The legacy /repos/{repo}/vulns endpoint was removed in Package Manager
2026.04.0 and only restored in 2026.04.1. Migrate to the more general
POST /filter/packages with has_vulns:true, which is the long-term home
for this query.
Addresses #17446.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Review feedbackRan a multi-agent review (code, tests, error handling, comments). Most of this is around silent failures on the new HTTP path; the structural choices (pure parser, mirroring Critical — silent failure paths
Important
Suggestions
Strengths
RecommendationThe structural change is good. Most of the silent-failure paths above existed pre-migration too, but #1 (HTTP status) and #3 (NDJSON error record policy) are arguably new regressions on the netrc path this PR is enabling. Worth addressing those two before merge; the rest can land as follow-ups. |
gtritchie
left a comment
There was a problem hiding this comment.
Overall LGTM, review agent had some concerns that are worth a peek to see if they're worth addressing.
Coerce PWB_PPM_CURL_VERBOSE through isTRUE(as.logical(...)) so a non-boolean value won't error inside the curl handle setup and silently empty the vuln response. When deduping vulnerabilities by id, merge the per-record versions maps so the UI's per-version check still flags every affected installed version.
curl::curl_fetch_memory does not raise on non-2xx, so a 401/403/404/500 would silently feed a non-NDJSON error body to the parser, yield zero vulns, and cache that empty result for the rest of the session. Add an explicit status check, log the cause from both the inner and outer tryCatch handlers, narrow the inner catch to error = identity, and have the parser warn + return NULL on an NDJSON error record (mirroring .rs.ppm.updateMetadataCache) so the caller can skip the cache and retry on the next refresh. Also strip stray \\r before splitting in case a proxy rewrites line endings. Addresses review feedback on #17602.
Add tests covering corners of .rs.ppm.parseVulnerabilityResponse so a future refactor makes a deliberate decision: malformed NDJSON lines are silently skipped (.rs.fromJSON returns NULL); id-less vulns end up in separate slots because R's list[[""]] always reads NULL while each write appends positionally; same-id dedup keeps the first record's fields and only merges the versions map; CRLF line endings parse cleanly thanks to the leading gsub.
Intent
Addresses #17446.
The Packages pane retrieves vulnerability info from Posit Package Manager via
.rs.ppm.getVulnerabilityInformation. That function was calling the legacyGET /repos/{repo}/vulnsendpoint, which was removed in Package Manager2026.04.0(and only restored in2026.04.1). This PR migrates the call to the more generalPOST /filter/packageswithhas_vulns: true, which is the recommended long-term home for this query.Implementation
src/cpp/session/modules/SessionPPM.R:.rs.ppm.getVulnerabilityInformationImplnow POSTs to<root>/__api__/filter/packagesviacurl::curl_fetch_memory, mirroring the pattern already used by.rs.ppm.updateMetadataCachein the same file. Netrc auth, thePWB_PPM_CURL_VERBOSEtoggle, and the per-repoUrlcache are preserved..rs.ppm.parseVulnerabilityResponse(contents)so it can be unit-tested without mocking the HTTP layer.{package -> [vulns]}shape consumed bySessionPackages.cppandPackageVulnerabilityTypes.java) and dedupes by vulnidwithin each package.Tests
New
src/cpp/tests/testthat/test-ppm.Rcovers the parser:vulnsfield skippedvulnsarrays skippednamefield skippedranges,events,versions) preservedTest plan
./rstudio-tests --scope r --filter ppm->[FAIL 0 | PASS 3314]