Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_url returns different urls calling twice (bug #506) #507

Merged
merged 12 commits into from
Jul 7, 2019
2 changes: 2 additions & 0 deletions bandit/core/docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def get_url(bid):
if info['id'].startswith('B3'): # B3XX
# Some of the links are combined, so we have exception cases
if info['id'] in ['B304', 'B305']:
info = info.copy()
info['id'] = 'b304-b305'
info['name'] = 'ciphers-and-modes'
elif info['id'] in ['B313', 'B314', 'B315', 'B316', 'B317',
'B318', 'B319', 'B320']:
info = info.copy()
info['id'] = 'b313-b320'
ext = template.format(
kind='calls', id=info['id'], name=info['name'])
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/core/test_docs_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2019 Victor Torre
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import testtools

from bandit.core.docs_utils import BASE_URL
from bandit.core.docs_utils import get_url


class DocsUtilTests(testtools.TestCase):
'''This set of tests exercises bandit.core.docs_util functions.'''

def test_overwrite_bib_info(self):
expected_url = BASE_URL + ("blacklists/blacklist_calls.html"
"#b304-b305-ciphers-and-modes")
self.assertEqual(get_url('B304'), get_url('B305'))
self.assertEqual(expected_url, get_url('B304'))

def test_plugin_call_bib(self):
expected_url = BASE_URL + "plugins/b101_assert_used.html"
self.assertEqual(expected_url, get_url('B101'))

def test_import_call_bib(self):
expected_url = BASE_URL + ("blacklists/blacklist_imports.html"
"#b413-import-pycrypto")
self.assertEqual(expected_url, get_url('B413'))