|
96 | 96 | end |
97 | 97 | end |
98 | 98 |
|
| 99 | + describe '#check_plugin_version_from_changelog' do |
| 100 | + let(:body) do |
| 101 | + '== Change Log == |
| 102 | +
|
| 103 | + = 1.2 = |
| 104 | + * 1.2 notes |
| 105 | +
|
| 106 | + = 1.1 = |
| 107 | + * 1.1 notes |
| 108 | +
|
| 109 | + = 1.0 = |
| 110 | + * First release.' |
| 111 | + end |
| 112 | + |
| 113 | + context 'when all versions of the plugin are vulnerable' do |
| 114 | + it 'returns :vulnerable' do |
| 115 | + expect(subject.check_plugin_version_from_changelog('a', 'a')).to eq :vulnerable |
| 116 | + end |
| 117 | + end |
| 118 | + |
| 119 | + context 'when all versions after a specific version are vulnerable' do |
| 120 | + it 'returns :vulnerable if the version is later than introduced' do |
| 121 | + introduced = '1.0' |
| 122 | + state = subject.check_plugin_version_from_changelog('a', 'a', nil, introduced) |
| 123 | + expect(state).to eq :vulnerable |
| 124 | + end |
| 125 | + |
| 126 | + it 'returns :safe if the version is earlier than introduced' do |
| 127 | + introduced = '1.3' |
| 128 | + state = subject.check_plugin_version_from_changelog('a', 'a', nil, introduced) |
| 129 | + expect(state).to eq :safe |
| 130 | + end |
| 131 | + |
| 132 | + it 'returns :vulnerable if the version is the same as introduced' do |
| 133 | + introduced = '1.2' |
| 134 | + state = subject.check_plugin_version_from_changelog('a', 'a', nil, introduced) |
| 135 | + expect(state).to eq :vulnerable |
| 136 | + end |
| 137 | + end |
| 138 | + |
| 139 | + context 'when a specifc range of versions are vulnerable' do |
| 140 | + it 'returns :vulnerable if the version is in the vulnerable range' do |
| 141 | + state = subject.check_plugin_version_from_changelog('a', 'a', '2.0', '1.0') |
| 142 | + expect(state).to eq :vulnerable |
| 143 | + |
| 144 | + state = subject.check_plugin_version_from_changelog('a', 'a', '2.0', '1.2') |
| 145 | + expect(state).to eq :vulnerable |
| 146 | + end |
| 147 | + |
| 148 | + it 'returns :safe if the version is outside the vulnerable range' do |
| 149 | + state = subject.check_plugin_version_from_changelog('a', 'a', nil, '1.3') |
| 150 | + expect(state).to eq :safe |
| 151 | + |
| 152 | + state = subject.check_plugin_version_from_changelog('a', 'a', '1.2', '1.0') |
| 153 | + expect(state).to eq :safe |
| 154 | + end |
| 155 | + end |
| 156 | + end |
| 157 | + |
99 | 158 | describe '#check_theme_version_from_readme' do |
100 | 159 | let(:body) do |
101 | 160 | 'Requires at least: 3.1 |
|
0 commit comments