Skip to content

Commit

Permalink
Add EPS classification fields to GitHub source model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Dec 3, 2024
1 parent 6e33f05 commit f0e9a6e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/models/sources/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def map_advisories(advisories)
references: advisory[:node][:advisory][:references].map { |r| r[:url] },
source_kind: 'github',
identifiers: advisory[:node][:advisory][:identifiers].map { |i|i[:value] },
epss_percentage: advisory[:node][:advisory][:epss][:percentage],
epss_percentile: advisory[:node][:advisory][:epss][:percentile],

# advisories need to be grouped by uuid and the following fields added together
ecosystem: correct_ecosystem(advisory[:node][:package][:ecosystem]),
Expand Down Expand Up @@ -104,6 +106,10 @@ def fetch_advisories_page(cursor = 'null')
vectorString
}
classification
epss{
percentage
percentile
}
}
firstPatchedVersion {
identifier
Expand Down
5 changes: 5 additions & 0 deletions app/views/advisories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
CVSS vector: <%= @advisory.cvss_vector %><br><br>
<% end %>

<% if @advisory.epss_percentage %>
EPSS Percentage: <%= @advisory.epss_percentage %><br>
EPSS Percentile: <%= @advisory.epss_percentile %><br><br>
<% end %>

Identifiers: <%= @advisory.identifiers.join(', ') %><br>
References:
<ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/v1/advisories/_advisory.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1 @@
json.extract! advisory, :uuid, :url, :title, :description, :origin, :severity, :published_at, :withdrawn_at, :classification, :cvss_score, :cvss_vector, :references, :source_kind, :identifiers, :repository_url, :blast_radius, :packages, :created_at, :updated_at
json.extract! advisory, :uuid, :url, :title, :description, :origin, :severity, :published_at, :withdrawn_at, :classification, :cvss_score, :cvss_vector, :references, :source_kind, :identifiers, :repository_url, :blast_radius, :packages, :created_at, :updated_at, :epss_percentage, :epss_percentile
6 changes: 6 additions & 0 deletions db/migrate/20241203120748_add_epss_to_advisories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddEpssToAdvisories < ActiveRecord::Migration[8.0]
def change
add_column :advisories, :epss_percentage, :float
add_column :advisories, :epss_percentile, :float
end
end
6 changes: 4 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions openapi/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ components:
type: string
updated_at:
type: string
epss_percentage:
type: number
epss_percentile:
type: number
Package:
type: object
properties:
Expand Down

0 comments on commit f0e9a6e

Please sign in to comment.