Skip to content

Commit b903e1f

Browse files
committed
Add OSV (Open Source Vulnerabilities) reference type support
1 parent b270f30 commit b903e1f

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

lib/msf/core/module/reference.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def initialize(in_ctx_id = 'Unknown', in_ctx_val = '', in_ctx_repo = nil)
131131
else
132132
self.site = "https://github.com/advisories/#{ghsa_id}"
133133
end
134+
elsif in_ctx_id == 'OSV'
135+
self.site = "https://osv.dev/vulnerability/#{in_ctx_val}"
134136
elsif in_ctx_id == 'URL'
135137
self.site = in_ctx_val.to_s
136138
elsif in_ctx_id == 'LOGO'

spec/module_validation_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@
125125

126126
it 'has errors' do
127127
expect(subject.errors.full_messages).to eq [
128-
"References url is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]",
129-
"References FOO is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]",
128+
"References url is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"OSV\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]",
129+
"References FOO is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"OSV\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]",
130130
"References NOCVE please include NOCVE values in the 'notes' section, rather than in 'references'",
131131
"References AKA please include AKA values in the 'notes' section, rather than in 'references'",
132-
"References ATTACK is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]"
132+
"References ATTACK is not valid, must be in [\"ATT&CK\", \"CVE\", \"CWE\", \"BID\", \"MSB\", \"EDB\", \"GHSA\", \"OSV\", \"US-CERT-VU\", \"ZDI\", \"URL\", \"WPVDB\", \"PACKETSTORM\", \"LOGO\", \"SOUNDTRACK\", \"OSVDB\", \"VTS\", \"OVE\"]"
133133
]
134134
end
135135
end

spec/support/lib/module_validation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def initialize(mod)
9292
MSB
9393
EDB
9494
GHSA
95+
OSV
9596
US-CERT-VU
9697
ZDI
9798
URL

tools/dev/msftidy.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ def check_ref_identifiers
277277
ghsa_pattern = /^(?:GHSA-)?[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}$/i
278278
warn("Invalid GHSA reference") if value !~ ghsa_pattern
279279
# No specific validation for repo format yet, as it's an optional string
280+
when 'OSV'
281+
# OSV format: ECOSYSTEM-YEAR-ID (e.g., GO-2021-0113, PYSEC-2024-123)
282+
osv_pattern = /^[A-Z]+-\d{4}-[A-Z0-9-]+$/i
283+
warn("Invalid OSV reference") if value !~ osv_pattern
280284
when 'URL'
281285
if value =~ /^https?:\/\/cvedetails\.com\/cve/
282286
warn("Please use 'CVE' for '#{value}'")
@@ -298,6 +302,8 @@ def check_ref_identifiers
298302
warn("Please use 'PACKETSTORM' for '#{value}'")
299303
elsif value =~ /^https?:\/\/github\.com\/(?:advisories|[\w\-]+\/[\w\-]+\/security\/advisories)\/GHSA-/
300304
warn("Please use 'GHSA' for '#{value}'")
305+
elsif value =~ /^https?:\/\/osv\.dev\/vulnerability\//
306+
warn("Please use 'OSV' for '#{value}'")
301307
end
302308
when 'AKA'
303309
warn("Please include AKA values in the 'notes' section, rather than in 'references'.")

tools/modules/module_missing_reference.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def types
2525
'WPVDB',
2626
'PACKETSTORM',
2727
'GHSA',
28+
'OSV',
2829
'URL'
2930
]
3031
end

tools/modules/module_reference.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def types
3535
'WPVDB' => 'https://wpscan.com/vulnerability/#{in_ctx_val}',
3636
'PACKETSTORM' => 'https://packetstormsecurity.com/files/#{in_ctx_val}',
3737
'GHSA' => 'https://github.com/advisories/#{in_ctx_val}',
38+
'OSV' => 'https://osv.dev/vulnerability/#{in_ctx_val}',
3839
'URL' => '#{in_ctx_val}'
3940
}
4041
end

0 commit comments

Comments
 (0)