Skip to content

Commit

Permalink
Land #177, update module name validation to include payload and evasi…
Browse files Browse the repository at this point in the history
…on modules
  • Loading branch information
adfoster-r7 authored Jan 4, 2024
2 parents ee504d5 + ae1bcbe commit f4e1494
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/metasploit/credential/origin/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Metasploit::Credential::Origin::Service < ApplicationRecord
#

# Regular expression that matches any `Mdm::Module::Detail#fullname` for {#module_full_name} where
# `Mdm::Module::Detail#mtype` is `'auxiliary'` or `'exploit'` and the remainder is a valid
# `Mdm::Module::Detail#mtype` is the module type, e.g. `'auxiliary'` or `'exploit'`, and the remainder is a valid
# `Mdm::Module::Detail#refname` (it does not contain a `'\'` and is lower case alphanumeric).
MODULE_FULL_NAME_REGEXP = /\A(?<module_type>auxiliary|exploit|post)\/(?<reference_name>[\-0-9A-Z_a-z]+(?:\/[\-0-9A-Z_a-z]+)*)\Z/
MODULE_FULL_NAME_REGEXP = /\A(?<module_type>auxiliary|evasion|exploit|payload|post)\/(?<reference_name>[\-0-9A-Z_a-z]+(?:\/[\-0-9A-Z_a-z]+)*)\Z/

#
# Associations
Expand Down
12 changes: 11 additions & 1 deletion spec/models/metasploit/credential/origin/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@
end
end

context 'with evasion' do
let(:module_type) do
'evasion'
end

it 'allows value' do
expect(service_origin).to allow_value(module_full_name).for(:module_full_name)
end
end

context 'with exploit' do
let(:module_type) do
'exploit'
Expand All @@ -108,7 +118,7 @@
end

it 'allows value' do
expect(service_origin).not_to allow_value(module_full_name).for(:module_full_name)
expect(service_origin).to allow_value(module_full_name).for(:module_full_name)
end
end

Expand Down

0 comments on commit f4e1494

Please sign in to comment.