Skip to content

Commit

Permalink
fixed is new alert logic
Browse files Browse the repository at this point in the history
  • Loading branch information
naarok committed Feb 8, 2023
1 parent 30a4ae0 commit dbdb84f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
1.4.0
Added Slack notifications on new Dependabot issues
Added equations to handle notes for non-CVEs

1.4.1
Fixed to use created_at date for finding new alerts
5 changes: 2 additions & 3 deletions lib/library_version_analysis/check_version_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module LibraryVersionAnalysis
:minor,
:patch,
:age,
:dependabot_published_at,
:dependabot_created_at,
:dependabot_permalink,
keyword_init: true
)
Expand Down Expand Up @@ -178,8 +178,7 @@ def notify(results)

results.each do |hash_line|
line = hash_line[1]

if (!line.dependabot_published_at.nil? && line.dependabot_published_at > recent_time )
if (!line.dependabot_created_at.nil? && line.dependabot_created_at > recent_time )
message = ":warning: NEW Dependabot alert! :warning:\n\nPackage: #{hash_line[0]}\n#{line.cvss}\n\nOwned by #{line.owner}\n#{line.dependabot_permalink}"
SlackNotify.notify(message, "security-alerts")
end
Expand Down
8 changes: 4 additions & 4 deletions lib/library_version_analysis/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def get_dependabot_findings(parsed_results, meta_data, github_name, ecosystem)

alerts.each do |_, alert|
package = alert[:package]

cvss = "#{alert[:severity]} #{alert[:identifiers]}"
if parsed_results.has_key?(package)
parsed_results[package].cvss = cvss
Expand All @@ -93,13 +92,14 @@ def get_dependabot_findings(parsed_results, meta_data, github_name, ecosystem)
patch: 0,
age: 0,
cvss: cvss,
dependabot_published_at: Time.parse(alert[:published_at]),
dependabot_permalink: alert[:permalink]
)

parsed_results[package] = vv
end

parsed_results[package].dependabot_created_at = Time.parse(alert[:created_at])
parsed_results[package].dependabot_permalink = alert[:permalink]

meta_data.total_cvss = meta_data.total_cvss + 1
end
end
Expand Down Expand Up @@ -132,7 +132,7 @@ def add_results(alerts, results, target_ecosystem)
package: alert.security_vulnerability.package.name,
identifiers: alert.security_vulnerability.advisory.identifiers.map(&:value),
severity: alert.security_vulnerability.severity,
published_at: alert.security_vulnerability.advisory.published_at,
created_at: alert.created_at,
permalink: alert.security_vulnerability.advisory.permalink
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/library_version_analysis/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LibraryVersionAnalysis
VERSION = "1.4.0".freeze
VERSION = "1.4.1".freeze
end

0 comments on commit dbdb84f

Please sign in to comment.