Skip to content

Commit

Permalink
Merge branch 'master' into exit_zero
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejstromich committed Jul 18, 2019
2 parents c508058 + 610b800 commit 0d1d284
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
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'))

0 comments on commit 0d1d284

Please sign in to comment.