⏱️ GetSecurityAdvisoriesSince
Fetches security advisories updated since a given time (incremental sync).
When to use
⏱️ For scheduled jobs that incrementally sync an advisory database, avoiding a full pull every time; 🛡️ maintaining a local advisory cache and keeping it fresh; 🔔 triggering alerts: processing only newly added / updated advisories each run.
Signature
go
func (c *ComposerClient) GetSecurityAdvisoriesSince(updatedSince time.Time) (*domain.AdvisoriesResponse, error)Parameters
| Parameter | Type | Description |
|---|---|---|
updatedSince | time.Time | Start time; the SDK takes its Unix timestamp as the updatedSince query parameter |
Return value
| Value | Type | Description |
|---|---|---|
| Result | *domain.AdvisoriesResponse | Advisories is a map[package name][]*Advisory, containing only advisories updated after the given time |
| Error | error | Returned on HTTP failure, non-200 status, or JSON parse failure |
Corresponding endpoint: GET https://packagist.org/api/security-advisories/?updatedSince={timestamp}.
Example
go
package main
import (
"fmt"
"log"
"time"
"github.com/scagogogo/composer-skills/pkg/client"
)
func main() {
c := client.NewComposerClient(30 * time.Second)
// Pull advisories updated in the last 24 hours
since := time.Now().Add(-24 * time.Hour)
resp, err := c.GetSecurityAdvisoriesSince(since)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Packages with advisories updated in the last 24h: %d\n", len(resp.Advisories))
for pkg, advisories := range resp.Advisories {
for _, a := range advisories {
fmt.Printf(" %s: %s (reported at %s)\n", pkg, a.Title, a.ReportedAt)
}
}
}Advanced
Incremental sync recommendation
Persist the "last sync time", pass it as updatedSince on each run, then save the current time as the new cursor after processing the results. Note that advisories may be updated rather than newly added, so use AdvisoryID for idempotency.
- 🔒 For the initial full load, use
GetSecurityAdvisories. - 🎯 To query only specific packages, use
GetSecurityAdvisoriesForPackages.