Skip to content

Instantly share code, notes, and snippets.

@ukazap
Last active July 11, 2025 10:21
Show Gist options
  • Select an option

  • Save ukazap/e46ee68549a769ea08448b9f7fbaef2b to your computer and use it in GitHub Desktop.

Select an option

Save ukazap/e46ee68549a769ea08448b9f7fbaef2b to your computer and use it in GitHub Desktop.
Poor man's dependabot (for Ruby)
#!/usr/bin/env ruby
`gem install bundler-audit && bundle audit download`
require 'set'
require 'json'
audit_output = `bundle audit check --format json`
audit_data = JSON.parse(audit_output)
# possible values: none, low, medium, high, critical
intolerable_levels = Set.new(%w[ high critical ])
found_intolerable = false
result = audit_data.fetch('results', []).reduce({}) do |grouped, vuln|
gem_name_and_version = vuln["gem"].values_at("name", "version").join(":")
advisory = vuln["advisory"]
if intolerable_levels.include?(advisory["criticality"])
found_intolerable = true
advisory["intolerable"] = true
end
grouped[gem_name_and_version] ||= Set.new
grouped[gem_name_and_version] << advisory
grouped
end
exit if result.empty?
puts "Found vulnerabilities:"
puts
result.each do |gem, advisories|
puts <<~END
#{gem}
#{"-" * gem.length}
END
advisories.each do |advisory|
puts <<~END
#{advisory["intolerable"] ? "🚨" : "💬"} #{advisory["title"]}
url: #{advisory["url"]}
criticality: #{advisory["criticality"] || "unknown"}
patched versions: #{advisory["patched_versions"]}
END
end
end
exit 1 if found_intolerable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment