Skip to content

Commit

Permalink
Update Trusty API response
Browse files Browse the repository at this point in the history
This commit updates the trusty response type. The main goal is to read the
sigstore provenance data from the new fields but other fields are now added
to keep the types up to date..

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
  • Loading branch information
puerco committed Jul 25, 2024
1 parent 128e30e commit d9c4a7e
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions pkg/types/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,42 @@ import "time"

// Reply is the response from the package report API
type Reply struct {
PackageName string `json:"package_name"`
PackageType string `json:"package_type"`
PackageVersion string `json:"package_version"`
Status string `json:"status"`
Summary ScoreSummary `json:"summary"`
Provenance *Provenance `json:"provenance"`
Activity *Activity `json:"activity"`
Typosquatting *Typosquatting `json:"typosquatting"`
Alternatives AlternativesList `json:"alternatives"`
PackageData PackageData `json:"package_data"`
PackageName string `json:"package_name"`
PackageType string `json:"package_type"`
PackageVersion string `json:"package_version"`
Status string `json:"status"`
Summary ScoreSummary `json:"summary"`
Provenance *Provenance `json:"provenance"`
Activity *Activity `json:"activity"`
Typosquatting *Typosquatting `json:"typosquatting"`
Alternatives AlternativesList `json:"alternatives"`
PackageData PackageData `json:"package_data"`
SameOriginPackagesCount int `json:"same_origin_packages_count"`
}

// Activity captures a package's activity score
type Activity struct {
Score float64 `json:"score"`
Description string `json:"description"`
Score float64 `json:"score"`
Description ActivityDescription `json:"description"`
}

// ActivityDescription captures the fields of the activuty score
type ActivityDescription struct {
Repository float64 `json:"repo"`
User float64 `json:"user"`
// UpdatedAt *time.Time `json:"updated_at"`
}

// Typosquatting score for the package's name
type Typosquatting struct {
Score float64 `json:"score"`
Description string `json:"description"`
Score float64 `json:"score"`
Description TyposquattingDescription `json:"description"`
// UpdatedAt *time.Time `json:"updated_at"`
}

// TyposquattingDescription captures the dat details of the typosquatting score
type TyposquattingDescription struct {
TotalSimilarNames int `json:"total_similar_names"`
}

// Alternative is an alternative package returned from the package intelligence API
Expand Down Expand Up @@ -81,13 +95,13 @@ type MaliciousData struct {
type Provenance struct {
Score float64 `json:"score"`
Description ProvenanceDescription `json:"description"`
// UpdatedAt time.Time `json:"updated_at"`
// UpdatedAt *time.Time `json:"updated_at"`
}

// ProvenanceDescription contians the provenance types
type ProvenanceDescription struct {
Historical HistoricalProvenance `json:"hp"`
Sigstore SigstoreProvenance `json:"provenance"`
Sigstore SigstoreProvenance `json:"sigstore"`
}

// HistoricalProvenance has the historical provenance components from a package
Expand Down

0 comments on commit d9c4a7e

Please sign in to comment.