Skip to content

feat(cooldown): respect trusted_packages in dependency cooldown#342

Merged
abhisek merged 15 commits into
mainfrom
dep-cooldown-respect-trusted-pkgs
Jun 21, 2026
Merged

feat(cooldown): respect trusted_packages in dependency cooldown#342
abhisek merged 15 commits into
mainfrom
dep-cooldown-respect-trusted-pkgs

Conversation

@Sahilb315

Copy link
Copy Markdown
Contributor

Summary

  • Treat the top-level trusted_packages list as a superset waiver: a trusted package now bypasses every PMG control — malware analysis, dependency cooldown, and any future controls — without needing a duplicate entry in dependency_cooldown.skip.
  • dependency_cooldown.skip keeps its existing role as the narrower, cooldown-only waiver (still subject to malware analysis).
  • Updated docs/dependency-cooldown.md, docs/trusted-packages.md, the config template, and the DependencyCooldownConfig.Skip doc comment to reflect the new model.
  • Tests updated: previous "independence" test replaced with TestCooldownSkipRespectsTrustedPackages covering the union behavior for both version-less and version-pinned trusted entries.

@safedep

safedep Bot commented Jun 15, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

Package Details
Package Malware Vulnerability Risky License Report
icon buf.build/gen/go/safedep/api/connectrpc/go @ v1.20.0-20260618082119-01127207dee4.1
go.mod
ok icon
ok icon
ok icon
🔗
icon buf.build/gen/go/safedep/api/protocolbuffers/go @ v1.36.11-20260618082119-01127207dee4.1
go.mod
ok icon
ok icon
ok icon
🔗

View complete scan results →

This report is generated by SafeDep Github App

@codecov-commenter

codecov-commenter commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.41237% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.18%. Comparing base (c17b941) to head (52d61cf).

Files with missing lines Patch % Lines
proxy/interceptors/cooldown.go 65.21% 7 Missing and 1 partial ⚠️
config/trusted.go 75.00% 2 Missing and 1 partial ⚠️
internal/audit/audit.go 89.47% 2 Missing ⚠️
proxy/interceptors/npm_cooldown.go 71.42% 1 Missing and 1 partial ⚠️
proxy/interceptors/pypi_cooldown.go 75.00% 1 Missing and 1 partial ⚠️
proxy/interceptors/npm_registry.go 75.00% 0 Missing and 1 partial ⚠️
proxy/interceptors/pypi_registry.go 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #342      +/-   ##
==========================================
+ Coverage   54.13%   54.18%   +0.04%     
==========================================
  Files         180      180              
  Lines       12844    12903      +59     
==========================================
+ Hits         6953     6991      +38     
- Misses       5225     5248      +23     
+ Partials      666      664       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread config/trusted.go Outdated
Comment thread config/trusted.go Outdated
Comment thread config/trusted.go
Sahilb315 added a commit that referenced this pull request Jun 15, 2026
Address review feedback on #342:

- Restore cooldownSkip to a pure single-list function (SRP); the merge
  into trusted_packages now happens in a separate mergeCooldownSkip step,
  driven by the exported CooldownSkip wrapper.
- Extend CooldownSkipInfo with a CooldownSkipReason (TrustedPackage /
  CooldownSkipList) on both SkipAll and per-version entries, so callers
  can tell apart the broad waiver from the cooldown-only one. When both
  lists match the same package, trusted_packages wins.
- Add audit.LogCooldownSkipped and emit it from the npm and PyPI
  interceptors on the SkipAll path, alongside the existing info log,
  carrying the source list as the reason.
Comment thread internal/audit/audit.go Outdated
Trusted packages are now treated as a superset waiver that bypasses every
PMG control (malware analysis, cooldown, and any future controls). A
globally trusted package is automatically exempt from the cooldown window
and no longer needs a duplicate entry in dependency_cooldown.skip.

The skip list remains the narrower, cooldown-only waiver for packages
that must bypass the cooldown wait but still be malware-scanned.
Address review feedback on #342:

- Restore cooldownSkip to a pure single-list function (SRP); the merge
  into trusted_packages now happens in a separate mergeCooldownSkip step,
  driven by the exported CooldownSkip wrapper.
- Extend CooldownSkipInfo with a CooldownSkipReason (TrustedPackage /
  CooldownSkipList) on both SkipAll and per-version entries, so callers
  can tell apart the broad waiver from the cooldown-only one. When both
  lists match the same package, trusted_packages wins.
- Add audit.LogCooldownSkipped and emit it from the npm and PyPI
  interceptors on the SkipAll path, alongside the existing info log,
  carrying the source list as the reason.
Address further review feedback:

- Drop the separate mergeCooldownSkip helper; cooldownSkip now writes
  into a shared *CooldownSkipInfo and is called twice from CooldownSkip
  (cooldown skip list first, trusted_packages on top so trusted entries
  override the reason on overlap).
- Audit log every exemption, not just SkipAll: a new auditCooldownSkip
  helper in proxy/interceptors/cooldown.go emits one event per match
  (package-wide or per-version), each tagged with its source list.
  LogCooldownSkipped gains a version argument for the per-version case.
- Cover the trusted_packages reason path in TestCooldownSkip.
auditCooldownSkip now only emits EventTypeCooldownSkipped for entries
that came from dependency_cooldown.skip. Trusted-package exemptions
already get an EventTypeInstallTrustedAllowed event at tarball-download
time (proxy/interceptors/base_registry.go), so emitting a cooldown event
for them too would double-count the same waiver.
@Sahilb315 Sahilb315 force-pushed the dep-cooldown-respect-trusted-pkgs branch from b3059e7 to f3beb49 Compare June 18, 2026 09:22
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

vet Summary Report

This report is generated by vet

Policy Checks

  • ✅ Vulnerability
  • ✅ Malware
  • ✅ License
  • ✅ Popularity
  • ✅ Maintenance
  • ✅ Security Posture
  • ✅ Threats

Malicious Package Analysis

Malicious package analysis was performed using SafeDep Cloud API

Malicious Package Analysis Report
Ecosystem Package Version Status Report
  • ℹ️ 0 packages have been actively analyzed for malicious behaviour.
  • ✅ No malicious packages found.

Note: Some of the package analysis jobs may still be running.Please check back later. Consider increasing the timeout for better coverage.

Changed Packages

Changed Packages

  • ✅ [Go] buf.build/gen/go/safedep/api/connectrpc/go@1.20.0-20260618082119-01127207dee4.1
  • ✅ [Go] buf.build/gen/go/safedep/api/protocolbuffers/go@1.36.11-20260618082119-01127207dee4.1

Comment thread config/trusted.go Outdated
Comment thread config/trusted.go Outdated
…uit on trusted SkipAll

Address PR review feedback:
- Rename cooldownSkip to collectCooldownSkip and return CooldownSkipInfo
  instead of mutating an input pointer.
- Add mergeCooldownSkip to combine per-list results with trusted_packages
  taking precedence on overlap.
- CooldownSkip now consults trusted_packages first and returns immediately
  on a package-wide trusted exemption (DC skip list cannot add anything).
- Extend tests to cover disjoint pinned entries across both lists and the
  case where DC version-less subsumes a trusted pinned entry.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates PMG’s dependency cooldown waiver model so the global trusted_packages list acts as a superset exemption (bypassing cooldown and other controls), while dependency_cooldown.skip remains a cooldown-only exemption. It also adds audit visibility for cooldown exemptions and updates docs/templates to match the new semantics.

Changes:

  • Extend cooldown skip resolution to union trusted_packages + dependency_cooldown.skip, tagging the exemption source.
  • Emit a new audit event for cooldown exemptions coming specifically from dependency_cooldown.skip, and translate it to a ControlTower package decision action.
  • Update documentation, config template/comments, and tests to reflect the new waiver model.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
proxy/interceptors/pypi_registry.go Uses updated cooldown skip info (version set) and audits cooldown-skip exemptions.
proxy/interceptors/npm_registry.go Uses updated cooldown skip info (version set) and audits cooldown-skip exemptions.
proxy/interceptors/cooldown.go Adds auditCooldownSkip helper to log/audit cooldown exemptions sourced from dependency_cooldown.skip.
internal/audit/event.go Introduces new audit event type dependency_cooldown_skipped.
internal/audit/cloud_translate.go Translates cooldown-skipped audit events into ControlTower package decision actions.
internal/audit/cloud_translate_test.go Adjusts unsupported-event coverage list for translation tests.
internal/audit/audit.go Adds LogCooldownSkipped audit API for cooldown exemption events.
config/trusted.go Implements union behavior and source-tagging for cooldown exemptions across trusted and cooldown-skip lists.
config/cooldown_skip_test.go Reworks tests to validate trusted-packages superset behavior and reason tagging.
config/config.template.yml Updates template guidance to describe trusted vs per-control cooldown skip behavior.
config/config.go Updates DependencyCooldownConfig.Skip doc comment to reflect new model.
docs/trusted-packages.md Documents trusted packages as a global waiver (including cooldown).
docs/dependency-cooldown.md Updates cooldown docs to describe trusted_packages as superset waiver and skip list as per-control.
go.mod Bumps safedep protocolbuffers module version; adds connectrpc module indirectly.
go.sum Adds sums for updated/added generated modules.
go.work.sum Adds sums for new/updated workspace dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/audit/audit.go Outdated
Comment thread internal/audit/cloud_translate.go
Comment thread proxy/interceptors/pypi_registry.go Outdated
Comment thread proxy/interceptors/cooldown.go Outdated
Comment thread internal/audit/event.go
Comment thread internal/audit/audit.go Outdated
…rsion

Backend rejects PackageVersion messages without a version, and audit logs
should reflect the runtime fact (a specific version was skipped) rather
than the config rule. Move the audit emission from metadata-request
handling to download-request handling, where the concrete version is
known, and require version in LogCooldownSkipped.
Comment thread internal/audit/audit.go Outdated
Comment thread proxy/interceptors/pypi_registry.go
Comment thread proxy/interceptors/npm_registry.go
Comment thread proxy/interceptors/npm_registry.go Outdated
Registry interceptors no longer compute CooldownSkip or branch on SkipAll;
they just call HandleMetadataRequest. The npm and pypi cooldown handlers
own the skip lookup, the package-wide exemption short-circuit, and (for
pypi) the canonical-name denormalization. Also align LogCooldownSkipped
with other LogXxx signatures by taking *packagev1.PackageVersion.
@Sahilb315 Sahilb315 requested a review from abhisek June 19, 2026 16:13
abhisek
abhisek previously approved these changes Jun 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.

Comment thread proxy/interceptors/pypi_registry.go
Comment thread proxy/interceptors/pypi_registry.go
Comment thread proxy/interceptors/npm_registry.go
Comment thread proxy/interceptors/cooldown.go Outdated
@abhisek abhisek merged commit 327c9c7 into main Jun 21, 2026
16 checks passed
@abhisek abhisek deleted the dep-cooldown-respect-trusted-pkgs branch June 21, 2026 12:52
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.

5 participants