@@ -15,8 +15,8 @@ class GitHubAdvisorySync
1515 # The min_year argument specifies the earliest year CVE to sync.
1616 # It is more important to sync the newer ones, so this allows the user to
1717 # control how old of CVEs the sync should pull over
18- def self . sync ( min_year : 2015 )
19- gh_advisories = GraphQLAPIClient . new . all_rubygem_advisories
18+ def self . sync ( min_year : 2015 , gem_name : nil )
19+ gh_advisories = GraphQLAPIClient . new . all_rubygem_advisories ( gem_name : gem_name )
2020
2121 # Filter out advisories with a CVE year that is before the min_year
2222 gh_advisories . select! { |v | v . cve_after_year? ( min_year ) }
@@ -89,10 +89,10 @@ def github_graphql_query(graphql_query_name, graphql_variables = {})
8989 body_obj
9090 end
9191
92- def all_rubygem_advisories
92+ def all_rubygem_advisories ( gem_name : nil )
9393 advisories = { }
9494
95- retrieve_all_rubygem_vulnerabilities . each do |vulnerability |
95+ retrieve_all_rubygem_vulnerabilities ( gem_name : gem_name ) . each do |vulnerability |
9696 advisory = GitHubAdvisory . new ( vulnerability [ "advisory" ] )
9797
9898 next if advisory . withdrawn?
@@ -105,9 +105,9 @@ def all_rubygem_advisories
105105 advisories . values
106106 end
107107
108- def retrieve_all_rubygem_vulnerabilities ( max_pages = 1000 , page_size = 100 )
108+ def retrieve_all_rubygem_vulnerabilities ( max_pages = 1000 , page_size = 100 , gem_name : nil )
109109 all_vulnerabilities = [ ]
110- variables = { "first" => page_size }
110+ variables = { "first" => page_size , "gem_name" => gem_name }
111111 max_pages . times do |page_num |
112112 puts "Getting page #{ page_num + 1 } of GitHub Vulnerabilities"
113113
@@ -126,8 +126,8 @@ def retrieve_all_rubygem_vulnerabilities(max_pages = 1000, page_size = 100)
126126
127127 module GraphQLQueries
128128 RUBYGEM_VULNERABILITIES_WITH_GITHUB_ADVISORIES = <<-GRAPHQL . freeze
129- query($first: Int, $after: String) {
130- securityVulnerabilities(first: $first, after: $after, ecosystem:RUBYGEMS) {
129+ query($first: Int, $after: String, $gem_name: String ) {
130+ securityVulnerabilities(first: $first, after: $after, ecosystem:RUBYGEMS, package: $gem_name ) {
131131 pageInfo {
132132 endCursor
133133 hasNextPage
0 commit comments