Skip to content

Commit

Permalink
Automatically detect the advisory ID from the new exploit path (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Dec 10, 2024
1 parent 1070ace commit 7a9f0a8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/ronin/exploits/cli/commands/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def initialize(**kwargs)
# The path to the new exploit file.
#
def run(file)
infer_advisory_id(file)

@directory = File.dirname(file)
@file_name = File.basename(file,File.extname(file))
@class_name = CommandKit::Inflector.camelize(@file_name)
Expand All @@ -365,6 +367,21 @@ def run(file)
chmod '+x', file
end

#
# Automatically detects the CVE or GHSA ID from the file name.
#
# @param [String] file
# The path to the new exploit file.
#
def infer_advisory_id(file)
path = File.expand_path(file)

if (match = path.match(/CVE-20\d{2}-\d{4,5}|GHSA(?:-[0-9a-z]{4}){3}/))
# ensure the advisory ID is the first advisory listed
@advisories.unshift(match[0])
end
end

#
# Formats a Hash into Ruby keyword arguments.
#
Expand Down

0 comments on commit 7a9f0a8

Please sign in to comment.