@@ -440,12 +440,66 @@ class OverridesItsInheritedSoftwareVersions < WithSoftwareVersionsSet
440
440
end
441
441
end
442
442
443
+ describe ".vulnerable_version?" do
444
+ module TestVulnerableVersion
445
+ class TestExploit < Ronin ::Exploits ::Exploit
446
+ software_versions [
447
+ '>= 1.2.3, < 2.0.0' ,
448
+ '>= 2.3.4, < 2.5.1'
449
+ ]
450
+ end
451
+ end
452
+
453
+ let ( :test_class ) { TestVulnerableVersion ::TestExploit }
454
+
455
+ subject { test_class }
456
+
457
+ context "when the given version is within one of the .software_versions ranges" do
458
+ it "must return true" do
459
+ expect ( subject . vulnerable_version? ( '1.4.2' ) ) . to be ( true )
460
+ end
461
+ end
462
+
463
+ context "when the given version is not within any of the .software_versions ranges" do
464
+ it "must return false" do
465
+ expect ( subject . vulnerable_version? ( '3.0.0' ) ) . to be ( false )
466
+ end
467
+ end
468
+ end
469
+
443
470
describe ".exploit_type" do
444
471
subject { described_class }
445
472
446
473
it { expect ( subject . exploit_type ) . to eq ( :exploit ) }
447
474
end
448
475
476
+ describe "#vulnerable_version?" do
477
+ module TestVulnerableVersion
478
+ class TestExploit < Ronin ::Exploits ::Exploit
479
+ software_versions [
480
+ '>= 1.2.3, < 2.0.0' ,
481
+ '>= 2.3.4, < 2.5.1'
482
+ ]
483
+ end
484
+ end
485
+
486
+ let ( :test_class ) { TestVulnerableVersion ::TestExploit }
487
+
488
+ subject { test_class . new }
489
+
490
+ context "when the given version is within one of the .software_versions ranges" do
491
+ it "must return true" do
492
+ expect ( subject . vulnerable_version? ( '1.4.2' ) ) . to be ( true )
493
+ end
494
+ end
495
+
496
+ context "when the given version is not within any of the .software_versions ranges" do
497
+ it "must return false" do
498
+ expect ( subject . vulnerable_version? ( '3.0.0' ) ) . to be ( false )
499
+ end
500
+ end
501
+ end
502
+
449
503
describe "#perform_validate" do
450
504
it "must call #validate_params" do
451
505
expect ( subject ) . to receive ( :validate_params )
0 commit comments